@bsv/sdk 1.3.9 → 1.3.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 (38) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/auth/Peer.js.map +1 -1
  3. package/dist/cjs/src/auth/utils/createNonce.js +9 -3
  4. package/dist/cjs/src/auth/utils/createNonce.js.map +1 -1
  5. package/dist/cjs/src/auth/utils/verifyNonce.js +3 -2
  6. package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -1
  7. package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
  8. package/dist/cjs/src/wallet/ProtoWallet.js.map +1 -1
  9. package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
  10. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  11. package/dist/esm/src/auth/Peer.js.map +1 -1
  12. package/dist/esm/src/auth/utils/createNonce.js +9 -3
  13. package/dist/esm/src/auth/utils/createNonce.js.map +1 -1
  14. package/dist/esm/src/auth/utils/verifyNonce.js +3 -2
  15. package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -1
  16. package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
  17. package/dist/esm/src/wallet/ProtoWallet.js.map +1 -1
  18. package/dist/esm/src/wallet/WalletClient.js.map +1 -1
  19. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  20. package/dist/types/src/auth/Peer.d.ts.map +1 -1
  21. package/dist/types/src/auth/utils/createNonce.d.ts +4 -3
  22. package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -1
  23. package/dist/types/src/auth/utils/verifyNonce.d.ts +3 -2
  24. package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -1
  25. package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts.map +1 -1
  26. package/dist/types/src/wallet/ProtoWallet.d.ts.map +1 -1
  27. package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
  28. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  29. package/dist/umd/bundle.js +1 -1
  30. package/docs/auth.md +12 -5
  31. package/package.json +1 -1
  32. package/src/auth/Peer.ts +21 -21
  33. package/src/auth/utils/__tests/cryptononce.test.ts +42 -7
  34. package/src/auth/utils/createNonce.ts +10 -4
  35. package/src/auth/utils/verifyNonce.ts +4 -3
  36. package/src/overlay-tools/OverlayAdminTokenTemplate.ts +4 -4
  37. package/src/wallet/ProtoWallet.ts +10 -10
  38. package/src/wallet/WalletClient.ts +30 -30
