@bsv/wallet-toolbox 1.5.10 → 1.5.12

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 (69) hide show
  1. package/docs/client.md +9 -9
  2. package/docs/setup.md +8 -8
  3. package/docs/wallet.md +9 -9
  4. package/mobile/out/src/SetupClient.d.ts +2 -2
  5. package/mobile/out/src/SetupClient.d.ts.map +1 -1
  6. package/mobile/out/src/SetupClient.js +2 -2
  7. package/mobile/out/src/SetupClient.js.map +1 -1
  8. package/mobile/out/src/SetupWallet.d.ts +2 -2
  9. package/mobile/out/src/SetupWallet.d.ts.map +1 -1
  10. package/mobile/out/src/Wallet.d.ts +3 -3
  11. package/mobile/out/src/Wallet.d.ts.map +1 -1
  12. package/mobile/out/src/Wallet.js.map +1 -1
  13. package/mobile/out/src/services/providers/ARC.d.ts.map +1 -1
  14. package/mobile/out/src/services/providers/ARC.js +2 -3
  15. package/mobile/out/src/services/providers/ARC.js.map +1 -1
  16. package/mobile/out/src/signer/WalletSigner.d.ts +3 -3
  17. package/mobile/out/src/signer/WalletSigner.d.ts.map +1 -1
  18. package/mobile/out/src/signer/WalletSigner.js.map +1 -1
  19. package/mobile/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
  20. package/mobile/out/src/utility/ScriptTemplateBRC29.js +1 -1
  21. package/mobile/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
  22. package/mobile/package-lock.json +6 -7
  23. package/mobile/package.json +2 -2
  24. package/out/src/Setup.d.ts +2 -2
  25. package/out/src/Setup.d.ts.map +1 -1
  26. package/out/src/Setup.js +2 -2
  27. package/out/src/Setup.js.map +1 -1
  28. package/out/src/SetupClient.d.ts +2 -2
  29. package/out/src/SetupClient.d.ts.map +1 -1
  30. package/out/src/SetupClient.js +2 -2
  31. package/out/src/SetupClient.js.map +1 -1
  32. package/out/src/SetupWallet.d.ts +2 -2
  33. package/out/src/SetupWallet.d.ts.map +1 -1
  34. package/out/src/Wallet.d.ts +3 -3
  35. package/out/src/Wallet.d.ts.map +1 -1
  36. package/out/src/Wallet.js.map +1 -1
  37. package/out/src/__tests/WalletPermissionsManager.proxying.test.js +1 -1
  38. package/out/src/__tests/WalletPermissionsManager.proxying.test.js.map +1 -1
  39. package/out/src/services/__tests/ARC.timeout.man.test.js +43 -2
  40. package/out/src/services/__tests/ARC.timeout.man.test.js.map +1 -1
  41. package/out/src/services/providers/ARC.d.ts.map +1 -1
  42. package/out/src/services/providers/ARC.js +2 -3
  43. package/out/src/services/providers/ARC.js.map +1 -1
  44. package/out/src/signer/WalletSigner.d.ts +3 -3
  45. package/out/src/signer/WalletSigner.d.ts.map +1 -1
  46. package/out/src/signer/WalletSigner.js.map +1 -1
  47. package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
  48. package/out/src/utility/ScriptTemplateBRC29.js +1 -1
  49. package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
  50. package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
  51. package/out/test/Wallet/live/walletLive.man.test.js +1 -1
  52. package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
  53. package/out/test/utils/TestUtilsWalletStorage.d.ts +4 -4
  54. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
  55. package/out/test/utils/TestUtilsWalletStorage.js +3 -3
  56. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
  57. package/out/tsconfig.all.tsbuildinfo +1 -1
  58. package/package.json +2 -2
  59. package/src/Setup.ts +5 -3
  60. package/src/SetupClient.ts +5 -3
  61. package/src/SetupWallet.ts +2 -2
  62. package/src/Wallet.ts +4 -3
  63. package/src/__tests/WalletPermissionsManager.proxying.test.ts +1 -1
  64. package/src/services/__tests/ARC.timeout.man.test.ts +45 -2
  65. package/src/services/providers/ARC.ts +2 -3
  66. package/src/signer/WalletSigner.ts +3 -3
  67. package/src/utility/ScriptTemplateBRC29.ts +3 -2
  68. package/test/Wallet/live/walletLive.man.test.ts +2 -1
  69. package/test/utils/TestUtilsWalletStorage.ts +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/wallet-toolbox",
