@bsv/sdk 1.2.22 → 1.3.0

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 (26) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/auth/certificates/Certificate.js +4 -4
  3. package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
  4. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +3 -3
  5. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  6. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +3 -3
  7. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  8. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  9. package/dist/esm/src/auth/certificates/Certificate.js +4 -4
  10. package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
  11. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +3 -3
  12. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  13. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +3 -3
  14. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  15. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  16. package/dist/types/src/auth/certificates/Certificate.d.ts +2 -2
  17. package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -1
  18. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  19. package/dist/umd/bundle.js +1 -1
  20. package/docs/auth.md +6 -6
  21. package/package.json +1 -1
  22. package/src/auth/certificates/Certificate.ts +4 -4
  23. package/src/auth/certificates/__tests/Certificate.test.ts +14 -14
  24. package/src/auth/clients/AuthFetch.ts +1 -1
  25. package/src/wallet/substrates/WalletWireProcessor.ts +3 -3
  26. package/src/wallet/substrates/WalletWireTransceiver.ts +3 -3
package/docs/auth.md CHANGED
@@ -214,8 +214,8 @@ export default class Certificate {
214
214
  fields: Record<CertificateFieldNameUnder50Bytes, string>;
215
215
  signature?: HexString;
216
216
  constructor(type: Base64String, serialNumber: Base64String, subject: PubKeyHex, certifier: PubKeyHex, revocationOutpoint: OutpointString, fields: Record<CertificateFieldNameUnder50Bytes, string>, signature?: HexString)
217
- toBin(includeSignature: boolean = true): number[]
218
- static fromBin(bin: number[]): Certificate
217
+ toBinary(includeSignature: boolean = true): number[]
218
+ static fromBinary(bin: number[]): Certificate
219
219
  async verify(): Promise<boolean>
220
220
  async sign(certifier: Wallet): Promise<void>
221
221
  }
@@ -316,12 +316,12 @@ type: Base64String
316
316
  ```
317
317
  See also: [Base64String](#type-base64string)
318
318
 
319
- #### Method fromBin
319
+ #### Method fromBinary
320
320
 
321
321
  Deserializes a certificate from binary format.
322
322
 
323
323
  ```ts
324
- static fromBin(bin: number[]): Certificate
324
+ static fromBinary(bin: number[]): Certificate
325
325
  ```
326
326
  See also: [Certificate](#class-certificate)
327
327
 
@@ -348,12 +348,12 @@ Argument Details
348
348
  + **certifier**
349
349
  + The wallet representing the certifier.
350
350
 
351
- #### Method toBin
351
+ #### Method toBinary
352
352
 
353
353
  Serializes the certificate into binary format, with or without a signature.
354
354
 
355
355
  ```ts
