@prosopo/keyring 2.8.6 → 2.8.8

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/accounts/getPair.js +33 -32
  3. package/dist/accounts/index.js +10 -4
  4. package/dist/accounts/mnemonic.js +15 -12
  5. package/dist/accounts/testAccounts.js +41 -35
  6. package/dist/cjs/accounts/getPair.cjs +2 -2
  7. package/dist/cjs/accounts/mnemonic.cjs +1 -2
  8. package/dist/index.js +19 -4
  9. package/dist/keyring/index.js +7 -3
  10. package/dist/keyring/keyring.js +255 -130
  11. package/dist/keyring/pairs.js +24 -27
  12. package/dist/pair/decode.js +26 -24
  13. package/dist/pair/defaults.js +30 -8
  14. package/dist/pair/encode.js +16 -14
  15. package/dist/pair/index.js +139 -134
  16. package/dist/pair/toJson.js +11 -6
  17. package/package.json +18 -14
  18. package/vite.cjs.config.ts +4 -1
  19. package/vite.esm.config.ts +20 -0
  20. package/vite.test.config.ts +32 -0
  21. package/dist/accounts/getPair.d.ts +0 -5
  22. package/dist/accounts/getPair.d.ts.map +0 -1
  23. package/dist/accounts/getPair.js.map +0 -1
  24. package/dist/accounts/index.d.ts +0 -4
  25. package/dist/accounts/index.d.ts.map +0 -1
  26. package/dist/accounts/index.js.map +0 -1
  27. package/dist/accounts/mnemonic.d.ts +0 -5
  28. package/dist/accounts/mnemonic.d.ts.map +0 -1
  29. package/dist/accounts/mnemonic.js.map +0 -1
  30. package/dist/accounts/testAccounts.d.ts +0 -4
  31. package/dist/accounts/testAccounts.d.ts.map +0 -1
  32. package/dist/accounts/testAccounts.js.map +0 -1
  33. package/dist/cjs/dist/accounts/getPair.cjs +0 -41
  34. package/dist/cjs/dist/accounts/index.cjs +0 -10
  35. package/dist/cjs/dist/accounts/mnemonic.cjs +0 -19
  36. package/dist/cjs/dist/accounts/testAccounts.cjs +0 -42
  37. package/dist/cjs/dist/index.cjs +0 -6
  38. package/dist/cjs/dist/keyring/index.cjs +0 -7
  39. package/dist/cjs/dist/keyring/keyring.cjs +0 -138
  40. package/dist/cjs/dist/keyring/pairs.cjs +0 -31
  41. package/dist/cjs/dist/pair/decode.cjs +0 -32
  42. package/dist/cjs/dist/pair/defaults.cjs +0 -31
  43. package/dist/cjs/dist/pair/encode.cjs +0 -18
  44. package/dist/cjs/dist/pair/index.cjs +0 -143
  45. package/dist/cjs/dist/pair/toJson.cjs +0 -11
  46. package/dist/index.d.ts +0 -4
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.js.map +0 -1
  49. package/dist/keyring/index.d.ts +0 -3
  50. package/dist/keyring/index.d.ts.map +0 -1
  51. package/dist/keyring/index.js.map +0 -1
  52. package/dist/keyring/keyring.d.ts +0 -36
  53. package/dist/keyring/keyring.d.ts.map +0 -1
  54. package/dist/keyring/keyring.js.map +0 -1
  55. package/dist/keyring/pairs.d.ts +0 -9
  56. package/dist/keyring/pairs.d.ts.map +0 -1
  57. package/dist/keyring/pairs.js.map +0 -1
  58. package/dist/keyring/testing.d.ts +0 -14
  59. package/dist/keyring/testing.d.ts.map +0 -1
  60. package/dist/keyring/testing.js +0 -76
  61. package/dist/keyring/testing.js.map +0 -1
  62. package/dist/keyring/testingPairs.d.ts +0 -26
  63. package/dist/keyring/testingPairs.d.ts.map +0 -1
  64. package/dist/keyring/testingPairs.js +0 -14
  65. package/dist/keyring/testingPairs.js.map +0 -1
  66. package/dist/pair/decode.d.ts +0 -6
  67. package/dist/pair/decode.d.ts.map +0 -1
  68. package/dist/pair/decode.js.map +0 -1
  69. package/dist/pair/decode.spec.d.ts +0 -2
  70. package/dist/pair/decode.spec.d.ts.map +0 -1
  71. package/dist/pair/decode.spec.js +0 -13
  72. package/dist/pair/decode.spec.js.map +0 -1
  73. package/dist/pair/defaults.d.ts +0 -7
  74. package/dist/pair/defaults.d.ts.map +0 -1
  75. package/dist/pair/defaults.js.map +0 -1
  76. package/dist/pair/encode.d.ts +0 -3
  77. package/dist/pair/encode.d.ts.map +0 -1
  78. package/dist/pair/encode.js.map +0 -1
  79. package/dist/pair/encode.spec.d.ts +0 -2
  80. package/dist/pair/encode.spec.d.ts.map +0 -1
  81. package/dist/pair/encode.spec.js +0 -16
  82. package/dist/pair/encode.spec.js.map +0 -1
  83. package/dist/pair/index.d.ts +0 -11
  84. package/dist/pair/index.d.ts.map +0 -1
  85. package/dist/pair/index.js.map +0 -1
  86. package/dist/pair/nobody.d.ts +0 -3
  87. package/dist/pair/nobody.d.ts.map +0 -1
  88. package/dist/pair/nobody.js +0 -40
  89. package/dist/pair/nobody.js.map +0 -1
  90. package/dist/pair/toJson.d.ts +0 -9
  91. package/dist/pair/toJson.d.ts.map +0 -1
  92. package/dist/pair/toJson.js.map +0 -1
  93. package/dist/pair/toJson.spec.d.ts +0 -2
  94. package/dist/pair/toJson.spec.d.ts.map +0 -1
  95. package/dist/pair/toJson.spec.js +0 -33
  96. package/dist/pair/toJson.spec.js.map +0 -1
