@prosopo/account 2.7.43 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build$colon$cjs.log +29 -7
- package/.turbo/turbo-build$colon$tsc.log +72 -0
- package/.turbo/turbo-build.log +34 -8
- package/CHANGELOG.md +48 -0
- package/dist/cjs/extension/ExtensionWeb2.cjs +9 -2
- package/dist/cjs/workers/CryptoWorkerManager.cjs +147 -0
- package/dist/cjs/workers/cryptoWorker.cjs +27 -0
- package/dist/extension/Extension.d.ts +5 -0
- package/dist/extension/Extension.d.ts.map +1 -0
- package/dist/extension/Extension.js.map +1 -0
- package/dist/extension/ExtensionWeb2.d.ts +9 -0
- package/dist/extension/ExtensionWeb2.d.ts.map +1 -0
- package/dist/extension/ExtensionWeb2.js +9 -2
- package/dist/extension/ExtensionWeb2.js.map +1 -0
- package/dist/extension/ExtensionWeb3.d.ts +7 -0
- package/dist/extension/ExtensionWeb3.d.ts.map +1 -0
- package/dist/extension/ExtensionWeb3.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/workers/CryptoWorkerManager.d.ts +12 -0
- package/dist/workers/CryptoWorkerManager.d.ts.map +1 -0
- package/dist/workers/CryptoWorkerManager.js +147 -0
- package/dist/workers/CryptoWorkerManager.js.map +1 -0
- package/dist/workers/cryptoWorker.d.ts +2 -0
- package/dist/workers/cryptoWorker.d.ts.map +1 -0
- package/dist/workers/cryptoWorker.js +28 -0
- package/dist/workers/cryptoWorker.js.map +1 -0
- package/dist/workers/index.d.ts +2 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +2 -0
- package/dist/workers/index.js.map +1 -0
- package/package.json +11 -10
- package/vite.cjs.config.ts +1 -1
- package/vite.esm.config.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/account@2.
|
|
2
|
+
> @prosopo/account@2.8.0 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -28,13 +28,35 @@ ViteCommonJSConfig: .
|
|
|
28
28
|
[36mvite v6.4.1 [32mbuilding SSR bundle for production...[36m[39m
|
|
29
29
|
Bundle build started
|
|
30
30
|
transforming...
|
|
31
|
+
[33m../../node_modules/@polkadot/x-randomvalues/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
32
|
+
|
|
33
|
+
"/*#__PURE__*/"
|
|
34
|
+
|
|
35
|
+
in "../../node_modules/@polkadot/x-randomvalues/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
36
|
+
[33m../../node_modules/@polkadot/x-textdecoder/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
37
|
+
|
|
38
|
+
"/*#__PURE__*/"
|
|
39
|
+
|
|
40
|
+
in "../../node_modules/@polkadot/x-textdecoder/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
41
|
+
[33m../../node_modules/@polkadot/x-textencoder/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
42
|
+
|
|
43
|
+
"/*#__PURE__*/"
|
|
44
|
+
|
|
45
|
+
in "../../node_modules/@polkadot/x-textencoder/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
46
|
+
[33m../../node_modules/@polkadot/util/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
47
|
+
|
|
48
|
+
"/*#__PURE__*/"
|
|
49
|
+
|
|
50
|
+
in "../../node_modules/@polkadot/util/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
31
51
|
Build end
|
|
32
|
-
[32m✓[39m
|
|
52
|
+
[32m✓[39m 6 modules transformed.
|
|
33
53
|
[33mEntry module "src/extension/ExtensionWeb2.ts" is using named and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.[39m
|
|
34
54
|
[33mEntry module "src/extension/ExtensionWeb3.ts" is using named and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.[39m
|
|
35
55
|
rendering chunks...
|
|
36
|
-
[2mdist/cjs/[22m[36mextension/Extension.cjs
|
|
37
|
-
[2mdist/cjs/[22m[36mindex.cjs
|
|
38
|
-
[2mdist/cjs/[22m[36mextension/ExtensionWeb3.cjs
|
|
39
|
-
[2mdist/cjs/[22m[36mextension/ExtensionWeb2.cjs
|
|
40
|
-
[
|
|
56
|
+
[2mdist/cjs/[22m[36mextension/Extension.cjs [39m[1m[2m 0.14 kB[22m[1m[22m
|
|
57
|
+
[2mdist/cjs/[22m[36mindex.cjs [39m[1m[2m 0.42 kB[22m[1m[22m
|
|
58
|
+
[2mdist/cjs/[22m[36mextension/ExtensionWeb3.cjs [39m[1m[2m 1.31 kB[22m[1m[22m
|
|
59
|
+
[2mdist/cjs/[22m[36mextension/ExtensionWeb2.cjs [39m[1m[2m 3.77 kB[22m[1m[22m
|
|
60
|
+
[2mdist/cjs/[22m[36mworkers/CryptoWorkerManager.cjs [39m[1m[2m 4.50 kB[22m[1m[22m
|
|
61
|
+
[2mdist/cjs/[22m[36mworkers/cryptoWorker.cjs [39m[1m[2m19.63 kB[22m[1m[22m
|
|
62
|
+
[32m✓ built in 1.45s[39m
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
|
|
2
|
+
> @prosopo/account@2.8.0 build:tsc
|
|
3
|
+
> npm run typecheck && npm run build
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> @prosopo/account@2.8.0 typecheck
|
|
7
|
+
> tsc --project tsconfig.types.json
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
> @prosopo/account@2.8.0 build
|
|
11
|
+
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
> @prosopo/account@2.8.0 build:cross-env
|
|
15
|
+
> vite build --config vite.esm.config.ts --mode production
|
|
16
|
+
|
|
17
|
+
ViteEsmConfig: .
|
|
18
|
+
{
|
|
19
|
+
tsConfigPaths: [
|
|
20
|
+
'/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
|
|
21
|
+
'/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
|
|
22
|
+
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
23
|
+
'/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
|
|
24
|
+
'/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
|
|
25
|
+
'/home/runner/work/captcha/captcha/packages/fingerprint/tsconfig.json',
|
|
26
|
+
'/home/runner/work/captcha/captcha/packages/keyring/tsconfig.json'
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
{
|
|
30
|
+
externals: [
|
|
31
|
+
'@prosopo/common',
|
|
32
|
+
'@prosopo/locale',
|
|
33
|
+
'@prosopo/types',
|
|
34
|
+
'@prosopo/util',
|
|
35
|
+
'@prosopo/util-crypto',
|
|
36
|
+
'@prosopo/fingerprint',
|
|
37
|
+
'@prosopo/keyring'
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
[36mvite v6.4.1 [32mbuilding SSR bundle for production...[36m[39m
|
|
41
|
+
Bundle build started
|
|
42
|
+
transforming...
|
|
43
|
+
[33m../../node_modules/@polkadot/x-randomvalues/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
44
|
+
|
|
45
|
+
"/*#__PURE__*/"
|
|
46
|
+
|
|
47
|
+
in "../../node_modules/@polkadot/x-randomvalues/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
48
|
+
[33m../../node_modules/@polkadot/x-textdecoder/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
49
|
+
|
|
50
|
+
"/*#__PURE__*/"
|
|
51
|
+
|
|
52
|
+
in "../../node_modules/@polkadot/x-textdecoder/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
53
|
+
[33m../../node_modules/@polkadot/x-textencoder/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
54
|
+
|
|
55
|
+
"/*#__PURE__*/"
|
|
56
|
+
|
|
57
|
+
in "../../node_modules/@polkadot/x-textencoder/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
58
|
+
[33m../../node_modules/@polkadot/util/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
59
|
+
|
|
60
|
+
"/*#__PURE__*/"
|
|
61
|
+
|
|
62
|
+
in "../../node_modules/@polkadot/util/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
63
|
+
Build end
|
|
64
|
+
[32m✓[39m 6 modules transformed.
|
|
65
|
+
rendering chunks...
|
|
66
|
+
[2mdist/[22m[36mextension/Extension.js [39m[1m[2m 0.04 kB[22m[1m[22m
|
|
67
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m 0.24 kB[22m[1m[22m
|
|
68
|
+
[2mdist/[22m[36mextension/ExtensionWeb3.js [39m[1m[2m 1.11 kB[22m[1m[22m
|
|
69
|
+
[2mdist/[22m[36mextension/ExtensionWeb2.js [39m[1m[2m 2.39 kB[22m[1m[22m
|
|
70
|
+
[2mdist/[22m[36mworkers/CryptoWorkerManager.js [39m[1m[2m 4.36 kB[22m[1m[22m
|
|
71
|
+
[2mdist/[22m[36mworkers/cryptoWorker.js [39m[1m[2m19.64 kB[22m[1m[22m
|
|
72
|
+
[32m✓ built in 1.16s[39m
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/account@2.
|
|
3
|
-
>
|
|
2
|
+
> @prosopo/account@2.8.0 build
|
|
3
|
+
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> @prosopo/account@2.8.0 build:cross-env
|
|
7
|
+
> vite build --config vite.esm.config.ts --mode production
|
|
4
8
|
|
|
5
9
|
ViteEsmConfig: .
|
|
6
10
|
{
|
|
@@ -28,11 +32,33 @@ ViteEsmConfig: .
|
|
|
28
32
|
[36mvite v6.4.1 [32mbuilding SSR bundle for production...[36m[39m
|
|
29
33
|
Bundle build started
|
|
30
34
|
transforming...
|
|
35
|
+
[33m../../node_modules/@polkadot/x-randomvalues/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
36
|
+
|
|
37
|
+
"/*#__PURE__*/"
|
|
38
|
+
|
|
39
|
+
in "../../node_modules/@polkadot/x-randomvalues/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
40
|
+
[33m../../node_modules/@polkadot/x-textdecoder/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
41
|
+
|
|
42
|
+
"/*#__PURE__*/"
|
|
43
|
+
|
|
44
|
+
in "../../node_modules/@polkadot/x-textdecoder/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
45
|
+
[33m../../node_modules/@polkadot/x-textencoder/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
46
|
+
|
|
47
|
+
"/*#__PURE__*/"
|
|
48
|
+
|
|
49
|
+
in "../../node_modules/@polkadot/x-textencoder/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
50
|
+
[33m../../node_modules/@polkadot/util/node_modules/@polkadot/x-global/index.js (9:23): A comment
|
|
51
|
+
|
|
52
|
+
"/*#__PURE__*/"
|
|
53
|
+
|
|
54
|
+
in "../../node_modules/@polkadot/util/node_modules/@polkadot/x-global/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.[39m
|
|
31
55
|
Build end
|
|
32
|
-
[32m✓[39m
|
|
56
|
+
[32m✓[39m 6 modules transformed.
|
|
33
57
|
rendering chunks...
|
|
34
|
-
[2mdist/[22m[36mextension/Extension.js
|
|
35
|
-
[2mdist/[22m[36mindex.js
|
|
36
|
-
[2mdist/[22m[36mextension/ExtensionWeb3.js
|
|
37
|
-
[2mdist/[22m[36mextension/ExtensionWeb2.js
|
|
38
|
-
[
|
|
58
|
+
[2mdist/[22m[36mextension/Extension.js [39m[1m[2m 0.04 kB[22m[1m[22m
|
|
59
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m 0.24 kB[22m[1m[22m
|
|
60
|
+
[2mdist/[22m[36mextension/ExtensionWeb3.js [39m[1m[2m 1.11 kB[22m[1m[22m
|
|
61
|
+
[2mdist/[22m[36mextension/ExtensionWeb2.js [39m[1m[2m 2.39 kB[22m[1m[22m
|
|
62
|
+
[2mdist/[22m[36mworkers/CryptoWorkerManager.js [39m[1m[2m 4.36 kB[22m[1m[22m
|
|
63
|
+
[2mdist/[22m[36mworkers/cryptoWorker.js [39m[1m[2m19.63 kB[22m[1m[22m
|
|
64
|
+
[32m✓ built in 1.56s[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @prosopo/account
|
|
2
2
|
|
|
3
|
+
## 2.8.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
- 6a4d57d: Move account creation into worker
|
|
7
|
+
|
|
8
|
+
### Patch Changes
|
|
9
|
+
|
|
10
|
+
- 0a38892: feat/cross-os-testing
|
|
11
|
+
- a8faa9a: bump license year
|
|
12
|
+
- 3acc333: Release 3.3.0
|
|
13
|
+
- Updated dependencies [a53526b]
|
|
14
|
+
- Updated dependencies [3acc333]
|
|
15
|
+
- Updated dependencies [0a38892]
|
|
16
|
+
- Updated dependencies [1ee3d80]
|
|
17
|
+
- Updated dependencies [a8faa9a]
|
|
18
|
+
- Updated dependencies [7543d17]
|
|
19
|
+
- Updated dependencies [3acc333]
|
|
20
|
+
- @prosopo/util@3.2.5
|
|
21
|
+
- @prosopo/util-crypto@13.5.29
|
|
22
|
+
- @prosopo/keyring@2.9.0
|
|
23
|
+
- @prosopo/types@3.8.0
|
|
24
|
+
- @prosopo/fingerprint@2.6.28
|
|
25
|
+
- @prosopo/common@3.1.28
|
|
26
|
+
|
|
27
|
+
## 2.7.46
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [141e462]
|
|
31
|
+
- @prosopo/types@3.7.2
|
|
32
|
+
- @prosopo/keyring@2.8.43
|
|
33
|
+
|
|
34
|
+
## 2.7.45
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [345b25b]
|
|
38
|
+
- @prosopo/types@3.7.1
|
|
39
|
+
- @prosopo/keyring@2.8.42
|
|
40
|
+
|
|
41
|
+
## 2.7.44
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [ce70a2b]
|
|
45
|
+
- Updated dependencies [c2b940f]
|
|
46
|
+
- Updated dependencies [f6b5094]
|
|
47
|
+
- @prosopo/types@3.7.0
|
|
48
|
+
- @prosopo/common@3.1.27
|
|
49
|
+
- @prosopo/keyring@2.8.41
|
|
50
|
+
|
|
3
51
|
## 2.7.43
|
|
4
52
|
### Patch Changes
|
|
5
53
|
|
|
@@ -27,6 +27,7 @@ const fingerprint = require("@prosopo/fingerprint");
|
|
|
27
27
|
const keyring = require("@prosopo/keyring");
|
|
28
28
|
const util = require("@prosopo/util");
|
|
29
29
|
const utilCrypto = require("@prosopo/util-crypto");
|
|
30
|
+
const CryptoWorkerManager = require("../workers/CryptoWorkerManager.cjs");
|
|
30
31
|
const Extension = require("./Extension.cjs");
|
|
31
32
|
const SignerLoader = async () => (await import("@polkadot/extension-base/page/Signer")).default;
|
|
32
33
|
const EntropyToMnemonicLoader = async () => (await import("@prosopo/util-crypto")).entropyToMnemonic;
|
|
@@ -72,8 +73,14 @@ class ExtensionWeb2 extends Extension.Extension {
|
|
|
72
73
|
const browserEntropy = await fingerprint.getFingerprint();
|
|
73
74
|
const entropy = utilCrypto.hexHash(browserEntropy, 128).slice(2);
|
|
74
75
|
const u8Entropy = util$1.stringToU8a(entropy);
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
let mnemonic;
|
|
77
|
+
try {
|
|
78
|
+
const workerManager = CryptoWorkerManager.getCryptoWorkerManager();
|
|
79
|
+
mnemonic = await workerManager.entropyToMnemonic(u8Entropy);
|
|
80
|
+
} catch (workerError) {
|
|
81
|
+
const entropyToMnemonic = await EntropyToMnemonicLoader();
|
|
82
|
+
mnemonic = entropyToMnemonic(u8Entropy);
|
|
83
|
+
}
|
|
77
84
|
const type = "sr25519";
|
|
78
85
|
const keyring$1 = new keyring.Keyring({
|
|
79
86
|
type
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const cryptoWorker = require("./cryptoWorker.cjs");
|
|
4
|
+
class CryptoWorkerManager {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.worker = null;
|
|
7
|
+
this.isInitializing = false;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Initialize the worker
|
|
11
|
+
*/
|
|
12
|
+
async initWorker() {
|
|
13
|
+
if (this.worker || this.isInitializing) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.isInitializing = true;
|
|
17
|
+
try {
|
|
18
|
+
this.worker = new cryptoWorker({ type: "module" });
|
|
19
|
+
this.worker.onerror = (errorEvent) => {
|
|
20
|
+
this.cleanup();
|
|
21
|
+
};
|
|
22
|
+
await this.testWorker();
|
|
23
|
+
} catch (error) {
|
|
24
|
+
this.cleanup();
|
|
25
|
+
throw error;
|
|
26
|
+
} finally {
|
|
27
|
+
if (!this.worker) {
|
|
28
|
+
this.isInitializing = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Test if the worker is functioning properly
|
|
34
|
+
*/
|
|
35
|
+
async testWorker() {
|
|
36
|
+
if (!this.worker) {
|
|
37
|
+
throw new Error("Worker not initialized");
|
|
38
|
+
}
|
|
39
|
+
const worker = this.worker;
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const testTimeout = setTimeout(() => {
|
|
42
|
+
worker.removeEventListener("message", handleMessage);
|
|
43
|
+
worker.removeEventListener("error", handleError);
|
|
44
|
+
reject(new Error("Worker test timeout"));
|
|
45
|
+
}, 5e3);
|
|
46
|
+
const handleMessage = (event) => {
|
|
47
|
+
const { taskId, error, result } = event.data;
|
|
48
|
+
if (taskId === "test") {
|
|
49
|
+
clearTimeout(testTimeout);
|
|
50
|
+
worker.removeEventListener("message", handleMessage);
|
|
51
|
+
worker.removeEventListener("error", handleError);
|
|
52
|
+
if (error || result !== "ready") {
|
|
53
|
+
reject(
|
|
54
|
+
new Error(
|
|
55
|
+
`Worker test failed: ${error || 'Did not return "ready"'}`
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
} else {
|
|
59
|
+
resolve();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const handleError = (error) => {
|
|
64
|
+
clearTimeout(testTimeout);
|
|
65
|
+
worker.removeEventListener("message", handleMessage);
|
|
66
|
+
worker.removeEventListener("error", handleError);
|
|
67
|
+
reject(
|
|
68
|
+
new Error(`Worker test failed with error event: ${error.message}`)
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
worker.addEventListener("message", handleMessage);
|
|
72
|
+
worker.addEventListener("error", handleError);
|
|
73
|
+
worker.postMessage({ taskId: "test", task: "test", data: {} });
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Run a task in the Web Worker
|
|
78
|
+
*/
|
|
79
|
+
async runTask(task, data) {
|
|
80
|
+
await this.initWorker();
|
|
81
|
+
if (!this.worker) {
|
|
82
|
+
throw new Error("Failed to initialize worker");
|
|
83
|
+
}
|
|
84
|
+
const worker = this.worker;
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
const taskId = Math.random().toString(36).substr(2, 9);
|
|
87
|
+
const timeoutId = setTimeout(() => {
|
|
88
|
+
worker.removeEventListener("message", handleMessage);
|
|
89
|
+
worker.removeEventListener("error", handleError);
|
|
90
|
+
reject(new Error(`Worker task ${task} timeout (Task ID: ${taskId})`));
|
|
91
|
+
}, 1e4);
|
|
92
|
+
const handleMessage = (event) => {
|
|
93
|
+
if (event.data.taskId === taskId) {
|
|
94
|
+
clearTimeout(timeoutId);
|
|
95
|
+
worker.removeEventListener("message", handleMessage);
|
|
96
|
+
worker.removeEventListener("error", handleError);
|
|
97
|
+
if (event.data.error) {
|
|
98
|
+
reject(new Error(`Worker task failed: ${event.data.error}`));
|
|
99
|
+
} else {
|
|
100
|
+
resolve(event.data.result);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const handleError = (error) => {
|
|
105
|
+
clearTimeout(timeoutId);
|
|
106
|
+
worker.removeEventListener("message", handleMessage);
|
|
107
|
+
worker.removeEventListener("error", handleError);
|
|
108
|
+
reject(new Error(`Worker error during task: ${error.message}`));
|
|
109
|
+
};
|
|
110
|
+
worker.addEventListener("message", handleMessage);
|
|
111
|
+
worker.addEventListener("error", handleError);
|
|
112
|
+
const message = { taskId, task, data };
|
|
113
|
+
worker.postMessage(message);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Convert entropy to mnemonic using Web Worker
|
|
118
|
+
*/
|
|
119
|
+
async entropyToMnemonic(entropy) {
|
|
120
|
+
return this.runTask("entropyToMnemonic", { entropy });
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Clean up worker resources
|
|
124
|
+
*/
|
|
125
|
+
cleanup() {
|
|
126
|
+
if (this.worker) {
|
|
127
|
+
this.worker.terminate();
|
|
128
|
+
}
|
|
129
|
+
this.worker = null;
|
|
130
|
+
this.isInitializing = false;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Public dispose method
|
|
134
|
+
*/
|
|
135
|
+
dispose() {
|
|
136
|
+
this.cleanup();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
let workerManagerInstance = null;
|
|
140
|
+
function getCryptoWorkerManager() {
|
|
141
|
+
if (!workerManagerInstance) {
|
|
142
|
+
workerManagerInstance = new CryptoWorkerManager();
|
|
143
|
+
}
|
|
144
|
+
return workerManagerInstance;
|
|
145
|
+
}
|
|
146
|
+
exports.CryptoWorkerManager = CryptoWorkerManager;
|
|
147
|
+
exports.getCryptoWorkerManager = getCryptoWorkerManager;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsContent = '(function(){"use strict";/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function A(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function b(t,...e){if(!A(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function k(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function E(t,e){b(t);const a=e.outputLen;if(t.length<a)throw new Error("digestInto() expects output buffer of length at least "+a)}function y(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function w(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function d(t,e){return t<<32-e|t>>>e}function U(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function x(t){return typeof t=="string"&&(t=U(t)),b(t),t}class q{}function B(t){const e=r=>t().update(x(r)).digest(),a=t();return e.outputLen=a.outputLen,e.blockLen=a.blockLen,e.create=()=>t(),e}function L(t,e,a,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,a,r);const o=BigInt(32),n=BigInt(4294967295),i=Number(a>>o&n),l=Number(a&n),c=r?4:0,u=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+u,l,r)}function I(t,e,a){return t&e^~t&a}function H(t,e,a){return t&e^t&a^e&a}class T extends q{constructor(e,a,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=a,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=w(this.buffer)}update(e){k(this),e=x(e),b(e);const{view:a,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){const l=Math.min(o-this.pos,n-i);if(l===o){const c=w(e);for(;o<=n-i;i+=o)this.process(c,i);continue}r.set(e.subarray(i,i+l),this.pos),this.pos+=l,i+=l,this.pos===o&&(this.process(a,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){k(this),E(e,this),this.finished=!0;const{buffer:a,view:r,blockLen:o,isLE:n}=this;let{pos:i}=this;a[i++]=128,y(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(r,0),i=0);for(let s=i;s<o;s++)a[s]=0;L(r,o-8,BigInt(this.length*8),n),this.process(r,0);const l=w(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,m=this.get();if(u>m.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<u;s++)l.setUint32(4*s,m[s],n)}digest(){const{buffer:e,outputLen:a}=this;this.digestInto(e);const r=e.slice(0,a);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:a,buffer:r,length:o,finished:n,destroyed:i,pos:l}=this;return e.destroyed=i,e.finished=n,e.length=o,e.pos=l,o%a&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const h=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),p=new Uint32Array(64);class D extends T{constructor(e=32){super(64,e,8,!1),this.A=h[0]|0,this.B=h[1]|0,this.C=h[2]|0,this.D=h[3]|0,this.E=h[4]|0,this.F=h[5]|0,this.G=h[6]|0,this.H=h[7]|0}get(){const{A:e,B:a,C:r,D:o,E:n,F:i,G:l,H:c}=this;return[e,a,r,o,n,i,l,c]}set(e,a,r,o,n,i,l,c){this.A=e|0,this.B=a|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=l|0,this.H=c|0}process(e,a){for(let s=0;s<16;s++,a+=4)p[s]=e.getUint32(a,!1);for(let s=16;s<64;s++){const g=p[s-15],f=p[s-2],z=d(g,7)^d(g,18)^g>>>3,v=d(f,17)^d(f,19)^f>>>10;p[s]=v+p[s-7]+z+p[s-16]|0}let{A:r,B:o,C:n,D:i,E:l,F:c,G:u,H:m}=this;for(let s=0;s<64;s++){const g=d(l,6)^d(l,11)^d(l,25),f=m+g+I(l,c,u)+_[s]+p[s]|0,v=(d(r,2)^d(r,13)^d(r,22))+H(r,o,n)|0;m=u,u=c,c=l,l=i+f|0,i=n,n=o,o=r,r=f+v|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,l=l+this.E|0,c=c+this.F|0,u=u+this.G|0,m=m+this.H|0,this.set(r,o,n,i,l,c,u,m)}roundClean(){y(p)}destroy(){this.set(0,0,0,0,0,0,0,0),y(this.buffer)}}const C={256:B(()=>new D)}[256],M="abandon|ability|able|about|above|absent|absorb|abstract|absurd|abuse|access|accident|account|accuse|achieve|acid|acoustic|acquire|across|act|action|actor|actress|actual|adapt|add|addict|address|adjust|admit|adult|advance|advice|aerobic|affair|afford|afraid|again|age|agent|agree|ahead|aim|air|airport|aisle|alarm|album|alcohol|alert|alien|all|alley|allow|almost|alone|alpha|already|also|alter|always|amateur|amazing|among|amount|amused|analyst|anchor|ancient|anger|angle|angry|animal|ankle|announce|annual|another|answer|antenna|antique|anxiety|any|apart|apology|appear|apple|approve|april|arch|arctic|area|arena|argue|arm|armed|armor|army|around|arrange|arrest|arrive|arrow|art|artefact|artist|artwork|ask|aspect|assault|asset|assist|assume|asthma|athlete|atom|attack|attend|attitude|attract|auction|audit|august|aunt|author|auto|autumn|average|avocado|avoid|awake|aware|away|awesome|awful|awkward|axis|baby|bachelor|bacon|badge|bag|balance|balcony|ball|bamboo|banana|banner|bar|barely|bargain|barrel|base|basic|basket|battle|beach|bean|beauty|because|become|beef|before|begin|behave|behind|believe|below|belt|bench|benefit|best|betray|better|between|beyond|bicycle|bid|bike|bind|biology|bird|birth|bitter|black|blade|blame|blanket|blast|bleak|bless|blind|blood|blossom|blouse|blue|blur|blush|board|boat|body|boil|bomb|bone|bonus|book|boost|border|boring|borrow|boss|bottom|bounce|box|boy|bracket|brain|brand|brass|brave|bread|breeze|brick|bridge|brief|bright|bring|brisk|broccoli|broken|bronze|broom|brother|brown|brush|bubble|buddy|budget|buffalo|build|bulb|bulk|bullet|bundle|bunker|burden|burger|burst|bus|business|busy|butter|buyer|buzz|cabbage|cabin|cable|cactus|cage|cake|call|calm|camera|camp|can|canal|cancel|candy|cannon|canoe|canvas|canyon|capable|capital|captain|car|carbon|card|cargo|carpet|carry|cart|case|cash|casino|castle|casual|cat|catalog|catch|category|cattle|caught|cause|caution|cave|ceiling|celery|cement|census|century|cereal|certain|chair|chalk|champion|change|chaos|chapter|charge|chase|chat|cheap|check|cheese|chef|cherry|chest|chicken|chief|child|chimney|choice|choose|chronic|chuckle|chunk|churn|cigar|cinnamon|circle|citizen|city|civil|claim|clap|clarify|claw|clay|clean|clerk|clever|click|client|cliff|climb|clinic|clip|clock|clog|close|cloth|cloud|clown|club|clump|cluster|clutch|coach|coast|coconut|code|coffee|coil|coin|collect|color|column|combine|come|comfort|comic|common|company|concert|conduct|confirm|congress|connect|consider|control|convince|cook|cool|copper|copy|coral|core|corn|correct|cost|cotton|couch|country|couple|course|cousin|cover|coyote|crack|cradle|craft|cram|crane|crash|crater|crawl|crazy|cream|credit|creek|crew|cricket|crime|crisp|critic|crop|cross|crouch|crowd|crucial|cruel|cruise|crumble|crunch|crush|cry|crystal|cube|culture|cup|cupboard|curious|current|curtain|curve|cushion|custom|cute|cycle|dad|damage|damp|dance|danger|daring|dash|daughter|dawn|day|deal|debate|debris|decade|december|decide|decline|decorate|decrease|deer|defense|define|defy|degree|delay|deliver|demand|demise|denial|dentist|deny|depart|depend|deposit|depth|deputy|derive|describe|desert|design|desk|despair|destroy|detail|detect|develop|device|devote|diagram|dial|diamond|diary|dice|diesel|diet|differ|digital|dignity|dilemma|dinner|dinosaur|direct|dirt|disagree|discover|disease|dish|dismiss|disorder|display|distance|divert|divide|divorce|dizzy|doctor|document|dog|doll|dolphin|domain|donate|donkey|donor|door|dose|double|dove|draft|dragon|drama|drastic|draw|dream|dress|drift|drill|drink|drip|drive|drop|drum|dry|duck|dumb|dune|during|dust|dutch|duty|dwarf|dynamic|eager|eagle|early|earn|earth|easily|east|easy|echo|ecology|economy|edge|edit|educate|effort|egg|eight|either|elbow|elder|electric|elegant|element|elephant|elevator|elite|else|embark|embody|embrace|emerge|emotion|employ|empower|empty|enable|enact|end|endless|endorse|enemy|energy|enforce|engage|engine|enhance|enjoy|enlist|enough|enrich|enroll|ensure|enter|entire|entry|envelope|episode|equal|equip|era|erase|erode|erosion|error|erupt|escape|essay|essence|estate|eternal|ethics|evidence|evil|evoke|evolve|exact|example|excess|exchange|excite|exclude|excuse|execute|exercise|exhaust|exhibit|exile|exist|exit|exotic|expand|expect|expire|explain|expose|express|extend|extra|eye|eyebrow|fabric|face|faculty|fade|faint|faith|fall|false|fame|family|famous|fan|fancy|fantasy|farm|fashion|fat|fatal|father|fatigue|fault|favorite|feature|february|federal|fee|feed|feel|female|fence|festival|fetch|fever|few|fiber|fiction|field|figure|file|film|filter|final|find|fine|finger|finish|fire|firm|first|fiscal|fish|fit|fitness|fix|flag|flame|flash|flat|flavor|flee|flight|flip|float|flock|floor|flower|fluid|flush|fly|foam|focus|fog|foil|fold|follow|food|foot|force|forest|forget|fork|fortune|forum|forward|fossil|foster|found|fox|fragile|frame|frequent|fresh|friend|fringe|frog|front|frost|frown|frozen|fruit|fuel|fun|funny|furnace|fury|future|gadget|gain|galaxy|gallery|game|gap|garage|garbage|garden|garlic|garment|gas|gasp|gate|gather|gauge|gaze|general|genius|genre|gentle|genuine|gesture|ghost|giant|gift|giggle|ginger|giraffe|girl|give|glad|glance|glare|glass|glide|glimpse|globe|gloom|glory|glove|glow|glue|goat|goddess|gold|good|goose|gorilla|gospel|gossip|govern|gown|grab|grace|grain|grant|grape|grass|gravity|great|green|grid|grief|grit|grocery|group|grow|grunt|guard|guess|guide|guilt|guitar|gun|gym|habit|hair|half|hammer|hamster|hand|happy|harbor|hard|harsh|harvest|hat|have|hawk|hazard|head|health|heart|heavy|hedgehog|height|hello|helmet|help|hen|hero|hidden|high|hill|hint|hip|hire|history|hobby|hockey|hold|hole|holiday|hollow|home|honey|hood|hope|horn|horror|horse|hospital|host|hotel|hour|hover|hub|huge|human|humble|humor|hundred|hungry|hunt|hurdle|hurry|hurt|husband|hybrid|ice|icon|idea|identify|idle|ignore|ill|illegal|illness|image|imitate|immense|immune|impact|impose|improve|impulse|inch|include|income|increase|index|indicate|indoor|industry|infant|inflict|inform|inhale|inherit|initial|inject|injury|inmate|inner|innocent|input|inquiry|insane|insect|inside|inspire|install|intact|interest|into|invest|invite|involve|iron|island|isolate|issue|item|ivory|jacket|jaguar|jar|jazz|jealous|jeans|jelly|jewel|job|join|joke|journey|joy|judge|juice|jump|jungle|junior|junk|just|kangaroo|keen|keep|ketchup|key|kick|kid|kidney|kind|kingdom|kiss|kit|kitchen|kite|kitten|kiwi|knee|knife|knock|know|lab|label|labor|ladder|lady|lake|lamp|language|laptop|large|later|latin|laugh|laundry|lava|law|lawn|lawsuit|layer|lazy|leader|leaf|learn|leave|lecture|left|leg|legal|legend|leisure|lemon|lend|length|lens|leopard|lesson|letter|level|liar|liberty|library|license|life|lift|light|like|limb|limit|link|lion|liquid|list|little|live|lizard|load|loan|lobster|local|lock|logic|lonely|long|loop|lottery|loud|lounge|love|loyal|lucky|luggage|lumber|lunar|lunch|luxury|lyrics|machine|mad|magic|magnet|maid|mail|main|major|make|mammal|man|manage|mandate|mango|mansion|manual|maple|marble|march|margin|marine|market|marriage|mask|mass|master|match|material|math|matrix|matter|maximum|maze|meadow|mean|measure|meat|mechanic|medal|media|melody|melt|member|memory|mention|menu|mercy|merge|merit|merry|mesh|message|metal|method|middle|midnight|milk|million|mimic|mind|minimum|minor|minute|miracle|mirror|misery|miss|mistake|mix|mixed|mixture|mobile|model|modify|mom|moment|monitor|monkey|monster|month|moon|moral|more|morning|mosquito|mother|motion|motor|mountain|mouse|move|movie|much|muffin|mule|multiply|muscle|museum|mushroom|music|must|mutual|myself|mystery|myth|naive|name|napkin|narrow|nasty|nation|nature|near|neck|need|negative|neglect|neither|nephew|nerve|nest|net|network|neutral|never|news|next|nice|night|noble|noise|nominee|noodle|normal|north|nose|notable|note|nothing|notice|novel|now|nuclear|number|nurse|nut|oak|obey|object|oblige|obscure|observe|obtain|obvious|occur|ocean|october|odor|off|offer|office|often|oil|okay|old|olive|olympic|omit|once|one|onion|online|only|open|opera|opinion|oppose|option|orange|orbit|orchard|order|ordinary|organ|orient|original|orphan|ostrich|other|outdoor|outer|output|outside|oval|oven|over|own|owner|oxygen|oyster|ozone|pact|paddle|page|pair|palace|palm|panda|panel|panic|panther|paper|parade|parent|park|parrot|party|pass|patch|path|patient|patrol|pattern|pause|pave|payment|peace|peanut|pear|peasant|pelican|pen|penalty|pencil|people|pepper|perfect|permit|person|pet|phone|photo|phrase|physical|piano|picnic|picture|piece|pig|pigeon|pill|pilot|pink|pioneer|pipe|pistol|pitch|pizza|place|planet|plastic|plate|play|please|pledge|pluck|plug|plunge|poem|poet|point|polar|pole|police|pond|pony|pool|popular|portion|position|possible|post|potato|pottery|poverty|powder|power|practice|praise|predict|prefer|prepare|present|pretty|prevent|price|pride|primary|print|priority|prison|private|prize|problem|process|produce|profit|program|project|promote|proof|property|prosper|protect|proud|provide|public|pudding|pull|pulp|pulse|pumpkin|punch|pupil|puppy|purchase|purity|purpose|purse|push|put|puzzle|pyramid|quality|quantum|quarter|question|quick|quit|quiz|quote|rabbit|raccoon|race|rack|radar|radio|rail|rain|raise|rally|ramp|ranch|random|range|rapid|rare|rate|rather|raven|raw|razor|ready|real|reason|rebel|rebuild|recall|receive|recipe|record|recycle|reduce|reflect|reform|refuse|region|regret|regular|reject|relax|release|relief|rely|remain|remember|remind|remove|render|renew|rent|reopen|repair|repeat|replace|report|require|rescue|resemble|resist|resource|response|result|retire|retreat|return|reunion|reveal|review|reward|rhythm|rib|ribbon|rice|rich|ride|ridge|rifle|right|rigid|ring|riot|ripple|risk|ritual|rival|river|road|roast|robot|robust|rocket|romance|roof|rookie|room|rose|rotate|rough|round|route|royal|rubber|rude|rug|rule|run|runway|rural|sad|saddle|sadness|safe|sail|salad|salmon|salon|salt|salute|same|sample|sand|satisfy|satoshi|sauce|sausage|save|say|scale|scan|scare|scatter|scene|scheme|school|science|scissors|scorpion|scout|scrap|screen|script|scrub|sea|search|season|seat|second|secret|section|security|seed|seek|segment|select|sell|seminar|senior|sense|sentence|series|service|session|settle|setup|seven|shadow|shaft|shallow|share|shed|shell|sheriff|shield|shift|shine|ship|shiver|shock|shoe|shoot|shop|short|shoulder|shove|shrimp|shrug|shuffle|shy|sibling|sick|side|siege|sight|sign|silent|silk|silly|silver|similar|simple|since|sing|siren|sister|situate|six|size|skate|sketch|ski|skill|skin|skirt|skull|slab|slam|sleep|slender|slice|slide|slight|slim|slogan|slot|slow|slush|small|smart|smile|smoke|smooth|snack|snake|snap|sniff|snow|soap|soccer|social|sock|soda|soft|solar|soldier|solid|solution|solve|someone|song|soon|sorry|sort|soul|sound|soup|source|south|space|spare|spatial|spawn|speak|special|speed|spell|spend|sphere|spice|spider|spike|spin|spirit|split|spoil|sponsor|spoon|sport|spot|spray|spread|spring|spy|square|squeeze|squirrel|stable|stadium|staff|stage|stairs|stamp|stand|start|state|stay|steak|steel|stem|step|stereo|stick|still|sting|stock|stomach|stone|stool|story|stove|strategy|street|strike|strong|struggle|student|stuff|stumble|style|subject|submit|subway|success|such|sudden|suffer|sugar|suggest|suit|summer|sun|sunny|sunset|super|supply|supreme|sure|surface|surge|surprise|surround|survey|suspect|sustain|swallow|swamp|swap|swarm|swear|sweet|swift|swim|swing|switch|sword|symbol|symptom|syrup|system|table|tackle|tag|tail|talent|talk|tank|tape|target|task|taste|tattoo|taxi|teach|team|tell|ten|tenant|tennis|tent|term|test|text|thank|that|theme|then|theory|there|they|thing|this|thought|three|thrive|throw|thumb|thunder|ticket|tide|tiger|tilt|timber|time|tiny|tip|tired|tissue|title|toast|tobacco|today|toddler|toe|together|toilet|token|tomato|tomorrow|tone|tongue|tonight|tool|tooth|top|topic|topple|torch|tornado|tortoise|toss|total|tourist|toward|tower|town|toy|track|trade|traffic|tragic|train|transfer|trap|trash|travel|tray|treat|tree|trend|trial|tribe|trick|trigger|trim|trip|trophy|trouble|truck|true|truly|trumpet|trust|truth|try|tube|tuition|tumble|tuna|tunnel|turkey|turn|turtle|twelve|twenty|twice|twin|twist|two|type|typical|ugly|umbrella|unable|unaware|uncle|uncover|under|undo|unfair|unfold|unhappy|uniform|unique|unit|universe|unknown|unlock|until|unusual|unveil|update|upgrade|uphold|upon|upper|upset|urban|urge|usage|use|used|useful|useless|usual|utility|vacant|vacuum|vague|valid|valley|valve|van|vanish|vapor|various|vast|vault|vehicle|velvet|vendor|venture|venue|verb|verify|version|very|vessel|veteran|viable|vibrant|vicious|victory|video|view|village|vintage|violin|virtual|virus|visa|visit|visual|vital|vivid|vocal|voice|void|volcano|volume|vote|voyage|wage|wagon|wait|walk|wall|walnut|want|warfare|warm|warrior|wash|wasp|waste|water|wave|way|wealth|weapon|wear|weasel|weather|web|wedding|weekend|weird|welcome|west|wet|whale|what|wheat|wheel|when|where|whip|whisper|wide|width|wife|wild|will|win|window|wine|wing|wink|winner|winter|wire|wisdom|wise|wish|witness|wolf|woman|wonder|wood|wool|word|work|world|worry|worth|wrap|wreck|wrestle|wrist|write|wrong|yard|year|yellow|you|young|youth|zebra|zero|zone|zoo".split("|"),F="Invalid entropy";function S(t){return Number.parseInt(t,2)}function j(t){return t.map(e=>e.toString(2).padStart(8,"0")).join("")}function V(t){return j(Array.from(C(t))).slice(0,t.length*8/32)}function $(t,e=M){if(t.length%4!==0||t.length<16||t.length>32)throw new Error(F);const r=`${j(Array.from(t))}${V(t)}`.match(/(.{1,11})/g)?.map(o=>e[S(o)]);if(!r||r.length<12)throw new Error("Unable to map entropy to mnemonic");return r.join(" ")}self.addEventListener("message",async t=>{const{taskId:e,task:a,data:r}=t.data;try{let o;switch(a){case"test":o="ready";break;case"entropyToMnemonic":if(!r.entropy)throw new Error("Entropy data is required");o=await G(r.entropy);break;default:throw new Error(`Unknown task: ${a}`)}const n={taskId:e,result:o};self.postMessage(n)}catch(o){const n={taskId:e,error:o instanceof Error?o.message:"Unknown error"};self.postMessage(n)}});async function G(t){try{return $(t)}catch(e){throw new Error(`Failed to process entropy: ${e instanceof Error?e.message:"Unknown error"}`)}}})();\n';
|
|
3
|
+
const blob = typeof self !== "undefined" && self.Blob && new Blob([jsContent], { type: "text/javascript;charset=utf-8" });
|
|
4
|
+
function WorkerWrapper(options) {
|
|
5
|
+
let objURL;
|
|
6
|
+
try {
|
|
7
|
+
objURL = blob && (self.URL || self.webkitURL).createObjectURL(blob);
|
|
8
|
+
if (!objURL) throw "";
|
|
9
|
+
const worker = new Worker(objURL, {
|
|
10
|
+
name: options?.name
|
|
11
|
+
});
|
|
12
|
+
worker.addEventListener("error", () => {
|
|
13
|
+
(self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
14
|
+
});
|
|
15
|
+
return worker;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
return new Worker(
|
|
18
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent),
|
|
19
|
+
{
|
|
20
|
+
name: options?.name
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
} finally {
|
|
24
|
+
objURL && (self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
module.exports = WorkerWrapper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../src/extension/Extension.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAK5E,8BAAsB,SAAS;aAOd,UAAU,CACzB,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Extension.js","sourceRoot":"","sources":["../../src/extension/Extension.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAgB,SAAS;CAU9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Account, ProcaptchaClientConfigOutput } from "@prosopo/types";
|
|
2
|
+
import { Extension } from "./Extension.js";
|
|
3
|
+
export declare class ExtensionWeb2 extends Extension {
|
|
4
|
+
getAccount(config: ProcaptchaClientConfigOutput): Promise<Account>;
|
|
5
|
+
private createExtension;
|
|
6
|
+
private createAccount;
|
|
7
|
+
}
|
|
8
|
+
export default ExtensionWeb2;
|
|
9
|
+
//# sourceMappingURL=ExtensionWeb2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionWeb2.d.ts","sourceRoot":"","sources":["../../src/extension/ExtensionWeb2.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAK5E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAY3C,qBAAa,aAAc,SAAQ,SAAS;IAC9B,UAAU,CACtB,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,OAAO,CAAC;YAUL,eAAe;YAoCf,aAAa;CAiC3B;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { getFingerprint } from "@prosopo/fingerprint";
|
|
|
3
3
|
import { Keyring } from "@prosopo/keyring";
|
|
4
4
|
import { u8aToHex, version } from "@prosopo/util";
|
|
5
5
|
import { hexHash } from "@prosopo/util-crypto";
|
|
6
|
+
import { getCryptoWorkerManager } from "../workers/CryptoWorkerManager.js";
|
|
6
7
|
import { Extension } from "./Extension.js";
|
|
7
8
|
const SignerLoader = async () => (await import("@polkadot/extension-base/page/Signer")).default;
|
|
8
9
|
const EntropyToMnemonicLoader = async () => (await import("@prosopo/util-crypto")).entropyToMnemonic;
|
|
@@ -48,8 +49,14 @@ class ExtensionWeb2 extends Extension {
|
|
|
48
49
|
const browserEntropy = await getFingerprint();
|
|
49
50
|
const entropy = hexHash(browserEntropy, 128).slice(2);
|
|
50
51
|
const u8Entropy = stringToU8a(entropy);
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
let mnemonic;
|
|
53
|
+
try {
|
|
54
|
+
const workerManager = getCryptoWorkerManager();
|
|
55
|
+
mnemonic = await workerManager.entropyToMnemonic(u8Entropy);
|
|
56
|
+
} catch (workerError) {
|
|
57
|
+
const entropyToMnemonic = await EntropyToMnemonicLoader();
|
|
58
|
+
mnemonic = entropyToMnemonic(u8Entropy);
|
|
59
|
+
}
|
|
53
60
|
const type = "sr25519";
|
|
54
61
|
const keyring = new Keyring({
|
|
55
62
|
type
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionWeb2.js","sourceRoot":"","sources":["../../src/extension/ExtensionWeb2.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE,CAC/B,CAAC,MAAM,MAAM,CAAC,sCAAsC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChE,MAAM,uBAAuB,GAAG,KAAK,IAAI,EAAE,CAC1C,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,iBAAiB,CAAC;AAO1D,MAAM,OAAO,aAAc,SAAQ,SAAS;IACpC,KAAK,CAAC,UAAU,CACtB,MAAoC;QAEpC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,SAAS,GAAsB,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAEzE,OAAO;YACN,OAAO;YACP,SAAS;SACT,CAAC;IACH,CAAC;IAEO,K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AAQ,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACzC,CAAC;QAED,MAAM,IAAI,GAAgB,SAAS,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;YAC3B,IAAI;SACJ,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,OAAO;YACN,OAAO;YACP,IAAI,EAAE,OAAO;YACb,OAAO;SACP,CAAC;IACH,CAAC;CACD;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Account, ProcaptchaClientConfigOutput } from "@prosopo/types";
|
|
2
|
+
import { Extension } from "./Extension.js";
|
|
3
|
+
export declare class ExtensionWeb3 extends Extension {
|
|
4
|
+
getAccount(config: ProcaptchaClientConfigOutput): Promise<Account>;
|
|
5
|
+
}
|
|
6
|
+
export default ExtensionWeb3;
|
|
7
|
+
//# sourceMappingURL=ExtensionWeb3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionWeb3.d.ts","sourceRoot":"","sources":["../../src/extension/ExtensionWeb3.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,qBAAa,aAAc,SAAQ,SAAS;IAC9B,UAAU,CACtB,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,OAAO,CAAC;CA8BnB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionWeb3.js","sourceRoot":"","sources":["../../src/extension/ExtensionWeb3.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OA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
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class CryptoWorkerManager {
|
|
2
|
+
private worker;
|
|
3
|
+
private isInitializing;
|
|
4
|
+
private initWorker;
|
|
5
|
+
private testWorker;
|
|
6
|
+
runTask<T>(task: string, data: Record<string, string | Uint8Array>): Promise<T>;
|
|
7
|
+
entropyToMnemonic(entropy: Uint8Array): Promise<string>;
|
|
8
|
+
private cleanup;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function getCryptoWorkerManager(): CryptoWorkerManager;
|
|
12
|
+
//# sourceMappingURL=CryptoWorkerManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CryptoWorkerManager.d.ts","sourceRoot":"","sources":["../../src/workers/CryptoWorkerManager.ts"],"names":[],"mappings":"AAgCA,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,cAAc,CAAS;YAKjB,UAAU;YAkCV,UAAU;IAsDlB,OAAO,CAAC,CAAC,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,GACvC,OAAO,CAAC,CAAC,CAAC;IAoDP,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAO7D,OAAO,CAAC,OAAO;IAWR,OAAO,IAAI,IAAI;CAGtB;AAQD,wBAAgB,sBAAsB,IAAI,mBAAmB,CAK5D"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import WorkerWrapper from "./cryptoWorker.js";
|
|
2
|
+
class CryptoWorkerManager {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.worker = null;
|
|
5
|
+
this.isInitializing = false;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Initialize the worker
|
|
9
|
+
*/
|
|
10
|
+
async initWorker() {
|
|
11
|
+
if (this.worker || this.isInitializing) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
this.isInitializing = true;
|
|
15
|
+
try {
|
|
16
|
+
this.worker = new WorkerWrapper({ type: "module" });
|
|
17
|
+
this.worker.onerror = (errorEvent) => {
|
|
18
|
+
this.cleanup();
|
|
19
|
+
};
|
|
20
|
+
await this.testWorker();
|
|
21
|
+
} catch (error) {
|
|
22
|
+
this.cleanup();
|
|
23
|
+
throw error;
|
|
24
|
+
} finally {
|
|
25
|
+
if (!this.worker) {
|
|
26
|
+
this.isInitializing = false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Test if the worker is functioning properly
|
|
32
|
+
*/
|
|
33
|
+
async testWorker() {
|
|
34
|
+
if (!this.worker) {
|
|
35
|
+
throw new Error("Worker not initialized");
|
|
36
|
+
}
|
|
37
|
+
const worker = this.worker;
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const testTimeout = setTimeout(() => {
|
|
40
|
+
worker.removeEventListener("message", handleMessage);
|
|
41
|
+
worker.removeEventListener("error", handleError);
|
|
42
|
+
reject(new Error("Worker test timeout"));
|
|
43
|
+
}, 5e3);
|
|
44
|
+
const handleMessage = (event) => {
|
|
45
|
+
const { taskId, error, result } = event.data;
|
|
46
|
+
if (taskId === "test") {
|
|
47
|
+
clearTimeout(testTimeout);
|
|
48
|
+
worker.removeEventListener("message", handleMessage);
|
|
49
|
+
worker.removeEventListener("error", handleError);
|
|
50
|
+
if (error || result !== "ready") {
|
|
51
|
+
reject(
|
|
52
|
+
new Error(
|
|
53
|
+
`Worker test failed: ${error || 'Did not return "ready"'}`
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
resolve();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const handleError = (error) => {
|
|
62
|
+
clearTimeout(testTimeout);
|
|
63
|
+
worker.removeEventListener("message", handleMessage);
|
|
64
|
+
worker.removeEventListener("error", handleError);
|
|
65
|
+
reject(
|
|
66
|
+
new Error(`Worker test failed with error event: ${error.message}`)
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
worker.addEventListener("message", handleMessage);
|
|
70
|
+
worker.addEventListener("error", handleError);
|
|
71
|
+
worker.postMessage({ taskId: "test", task: "test", data: {} });
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Run a task in the Web Worker
|
|
76
|
+
*/
|
|
77
|
+
async runTask(task, data) {
|
|
78
|
+
await this.initWorker();
|
|
79
|
+
if (!this.worker) {
|
|
80
|
+
throw new Error("Failed to initialize worker");
|
|
81
|
+
}
|
|
82
|
+
const worker = this.worker;
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
const taskId = Math.random().toString(36).substr(2, 9);
|
|
85
|
+
const timeoutId = setTimeout(() => {
|
|
86
|
+
worker.removeEventListener("message", handleMessage);
|
|
87
|
+
worker.removeEventListener("error", handleError);
|
|
88
|
+
reject(new Error(`Worker task ${task} timeout (Task ID: ${taskId})`));
|
|
89
|
+
}, 1e4);
|
|
90
|
+
const handleMessage = (event) => {
|
|
91
|
+
if (event.data.taskId === taskId) {
|
|
92
|
+
clearTimeout(timeoutId);
|
|
93
|
+
worker.removeEventListener("message", handleMessage);
|
|
94
|
+
worker.removeEventListener("error", handleError);
|
|
95
|
+
if (event.data.error) {
|
|
96
|
+
reject(new Error(`Worker task failed: ${event.data.error}`));
|
|
97
|
+
} else {
|
|
98
|
+
resolve(event.data.result);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const handleError = (error) => {
|
|
103
|
+
clearTimeout(timeoutId);
|
|
104
|
+
worker.removeEventListener("message", handleMessage);
|
|
105
|
+
worker.removeEventListener("error", handleError);
|
|
106
|
+
reject(new Error(`Worker error during task: ${error.message}`));
|
|
107
|
+
};
|
|
108
|
+
worker.addEventListener("message", handleMessage);
|
|
109
|
+
worker.addEventListener("error", handleError);
|
|
110
|
+
const message = { taskId, task, data };
|
|
111
|
+
worker.postMessage(message);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Convert entropy to mnemonic using Web Worker
|
|
116
|
+
*/
|
|
117
|
+
async entropyToMnemonic(entropy) {
|
|
118
|
+
return this.runTask("entropyToMnemonic", { entropy });
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Clean up worker resources
|
|
122
|
+
*/
|
|
123
|
+
cleanup() {
|
|
124
|
+
if (this.worker) {
|
|
125
|
+
this.worker.terminate();
|
|
126
|
+
}
|
|
127
|
+
this.worker = null;
|
|
128
|
+
this.isInitializing = false;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Public dispose method
|
|
132
|
+
*/
|
|
133
|
+
dispose() {
|
|
134
|
+
this.cleanup();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
let workerManagerInstance = null;
|
|
138
|
+
function getCryptoWorkerManager() {
|
|
139
|
+
if (!workerManagerInstance) {
|
|
140
|
+
workerManagerInstance = new CryptoWorkerManager();
|
|
141
|
+
}
|
|
142
|
+
return workerManagerInstance;
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
CryptoWorkerManager,
|
|
146
|
+
getCryptoWorkerManager
|
|
147
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CryptoWorkerManager.js","sourceRoot":"","sources":["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IAAI,qBAAqB,GAA+B,IAAI,CAAC;AAK7D,MAAM,UAAU,sBAAsB;IACrC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC5B,qBAAqB,GAAG,IAAI,mBAAmB,EAAE,CAAC;IACnD,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptoWorker.d.ts","sourceRoot":"","sources":["../../src/workers/cryptoWorker.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const jsContent = '(function(){"use strict";/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function A(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function b(t,...e){if(!A(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function k(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function E(t,e){b(t);const a=e.outputLen;if(t.length<a)throw new Error("digestInto() expects output buffer of length at least "+a)}function y(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function w(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function d(t,e){return t<<32-e|t>>>e}function U(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function x(t){return typeof t=="string"&&(t=U(t)),b(t),t}class q{}function B(t){const e=r=>t().update(x(r)).digest(),a=t();return e.outputLen=a.outputLen,e.blockLen=a.blockLen,e.create=()=>t(),e}function L(t,e,a,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,a,r);const o=BigInt(32),n=BigInt(4294967295),i=Number(a>>o&n),l=Number(a&n),c=r?4:0,u=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+u,l,r)}function I(t,e,a){return t&e^~t&a}function H(t,e,a){return t&e^t&a^e&a}class T extends q{constructor(e,a,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=a,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=w(this.buffer)}update(e){k(this),e=x(e),b(e);const{view:a,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){const l=Math.min(o-this.pos,n-i);if(l===o){const c=w(e);for(;o<=n-i;i+=o)this.process(c,i);continue}r.set(e.subarray(i,i+l),this.pos),this.pos+=l,i+=l,this.pos===o&&(this.process(a,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){k(this),E(e,this),this.finished=!0;const{buffer:a,view:r,blockLen:o,isLE:n}=this;let{pos:i}=this;a[i++]=128,y(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(r,0),i=0);for(let s=i;s<o;s++)a[s]=0;L(r,o-8,BigInt(this.length*8),n),this.process(r,0);const l=w(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,m=this.get();if(u>m.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<u;s++)l.setUint32(4*s,m[s],n)}digest(){const{buffer:e,outputLen:a}=this;this.digestInto(e);const r=e.slice(0,a);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:a,buffer:r,length:o,finished:n,destroyed:i,pos:l}=this;return e.destroyed=i,e.finished=n,e.length=o,e.pos=l,o%a&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const h=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),p=new Uint32Array(64);class D extends T{constructor(e=32){super(64,e,8,!1),this.A=h[0]|0,this.B=h[1]|0,this.C=h[2]|0,this.D=h[3]|0,this.E=h[4]|0,this.F=h[5]|0,this.G=h[6]|0,this.H=h[7]|0}get(){const{A:e,B:a,C:r,D:o,E:n,F:i,G:l,H:c}=this;return[e,a,r,o,n,i,l,c]}set(e,a,r,o,n,i,l,c){this.A=e|0,this.B=a|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=l|0,this.H=c|0}process(e,a){for(let s=0;s<16;s++,a+=4)p[s]=e.getUint32(a,!1);for(let s=16;s<64;s++){const g=p[s-15],f=p[s-2],z=d(g,7)^d(g,18)^g>>>3,v=d(f,17)^d(f,19)^f>>>10;p[s]=v+p[s-7]+z+p[s-16]|0}let{A:r,B:o,C:n,D:i,E:l,F:c,G:u,H:m}=this;for(let s=0;s<64;s++){const g=d(l,6)^d(l,11)^d(l,25),f=m+g+I(l,c,u)+_[s]+p[s]|0,v=(d(r,2)^d(r,13)^d(r,22))+H(r,o,n)|0;m=u,u=c,c=l,l=i+f|0,i=n,n=o,o=r,r=f+v|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,l=l+this.E|0,c=c+this.F|0,u=u+this.G|0,m=m+this.H|0,this.set(r,o,n,i,l,c,u,m)}roundClean(){y(p)}destroy(){this.set(0,0,0,0,0,0,0,0),y(this.buffer)}}const C={256:B(()=>new D)}[256],M="abandon|ability|able|about|above|absent|absorb|abstract|absurd|abuse|access|accident|account|accuse|achieve|acid|acoustic|acquire|across|act|action|actor|actress|actual|adapt|add|addict|address|adjust|admit|adult|advance|advice|aerobic|affair|afford|afraid|again|age|agent|agree|ahead|aim|air|airport|aisle|alarm|album|alcohol|alert|alien|all|alley|allow|almost|alone|alpha|already|also|alter|always|amateur|amazing|among|amount|amused|analyst|anchor|ancient|anger|angle|angry|animal|ankle|announce|annual|another|answer|antenna|antique|anxiety|any|apart|apology|appear|apple|approve|april|arch|arctic|area|arena|argue|arm|armed|armor|army|around|arrange|arrest|arrive|arrow|art|artefact|artist|artwork|ask|aspect|assault|asset|assist|assume|asthma|athlete|atom|attack|attend|attitude|attract|auction|audit|august|aunt|author|auto|autumn|average|avocado|avoid|awake|aware|away|awesome|awful|awkward|axis|baby|bachelor|bacon|badge|bag|balance|balcony|ball|bamboo|banana|banner|bar|barely|bargain|barrel|base|basic|basket|battle|beach|bean|beauty|because|become|beef|before|begin|behave|behind|believe|below|belt|bench|benefit|best|betray|better|between|beyond|bicycle|bid|bike|bind|biology|bird|birth|bitter|black|blade|blame|blanket|blast|bleak|bless|blind|blood|blossom|blouse|blue|blur|blush|board|boat|body|boil|bomb|bone|bonus|book|boost|border|boring|borrow|boss|bottom|bounce|box|boy|bracket|brain|brand|brass|brave|bread|breeze|brick|bridge|brief|bright|bring|brisk|broccoli|broken|bronze|broom|brother|brown|brush|bubble|buddy|budget|buffalo|build|bulb|bulk|bullet|bundle|bunker|burden|burger|burst|bus|business|busy|butter|buyer|buzz|cabbage|cabin|cable|cactus|cage|cake|call|calm|camera|camp|can|canal|cancel|candy|cannon|canoe|canvas|canyon|capable|capital|captain|car|carbon|card|cargo|carpet|carry|cart|case|cash|casino|castle|casual|cat|catalog|catch|category|cattle|caught|cause|caution|cave|ceiling|celery|cement|census|century|cereal|certain|chair|chalk|champion|change|chaos|chapter|charge|chase|chat|cheap|check|cheese|chef|cherry|chest|chicken|chief|child|chimney|choice|choose|chronic|chuckle|chunk|churn|cigar|cinnamon|circle|citizen|city|civil|claim|clap|clarify|claw|clay|clean|clerk|clever|click|client|cliff|climb|clinic|clip|clock|clog|close|cloth|cloud|clown|club|clump|cluster|clutch|coach|coast|coconut|code|coffee|coil|coin|collect|color|column|combine|come|comfort|comic|common|company|concert|conduct|confirm|congress|connect|consider|control|convince|cook|cool|copper|copy|coral|core|corn|correct|cost|cotton|couch|country|couple|course|cousin|cover|coyote|crack|cradle|craft|cram|crane|crash|crater|crawl|crazy|cream|credit|creek|crew|cricket|crime|crisp|critic|crop|cross|crouch|crowd|crucial|cruel|cruise|crumble|crunch|crush|cry|crystal|cube|culture|cup|cupboard|curious|current|curtain|curve|cushion|custom|cute|cycle|dad|damage|damp|dance|danger|daring|dash|daughter|dawn|day|deal|debate|debris|decade|december|decide|decline|decorate|decrease|deer|defense|define|defy|degree|delay|deliver|demand|demise|denial|dentist|deny|depart|depend|deposit|depth|deputy|derive|describe|desert|design|desk|despair|destroy|detail|detect|develop|device|devote|diagram|dial|diamond|diary|dice|diesel|diet|differ|digital|dignity|dilemma|dinner|dinosaur|direct|dirt|disagree|discover|disease|dish|dismiss|disorder|display|distance|divert|divide|divorce|dizzy|doctor|document|dog|doll|dolphin|domain|donate|donkey|donor|door|dose|double|dove|draft|dragon|drama|drastic|draw|dream|dress|drift|drill|drink|drip|drive|drop|drum|dry|duck|dumb|dune|during|dust|dutch|duty|dwarf|dynamic|eager|eagle|early|earn|earth|easily|east|easy|echo|ecology|economy|edge|edit|educate|effort|egg|eight|either|elbow|elder|electric|elegant|element|elephant|elevator|elite|else|embark|embody|embrace|emerge|emotion|employ|empower|empty|enable|enact|end|endless|endorse|enemy|energy|enforce|engage|engine|enhance|enjoy|enlist|enough|enrich|enroll|ensure|enter|entire|entry|envelope|episode|equal|equip|era|erase|erode|erosion|error|erupt|escape|essay|essence|estate|eternal|ethics|evidence|evil|evoke|evolve|exact|example|excess|exchange|excite|exclude|excuse|execute|exercise|exhaust|exhibit|exile|exist|exit|exotic|expand|expect|expire|explain|expose|express|extend|extra|eye|eyebrow|fabric|face|faculty|fade|faint|faith|fall|false|fame|family|famous|fan|fancy|fantasy|farm|fashion|fat|fatal|father|fatigue|fault|favorite|feature|february|federal|fee|feed|feel|female|fence|festival|fetch|fever|few|fiber|fiction|field|figure|file|film|filter|final|find|fine|finger|finish|fire|firm|first|fiscal|fish|fit|fitness|fix|flag|flame|flash|flat|flavor|flee|flight|flip|float|flock|floor|flower|fluid|flush|fly|foam|focus|fog|foil|fold|follow|food|foot|force|forest|forget|fork|fortune|forum|forward|fossil|foster|found|fox|fragile|frame|frequent|fresh|friend|fringe|frog|front|frost|frown|frozen|fruit|fuel|fun|funny|furnace|fury|future|gadget|gain|galaxy|gallery|game|gap|garage|garbage|garden|garlic|garment|gas|gasp|gate|gather|gauge|gaze|general|genius|genre|gentle|genuine|gesture|ghost|giant|gift|giggle|ginger|giraffe|girl|give|glad|glance|glare|glass|glide|glimpse|globe|gloom|glory|glove|glow|glue|goat|goddess|gold|good|goose|gorilla|gospel|gossip|govern|gown|grab|grace|grain|grant|grape|grass|gravity|great|green|grid|grief|grit|grocery|group|grow|grunt|guard|guess|guide|guilt|guitar|gun|gym|habit|hair|half|hammer|hamster|hand|happy|harbor|hard|harsh|harvest|hat|have|hawk|hazard|head|health|heart|heavy|hedgehog|height|hello|helmet|help|hen|hero|hidden|high|hill|hint|hip|hire|history|hobby|hockey|hold|hole|holiday|hollow|home|honey|hood|hope|horn|horror|horse|hospital|host|hotel|hour|hover|hub|huge|human|humble|humor|hundred|hungry|hunt|hurdle|hurry|hurt|husband|hybrid|ice|icon|idea|identify|idle|ignore|ill|illegal|illness|image|imitate|immense|immune|impact|impose|improve|impulse|inch|include|income|increase|index|indicate|indoor|industry|infant|inflict|inform|inhale|inherit|initial|inject|injury|inmate|inner|innocent|input|inquiry|insane|insect|inside|inspire|install|intact|interest|into|invest|invite|involve|iron|island|isolate|issue|item|ivory|jacket|jaguar|jar|jazz|jealous|jeans|jelly|jewel|job|join|joke|journey|joy|judge|juice|jump|jungle|junior|junk|just|kangaroo|keen|keep|ketchup|key|kick|kid|kidney|kind|kingdom|kiss|kit|kitchen|kite|kitten|kiwi|knee|knife|knock|know|lab|label|labor|ladder|lady|lake|lamp|language|laptop|large|later|latin|laugh|laundry|lava|law|lawn|lawsuit|layer|lazy|leader|leaf|learn|leave|lecture|left|leg|legal|legend|leisure|lemon|lend|length|lens|leopard|lesson|letter|level|liar|liberty|library|license|life|lift|light|like|limb|limit|link|lion|liquid|list|little|live|lizard|load|loan|lobster|local|lock|logic|lonely|long|loop|lottery|loud|lounge|love|loyal|lucky|luggage|lumber|lunar|lunch|luxury|lyrics|machine|mad|magic|magnet|maid|mail|main|major|make|mammal|man|manage|mandate|mango|mansion|manual|maple|marble|march|margin|marine|market|marriage|mask|mass|master|match|material|math|matrix|matter|maximum|maze|meadow|mean|measure|meat|mechanic|medal|media|melody|melt|member|memory|mention|menu|mercy|merge|merit|merry|mesh|message|metal|method|middle|midnight|milk|million|mimic|mind|minimum|minor|minute|miracle|mirror|misery|miss|mistake|mix|mixed|mixture|mobile|model|modify|mom|moment|monitor|monkey|monster|month|moon|moral|more|morning|mosquito|mother|motion|motor|mountain|mouse|move|movie|much|muffin|mule|multiply|muscle|museum|mushroom|music|must|mutual|myself|mystery|myth|naive|name|napkin|narrow|nasty|nation|nature|near|neck|need|negative|neglect|neither|nephew|nerve|nest|net|network|neutral|never|news|next|nice|night|noble|noise|nominee|noodle|normal|north|nose|notable|note|nothing|notice|novel|now|nuclear|number|nurse|nut|oak|obey|object|oblige|obscure|observe|obtain|obvious|occur|ocean|october|odor|off|offer|office|often|oil|okay|old|olive|olympic|omit|once|one|onion|online|only|open|opera|opinion|oppose|option|orange|orbit|orchard|order|ordinary|organ|orient|original|orphan|ostrich|other|outdoor|outer|output|outside|oval|oven|over|own|owner|oxygen|oyster|ozone|pact|paddle|page|pair|palace|palm|panda|panel|panic|panther|paper|parade|parent|park|parrot|party|pass|patch|path|patient|patrol|pattern|pause|pave|payment|peace|peanut|pear|peasant|pelican|pen|penalty|pencil|people|pepper|perfect|permit|person|pet|phone|photo|phrase|physical|piano|picnic|picture|piece|pig|pigeon|pill|pilot|pink|pioneer|pipe|pistol|pitch|pizza|place|planet|plastic|plate|play|please|pledge|pluck|plug|plunge|poem|poet|point|polar|pole|police|pond|pony|pool|popular|portion|position|possible|post|potato|pottery|poverty|powder|power|practice|praise|predict|prefer|prepare|present|pretty|prevent|price|pride|primary|print|priority|prison|private|prize|problem|process|produce|profit|program|project|promote|proof|property|prosper|protect|proud|provide|public|pudding|pull|pulp|pulse|pumpkin|punch|pupil|puppy|purchase|purity|purpose|purse|push|put|puzzle|pyramid|quality|quantum|quarter|question|quick|quit|quiz|quote|rabbit|raccoon|race|rack|radar|radio|rail|rain|raise|rally|ramp|ranch|random|range|rapid|rare|rate|rather|raven|raw|razor|ready|real|reason|rebel|rebuild|recall|receive|recipe|record|recycle|reduce|reflect|reform|refuse|region|regret|regular|reject|relax|release|relief|rely|remain|remember|remind|remove|render|renew|rent|reopen|repair|repeat|replace|report|require|rescue|resemble|resist|resource|response|result|retire|retreat|return|reunion|reveal|review|reward|rhythm|rib|ribbon|rice|rich|ride|ridge|rifle|right|rigid|ring|riot|ripple|risk|ritual|rival|river|road|roast|robot|robust|rocket|romance|roof|rookie|room|rose|rotate|rough|round|route|royal|rubber|rude|rug|rule|run|runway|rural|sad|saddle|sadness|safe|sail|salad|salmon|salon|salt|salute|same|sample|sand|satisfy|satoshi|sauce|sausage|save|say|scale|scan|scare|scatter|scene|scheme|school|science|scissors|scorpion|scout|scrap|screen|script|scrub|sea|search|season|seat|second|secret|section|security|seed|seek|segment|select|sell|seminar|senior|sense|sentence|series|service|session|settle|setup|seven|shadow|shaft|shallow|share|shed|shell|sheriff|shield|shift|shine|ship|shiver|shock|shoe|shoot|shop|short|shoulder|shove|shrimp|shrug|shuffle|shy|sibling|sick|side|siege|sight|sign|silent|silk|silly|silver|similar|simple|since|sing|siren|sister|situate|six|size|skate|sketch|ski|skill|skin|skirt|skull|slab|slam|sleep|slender|slice|slide|slight|slim|slogan|slot|slow|slush|small|smart|smile|smoke|smooth|snack|snake|snap|sniff|snow|soap|soccer|social|sock|soda|soft|solar|soldier|solid|solution|solve|someone|song|soon|sorry|sort|soul|sound|soup|source|south|space|spare|spatial|spawn|speak|special|speed|spell|spend|sphere|spice|spider|spike|spin|spirit|split|spoil|sponsor|spoon|sport|spot|spray|spread|spring|spy|square|squeeze|squirrel|stable|stadium|staff|stage|stairs|stamp|stand|start|state|stay|steak|steel|stem|step|stereo|stick|still|sting|stock|stomach|stone|stool|story|stove|strategy|street|strike|strong|struggle|student|stuff|stumble|style|subject|submit|subway|success|such|sudden|suffer|sugar|suggest|suit|summer|sun|sunny|sunset|super|supply|supreme|sure|surface|surge|surprise|surround|survey|suspect|sustain|swallow|swamp|swap|swarm|swear|sweet|swift|swim|swing|switch|sword|symbol|symptom|syrup|system|table|tackle|tag|tail|talent|talk|tank|tape|target|task|taste|tattoo|taxi|teach|team|tell|ten|tenant|tennis|tent|term|test|text|thank|that|theme|then|theory|there|they|thing|this|thought|three|thrive|throw|thumb|thunder|ticket|tide|tiger|tilt|timber|time|tiny|tip|tired|tissue|title|toast|tobacco|today|toddler|toe|together|toilet|token|tomato|tomorrow|tone|tongue|tonight|tool|tooth|top|topic|topple|torch|tornado|tortoise|toss|total|tourist|toward|tower|town|toy|track|trade|traffic|tragic|train|transfer|trap|trash|travel|tray|treat|tree|trend|trial|tribe|trick|trigger|trim|trip|trophy|trouble|truck|true|truly|trumpet|trust|truth|try|tube|tuition|tumble|tuna|tunnel|turkey|turn|turtle|twelve|twenty|twice|twin|twist|two|type|typical|ugly|umbrella|unable|unaware|uncle|uncover|under|undo|unfair|unfold|unhappy|uniform|unique|unit|universe|unknown|unlock|until|unusual|unveil|update|upgrade|uphold|upon|upper|upset|urban|urge|usage|use|used|useful|useless|usual|utility|vacant|vacuum|vague|valid|valley|valve|van|vanish|vapor|various|vast|vault|vehicle|velvet|vendor|venture|venue|verb|verify|version|very|vessel|veteran|viable|vibrant|vicious|victory|video|view|village|vintage|violin|virtual|virus|visa|visit|visual|vital|vivid|vocal|voice|void|volcano|volume|vote|voyage|wage|wagon|wait|walk|wall|walnut|want|warfare|warm|warrior|wash|wasp|waste|water|wave|way|wealth|weapon|wear|weasel|weather|web|wedding|weekend|weird|welcome|west|wet|whale|what|wheat|wheel|when|where|whip|whisper|wide|width|wife|wild|will|win|window|wine|wing|wink|winner|winter|wire|wisdom|wise|wish|witness|wolf|woman|wonder|wood|wool|word|work|world|worry|worth|wrap|wreck|wrestle|wrist|write|wrong|yard|year|yellow|you|young|youth|zebra|zero|zone|zoo".split("|"),F="Invalid entropy";function S(t){return Number.parseInt(t,2)}function j(t){return t.map(e=>e.toString(2).padStart(8,"0")).join("")}function V(t){return j(Array.from(C(t))).slice(0,t.length*8/32)}function $(t,e=M){if(t.length%4!==0||t.length<16||t.length>32)throw new Error(F);const r=`${j(Array.from(t))}${V(t)}`.match(/(.{1,11})/g)?.map(o=>e[S(o)]);if(!r||r.length<12)throw new Error("Unable to map entropy to mnemonic");return r.join(" ")}self.addEventListener("message",async t=>{const{taskId:e,task:a,data:r}=t.data;try{let o;switch(a){case"test":o="ready";break;case"entropyToMnemonic":if(!r.entropy)throw new Error("Entropy data is required");o=await G(r.entropy);break;default:throw new Error(`Unknown task: ${a}`)}const n={taskId:e,result:o};self.postMessage(n)}catch(o){const n={taskId:e,error:o instanceof Error?o.message:"Unknown error"};self.postMessage(n)}});async function G(t){try{return $(t)}catch(e){throw new Error(`Failed to process entropy: ${e instanceof Error?e.message:"Unknown error"}`)}}})();\n';
|
|
2
|
+
const blob = typeof self !== "undefined" && self.Blob && new Blob([jsContent], { type: "text/javascript;charset=utf-8" });
|
|
3
|
+
function WorkerWrapper(options) {
|
|
4
|
+
let objURL;
|
|
5
|
+
try {
|
|
6
|
+
objURL = blob && (self.URL || self.webkitURL).createObjectURL(blob);
|
|
7
|
+
if (!objURL) throw "";
|
|
8
|
+
const worker = new Worker(objURL, {
|
|
9
|
+
name: options?.name
|
|
10
|
+
});
|
|
11
|
+
worker.addEventListener("error", () => {
|
|
12
|
+
(self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
13
|
+
});
|
|
14
|
+
return worker;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return new Worker(
|
|
17
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent),
|
|
18
|
+
{
|
|
19
|
+
name: options?.name
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
} finally {
|
|
23
|
+
objURL && (self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
WorkerWrapper as default
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptoWorker.js","sourceRoot":"","sources":["../../src/workers/cryptoWorker.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAiBzD,IAAI,CAAC,gBAAgB,CACpB,SAAS,EACT,KAAK,EAAE,KAAwC,EAAE,EAAE;IAClD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;IAE1C,IAAI,CAAC;QACJ,IAAI,MAAc,CAAC;QAEnB,QAAQ,IAAI,EAAE,CAAC;YACd,KAAK,MAAM;gBAEV,MAAM,GAAG,OAAO,CAAC;gBACjB,MAAM;YACP,KAAK,mBAAmB;gBACvB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;oBACnB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;gBAC7C,CAAC;gBACD,MAAM,GAAG,MAAM,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACtD,MAAM;YACP;gBACC,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,QAAQ,GAAyB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC1D,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,QAAQ,GAAyB;YACtC,MAAM;YACN,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAC/D,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;AACF,CAAC,CACD,CAAC;AAGF,KAAK,UAAU,wBAAwB,CAAC,OAAmB;IAC1D,IAAI,CAAC;QAEJ,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACd,8BAA8B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CACxF,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workers/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workers/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/account",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Services and Utils for Prosopo account gen and management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
|
|
31
|
-
"build": "
|
|
32
|
-
"build:
|
|
31
|
+
"build": "npm run build:cross-env -- --mode ${NODE_ENV:-development}",
|
|
32
|
+
"build:cross-env": "vite build --config vite.esm.config.ts",
|
|
33
|
+
"build:tsc": "npm run typecheck && npm run build",
|
|
33
34
|
"build:cjs": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
|
|
34
35
|
"typecheck": "tsc --project tsconfig.types.json"
|
|
35
36
|
},
|
|
@@ -49,15 +50,15 @@
|
|
|
49
50
|
"@polkadot/extension-inject": "0.62.3",
|
|
50
51
|
"@polkadot/util": "13.5.7",
|
|
51
52
|
"@polkadot/util-crypto": "13.5.7",
|
|
52
|
-
"@prosopo/common": "3.1.
|
|
53
|
-
"@prosopo/fingerprint": "2.6.
|
|
54
|
-
"@prosopo/keyring": "2.
|
|
55
|
-
"@prosopo/types": "3.
|
|
56
|
-
"@prosopo/util": "3.2.
|
|
57
|
-
"@prosopo/util-crypto": "13.5.
|
|
53
|
+
"@prosopo/common": "3.1.28",
|
|
54
|
+
"@prosopo/fingerprint": "2.6.28",
|
|
55
|
+
"@prosopo/keyring": "2.9.0",
|
|
56
|
+
"@prosopo/types": "3.8.0",
|
|
57
|
+
"@prosopo/util": "3.2.5",
|
|
58
|
+
"@prosopo/util-crypto": "13.5.29"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@prosopo/config": "3.
|
|
61
|
+
"@prosopo/config": "3.3.0",
|
|
61
62
|
"@types/node": "22.10.2",
|
|
62
63
|
"@vitest/coverage-v8": "3.2.4",
|
|
63
64
|
"concurrently": "9.0.1",
|
package/vite.cjs.config.ts
CHANGED
package/vite.esm.config.ts
CHANGED