356
- toBin(includeSignature: boolean = true): number[]
356
+ toBinary(includeSignature: boolean = true): number[]
357
357
  ```
358
358
 
359
359
  Returns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/sdk",
3
- "version": "1.2.22",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "BSV Blockchain Software Development Kit",
6
6
  "main": "dist/cjs/mod.js",
@@ -85,7 +85,7 @@ export default class Certificate {
85
85
  * @param {boolean} [includeSignature=true] - Whether to include the signature in the serialization.
86
86
  * @returns {number[]} - The serialized certificate in binary format.
87
87
  */
88
- toBin(includeSignature: boolean = true): number[] {
88
+ toBinary(includeSignature: boolean = true): number[] {
89
89
  const writer = new Utils.Writer()
90
90
 
91
91
  // Write type (Base64String, 32 bytes)
@@ -141,7 +141,7 @@ export default class Certificate {
141
141
  * @param {number[]} bin - The binary data representing the certificate.
142
142
  * @returns {Certificate} - The deserialized Certificate object.
143
143
  */
144
- static fromBin(bin: number[]): Certificate {
144
+ static fromBinary(bin: number[]): Certificate {
145
145
  const reader = new Utils.Reader(bin)
146
146
 
147
147
  // Read type
@@ -210,7 +210,7 @@ export default class Certificate {
210
210
  async verify(): Promise<boolean> {
211
211
  // A verifier can be any wallet capable of verifying signatures
212
212
  const verifier = new ProtoWallet('anyone')
213
- const verificationData = this.toBin(false) // Exclude the signature from the verification data
213
+ const verificationData = this.toBinary(false) // Exclude the signature from the verification data
214
214
 
215
215
  const { valid } = await verifier.verifySignature({
216
216
  signature: Utils.toArray(this.signature, 'hex'),
@@ -229,7 +229,7 @@ export default class Certificate {
229
229
  * @returns {Promise<void>}
230
230
  */
231
231
  async sign(certifier: Wallet): Promise<void> {
232
- const preimage = this.toBin(false) // Exclude the signature when signing
232
+ const preimage = this.toBinary(false) // Exclude the signature when signing
233
233
  const { signature } = await certifier.createSignature({
234
234
  data: preimage,
235
235
  protocolID: [2, 'certificate signature'],
@@ -49,8 +49,8 @@ describe('Certificate', () => {
49
49
  undefined // No signature
50
50
  )
51
51
 
52
- const serialized = certificate.toBin(false) // Exclude signature
53
- const deserializedCertificate = Certificate.fromBin(serialized)
52
+ const serialized = certificate.toBinary(false) // Exclude signature
53
+ const deserializedCertificate = Certificate.fromBinary(serialized)
54
54
 
55
55
  expect(deserializedCertificate.type).toEqual(sampleType)
56
56
  expect(deserializedCertificate.serialNumber).toEqual(sampleSerialNumber)
@@ -76,8 +76,8 @@ describe('Certificate', () => {
76
76
  const certifierWallet = new ProtoWallet(sampleCertifierPrivateKey)
77
77
  await certificate.sign(certifierWallet)
78
78
 
79
- const serialized = certificate.toBin(true) // Include signature
80
- const deserializedCertificate = Certificate.fromBin(serialized)
79
+ const serialized = certificate.toBinary(true) // Include signature
80
+ const deserializedCertificate = Certificate.fromBinary(serialized)
81
81
 
82
82
  expect(deserializedCertificate.type).toEqual(sampleType)
83
83
  expect(deserializedCertificate.serialNumber).toEqual(sampleSerialNumber)
@@ -176,8 +176,8 @@ describe('Certificate', () => {
176
176
  await certificate.sign(certifierWallet)
177
177
 
178
178
  // Serialize and deserialize
179
- const serialized = certificate.toBin(true)
180
- const deserializedCertificate = Certificate.fromBin(serialized)
179
+ const serialized = certificate.toBinary(true)
180
+ const deserializedCertificate = Certificate.fromBinary(serialized)
181
181
 
182
182
  expect(deserializedCertificate.fields).toEqual(sampleFieldsEmpty)
183
183
 
@@ -198,8 +198,8 @@ describe('Certificate', () => {
198
198
  )
199
199
 
200
200
  // Serialize without signature
201
- const serialized = certificate.toBin(false)
202
- const deserializedCertificate = Certificate.fromBin(serialized)
201
+ const serialized = certificate.toBinary(false)
202
+ const deserializedCertificate = Certificate.fromBinary(serialized)
203
203
 
204
204
  expect(deserializedCertificate.signature).toBeUndefined() // Signature should be empty
205
205
  expect(deserializedCertificate.fields).toEqual(sampleFields)
@@ -227,8 +227,8 @@ describe('Certificate', () => {
227
227
  await certificate.sign(certifierWallet)
228
228
 
229
229
  // Serialize and deserialize
230
- const serialized = certificate.toBin(true)
231
- const deserializedCertificate = Certificate.fromBin(serialized)
230
+ const serialized = certificate.toBinary(true)
231
+ const deserializedCertificate = Certificate.fromBinary(serialized)
232
232
 
233
233
  expect(deserializedCertificate.fields).toEqual(fields)
234
234
 
@@ -248,8 +248,8 @@ describe('Certificate', () => {
248
248
  undefined // No signature
249
249
  )
250
250
 
251
- const serialized = certificate.toBin(false)
252
- const deserializedCertificate = Certificate.fromBin(serialized)
251
+ const serialized = certificate.toBinary(false)
252
+ const deserializedCertificate = Certificate.fromBinary(serialized)
253
253
 
254
254
  expect(deserializedCertificate.revocationOutpoint).toEqual(sampleRevocationOutpoint)
255
255
  })
@@ -270,8 +270,8 @@ describe('Certificate', () => {
270
270
  await certificate.sign(certifierWallet)
271
271
 
272
272
  // Serialize and deserialize
273
- const serialized = certificate.toBin(true)
274
- const deserializedCertificate = Certificate.fromBin(serialized)
273
+ const serialized = certificate.toBinary(true)
274
+ const deserializedCertificate = Certificate.fromBinary(serialized)
275
275
 
276
276
  expect(deserializedCertificate.fields).toEqual({})
277
277
 
@@ -4,7 +4,7 @@ import { SimplifiedFetchTransport } from '../transports/SimplifiedFetchTransport
4
4
  import { SessionManager } from '../SessionManager.js'
5
5
  import { RequestedCertificateSet } from '../types.js'
6
6
  import { VerifiableCertificate } from '../certificates/VerifiableCertificate.js'
7
- import { Writer } from 'src/primitives/utils.js'
7
+ import { Writer } from '../../primitives/utils.js'
8
8
 
9
9
  type SimplifiedFetchRequestOptions = {
10
10
  method?: string,
@@ -1571,7 +1571,7 @@ export default class WalletWireProcessor implements WalletWire {
1571
1571
  acquireResult.fields,
1572
1572
  acquireResult.signature
1573
1573
  )
1574
- const certBin = cert.toBin()
1574
+ const certBin = cert.toBinary()
1575
1575
 
1576
1576
  // Return success code and certificate binary
1577
1577
  const responseWriter = new Utils.Writer()
@@ -1651,7 +1651,7 @@ export default class WalletWireProcessor implements WalletWire {
1651
1651
  cert.fields,
1652
1652
  cert.signature
1653
1653
  )
1654
- const certBin = certificate.toBin()
1654
+ const certBin = certificate.toBinary()
1655
1655
 
1656
1656
  // Write certificate binary length and data
1657
1657
  resultWriter.writeVarIntNum(certBin.length)
@@ -1961,7 +1961,7 @@ export default class WalletWireProcessor implements WalletWire {
1961
1961
  cert.fields,
1962
1962
  cert.signaturre
1963
1963
  )
1964
- const certBin = certificate.toBin()
1964
+ const certBin = certificate.toBinary()
1965
1965
 
1966
1966
  // Write certificate binary length and data
1967
1967
  resultWriter.writeVarIntNum(certBin.length)
@@ -1153,7 +1153,7 @@ export default class WalletWireTransceiver implements Wallet {
1153
1153
  }
1154
1154
 
1155
1155
  const result = await this.transmit('acquireCertificate', originator, paramWriter.toArray())
1156
- const cert = Certificate.fromBin(result)
1156
+ const cert = Certificate.fromBinary(result)
1157
1157
  return {
1158
1158
  ...cert,
1159
1159
  signature: cert.signature as string
@@ -1214,7 +1214,7 @@ export default class WalletWireTransceiver implements Wallet {
1214
1214
  for (let i = 0; i < totalCertificates; i++) {
1215
1215
  const certificateLength = resultReader.readVarIntNum()
1216
1216
  const certificateBin = resultReader.read(certificateLength)
1217
- const cert = Certificate.fromBin(certificateBin)
1217
+ const cert = Certificate.fromBinary(certificateBin)
1218
1218
  certificates.push({
1219
1219
  ...cert,
1220
1220
  signature: cert.signature as string
@@ -1328,7 +1328,7 @@ export default class WalletWireTransceiver implements Wallet {
1328
1328
  for (let i = 0; i < totalCertificates; i++) {
1329
1329
  const certBinLen = resultReader.readVarIntNum()
1330
1330
  const certBin = resultReader.read(certBinLen)
1331
- const cert = Certificate.fromBin(certBin)
1331
+ const cert = Certificate.fromBinary(certBin)
1332
1332
  const nameLength = resultReader.readVarIntNum()
1333
1333
  const name = Utils.toUTF8(resultReader.read(nameLength))
1334
1334
  const iconUrlLength = resultReader.readVarIntNum()