@pezkuwi/keyring 14.0.7 → 14.0.10

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 (174) hide show
  1. package/build/LICENSE +201 -0
  2. package/build/README.md +17 -0
  3. package/{bundle-pezkuwi-keyring.js → build/bundle-pezkuwi-keyring.js} +1 -1
  4. package/build/bundle.js +7 -0
  5. package/build/cjs/bundle.d.ts +7 -0
  6. package/build/cjs/bundle.js +19 -0
  7. package/build/cjs/defaults.js +5 -0
  8. package/build/cjs/index.js +7 -0
  9. package/build/cjs/keyring.js +261 -0
  10. package/build/cjs/packageInfo.js +4 -0
  11. package/build/cjs/pair/decode.js +45 -0
  12. package/build/cjs/pair/defaults.js +15 -0
  13. package/build/cjs/pair/encode.js +22 -0
  14. package/build/cjs/pair/index.js +183 -0
  15. package/build/cjs/pair/nobody.js +43 -0
  16. package/build/cjs/pair/toJson.js +11 -0
  17. package/build/cjs/pair/types.js +2 -0
  18. package/build/cjs/pairs.js +28 -0
  19. package/build/cjs/testing.js +126 -0
  20. package/build/cjs/testingPairs.js +16 -0
  21. package/build/cjs/types.js +2 -0
  22. package/build/defaults.d.ts +2 -0
  23. package/build/defaults.js +2 -0
  24. package/build/index.d.ts +4 -0
  25. package/build/index.js +4 -0
  26. package/build/keyring.d.ts +145 -0
  27. package/build/keyring.js +257 -0
  28. package/build/package.json +294 -0
  29. package/build/packageDetect.d.ts +1 -0
  30. package/build/packageDetect.js +5 -0
  31. package/build/packageInfo.d.ts +6 -0
  32. package/build/packageInfo.js +1 -0
  33. package/build/pair/decode.d.ts +12 -0
  34. package/build/pair/decode.js +42 -0
  35. package/build/pair/defaults.d.ts +12 -0
  36. package/build/pair/defaults.js +12 -0
  37. package/build/pair/encode.d.ts +5 -0
  38. package/build/pair/encode.js +19 -0
  39. package/build/pair/index.d.ts +40 -0
  40. package/build/pair/index.js +180 -0
  41. package/build/pair/nobody.d.ts +2 -0
  42. package/build/pair/nobody.js +40 -0
  43. package/build/pair/toJson.d.ts +8 -0
  44. package/build/pair/toJson.js +8 -0
  45. package/build/pair/types.d.ts +5 -0
  46. package/build/pair/types.js +1 -0
  47. package/build/pairs.d.ts +8 -0
  48. package/build/pairs.js +24 -0
  49. package/build/testing.d.ts +20 -0
  50. package/build/testing.js +122 -0
  51. package/build/testingPairs.d.ts +25 -0
  52. package/build/testingPairs.js +13 -0
  53. package/build/types.d.ts +111 -0
  54. package/build/types.js +1 -0
  55. package/build-deno/README.md +17 -0
  56. package/build-deno/bundle.ts +10 -0
  57. package/build-deno/defaults.ts +4 -0
  58. package/build-deno/index.ts +8 -0
  59. package/build-deno/keyring.ts +305 -0
  60. package/build-deno/mod.ts +2 -0
  61. package/build-deno/packageDetect.ts +9 -0
  62. package/build-deno/packageInfo.ts +3 -0
  63. package/build-deno/pair/decode.ts +54 -0
  64. package/build-deno/pair/defaults.ts +18 -0
  65. package/build-deno/pair/encode.ts +28 -0
  66. package/build-deno/pair/index.ts +218 -0
  67. package/build-deno/pair/nobody.ts +58 -0
  68. package/build-deno/pair/toJson.ts +18 -0
  69. package/build-deno/pair/types.ts +6 -0
  70. package/build-deno/pairs.ts +39 -0
  71. package/build-deno/testing.ts +150 -0
  72. package/build-deno/testingPairs.ts +54 -0
  73. package/build-deno/types.ts +129 -0
  74. package/build-tsc-cjs/packageDetect.js +7 -0
  75. package/{cjs → build-tsc-cjs}/packageInfo.js +1 -1
  76. package/{packageInfo.js → build-tsc-esm/packageInfo.js} +1 -1
  77. package/package.json +9 -271
  78. package/src/bundle.ts +16 -0
  79. package/src/defaults.ts +8 -0
  80. package/src/index.spec.ts +609 -0
  81. package/src/index.ts +10 -0
  82. package/src/keyring.ts +307 -0
  83. package/src/mod.ts +4 -0
  84. package/src/packageDetect.ts +13 -0
  85. package/src/packageInfo.ts +6 -0
  86. package/src/pair/decode.spec.ts +26 -0
  87. package/src/pair/decode.ts +56 -0
  88. package/src/pair/defaults.ts +20 -0
  89. package/src/pair/encode.spec.ts +28 -0
  90. package/src/pair/encode.ts +30 -0
  91. package/src/pair/index.spec.ts +189 -0
  92. package/src/pair/index.ts +220 -0
  93. package/src/pair/nobody.ts +62 -0
  94. package/src/pair/toJson.spec.ts +42 -0
  95. package/src/pair/toJson.ts +20 -0
  96. package/src/pair/types.ts +8 -0
  97. package/src/pair/vrf.spec.ts +47 -0
  98. package/src/pairs.ts +41 -0
  99. package/src/suri.spec.ts +109 -0
  100. package/src/testing.ts +156 -0
  101. package/src/testingPairs.spec.ts +79 -0
  102. package/src/testingPairs.ts +56 -0
  103. package/src/types.ts +131 -0
  104. package/tsconfig.build.json +16 -0
  105. package/tsconfig.build.tsbuildinfo +1 -0
  106. package/tsconfig.spec.json +18 -0
  107. package/tsconfig.spec.tsbuildinfo +1 -0
  108. /package/{cjs → build}/bundle.d.ts +0 -0
  109. /package/{defaults.d.ts → build/cjs/defaults.d.ts} +0 -0
  110. /package/{index.d.ts → build/cjs/index.d.ts} +0 -0
  111. /package/{keyring.d.ts → build/cjs/keyring.d.ts} +0 -0
  112. /package/{cjs → build/cjs}/package.json +0 -0
  113. /package/{packageDetect.d.ts → build/cjs/packageDetect.d.ts} +0 -0
  114. /package/{cjs → build/cjs}/packageDetect.js +0 -0
  115. /package/{packageInfo.d.ts → build/cjs/packageInfo.d.ts} +0 -0
  116. /package/{pair → build/cjs/pair}/decode.d.ts +0 -0
  117. /package/{pair → build/cjs/pair}/defaults.d.ts +0 -0
  118. /package/{pair → build/cjs/pair}/encode.d.ts +0 -0
  119. /package/{pair → build/cjs/pair}/index.d.ts +0 -0
  120. /package/{pair → build/cjs/pair}/nobody.d.ts +0 -0
  121. /package/{pair → build/cjs/pair}/toJson.d.ts +0 -0
  122. /package/{pair → build/cjs/pair}/types.d.ts +0 -0
  123. /package/{pairs.d.ts → build/cjs/pairs.d.ts} +0 -0
  124. /package/{testing.d.ts → build/cjs/testing.d.ts} +0 -0
  125. /package/{testingPairs.d.ts → build/cjs/testingPairs.d.ts} +0 -0
  126. /package/{types.d.ts → build/cjs/types.d.ts} +0 -0
  127. /package/{bundle.d.ts → build-tsc/bundle.d.ts} +0 -0
  128. /package/{cjs → build-tsc}/defaults.d.ts +0 -0
  129. /package/{cjs → build-tsc}/index.d.ts +0 -0
  130. /package/{cjs → build-tsc}/keyring.d.ts +0 -0
  131. /package/{cjs → build-tsc}/packageDetect.d.ts +0 -0
  132. /package/{cjs → build-tsc}/packageInfo.d.ts +0 -0
  133. /package/{cjs → build-tsc}/pair/decode.d.ts +0 -0
  134. /package/{cjs → build-tsc}/pair/defaults.d.ts +0 -0
  135. /package/{cjs → build-tsc}/pair/encode.d.ts +0 -0
  136. /package/{cjs → build-tsc}/pair/index.d.ts +0 -0
  137. /package/{cjs → build-tsc}/pair/nobody.d.ts +0 -0
  138. /package/{cjs → build-tsc}/pair/toJson.d.ts +0 -0
  139. /package/{cjs → build-tsc}/pair/types.d.ts +0 -0
  140. /package/{cjs → build-tsc}/pairs.d.ts +0 -0
  141. /package/{cjs → build-tsc}/testing.d.ts +0 -0
  142. /package/{cjs → build-tsc}/testingPairs.d.ts +0 -0
  143. /package/{cjs → build-tsc}/types.d.ts +0 -0
  144. /package/{cjs → build-tsc-cjs}/bundle.js +0 -0
  145. /package/{cjs → build-tsc-cjs}/defaults.js +0 -0
  146. /package/{cjs → build-tsc-cjs}/index.js +0 -0
  147. /package/{cjs → build-tsc-cjs}/keyring.js +0 -0
  148. /package/{cjs → build-tsc-cjs}/pair/decode.js +0 -0
  149. /package/{cjs → build-tsc-cjs}/pair/defaults.js +0 -0
  150. /package/{cjs → build-tsc-cjs}/pair/encode.js +0 -0
  151. /package/{cjs → build-tsc-cjs}/pair/index.js +0 -0
  152. /package/{cjs → build-tsc-cjs}/pair/nobody.js +0 -0
  153. /package/{cjs → build-tsc-cjs}/pair/toJson.js +0 -0
  154. /package/{cjs → build-tsc-cjs}/pair/types.js +0 -0
  155. /package/{cjs → build-tsc-cjs}/pairs.js +0 -0
  156. /package/{cjs → build-tsc-cjs}/testing.js +0 -0
  157. /package/{cjs → build-tsc-cjs}/testingPairs.js +0 -0
  158. /package/{cjs → build-tsc-cjs}/types.js +0 -0
  159. /package/{bundle.js → build-tsc-esm/bundle.js} +0 -0
  160. /package/{defaults.js → build-tsc-esm/defaults.js} +0 -0
  161. /package/{index.js → build-tsc-esm/index.js} +0 -0
  162. /package/{keyring.js → build-tsc-esm/keyring.js} +0 -0
  163. /package/{packageDetect.js → build-tsc-esm/packageDetect.js} +0 -0
  164. /package/{pair → build-tsc-esm/pair}/decode.js +0 -0
  165. /package/{pair → build-tsc-esm/pair}/defaults.js +0 -0
  166. /package/{pair → build-tsc-esm/pair}/encode.js +0 -0
  167. /package/{pair → build-tsc-esm/pair}/index.js +0 -0
  168. /package/{pair → build-tsc-esm/pair}/nobody.js +0 -0
  169. /package/{pair → build-tsc-esm/pair}/toJson.js +0 -0
  170. /package/{pair → build-tsc-esm/pair}/types.js +0 -0
  171. /package/{pairs.js → build-tsc-esm/pairs.js} +0 -0
  172. /package/{testing.js → build-tsc-esm/testing.js} +0 -0
  173. /package/{testingPairs.js → build-tsc-esm/testingPairs.js} +0 -0
  174. /package/{types.js → build-tsc-esm/types.js} +0 -0
