@prosopo/keyring 2.8.40 → 2.9.34
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 +8 -6
- package/.turbo/turbo-build$colon$tsc.log +32 -0
- package/.turbo/turbo-build.log +13 -7
- package/CHANGELOG.md +296 -0
- package/dist/accounts/getPair.d.ts +5 -0
- package/dist/accounts/getPair.d.ts.map +1 -0
- package/dist/accounts/getPair.js.map +1 -0
- package/dist/accounts/index.d.ts +4 -0
- package/dist/accounts/index.d.ts.map +1 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/accounts/mnemonic.d.ts +5 -0
- package/dist/accounts/mnemonic.d.ts.map +1 -0
- package/dist/accounts/mnemonic.js.map +1 -0
- package/dist/accounts/testAccounts.d.ts +4 -0
- package/dist/accounts/testAccounts.d.ts.map +1 -0
- package/dist/accounts/testAccounts.js +6 -3
- package/dist/accounts/testAccounts.js.map +1 -0
- package/dist/cjs/accounts/testAccounts.cjs +6 -3
- package/dist/cjs/pair/index.cjs +21 -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/keyring/index.d.ts +3 -0
- package/dist/keyring/index.d.ts.map +1 -0
- package/dist/keyring/index.js.map +1 -0
- package/dist/keyring/keyring.d.ts +36 -0
- package/dist/keyring/keyring.d.ts.map +1 -0
- package/dist/keyring/keyring.js.map +1 -0
- package/dist/keyring/pairs.d.ts +9 -0
- package/dist/keyring/pairs.d.ts.map +1 -0
- package/dist/keyring/pairs.js.map +1 -0
- package/dist/keyring/testing.d.ts +14 -0
- package/dist/keyring/testing.d.ts.map +1 -0
- package/dist/keyring/testing.js +76 -0
- package/dist/keyring/testing.js.map +1 -0
- package/dist/keyring/testingPairs.d.ts +26 -0
- package/dist/keyring/testingPairs.d.ts.map +1 -0
- package/dist/keyring/testingPairs.js +14 -0
- package/dist/keyring/testingPairs.js.map +1 -0
- package/dist/pair/decode.d.ts +6 -0
- package/dist/pair/decode.d.ts.map +1 -0
- package/dist/pair/decode.js.map +1 -0
- package/dist/pair/decode.spec.d.ts +2 -0
- package/dist/pair/decode.spec.d.ts.map +1 -0
- package/dist/pair/decode.spec.js +13 -0
- package/dist/pair/decode.spec.js.map +1 -0
- package/dist/pair/defaults.d.ts +7 -0
- package/dist/pair/defaults.d.ts.map +1 -0
- package/dist/pair/defaults.js.map +1 -0
- package/dist/pair/encode.d.ts +3 -0
- package/dist/pair/encode.d.ts.map +1 -0
- package/dist/pair/encode.js.map +1 -0
- package/dist/pair/encode.spec.d.ts +2 -0
- package/dist/pair/encode.spec.d.ts.map +1 -0
- package/dist/pair/encode.spec.js +16 -0
- package/dist/pair/encode.spec.js.map +1 -0
- package/dist/pair/index.d.ts +11 -0
- package/dist/pair/index.d.ts.map +1 -0
- package/dist/pair/index.js +22 -1
- package/dist/pair/index.js.map +1 -0
- package/dist/pair/nobody.d.ts +3 -0
- package/dist/pair/nobody.d.ts.map +1 -0
- package/dist/pair/nobody.js +48 -0
- package/dist/pair/nobody.js.map +1 -0
- package/dist/pair/toJson.d.ts +9 -0
- package/dist/pair/toJson.d.ts.map +1 -0
- package/dist/pair/toJson.js.map +1 -0
- package/dist/pair/toJson.spec.d.ts +2 -0
- package/dist/pair/toJson.spec.d.ts.map +1 -0
- package/dist/pair/toJson.spec.js +33 -0
- package/dist/pair/toJson.spec.js.map +1 -0
- package/package.json +10 -8
- package/src/accounts/getPair.ts +63 -0
- package/src/accounts/index.ts +16 -0
- package/src/accounts/mnemonic.ts +45 -0
- package/src/accounts/testAccounts.ts +66 -0
- package/src/index.ts +16 -0
- package/src/keyring/index.ts +15 -0
- package/src/keyring/keyring.ts +411 -0
- package/src/keyring/pairs.ts +44 -0
- package/src/keyring/testing.ts +119 -0
- package/src/keyring/testingPairs.ts +61 -0
- package/src/pair/decode.spec.ts +23 -0
- package/src/pair/decode.ts +65 -0
- package/src/pair/defaults.ts +22 -0
- package/src/pair/encode.spec.ts +24 -0
- package/src/pair/encode.ts +32 -0
- package/src/pair/index.ts +304 -0
- package/src/pair/nobody.ts +78 -0
- package/src/pair/toJson.spec.ts +40 -0
- package/src/pair/toJson.ts +28 -0
- package/tsconfig.cjs.json +30 -0
- package/tsconfig.json +33 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsconfig.types.json +9 -0
- package/vite.cjs.config.ts +1 -1
- package/vite.esm.config.ts +1 -1
- package/vite.test.config.ts +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright 2017-2025 @polkadot/keyring authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
KeyringPair,
|
|
6
|
+
KeyringPair$Json,
|
|
7
|
+
KeyringPair$Meta,
|
|
8
|
+
} from "@prosopo/types";
|
|
9
|
+
import type { JWT, JWTVerifyResult } from "@prosopo/util-crypto";
|
|
10
|
+
|
|
11
|
+
// empty publicKey
|
|
12
|
+
const publicKey = new Uint8Array(32);
|
|
13
|
+
|
|
14
|
+
// pre-computed via encodeAddress(publicKey)
|
|
15
|
+
const address = "5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM";
|
|
16
|
+
|
|
17
|
+
const meta = {
|
|
18
|
+
isTesting: true,
|
|
19
|
+
name: "nobody",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const json: KeyringPair$Json = {
|
|
23
|
+
address,
|
|
24
|
+
encoded: "",
|
|
25
|
+
encoding: {
|
|
26
|
+
content: ["pkcs8", "ed25519"],
|
|
27
|
+
type: "none",
|
|
28
|
+
version: "0",
|
|
29
|
+
},
|
|
30
|
+
meta,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const pair: KeyringPair = {
|
|
34
|
+
address,
|
|
35
|
+
addressRaw: publicKey,
|
|
36
|
+
decodePkcs8: (_passphrase?: string, _encoded?: Uint8Array): void => undefined,
|
|
37
|
+
derive: (_suri: string, _meta?: KeyringPair$Meta): KeyringPair => pair,
|
|
38
|
+
encodePkcs8: (_passphrase?: string): Uint8Array => new Uint8Array(0),
|
|
39
|
+
isLocked: true,
|
|
40
|
+
jwtIssue: (_options?: { expiresIn?: number; notBefore?: number }): JWT =>
|
|
41
|
+
"jwt.dummy.token",
|
|
42
|
+
jwtVerify: (
|
|
43
|
+
_jwt: JWT,
|
|
44
|
+
_options?: { ignoreExpiration?: boolean; ignoreNotBefore?: boolean },
|
|
45
|
+
): JWTVerifyResult => ({
|
|
46
|
+
isValid: false,
|
|
47
|
+
error: "JWT verification failed",
|
|
48
|
+
crypto: "sr25519",
|
|
49
|
+
publicKey,
|
|
50
|
+
isWrapped: false,
|
|
51
|
+
}),
|
|
52
|
+
lock: (): void => {
|
|
53
|
+
// no locking, it is always locked
|
|
54
|
+
},
|
|
55
|
+
meta,
|
|
56
|
+
publicKey,
|
|
57
|
+
setMeta: (_meta: KeyringPair$Meta): void => undefined,
|
|
58
|
+
sign: (_message: Uint8Array): Uint8Array => new Uint8Array(64),
|
|
59
|
+
toJson: (_passphrase?: string): KeyringPair$Json => json,
|
|
60
|
+
type: "sr25519",
|
|
61
|
+
unlock: (_passphrase?: string): void => undefined,
|
|
62
|
+
verify: (_message: Uint8Array, _signature: Uint8Array): boolean => false,
|
|
63
|
+
vrfSign: (
|
|
64
|
+
_message: Uint8Array,
|
|
65
|
+
_context?: string | Uint8Array,
|
|
66
|
+
_extra?: string | Uint8Array,
|
|
67
|
+
): Uint8Array => new Uint8Array(96),
|
|
68
|
+
vrfVerify: (
|
|
69
|
+
_message: Uint8Array,
|
|
70
|
+
_vrfResult: Uint8Array,
|
|
71
|
+
_context?: string | Uint8Array,
|
|
72
|
+
_extra?: string | Uint8Array,
|
|
73
|
+
): boolean => false,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export function nobody(): KeyringPair {
|
|
77
|
+
return pair;
|
|
78
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright 2017-2025 @polkadot/keyring authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { createTestPairs } from "../keyring/testingPairs.js";
|
|
6
|
+
|
|
7
|
+
const keyring = createTestPairs({ type: "sr25519" }, false);
|
|
8
|
+
|
|
9
|
+
describe("toJson", (): void => {
|
|
10
|
+
it("creates an unencoded output with no passphrase", (): void => {
|
|
11
|
+
expect(keyring.alice.toJson()).toMatchObject({
|
|
12
|
+
address: "5Engs9f8Gk6JqvVWz3kFyJ8Kqkgx7pLi8C1UTcr7EZ855qBQ",
|
|
13
|
+
encoded:
|
|
14
|
+
"MFMCAQEwBQYDK2VwBCIEIHipoQ68w1cHP0Tju+ym3lzqc2fma5FCMXgDqwBDqTtU2pOQGFg2vA+4oVIIZMphcnOugCZhNuyAfxQ4r1OyWsahIwMhAHh9b36VcuIWVvYdPYl8NDyAyBt3Sx125cjHJVK3zLwl",
|
|
15
|
+
encoding: {
|
|
16
|
+
content: ["pkcs8", "sr25519"],
|
|
17
|
+
type: ["none"],
|
|
18
|
+
version: "3",
|
|
19
|
+
},
|
|
20
|
+
meta: {
|
|
21
|
+
isTesting: true,
|
|
22
|
+
name: "alice",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("creates an encoded output with passphrase", (): void => {
|
|
28
|
+
const json = keyring.alice.toJson("testing");
|
|
29
|
+
|
|
30
|
+
expect(json.encoded).toHaveLength(268);
|
|
31
|
+
expect(json).toMatchObject({
|
|
32
|
+
address: "5Engs9f8Gk6JqvVWz3kFyJ8Kqkgx7pLi8C1UTcr7EZ855qBQ",
|
|
33
|
+
encoding: {
|
|
34
|
+
content: ["pkcs8", "sr25519"],
|
|
35
|
+
type: ["scrypt", "xsalsa20-poly1305"],
|
|
36
|
+
version: "3",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2017-2025 @polkadot/keyring authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { KeyringPair$Json, KeyringPair$Meta } from "@prosopo/types";
|
|
5
|
+
import type { KeypairType } from "@prosopo/util-crypto";
|
|
6
|
+
|
|
7
|
+
import { objectSpread } from "@polkadot/util";
|
|
8
|
+
import { jsonEncryptFormat } from "@prosopo/util-crypto";
|
|
9
|
+
|
|
10
|
+
interface PairStateJson {
|
|
11
|
+
address: string;
|
|
12
|
+
meta: KeyringPair$Meta;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function pairToJson(
|
|
16
|
+
type: KeypairType,
|
|
17
|
+
{ address, meta }: PairStateJson,
|
|
18
|
+
encoded: Uint8Array,
|
|
19
|
+
isEncrypted: boolean,
|
|
20
|
+
): KeyringPair$Json {
|
|
21
|
+
return objectSpread(
|
|
22
|
+
jsonEncryptFormat(encoded, ["pkcs8", type], isEncrypted),
|
|
23
|
+
{
|
|
24
|
+
address,
|
|
25
|
+
meta,
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.cjs.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist/cjs"
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"./src/**/*.ts",
|
|
9
|
+
"./src/**/*.json",
|
|
10
|
+
"./src/**/*.d.ts",
|
|
11
|
+
"./src/**/*.tsx"
|
|
12
|
+
],
|
|
13
|
+
"references": [
|
|
14
|
+
{
|
|
15
|
+
"path": "../../dev/config/tsconfig.cjs.json"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "../common/tsconfig.cjs.json"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "../types/tsconfig.cjs.json"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "../util-crypto/tsconfig.cjs.json"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "../util/tsconfig.cjs.json"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.esm.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"lib": ["es6", "dom"],
|
|
7
|
+
"allowJs": true
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"src",
|
|
11
|
+
"src/**/*.json",
|
|
12
|
+
"src/**/*.ts",
|
|
13
|
+
"src/**/*.tsx",
|
|
14
|
+
"src/**/*.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"references": [
|
|
17
|
+
{
|
|
18
|
+
"path": "../../dev/config/tsconfig.json"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "../common"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "../types"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "../util-crypto"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "../util"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|