Mercurial > sat_docs
annotate scripts/minifier/otr/dsa-webworker.js @ 171:a213053a03be
flatpak: update files following names change + Python 3 update:
- `build_manifest.py` has been fixed to work with recent SàT/Libervia
- filenames/scripts have been udpated to reflect project name change
- installation now uses `requirements.txt` when dev version is requested
- there are now 3 types of commands wrapper:
* `libervia_wrapper.py` uses `pb` bridge, starts backend before frontend, and stops it
when frontend is stopped. It's used by `Libervia Desktop` (Cagou)
* `libervia_wrapper-dbus.py` uses `dbus` bridge, starts backend before frontend, and
stops it when frontend is stopped. It's used for `Libervia TUI` (Primitivus)
* `libervia_wrapper-dbus.py` uses `dbus` bridge, starts backend if necessary and
doesn't stop it (to avoid waiting for backend start next time). It's used by
`Libervia CLI` (jp).
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 30 Nov 2021 21:42:06 +0100 |
parents | 1596660ddf72 |
children |
rev | line source |
---|---|
12
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
1 ;(function (root) { |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
2 "use strict"; |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
3 |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
4 root.OTR = {} |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
5 root.DSA = {} |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
6 root.crypto = { |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
7 randomBytes: function () { |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
8 throw new Error("Haven't seeded yet.") |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
9 } |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
10 } |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
11 |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
12 // default imports |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
13 var imports = [ |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
14 'vendor/salsa20.js' |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
15 , 'vendor/bigint.js' |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
16 , 'vendor/crypto.js' |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
17 , 'vendor/eventemitter.js' |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
18 , 'lib/const.js' |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
19 , 'lib/helpers.js' |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
20 , 'lib/dsa.js' |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
21 ] |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
22 |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
23 function sendMsg(type, val) { |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
24 postMessage({ type: type, val: val }) |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
25 } |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
26 |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
27 onmessage = function (e) { |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
28 var data = e.data; |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
29 |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
30 if (data.imports) imports = data.imports |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
31 importScripts.apply(root, imports); |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
32 |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
33 // use salsa20 since there's no prng in webworkers |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
34 var state = new root.Salsa20(data.seed.slice(0, 32), data.seed.slice(32)) |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
35 root.crypto.randomBytes = function (n) { |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
36 return state.getBytes(n) |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
37 } |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
38 |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
39 if (data.debug) sendMsg('debug', 'DSA key creation started') |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
40 var dsa |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
41 try { |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
42 dsa = new root.DSA() |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
43 } catch (e) { |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
44 if (data.debug) sendMsg('debug', e.toString()) |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
45 return |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
46 } |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
47 if (data.debug) sendMsg('debug', 'DSA key creation finished') |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
48 |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
49 sendMsg('data', dsa.packPrivate()) |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
50 } |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
51 |
1596660ddf72
Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
52 }(this)) |