@bsv/message-box-client 1.3.0 → 1.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/message-box-client",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -75,6 +75,6 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@bsv/authsocket-client": "^1.0.12",
78
- "@bsv/sdk": "^1.7.6"
78
+ "@bsv/sdk": "^1.8.2"
79
79
  }
80
80
  }
@@ -39,7 +39,7 @@ import {
39
39
  InternalizeOutput,
40
40
  Random,
41
41
  OriginatorDomainNameStringUnder250Bytes
42
-
42
+
43
43
  } from '@bsv/sdk'
44
44
  import { AuthSocketClient } from '@bsv/authsocket-client'
45
45
  import * as Logger from './Utils/logger.js'
@@ -315,7 +315,7 @@ export class MessageBoxClient {
315
315
  if (typeof targetHost !== 'string' || targetHost.trim() === '') {
316
316
  throw new Error('Cannot initialize WebSocket: No valid host provided')
317
317
  }
318
- this.socket = AuthSocketClient(targetHost, { wallet: this.walletClient, originator: this.originator}, )
318
+ this.socket = AuthSocketClient(targetHost, { wallet: this.walletClient, originator: this.originator })
319
319
 
320
320
  let identitySent = false
321
321
  let authenticated = false
@@ -410,7 +410,7 @@ export class MessageBoxClient {
410
410
  */
411
411
  async queryAdvertisements (
412
412
  identityKey?: string,
413
- host?: string,
413
+ host?: string
414
414
  ): Promise<AdvertisementToken[]> {
415
415
  const hosts: AdvertisementToken[] = []
416
416
  try {
@@ -639,7 +639,7 @@ export class MessageBoxClient {
639
639
  body,
640
640
  messageId,
641
641
  skipEncryption,
642
- checkPermissions,
642
+ checkPermissions
643
643
  }: SendMessageParams, overrideHost?: string): Promise<SendMessageResponse> {
644
644
  if (recipient == null || recipient.trim() === '') {
645
645
  throw new Error('[MB CLIENT ERROR] Recipient identity key is required')
@@ -861,7 +861,7 @@ export class MessageBoxClient {
861
861
  */
862
862
  async sendMessage (
863
863
  message: SendMessageParams,
864
- overrideHost?: string,
864
+ overrideHost?: string
865
865
  ): Promise<SendMessageResponse> {
866
866
  await this.assertInitialized()
867
867
  if (message.recipient == null || message.recipient.trim() === '') {
@@ -1219,7 +1219,7 @@ export class MessageBoxClient {
1219
1219
  if (hosts.length === 0) {
1220
1220
  const advertisedHosts = await this.queryAdvertisements(
1221
1221
  await this.getIdentityKey(),
1222
- undefined,
1222
+ undefined
1223
1223
  )
1224
1224
  hosts = Array.from(new Set([this.host, ...advertisedHosts.map(h => h.host)]))
1225
1225
  }
@@ -2157,7 +2157,7 @@ export class MessageBoxClient {
2157
2157
  private async createMessagePayment (
2158
2158
  recipient: string,
2159
2159
  quote: MessageBoxQuote,
2160
- description: string = 'MessageBox delivery payment',
2160
+ description: string = 'MessageBox delivery payment'
2161
2161
  ): Promise<Payment> {
2162
2162
  if (quote.recipientFee <= 0 && quote.deliveryFee <= 0) {
2163
2163
  throw new Error('No payment required')
@@ -87,7 +87,7 @@ export class PeerPayClient extends MessageBoxClient {
87
87
 
88
88
  private get authFetchInstance (): AuthFetch {
89
89
  if (this._authFetchInstance === null || this._authFetchInstance === undefined) {
90
- this._authFetchInstance = new AuthFetch(this.peerPayWalletClient, undefined, undefined, this.originator)
90
+ this._authFetchInstance = new AuthFetch(this.peerPayWalletClient, undefined, undefined, this.originator)
91
91
  }
92
92
  return this._authFetchInstance
93
93
  }
@@ -136,6 +136,7 @@ export class PeerPayClient extends MessageBoxClient {
136
136
  // Create the payment action
137
137
  const paymentAction = await this.peerPayWalletClient.createAction({
138
138
  description: 'PeerPay payment',
139
+ labels: ['peerpay'],
139
140
  outputs: [{
140
141
  satoshis: payment.amount,
141
142
  lockingScript,
@@ -217,7 +218,7 @@ export class PeerPayClient extends MessageBoxClient {
217
218
  await this.sendLiveMessage({
218
219
  recipient: payment.recipient,
219
220
  messageBox: STANDARD_PAYMENT_MESSAGEBOX,
220
- body: JSON.stringify(paymentToken),
221
+ body: JSON.stringify(paymentToken)
221
222
  }, overrideHost)
222
223
  } catch (err) {
223
224
  Logger.warn('[PP CLIENT] sendLiveMessage failed, falling back to HTTP:', err)
@@ -226,7 +227,7 @@ export class PeerPayClient extends MessageBoxClient {
226
227
  await this.sendMessage({
227
228
  recipient: payment.recipient,
228
229
  messageBox: STANDARD_PAYMENT_MESSAGEBOX,
229
- body: JSON.stringify(paymentToken),
230
+ body: JSON.stringify(paymentToken)
230
231
  }, overrideHost)
231
232
  }
232
233
  }
@@ -245,14 +246,14 @@ export class PeerPayClient extends MessageBoxClient {
245
246
  */
246
247
  async listenForLivePayments ({
247
248
  onPayment,
248
- overrideHost,
249
+ overrideHost
249
250
  }: {
250
251
  onPayment: (payment: IncomingPayment) => void
251
252
  overrideHost?: string
252
253
  }): Promise<void> {
253
254
  await this.listenForLiveMessages({
254
255
  messageBox: STANDARD_PAYMENT_MESSAGEBOX,
255
- overrideHost,
256
+ overrideHost,
256
257
 
257
258
  // Convert PeerMessage → IncomingPayment before calling onPayment
258
259
  onMessage: (message: PeerMessage) => {
@@ -294,13 +295,14 @@ export class PeerPayClient extends MessageBoxClient {
294
295
  outputIndex: STANDARD_PAYMENT_OUTPUT_INDEX,
295
296
  protocol: 'wallet payment'
296
297
  }],
298
+ labels: ['peerpay'],
297
299
  description: 'PeerPay Payment'
298
300
  }, this.originator)
299
301
 
300
302
  Logger.log(`[PP CLIENT] Payment internalized successfully: ${JSON.stringify(paymentResult, null, 2)}`)
301
303
  Logger.log(`[PP CLIENT] Acknowledging payment with messageId: ${payment.messageId}`)
302
304
 
303
- await this.acknowledgeMessage({ messageIds: [payment.messageId]})
305
+ await this.acknowledgeMessage({ messageIds: [payment.messageId] })
304
306
 
305
307
  return { payment, paymentResult }
306
308
  } catch (error) {
@@ -381,7 +383,7 @@ export class PeerPayClient extends MessageBoxClient {
381
383
  * @returns {Promise<IncomingPayment[]>} Resolves with an array of pending payments.
382
384
  */
383
385
  async listIncomingPayments (overrideHost?: string): Promise<IncomingPayment[]> {
384
- const messages = await this.listMessages({ messageBox: STANDARD_PAYMENT_MESSAGEBOX, host: overrideHost})
386
+ const messages = await this.listMessages({ messageBox: STANDARD_PAYMENT_MESSAGEBOX, host: overrideHost })
385
387
  return messages.map((msg: any) => {
386
388
  const parsedToken = safeParse<PaymentToken>(msg.body)
387
389