@prosopo/keyring 2.9.59 → 2.9.61
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 +21 -19
- package/.turbo/turbo-build$colon$tsc.log +11 -11
- package/.turbo/turbo-build.log +23 -20
- package/CHANGELOG.md +19 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/accounts/getPair.js +28 -38
- package/dist/accounts/index.js +1 -7
- package/dist/accounts/mnemonic.js +17 -13
- package/dist/accounts/testAccounts.js +36 -42
- package/dist/cjs/accounts/getPair.cjs +30 -40
- package/dist/cjs/accounts/index.cjs +8 -10
- package/dist/cjs/accounts/mnemonic.cjs +19 -14
- package/dist/cjs/accounts/testAccounts.cjs +36 -41
- package/dist/cjs/index.cjs +15 -18
- package/dist/cjs/keyring/index.cjs +5 -7
- package/dist/cjs/keyring/keyring.cjs +257 -266
- package/dist/cjs/keyring/pairs.cjs +23 -27
- package/dist/cjs/pair/decode.cjs +31 -29
- package/dist/cjs/pair/defaults.cjs +28 -28
- package/dist/cjs/pair/encode.cjs +14 -15
- package/dist/cjs/pair/index.cjs +191 -167
- package/dist/cjs/pair/toJson.cjs +8 -11
- package/dist/index.js +4 -15
- package/dist/keyring/index.js +2 -6
- package/dist/keyring/keyring.js +254 -265
- package/dist/keyring/pairs.js +22 -26
- package/dist/pair/decode.js +29 -29
- package/dist/pair/defaults.js +29 -30
- package/dist/pair/encode.js +14 -15
- package/dist/pair/index.js +188 -165
- package/dist/pair/toJson.js +8 -11
- package/package.json +8 -8
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/keyring@2.9.
|
|
2
|
+
> @prosopo/keyring@2.9.61 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -23,23 +23,25 @@ ViteCommonJSConfig: .
|
|
|
23
23
|
'@prosopo/util-crypto'
|
|
24
24
|
]
|
|
25
25
|
}
|
|
26
|
-
[
|
|
26
|
+
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
27
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
27
28
|
Bundle build started
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
[32m✓[39m 13 modules transformed.
|
|
29
|
+
[2K
|
|
30
|
+
✓ 14 modules transformed.
|
|
31
31
|
rendering chunks...
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
computing gzip size...
|
|
33
|
+
dist/cjs/keyring/index.cjs 0.22 kB │ gzip: 0.11 kB
|
|
34
|
+
dist/cjs/pair/toJson.cjs 0.40 kB │ gzip: 0.25 kB
|
|
35
|
+
dist/cjs/pair/defaults.cjs 0.45 kB │ gzip: 0.25 kB
|
|
36
|
+
dist/cjs/accounts/index.cjs 0.47 kB │ gzip: 0.17 kB
|
|
37
|
+
dist/cjs/keyring/pairs.cjs 0.86 kB │ gzip: 0.38 kB
|
|
38
|
+
dist/cjs/index.cjs 0.91 kB │ gzip: 0.31 kB
|
|
39
|
+
dist/cjs/pair/encode.cjs 0.91 kB │ gzip: 0.44 kB
|
|
40
|
+
dist/cjs/accounts/mnemonic.cjs 0.95 kB │ gzip: 0.38 kB
|
|
41
|
+
dist/cjs/accounts/testAccounts.cjs 1.31 kB │ gzip: 0.63 kB
|
|
42
|
+
dist/cjs/accounts/getPair.cjs 1.41 kB │ gzip: 0.60 kB
|
|
43
|
+
dist/cjs/pair/decode.cjs 1.77 kB │ gzip: 0.70 kB
|
|
44
|
+
dist/cjs/pair/index.cjs 7.26 kB │ gzip: 2.12 kB
|
|
45
|
+
dist/cjs/keyring/keyring.cjs 11.14 kB │ gzip: 3.05 kB
|
|
46
|
+
|
|
47
|
+
[32m✓ built in 85ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/keyring@2.9.
|
|
2
|
+
> @prosopo/keyring@2.9.61 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
8:59:09 PM - Projects in this build:
|
|
6
6
|
* ../../dev/config/tsconfig.json
|
|
7
7
|
* ../locale/tsconfig.json
|
|
8
8
|
* ../util/tsconfig.json
|
|
@@ -12,21 +12,21 @@
|
|
|
12
12
|
* ../common/tsconfig.json
|
|
13
13
|
* tsconfig.json
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
8:59:09 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
8:59:09 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
8:59:09 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
8:59:09 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
8:59:09 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
8:59:09 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/provider/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
8:59:09 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/tests/utils/batches.unit.test.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
8:59:09 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
8:59:09 PM - Building project '/home/runner/work/captcha/captcha/packages/keyring/tsconfig.json'...
|
|
32
32
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/keyring@2.9.
|
|
2
|
+
> @prosopo/keyring@2.9.61 build
|
|
3
3
|
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @prosopo/keyring@2.9.
|
|
6
|
+
> @prosopo/keyring@2.9.61 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -27,23 +27,26 @@ ViteEsmConfig: .
|
|
|
27
27
|
'@prosopo/util-crypto'
|
|
28
28
|
]
|
|
29
29
|
}
|
|
30
|
-
[
|
|
30
|
+
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
31
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
31
32
|
Bundle build started
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
[32m✓[39m 13 modules transformed.
|
|
33
|
+
[2K
|
|
34
|
+
✓ 14 modules transformed.
|
|
35
35
|
rendering chunks...
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
computing gzip size...
|
|
37
|
+
dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
|
|
38
|
+
dist/keyring/index.js 0.12 kB │ gzip: 0.09 kB
|
|
39
|
+
dist/accounts/index.js 0.28 kB │ gzip: 0.14 kB
|
|
40
|
+
dist/pair/toJson.js 0.34 kB │ gzip: 0.22 kB
|
|
41
|
+
dist/pair/defaults.js 0.42 kB │ gzip: 0.25 kB
|
|
42
|
+
dist/index.js 0.54 kB │ gzip: 0.23 kB
|
|
43
|
+
dist/keyring/pairs.js 0.71 kB │ gzip: 0.36 kB
|
|
44
|
+
dist/pair/encode.js 0.77 kB │ gzip: 0.41 kB
|
|
45
|
+
dist/accounts/mnemonic.js 0.84 kB │ gzip: 0.36 kB
|
|
46
|
+
dist/accounts/testAccounts.js 1.14 kB │ gzip: 0.60 kB
|
|
47
|
+
dist/accounts/getPair.js 1.24 kB │ gzip: 0.56 kB
|
|
48
|
+
dist/pair/decode.js 1.48 kB │ gzip: 0.66 kB
|
|
49
|
+
dist/pair/index.js 6.96 kB │ gzip: 2.09 kB
|
|
50
|
+
dist/keyring/keyring.js 10.74 kB │ gzip: 2.99 kB
|
|
51
|
+
|
|
52
|
+
[32m✓ built in 83ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @prosopo/keyring
|
|
2
2
|
|
|
3
|
+
## 2.9.61
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- e14fce6: chore(deps): bump vite to 6.4.3 and mongoose to 8.24.1, and adjust types for the mongoose 8.24 Document/ObjectId changes
|
|
7
|
+
- Updated dependencies [2c47bb7]
|
|
8
|
+
- Updated dependencies [0e1171c]
|
|
9
|
+
- Updated dependencies [103318c]
|
|
10
|
+
- Updated dependencies [270a8d8]
|
|
11
|
+
- Updated dependencies [e14fce6]
|
|
12
|
+
- @prosopo/util@3.3.5
|
|
13
|
+
- @prosopo/types@4.10.0
|
|
14
|
+
- @prosopo/common@3.1.48
|
|
15
|
+
|
|
16
|
+
## 2.9.60
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [a0cb39e]
|
|
20
|
+
- @prosopo/types@4.9.12
|
|
21
|
+
|
|
3
22
|
## 2.9.59
|
|
4
23
|
### Patch Changes
|
|
5
24
|
|
package/dist/accounts/getPair.js
CHANGED
|
@@ -1,43 +1,33 @@
|
|
|
1
|
+
import { Keyring } from "../keyring/keyring.js";
|
|
2
|
+
import { mnemonicValidate } from "@prosopo/util-crypto";
|
|
1
3
|
import { hexToU8a } from "@polkadot/util/hex";
|
|
2
4
|
import { isHex } from "@polkadot/util/is";
|
|
3
5
|
import { ProsopoEnvError } from "@prosopo/common";
|
|
4
|
-
|
|
5
|
-
import { Keyring } from "../keyring/keyring.js";
|
|
6
|
+
//#region src/accounts/getPair.ts
|
|
6
7
|
function getPair(secret, account, pairType, ss58Format) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} catch (e) {
|
|
31
|
-
throw new ProsopoEnvError("GENERAL.MISSING_SECRET_KEY", {
|
|
32
|
-
context: { error: e }
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
} else if (typeof secret === "object") {
|
|
36
|
-
return keyring.addFromJson(secret);
|
|
37
|
-
} else {
|
|
38
|
-
throw new ProsopoEnvError("GENERAL.MISSING_SECRET_KEY");
|
|
39
|
-
}
|
|
8
|
+
pairType = pairType || "sr25519";
|
|
9
|
+
ss58Format = ss58Format || 42;
|
|
10
|
+
const keyring = new Keyring({
|
|
11
|
+
type: pairType,
|
|
12
|
+
ss58Format
|
|
13
|
+
});
|
|
14
|
+
if (!secret && account) return keyring.addFromAddress(account);
|
|
15
|
+
if (secret && typeof secret === "string") {
|
|
16
|
+
if (mnemonicValidate(secret)) return keyring.addFromMnemonic(secret);
|
|
17
|
+
if (isHex(secret)) return keyring.addFromSeed(hexToU8a(secret));
|
|
18
|
+
if (secret.includes("//")) return keyring.addFromUri(secret);
|
|
19
|
+
try {
|
|
20
|
+
const json = JSON.parse(secret);
|
|
21
|
+
const { encoding: { content } } = json;
|
|
22
|
+
return new Keyring({
|
|
23
|
+
type: content[1],
|
|
24
|
+
ss58Format
|
|
25
|
+
}).addFromJson(json);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
throw new ProsopoEnvError("GENERAL.MISSING_SECRET_KEY", { context: { error: e } });
|
|
28
|
+
}
|
|
29
|
+
} else if (typeof secret === "object") return keyring.addFromJson(secret);
|
|
30
|
+
else throw new ProsopoEnvError("GENERAL.MISSING_SECRET_KEY");
|
|
40
31
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { getPair };
|
package/dist/accounts/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { generateMiniSecret, generateMnemonic } from "./mnemonic.js";
|
|
2
2
|
import { getPair } from "./getPair.js";
|
|
3
3
|
import { getDefaultProviders, getDefaultSiteKeys } from "./testAccounts.js";
|
|
4
|
-
export {
|
|
5
|
-
generateMiniSecret,
|
|
6
|
-
generateMnemonic,
|
|
7
|
-
getDefaultProviders,
|
|
8
|
-
getDefaultSiteKeys,
|
|
9
|
-
getPair
|
|
10
|
-
};
|
|
4
|
+
export { generateMiniSecret, generateMnemonic, getDefaultProviders, getDefaultSiteKeys, getPair };
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { mnemonicGenerate, mnemonicToMiniSecret } from "@prosopo/util-crypto";
|
|
2
1
|
import { Keyring } from "../keyring/keyring.js";
|
|
2
|
+
import { mnemonicGenerate, mnemonicToMiniSecret } from "@prosopo/util-crypto";
|
|
3
|
+
//#region src/accounts/mnemonic.ts
|
|
4
|
+
/** Generate a mnemonic, returning the mnemonic and associated address
|
|
5
|
+
* @param keyring
|
|
6
|
+
* @param pairType
|
|
7
|
+
*/
|
|
3
8
|
async function generateMnemonic(keyring, pairType) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const mnemonic = mnemonicGenerate();
|
|
8
|
-
const account = keyring.addFromMnemonic(mnemonic);
|
|
9
|
-
return [mnemonic, account.address];
|
|
9
|
+
if (!keyring) keyring = new Keyring({ type: pairType || "sr25519" });
|
|
10
|
+
const mnemonic = mnemonicGenerate();
|
|
11
|
+
return [mnemonic, keyring.addFromMnemonic(mnemonic).address];
|
|
10
12
|
}
|
|
13
|
+
/** Generate a secret, returning the secret and associated address
|
|
14
|
+
* @param keyring
|
|
15
|
+
* @param pairType
|
|
16
|
+
*/
|
|
11
17
|
async function generateMiniSecret(keyring, pairType) {
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
const [mnemonic, address] = await generateMnemonic(keyring, pairType);
|
|
19
|
+
return [mnemonicToMiniSecret(mnemonic), address];
|
|
14
20
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
generateMnemonic
|
|
18
|
-
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { generateMiniSecret, generateMnemonic };
|
|
@@ -1,47 +1,41 @@
|
|
|
1
|
-
import { CaptchaType, ClientSettingsSchema } from "@prosopo/types";
|
|
2
|
-
import "../keyring/index.js";
|
|
3
|
-
import { getPair } from "./getPair.js";
|
|
4
1
|
import { DEV_PHRASE } from "../keyring/keyring.js";
|
|
2
|
+
import { getPair } from "./getPair.js";
|
|
3
|
+
import { CaptchaType, ClientSettingsSchema } from "@prosopo/types";
|
|
4
|
+
//#region src/accounts/testAccounts.ts
|
|
5
5
|
function getDefaultSiteKeys() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
const captchaTypes = [
|
|
7
|
+
CaptchaType.image,
|
|
8
|
+
CaptchaType.pow,
|
|
9
|
+
CaptchaType.frictionless,
|
|
10
|
+
CaptchaType.puzzle
|
|
11
|
+
];
|
|
12
|
+
const sites = [];
|
|
13
|
+
for (const captchaType of captchaTypes) {
|
|
14
|
+
const secret = `${DEV_PHRASE}//${captchaType}`;
|
|
15
|
+
const pair = getPair(secret);
|
|
16
|
+
sites.push({
|
|
17
|
+
pair,
|
|
18
|
+
address: pair.address,
|
|
19
|
+
secret,
|
|
20
|
+
settings: ClientSettingsSchema.parse({
|
|
21
|
+
captchaType,
|
|
22
|
+
domains: ["localhost"],
|
|
23
|
+
imageMaxRounds: 2,
|
|
24
|
+
frictionlessThreshold: .8
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return sites;
|
|
29
29
|
}
|
|
30
30
|
function getDefaultProviders() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
datasetFile: "./dev/data/captchas.json",
|
|
40
|
-
captchaDatasetId: "0x3e067b8f6aeae82fdbe2b2557b9c2d90aaabff241df651bf0f36667d2ab0018d"
|
|
41
|
-
}
|
|
42
|
-
];
|
|
31
|
+
const pair = getPair("puppy cream effort carbon despair leg pyramid cotton endorse immense drill peasant");
|
|
32
|
+
return [{
|
|
33
|
+
url: "https://localhost:9229",
|
|
34
|
+
pair,
|
|
35
|
+
address: pair.address,
|
|
36
|
+
datasetFile: "./dev/data/captchas.json",
|
|
37
|
+
captchaDatasetId: "0x3e067b8f6aeae82fdbe2b2557b9c2d90aaabff241df651bf0f36667d2ab0018d"
|
|
38
|
+
}];
|
|
43
39
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
getDefaultSiteKeys
|
|
47
|
-
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { getDefaultProviders, getDefaultSiteKeys };
|
|
@@ -1,43 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const keyring = require("../keyring/keyring.cjs");
|
|
1
|
+
const require_keyring = require("../keyring/keyring.cjs");
|
|
2
|
+
let _prosopo_util_crypto = require("@prosopo/util-crypto");
|
|
3
|
+
let _polkadot_util_hex = require("@polkadot/util/hex");
|
|
4
|
+
let _polkadot_util_is = require("@polkadot/util/is");
|
|
5
|
+
let _prosopo_common = require("@prosopo/common");
|
|
6
|
+
//#region src/accounts/getPair.ts
|
|
8
7
|
function getPair(secret, account, pairType, ss58Format) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} catch (e) {
|
|
33
|
-
throw new common.ProsopoEnvError("GENERAL.MISSING_SECRET_KEY", {
|
|
34
|
-
context: { error: e }
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
} else if (typeof secret === "object") {
|
|
38
|
-
return keyring$1.addFromJson(secret);
|
|
39
|
-
} else {
|
|
40
|
-
throw new common.ProsopoEnvError("GENERAL.MISSING_SECRET_KEY");
|
|
41
|
-
}
|
|
8
|
+
pairType = pairType || "sr25519";
|
|
9
|
+
ss58Format = ss58Format || 42;
|
|
10
|
+
const keyring = new require_keyring.Keyring({
|
|
11
|
+
type: pairType,
|
|
12
|
+
ss58Format
|
|
13
|
+
});
|
|
14
|
+
if (!secret && account) return keyring.addFromAddress(account);
|
|
15
|
+
if (secret && typeof secret === "string") {
|
|
16
|
+
if ((0, _prosopo_util_crypto.mnemonicValidate)(secret)) return keyring.addFromMnemonic(secret);
|
|
17
|
+
if ((0, _polkadot_util_is.isHex)(secret)) return keyring.addFromSeed((0, _polkadot_util_hex.hexToU8a)(secret));
|
|
18
|
+
if (secret.includes("//")) return keyring.addFromUri(secret);
|
|
19
|
+
try {
|
|
20
|
+
const json = JSON.parse(secret);
|
|
21
|
+
const { encoding: { content } } = json;
|
|
22
|
+
return new require_keyring.Keyring({
|
|
23
|
+
type: content[1],
|
|
24
|
+
ss58Format
|
|
25
|
+
}).addFromJson(json);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
throw new _prosopo_common.ProsopoEnvError("GENERAL.MISSING_SECRET_KEY", { context: { error: e } });
|
|
28
|
+
}
|
|
29
|
+
} else if (typeof secret === "object") return keyring.addFromJson(secret);
|
|
30
|
+
else throw new _prosopo_common.ProsopoEnvError("GENERAL.MISSING_SECRET_KEY");
|
|
42
31
|
}
|
|
32
|
+
//#endregion
|
|
43
33
|
exports.getPair = getPair;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.getPair =
|
|
9
|
-
exports.getDefaultProviders = testAccounts.getDefaultProviders;
|
|
10
|
-
exports.getDefaultSiteKeys = testAccounts.getDefaultSiteKeys;
|
|
1
|
+
const require_mnemonic = require("./mnemonic.cjs");
|
|
2
|
+
const require_getPair = require("./getPair.cjs");
|
|
3
|
+
const require_testAccounts = require("./testAccounts.cjs");
|
|
4
|
+
exports.generateMiniSecret = require_mnemonic.generateMiniSecret;
|
|
5
|
+
exports.generateMnemonic = require_mnemonic.generateMnemonic;
|
|
6
|
+
exports.getDefaultProviders = require_testAccounts.getDefaultProviders;
|
|
7
|
+
exports.getDefaultSiteKeys = require_testAccounts.getDefaultSiteKeys;
|
|
8
|
+
exports.getPair = require_getPair.getPair;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
const require_keyring = require("../keyring/keyring.cjs");
|
|
2
|
+
let _prosopo_util_crypto = require("@prosopo/util-crypto");
|
|
3
|
+
//#region src/accounts/mnemonic.ts
|
|
4
|
+
/** Generate a mnemonic, returning the mnemonic and associated address
|
|
5
|
+
* @param keyring
|
|
6
|
+
* @param pairType
|
|
7
|
+
*/
|
|
8
|
+
async function generateMnemonic(keyring, pairType) {
|
|
9
|
+
if (!keyring) keyring = new require_keyring.Keyring({ type: pairType || "sr25519" });
|
|
10
|
+
const mnemonic = (0, _prosopo_util_crypto.mnemonicGenerate)();
|
|
11
|
+
return [mnemonic, keyring.addFromMnemonic(mnemonic).address];
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/** Generate a secret, returning the secret and associated address
|
|
14
|
+
* @param keyring
|
|
15
|
+
* @param pairType
|
|
16
|
+
*/
|
|
17
|
+
async function generateMiniSecret(keyring, pairType) {
|
|
18
|
+
const [mnemonic, address] = await generateMnemonic(keyring, pairType);
|
|
19
|
+
return [(0, _prosopo_util_crypto.mnemonicToMiniSecret)(mnemonic), address];
|
|
16
20
|
}
|
|
21
|
+
//#endregion
|
|
17
22
|
exports.generateMiniSecret = generateMiniSecret;
|
|
18
23
|
exports.generateMnemonic = generateMnemonic;
|
|
@@ -1,47 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const getPair = require("./getPair.cjs");
|
|
6
|
-
const keyring = require("../keyring/keyring.cjs");
|
|
1
|
+
const require_keyring = require("../keyring/keyring.cjs");
|
|
2
|
+
const require_getPair = require("./getPair.cjs");
|
|
3
|
+
let _prosopo_types = require("@prosopo/types");
|
|
4
|
+
//#region src/accounts/testAccounts.ts
|
|
7
5
|
function getDefaultSiteKeys() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
6
|
+
const captchaTypes = [
|
|
7
|
+
_prosopo_types.CaptchaType.image,
|
|
8
|
+
_prosopo_types.CaptchaType.pow,
|
|
9
|
+
_prosopo_types.CaptchaType.frictionless,
|
|
10
|
+
_prosopo_types.CaptchaType.puzzle
|
|
11
|
+
];
|
|
12
|
+
const sites = [];
|
|
13
|
+
for (const captchaType of captchaTypes) {
|
|
14
|
+
const secret = `${require_keyring.DEV_PHRASE}//${captchaType}`;
|
|
15
|
+
const pair = require_getPair.getPair(secret);
|
|
16
|
+
sites.push({
|
|
17
|
+
pair,
|
|
18
|
+
address: pair.address,
|
|
19
|
+
secret,
|
|
20
|
+
settings: _prosopo_types.ClientSettingsSchema.parse({
|
|
21
|
+
captchaType,
|
|
22
|
+
domains: ["localhost"],
|
|
23
|
+
imageMaxRounds: 2,
|
|
24
|
+
frictionlessThreshold: .8
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return sites;
|
|
31
29
|
}
|
|
32
30
|
function getDefaultProviders() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
datasetFile: "./dev/data/captchas.json",
|
|
42
|
-
captchaDatasetId: "0x3e067b8f6aeae82fdbe2b2557b9c2d90aaabff241df651bf0f36667d2ab0018d"
|
|
43
|
-
}
|
|
44
|
-
];
|
|
31
|
+
const pair = require_getPair.getPair("puppy cream effort carbon despair leg pyramid cotton endorse immense drill peasant");
|
|
32
|
+
return [{
|
|
33
|
+
url: "https://localhost:9229",
|
|
34
|
+
pair,
|
|
35
|
+
address: pair.address,
|
|
36
|
+
datasetFile: "./dev/data/captchas.json",
|
|
37
|
+
captchaDatasetId: "0x3e067b8f6aeae82fdbe2b2557b9c2d90aaabff241df651bf0f36667d2ab0018d"
|
|
38
|
+
}];
|
|
45
39
|
}
|
|
40
|
+
//#endregion
|
|
46
41
|
exports.getDefaultProviders = getDefaultProviders;
|
|
47
42
|
exports.getDefaultSiteKeys = getDefaultSiteKeys;
|