@bsv/message-box-client 1.2.8 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/message-box-client",
3
- "version": "1.2.8",
3
+ "version": "1.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -74,7 +74,7 @@
74
74
  "webpack-merge": "^6.0.1"
75
75
  },
76
76
  "dependencies": {
77
- "@bsv/authsocket-client": "^1.0.11",
78
- "@bsv/sdk": "^1.7.5"
77
+ "@bsv/authsocket-client": "^1.0.12",
78
+ "@bsv/sdk": "^1.7.6"
79
79
  }
80
80
  }
@@ -37,7 +37,9 @@ import {
37
37
  WalletInterface,
38
38
  ProtoWallet,
39
39
  InternalizeOutput,
40
- Random
40
+ Random,
41
+ OriginatorDomainNameStringUnder250Bytes
42
+
41
43
  } from '@bsv/sdk'
42
44
  import { AuthSocketClient } from '@bsv/authsocket-client'
43
45
  import * as Logger from './Utils/logger.js'
@@ -91,7 +93,7 @@ export class MessageBoxClient {
91
93
  private readonly lookupResolver: LookupResolver
92
94
  private readonly networkPreset: 'local' | 'mainnet' | 'testnet'
93
95
  private initialized = false
94
-
96
+ protected originator?: OriginatorDomainNameStringUnder250Bytes
95
97
  /**
96
98
  * @constructor
97
99
  * @param {Object} options - Initialization options for the MessageBoxClient.
@@ -131,9 +133,9 @@ export class MessageBoxClient {
131
133
  : DEFAULT_MAINNET_HOST
132
134
 
133
135
  this.host = host?.trim() ?? defaultHost
134
-
136
+ this.originator = originator
135
137
  this.walletClient = walletClient ?? new WalletClient('auto', originator)
136
- this.authFetch = new AuthFetch(this.walletClient)
138
+ this.authFetch = new AuthFetch(this.walletClient, undefined, undefined, originator)
137
139
  this.networkPreset = networkPreset
138
140
 
139
141
  this.lookupResolver = new LookupResolver({
@@ -168,7 +170,7 @@ export class MessageBoxClient {
168
170
  * await client.init()
169
171
  * await client.sendMessage({ recipient, messageBox: 'inbox', body: 'Hello' })
170
172
  */
171
- async init (targetHost: string = this.host, originator?: string): Promise<void> {
173
+ async init (targetHost: string = this.host): Promise<void> {
172
174
  const normalizedHost = targetHost?.trim()
173
175
  if (normalizedHost === '') {
174
176
  throw new Error('Cannot anoint host: No valid host provided')
@@ -183,14 +185,14 @@ export class MessageBoxClient {
183
185
  if (this.initialized) return
184
186
 
185
187
  // 1. Get our identity key
186
- const identityKey = await this.getIdentityKey(originator)
188
+ const identityKey = await this.getIdentityKey()
187
189
  // 2. Check for any matching advertisements for the given host
188
- const [firstAdvertisement] = await this.queryAdvertisements(identityKey, normalizedHost, originator)
190
+ const [firstAdvertisement] = await this.queryAdvertisements(identityKey, normalizedHost)
189
191
  // 3. If none our found, anoint this host
190
192
  if (firstAdvertisement == null || firstAdvertisement?.host?.trim() === '' || firstAdvertisement?.host !== normalizedHost) {
191
193
  Logger.log('[MB CLIENT] Anointing host:', normalizedHost)
192
194
  try {
193
- const { txid } = await this.anointHost(normalizedHost, originator)
195
+ const { txid } = await this.anointHost(normalizedHost)
194
196
  if (txid == null || txid.trim() === '') {
195
197
  throw new Error('Failed to anoint host: No transaction ID returned')
196
198
  }
@@ -238,14 +240,14 @@ export class MessageBoxClient {
238
240
  * Returns the client's identity key, used for signing, encryption, and addressing.
239
241
  * If not already loaded, it will fetch and cache it.
240
242
  */
241
- public async getIdentityKey (originator?: string): Promise<string> {
243
+ public async getIdentityKey (): Promise<string> {
242
244
  if (this.myIdentityKey != null && this.myIdentityKey.trim() !== '') {
243
245
  return this.myIdentityKey
244
246
  }
245
247
 
246
248
  Logger.log('[MB CLIENT] Fetching identity key...')
247
249
  try {
248
- const keyResult = await this.walletClient.getPublicKey({ identityKey: true }, originator)
250
+ const keyResult = await this.walletClient.getPublicKey({ identityKey: true }, this.originator)
249
251
  this.myIdentityKey = keyResult.publicKey
250
252
  Logger.log(`[MB CLIENT] Identity key fetched: ${this.myIdentityKey}`)
251
253
  return this.myIdentityKey
@@ -294,11 +296,11 @@ export class MessageBoxClient {
294
296
  * await mb.initializeConnection()
295
297
  * // WebSocket is now ready for use
296
298
  */
297
- async initializeConnection (originator?: string, overrideHost?: string): Promise<void> {
299
+ async initializeConnection (overrideHost?: string): Promise<void> {
298
300
  Logger.log('[MB CLIENT] initializeConnection() STARTED')
299
301
 
300
302
  if (this.myIdentityKey == null || this.myIdentityKey.trim() === '') {
301
- await this.getIdentityKey(originator)
303
+ await this.getIdentityKey()
302
304
  }
303
305
 
304
306
  if (this.myIdentityKey == null || this.myIdentityKey.trim() === '') {
@@ -313,7 +315,7 @@ export class MessageBoxClient {
313
315
  if (typeof targetHost !== 'string' || targetHost.trim() === '') {
314
316
  throw new Error('Cannot initialize WebSocket: No valid host provided')
315
317
  }
316
- this.socket = AuthSocketClient(targetHost, { wallet: this.walletClient })
318
+ this.socket = AuthSocketClient(targetHost, { wallet: this.walletClient, originator: this.originator}, )
317
319
 
318
320
  let identitySent = false
319
321
  let authenticated = false
@@ -388,8 +390,8 @@ export class MessageBoxClient {
388
390
  * @example
389
391
  * const host = await resolveHostForRecipient('028d...') // → returns either overlay host or this.host
390
392
  */
391
- async resolveHostForRecipient (identityKey: string, originator?: string): Promise<string> {
392
- const advertisementTokens = await this.queryAdvertisements(identityKey, undefined, originator)
393
+ async resolveHostForRecipient (identityKey: string): Promise<string> {
394
+ const advertisementTokens = await this.queryAdvertisements(identityKey, undefined)
393
395
  if (advertisementTokens.length === 0) {
394
396
  Logger.warn(`[MB CLIENT] No advertisements for ${identityKey}, using default host ${this.host}`)
395
397
  return this.host
@@ -409,11 +411,10 @@ export class MessageBoxClient {
409
411
  async queryAdvertisements (
410
412
  identityKey?: string,
411
413
  host?: string,
412
- originator?: string
413
414
  ): Promise<AdvertisementToken[]> {
414
415
  const hosts: AdvertisementToken[] = []
415
416
  try {
416
- const query: Record<string, string> = { identityKey: identityKey ?? await this.getIdentityKey(originator) }
417
+ const query: Record<string, string> = { identityKey: identityKey ?? await this.getIdentityKey() }
417
418
  if (host != null && host.trim() !== '') query.host = host
418
419
 
419
420
  const result = await this.lookupResolver.query({
@@ -471,13 +472,13 @@ export class MessageBoxClient {
471
472
  * await client.joinRoom('payment_inbox')
472
473
  * // Now listening for real-time messages in room '028d...-payment_inbox'
473
474
  */
474
- async joinRoom (messageBox: string, originator?: string, overrideHost?: string): Promise<void> {
475
+ async joinRoom (messageBox: string, overrideHost?: string): Promise<void> {
475
476
  Logger.log(`[MB CLIENT] Attempting to join WebSocket room: ${messageBox}`)
476
477
 
477
478
  // Ensure WebSocket connection is established first
478
479
  if (this.socket == null) {
479
480
  Logger.log('[MB CLIENT] No WebSocket connection. Initializing...')
480
- await this.initializeConnection(originator, overrideHost)
481
+ await this.initializeConnection(overrideHost)
481
482
  }
482
483
 
483
484
  if (this.myIdentityKey == null || this.myIdentityKey.trim() === '') {
@@ -532,12 +533,10 @@ export class MessageBoxClient {
532
533
  async listenForLiveMessages ({
533
534
  onMessage,
534
535
  messageBox,
535
- originator,
536
536
  overrideHost
537
537
  }: {
538
538
  onMessage: (message: PeerMessage) => void
539
539
  messageBox: string
540
- originator?: string
541
540
  overrideHost?: string
542
541
  }): Promise<void> {
543
542
  Logger.log(`[MB CLIENT] Setting up listener for WebSocket room: ${messageBox}`)
@@ -545,11 +544,11 @@ export class MessageBoxClient {
545
544
  // Ensure WebSocket connection is established first
546
545
  if (this.socket == null) {
547
546
  Logger.log('[MB CLIENT] No WebSocket connection. Initializing...')
548
- await this.initializeConnection(originator, overrideHost)
547
+ await this.initializeConnection(overrideHost)
549
548
  }
550
549
 
551
550
  // Join the room
552
- await this.joinRoom(messageBox, originator, overrideHost)
551
+ await this.joinRoom(messageBox, this.originator)
553
552
 
554
553
  // Ensure identity key is available before creating roomId
555
554
  if (this.myIdentityKey == null || this.myIdentityKey.trim() === '') {
@@ -586,7 +585,7 @@ export class MessageBoxClient {
586
585
  keyID: '1',
587
586
  counterparty: message.sender,
588
587
  ciphertext: Utils.toArray((parsedBody as any).encryptedMessage, 'base64')
589
- }, originator)
588
+ }, this.originator)
590
589
 
591
590
  message.body = Utils.toUTF8(decrypted.plaintext)
592
591
  } else {
@@ -641,7 +640,6 @@ export class MessageBoxClient {
641
640
  messageId,
642
641
  skipEncryption,
643
642
  checkPermissions,
644
- originator
645
643
  }: SendMessageParams, overrideHost?: string): Promise<SendMessageResponse> {
646
644
  if (recipient == null || recipient.trim() === '') {
647
645
  throw new Error('[MB CLIENT ERROR] Recipient identity key is required')
@@ -654,7 +652,7 @@ export class MessageBoxClient {
654
652
  }
655
653
 
656
654
  // Ensure room is joined before sending
657
- await this.joinRoom(messageBox, originator, overrideHost)
655
+ await this.joinRoom(messageBox, this.originator)
658
656
 
659
657
  // Fallback to HTTP if WebSocket is not connected
660
658
  if (this.socket == null || !this.socket.connected) {
@@ -670,7 +668,7 @@ export class MessageBoxClient {
670
668
  protocolID: [1, 'messagebox'],
671
669
  keyID: '1',
672
670
  counterparty: recipient
673
- }, originator)
671
+ }, this.originator)
674
672
  finalMessageId = messageId ?? Array.from(hmac.hmac).map(b => b.toString(16).padStart(2, '0')).join('')
675
673
  } catch (error) {
676
674
  Logger.error('[MB CLIENT ERROR] Failed to generate HMAC:', error)
@@ -689,7 +687,7 @@ export class MessageBoxClient {
689
687
  keyID: '1',
690
688
  counterparty: recipient,
691
689
  plaintext: Utils.toArray(typeof body === 'string' ? body : JSON.stringify(body), 'utf8')
692
- }, originator)
690
+ }, this.originator)
693
691
 
694
692
  outgoingBody = JSON.stringify({
695
693
  encryptedMessage: Utils.toBase64(encryptedMessage.ciphertext)
@@ -864,7 +862,6 @@ export class MessageBoxClient {
864
862
  async sendMessage (
865
863
  message: SendMessageParams,
866
864
  overrideHost?: string,
867
- originator?: string
868
865
  ): Promise<SendMessageResponse> {
869
866
  await this.assertInitialized()
870
867
  if (message.recipient == null || message.recipient.trim() === '') {
@@ -921,7 +918,7 @@ export class MessageBoxClient {
921
918
  protocolID: [1, 'messagebox'],
922
919
  keyID: '1',
923
920
  counterparty: message.recipient
924
- }, originator)
921
+ }, this.originator)
925
922
  messageId = message.messageId ?? Array.from(hmac.hmac).map(b => b.toString(16).padStart(2, '0')).join('')
926
923
  } catch (error) {
927
924
  Logger.error('[MB CLIENT ERROR] Failed to generate HMAC:', error)
@@ -937,7 +934,7 @@ export class MessageBoxClient {
937
934
  keyID: '1',
938
935
  counterparty: message.recipient,
939
936
  plaintext: Utils.toArray(typeof message.body === 'string' ? message.body : JSON.stringify(message.body), 'utf8')
940
- }, originator)
937
+ }, this.originator)
941
938
 
942
939
  finalBody = JSON.stringify({ encryptedMessage: Utils.toBase64(encryptedMessage.ciphertext) })
943
940
  }
@@ -959,7 +956,7 @@ export class MessageBoxClient {
959
956
 
960
957
  if (this.myIdentityKey == null || this.myIdentityKey === '') {
961
958
  try {
962
- const keyResult = await this.walletClient.getPublicKey({ identityKey: true }, originator)
959
+ const keyResult = await this.walletClient.getPublicKey({ identityKey: true }, this.originator)
963
960
  this.myIdentityKey = keyResult.publicKey
964
961
  Logger.log(`[MB CLIENT] Fetched identity key before sending request: ${this.myIdentityKey}`)
965
962
  } catch (error) {
@@ -1025,14 +1022,14 @@ export class MessageBoxClient {
1025
1022
  * @example
1026
1023
  * const { txid } = await client.anointHost('https://my-messagebox.io')
1027
1024
  */
1028
- async anointHost (host: string, originator?: string): Promise<{ txid: string }> {
1025
+ async anointHost (host: string): Promise<{ txid: string }> {
1029
1026
  Logger.log('[MB CLIENT] Starting anointHost...')
1030
1027
  try {
1031
1028
  if (!host.startsWith('http')) {
1032
1029
  throw new Error('Invalid host URL')
1033
1030
  }
1034
1031
 
1035
- const identityKey = await this.getIdentityKey(originator)
1032
+ const identityKey = await this.getIdentityKey()
1036
1033
 
1037
1034
  Logger.log('[MB CLIENT] Fields - Identity:', identityKey, 'Host:', host)
1038
1035
 
@@ -1041,7 +1038,7 @@ export class MessageBoxClient {
1041
1038
  Utils.toArray(host, 'utf8')
1042
1039
  ]
1043
1040
 
1044
- const pushdrop = new PushDrop(this.walletClient, originator)
1041
+ const pushdrop = new PushDrop(this.walletClient, this.originator)
1045
1042
  Logger.log('Fields:', fields.map(a => Utils.toHex(a)))
1046
1043
  Logger.log('ProtocolID:', [1, 'messagebox advertisement'])
1047
1044
  Logger.log('KeyID:', '1')
@@ -1067,7 +1064,7 @@ export class MessageBoxClient {
1067
1064
  outputDescription: 'Overlay advertisement output'
1068
1065
  }],
1069
1066
  options: { randomizeOutputs: false, acceptDelayedBroadcast: false }
1070
- }, originator)
1067
+ }, this.originator)
1071
1068
 
1072
1069
  Logger.log('[MB CLIENT] Transaction created:', txid)
1073
1070
 
@@ -1107,7 +1104,7 @@ export class MessageBoxClient {
1107
1104
  * @example
1108
1105
  * const { txid } = await client.revokeHost('https://my-messagebox.io')
1109
1106
  */
1110
- async revokeHostAdvertisement (advertisementToken: AdvertisementToken, originator?: string): Promise<{ txid: string }> {
1107
+ async revokeHostAdvertisement (advertisementToken: AdvertisementToken): Promise<{ txid: string }> {
1111
1108
  Logger.log('[MB CLIENT] Starting revokeHost...')
1112
1109
  const outpoint = `${advertisementToken.txid}.${advertisementToken.outputIndex}`
1113
1110
  try {
@@ -1121,7 +1118,7 @@ export class MessageBoxClient {
1121
1118
  inputDescription: 'Revoking host advertisement token'
1122
1119
  }
1123
1120
  ]
1124
- }, originator)
1121
+ }, this.originator)
1125
1122
 
1126
1123
  if (signableTransaction === undefined) {
1127
1124
  throw new Error('Failed to create signable transaction.')
@@ -1130,7 +1127,7 @@ export class MessageBoxClient {
1130
1127
  const partialTx = Transaction.fromBEEF(signableTransaction.tx)
1131
1128
 
1132
1129
  // Prepare the unlocker
1133
- const pushdrop = new PushDrop(this.walletClient, originator)
1130
+ const pushdrop = new PushDrop(this.walletClient, this.originator)
1134
1131
  const unlocker = await pushdrop.unlock(
1135
1132
  [1, 'messagebox advertisement'],
1136
1133
  '1',
@@ -1155,7 +1152,7 @@ export class MessageBoxClient {
1155
1152
  options: {
1156
1153
  acceptDelayedBroadcast: false
1157
1154
  }
1158
- }, originator)
1155
+ }, this.originator)
1159
1156
 
1160
1157
  if (signedTx === undefined) {
1161
1158
  throw new Error('Failed to finalize the transaction signature.')
@@ -1210,13 +1207,10 @@ export class MessageBoxClient {
1210
1207
  * messages.forEach(msg => console.log(msg.sender, msg.body))
1211
1208
  * // Payments included with messages are automatically received
1212
1209
  */
1213
- async listMessages ({ messageBox, host, originator, acceptPayments }: ListMessagesParams): Promise<PeerMessage[]> {
1210
+ async listMessages ({ messageBox, host, acceptPayments }: ListMessagesParams): Promise<PeerMessage[]> {
1214
1211
  if (typeof acceptPayments !== 'boolean') {
1215
1212
  acceptPayments = true
1216
1213
  }
1217
- if (typeof host !== 'string') {
1218
- await this.assertInitialized()
1219
- }
1220
1214
  if (messageBox.trim() === '') {
1221
1215
  throw new Error('MessageBox cannot be empty')
1222
1216
  }
@@ -1224,9 +1218,8 @@ export class MessageBoxClient {
1224
1218
  let hosts: string[] = host != null ? [host] : []
1225
1219
  if (hosts.length === 0) {
1226
1220
  const advertisedHosts = await this.queryAdvertisements(
1227
- await this.getIdentityKey(originator),
1221
+ await this.getIdentityKey(),
1228
1222
  undefined,
1229
- originator
1230
1223
  )
1231
1224
  hosts = Array.from(new Set([this.host, ...advertisedHosts.map(h => h.host)]))
1232
1225
  }
@@ -1325,7 +1318,7 @@ export class MessageBoxClient {
1325
1318
  tx: paymentData.tx,
1326
1319
  outputs: recipientOutputs,
1327
1320
  description: paymentData.description ?? 'MessageBox recipient payment'
1328
- }, originator)
1321
+ }, this.originator)
1329
1322
 
1330
1323
  if (internalizeResult.accepted) {
1331
1324
  Logger.log(
@@ -1368,7 +1361,7 @@ export class MessageBoxClient {
1368
1361
  messageContent.encryptedMessage,
1369
1362
  'base64'
1370
1363
  )
1371
- }, originator)
1364
+ }, this.originator)
1372
1365
 
1373
1366
  const decryptedText = Utils.toUTF8(decrypted.plaintext)
1374
1367
  message.body = this.tryParse(decryptedText)
@@ -1625,7 +1618,7 @@ export class MessageBoxClient {
1625
1618
  * @example
1626
1619
  * await client.acknowledgeMessage({ messageIds: ['msg123', 'msg456'] })
1627
1620
  */
1628
- async acknowledgeMessage ({ messageIds, host, originator }: AcknowledgeMessageParams): Promise<string> {
1621
+ async acknowledgeMessage ({ messageIds, host }: AcknowledgeMessageParams): Promise<string> {
1629
1622
  if (!Array.isArray(messageIds) || messageIds.length === 0) {
1630
1623
  throw new Error('Message IDs array cannot be empty')
1631
1624
  }
@@ -1635,8 +1628,8 @@ export class MessageBoxClient {
1635
1628
  let hosts: string[] = host != null ? [host] : []
1636
1629
  if (hosts.length === 0) {
1637
1630
  // 1. Determine all hosts (advertised + default)
1638
- const identityKey = await this.getIdentityKey(originator)
1639
- const advertisedHosts = await this.queryAdvertisements(identityKey, undefined, originator)
1631
+ const identityKey = await this.getIdentityKey()
1632
+ const advertisedHosts = await this.queryAdvertisements(identityKey, undefined)
1640
1633
  hosts = Array.from(new Set([this.host, ...advertisedHosts.map(h => h.host)]))
1641
1634
  }
1642
1635
 
@@ -2165,7 +2158,6 @@ export class MessageBoxClient {
2165
2158
  recipient: string,
2166
2159
  quote: MessageBoxQuote,
2167
2160
  description: string = 'MessageBox delivery payment',
2168
- originator?: string
2169
2161
  ): Promise<Payment> {
2170
2162
  if (quote.recipientFee <= 0 && quote.deliveryFee <= 0) {
2171
2163
  throw new Error('No payment required')
@@ -2190,7 +2182,7 @@ export class MessageBoxClient {
2190
2182
  protocolID: [2, '3241645161d8'],
2191
2183
  keyID: `${derivationPrefix} ${derivationSuffix}`,
2192
2184
  counterparty: quote.deliveryAgentIdentityKey
2193
- }, originator)
2185
+ }, this.originator)
2194
2186
 
2195
2187
  // Create locking script using host's public key
2196
2188
  const lockingScript = new P2PKH().lock(PublicKey.fromString(derivedKeyResult).toAddress()).toHex()
@@ -2264,7 +2256,7 @@ export class MessageBoxClient {
2264
2256
  description,
2265
2257
  outputs: createActionOutputs,
2266
2258
  options: { randomizeOutputs: false, acceptDelayedBroadcast: false }
2267
- }, originator)
2259
+ }, this.originator)
2268
2260
 
2269
2261
  if (tx == null) {
2270
2262
  throw new Error('Failed to create payment transaction')
@@ -75,12 +75,11 @@ export interface IncomingPayment {
75
75
  export class PeerPayClient extends MessageBoxClient {
76
76
  private readonly peerPayWalletClient: WalletInterface
77
77
  private _authFetchInstance?: AuthFetch
78
- private originator?: OriginatorDomainNameStringUnder250Bytes
79
78
  constructor (config: PeerPayClientConfig) {
80
79
  const { messageBoxHost = 'https://messagebox.babbage.systems', walletClient, enableLogging = false, originator } = config
81
80
 
82
81
  // 🔹 Pass enableLogging to MessageBoxClient
83
- super({ host: messageBoxHost, walletClient, enableLogging })
82
+ super({ host: messageBoxHost, walletClient, enableLogging, originator })
84
83
 
85
84
  this.peerPayWalletClient = walletClient
86
85
  this.originator = originator
@@ -116,7 +115,6 @@ export class PeerPayClient extends MessageBoxClient {
116
115
 
117
116
  Logger.log(`[PP CLIENT] Derivation Prefix: ${derivationPrefix}`)
118
117
  Logger.log(`[PP CLIENT] Derivation Suffix: ${derivationSuffix}`)
119
-
120
118
  // Get recipient's derived public key
121
119
  const { publicKey: derivedKeyResult } = await this.peerPayWalletClient.getPublicKey({
122
120
  protocolID: [2, '3241645161d8'],
@@ -220,7 +218,6 @@ export class PeerPayClient extends MessageBoxClient {
220
218
  recipient: payment.recipient,
221
219
  messageBox: STANDARD_PAYMENT_MESSAGEBOX,
222
220
  body: JSON.stringify(paymentToken),
223
- originator: this.originator
224
221
  }, overrideHost)
225
222
  } catch (err) {
226
223
  Logger.warn('[PP CLIENT] sendLiveMessage failed, falling back to HTTP:', err)
@@ -230,7 +227,6 @@ export class PeerPayClient extends MessageBoxClient {
230
227
  recipient: payment.recipient,
231
228
  messageBox: STANDARD_PAYMENT_MESSAGEBOX,
232
229
  body: JSON.stringify(paymentToken),
233
- originator: this.originator
234
230
  }, overrideHost)
235
231
  }
236
232
  }
@@ -250,16 +246,13 @@ export class PeerPayClient extends MessageBoxClient {
250
246
  async listenForLivePayments ({
251
247
  onPayment,
252
248
  overrideHost,
253
- originator
254
249
  }: {
255
250
  onPayment: (payment: IncomingPayment) => void
256
251
  overrideHost?: string
257
- originator?: string
258
252
  }): Promise<void> {
259
253
  await this.listenForLiveMessages({
260
254
  messageBox: STANDARD_PAYMENT_MESSAGEBOX,
261
255
  overrideHost,
262
- originator,
263
256
 
264
257
  // Convert PeerMessage → IncomingPayment before calling onPayment
265
258
  onMessage: (message: PeerMessage) => {
@@ -307,7 +300,7 @@ export class PeerPayClient extends MessageBoxClient {
307
300
  Logger.log(`[PP CLIENT] Payment internalized successfully: ${JSON.stringify(paymentResult, null, 2)}`)
308
301
  Logger.log(`[PP CLIENT] Acknowledging payment with messageId: ${payment.messageId}`)
309
302
 
310
- await this.acknowledgeMessage({ messageIds: [payment.messageId] , originator: this.originator})
303
+ await this.acknowledgeMessage({ messageIds: [payment.messageId]})
311
304
 
312
305
  return { payment, paymentResult }
313
306
  } catch (error) {
@@ -371,7 +364,7 @@ export class PeerPayClient extends MessageBoxClient {
371
364
 
372
365
  try {
373
366
  Logger.log(`[PP CLIENT] Acknowledging message ${payment.messageId} after refunding...`)
374
- await this.acknowledgeMessage({ messageIds: [payment.messageId], originator: this.originator })
367
+ await this.acknowledgeMessage({ messageIds: [payment.messageId] })
375
368
  Logger.log('[PP CLIENT] Acknowledgment after refund successful.')
376
369
  } catch (error: any) {
377
370
  Logger.error(`[PP CLIENT] Error acknowledging message after refund: ${(error as { message: string }).message}`)
@@ -388,8 +381,7 @@ export class PeerPayClient extends MessageBoxClient {
388
381
  * @returns {Promise<IncomingPayment[]>} Resolves with an array of pending payments.
389
382
  */
390
383
  async listIncomingPayments (overrideHost?: string): Promise<IncomingPayment[]> {
391
- const messages = await this.listMessages({ messageBox: STANDARD_PAYMENT_MESSAGEBOX, host: overrideHost })
392
-
384
+ const messages = await this.listMessages({ messageBox: STANDARD_PAYMENT_MESSAGEBOX, host: overrideHost})
393
385
  return messages.map((msg: any) => {
394
386
  const parsedToken = safeParse<PaymentToken>(msg.body)
395
387
 
package/src/types.ts CHANGED
@@ -69,7 +69,6 @@ export interface SendMessageParams {
69
69
  skipEncryption?: boolean
70
70
  /** Optional: Enable permission and fee checking (default: false for backwards compatibility) */
71
71
  checkPermissions?: boolean
72
- originator?: string
73
72
  }
74
73
 
75
74
  /**
@@ -89,12 +88,10 @@ export interface SendMessageResponse {
89
88
  *
90
89
  * @property {string[]} messageIds - An array of message IDs to acknowledge.
91
90
  * @property {string} [host] - Optional host URL where the messages originated.
92
- * @property {string} [originator] - Optional originator of the message box client.
93
91
  */
94
92
  export interface AcknowledgeMessageParams {
95
93
  messageIds: string[]
96
94
  host?: string
97
- originator?: string
98
95
  }
99
96
 
100
97
  /**
@@ -102,12 +99,10 @@ export interface AcknowledgeMessageParams {
102
99
  *
103
100
  * @property messageBox - The identifier of the message box to retrieve messages from.
104
101
  * @property host - (Optional) The host URL to connect to for retrieving messages.
105
- * @property originator - (Optional) The originator of the message box client.
106
102
  */
107
103
  export interface ListMessagesParams {
108
104
  messageBox: string
109
105
  host?: string
110
- originator?: string
111
106
  acceptPayments?: boolean
112
107
  }
113
108