@bsv/sdk 2.0.11 → 2.0.13
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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/auth/clients/__tests__/AuthFetch.additional.test.js +827 -0
- package/dist/cjs/src/auth/clients/__tests__/AuthFetch.additional.test.js.map +1 -0
- package/dist/cjs/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.js +654 -0
- package/dist/cjs/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.js.map +1 -0
- package/dist/cjs/src/overlay-tools/HostReputationTracker.js +21 -13
- package/dist/cjs/src/overlay-tools/HostReputationTracker.js.map +1 -1
- package/dist/cjs/src/primitives/PrivateKey.js +3 -3
- package/dist/cjs/src/primitives/PrivateKey.js.map +1 -1
- package/dist/cjs/src/script/Spend.js +17 -9
- package/dist/cjs/src/script/Spend.js.map +1 -1
- package/dist/cjs/src/storage/StorageDownloader.js +6 -6
- package/dist/cjs/src/storage/StorageDownloader.js.map +1 -1
- package/dist/cjs/src/storage/StorageUtils.js +1 -1
- package/dist/cjs/src/storage/StorageUtils.js.map +1 -1
- package/dist/cjs/src/transaction/MerklePath.js +168 -27
- package/dist/cjs/src/transaction/MerklePath.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/auth/clients/__tests__/AuthFetch.additional.test.js +825 -0
- package/dist/esm/src/auth/clients/__tests__/AuthFetch.additional.test.js.map +1 -0
- package/dist/esm/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.js +619 -0
- package/dist/esm/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.js.map +1 -0
- package/dist/esm/src/overlay-tools/HostReputationTracker.js +21 -13
- package/dist/esm/src/overlay-tools/HostReputationTracker.js.map +1 -1
- package/dist/esm/src/primitives/PrivateKey.js +3 -3
- package/dist/esm/src/primitives/PrivateKey.js.map +1 -1
- package/dist/esm/src/script/Spend.js +17 -9
- package/dist/esm/src/script/Spend.js.map +1 -1
- package/dist/esm/src/storage/StorageDownloader.js +6 -6
- package/dist/esm/src/storage/StorageDownloader.js.map +1 -1
- package/dist/esm/src/storage/StorageUtils.js +1 -1
- package/dist/esm/src/storage/StorageUtils.js.map +1 -1
- package/dist/esm/src/transaction/MerklePath.js +168 -27
- package/dist/esm/src/transaction/MerklePath.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/auth/clients/__tests__/AuthFetch.additional.test.d.ts +21 -0
- package/dist/types/src/auth/clients/__tests__/AuthFetch.additional.test.d.ts.map +1 -0
- package/dist/types/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.d.ts +2 -0
- package/dist/types/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.d.ts.map +1 -0
- package/dist/types/src/overlay-tools/HostReputationTracker.d.ts.map +1 -1
- package/dist/types/src/script/Spend.d.ts.map +1 -1
- package/dist/types/src/transaction/MerklePath.d.ts +27 -0
- package/dist/types/src/transaction/MerklePath.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +3 -3
- package/dist/umd/bundle.js.map +1 -1
- package/docs/reference/storage.md +1 -1
- package/docs/reference/transaction.md +40 -0
- package/package.json +1 -1
- package/src/auth/clients/__tests__/AuthFetch.additional.test.ts +1131 -0
- package/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.ts +770 -0
- package/src/auth/utils/__tests/validateCertificates.test.ts +12 -9
- package/src/compat/__tests/Mnemonic.additional.test.ts +64 -0
- package/src/identity/__tests/IdentityClient.additional.test.ts +767 -0
- package/src/kvstore/__tests/LocalKVStore.additional.test.ts +611 -0
- package/src/kvstore/__tests/LocalKVStore.test.ts +4 -6
- package/src/kvstore/__tests/kvStoreInterpreter.test.ts +327 -0
- package/src/overlay-tools/HostReputationTracker.ts +17 -14
- package/src/overlay-tools/__tests/HostReputationTracker.additional.test.ts +561 -0
- package/src/overlay-tools/__tests/LookupResolver.additional.test.ts +612 -0
- package/src/overlay-tools/__tests/withDoubleSpendRetry.test.ts +278 -0
- package/src/primitives/PrivateKey.ts +3 -3
- package/src/primitives/__tests/BigNumber.additional.test.ts +79 -0
- package/src/primitives/__tests/Curve.additional.test.ts +208 -0
- package/src/primitives/__tests/ECDSA.additional.test.ts +122 -0
- package/src/primitives/__tests/Hash.additional.test.ts +59 -0
- package/src/primitives/__tests/JacobianPoint.test.ts +308 -0
- package/src/primitives/__tests/Point.additional.test.ts +503 -0
- package/src/primitives/__tests/PublicKey.additional.test.ts +383 -0
- package/src/primitives/__tests/Random.additional.test.ts +262 -0
- package/src/primitives/__tests/Signature.test.ts +333 -0
- package/src/primitives/__tests/TransactionSignature.additional.test.ts +241 -0
- package/src/registry/__tests/RegistryClient.additional.test.ts +750 -0
- package/src/remittance/__tests/BasicBRC29.additional.test.ts +657 -0
- package/src/remittance/__tests/RemittanceManager.additional.test.ts +1272 -0
- package/src/script/Spend.ts +19 -11
- package/src/script/__tests/LockingUnlockingScript.test.ts +79 -0
- package/src/script/__tests/Script.additional.test.ts +100 -0
- package/src/script/__tests/ScriptEvaluationError.test.ts +98 -0
- package/src/script/__tests/Spend.additional.test.ts +837 -0
- package/src/script/templates/__tests/RPuzzle.test.ts +134 -0
- package/src/storage/StorageDownloader.ts +6 -6
- package/src/storage/StorageUtils.ts +1 -1
- package/src/transaction/MerklePath.ts +196 -36
- package/src/transaction/__tests/BeefParty.additional.test.ts +22 -0
- package/src/transaction/__tests/Broadcaster.test.ts +159 -0
- package/src/transaction/__tests/MerklePath.bench.test.ts +105 -0
- package/src/transaction/__tests/MerklePath.test.ts +232 -21
- package/src/transaction/__tests/Transaction.additional.test.ts +225 -0
- package/src/transaction/broadcasters/__tests/ARC.additional.test.ts +585 -0
- package/src/transaction/broadcasters/__tests/Teranode.test.ts +349 -0
- package/src/transaction/chaintrackers/__tests/BlockHeadersService.test.ts +253 -0
- package/src/transaction/chaintrackers/__tests/DefaultChainTracker.test.ts +44 -0
- package/src/transaction/chaintrackers/__tests/WhatsOnChain.additional.test.ts +193 -0
- package/src/transaction/fee-models/__tests/SatoshisPerKilobyte.test.ts +262 -0
- package/src/transaction/http/__tests/BinaryFetchClient.test.ts +212 -0
- package/src/transaction/http/__tests/DefaultHttpClient.additional.test.ts +192 -0
- package/src/transaction/http/__tests/DefaultHttpClient.test.ts +71 -0
- package/src/wallet/__tests/ProtoWallet.additional.test.ts +134 -0
- package/src/wallet/__tests/WERR.test.ts +212 -0
- package/src/wallet/__tests/WalletClient.additional.test.ts +699 -0
- package/src/wallet/__tests/WalletClient.substrate.test.ts +759 -0
- package/src/wallet/__tests/WalletError.test.ts +290 -0
- package/src/wallet/__tests/validationHelpers.test.ts +1218 -0
- package/src/wallet/substrates/__tests/HTTPWalletJSON.test.ts +496 -0
- package/src/wallet/substrates/__tests/HTTPWalletWire.test.ts +273 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { validateCertificates } from '../../../auth/utils/validateCertificates'
|
|
2
2
|
import { VerifiableCertificate } from '../../../auth/certificates/VerifiableCertificate'
|
|
3
|
-
import { ProtoWallet } from '../../../wallet/index'
|
|
3
|
+
import { ProtoWallet, WalletInterface } from '../../../wallet/index'
|
|
4
4
|
import { PrivateKey } from '../../../primitives/index'
|
|
5
|
+
import { AuthMessage } from '../../../auth/types'
|
|
5
6
|
|
|
6
7
|
let mockVerify = jest.fn(async () => await Promise.resolve(true))
|
|
7
8
|
let mockDecryptFields = jest.fn(
|
|
@@ -40,8 +41,8 @@ jest.mock('../../../auth/certificates/VerifiableCertificate', () => {
|
|
|
40
41
|
})
|
|
41
42
|
|
|
42
43
|
describe('validateCertificates', () => {
|
|
43
|
-
let verifierWallet
|
|
44
|
-
let message
|
|
44
|
+
let verifierWallet: WalletInterface
|
|
45
|
+
let message: AuthMessage
|
|
45
46
|
|
|
46
47
|
beforeEach(() => {
|
|
47
48
|
jest.clearAllMocks()
|
|
@@ -53,8 +54,10 @@ describe('validateCertificates', () => {
|
|
|
53
54
|
async () => await Promise.resolve({ field1: 'decryptedValue1' })
|
|
54
55
|
)
|
|
55
56
|
|
|
56
|
-
verifierWallet = new ProtoWallet(new PrivateKey(1))
|
|
57
|
+
verifierWallet = new ProtoWallet(new PrivateKey(1)) as unknown as WalletInterface
|
|
57
58
|
message = {
|
|
59
|
+
version: '1.0',
|
|
60
|
+
messageType: 'certificateResponse',
|
|
58
61
|
identityKey: 'valid_subject',
|
|
59
62
|
certificates: [
|
|
60
63
|
{
|
|
@@ -65,7 +68,7 @@ describe('validateCertificates', () => {
|
|
|
65
68
|
revocationOutpoint: 'outpoint',
|
|
66
69
|
fields: { field1: 'encryptedData1' },
|
|
67
70
|
decryptedFields: {}
|
|
68
|
-
}
|
|
71
|
+
} as any
|
|
69
72
|
]
|
|
70
73
|
}
|
|
71
74
|
})
|
|
@@ -76,9 +79,9 @@ describe('validateCertificates', () => {
|
|
|
76
79
|
).resolves.not.toThrow()
|
|
77
80
|
|
|
78
81
|
expect(VerifiableCertificate).toHaveBeenCalledTimes(
|
|
79
|
-
message.certificates
|
|
82
|
+
message.certificates!.length
|
|
80
83
|
)
|
|
81
|
-
expect(mockVerify).toHaveBeenCalledTimes(message.certificates
|
|
84
|
+
expect(mockVerify).toHaveBeenCalledTimes(message.certificates!.length)
|
|
82
85
|
expect(mockDecryptFields).toHaveBeenCalledWith(verifierWallet, undefined, undefined, undefined)
|
|
83
86
|
})
|
|
84
87
|
|
|
@@ -147,9 +150,9 @@ describe('validateCertificates', () => {
|
|
|
147
150
|
revocationOutpoint: 'outpoint',
|
|
148
151
|
fields: { field1: 'encryptedData1' },
|
|
149
152
|
decryptedFields: {}
|
|
150
|
-
}
|
|
153
|
+
} as any
|
|
151
154
|
|
|
152
|
-
message.certificates
|
|
155
|
+
message.certificates!.push(anotherCertificate)
|
|
153
156
|
|
|
154
157
|
await expect(
|
|
155
158
|
validateCertificates(verifierWallet, message)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Mnemonic from '../Mnemonic'
|
|
2
|
+
|
|
3
|
+
const VALID_MNEMONIC = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
|
|
4
|
+
|
|
5
|
+
describe('Mnemonic – additional coverage', () => {
|
|
6
|
+
describe('fromRandom – default and edge-case bits', () => {
|
|
7
|
+
it('uses 128 bits when bits is undefined', () => {
|
|
8
|
+
const m = new Mnemonic().fromRandom(undefined)
|
|
9
|
+
expect(m.mnemonic.split(' ')).toHaveLength(12) // 128-bit → 12 words
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('uses 128 bits when bits is 0', () => {
|
|
13
|
+
const m = new Mnemonic().fromRandom(0)
|
|
14
|
+
expect(m.mnemonic.split(' ')).toHaveLength(12)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('uses 128 bits when bits is NaN', () => {
|
|
18
|
+
const m = new Mnemonic().fromRandom(NaN)
|
|
19
|
+
expect(m.mnemonic.split(' ')).toHaveLength(12)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('throws when bits is a multiple of 32 but less than 128', () => {
|
|
23
|
+
// 96 is a multiple of 32 but < 128
|
|
24
|
+
expect(() => new Mnemonic().fromRandom(96)).toThrow('bits must be at least 128')
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
describe('toBinary – empty mnemonic and seed', () => {
|
|
29
|
+
it('encodes empty mnemonic as varint 0', () => {
|
|
30
|
+
const m = new Mnemonic('', [])
|
|
31
|
+
const buf = m.toBinary()
|
|
32
|
+
// Both mnemonic and seed are empty → first byte (varint) is 0
|
|
33
|
+
expect(buf[0]).toBe(0)
|
|
34
|
+
expect(buf[1]).toBe(0)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
describe('fromBinary – empty fields', () => {
|
|
39
|
+
it('round-trips an instance with empty mnemonic and seed', () => {
|
|
40
|
+
const original = new Mnemonic('', [])
|
|
41
|
+
const buf = original.toBinary()
|
|
42
|
+
const restored = new Mnemonic().fromBinary(buf)
|
|
43
|
+
expect(restored.mnemonic).toBe('')
|
|
44
|
+
expect(restored.seed).toHaveLength(0)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
describe('mnemonic2Seed', () => {
|
|
49
|
+
it('throws when passphrase is not a string', () => {
|
|
50
|
+
const m = Mnemonic.fromString(VALID_MNEMONIC)
|
|
51
|
+
expect(() => {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
m.mnemonic2Seed(42 as any)
|
|
54
|
+
}).toThrow('passphrase must be a string or undefined')
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
describe('toString', () => {
|
|
59
|
+
it('returns the mnemonic string', () => {
|
|
60
|
+
const m = Mnemonic.fromString(VALID_MNEMONIC)
|
|
61
|
+
expect(m.toString()).toBe(VALID_MNEMONIC)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
})
|