@twin.org/dlt-account 0.9.2-next.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.
@@ -0,0 +1,545 @@
1
+ # Class: AccountHelper
2
+
3
+ Helper class for account management operations.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new AccountHelper**(): `AccountHelper`
10
+
11
+ #### Returns
12
+
13
+ `AccountHelper`
14
+
15
+ ## Properties
16
+
17
+ ### CLASS\_NAME {#class_name}
18
+
19
+ > `readonly` `static` **CLASS\_NAME**: `string`
20
+
21
+ Runtime name for the class.
22
+
23
+ ***
24
+
25
+ ### DEFAULT\_MNEMONIC\_SECRET\_NAME {#default_mnemonic_secret_name}
26
+
27
+ > `readonly` `static` **DEFAULT\_MNEMONIC\_SECRET\_NAME**: `string` = `"mnemonic"`
28
+
29
+ Default name for the mnemonic secret.
30
+
31
+ ***
32
+
33
+ ### DEFAULT\_SEED\_SECRET\_NAME {#default_seed_secret_name}
34
+
35
+ > `readonly` `static` **DEFAULT\_SEED\_SECRET\_NAME**: `string` = `"seed"`
36
+
37
+ Default name for the seed secret.
38
+
39
+ ***
40
+
41
+ ### DEFAULT\_COIN\_TYPE {#default_coin_type}
42
+
43
+ > `readonly` `static` **DEFAULT\_COIN\_TYPE**: `number` = `4218`
44
+
45
+ Default coin type.
46
+
47
+ ***
48
+
49
+ ### DEFAULT\_CALC\_CHUNK\_SIZE {#default_calc_chunk_size}
50
+
51
+ > `readonly` `static` **DEFAULT\_CALC\_CHUNK\_SIZE**: `number` = `25`
52
+
53
+ Default pre-calculation chunk size.
54
+
55
+ ***
56
+
57
+ ### DEFAULT\_SCAN\_RANGE\_SIZE {#default_scan_range_size}
58
+
59
+ > `readonly` `static` **DEFAULT\_SCAN\_RANGE\_SIZE**: `number` = `1000`
60
+
61
+ Default scan range.
62
+
63
+ ## Methods
64
+
65
+ ### createAccountKeys() {#createaccountkeys}
66
+
67
+ > `static` **createAccountKeys**(`accountConfig`, `vaultConnector`, `identity`, `mnemonic?`, `accountIndex?`): `Promise`\<`string`\>
68
+
69
+ Create a new account by generating a mnemonic and seed, storing them in the vault, and pre-caching the first chunk of derived keys.
70
+
71
+ #### Parameters
72
+
73
+ ##### accountConfig
74
+
75
+ [`IAccountConfig`](../interfaces/IAccountConfig.md) \| `undefined`
76
+
77
+ The account configuration.
78
+
79
+ ##### vaultConnector
80
+
81
+ `IVaultConnector`
82
+
83
+ The vault connector.
84
+
85
+ ##### identity
86
+
87
+ `string`
88
+
89
+ The identity of the user to access the vault keys.
90
+
91
+ ##### mnemonic?
92
+
93
+ `string`
94
+
95
+ The mnemonic to store, if undefined a new one will be generated and returned.
96
+
97
+ ##### accountIndex?
98
+
99
+ `number`
100
+
101
+ The account index to pre-cache.
102
+
103
+ #### Returns
104
+
105
+ `Promise`\<`string`\>
106
+
107
+ The mnemonic that was stored.
108
+
109
+ ***
110
+
111
+ ### renameAccountKeys() {#renameaccountkeys}
112
+
113
+ > `static` **renameAccountKeys**(`accountConfig`, `vaultConnector`, `fromIdentity`, `toIdentity`): `Promise`\<`void`\>
114
+
115
+ Rename all vault entries for an account from one identity to another.
116
+
117
+ #### Parameters
118
+
119
+ ##### accountConfig
120
+
121
+ [`IAccountConfig`](../interfaces/IAccountConfig.md) \| `undefined`
122
+
123
+ The account configuration.
124
+
125
+ ##### vaultConnector
126
+
127
+ `IVaultConnector`
128
+
129
+ The vault connector.
130
+
131
+ ##### fromIdentity
132
+
133
+ `string`
134
+
135
+ The source identity whose vault entries should be copied.
136
+
137
+ ##### toIdentity
138
+
139
+ `string`
140
+
141
+ The destination identity that will receive the copied entries.
142
+
143
+ #### Returns
144
+
145
+ `Promise`\<`void`\>
146
+
147
+ ***
148
+
149
+ ### removeAccountKeys() {#removeaccountkeys}
150
+
151
+ > `static` **removeAccountKeys**(`accountConfig`, `vaultConnector`, `identity`): `Promise`\<`void`\>
152
+
153
+ Remove all vault entries for an account.
154
+
155
+ #### Parameters
156
+
157
+ ##### accountConfig
158
+
159
+ [`IAccountConfig`](../interfaces/IAccountConfig.md) \| `undefined`
160
+
161
+ The account configuration.
162
+
163
+ ##### vaultConnector
164
+
165
+ `IVaultConnector`
166
+
167
+ The vault connector.
168
+
169
+ ##### identity
170
+
171
+ `string`
172
+
173
+ The identity of the user whose vault keys should be removed.
174
+
175
+ #### Returns
176
+
177
+ `Promise`\<`void`\>
178
+
179
+ ***
180
+
181
+ ### buildSeedKey() {#buildseedkey}
182
+
183
+ > `static` **buildSeedKey**(`identity`, `vaultSeedId?`): `string`
184
+
185
+ Get the key for storing the seed.
186
+
187
+ #### Parameters
188
+
189
+ ##### identity
190
+
191
+ `string`
192
+
193
+ The identity to use.
194
+
195
+ ##### vaultSeedId?
196
+
197
+ `string`
198
+
199
+ The seed ID to use.
200
+
201
+ #### Returns
202
+
203
+ `string`
204
+
205
+ The seed key.
206
+
207
+ ***
208
+
209
+ ### buildMnemonicKey() {#buildmnemonickey}
210
+
211
+ > `static` **buildMnemonicKey**(`identity`, `vaultMnemonicId?`): `string`
212
+
213
+ Get the key for storing the mnemonic.
214
+
215
+ #### Parameters
216
+
217
+ ##### identity
218
+
219
+ `string`
220
+
221
+ The identity to use.
222
+
223
+ ##### vaultMnemonicId?
224
+
225
+ `string`
226
+
227
+ The mnemonic ID to use.
228
+
229
+ #### Returns
230
+
231
+ `string`
232
+
233
+ The mnemonic key.
234
+
235
+ ***
236
+
237
+ ### getPublicKeys() {#getpublickeys}
238
+
239
+ > `static` **getPublicKeys**(`accountConfig`, `vaultConnector`, `identity`, `accountIndex`, `internal`, `addressIndex`, `seedProvider`): `Promise`\<`string`[]\>
240
+
241
+ Ensure a range of BIP44-derived keys are registered as individual vault keys and return their public keys.
242
+ If the first key of the range already exists the range is considered registered and only public keys are derived.
243
+ If not registered, all keys are derived and added to the vault before returning the public keys.
244
+
245
+ #### Parameters
246
+
247
+ ##### accountConfig
248
+
249
+ [`IAccountConfig`](../interfaces/IAccountConfig.md) \| `undefined`
250
+
251
+ The account configuration.
252
+
253
+ ##### vaultConnector
254
+
255
+ `IVaultConnector`
256
+
257
+ The vault connector to use.
258
+
259
+ ##### identity
260
+
261
+ `string`
262
+
263
+ The identity of the user to access the vault keys.
264
+
265
+ ##### accountIndex
266
+
267
+ `number`
268
+
269
+ The account index.
270
+
271
+ ##### internal
272
+
273
+ `boolean`
274
+
275
+ Whether the addresses are internal or external.
276
+
277
+ ##### addressIndex
278
+
279
+ `number`
280
+
281
+ Any address index within the desired chunk; aligned internally.
282
+
283
+ ##### seedProvider
284
+
285
+ () => `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
286
+
287
+ Callback invoked at most once per call to supply the seed when a chunk is not yet registered.
288
+
289
+ #### Returns
290
+
291
+ `Promise`\<`string`[]\>
292
+
293
+ The base64-encoded public keys for each address in the range.
294
+
295
+ ***
296
+
297
+ ### buildAddressKeyName() {#buildaddresskeyname}
298
+
299
+ > `static` **buildAddressKeyName**(`identity`, `accountIndex`, `internal`, `addressIndex`): `string`
300
+
301
+ Build the vault key name for a specific derived address.
302
+
303
+ #### Parameters
304
+
305
+ ##### identity
306
+
307
+ `string`
308
+
309
+ The identity to use.
310
+
311
+ ##### accountIndex
312
+
313
+ `number`
314
+
315
+ The account index.
316
+
317
+ ##### internal
318
+
319
+ `boolean`
320
+
321
+ Whether the address is internal or external.
322
+
323
+ ##### addressIndex
324
+
325
+ `number`
326
+
327
+ The address index.
328
+
329
+ #### Returns
330
+
331
+ `string`
332
+
333
+ The vault key name.
334
+
335
+ ***
336
+
337
+ ### getAddress() {#getaddress}
338
+
339
+ > `static` **getAddress**(`accountConfig`, `vaultConnector`, `identity`, `accountIndex`, `startAddressIndex`, `isInternal?`): `Promise`\<`string`\>
340
+
341
+ Get address for the identity.
342
+
343
+ #### Parameters
344
+
345
+ ##### accountConfig
346
+
347
+ [`IAccountConfig`](../interfaces/IAccountConfig.md) \| `undefined`
348
+
349
+ The account configuration.
350
+
351
+ ##### vaultConnector
352
+
353
+ `IVaultConnector`
354
+
355
+ The vault connector.
356
+
357
+ ##### identity
358
+
359
+ `string`
360
+
361
+ The identity of the user to access the vault keys.
362
+
363
+ ##### accountIndex
364
+
365
+ `number`
366
+
367
+ The account index to get the addresses for.
368
+
369
+ ##### startAddressIndex
370
+
371
+ `number`
372
+
373
+ The start index for the addresses.
374
+
375
+ ##### isInternal?
376
+
377
+ `boolean`
378
+
379
+ Whether the addresses are internal.
380
+
381
+ #### Returns
382
+
383
+ `Promise`\<`string`\>
384
+
385
+ The address.
386
+
387
+ ***
388
+
389
+ ### getAddresses() {#getaddresses}
390
+
391
+ > `static` **getAddresses**(`accountConfig`, `vaultConnector`, `identity`, `accountIndex`, `startAddressIndex`, `count`, `isInternal?`): `Promise`\<`string`[]\>
392
+
393
+ Get addresses for the identity.
394
+
395
+ #### Parameters
396
+
397
+ ##### accountConfig
398
+
399
+ [`IAccountConfig`](../interfaces/IAccountConfig.md) \| `undefined`
400
+
401
+ The account configuration.
402
+
403
+ ##### vaultConnector
404
+
405
+ `IVaultConnector`
406
+
407
+ The vault connector.
408
+
409
+ ##### identity
410
+
411
+ `string`
412
+
413
+ The identity of the user to access the vault keys.
414
+
415
+ ##### accountIndex
416
+
417
+ `number`
418
+
419
+ The account index to get the addresses for.
420
+
421
+ ##### startAddressIndex
422
+
423
+ `number`
424
+
425
+ The start index for the addresses.
426
+
427
+ ##### count
428
+
429
+ `number`
430
+
431
+ The number of addresses to generate.
432
+
433
+ ##### isInternal?
434
+
435
+ `boolean`
436
+
437
+ Whether the addresses are internal.
438
+
439
+ #### Returns
440
+
441
+ `Promise`\<`string`[]\>
442
+
443
+ The list of addresses.
444
+
445
+ ***
446
+
447
+ ### getSeed() {#getseed}
448
+
449
+ > `static` **getSeed**(`accountConfig`, `vaultConnector`, `identity`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
450
+
451
+ Get the seed from the vault, deriving it from the mnemonic if necessary.
452
+
453
+ #### Parameters
454
+
455
+ ##### accountConfig
456
+
457
+ [`IAccountConfig`](../interfaces/IAccountConfig.md) \| `undefined`
458
+
459
+ The account configuration.
460
+
461
+ ##### vaultConnector
462
+
463
+ `IVaultConnector`
464
+
465
+ The vault connector to use.
466
+
467
+ ##### identity
468
+
469
+ `string`
470
+
471
+ The identity of the user to access the vault keys.
472
+
473
+ #### Returns
474
+
475
+ `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
476
+
477
+ The seed bytes.
478
+
479
+ ***
480
+
481
+ ### findAddressKey() {#findaddresskey}
482
+
483
+ > `static` **findAddressKey**(`accountConfig`, `vaultConnector`, `identity`, `address`, `accountIndex?`): `Promise`\<\{ `keyName`: `string`; `publicKey`: `Uint8Array`; \}\>
484
+
485
+ Find the vault key name and public key for a specific address by scanning derived keys.
486
+
487
+ #### Parameters
488
+
489
+ ##### accountConfig
490
+
491
+ [`IAccountConfig`](../interfaces/IAccountConfig.md) \| `undefined`
492
+
493
+ The account configuration.
494
+
495
+ ##### vaultConnector
496
+
497
+ `IVaultConnector`
498
+
499
+ The vault connector to use.
500
+
501
+ ##### identity
502
+
503
+ `string`
504
+
505
+ The identity of the user to access the vault keys.
506
+
507
+ ##### address
508
+
509
+ `string`
510
+
511
+ The owner address whose key should be located.
512
+
513
+ ##### accountIndex?
514
+
515
+ `number` = `0`
516
+
517
+ The account index to search.
518
+
519
+ #### Returns
520
+
521
+ `Promise`\<\{ `keyName`: `string`; `publicKey`: `Uint8Array`; \}\>
522
+
523
+ The vault key name and the public key bytes.
524
+
525
+ ***
526
+
527
+ ### publicKeyToAddress() {#publickeytoaddress}
528
+
529
+ > `static` **publicKeyToAddress**(`publicKey`): `string`
530
+
531
+ Derive an address from a public key.
532
+
533
+ #### Parameters
534
+
535
+ ##### publicKey
536
+
537
+ `Uint8Array`
538
+
539
+ The public key to derive the address from.
540
+
541
+ #### Returns
542
+
543
+ `string`
544
+
545
+ The derived address.
@@ -0,0 +1,9 @@
1
+ # @twin.org/dlt-account
2
+
3
+ ## Classes
4
+
5
+ - [AccountHelper](classes/AccountHelper.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [IAccountConfig](interfaces/IAccountConfig.md)
@@ -0,0 +1,35 @@
1
+ # Interface: IAccountConfig
2
+
3
+ The configuration for an account.
4
+
5
+ ## Properties
6
+
7
+ ### vaultSeedId? {#vaultseedid}
8
+
9
+ > `optional` **vaultSeedId?**: `string`
10
+
11
+ The ID of the vault seed.
12
+
13
+ ***
14
+
15
+ ### vaultMnemonicId? {#vaultmnemonicid}
16
+
17
+ > `optional` **vaultMnemonicId?**: `string`
18
+
19
+ The ID of the vault mnemonic.
20
+
21
+ ***
22
+
23
+ ### coinType? {#cointype}
24
+
25
+ > `optional` **coinType?**: `number`
26
+
27
+ The coin type.
28
+
29
+ ***
30
+
31
+ ### maxAddressScanRange? {#maxaddressscanrange}
32
+
33
+ > `optional` **maxAddressScanRange?**: `number`
34
+
35
+ The maximum number of addresses to scan for the account.
@@ -0,0 +1,8 @@
1
+ {
2
+ "error": {
3
+ "accountHelper": {
4
+ "addressNotFound": "The address is missing could not be found from the seed \"{address}\"",
5
+ "missingPublicKey": "The public key is missing for vault key \"{keyName}\""
6
+ }
7
+ }
8
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@twin.org/dlt-account",
3
+ "version": "0.9.2-next.2",
4
+ "description": "Account management utilities for distributed ledger operations.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/iotaledger/twin-dlt.git",
8
+ "directory": "packages/dlt-account"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=24.0.0"
15
+ },
16
+ "dependencies": {
17
+ "@twin.org/core": "next",
18
+ "@twin.org/crypto": "next",
19
+ "@twin.org/nameof": "next",
20
+ "@twin.org/vault-models": "next"
21
+ },
22
+ "main": "./dist/es/index.js",
23
+ "types": "./dist/types/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/types/index.d.ts",
27
+ "import": "./dist/es/index.js",
28
+ "default": "./dist/es/index.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist/es",
33
+ "dist/types",
34
+ "locales",
35
+ "docs"
36
+ ],
37
+ "keywords": [
38
+ "twin",
39
+ "trade",
40
+ "iota",
41
+ "framework",
42
+ "blockchain",
43
+ "dlt",
44
+ "account"
45
+ ],
46
+ "bugs": {
47
+ "url": "git+https://github.com/iotaledger/twin-dlt/issues"
48
+ },
49
+ "homepage": "https://twindev.org"
50
+ }