@prosopo/keyring 2.10.0 → 2.10.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.
Files changed (43) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +3 -6
  2. package/.turbo/turbo-build$colon$tsc.log +11 -14
  3. package/.turbo/turbo-build.log +4 -10
  4. package/CHANGELOG.md +44 -0
  5. package/LICENSE +201 -0
  6. package/dist/accounts/testAccounts.d.ts.map +1 -1
  7. package/dist/accounts/testAccounts.js +23 -8
  8. package/dist/accounts/testAccounts.js.map +1 -1
  9. package/dist/accounts/testAccounts.test.js +33 -4
  10. package/dist/accounts/testAccounts.test.js.map +1 -1
  11. package/dist/cjs/accounts/testAccounts.cjs +23 -8
  12. package/package.json +59 -60
  13. package/src/accounts/getPair.test.ts +0 -142
  14. package/src/accounts/getPair.ts +0 -63
  15. package/src/accounts/index.ts +0 -16
  16. package/src/accounts/mnemonic.test.ts +0 -103
  17. package/src/accounts/mnemonic.ts +0 -45
  18. package/src/accounts/testAccounts.test.ts +0 -102
  19. package/src/accounts/testAccounts.ts +0 -66
  20. package/src/index.ts +0 -16
  21. package/src/keyring/index.ts +0 -15
  22. package/src/keyring/keyring.test.ts +0 -373
  23. package/src/keyring/keyring.ts +0 -411
  24. package/src/keyring/pairs.test.ts +0 -133
  25. package/src/keyring/pairs.ts +0 -44
  26. package/src/keyring/testing.test.ts +0 -146
  27. package/src/keyring/testing.ts +0 -119
  28. package/src/keyring/testingPairs.ts +0 -61
  29. package/src/keyring.test-d.ts +0 -134
  30. package/src/pair/decode.spec.ts +0 -25
  31. package/src/pair/decode.ts +0 -64
  32. package/src/pair/defaults.ts +0 -22
  33. package/src/pair/encode.spec.ts +0 -30
  34. package/src/pair/encode.ts +0 -32
  35. package/src/pair/index.ts +0 -304
  36. package/src/pair/nobody.test.ts +0 -127
  37. package/src/pair/nobody.ts +0 -79
  38. package/src/pair/toJson.spec.ts +0 -46
  39. package/src/pair/toJson.ts +0 -28
  40. package/tsconfig.cjs.json +0 -30
  41. package/tsconfig.json +0 -33
  42. package/tsconfig.tsbuildinfo +0 -1
  43. package/tsconfig.types.json +0 -9
