@prosopo/keyring 2.5.5 → 2.6.2
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/CHANGELOG.md +27 -0
- package/dist/cjs/accounts/getPair.cjs +49 -0
- package/dist/cjs/accounts/index.cjs +8 -0
- package/dist/cjs/accounts/mnemonic.cjs +20 -0
- package/dist/cjs/index.cjs +9 -0
- package/package.json +6 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @prosopo/keyring
|
|
2
|
+
|
|
3
|
+
## 2.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [6ff193a]
|
|
8
|
+
- @prosopo/types@2.6.2
|
|
9
|
+
|
|
10
|
+
## 2.6.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [52feffc]
|
|
15
|
+
- @prosopo/types@2.6.1
|
|
16
|
+
|
|
17
|
+
## 2.6.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- a0bfc8a: bump all pkg versions since independent versioning applied
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [a0bfc8a]
|
|
26
|
+
- @prosopo/common@2.6.0
|
|
27
|
+
- @prosopo/types@2.6.0
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const keyring = require("@polkadot/keyring");
|
|
4
|
+
const utilCrypto = require("@polkadot/util-crypto");
|
|
5
|
+
const mnemonic = require("@polkadot/util-crypto/mnemonic");
|
|
6
|
+
const hex = require("@polkadot/util/hex");
|
|
7
|
+
const is = require("@polkadot/util/is");
|
|
8
|
+
const common = require("@prosopo/common");
|
|
9
|
+
async function getPairAsync(secret, account, pairType, ss58Format) {
|
|
10
|
+
await utilCrypto.cryptoWaitReady();
|
|
11
|
+
return getPair(secret, account, pairType, ss58Format);
|
|
12
|
+
}
|
|
13
|
+
function getPair(secret, account, pairType, ss58Format) {
|
|
14
|
+
pairType = pairType || "sr25519";
|
|
15
|
+
ss58Format = ss58Format || 42;
|
|
16
|
+
const keyring$1 = new keyring.Keyring({ type: pairType, ss58Format });
|
|
17
|
+
if (!secret && account) {
|
|
18
|
+
return keyring$1.addFromAddress(account);
|
|
19
|
+
}
|
|
20
|
+
if (secret && typeof secret === "string") {
|
|
21
|
+
if (mnemonic.mnemonicValidate(secret)) {
|
|
22
|
+
return keyring$1.addFromMnemonic(secret);
|
|
23
|
+
}
|
|
24
|
+
if (is.isHex(secret)) {
|
|
25
|
+
return keyring$1.addFromSeed(hex.hexToU8a(secret));
|
|
26
|
+
}
|
|
27
|
+
if (secret.startsWith("//")) {
|
|
28
|
+
return keyring$1.addFromUri(secret);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const json = JSON.parse(secret);
|
|
32
|
+
const {
|
|
33
|
+
encoding: { content }
|
|
34
|
+
} = json;
|
|
35
|
+
const keyring2 = new keyring.Keyring({ type: content[1], ss58Format });
|
|
36
|
+
return keyring2.addFromJson(json);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new common.ProsopoEnvError("GENERAL.NO_MNEMONIC_OR_SEED", {
|
|
39
|
+
context: { error: e }
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
} else if (typeof secret === "object") {
|
|
43
|
+
return keyring$1.addFromJson(secret);
|
|
44
|
+
} else {
|
|
45
|
+
throw new common.ProsopoEnvError("GENERAL.NO_MNEMONIC_OR_SEED");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.getPair = getPair;
|
|
49
|
+
exports.getPairAsync = getPairAsync;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const mnemonic = require("./mnemonic.cjs");
|
|
4
|
+
const getPair = require("./getPair.cjs");
|
|
5
|
+
exports.generateMiniSecret = mnemonic.generateMiniSecret;
|
|
6
|
+
exports.generateMnemonic = mnemonic.generateMnemonic;
|
|
7
|
+
exports.getPair = getPair.getPair;
|
|
8
|
+
exports.getPairAsync = getPair.getPairAsync;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const keyring = require("@polkadot/keyring");
|
|
4
|
+
const utilCrypto = require("@polkadot/util-crypto");
|
|
5
|
+
const mnemonic = require("@polkadot/util-crypto/mnemonic");
|
|
6
|
+
async function generateMnemonic(keyring$1, pairType) {
|
|
7
|
+
if (!keyring$1) {
|
|
8
|
+
keyring$1 = new keyring.Keyring({ type: pairType || "sr25519" });
|
|
9
|
+
}
|
|
10
|
+
await utilCrypto.cryptoWaitReady();
|
|
11
|
+
const mnemonic$1 = mnemonic.mnemonicGenerate();
|
|
12
|
+
const account = keyring$1.addFromMnemonic(mnemonic$1);
|
|
13
|
+
return [mnemonic$1, account.address];
|
|
14
|
+
}
|
|
15
|
+
async function generateMiniSecret(keyring2, pairType) {
|
|
16
|
+
const [mnemonic$1, address] = await generateMnemonic(keyring2, pairType);
|
|
17
|
+
return [mnemonic.mnemonicToMiniSecret(mnemonic$1), address];
|
|
18
|
+
}
|
|
19
|
+
exports.generateMiniSecret = generateMiniSecret;
|
|
20
|
+
exports.generateMnemonic = generateMnemonic;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("./accounts/index.cjs");
|
|
4
|
+
const mnemonic = require("./accounts/mnemonic.cjs");
|
|
5
|
+
const getPair = require("./accounts/getPair.cjs");
|
|
6
|
+
exports.generateMiniSecret = mnemonic.generateMiniSecret;
|
|
7
|
+
exports.generateMnemonic = mnemonic.generateMnemonic;
|
|
8
|
+
exports.getPair = getPair.getPair;
|
|
9
|
+
exports.getPairAsync = getPair.getPairAsync;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/keyring",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "Keypair generator for Prosopo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "git+
|
|
25
|
+
"url": "git+https://github.com/prosopo/captcha.git",
|
|
26
|
+
"directory": "packages/keyring"
|
|
26
27
|
},
|
|
27
28
|
"author": "Prosopo Limited",
|
|
28
29
|
"license": "Apache-2.0",
|
|
@@ -34,11 +35,11 @@
|
|
|
34
35
|
"@polkadot/keyring": "12.6.2",
|
|
35
36
|
"@polkadot/util": "12.6.2",
|
|
36
37
|
"@polkadot/util-crypto": "12.6.2",
|
|
37
|
-
"@prosopo/common": "2.
|
|
38
|
-
"@prosopo/types": "2.
|
|
38
|
+
"@prosopo/common": "2.6.0",
|
|
39
|
+
"@prosopo/types": "2.6.2"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@prosopo/config": "2.
|
|
42
|
+
"@prosopo/config": "2.6.0",
|
|
42
43
|
"@vitest/coverage-v8": "3.0.9",
|
|
43
44
|
"concurrently": "9.0.1",
|
|
44
45
|
"del-cli": "6.0.0",
|