@@ -1,151 +1,156 @@
1
- import { objectSpread, u8aConcat, u8aEmpty, u8aToHex, u8aToU8a, } from "@polkadot/util";
2
- import { blake2AsU8a } from "@prosopo/util-crypto";
3
- import { keyExtractPath, keyFromPath } from "@prosopo/util-crypto";
4
- import { secp256k1Compress } from "@prosopo/util-crypto";
5
- import { signatureVerify } from "@prosopo/util-crypto";
6
- import { sr25519FromSeed, sr25519Sign } from "@prosopo/util-crypto";
7
- import { sr25519VrfSign, sr25519VrfVerify } from "@prosopo/util-crypto";
1
+ import { u8aEmpty, u8aConcat, u8aToU8a, u8aToHex, objectSpread } from "@polkadot/util";
2
+ import { sr25519FromSeed, sr25519Sign, blake2AsU8a, sr25519VrfVerify, sr25519VrfSign, signatureVerify, secp256k1Compress, keyExtractPath, keyFromPath } from "@prosopo/util-crypto";
8
3
  import { decodePair } from "./decode.js";
9
4
  import { encodePair } from "./encode.js";
10
5
  import { pairToJson } from "./toJson.js";
11
6
  const SIG_TYPE_NONE = new Uint8Array([]);
12
7
  const TYPE_FROM_SEED = {
13
- sr25519: sr25519FromSeed,
14
- ed25519: () => {
15
- throw new Error("Not Implemented");
16
- },
17
- ecdsa: () => {
18
- throw new Error("Not Implemented");
19
- },
20
- ethereum: () => {
21
- throw new Error("Not Implemented");
22
- },
8
+ sr25519: sr25519FromSeed,
9
+ ed25519: () => {
10
+ throw new Error("Not Implemented");
11
+ },
12
+ ecdsa: () => {
13
+ throw new Error("Not Implemented");
14
+ },
15
+ ethereum: () => {
16
+ throw new Error("Not Implemented");
17
+ }
23
18
  };
24
19
  const TYPE_PREFIX = {
25
- ecdsa: new Uint8Array([2]),
26
- ed25519: new Uint8Array([0]),
27
- ethereum: new Uint8Array([2]),
28
- sr25519: new Uint8Array([1]),
20
+ ecdsa: new Uint8Array([2]),
21
+ ed25519: new Uint8Array([0]),
22
+ ethereum: new Uint8Array([2]),
23
+ sr25519: new Uint8Array([1])
29
24
  };