package/src/pair/index.ts DELETED
@@ -1,304 +0,0 @@
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
- SignOptions,
9
- } from "@prosopo/types";
10
- import type { PairInfo } from "@prosopo/types";
11
-
12
- import {
13
- objectSpread,
14
- u8aConcat,
15
- u8aEmpty,
16
- u8aToHex,
17
- u8aToU8a,
18
- } from "@polkadot/util";
19
-
20
- import {
21
- type JWT,
22
- blake2AsU8a,
23
- jwtVerify,
24
- sr25519jwtIssue,
25
- } from "@prosopo/util-crypto";
26
- import type { EncryptedJsonEncoding } from "@prosopo/util-crypto";
27
- import { keyExtractPath, keyFromPath } from "@prosopo/util-crypto";
28
- import { secp256k1Compress } from "@prosopo/util-crypto";
29
- import { signatureVerify } from "@prosopo/util-crypto";
30
- import { sr25519FromSeed, sr25519Sign } from "@prosopo/util-crypto";
31
- import { sr25519VrfSign, sr25519VrfVerify } from "@prosopo/util-crypto";
32
- import type { JWTVerifyOptions, JWTVerifyResult } from "@prosopo/util-crypto";
33
- import { decodePair } from "./decode.js";
34
- import { encodePair } from "./encode.js";
35
- import { pairToJson } from "./toJson.js";
36
-
37
- type KeypairType = "sr25519" | "ed25519" | "ecdsa" | "ethereum";
38
-
39
- interface Setup {
40
- toSS58: (publicKey: Uint8Array) => string;
41
- type: KeypairType;
42
- }
43
-
44
- const SIG_TYPE_NONE = new Uint8Array([]);
45
-
46
- const TYPE_FROM_SEED = {
47
- sr25519: sr25519FromSeed,
48
- ed25519: () => {
49
- throw new Error("Not Implemented");
50
- },
51
- ecdsa: () => {
52
- throw new Error("Not Implemented");
53
- },
54
- ethereum: () => {
55
- throw new Error("Not Implemented");
56
- },
57
- };
58
-
59
- const TYPE_PREFIX = {
60
- ecdsa: new Uint8Array([2]),
61
- ed25519: new Uint8Array([0]),
62
- ethereum: new Uint8Array([2]),
63
- sr25519: new Uint8Array([1]),
64
- };
65
-
66
- const TYPE_SIGNATURE = {
67
- sr25519: sr25519Sign,
68
- ed25519: () => {
69
- throw new Error("Not Implemented");
70
- },
71
- ecdsa: () => {
72
- throw new Error("Not Implemented");
73
- },
74
- ethereum: () => {
75
- throw new Error("Not Implemented");
76
- },
77
- };
78
-
79
- const TYPE_JWT_ISSUE = {
80
- sr25519: sr25519jwtIssue,
81
- ed25519: () => {
82
- throw new Error("Not Implemented");
83
- },
84
- ecdsa: () => {
85
- throw new Error("Not Implemented");
86
- },
87
- ethereum: () => {
88
- throw new Error("Not Implemented");
89
- },
90
- };
91
-
92
- const TYPE_ADDRESS = {
93
- sr25519: (p: Uint8Array) => p,
94
- ed25519: () => {
95
- throw new Error("Not Implemented");
96
- },
97
- ecdsa: () => {
98
- throw new Error("Not Implemented");
99
- },
100
- ethereum: () => {
101
- throw new Error("Not Implemented");
102
- },
103
- };
104
-
105
- function isLocked(secretKey?: Uint8Array): secretKey is undefined {
106
- return !secretKey || u8aEmpty(secretKey);
107
- }
108
-
109
- function vrfHash(
110
- proof: Uint8Array,
111
- context?: string | Uint8Array,
112
- extra?: string | Uint8Array,
113
- ): Uint8Array {
114
- return blake2AsU8a(u8aConcat(context || "", extra || "", proof));
115
- }
116
-
117
- /**
118
- * @name createPair
119
- * @summary Creates a keyring pair object
120
- * @description Creates a keyring pair object with provided account public key, metadata, and encoded arguments.
121
- * The keyring pair stores the account state including the encoded address and associated metadata.
122
- *
123
- * It has properties whose values are functions that may be called to perform account actions:
124
- *
125
- * - `address` function retrieves the address associated with the account.
126
- * - `decodedPkcs8` function is called with the account passphrase and account encoded public key.
127
- * It decodes the encoded public key using the passphrase provided to obtain the decoded account public key
128
- * and associated secret key that are then available in memory, and changes the account address stored in the
129
- * state of the pair to correspond to the address of the decoded public key.
130
- * - `encodePkcs8` function when provided with the correct passphrase associated with the account pair
131
- * and when the secret key is in memory (when the account pair is not locked) it returns an encoded
132
- * public key of the account.
133
- * - `meta` is the metadata that is stored in the state of the pair, either when it was originally
134
- * created or set via `setMeta`.
135
- * - `publicKey` returns the public key stored in memory for the pair.
136
- * - `sign` may be used to return a signature by signing a provided message with the secret
137
- * key (if it is in memory) using Nacl.
138
- * - `toJson` calls another `toJson` function and provides the state of the pair,
139
- * it generates arguments to be passed to the other `toJson` function including an encoded public key of the account
140
- * that it generates using the secret key from memory (if it has been made available in memory)
141
- * and the optionally provided passphrase argument. It passes a third boolean argument to `toJson`
142
- * indicating whether the public key has been encoded or not (if a passphrase argument was provided then it is encoded).
143
- * The `toJson` function that it calls returns a JSON object with properties including the `address`
144
- * and `meta` that are assigned with the values stored in the corresponding state variables of the account pair,
145
- * an `encoded` property that is assigned with the encoded public key in hex format, and an `encoding`
146
- * property that indicates whether the public key value of the `encoded` property is encoded or not.
147
- */
148
- export function createPair(
149
- { toSS58, type }: Setup,
150
- { publicKey, secretKey }: PairInfo,
151
- meta: KeyringPair$Meta = {},
152
- encoded: Uint8Array | null = null,
153
- encTypes?: EncryptedJsonEncoding[],
154
- ): KeyringPair {
155
- const decodePkcs8 = (
156
- passphrase?: string,
157
- userEncoded?: Uint8Array | null,
158
- ): void => {
159
- const decoded = decodePair(passphrase, userEncoded || encoded, encTypes);
160
-
161
- if (decoded.secretKey.length === 64) {
162
- publicKey = decoded.publicKey;
163
- secretKey = decoded.secretKey;
164
- } else {
165
- const pair = TYPE_FROM_SEED[type](decoded.secretKey);
166
-
167
- publicKey = pair.publicKey;
168
- secretKey = pair.secretKey;
169
- }
170
- };
171
-
172
- const recode = (passphrase?: string): Uint8Array => {
173
- isLocked(secretKey) && encoded && decodePkcs8(passphrase, encoded);
174
-
175
- encoded = encodePair({ publicKey, secretKey }, passphrase); // re-encode, latest version
176
- encTypes = undefined; // swap to defaults, latest version follows
177
-
178
- return encoded;
179
- };
180
-
181
- const encodeAddress = (): string => {
182
- const raw = TYPE_ADDRESS[type](publicKey);
183
-
184
- return toSS58(raw);
185
- };
186
-
187
- return {
188
- get address(): string {
189
- return encodeAddress();
190
- },
191
- get addressRaw(): Uint8Array {
192
- return TYPE_ADDRESS[type](publicKey);
193
- },
194
- get isLocked(): boolean {
195
- return isLocked(secretKey);
196
- },
197
- get meta(): KeyringPair$Meta {
198
- return meta;
199
- },
200
- get publicKey(): Uint8Array {
201
- return publicKey;
202
- },
203
- get type(): KeypairType {
204
- return type;
205
- },
206
- // eslint-disable-next-line sort-keys
207
- decodePkcs8,
208
- derive: (suri: string, meta?: KeyringPair$Meta): KeyringPair => {
209
- if (isLocked(secretKey)) {
210
- throw new Error("Cannot derive on a locked keypair");
211
- }
212
-
213
- const { path } = keyExtractPath(suri);
214
- const derived = keyFromPath({ publicKey, secretKey }, path, type);
215
-
216
- return createPair({ toSS58, type }, derived, meta, null);
217
- },
218
- encodePkcs8: (passphrase?: string): Uint8Array => {
219
- return recode(passphrase);
220
- },
221
- jwtIssue: (
222
- options?: { expiresIn?: number; notBefore?: number },
223
- message?: { [key: string]: string },
224
- ): JWT => {
225
- if (isLocked(secretKey)) {
226
- throw new Error("Cannot sign with a locked key pair");
227
- }
228
- return TYPE_JWT_ISSUE[type]({ publicKey, secretKey }, options, message);
229
- },
230
- jwtVerify: (jwt: JWT, options?: JWTVerifyOptions): JWTVerifyResult => {
231
- return jwtVerify(jwt, publicKey, options);
232
- },
233
- lock: (): void => {
234
- secretKey = new Uint8Array([]);
235
- },
236
- setMeta: (additional: KeyringPair$Meta): void => {
237
- meta = objectSpread({}, meta, additional);
238
- },
239
- sign: (
240
- message: string | Uint8Array,
241
- options: SignOptions = {},
242
- ): Uint8Array => {
243
- if (isLocked(secretKey)) {
244
- throw new Error("Cannot sign with a locked key pair");
245
- }
246
-
247
- return u8aConcat(
248
- options.withType ? TYPE_PREFIX[type] : SIG_TYPE_NONE,
249
- TYPE_SIGNATURE[type](u8aToU8a(message), { publicKey, secretKey }),
250
- );
251
- },
252
- toJson: (passphrase?: string): KeyringPair$Json => {
253
- // NOTE: For ecdsa and ethereum, the publicKey cannot be extracted from the address. For these
254
- // pass the hex-encoded publicKey through to the address portion of the JSON (before decoding)
255
- // unless the publicKey is already an address
256
- const address = ["ecdsa", "ethereum"].includes(type)
257
- ? publicKey.length === 20
258
- ? u8aToHex(publicKey)
259
- : u8aToHex(secp256k1Compress(publicKey))
260
- : encodeAddress();
261
-
262
- return pairToJson(
263
- type,
264
- { address, meta },
265
- recode(passphrase),
266
- !!passphrase,
267
- );
268
- },
269
- unlock: (passphrase?: string): void => {
270
- decodePkcs8(passphrase);
271
- },
272
- verify: (
273
- message: string | Uint8Array,
274
- signature: string | Uint8Array,
275
- signerPublic: string | Uint8Array,
276
- ): boolean => {
277
- return signatureVerify(
278
- message,
279
- signature,
280
- TYPE_ADDRESS[type](u8aToU8a(signerPublic)),
281
- ).isValid;
282
- },
283
- vrfSign: (
284
- message: string | Uint8Array,
285
- context?: string | Uint8Array,
286
- extra?: string | Uint8Array,
287
- ): Uint8Array => {
288
- if (isLocked(secretKey)) {
289
- throw new Error("Cannot sign with a locked key pair");
290
- }
291
-
292
- return sr25519VrfSign(message, { secretKey }, context, extra);
293
- },
294
- vrfVerify: (
295
- message: string | Uint8Array,
296
- vrfResult: Uint8Array,
297
- signerPublic: Uint8Array | string,
298
- context?: string | Uint8Array,
299
- extra?: string | Uint8Array,
300
- ): boolean => {
301
- return sr25519VrfVerify(message, vrfResult, publicKey, context, extra);
302
- },
303
- };
304
- }
@@ -1,127 +0,0 @@
1
- // Copyright 2021-2026 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 { encodeAddress } from "@prosopo/util-crypto";
16
- import { describe, expect, it } from "vitest";
17
- import {
18
- PAIR_DIV,
19
- PAIR_HDR,
20
- PUB_LENGTH,
21
- SALT_LENGTH,
22
- SEC_LENGTH,
23
- SEED_LENGTH,
24
- } from "./defaults.js";
25
- import { nobody } from "./nobody.js";
26
-
27
- describe("nobody", () => {
28
- it("is the all-zero public key, encoded as the well-known address", () => {
29
- const pair = nobody();
30
- expect(pair.publicKey).toEqual(new Uint8Array(32));
31
- expect(pair.address).toBe(
32
- "5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM",
33
- );
34
- // The address is a pre-computed constant in the source; if the encoding
35
- // ever changed, the constant would silently be wrong.
36
- expect(pair.address).toBe(encodeAddress(pair.publicKey, 42));
37
- });
38
-
39
- it("is permanently locked", () => {
40
- const pair = nobody();
41
- expect(pair.isLocked).toBe(true);
42
- pair.unlock("anything");
43
- expect(pair.isLocked).toBe(true);
44
- pair.lock();
45
- expect(pair.isLocked).toBe(true);
46
- });
47
-
48
- it("never verifies a signature, whatever it is given", () => {
49
- // This is the whole point of the pair: it stands in for "no account"
50
- // and must never authenticate anyone.
51
- const pair = nobody();
52
- expect(
53
- pair.verify(new Uint8Array(1), new Uint8Array(64), pair.publicKey),
54
- ).toBe(false);
55
- expect(
56
- pair.verify(
57
- new Uint8Array(0),
58
- pair.sign(new Uint8Array(1)),
59
- pair.publicKey,
60
- ),
61
- ).toBe(false);
62
- expect(
63
- pair.vrfVerify(new Uint8Array(1), new Uint8Array(96), pair.publicKey),
64
- ).toBe(false);
65
- });
66
-
67
- it("never reports a JWT as valid", () => {
68
- const result = nobody().jwtVerify(nobody().jwtIssue());
69
- expect(result.isValid).toBe(false);
70
- expect(result.error).toBe("JWT verification failed");
71
- expect(result.publicKey).toEqual(new Uint8Array(32));
72
- });
73
-
74
- it("returns correctly sized but empty signatures", () => {
75
- const pair = nobody();
76
- expect(pair.sign(new Uint8Array(1))).toEqual(new Uint8Array(64));
77
- expect(pair.vrfSign(new Uint8Array(1))).toEqual(new Uint8Array(96));
78
- expect(pair.encodePkcs8()).toEqual(new Uint8Array(0));
79
- });
80
-
81
- it("derives to itself, so no chain of derivation can escape it", () => {
82
- const pair = nobody();
83
- expect(pair.derive("//anything")).toBe(pair);
84
- expect(pair.derive("//a").derive("//b")).toBe(pair);
85
- });
86
-
87
- it("ignores attempts to change its meta", () => {
88
- const pair = nobody();
89
- pair.setMeta({ name: "somebody" });
90
- expect(pair.meta.name).toBe("nobody");
91
- expect(pair.meta.isTesting).toBe(true);
92
- });
93
-
94
- it("serialises to an unencrypted v0 json blob", () => {
95
- const json = nobody().toJson();
96
- expect(json.address).toBe(nobody().address);
97
- expect(json.encoded).toBe("");
98
- expect(json.encoding.version).toBe("0");
99
- expect(json.encoding.type).toBe("none");
100
- });
101
-
102
- it("returns the same shared instance each call", () => {
103
- expect(nobody()).toBe(nobody());
104
- });
105
-
106
- it("accepts pkcs8 decoding without throwing", () => {
107
- expect(() => nobody().decodePkcs8("pass", new Uint8Array(1))).not.toThrow();
108
- });
109
- });
110
-
111
- describe("pair defaults", () => {
112
- it("declares the sr25519 key and seed lengths", () => {
113
- expect(PUB_LENGTH).toBe(32);
114
- expect(SEED_LENGTH).toBe(32);
115
- expect(SALT_LENGTH).toBe(32);
116
- expect(SEC_LENGTH).toBe(64);
117
- });
118
-
119
- it("declares the pkcs8 header and divider used by the encoder", () => {
120
- // These framing bytes are what makes an exported key readable by
121
- // polkadot-js; a change here silently breaks every existing backup.
122
- expect(Array.from(PAIR_DIV)).toEqual([161, 35, 3, 33, 0]);
123
- expect(Array.from(PAIR_HDR)).toEqual([
124
- 48, 83, 2, 1, 1, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32,
125
- ]);
126
- });
127
- });
@@ -1,79 +0,0 @@
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 {
10
- JWT,
11
- JWTVerifyOptions,
12
- JWTVerifyResult,
13
- } from "@prosopo/util-crypto";
14
-
15
- // empty publicKey
16
- const publicKey = new Uint8Array(32);
17
-
18
- // pre-computed via encodeAddress(publicKey)
19
- const address = "5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM";
20
-
21
- const meta = {
22
- isTesting: true,
23
- name: "nobody",
24
- };
25
-
26
- const json: KeyringPair$Json = {
27
- address,
28
- encoded: "",
29
- encoding: {
30
- content: ["pkcs8", "ed25519"],
31
- type: "none",
32
- version: "0",
33
- },
34
- meta,
35
- };
36
-
37
- const pair: KeyringPair = {
38
- address,
39
- addressRaw: publicKey,
40
- decodePkcs8: (_passphrase?: string, _encoded?: Uint8Array): void => undefined,
41
- derive: (_suri: string, _meta?: KeyringPair$Meta): KeyringPair => pair,
42
- encodePkcs8: (_passphrase?: string): Uint8Array => new Uint8Array(0),
43
- isLocked: true,
44
- jwtIssue: (_options?: { expiresIn?: number; notBefore?: number }): JWT =>
45
- "jwt.dummy.token",
46
- jwtVerify: (_jwt: JWT, _options?: JWTVerifyOptions): JWTVerifyResult => ({
47
- isValid: false,
48
- error: "JWT verification failed",
49
- crypto: "sr25519",
50
- publicKey,
51
- isWrapped: false,
52
- }),
53
- lock: (): void => {
54
- // no locking, it is always locked
55
- },
56
- meta,
57
- publicKey,
58
- setMeta: (_meta: KeyringPair$Meta): void => undefined,
59
- sign: (_message: Uint8Array): Uint8Array => new Uint8Array(64),
60
- toJson: (_passphrase?: string): KeyringPair$Json => json,
61
- type: "sr25519",
62
- unlock: (_passphrase?: string): void => undefined,
63
- verify: (_message: Uint8Array, _signature: Uint8Array): boolean => false,
64
- vrfSign: (
65
- _message: Uint8Array,
66
- _context?: string | Uint8Array,
67
- _extra?: string | Uint8Array,
68
- ): Uint8Array => new Uint8Array(96),
69
- vrfVerify: (
70
- _message: Uint8Array,
71
- _vrfResult: Uint8Array,
72
- _context?: string | Uint8Array,
73
- _extra?: string | Uint8Array,
74
- ): boolean => false,
75
- };
76
-
77
- export function nobody(): KeyringPair {
78
- return pair;
79
- }
@@ -1,46 +0,0 @@
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
- // scrypt with the production parameters takes several seconds, which
28
- // overruns the 10s default on a loaded CI runner.
29
- it(
30
- "creates an encoded output with passphrase",
31
- { timeout: 60000 },
32
- (): void => {
33
- const json = keyring.alice.toJson("testing");
34
-
35
- expect(json.encoded).toHaveLength(268);
36
- expect(json).toMatchObject({
37
- address: "5Engs9f8Gk6JqvVWz3kFyJ8Kqkgx7pLi8C1UTcr7EZ855qBQ",
38
- encoding: {
39
- content: ["pkcs8", "sr25519"],
40
- type: ["scrypt", "xsalsa20-poly1305"],
41
- version: "3",
42
- },
43
- });
44
- },
45
- );
46
- });
@@ -1,28 +0,0 @@
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
- }
package/tsconfig.cjs.json DELETED
@@ -1,30 +0,0 @@
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 DELETED
@@ -1,33 +0,0 @@
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
- }