@@ -13,7 +13,7 @@ const MAX_XDM_RESPONSE_WAIT = 200
13
13
  export default class WalletClient implements WalletInterface {
14
14
  public substrate: 'auto' | WalletInterface
15
15
  originator?: OriginatorDomainNameStringUnder250Bytes
16
- constructor(substrate: 'auto' | 'Cicada' | 'XDM' | 'window.CWI' | 'json-api' | WalletInterface = 'auto', originator?: OriginatorDomainNameStringUnder250Bytes) {
16
+ constructor (substrate: 'auto' | 'Cicada' | 'XDM' | 'window.CWI' | 'json-api' | WalletInterface = 'auto', originator?: OriginatorDomainNameStringUnder250Bytes) {
17
17
  if (substrate === 'Cicada') substrate = new WalletWireTransceiver(new HTTPWalletWire(originator))
18
18
  if (substrate === 'window.CWI') substrate = new WindowCWISubstrate()
19
19
  if (substrate === 'XDM') substrate = new XDMSubstrate()
@@ -22,7 +22,7 @@ export default class WalletClient implements WalletInterface {
22
22
  this.originator = originator
23
23
  }
24
24
 
25
- async connectToSubstrate() {
25
+ async connectToSubstrate () {
26
26
  if (typeof this.substrate === 'object') {
27
27
  return // substrate is already connected
28
28
  }
@@ -68,141 +68,141 @@ export default class WalletClient implements WalletInterface {
68
68
  }
69
69
  }
70
70
 
71
- async createAction(args: CreateActionArgs): Promise<CreateActionResult> {
71
+ async createAction (args: CreateActionArgs): Promise<CreateActionResult> {
72
72
  await this.connectToSubstrate()
73
73
  return await (this.substrate as WalletInterface).createAction(args, this.originator)
74
74
  }
75
75
 
76
- async signAction(args: SignActionArgs): Promise<SignActionResult> {
76
+ async signAction (args: SignActionArgs): Promise<SignActionResult> {
77
77
  await this.connectToSubstrate()
78
78
  return await (this.substrate as WalletInterface).signAction(args, this.originator)
79
79
  }
80
80
 
81
- async abortAction(args: { reference: Base64String }): Promise<{ aborted: true }> {
81
+ async abortAction (args: { reference: Base64String }): Promise<{ aborted: true }> {
82
82
  await this.connectToSubstrate()
83
83
  return await (this.substrate as WalletInterface).abortAction(args, this.originator)
84
84
  }
85
85
 
86
- async listActions(args: ListActionsArgs): Promise<ListActionsResult> {
86
+ async listActions (args: ListActionsArgs): Promise<ListActionsResult> {
87
87
  await this.connectToSubstrate()
88
88
  return await (this.substrate as WalletInterface).listActions(args, this.originator)
89
89
  }
90
90
 
91
- async internalizeAction(args: InternalizeActionArgs): Promise<{ accepted: true }> {
91
+ async internalizeAction (args: InternalizeActionArgs): Promise<{ accepted: true }> {
92
92
  await this.connectToSubstrate()
93
93
  return await (this.substrate as WalletInterface).internalizeAction(args, this.originator)
94
94
  }
95
95
 
96
- async listOutputs(args: ListOutputsArgs): Promise<ListOutputsResult> {
96
+ async listOutputs (args: ListOutputsArgs): Promise<ListOutputsResult> {
97
97
  await this.connectToSubstrate()
98
98
  return await (this.substrate as WalletInterface).listOutputs(args, this.originator)
99
99
  }
100
100
 
101
- async relinquishOutput(args: { basket: BasketStringUnder300Bytes, output: OutpointString }): Promise<{ relinquished: true }> {
101
+ async relinquishOutput (args: { basket: BasketStringUnder300Bytes, output: OutpointString }): Promise<{ relinquished: true }> {
102
102
  await this.connectToSubstrate()
103
103
  return await (this.substrate as WalletInterface).relinquishOutput(args, this.originator)
104
104
  }
105
105
 
106
- async getPublicKey(args: { identityKey?: true, protocolID?: [SecurityLevel, ProtocolString5To400Bytes], keyID?: KeyIDStringUnder800Bytes, privileged?: BooleanDefaultFalse, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', forSelf?: BooleanDefaultFalse }): Promise<{ publicKey: PubKeyHex }> {
106
+ async getPublicKey (args: { identityKey?: true, protocolID?: [SecurityLevel, ProtocolString5To400Bytes], keyID?: KeyIDStringUnder800Bytes, privileged?: BooleanDefaultFalse, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', forSelf?: BooleanDefaultFalse }): Promise<{ publicKey: PubKeyHex }> {
107
107
  await this.connectToSubstrate()
108
108
  return await (this.substrate as WalletInterface).getPublicKey(args, this.originator)
109
109
  }
110
110
 
111
- async revealCounterpartyKeyLinkage(args: { counterparty: PubKeyHex, verifier: PubKeyHex, privilegedReason?: DescriptionString5to50Bytes, privileged?: BooleanDefaultFalse }): Promise<{ prover: PubKeyHex, verifier: PubKeyHex, counterparty: PubKeyHex, revelationTime: ISOTimestampString, encryptedLinkage: Byte[], encryptedLinkageProof: Byte[] }> {
111
+ async revealCounterpartyKeyLinkage (args: { counterparty: PubKeyHex, verifier: PubKeyHex, privilegedReason?: DescriptionString5to50Bytes, privileged?: BooleanDefaultFalse }): Promise<{ prover: PubKeyHex, verifier: PubKeyHex, counterparty: PubKeyHex, revelationTime: ISOTimestampString, encryptedLinkage: Byte[], encryptedLinkageProof: Byte[] }> {
112
112
  await this.connectToSubstrate()
113
113
  return await (this.substrate as WalletInterface).revealCounterpartyKeyLinkage(args, this.originator)
114
114
  }
115
115
 
116
- async revealSpecificKeyLinkage(args: { counterparty: PubKeyHex, verifier: PubKeyHex, protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, privileged?: BooleanDefaultFalse }): Promise<{ prover: PubKeyHex, verifier: PubKeyHex, counterparty: PubKeyHex, protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, encryptedLinkage: Byte[], encryptedLinkageProof: Byte[], proofType: Byte }> {
116
+ async revealSpecificKeyLinkage (args: { counterparty: PubKeyHex, verifier: PubKeyHex, protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, privileged?: BooleanDefaultFalse }): Promise<{ prover: PubKeyHex, verifier: PubKeyHex, counterparty: PubKeyHex, protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, encryptedLinkage: Byte[], encryptedLinkageProof: Byte[], proofType: Byte }> {
117
117
  await this.connectToSubstrate()
118
118
  return await (this.substrate as WalletInterface).revealSpecificKeyLinkage(args, this.originator)
119
119
  }
120
120
 
121
- async encrypt(args: { plaintext: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ ciphertext: Byte[] }> {
121
+ async encrypt (args: { plaintext: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ ciphertext: Byte[] }> {
122
122
  await this.connectToSubstrate()
123
123
  return await (this.substrate as WalletInterface).encrypt(args, this.originator)
124
124
  }
125
125
 
126
- async decrypt(args: { ciphertext: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ plaintext: Byte[] }> {
126
+ async decrypt (args: { ciphertext: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ plaintext: Byte[] }> {
127
127
  return await (this.substrate as WalletInterface).decrypt(args, this.originator)
128
128
  }
129
129
 
130
- async createHmac(args: { data: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ hmac: Byte[] }> {
130
+ async createHmac (args: { data: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ hmac: Byte[] }> {
131
131
  await this.connectToSubstrate()
132
132
  return await (this.substrate as WalletInterface).createHmac(args, this.originator)
133
133
  }
134
134
 
135
- async verifyHmac(args: { data: Byte[], hmac: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ valid: true }> {
135
+ async verifyHmac (args: { data: Byte[], hmac: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ valid: true }> {
136
136
  await this.connectToSubstrate()
137
137
  return await (this.substrate as WalletInterface).verifyHmac(args, this.originator)
138
138
  }
139
139
 
140
- async createSignature(args: { data?: Byte[], hashToDirectlySign?: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ signature: Byte[] }> {
140
+ async createSignature (args: { data?: Byte[], hashToDirectlySign?: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', privileged?: BooleanDefaultFalse }): Promise<{ signature: Byte[] }> {
141
141
  await this.connectToSubstrate()
142
142
  return await (this.substrate as WalletInterface).createSignature(args, this.originator)
143
143
  }
144
144
 
145
- async verifySignature(args: { data?: Byte[], hashToDirectlyVerify?: Byte[], signature: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', forSelf?: BooleanDefaultFalse, privileged?: BooleanDefaultFalse }): Promise<{ valid: true }> {
145
+ async verifySignature (args: { data?: Byte[], hashToDirectlyVerify?: Byte[], signature: Byte[], protocolID: [SecurityLevel, ProtocolString5To400Bytes], keyID: KeyIDStringUnder800Bytes, privilegedReason?: DescriptionString5to50Bytes, counterparty?: PubKeyHex | 'self' | 'anyone', forSelf?: BooleanDefaultFalse, privileged?: BooleanDefaultFalse }): Promise<{ valid: true }> {
146
146
  await this.connectToSubstrate()
147
147
  return await (this.substrate as WalletInterface).verifySignature(args, this.originator)
148
148
  }
149
149
 
150
- async acquireCertificate(args: AcquireCertificateArgs): Promise<AcquireCertificateResult> {
150
+ async acquireCertificate (args: AcquireCertificateArgs): Promise<AcquireCertificateResult> {
151
151
  await this.connectToSubstrate()
152
152
  return await (this.substrate as WalletInterface).acquireCertificate(args, this.originator)
153
153
  }
154
154
 
155
- async listCertificates(args: { certifiers: PubKeyHex[], types: Base64String[], limit?: PositiveIntegerDefault10Max10000, offset?: PositiveIntegerOrZero, privileged?: BooleanDefaultFalse, privilegedReason?: DescriptionString5to50Bytes }): Promise<ListCertificatesResult> {
155
+ async listCertificates (args: { certifiers: PubKeyHex[], types: Base64String[], limit?: PositiveIntegerDefault10Max10000, offset?: PositiveIntegerOrZero, privileged?: BooleanDefaultFalse, privilegedReason?: DescriptionString5to50Bytes }): Promise<ListCertificatesResult> {
156
156
  await this.connectToSubstrate()
157
157
  return await (this.substrate as WalletInterface).listCertificates(args, this.originator)
158
158
  }
159
159
 
160
- async proveCertificate(args: ProveCertificateArgs): Promise<ProveCertificateResult> {
160
+ async proveCertificate (args: ProveCertificateArgs): Promise<ProveCertificateResult> {
161
161
  await this.connectToSubstrate()
162
162
  return await (this.substrate as WalletInterface).proveCertificate(args, this.originator)
163
163
  }
164
164
 
165
- async relinquishCertificate(args: { type: Base64String, serialNumber: Base64String, certifier: PubKeyHex }): Promise<{ relinquished: true }> {
165
+ async relinquishCertificate (args: { type: Base64String, serialNumber: Base64String, certifier: PubKeyHex }): Promise<{ relinquished: true }> {
166
166
  await this.connectToSubstrate()
167
167
  return await (this.substrate as WalletInterface).relinquishCertificate(args, this.originator)
168
168
  }
169
169
 
170
- async discoverByIdentityKey(args: { identityKey: PubKeyHex, limit?: PositiveIntegerDefault10Max10000, offset?: PositiveIntegerOrZero }): Promise<DiscoverCertificatesResult> {
170
+ async discoverByIdentityKey (args: { identityKey: PubKeyHex, limit?: PositiveIntegerDefault10Max10000, offset?: PositiveIntegerOrZero }): Promise<DiscoverCertificatesResult> {
171
171
  await this.connectToSubstrate()
172
172
  return await (this.substrate as WalletInterface).discoverByIdentityKey(args, this.originator)
173
173
  }
174
174
 
175
- async discoverByAttributes(args: { attributes: Record<CertificateFieldNameUnder50Bytes, string>, limit?: PositiveIntegerDefault10Max10000, offset?: PositiveIntegerOrZero }): Promise<DiscoverCertificatesResult> {
175
+ async discoverByAttributes (args: { attributes: Record<CertificateFieldNameUnder50Bytes, string>, limit?: PositiveIntegerDefault10Max10000, offset?: PositiveIntegerOrZero }): Promise<DiscoverCertificatesResult> {
176
176
  await this.connectToSubstrate()
177
177
  return await (this.substrate as WalletInterface).discoverByAttributes(args, this.originator)
178
178
  }
179
179
 
180
- async isAuthenticated(args: {} = {}): Promise<AuthenticatedResult> {
180
+ async isAuthenticated (args: {} = {}): Promise<AuthenticatedResult> {
181
181
  await this.connectToSubstrate()
182
182
  return await (this.substrate as WalletInterface).isAuthenticated(args, this.originator)
183
183
  }
184
184
 
185
- async waitForAuthentication(args: {} = {}): Promise<{ authenticated: true }> {
185
+ async waitForAuthentication (args: {} = {}): Promise<{ authenticated: true }> {
186
186
  await this.connectToSubstrate()
187
187
  return await (this.substrate as WalletInterface).waitForAuthentication(args, this.originator)
188
188
  }
189
189
 
190
- async getHeight(args: {} = {}): Promise<{ height: PositiveInteger }> {
190
+ async getHeight (args: {} = {}): Promise<{ height: PositiveInteger }> {
191
191
  await this.connectToSubstrate()
192
192
  return await (this.substrate as WalletInterface).getHeight(args, this.originator)
193
193
  }
194
194
 
195
- async getHeaderForHeight(args: { height: PositiveInteger }): Promise<{ header: HexString }> {
195
+ async getHeaderForHeight (args: { height: PositiveInteger }): Promise<{ header: HexString }> {
196
196
  await this.connectToSubstrate()
197
197
  return await (this.substrate as WalletInterface).getHeaderForHeight(args, this.originator)
198
198
  }
199
199
 
200
- async getNetwork(args: {} = {}): Promise<{ network: 'mainnet' | 'testnet' }> {
200
+ async getNetwork (args: {} = {}): Promise<{ network: 'mainnet' | 'testnet' }> {
201
201
  await this.connectToSubstrate()
202
202
  return await (this.substrate as WalletInterface).getNetwork(args, this.originator)
203
203
  }
204
204
 
205
- async getVersion(args: {} = {}): Promise<{ version: VersionString7To30Bytes }> {
205
+ async getVersion (args: {} = {}): Promise<{ version: VersionString7To30Bytes }> {
206
206
  await this.connectToSubstrate()
207
207
  return await (this.substrate as WalletInterface).getVersion(args, this.originator)
208
208
  }