30
25
  const TYPE_SIGNATURE = {
31
- sr25519: sr25519Sign,
32
- ed25519: () => {
33
- throw new Error("Not Implemented");
34
- },
35
- ecdsa: () => {
36
- throw new Error("Not Implemented");
37
- },
38
- ethereum: () => {
39
- throw new Error("Not Implemented");
40
- },
26
+ sr25519: sr25519Sign,
27
+ ed25519: () => {
28
+ throw new Error("Not Implemented");
29
+ },
30
+ ecdsa: () => {
31
+ throw new Error("Not Implemented");
32
+ },
33
+ ethereum: () => {
34
+ throw new Error("Not Implemented");
35
+ }
41
36
  };
42
37
  const TYPE_ADDRESS = {
43
- sr25519: (p) => p,
44
- ed25519: () => {
45
- throw new Error("Not Implemented");
46
- },
47
- ecdsa: () => {
48
- throw new Error("Not Implemented");
49
- },
50
- ethereum: () => {
51
- throw new Error("Not Implemented");
52
- },
38
+ sr25519: (p) => p,
39
+ ed25519: () => {
40
+ throw new Error("Not Implemented");
41
+ },
42
+ ecdsa: () => {
43
+ throw new Error("Not Implemented");
44
+ },
45
+ ethereum: () => {
46
+ throw new Error("Not Implemented");
47
+ }
53
48
  };
54
49
  function isLocked(secretKey) {
55
- return !secretKey || u8aEmpty(secretKey);
50
+ return !secretKey || u8aEmpty(secretKey);
56
51
  }
57
52
  function vrfHash(proof, context, extra) {
58
- return blake2AsU8a(u8aConcat(context || "", extra || "", proof));
53
+ return blake2AsU8a(u8aConcat(context || "", extra || "", proof));
59
54
  }