@@ -0,0 +1,58 @@
1
+
2
+ import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '../types.ts';
3
+
4
+ const publicKey = new Uint8Array(32);
5
+
6
+ const address = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM';
7
+
8
+ const meta = {
9
+ isTesting: true,
10
+ name: 'nobody'
11
+ };
12
+
13
+ const json: KeyringPair$Json = {
14
+ address,
15
+ encoded: '',
16
+ encoding: {
17
+ content: ['pkcs8', 'ed25519'],
18
+ type: 'none',
19
+ version: '0'
20
+ },
21
+ meta
22
+ };
23
+
24
+ const pair: KeyringPair = {
25
+ address,
26
+ addressRaw: publicKey,
27
+ decodePkcs8: (_passphrase?: string, _encoded?: Uint8Array): void =>
28
+ undefined,
29
+ derive: (_suri: string, _meta?: KeyringPair$Meta): KeyringPair =>
30
+ pair,
31
+ encodePkcs8: (_passphrase?: string): Uint8Array =>
32
+ new Uint8Array(0),
33
+ isLocked: true,
34
+ lock: (): void => {
35
+ // no locking, it is always locked
36
+ },
37
+ meta,
38
+ publicKey,
39
+ setMeta: (_meta: KeyringPair$Meta): void =>
40
+ undefined,
41
+ sign: (_message: Uint8Array): Uint8Array =>
42
+ new Uint8Array(64),
43
+ toJson: (_passphrase?: string): KeyringPair$Json =>
44
+ json,
45
+ type: 'ed25519',
46
+ unlock: (_passphrase?: string): void =>
47
+ undefined,
48
+ verify: (_message: Uint8Array, _signature: Uint8Array): boolean =>
49
+ false,
50
+ vrfSign: (_message: Uint8Array, _context?: string | Uint8Array, _extra?: string | Uint8Array): Uint8Array =>
51
+ new Uint8Array(96),
52
+ vrfVerify: (_message: Uint8Array, _vrfResult: Uint8Array, _context?: string | Uint8Array, _extra?: string | Uint8Array): boolean =>
53
+ false
54
+ };
55
+
56
+ export function nobody (): KeyringPair {
57
+ return pair;
58
+ }
@@ -0,0 +1,18 @@
1
+
2
+ import type { KeypairType } from 'https://deno.land/x/pezkuwi/util-crypto/types.ts';
3
+ import type { KeyringPair$Json, KeyringPair$Meta } from '../types.ts';
4
+
5
+ import { objectSpread } from 'https://deno.land/x/pezkuwi/util/mod.ts';
6
+ import { jsonEncryptFormat } from 'https://deno.land/x/pezkuwi/util-crypto/mod.ts';
7
+
8
+ interface PairStateJson {
9
+ address: string;
10
+ meta: KeyringPair$Meta;
11
+ }
12
+
13
+ export function pairToJson (type: KeypairType, { address, meta }: PairStateJson, encoded: Uint8Array, isEncrypted: boolean): KeyringPair$Json {
14
+ return objectSpread(jsonEncryptFormat(encoded, ['pkcs8', type], isEncrypted), {
15
+ address,
16
+ meta
17
+ });
18
+ }
@@ -0,0 +1,6 @@
1
+
2
+ export interface PairInfo {
3
+ publicKey: Uint8Array;
4
+ secretKey?: Uint8Array | undefined;
5
+ seed?: Uint8Array | null;
6
+ }
@@ -0,0 +1,39 @@
1
+
2
+ import type { KeyringPair, KeyringPairs } from './types.ts';
3
+
4
+ import { isHex, isU8a, u8aToHex, u8aToU8a } from 'https://deno.land/x/pezkuwi/util/mod.ts';
5
+ import { decodeAddress } from 'https://deno.land/x/pezkuwi/util-crypto/mod.ts';
6
+
7
+ type KeyringPairMap = Record<string, KeyringPair>;
8
+
9
+ export class Pairs implements KeyringPairs {
10
+ readonly #map: KeyringPairMap = {};
11
+
12
+ public add (pair: KeyringPair): KeyringPair {
13
+ this.#map[decodeAddress(pair.address).toString()] = pair;
14
+
15
+ return pair;
16
+ }
17
+
18
+ public all (): KeyringPair[] {
19
+ return Object.values(this.#map);
20
+ }
21
+
22
+ public get (address: string | Uint8Array): KeyringPair {
23
+ const pair = this.#map[decodeAddress(address).toString()];
24
+
25
+ if (!pair) {
26
+ throw new Error(`Unable to retrieve keypair '${
27
+ isU8a(address) || isHex(address)
28
+ ? u8aToHex(u8aToU8a(address))
29
+ : address
30
+ }'`);
31
+ }
32
+
33
+ return pair;
34
+ }
35
+
36
+ public remove (address: string | Uint8Array): void {
37
+ delete this.#map[decodeAddress(address).toString()];
38
+ }
39
+ }
@@ -0,0 +1,150 @@
1
+
2
+ import type { HexString } from 'https://deno.land/x/pezkuwi/util/types.ts';
3
+ import type { KeypairType } from 'https://deno.land/x/pezkuwi/util-crypto/types.ts';
4
+ import type { KeyringInstance, KeyringOptions } from './types.ts';
5
+
6
+ import { hexToU8a } from 'https://deno.land/x/pezkuwi/util/mod.ts';
7
+
8
+ import { createPair } from './pair/index.ts';
9
+ import { Keyring } from './keyring.ts';
10
+
11
+ interface PairDef {
12
+ name?: string;
13
+ p: HexString;
14
+ s: HexString;
15
+ seed?: string;
16
+ type: KeypairType
17
+ }
18
+
19
+ export const PAIRSSR25519: PairDef[] = [
20
+ {
21
+ p: '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d',
22
+ s: '0x98319d4ff8a9508c4bb0cf0b5a78d760a0b2082c02775e6e82370816fedfff48925a225d97aa00682d6a59b95b18780c10d7032336e88f3442b42361f4a66011', // nosemgrep
23
+ seed: 'Alice',
24
+ type: 'sr25519'
25
+ },
26
+ {
27
+ p: '0xbe5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f',
28
+ s: '0xe8da6c9d810e020f5e3c7f5af2dea314cbeaa0d72bc6421e92c0808a0c584a6046ab28e97c3ffc77fe12b5a4d37e8cd4afbfebbf2391ffc7cb07c0f38c023efd', // nosemgrep
29
+ seed: 'Alice//stash',
30
+ type: 'sr25519'
31
+ },
32
+ {
33
+ p: '0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48',
34
+ s: '0x081ff694633e255136bdb456c20a5fc8fed21f8b964c11bb17ff534ce80ebd5941ae88f85d0c1bfc37be41c904e1dfc01de8c8067b0d6d5df25dd1ac0894a325', // nosemgrep
35
+ seed: 'Bob',
36
+ type: 'sr25519'
37
+ },
38
+ {
39
+ p: '0xfe65717dad0447d715f660a0a58411de509b42e6efb8375f562f58a554d5860e',
40
+ s: '0xc006507cdfc267a21532394c49ca9b754ca71de21e15a1cdf807c7ceab6d0b6c3ed408d9d35311540dcd54931933e67cf1ea10d46f75408f82b789d9bd212fde', // nosemgrep
41
+ seed: 'Bob//stash',
42
+ type: 'sr25519'
43
+ },
44
+ {
45
+ p: '0x90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22',
46
+ s: '0xa8f2d83016052e5d6d77b2f6fd5d59418922a09024cda701b3c34369ec43a7668faf12ff39cd4e5d92bb773972f41a7a5279ebc2ed92264bed8f47d344f8f18c', // nosemgrep
47
+ seed: 'Charlie',
48
+ type: 'sr25519'
49
+ },
50
+ {
51
+ p: '0x306721211d5404bd9da88e0204360a1a9ab8b87c66c1bc2fcdd37f3c2222cc20',
52
+ s: '0x20e05482ca4677e0edbc58ae9a3a59f6ed3b1a9484ba17e64d6fe8688b2b7b5d108c4487b9323b98b11fe36cb301b084e920f7b7895536809a6d62a451b25568', // nosemgrep
53
+ seed: 'Dave',
54
+ type: 'sr25519'
55
+ },
56
+ {
57
+ p: '0xe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e',
58
+ s: '0x683576abfd5dc35273e4264c23095a1bf21c14517bece57c7f0cc5c0ed4ce06a3dbf386b7828f348abe15d76973a72009e6ef86a5c91db2990cb36bb657c6587', // nosemgrep
59
+ seed: 'Eve',
60
+ type: 'sr25519'
61
+ },
62
+ {
63
+ p: '0x1cbd2d43530a44705ad088af313e18f80b53ef16b36177cd4b77b846f2a5f07c',
64
+ s: '0xb835c20f450079cf4f513900ae9faf8df06ad86c681884122c752a4b2bf74d4303e4f21bc6cc62bb4eeed5a9cce642c25e2d2ac1464093b50f6196d78e3a7426', // nosemgrep
65
+ seed: 'Ferdie',
66
+ type: 'sr25519'
67
+ }
68
+ ];
69
+
70
+ export const PAIRSETHEREUM: PairDef[] = [
71
+ {
72
+ name: 'Alith',
73
+ p: '0x02509540919faacf9ab52146c9aa40db68172d83777250b28e4679176e49ccdd9f',
74
+ s: '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133', // nosemgrep
75
+ type: 'ethereum'
76
+ },
77
+ {
78
+ name: 'Baltathar',
79
+ p: '0x033bc19e36ff1673910575b6727a974a9abd80c9a875d41ab3e2648dbfb9e4b518',
80
+ s: '0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b', // nosemgrep
81
+ type: 'ethereum'
82
+ },
83
+ {
84
+ name: 'Charleth',
85
+ p: '0x0234637bdc0e89b5d46543bcbf8edff329d2702bc995e27e9af4b1ba009a3c2a5e',
86
+ s: '0x0b6e18cafb6ed99687ec547bd28139cafdd2bffe70e6b688025de6b445aa5c5b', // nosemgrep
87
+ type: 'ethereum'
88
+ },
89
+ {
90
+ name: 'Dorothy',
91
+ p: '0x02a00d60b2b408c2a14c5d70cdd2c205db8985ef737a7e55ad20ea32cc9e7c417c',
92
+ s: '0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68', // nosemgrep
93
+ type: 'ethereum'
94
+ },
95
+ {
96
+ name: 'Ethan',
97
+ p: '0x025cdc005b752651cd3f728fb9192182acb3a9c89e19072cbd5b03f3ee1f1b3ffa',
98
+ s: '0x7dce9bc8babb68fec1409be38c8e1a52650206a7ed90ff956ae8a6d15eeaaef4', // nosemgrep
99
+ type: 'ethereum'
100
+ },
101
+ {
102
+ name: 'Faith',
103
+ p: '0x037964b6c9d546da4646ada28a99e34acaa1d14e7aba861a9055f9bd200c8abf74',
104
+ s: '0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df', // nosemgrep
105
+ type: 'ethereum'
106
+ }
107
+ ];
108
+
109
+ function createMeta (name?: string, seed?: string) {
110
+ if (!name && !seed) {
111
+ throw new Error('Testing pair should have either a name or a seed');
112
+ }
113
+
114
+ return {
115
+ isTesting: true,
116
+ name: name || seed?.replace('//', '_').toLowerCase()
117
+ };
118
+ }
119
+
120
+ /**
121
+ * @name testKeyring
122
+ * @summary Create an instance of Keyring pre-populated with locked test accounts
123
+ * @description The test accounts (i.e. alice, bob, dave, eve, ferdie)
124
+ * are available on the dev chain and each test account is initialized with DOT funds.
125
+ */
126
+ export function createTestKeyring (options: KeyringOptions = {}, isDerived = true): KeyringInstance {
127
+ const keyring = new Keyring(options);
128
+ const pairs = options.type === 'ethereum'
129
+ ? PAIRSETHEREUM
130
+ : PAIRSSR25519;
131
+
132
+ for (const { name, p, s, seed, type } of pairs) {
133
+ const meta = createMeta(name, seed);
134
+ const pair = !isDerived && !name && seed
135
+ ? keyring.addFromUri(seed, meta, options.type)
136
+ : keyring.addPair(
137
+ createPair(
138
+ { toSS58: keyring.encodeAddress, type },
139
+ { publicKey: hexToU8a(p), secretKey: hexToU8a(s) },
140
+ meta
141
+ )
142
+ );
143
+
144
+ pair.lock = (): void => {
145
+ // we don't have lock/unlock functionality here
146
+ };
147
+ }
148
+
149
+ return keyring;
150
+ }
@@ -0,0 +1,54 @@
1
+
2
+ import type { KeypairType } from 'https://deno.land/x/pezkuwi/util-crypto/types.ts';
3
+ import type { KeyringOptions, KeyringPair } from './types.ts';
4
+
5
+ import { nobody } from './pair/nobody.ts';
6
+ import { createTestKeyring } from './testing.ts';
7
+
8
+ export interface TestKeyringMap {
9
+ nobody: KeyringPair;
10
+
11
+ [index: string]: KeyringPair;
12
+ }
13
+
14
+ export interface TestKeyringMapBizinikiwi extends TestKeyringMap {
15
+ alice: KeyringPair;
16
+ bob: KeyringPair;
17
+ charlie: KeyringPair;
18
+ dave: KeyringPair;
19
+ eve: KeyringPair;
20
+ ferdie: KeyringPair;
21
+ }
22
+
23
+ export interface TestKeyringMapEthereum extends TestKeyringMap {
24
+ Alith: KeyringPair;
25
+ Baltathar: KeyringPair;
26
+ Charleth: KeyringPair;
27
+ Dorothy: KeyringPair;
28
+ Ethan: KeyringPair;
29
+ Faith: KeyringPair;
30
+ }
31
+
32
+ export type DetectMap<O extends KeyringOptions | undefined> = DetectPairType<O> extends 'ethereum'
33
+ ? TestKeyringMapEthereum
34
+ : TestKeyringMapBizinikiwi;
35
+
36
+ export type DetectPairType<O extends KeyringOptions | undefined> = O extends KeyringOptions
37
+ ? O['type'] extends KeypairType
38
+ ? O['type']
39
+ : 'sr25519'
40
+ : 'sr25519';
41
+
42
+ export function createTestPairs <O extends KeyringOptions, M = DetectMap<O>> (options?: O, isDerived = true): M {
43
+ const keyring = createTestKeyring(options, isDerived);
44
+ const pairs = keyring.getPairs();
45
+ const map: TestKeyringMap = { nobody: nobody() };
46
+
47
+ for (const p of pairs) {
48
+ if (p.meta.name) {
49
+ map[p.meta.name] = p;
50
+ }
51
+ }
52
+
53
+ return map as M;
54
+ }
@@ -0,0 +1,129 @@
1
+
2
+ import type { HexString } from 'https://deno.land/x/pezkuwi/util/types.ts';
3
+ import type { EncryptedJson, Keypair, KeypairType, Prefix } from 'https://deno.land/x/pezkuwi/util-crypto/types.ts';
4
+
5
+ export interface KeyringOptions {
6
+ /** The ss58Format to use for address encoding (defaults to 42) */
7
+ ss58Format?: Prefix;
8
+ /** The type of keyring to create (defaults to ed25519) */
9
+ type?: KeypairType;
10
+ }
11
+
12
+ export interface KeyringPair$MetaHardware {
13
+ accountIndex?: number;
14
+ accountOffset?: number;
15
+ addressOffset?: number;
16
+ hardwareType?: 'ledger';
17
+ }
18
+
19
+ export interface KeyringPair$MetaFlags {
20
+ isDefaultAuthSelected?: boolean;
21
+ isExternal?: boolean;
22
+ isHardware?: boolean;
23
+ isHidden?: boolean;
24
+ isInjected?: boolean;
25
+ isMultisig?: boolean;
26
+ isProxied?: boolean;
27
+ isRecent?: boolean;
28
+ isTesting?: boolean;
29
+ }
30
+
31
+ export interface KeyringPair$MetaContract {
32
+ abi: string;
33
+ genesisHash?: HexString | null;
34
+ }
35
+
36
+ export interface KeyringPair$MetaExtension {
37
+ source?: string;
38
+ }
39
+
40
+ export interface KeyringPair$MetaMultisig {
41
+ threshold?: number;
42
+ who?: string[];
43
+ }
44
+
45
+ export interface KeyringPair$MetaParent {
46
+ parentAddress?: string;
47
+ parentName?: string;
48
+ }
49
+
50
+ export interface KeyringPair$Meta extends KeyringPair$MetaExtension, KeyringPair$MetaFlags, KeyringPair$MetaHardware, KeyringPair$MetaMultisig, KeyringPair$MetaParent {
51
+ address?: string;
52
+ contract?: KeyringPair$MetaContract;
53
+ genesisHash?: HexString | null;
54
+ name?: string;
55
+ suri?: string;
56
+ tags?: string[];
57
+ type?: KeypairType;
58
+ whenCreated?: number;
59
+ whenEdited?: number;
60
+ whenUsed?: number;
61
+
62
+ [key: string]: unknown;
63
+ }
64
+
65
+ export interface KeyringPair$Json extends EncryptedJson {
66
+ /** The ss58 encoded address or the hex-encoded version (the latter is for ETH-compat chains) */
67
+ address: string;
68
+ /** The underlying metadata associated with the keypair */
69
+ meta: KeyringPair$Meta;
70
+ }
71
+
72
+ export interface SignOptions {
73
+ /** Create a MultiSignature-compatible output with an indicator type */
74
+ withType?: boolean;
75
+ }
76
+
77
+ export interface KeyringPair {
78
+ readonly address: string;
79
+ readonly addressRaw: Uint8Array;
80
+ readonly meta: KeyringPair$Meta;
81
+ readonly isLocked: boolean;
82
+ readonly publicKey: Uint8Array;
83
+ readonly type: KeypairType;
84
+
85
+ decodePkcs8 (passphrase?: string, encoded?: Uint8Array): void;
86
+ derive (suri: string, meta?: KeyringPair$Meta): KeyringPair;
87
+ encodePkcs8 (passphrase?: string): Uint8Array;
88
+ lock (): void;
89
+ setMeta (meta: KeyringPair$Meta): void;
90
+ sign (message: string | Uint8Array, options?: SignOptions): Uint8Array;
91
+ toJson (passphrase?: string): KeyringPair$Json;
92
+ unlock (passphrase?: string): void;
93
+ verify (message: string | Uint8Array, signature: Uint8Array, signerPublic: string | Uint8Array): boolean;
94
+ vrfSign (message: string | Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array;
95
+ vrfVerify (message: string | Uint8Array, vrfResult: Uint8Array, signerPublic: string | Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): boolean;
96
+ }
97
+
98
+ export interface KeyringPairs {
99
+ add: (pair: KeyringPair) => KeyringPair;
100
+ all: () => KeyringPair[];
101
+ get: (address: string | Uint8Array) => KeyringPair;
102
+ remove: (address: string | Uint8Array) => void;
103
+ }
104
+
105
+ export interface KeyringInstance {
106
+ readonly pairs: KeyringPair[];
107
+ readonly publicKeys: Uint8Array[];
108
+ readonly type: KeypairType;
109
+
110
+ decodeAddress (encoded: string | Uint8Array, ignoreChecksum?: boolean, ss58Format?: Prefix): Uint8Array;
111
+ encodeAddress (key: Uint8Array | string, ss58Format?: Prefix): string;
112
+ setSS58Format (ss58Format: Prefix): void;
113
+
114
+ addPair (pair: KeyringPair): KeyringPair;
115
+ addFromAddress (address: string | Uint8Array, meta?: KeyringPair$Meta, encoded?: Uint8Array | null, type?: KeypairType, ignoreChecksum?: boolean): KeyringPair;
116
+ addFromJson (pair: KeyringPair$Json, ignoreChecksum?: boolean): KeyringPair;
117
+ addFromMnemonic (mnemonic: string, meta?: KeyringPair$Meta, type?: KeypairType, wordlist?: string[]): KeyringPair;
118
+ addFromPair (pair: Keypair, meta?: KeyringPair$Meta, type?: KeypairType): KeyringPair
119
+ addFromSeed (seed: Uint8Array, meta?: KeyringPair$Meta, type?: KeypairType): KeyringPair;
120
+ addFromUri (suri: string, meta?: KeyringPair$Meta, type?: KeypairType, wordlist?: string[]): KeyringPair;
121
+ createFromJson (json: KeyringPair$Json, ignoreChecksum?: boolean): KeyringPair;
122
+ createFromPair (pair: Keypair, meta: KeyringPair$Meta, type: KeypairType): KeyringPair
123
+ createFromUri (suri: string, meta?: KeyringPair$Meta, type?: KeypairType, wordlist?: string[]): KeyringPair;
124
+ getPair (address: string | Uint8Array): KeyringPair;
125
+ getPairs (): KeyringPair[];
126
+ getPublicKeys (): Uint8Array[];
127
+ removePair (address: string | Uint8Array): void;
128
+ toJson (address: string | Uint8Array, passphrase?: string): KeyringPair$Json;
129
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const util_1 = require("@pezkuwi/util");
4
+ const packageInfo_1 = require("@pezkuwi/util/packageInfo");
5
+ const packageInfo_2 = require("@pezkuwi/util-crypto/packageInfo");
6
+ const packageInfo_js_1 = require("./packageInfo.js");
7
+ (0, util_1.detectPackage)(packageInfo_js_1.packageInfo, null, [packageInfo_2.packageInfo, packageInfo_1.packageInfo]);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageInfo = void 0;
4
- exports.packageInfo = { name: '@pezkuwi/keyring', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '14.0.6' };
4
+ exports.packageInfo = { name: '@pezkuwi/keyring', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '14.0.10' };
@@ -1 +1 @@
1
- export const packageInfo = { name: '@pezkuwi/keyring', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '14.0.6' };
1
+ export const packageInfo = { name: '@pezkuwi/keyring', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '14.0.10' };