3
- "version": "1.5.10",
3
+ "version": "1.5.12",
4
4
  "description": "BRC100 conforming wallet, wallet storage and wallet signer components",
5
5
  "main": "./out/src/index.js",
6
6
  "types": "./out/src/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@bsv/auth-express-middleware": "^1.2.0",
34
34
  "@bsv/payment-express-middleware": "^1.2.1",
35
- "@bsv/sdk": "^1.6.12",
35
+ "@bsv/sdk": "^1.6.16",
36
36
  "express": "^4.21.2",
37
37
  "idb": "^8.0.2",
38
38
  "knex": "^3.1.0",
package/src/Setup.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { KeyPairAddress, SetupWallet, SetupWalletClient } from './SetupWallet'
2
2
  import {
3
3
  BEEF,
4
+ CachedKeyDeriver,
4
5
  CreateActionArgs,
5
6
  CreateActionOptions,
6
7
  CreateActionOutput,
7
8
  CreateActionResult,
8
9
  KeyDeriver,
10
+ KeyDeriverApi,
9
11
  LockingScript,
10
12
  P2PKH,
11
13
  PrivateKey,
@@ -142,7 +144,7 @@ DEV_KEYS = '{
142
144
  args.rootKeyHex ||= args.env.devKeys[args.env.identityKey]
143
145
  const rootKey = PrivateKey.fromHex(args.rootKeyHex)
144
146
  const identityKey = rootKey.toPublicKey().toString()
145
- const keyDeriver = new KeyDeriver(rootKey)
147
+ const keyDeriver = new CachedKeyDeriver(rootKey)
146
148
  const storage = new WalletStorageManager(identityKey, args.active, args.backups)
147
149
  if (storage.canMakeAvailable()) await storage.makeAvailable()
148
150
  const serviceOptions = Services.createDefaultOptions(chain)
@@ -196,7 +198,7 @@ DEV_KEYS = '{
196
198
  const chain = args.chain
197
199
  const endpointUrl = args.storageUrl || `https://${args.chain !== 'main' ? 'staging-' : ''}storage.babbage.systems`
198
200
  const rootKey = PrivateKey.fromHex(args.rootKeyHex)
199
- const keyDeriver = new KeyDeriver(rootKey)
201
+ const keyDeriver = new CachedKeyDeriver(rootKey)
200
202
  const storage = new WalletStorageManager(keyDeriver.identityKey)
201
203
  const services = new Services(chain)
202
204
  const privilegedKeyManager = args.privilegedKeyGetter
@@ -512,7 +514,7 @@ export interface SetupWalletKnex extends SetupWallet {
512
514
 
513
515
  rootKey: PrivateKey
514
516
  identityKey: string
515
- keyDeriver: KeyDeriver
517
+ keyDeriver: KeyDeriverApi
516
518
  chain: sdk.Chain
517
519
  storage: WalletStorageManager
518
520
  services: Services
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  BEEF,
3
+ CachedKeyDeriver,
3
4
  CreateActionArgs,
4
5
  CreateActionOptions,
5
6
  CreateActionOutput,
6
7
  CreateActionResult,
7
8
  KeyDeriver,
9
+ KeyDeriverApi,
8
10
  LockingScript,
9
11
  P2PKH,
10
12
  PrivateKey,
@@ -34,7 +36,7 @@ export abstract class SetupClient {
34
36
  const chain = args.chain
35
37
  const rootKey = PrivateKey.fromHex(args.rootKeyHex)
36
38
  const identityKey = rootKey.toPublicKey().toString()
37
- const keyDeriver = new KeyDeriver(rootKey)
39
+ const keyDeriver = new CachedKeyDeriver(rootKey)
38
40
  const storage = new WalletStorageManager(identityKey, args.active, args.backups)
39
41
  if (storage.canMakeAvailable()) await storage.makeAvailable()
40
42
  const serviceOptions = Services.createDefaultOptions(chain)
@@ -84,7 +86,7 @@ export abstract class SetupClient {
84
86
  const chain = args.chain
85
87
  const endpointUrl = args.storageUrl || `https://${args.chain !== 'main' ? 'staging-' : ''}storage.babbage.systems`
86
88
  const rootKey = PrivateKey.fromHex(args.rootKeyHex)
87
- const keyDeriver = new KeyDeriver(rootKey)
89
+ const keyDeriver = new CachedKeyDeriver(rootKey)
88
90
  const storage = new WalletStorageManager(keyDeriver.identityKey)
89
91
  const services = new Services(chain)
90
92
  const privilegedKeyManager = args.privilegedKeyGetter
@@ -290,7 +292,7 @@ export interface SetupWalletIdb extends SetupWallet {
290
292
 
291
293
  rootKey: PrivateKey
292
294
  identityKey: string
293
- keyDeriver: KeyDeriver
295
+ keyDeriver: KeyDeriverApi
294
296
  chain: sdk.Chain
295
297
  storage: WalletStorageManager
296
298
  services: Services
@@ -1,4 +1,4 @@
1
- import { PrivateKey, KeyDeriver, PublicKey } from '@bsv/sdk'
1
+ import { PrivateKey, KeyDeriver, PublicKey, KeyDeriverApi } from '@bsv/sdk'
2
2
  import { WalletStorageManager, Monitor, sdk } from './index.client'
3
3
  import { Services } from './services'
4
4
  import { Wallet } from './Wallet'
@@ -23,7 +23,7 @@ export interface SetupWallet {
23
23
  /**
24
24
  * The `KeyDeriver` component used by the wallet for key derivation and cryptographic functions.
25
25
  */
26
- keyDeriver: KeyDeriver
26
+ keyDeriver: KeyDeriverApi
27
27
  /**
28
28
  * The chain ('main' or 'test') which the wallet accesses.
29
29
  */
package/src/Wallet.ts CHANGED
@@ -65,7 +65,8 @@ import {
65
65
  Certificate,
66
66
  LookupResolver,
67
67
  AtomicBEEF,
68
- BEEF
68
+ BEEF,
69
+ KeyDeriverApi
69
70
  } from '@bsv/sdk'
70
71
  import * as sdk from './sdk'
71
72
  import { acquireDirectCertificate } from './signer/methods/acquireDirectCertificate'
@@ -92,7 +93,7 @@ import { ScriptTemplateBRC29 } from './utility/ScriptTemplateBRC29'
92
93
 
93
94
  export interface WalletArgs {
94
95
  chain: sdk.Chain
95
- keyDeriver: KeyDeriver
96
+ keyDeriver: KeyDeriverApi
96
97
  storage: WalletStorageManager
97
98
  services?: sdk.WalletServices
98
99
  monitor?: Monitor
@@ -107,7 +108,7 @@ function isWalletSigner(args: WalletArgs | WalletSigner): args is WalletSigner {
107
108
 
108
109
  export class Wallet implements WalletInterface, ProtoWallet {
109
110
  chain: sdk.Chain
110
- keyDeriver: KeyDeriver
111
+ keyDeriver: KeyDeriverApi
111
112
  storage: WalletStorageManager
112
113
  settingsManager: WalletSettingsManager
113
114
  lookupResolver: LookupResolver
@@ -679,7 +679,7 @@ describe('WalletPermissionsManager - Regression & Integration with Underlying Wa
679
679
  const result = await manager.waitForAuthentication({}, 'someone.com')
680
680
  expect(result.authenticated).toBe(true)
681
681
  expect(underlying.waitForAuthentication).toHaveBeenCalledTimes(1)
682
- })
682
+ }, 30000)
683
683
 
684
684
  it('should proxy getHeight', async () => {
685
685
  const result = await manager.getHeight({}, 'someone.com')
@@ -17,18 +17,61 @@ describe('ARC tests', () => {
17
17
  const requestOptions: HttpClientRequestOptions = {
18
18
  method: 'POST',
19
19
  headers,
20
- data: { rawTx: beef905631 }
20
+ data: { rawTx: beef905631 },
21
+ signal: AbortSignal.timeout(100)
21
22
  }
22
23
 
23
- requestOptions['signal'] = AbortSignal.timeout(5000)
24
+ try {
25
+ const response = await httpClient.request(url, requestOptions)
26
+ expect(true).toBe(false) // Should not reach here, expect an error
27
+ } catch (error: any) {
28
+ console.log('Error posting to TAAL:', error.message)
29
+ expect(error.code).toBe('ABORT_ERR')
30
+ }
24
31
 
25
32
  try {
33
+ requestOptions.signal = AbortSignal.timeout(30000) // 30 seconds timeout
26
34
  const response = await httpClient.request(url, requestOptions)
27
35
  expect(response.status).toBe(200)
36
+ } catch (error: any) {
37
+ console.log('Error posting to TAAL:', error.message)
38
+ expect(true).toBe(false) // Should not reach here, expect an error
39
+ }
40
+ })
41
+
42
+ test('12 post to GorillaPool for timeout', async () => {
43
+ const httpClient = defaultHttpClient()
44
+ const url = `https://arc.gorillapool.io/v1/tx`
45
+
46
+ const headers: Record<string, string> = {
47
+ 'Content-Type': 'application/json',
48
+ 'XDeployment-ID': 'wallet-toolbox-test11',
49
+ //Authorization: `Bearer ${envMain.gorillaPoolApiKey}`
50
+ }
51
+
52
+ const requestOptions: HttpClientRequestOptions = {
53
+ method: 'POST',
54
+ headers,
55
+ data: { rawTx: beef905631 },
56
+ signal: AbortSignal.timeout(100)
57
+ }
58
+
59
+ try {
60
+ const response = await httpClient.request(url, requestOptions)
61
+ expect(true).toBe(false) // Should not reach here, expect an error
28
62
  } catch (error: any) {
29
63
  console.log('Error posting to TAAL:', error.message)
30
64
  expect(error.code).toBe('ABORT_ERR')
31
65
  }
66
+
67
+ try {
68
+ requestOptions.signal = AbortSignal.timeout(30000) // 30 seconds timeout
69
+ const response = await httpClient.request(url, requestOptions)
70
+ expect(response.status).toBe(200)
71
+ } catch (error: any) {
72
+ console.log('Error posting to TAAL:', error.message)
73
+ expect(true).toBe(false) // Should not reach here, expect an error
74
+ }
32
75
  })
33
76
  })
34
77
 
@@ -135,7 +135,8 @@ export class ARC {
135
135
  const requestOptions: HttpClientRequestOptions = {
136
136
  method: 'POST',
137
137
  headers: this.requestHeaders(),
138
- data: { rawTx }
138
+ data: { rawTx },
139
+ signal: AbortSignal.timeout(1000 * 30) // 30 seconds timeout, error.code will be 'ABORT_ERR'
139
140
  }
140
141
 
141
142
  const r: sdk.PostTxResultForTxid = {
@@ -143,8 +144,6 @@ export class ARC {
143
144
  status: 'success',
144
145
  notes: []
145
146
  }
146
- // Set a timeout on the request
147
- requestOptions['signal'] = AbortSignal.timeout(1000 * 30) // 30 seconds timeout, error.code will be 'ABORT_ERR'
148
147
 
149
148
  const url = `${this.URL}/v1/tx`
150
149
  const nn = () => ({ name: this.name, when: new Date().toISOString() })
@@ -1,4 +1,4 @@
1
- import { KeyDeriver } from '@bsv/sdk'
1
+ import { KeyDeriver, KeyDeriverApi } from '@bsv/sdk'
2
2
  import { sdk } from '../index.client'
3
3
  import { WalletStorageManager } from '../storage/WalletStorageManager'
4
4
 
@@ -6,10 +6,10 @@ export class WalletSigner {
6
6
  isWalletSigner: true = true
7
7
 
8
8
  chain: sdk.Chain
9
- keyDeriver: KeyDeriver
9
+ keyDeriver: KeyDeriverApi
10
10
  storage: WalletStorageManager
11
11
 
12
- constructor(chain: sdk.Chain, keyDeriver: KeyDeriver, storage: WalletStorageManager) {
12
+ constructor(chain: sdk.Chain, keyDeriver: KeyDeriverApi, storage: WalletStorageManager) {
13
13
  this.chain = chain
14
14
  this.keyDeriver = keyDeriver
15
15
  this.storage = storage
@@ -9,7 +9,8 @@ import {
9
9
  LockingScript,
10
10
  P2PKH,
11
11
  PrivateKey,
12
- Script
12
+ Script,
13
+ CachedKeyDeriver
13
14
  } from '@bsv/sdk'
14
15
 
15
16
  export const brc29ProtocolID: WalletProtocol = [2, '3241645161d8']
@@ -41,7 +42,7 @@ export class ScriptTemplateBRC29 implements ScriptTemplate {
41
42
  getKeyDeriver(privKey: PrivateKey | HexString): KeyDeriverApi {
42
43
  if (typeof privKey === 'string') privKey = PrivateKey.fromHex(privKey)
43
44
  if (!this.params.keyDeriver || this.params.keyDeriver.rootKey.toHex() !== privKey.toHex())
44
- return new KeyDeriver(privKey)
45
+ return new CachedKeyDeriver(privKey)
45
46
  return this.params.keyDeriver
46
47
  }
47
48
 
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
2
  import {
3
3
  Beef,
4
+ CachedKeyDeriver,
4
5
  CreateActionArgs,
5
6
  InternalizeActionArgs,
6
7
  KeyDeriver,
@@ -426,7 +427,7 @@ export function createWalletPaymentOutput(args: {
426
427
  const t = new ScriptTemplateBRC29({
427
428
  derivationPrefix: randomBytesBase64(8),
428
429
  derivationSuffix: randomBytesBase64(8),
429
- keyDeriver: new KeyDeriver(PrivateKey.fromString(args.fromRootKeyHex))
430
+ keyDeriver: new CachedKeyDeriver(PrivateKey.fromString(args.fromRootKeyHex))
430
431
  })
431
432
 
432
433
  const lockingScript = t.lock(args.fromRootKeyHex, args.toIdentityKey)
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  Beef,
3
+ CachedKeyDeriver,
3
4
  CreateActionArgs,
4
5
  CreateActionOutput,
5
6
  CreateActionResult,
6
7
  HexString,
7
8
  KeyDeriver,
9
+ KeyDeriverApi,
8
10
  P2PKH,
9
11
  PrivateKey,
10
12
  PublicKey,
@@ -309,7 +311,7 @@ export abstract class TestUtilsWalletStorage {
309
311
  args.rootKeyHex ||= '1'.repeat(64)
310
312
  const rootKey = PrivateKey.fromHex(args.rootKeyHex)
311
313
  const identityKey = rootKey.toPublicKey().toString()
312
- const keyDeriver = new KeyDeriver(rootKey)
314
+ const keyDeriver = new CachedKeyDeriver(rootKey)
313
315
  const chain = args.chain
314
316
  const storage = new WalletStorageManager(identityKey, args.active, args.backups)
315
317
  if (storage.canMakeAvailable()) await storage.makeAvailable()
@@ -807,7 +809,7 @@ export abstract class TestUtilsWalletStorage {
807
809
  const rootKeyHex = _tu.legacyRootKeyHex
808
810
  const identityKey = '03ac2d10bdb0023f4145cc2eba2fcd2ad3070cb2107b0b48170c46a9440e4cc3fe'
809
811
  const rootKey = PrivateKey.fromHex(rootKeyHex)
810
- const keyDeriver = new KeyDeriver(rootKey)
812
+ const keyDeriver = new CachedKeyDeriver(rootKey)
811
813
  const activeStorage = new StorageKnex({
812
814
  chain,
813
815
  knex: walletKnex,
@@ -977,7 +979,7 @@ export abstract class TestUtilsWalletStorage {
977
979
  const rootKeyHex = _tu.legacyRootKeyHex
978
980
  const identityKey = '03ac2d10bdb0023f4145cc2eba2fcd2ad3070cb2107b0b48170c46a9440e4cc3fe'
979
981
  const rootKey = PrivateKey.fromHex(rootKeyHex)
980
- const keyDeriver = new KeyDeriver(rootKey)
982
+ const keyDeriver = new CachedKeyDeriver(rootKey)
981
983
 
982
984
  const activeStorage = new StorageIdb({
983
985
  chain,
@@ -1835,7 +1837,7 @@ export interface TestWalletProvider<T> extends TestWalletOnly {
1835
1837
 
1836
1838
  rootKey: PrivateKey
1837
1839
  identityKey: string
1838
- keyDeriver: KeyDeriver
1840
+ keyDeriver: KeyDeriverApi
1839
1841
  chain: sdk.Chain
1840
1842
  storage: WalletStorageManager
1841
1843
  services: Services
@@ -1853,7 +1855,7 @@ export interface TestWallet<T> extends TestWalletOnly {
1853
1855
 
1854
1856
  rootKey: PrivateKey
1855
1857
  identityKey: string
1856
- keyDeriver: KeyDeriver
1858
+ keyDeriver: KeyDeriverApi
1857
1859
  chain: sdk.Chain
1858
1860
  storage: WalletStorageManager
1859
1861
  services: Services
@@ -1867,7 +1869,7 @@ export interface TestWallet<T> extends TestWalletOnly {
1867
1869
  export interface TestWalletOnly {
1868
1870
  rootKey: PrivateKey
1869
1871
  identityKey: string
1870
- keyDeriver: KeyDeriver
1872
+ keyDeriver: KeyDeriverApi
1871
1873
  chain: sdk.Chain
1872
1874
  storage: WalletStorageManager
1873
1875
  services: Services