60
- export function createPair({ toSS58, type }, { publicKey, secretKey }, meta = {}, encoded = null, encTypes) {
61
- const decodePkcs8 = (passphrase, userEncoded) => {
62
- const decoded = decodePair(passphrase, userEncoded || encoded, encTypes);
63
- if (decoded.secretKey.length === 64) {
64
- publicKey = decoded.publicKey;
65
- secretKey = decoded.secretKey;
66
- }
67
- else {
68
- const pair = TYPE_FROM_SEED[type](decoded.secretKey);
69
- publicKey = pair.publicKey;
70
- secretKey = pair.secretKey;
71
- }
72
- };
73
- const recode = (passphrase) => {
74
- isLocked(secretKey) && encoded && decodePkcs8(passphrase, encoded);
75
- encoded = encodePair({ publicKey, secretKey }, passphrase);
76
- encTypes = undefined;
77
- return encoded;
78
- };
79
- const encodeAddress = () => {
80
- const raw = TYPE_ADDRESS[type](publicKey);
81
- return toSS58(raw);
82
- };
83
- return {
84
- get address() {
85
- return encodeAddress();
86
- },
87
- get addressRaw() {
88
- return TYPE_ADDRESS[type](publicKey);
89
- },
90
- get isLocked() {
91
- return isLocked(secretKey);
92
- },
93
- get meta() {
94
- return meta;
95
- },
96
- get publicKey() {
97
- return publicKey;
98
- },
99
- get type() {
100
- return type;
101
- },
102
- decodePkcs8,
103
- derive: (suri, meta) => {
104
- if (isLocked(secretKey)) {
105
- throw new Error("Cannot derive on a locked keypair");
106
- }
107
- const { path } = keyExtractPath(suri);
108
- const derived = keyFromPath({ publicKey, secretKey }, path, type);
109
- return createPair({ toSS58, type }, derived, meta, null);
110
- },
111
- encodePkcs8: (passphrase) => {
112
- return recode(passphrase);
113
- },
114
- lock: () => {
115
- secretKey = new Uint8Array([]);
116
- },
117
- setMeta: (additional) => {
118
- meta = objectSpread({}, meta, additional);
119
- },
120
- sign: (message, options = {}) => {
121
- if (isLocked(secretKey)) {
122
- throw new Error("Cannot sign with a locked key pair");
123
- }
124
- return u8aConcat(options.withType ? TYPE_PREFIX[type] : SIG_TYPE_NONE, TYPE_SIGNATURE[type](u8aToU8a(message), { publicKey, secretKey }));
125
- },
126
- toJson: (passphrase) => {
127
- const address = ["ecdsa", "ethereum"].includes(type)
128
- ? publicKey.length === 20
129
- ? u8aToHex(publicKey)
130
- : u8aToHex(secp256k1Compress(publicKey))
131
- : encodeAddress();
132
- return pairToJson(type, { address, meta }, recode(passphrase), !!passphrase);
133
- },
134
- unlock: (passphrase) => {
135
- decodePkcs8(passphrase);
136
- },
137
- verify: (message, signature, signerPublic) => {
138
- return signatureVerify(message, signature, TYPE_ADDRESS[type](u8aToU8a(signerPublic))).isValid;
139
- },
140
- vrfSign: (message, context, extra) => {
141
- if (isLocked(secretKey)) {
142
- throw new Error("Cannot sign with a locked key pair");
143
- }
144
- return sr25519VrfSign(message, { secretKey }, context, extra);
145
- },
146
- vrfVerify: (message, vrfResult, signerPublic, context, extra) => {
147
- return sr25519VrfVerify(message, vrfResult, publicKey, context, extra);
148
- },
149
- };
55
+ function createPair({ toSS58, type }, { publicKey, secretKey }, meta = {}, encoded = null, encTypes) {
56
+ const decodePkcs8 = (passphrase, userEncoded) => {
57
+ const decoded = decodePair(passphrase, userEncoded || encoded, encTypes);
58
+ if (decoded.secretKey.length === 64) {
59
+ publicKey = decoded.publicKey;
60
+ secretKey = decoded.secretKey;
61
+ } else {
62
+ const pair = TYPE_FROM_SEED[type](decoded.secretKey);
63
+ publicKey = pair.publicKey;
64
+ secretKey = pair.secretKey;
65
+ }
66
+ };
67
+ const recode = (passphrase) => {
68
+ isLocked(secretKey) && encoded && decodePkcs8(passphrase, encoded);
69
+ encoded = encodePair({ publicKey, secretKey }, passphrase);
70
+ encTypes = void 0;
71
+ return encoded;
72
+ };
73
+ const encodeAddress = () => {
74
+ const raw = TYPE_ADDRESS[type](publicKey);
75
+ return toSS58(raw);
76
+ };
77
+ return {
78
+ get address() {
79
+ return encodeAddress();
80
+ },
81
+ get addressRaw() {
82
+ return TYPE_ADDRESS[type](publicKey);
83
+ },
84
+ get isLocked() {
85
+ return isLocked(secretKey);
86
+ },
87
+ get meta() {
88
+ return meta;
89
+ },
90
+ get publicKey() {
91
+ return publicKey;
92
+ },
93
+ get type() {
94
+ return type;
95
+ },
96
+ // eslint-disable-next-line sort-keys
97
+ decodePkcs8,
98
+ derive: (suri, meta2) => {
99
+ if (isLocked(secretKey)) {
100
+ throw new Error("Cannot derive on a locked keypair");
101
+ }
102
+ const { path } = keyExtractPath(suri);
103
+ const derived = keyFromPath({ publicKey, secretKey }, path, type);
104
+ return createPair({ toSS58, type }, derived, meta2, null);
105
+ },
106
+ encodePkcs8: (passphrase) => {
107
+ return recode(passphrase);
108
+ },
109
+ lock: () => {
110
+ secretKey = new Uint8Array([]);
111
+ },
112
+ setMeta: (additional) => {
113
+ meta = objectSpread({}, meta, additional);
114
+ },
115
+ sign: (message, options = {}) => {
116
+ if (isLocked(secretKey)) {
117
+ throw new Error("Cannot sign with a locked key pair");
118
+ }
119
+ return u8aConcat(
120
+ options.withType ? TYPE_PREFIX[type] : SIG_TYPE_NONE,
121
+ TYPE_SIGNATURE[type](u8aToU8a(message), { publicKey, secretKey })
122
+ );
123
+ },
124
+ toJson: (passphrase) => {
125
+ const address = ["ecdsa", "ethereum"].includes(type) ? publicKey.length === 20 ? u8aToHex(publicKey) : u8aToHex(secp256k1Compress(publicKey)) : encodeAddress();
126
+ return pairToJson(
127
+ type,
128
+ { address, meta },
129
+ recode(passphrase),
130
+ !!passphrase
131
+ );
132
+ },
133
+ unlock: (passphrase) => {
134
+ decodePkcs8(passphrase);
135
+ },
136
+ verify: (message, signature, signerPublic) => {
137
+ return signatureVerify(
138
+ message,
139
+ signature,
140
+ TYPE_ADDRESS[type](u8aToU8a(signerPublic))
141
+ ).isValid;
142
+ },
143
+ vrfSign: (message, context, extra) => {
144
+ if (isLocked(secretKey)) {
145
+ throw new Error("Cannot sign with a locked key pair");
146
+ }
147
+ return sr25519VrfSign(message, { secretKey }, context, extra);
148
+ },
149
+ vrfVerify: (message, vrfResult, signerPublic, context, extra) => {
150
+ return sr25519VrfVerify(message, vrfResult, publicKey, context, extra);
151
+ }
152
+ };
150
153
  }
151
- //# sourceMappingURL=index.js.map
154
+ export {
155
+ createPair
156
+ };
@@ -1,9 +1,14 @@
1
1
  import { objectSpread } from "@polkadot/util";
2
2
  import { jsonEncryptFormat } from "@prosopo/util-crypto";
3
- export function pairToJson(type, { address, meta }, encoded, isEncrypted) {
4
- return objectSpread(jsonEncryptFormat(encoded, ["pkcs8", type], isEncrypted), {
5
- address,
6
- meta,
7
- });
3
+ function pairToJson(type, { address, meta }, encoded, isEncrypted) {
4
+ return objectSpread(
5
+ jsonEncryptFormat(encoded, ["pkcs8", type], isEncrypted),
6
+ {
7
+ address,
8
+ meta
9
+ }
10
+ );
8
11
  }
9
- //# sourceMappingURL=toJson.js.map
12
+ export {
13
+ pairToJson
14
+ };
package/package.json CHANGED
@@ -1,24 +1,28 @@
1
1
  {
2
2
  "name": "@prosopo/keyring",
3
- "version": "2.8.6",
3
+ "version": "2.8.8",
4
4
  "description": "Keypair generator for Prosopo",
5
5
  "main": "dist/index.js",
6
- "type": "module",
7
- "engines": {
8
- "node": "20",
9
- "npm": "10.8.2"
10
- },
6
+ "types": "dist/index.d.ts",
11
7
  "exports": {
12
8
  ".": {
9
+ "types": "./dist/index.d.ts",
13
10
  "import": "./dist/index.js",
14
11
  "require": "./dist/cjs/index.cjs"
15
12
  }
16
13
  },
14
+ "type": "module",
15
+ "engines": {
16
+ "node": "20",
17
+ "npm": "10.8.2"
18
+ },
17
19
  "scripts": {
18
- "test": "echo \"No test specified\"",
19
- "clean": "tsc --build --clean",
20
- "build": "tsc --build --verbose",
21
- "build:cjs": "npx vite --config vite.cjs.config.ts build"
20
+ "clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
21
+ "build": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
22
+ "build:tsc": "tsc --build --verbose",
23
+ "build:cjs": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
24
+ "typecheck": "tsc --build --declaration --emitDeclarationOnly --force",
25
+ "test": "NODE_ENV=${NODE_ENV:-test}; npx vitest run --config ./vite.test.config.ts --mode $NODE_ENV"
22
26
  },
23
27
  "repository": {
24
28
  "type": "git",
@@ -34,9 +38,10 @@
34
38
  "@noble/curves": "1.9.2",
35
39
  "@noble/hashes": "^1.5.0",
36
40
  "@polkadot/util": "12.6.2",
37
- "@prosopo/common": "3.0.2",
38
- "@prosopo/types": "3.0.3",
39
- "@prosopo/util-crypto": "13.5.1",
41
+ "@prosopo/common": "3.1.1",
42
+ "@prosopo/config": "3.1.2",
43
+ "@prosopo/types": "3.0.5",
44
+ "@prosopo/util-crypto": "13.5.3",
40
45
  "@typegoose/auto-increment": "4.13.0",
41
46
  "axios": "1.10.0",
42
47
  "esbuild": "0.25.6",
@@ -44,7 +49,6 @@
44
49
  "webpack-dev-server": "5.2.2"
45
50
  },
46
51
  "devDependencies": {
47
- "@prosopo/config": "3.1.0",
48
52
  "@vitest/coverage-v8": "3.0.9",
49
53
  "concurrently": "9.0.1",
50
54
  "del-cli": "6.0.0",
@@ -15,5 +15,8 @@ import path from "node:path";
15
15
  import { ViteCommonJSConfig } from "@prosopo/config";
16
16
 
17
17
  export default function () {
18
- return ViteCommonJSConfig("util", path.resolve("./tsconfig.cjs.json"));
18
+ return ViteCommonJSConfig(
19
+ path.basename("."),
20
+ path.resolve("./tsconfig.json"),
21
+ );
19
22
  }
@@ -0,0 +1,20 @@
1
+ // Copyright 2021-2025 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import path from "node:path";
16
+ import { ViteEsmConfig } from "@prosopo/config";
17
+
18
+ export default function () {
19
+ return ViteEsmConfig(path.basename("."), path.resolve("./tsconfig.json"));
20
+ }
@@ -0,0 +1,32 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ // Copyright 2021-2025 Prosopo (UK) Ltd.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ import { ViteTestConfig } from "@prosopo/config";
17
+ import dotenv from "dotenv";
18
+ process.env.NODE_ENV = "test";
19
+ // if .env.test exists at this level, use it, otherwise use the one at the root
20
+ const envFile = `.env.${process.env.NODE_ENV || "development"}`;
21
+ let envPath = envFile;
22
+ if (fs.existsSync(envFile)) {
23
+ envPath = path.resolve(envFile);
24
+ } else if (fs.existsSync(`../../${envFile}`)) {
25
+ envPath = path.resolve(`../../${envFile}`);
26
+ } else {
27
+ throw new Error(`No ${envFile} file found`);
28
+ }
29
+
30
+ dotenv.config({ path: envPath });
31
+
32
+ export default ViteTestConfig();
@@ -1,5 +0,0 @@
1
- import type { PolkadotSecretJSON } from "@prosopo/types";
2
- import type { KeyringPair, KeyringPair$Json } from "@prosopo/types";
3
- import type { KeypairType } from "@prosopo/util-crypto";
4
- export declare function getPair(secret?: string | KeyringPair$Json | PolkadotSecretJSON, account?: string | Uint8Array, pairType?: KeypairType, ss58Format?: number): KeyringPair;
5
- //# sourceMappingURL=getPair.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getPair.d.ts","sourceRoot":"","sources":["../../src/accounts/getPair.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,wBAAgB,OAAO,CACtB,MAAM,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,kBAAkB,EACvD,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,EAC7B,QAAQ,CAAC,EAAE,WAAW,EACtB,UAAU,CAAC,EAAE,MAAM,GACjB,WAAW,CAkCb"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getPair.js","sourceRoot":"","sources":["../../src/accounts/getPair.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,MAAM,UAAU,OAAO,CACtB,MAAuD,EACvD,OAA6B,EAC7B,QAAsB,EACtB,UAAmB;IAEnB,QAAQ,GAAG,QAAQ,IAAI,SAAS,CAAC;IACjC,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAC5D,IAAI,CAAC,MAAM,IAAI,OAAO,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACnB,OAAO,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAChC,MAAM,EACL,QAAQ,EAAE,EAAE,OAAO,EAAE,GACrB,GAAG,IAAI,CAAC;YACT,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;YAC9D,OAAO,OAAO,CAAC,WAAW,CAAC,IAAwB,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,MAAM,IAAI,eAAe,CAAC,6BAA6B,EAAE;gBACxD,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;aACrB,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,OAAO,CAAC,WAAW,CAAC,MAA0B,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACP,MAAM,IAAI,eAAe,CAAC,6BAA6B,CAAC,CAAC;IAC1D,CAAC;AACF,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from "./mnemonic.js";
2
- export * from "./getPair.js";
3
- export * from "./testAccounts.js";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/accounts/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/accounts/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
@@ -1,5 +0,0 @@
1
- import { Keyring } from "@prosopo/keyring";
2
- import type { KeypairType } from "@prosopo/util-crypto";
3
- export declare function generateMnemonic(keyring?: Keyring, pairType?: KeypairType): Promise<[string, string]>;
4
- export declare function generateMiniSecret(keyring?: Keyring, pairType?: KeypairType): Promise<[Uint8Array, string]>;
5
- //# sourceMappingURL=mnemonic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mnemonic.d.ts","sourceRoot":"","sources":["../../src/accounts/mnemonic.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD,wBAAsB,gBAAgB,CACrC,OAAO,CAAC,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAO3B;AAMD,wBAAsB,kBAAkB,CACvC,OAAO,CAAC,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAG/B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mnemonic.js","sourceRoot":"","sources":["../../src/accounts/mnemonic.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAO9E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACrC,OAAiB,EACjB,QAAsB;IAEtB,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,IAAI,SAAS,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,OAAiB,EACjB,QAAsB;IAEtB,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtE,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC"}
@@ -1,4 +0,0 @@
1
- import { type IProviderAccount, type ISite } from "@prosopo/types";
2
- export declare function getDefaultSiteKeys(): ISite[];
3
- export declare function getDefaultProviders(): IProviderAccount[];
4
- //# sourceMappingURL=testAccounts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testAccounts.d.ts","sourceRoot":"","sources":["../../src/accounts/testAccounts.ts"],"names":[],"mappings":"AAcA,OAAO,EAGN,KAAK,gBAAgB,EACrB,KAAK,KAAK,EACV,MAAM,gBAAgB,CAAC;AAIxB,wBAAgB,kBAAkB,IAAI,KAAK,EAAE,CAqB5C;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,EAAE,CAcxD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"testAccounts.js","sourceRoot":"","sources":["../../src/accounts/testAccounts.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,WAAW,EACX,oBAAoB,GAGpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,UAAU,kBAAkB;IACjC,MAAM,YAAY,GAAG;QACpB,WAAW,CAAC,KAAK;QACjB,WAAW,CAAC,GAAG;QACf,WAAW,CAAC,YAAY;QACxB,WAAW,CAAC,SAAS;KACrB,CAAC;IACF,MAAM,KAAK,GAAY,EAAE,CAAC;IAC1B,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,GAAG,UAAU,KAAK,WAAW,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,oBAAoB,CAAC,KAAK,CAAC;gBACpC,WAAW,EAAE,WAAW;aACxB,CAAC;SACF,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,mBAAmB;IAClC,MAAM,IAAI,GAAG,OAAO,CACnB,oFAAoF,CACpF,CAAC;IACF,OAAO;QACN;YACC,GAAG,EAAE,uBAAuB;YAC5B,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,0BAA0B;YACvC,gBAAgB,EACf,oEAAoE;SACrE;KACD,CAAC;AACH,CAAC"}
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const hex = require("@polkadot/util/hex");
4
- const is = require("@polkadot/util/is");
5
- const common = require("@prosopo/common");
6
- const utilCrypto = require("@prosopo/util-crypto");
7
- const keyring = require("../keyring/keyring.cjs");
8
- function getPair(secret, account, pairType, ss58Format) {
9
- pairType = pairType || "sr25519";
10
- ss58Format = ss58Format || 42;
11
- const keyring$1 = new keyring.Keyring({ type: pairType, ss58Format });
12
- if (!secret && account) {
13
- return keyring$1.addFromAddress(account);
14
- }
15
- if (secret && typeof secret === "string") {
16
- if (utilCrypto.mnemonicValidate(secret)) {
17
- return keyring$1.addFromMnemonic(secret);
18
- }
19
- if (is.isHex(secret)) {
20
- return keyring$1.addFromSeed(hex.hexToU8a(secret));
21
- }
22
- if (secret.includes("//")) {
23
- return keyring$1.addFromUri(secret);
24
- }
25
- try {
26
- const json = JSON.parse(secret);
27
- const { encoding: { content } } = json;
28
- const keyring$12 = new keyring.Keyring({ type: content[1], ss58Format });
29
- return keyring$12.addFromJson(json);
30
- } catch (e) {
31
- throw new common.ProsopoEnvError("GENERAL.NO_MNEMONIC_OR_SEED", {
32
- context: { error: e }
33
- });
34
- }
35
- } else if (typeof secret === "object") {
36
- return keyring$1.addFromJson(secret);
37
- } else {
38
- throw new common.ProsopoEnvError("GENERAL.NO_MNEMONIC_OR_SEED");
39
- }
40
- }
41
- exports.getPair = getPair;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const mnemonic = require("./mnemonic.cjs");
4
- const getPair = require("./getPair.cjs");
5
- const testAccounts = require("./testAccounts.cjs");
6
- exports.generateMiniSecret = mnemonic.generateMiniSecret;
7
- exports.generateMnemonic = mnemonic.generateMnemonic;
8
- exports.getPair = getPair.getPair;
9
- exports.getDefaultProviders = testAccounts.getDefaultProviders;
10
- exports.getDefaultSiteKeys = testAccounts.getDefaultSiteKeys;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- require("../index.cjs");
4
- const utilCrypto = require("@prosopo/util-crypto");
5
- const keyring = require("../keyring/keyring.cjs");
6
- async function generateMnemonic(keyring$1, pairType) {
7
- if (!keyring$1) {
8
- keyring$1 = new keyring.Keyring({ type: pairType || "sr25519" });
9
- }
10
- const mnemonic = utilCrypto.mnemonicGenerate();
11
- const account = keyring$1.addFromMnemonic(mnemonic);
12
- return [mnemonic, account.address];
13
- }
14
- async function generateMiniSecret(keyring2, pairType) {
15
- const [mnemonic, address] = await generateMnemonic(keyring2, pairType);
16
- return [utilCrypto.mnemonicToMiniSecret(mnemonic), address];
17
- }
18
- exports.generateMiniSecret = generateMiniSecret;
19
- exports.generateMnemonic = generateMnemonic;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const types = require("@prosopo/types");
4
- require("../keyring/index.cjs");
5
- const getPair = require("./getPair.cjs");
6
- const keyring = require("../keyring/keyring.cjs");
7
- function getDefaultSiteKeys() {
8
- const captchaTypes = [
9
- types.CaptchaType.image,
10
- types.CaptchaType.pow,
11
- types.CaptchaType.frictionless,
12
- types.CaptchaType.invisible
13
- ];
14
- const sites = [];
15
- for (const captchaType of captchaTypes) {
16
- const secret = `${keyring.DEV_PHRASE}//${captchaType}`;
17
- const pair = getPair.getPair(secret);
18
- sites.push({
19
- pair,
20
- address: pair.address,
21
- secret,
22
- settings: types.ClientSettingsSchema.parse({
23
- captchaType
24
- })
25
- });
26
- }
27
- return sites;
28
- }
29
- function getDefaultProviders() {
30
- const pair = getPair.getPair("puppy cream effort carbon despair leg pyramid cotton endorse immense drill peasant");
31
- return [
32
- {
33
- url: "http://localhost:9229",
34
- pair,
35
- address: pair.address,
36
- datasetFile: "./dev/data/captchas.json",
37
- captchaDatasetId: "0x3e067b8f6aeae82fdbe2b2557b9c2d90aaabff241df651bf0f36667d2ab0018d"
38
- }
39
- ];
40
- }
41
- exports.getDefaultProviders = getDefaultProviders;
42
- exports.getDefaultSiteKeys = getDefaultSiteKeys;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- require("./accounts/index.cjs");
4
- require("./keyring/index.cjs");
5
- const index = require("./pair/index.cjs");
6
- exports.createPair = index.createPair;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const keyring = require("./keyring.cjs");
4
- const pairs = require("./pairs.cjs");
5
- exports.DEV_PHRASE = keyring.DEV_PHRASE;
6
- exports.Keyring = keyring.Keyring;
7
- exports.Pairs = pairs.Pairs;