@bsv/wallet-toolbox 1.5.11 → 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.
- package/docs/client.md +9 -9
- package/docs/setup.md +8 -8
- package/docs/wallet.md +9 -9
- package/mobile/out/src/SetupClient.d.ts +2 -2
- package/mobile/out/src/SetupClient.d.ts.map +1 -1
- package/mobile/out/src/SetupClient.js +2 -2
- package/mobile/out/src/SetupClient.js.map +1 -1
- package/mobile/out/src/SetupWallet.d.ts +2 -2
- package/mobile/out/src/SetupWallet.d.ts.map +1 -1
- package/mobile/out/src/Wallet.d.ts +3 -3
- package/mobile/out/src/Wallet.d.ts.map +1 -1
- package/mobile/out/src/Wallet.js.map +1 -1
- package/mobile/out/src/signer/WalletSigner.d.ts +3 -3
- package/mobile/out/src/signer/WalletSigner.d.ts.map +1 -1
- package/mobile/out/src/signer/WalletSigner.js.map +1 -1
- package/mobile/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/mobile/out/src/utility/ScriptTemplateBRC29.js +1 -1
- package/mobile/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/mobile/package-lock.json +6 -7
- package/mobile/package.json +2 -2
- package/out/src/Setup.d.ts +2 -2
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +2 -2
- package/out/src/Setup.js.map +1 -1
- package/out/src/SetupClient.d.ts +2 -2
- package/out/src/SetupClient.d.ts.map +1 -1
- package/out/src/SetupClient.js +2 -2
- package/out/src/SetupClient.js.map +1 -1
- package/out/src/SetupWallet.d.ts +2 -2
- package/out/src/SetupWallet.d.ts.map +1 -1
- package/out/src/Wallet.d.ts +3 -3
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js.map +1 -1
- package/out/src/__tests/WalletPermissionsManager.proxying.test.js +1 -1
- package/out/src/__tests/WalletPermissionsManager.proxying.test.js.map +1 -1
- package/out/src/signer/WalletSigner.d.ts +3 -3
- package/out/src/signer/WalletSigner.d.ts.map +1 -1
- package/out/src/signer/WalletSigner.js.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.js +1 -1
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +4 -4
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +3 -3
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Setup.ts +5 -3
- package/src/SetupClient.ts +5 -3
- package/src/SetupWallet.ts +2 -2
- package/src/Wallet.ts +4 -3
- package/src/__tests/WalletPermissionsManager.proxying.test.ts +1 -1
- package/src/signer/WalletSigner.ts +3 -3
- package/src/utility/ScriptTemplateBRC29.ts +3 -2
- package/test/Wallet/live/walletLive.man.test.ts +2 -1
- 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.
|
|
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.
|
|
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
|
|
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
|
|
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:
|
|
517
|
+
keyDeriver: KeyDeriverApi
|
|
516
518
|
chain: sdk.Chain
|
|
517
519
|
storage: WalletStorageManager
|
|
518
520
|
services: Services
|
package/src/SetupClient.ts
CHANGED
|
@@ -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
|
|
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
|
|
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:
|
|
295
|
+
keyDeriver: KeyDeriverApi
|
|
294
296
|
chain: sdk.Chain
|
|
295
297
|
storage: WalletStorageManager
|
|
296
298
|
services: Services
|
package/src/SetupWallet.ts
CHANGED
|
@@ -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:
|
|
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:
|
|
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:
|
|
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')
|
|
@@ -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:
|
|
9
|
+
keyDeriver: KeyDeriverApi
|
|
10
10
|
storage: WalletStorageManager
|
|
11
11
|
|
|
12
|
-
constructor(chain: sdk.Chain, keyDeriver:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
1872
|
+
keyDeriver: KeyDeriverApi
|
|
1871
1873
|
chain: sdk.Chain
|
|
1872
1874
|
storage: WalletStorageManager
|
|
1873
1875
|
services: Services
|