@xmtp/node-sdk 1.2.1 → 2.0.1

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/index.d.ts CHANGED
@@ -60,7 +60,11 @@ type StorageOptions = {
60
60
  /**
61
61
  * Path to the local DB
62
62
  */
63
- dbPath?: string;
63
+ dbPath?: string | null;
64
+ /**
65
+ * Encryption key for the local DB
66
+ */
67
+ dbEncryptionKey?: Uint8Array;
64
68
  };
65
69
  type ContentOptions = {
66
70
  /**
@@ -107,9 +111,29 @@ declare class AsyncStream<T> {
107
111
 
108
112
  type MessageKind = "application" | "membership_change";
109
113
  type MessageDeliveryStatus = "unpublished" | "published" | "failed";
110
- declare class DecodedMessage<T = any> {
114
+ /**
115
+ * Represents a decoded XMTP message
116
+ *
117
+ * This class transforms network messages into a structured format with
118
+ * content decoding.
119
+ *
120
+ * @class
121
+ * @property {any} content - The decoded content of the message
122
+ * @property {ContentTypeId} contentType - The content type of the message content
123
+ * @property {string} conversationId - Unique identifier for the conversation
124
+ * @property {MessageDeliveryStatus} deliveryStatus - Current delivery status of the message ("unpublished" | "published" | "failed")
125
+ * @property {string} [fallback] - Optional fallback text for the message
126
+ * @property {number} [compression] - Optional compression level applied to the message
127
+ * @property {string} id - Unique identifier for the message
128
+ * @property {MessageKind} kind - Type of message ("application" | "membership_change")
129
+ * @property {Record<string, string>} parameters - Additional parameters associated with the message
130
+ * @property {string} senderInboxId - Identifier for the sender's inbox
131
+ * @property {Date} sentAt - Timestamp when the message was sent
132
+ * @property {number} sentAtNs - Timestamp when the message was sent (in nanoseconds)
133
+ */
134
+ declare class DecodedMessage<T = unknown> {
111
135
  #private;
112
- content: T;
136
+ content: T | undefined;
113
137
  contentType: ContentTypeId | undefined;
114
138
  conversationId: string;
115
139
  deliveryStatus: MessageDeliveryStatus;
@@ -124,91 +148,455 @@ declare class DecodedMessage<T = any> {
124
148
  constructor(client: Client, message: Message);
125
149
  }
126
150
 
151
+ /**
152
+ * Represents a conversation
153
+ *
154
+ * This class is not intended to be initialized directly.
155
+ */
127
156
  declare class Conversation {
128
157
  #private;
158
+ /**
159
+ * Creates a new conversation instance
160
+ *
161
+ * @param client - The client instance managing the conversation
162
+ * @param conversation - The underlying conversation instance
163
+ * @param lastMessage - Optional last message in the conversation
164
+ */
129
165
  constructor(client: Client, conversation: Conversation$1, lastMessage?: Message | null);
166
+ /**
167
+ * Gets the unique identifier for this conversation
168
+ */
130
169
  get id(): string;
170
+ /**
171
+ * Gets whether this conversation is currently active
172
+ */
131
173
  get isActive(): boolean;
174
+ /**
175
+ * Gets the inbox ID that added this client's inbox to the conversation
176
+ */
132
177
  get addedByInboxId(): string;
178
+ /**
179
+ * Gets the timestamp when the conversation was created in nanoseconds
180
+ */
133
181
  get createdAtNs(): number;
182
+ /**
183
+ * Gets the date when the conversation was created
184
+ */
134
185
  get createdAt(): Date;
186
+ /**
187
+ * Gets the metadata for this conversation
188
+ *
189
+ * @returns Promise that resolves with the conversation metadata
190
+ */
135
191
  metadata(): Promise<{
136
192
  creatorInboxId: string;
137
193
  conversationType: string;
138
194
  }>;
195
+ /**
196
+ * Gets the members of this conversation
197
+ *
198
+ * @returns Promise that resolves with the conversation members
199
+ */
139
200
  members(): Promise<_xmtp_node_bindings.GroupMember[]>;
201
+ /**
202
+ * Synchronizes conversation data from the network
203
+ *
204
+ * @returns Promise that resolves when synchronization is complete
205
+ */
140
206
  sync(): Promise<void>;
141
- stream(callback?: StreamCallback<DecodedMessage>): AsyncStream<DecodedMessage<any>>;
207
+ /**
208
+ * Creates a stream for new messages in this conversation
209
+ *
210
+ * @param callback - Optional callback function for handling new stream values
211
+ * @returns Stream instance for new messages
212
+ */
213
+ stream(callback?: StreamCallback<DecodedMessage>): AsyncStream<DecodedMessage<unknown>>;
214
+ /**
215
+ * Publishes pending messages that were sent optimistically
216
+ *
217
+ * @returns Promise that resolves when publishing is complete
218
+ */
142
219
  publishMessages(): Promise<void>;
143
- sendOptimistic(content: any, contentType?: ContentTypeId): string;
144
- send(content: any, contentType?: ContentTypeId): Promise<string>;
220
+ /**
221
+ * Prepares a message to be published
222
+ *
223
+ * @param content - The content to send
224
+ * @param contentType - Optional content type of the message content
225
+ * @returns Promise that resolves with the message ID
226
+ * @throws {MissingContentTypeError} if content type is required but not provided
227
+ */
228
+ sendOptimistic(content: unknown, contentType?: ContentTypeId): string;
229
+ /**
230
+ * Publishes a new message
231
+ *
232
+ * @param content - The content to send
233
+ * @param contentType - Optional content type of the message content
234
+ * @returns Promise that resolves with the message ID after it has been sent
235
+ * @throws {MissingContentTypeError} if content type is required but not provided
236
+ */
237
+ send(content: unknown, contentType?: ContentTypeId): Promise<string>;
238
+ /**
239
+ * Lists messages in this conversation
240
+ *
241
+ * @param options - Optional filtering and pagination options
242
+ * @returns Promise that resolves with an array of decoded messages
243
+ */
145
244
  messages(options?: ListMessagesOptions): Promise<DecodedMessage[]>;
146
- lastMessage(): Promise<DecodedMessage<any>>;
245
+ /**
246
+ * Gets the last message in this conversation
247
+ *
248
+ * @returns Promise that resolves with the last message or undefined if none exists
249
+ */
250
+ lastMessage(): Promise<DecodedMessage<unknown>>;
251
+ /**
252
+ * Gets the consent state for this conversation
253
+ */
147
254
  get consentState(): ConsentState;
255
+ /**
256
+ * Updates the consent state for this conversation
257
+ *
258
+ * @param consentState - The new consent state to set
259
+ */
148
260
  updateConsentState(consentState: ConsentState): void;
261
+ /**
262
+ * Gets the message disappearing settings for this conversation
263
+ *
264
+ * @returns The current message disappearing settings or undefined if not set
265
+ */
149
266
  messageDisappearingSettings(): _xmtp_node_bindings.MessageDisappearingSettings | undefined;
267
+ /**
268
+ * Updates message disappearing settings for this conversation
269
+ *
270
+ * @param fromNs - The timestamp from which messages should start disappearing
271
+ * @param inNs - The duration after which messages should disappear
272
+ * @returns Promise that resolves when the update is complete
273
+ */
150
274
  updateMessageDisappearingSettings(fromNs: number, inNs: number): Promise<void>;
275
+ /**
276
+ * Removes message disappearing settings from this conversation
277
+ *
278
+ * @returns Promise that resolves when the settings are removed
279
+ */
151
280
  removeMessageDisappearingSettings(): Promise<void>;
281
+ /**
282
+ * Checks if message disappearing is enabled for this conversation
283
+ *
284
+ * @returns Whether message disappearing is enabled
285
+ */
152
286
  isMessageDisappearingEnabled(): boolean;
153
287
  pausedForVersion(): string | undefined;
288
+ /**
289
+ * Retrieves HMAC keys for this conversation
290
+ *
291
+ * @returns The HMAC keys for this conversation
292
+ */
154
293
  getHmacKeys(): _xmtp_node_bindings.HmacKey[];
155
294
  }
156
295
 
296
+ /**
297
+ * Represents a direct message conversation between two inboxes
298
+ *
299
+ * This class is not intended to be initialized directly.
300
+ */
157
301
  declare class Dm extends Conversation {
158
302
  #private;
303
+ /**
304
+ * Creates a new direct message conversation instance
305
+ *
306
+ * @param client - The client instance managing this direct message conversation
307
+ * @param conversation - The underlying conversation instance
308
+ * @param lastMessage - Optional last message in the conversation
309
+ */
159
310
  constructor(client: Client, conversation: Conversation$1, lastMessage?: Message | null);
311
+ /**
312
+ * Retrieves the inbox ID of the other participant in the DM
313
+ *
314
+ * @returns Promise that resolves with the peer's inbox ID
315
+ */
160
316
  get peerInboxId(): string;
161
317
  }
162
318
 
319
+ /**
320
+ * Represents a group conversation between multiple inboxes
321
+ *
322
+ * This class is not intended to be initialized directly.
323
+ */
163
324
  declare class Group extends Conversation {
164
325
  #private;
326
+ /**
327
+ * Creates a new group conversation instance
328
+ *
329
+ * @param client - The client instance managing this group conversation
330
+ * @param conversation - The underlying conversation object
331
+ * @param lastMessage - Optional last message in the conversation
332
+ */
165
333
  constructor(client: Client, conversation: Conversation$1, lastMessage?: Message | null);
334
+ /**
335
+ * The name of the group
336
+ */
166
337
  get name(): string;
338
+ /**
339
+ * Updates the group's name
340
+ *
341
+ * @param name The new name for the group
342
+ */
167
343
  updateName(name: string): Promise<void>;
344
+ /**
345
+ * The image URL of the group
346
+ */
168
347
  get imageUrl(): string;
348
+ /**
349
+ * Updates the group's image URL
350
+ *
351
+ * @param imageUrl The new image URL for the group
352
+ */
169
353
  updateImageUrl(imageUrl: string): Promise<void>;
354
+ /**
355
+ * The description of the group
356
+ */
170
357
  get description(): string;
358
+ /**
359
+ * Updates the group's description
360
+ *
361
+ * @param description The new description for the group
362
+ */
171
363
  updateDescription(description: string): Promise<void>;
364
+ /**
365
+ * The permissions of the group
366
+ */
172
367
  get permissions(): {
173
368
  policyType: _xmtp_node_bindings.GroupPermissionsOptions;
174
369
  policySet: _xmtp_node_bindings.PermissionPolicySet;
175
370
  };
371
+ /**
372
+ * Updates a specific permission policy for the group
373
+ *
374
+ * @param permissionType The type of permission to update
375
+ * @param policy The new permission policy
376
+ * @param metadataField Optional metadata field for the permission
377
+ */
176
378
  updatePermission(permissionType: PermissionUpdateType, policy: PermissionPolicy, metadataField?: MetadataField): Promise<void>;
379
+ /**
380
+ * The list of admins of the group
381
+ */
177
382
  get admins(): string[];
383
+ /**
384
+ * The list of super admins of the group
385
+ */
178
386
  get superAdmins(): string[];
387
+ /**
388
+ * Checks if an inbox is an admin of the group
389
+ *
390
+ * @param inboxId The inbox ID to check
391
+ * @returns Boolean indicating if the inbox is an admin
392
+ */
179
393
  isAdmin(inboxId: string): boolean;
394
+ /**
395
+ * Checks if an inbox is a super admin of the group
396
+ *
397
+ * @param inboxId The inbox ID to check
398
+ * @returns Boolean indicating if the inbox is a super admin
399
+ */
180
400
  isSuperAdmin(inboxId: string): boolean;
401
+ /**
402
+ * Adds members to the group using identifiers
403
+ *
404
+ * @param identifiers Array of member identifiers to add
405
+ */
181
406
  addMembersByIdentifiers(identifiers: Identifier[]): Promise<void>;
407
+ /**
408
+ * Adds members to the group using inbox IDs
409
+ *
410
+ * @param inboxIds Array of inbox IDs to add
411
+ */
182
412
  addMembers(inboxIds: string[]): Promise<void>;
413
+ /**
414
+ * Removes members from the group using identifiers
415
+ *
416
+ * @param identifiers Array of member identifiers to remove
417
+ */
183
418
  removeMembersByIdentifiers(identifiers: Identifier[]): Promise<void>;
419
+ /**
420
+ * Removes members from the group using inbox IDs
421
+ *
422
+ * @param inboxIds Array of inbox IDs to remove
423
+ */
184
424
  removeMembers(inboxIds: string[]): Promise<void>;
425
+ /**
426
+ * Promotes a group member to admin status
427
+ *
428
+ * @param inboxId The inbox ID of the member to promote
429
+ */
185
430
  addAdmin(inboxId: string): Promise<void>;
431
+ /**
432
+ * Removes admin status from a group member
433
+ *
434
+ * @param inboxId The inbox ID of the admin to demote
435
+ */
186
436
  removeAdmin(inboxId: string): Promise<void>;
437
+ /**
438
+ * Promotes a group member to super admin status
439
+ *
440
+ * @param inboxId The inbox ID of the member to promote
441
+ */
187
442
  addSuperAdmin(inboxId: string): Promise<void>;
443
+ /**
444
+ * Removes super admin status from a group member
445
+ *
446
+ * @param inboxId The inbox ID of the super admin to demote
447
+ */
188
448
  removeSuperAdmin(inboxId: string): Promise<void>;
189
449
  }
190
450
 
451
+ /**
452
+ * Manages conversations
453
+ *
454
+ * This class is not intended to be initialized directly.
455
+ */
191
456
  declare class Conversations {
192
457
  #private;
458
+ /**
459
+ * Creates a new conversations instance
460
+ *
461
+ * @param client - The client instance managing the conversations
462
+ * @param conversations - The underlying conversations instance
463
+ */
193
464
  constructor(client: Client, conversations: Conversations$1);
465
+ /**
466
+ * Retrieves a conversation by its ID
467
+ *
468
+ * @param id - The conversation ID to look up
469
+ * @returns The conversation if found, undefined otherwise
470
+ */
194
471
  getConversationById(id: string): Promise<Dm | Group | undefined>;
472
+ /**
473
+ * Retrieves a DM by inbox ID
474
+ *
475
+ * @param inboxId - The inbox ID to look up
476
+ * @returns The DM if found, undefined otherwise
477
+ */
195
478
  getDmByInboxId(inboxId: string): Dm | undefined;
196
- getMessageById<T = any>(id: string): DecodedMessage<T> | undefined;
479
+ /**
480
+ * Retrieves a message by its ID
481
+ *
482
+ * @param id - The message ID to look up
483
+ * @returns The decoded message if found, undefined otherwise
484
+ */
485
+ getMessageById<T = unknown>(id: string): DecodedMessage<T> | undefined;
486
+ /**
487
+ * Creates a new group conversation with the specified identifiers
488
+ *
489
+ * @param identifiers - Array of identifiers for group members
490
+ * @param options - Optional group creation options
491
+ * @returns The new group
492
+ */
197
493
  newGroupWithIdentifiers(identifiers: Identifier[], options?: CreateGroupOptions): Promise<Group>;
494
+ /**
495
+ * Creates a new group conversation with the specified inbox IDs
496
+ *
497
+ * @param inboxIds - Array of inbox IDs for group members
498
+ * @param options - Optional group creation options
499
+ * @returns The new group
500
+ */
198
501
  newGroup(inboxIds: string[], options?: CreateGroupOptions): Promise<Group>;
502
+ /**
503
+ * Creates a new DM conversation with the specified identifier
504
+ *
505
+ * @param identifier - Identifier for the DM recipient
506
+ * @param options - Optional DM creation options
507
+ * @returns The new DM
508
+ */
199
509
  newDmWithIdentifier(identifier: Identifier, options?: CreateDmOptions): Promise<Dm>;
510
+ /**
511
+ * Creates a new DM conversation with the specified inbox ID
512
+ *
513
+ * @param inboxId - Inbox ID for the DM recipient
514
+ * @param options - Optional DM creation options
515
+ * @returns The new DM
516
+ */
200
517
  newDm(inboxId: string, options?: CreateDmOptions): Promise<Dm>;
518
+ /**
519
+ * Lists all conversations with optional filtering
520
+ *
521
+ * @param options - Optional filtering and pagination options
522
+ * @returns Array of conversations
523
+ */
201
524
  list(options?: ListConversationsOptions): Promise<(Dm | Group)[]>;
525
+ /**
526
+ * Lists all groups with optional filtering
527
+ *
528
+ * @param options - Optional filtering and pagination options
529
+ * @returns Array of groups
530
+ */
202
531
  listGroups(options?: Omit<ListConversationsOptions, "conversationType">): Group[];
532
+ /**
533
+ * Lists all DMs with optional filtering
534
+ *
535
+ * @param options - Optional filtering and pagination options
536
+ * @returns Array of DMs
537
+ */
203
538
  listDms(options?: Omit<ListConversationsOptions, "conversationType">): Dm[];
539
+ /**
540
+ * Synchronizes conversations for the current client from the network
541
+ *
542
+ * @returns Promise that resolves when sync is complete
543
+ */
204
544
  sync(): Promise<void>;
545
+ /**
546
+ * Synchronizes all conversations and messages from the network with optional
547
+ * consent state filtering
548
+ *
549
+ * @param consentStates - Optional array of consent states to filter by
550
+ * @returns Promise that resolves when sync is complete
551
+ */
205
552
  syncAll(consentStates?: ConsentState[]): Promise<bigint>;
553
+ /**
554
+ * Creates a stream for new conversations
555
+ *
556
+ * @param callback - Optional callback function for handling new stream value
557
+ * @returns Stream instance for new conversations
558
+ */
206
559
  stream(callback?: StreamCallback<Group | Dm>): AsyncStream<Dm | Group>;
560
+ /**
561
+ * Creates a stream for new group conversations
562
+ *
563
+ * @param callback - Optional callback function for handling new stream value
564
+ * @returns Stream instance for new group conversations
565
+ */
207
566
  streamGroups(callback?: StreamCallback<Group>): AsyncStream<Group>;
567
+ /**
568
+ * Creates a stream for new DM conversations
569
+ *
570
+ * @param callback - Optional callback function for handling new stream value
571
+ * @returns Stream instance for new DM conversations
572
+ */
208
573
  streamDms(callback?: StreamCallback<Dm>): AsyncStream<Dm>;
209
- streamAllMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage<any>>>;
210
- streamAllGroupMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage<any>>>;
211
- streamAllDmMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage<any>>>;
574
+ /**
575
+ * Creates a stream for all new messages
576
+ *
577
+ * @param callback - Optional callback function for handling new stream value
578
+ * @returns Stream instance for new messages
579
+ */
580
+ streamAllMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage<unknown>>>;
581
+ /**
582
+ * Creates a stream for all new group messages
583
+ *
584
+ * @param callback - Optional callback function for handling new stream value
585
+ * @returns Stream instance for new group messages
586
+ */
587
+ streamAllGroupMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage<unknown>>>;
588
+ /**
589
+ * Creates a stream for all new DM messages
590
+ *
591
+ * @param callback - Optional callback function for handling new stream value
592
+ * @returns Stream instance for new DM messages
593
+ */
594
+ streamAllDmMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage<unknown>>>;
595
+ /**
596
+ * Retrieves HMAC keys for all conversations
597
+ *
598
+ * @returns The HMAC keys for all conversations
599
+ */
212
600
  hmacKeys(): Record<string, _xmtp_node_bindings.HmacKey[]>;
213
601
  }
214
602
 
@@ -218,15 +606,70 @@ type PreferenceUpdate = {
218
606
  key: Uint8Array;
219
607
  };
220
608
  };
609
+ /**
610
+ * Manages user preferences and consent states
611
+ *
612
+ * This class is not intended to be initialized directly.
613
+ */
221
614
  declare class Preferences {
222
615
  #private;
616
+ /**
617
+ * Creates a new preferences instance
618
+ *
619
+ * @param client - The client instance managing preferences
620
+ * @param conversations - The underlying conversations instance
621
+ */
223
622
  constructor(client: Client$1, conversations: Conversations$1);
623
+ /**
624
+ * Retrieves the current inbox state
625
+ *
626
+ * @param refreshFromNetwork - Optional flag to force refresh from network
627
+ * @returns Promise that resolves with the inbox state
628
+ */
224
629
  inboxState(refreshFromNetwork?: boolean): Promise<_xmtp_node_bindings.InboxState>;
630
+ /**
631
+ * Gets the latest inbox state for a specific inbox
632
+ *
633
+ * @param inboxId - The inbox ID to get state for
634
+ * @returns Promise that resolves with the latest inbox state
635
+ */
225
636
  getLatestInboxState(inboxId: string): Promise<_xmtp_node_bindings.InboxState>;
637
+ /**
638
+ * Retrieves inbox state for specific inbox IDs
639
+ *
640
+ * @param inboxIds - Array of inbox IDs to get state for
641
+ * @param refreshFromNetwork - Optional flag to force refresh from network
642
+ * @returns Promise that resolves with the inbox state for the inbox IDs
643
+ */
226
644
  inboxStateFromInboxIds(inboxIds: string[], refreshFromNetwork?: boolean): Promise<_xmtp_node_bindings.InboxState[]>;
645
+ /**
646
+ * Updates consent states for multiple records
647
+ *
648
+ * @param consentStates - Array of consent records to update
649
+ * @returns Promise that resolves when consent states are updated
650
+ */
227
651
  setConsentStates(consentStates: Consent[]): Promise<void>;
652
+ /**
653
+ * Retrieves consent state for a specific entity
654
+ *
655
+ * @param entityType - Type of entity to get consent for
656
+ * @param entity - Entity identifier
657
+ * @returns Promise that resolves with the consent state
658
+ */
228
659
  getConsentState(entityType: ConsentEntityType, entity: string): Promise<_xmtp_node_bindings.ConsentState>;
660
+ /**
661
+ * Creates a stream of consent state updates
662
+ *
663
+ * @param callback - Optional callback function for handling stream updates
664
+ * @returns Stream instance for consent updates
665
+ */
229
666
  streamConsent(callback?: StreamCallback<Consent[]>): AsyncStream<Consent[]>;
667
+ /**
668
+ * Creates a stream of user preference updates
669
+ *
670
+ * @param callback - Optional callback function for handling stream updates
671
+ * @returns Stream instance for preference updates
672
+ */
230
673
  streamPreferences(callback?: StreamCallback<PreferenceUpdate>): AsyncStream<PreferenceUpdate>;
231
674
  }
232
675
 
@@ -246,116 +689,387 @@ type Signer = {
246
689
  getChainId: GetChainId;
247
690
  };
248
691
 
692
+ /**
693
+ * Client for interacting with the XMTP network
694
+ */
249
695
  declare class Client {
250
696
  #private;
251
- constructor(client: Client$1, signer: Signer, codecs: ContentCodec[]);
252
- static create(signer: Signer, encryptionKey: Uint8Array, options?: ClientOptions): Promise<Client>;
253
- get identifier(): Identifier;
697
+ /**
698
+ * Creates a new XMTP client instance
699
+ *
700
+ * This class is not intended to be initialized directly.
701
+ * Use `Client.create` or `Client.build` instead.
702
+ *
703
+ * @param options - Optional configuration for the client
704
+ */
705
+ constructor(options?: ClientOptions);
706
+ /**
707
+ * Initializes the client with the provided identifier
708
+ *
709
+ * This is not meant to be called directly.
710
+ * Use `Client.create` or `Client.build` instead.
711
+ *
712
+ * @param identifier - The identifier to initialize the client with
713
+ */
714
+ init(identifier: Identifier): Promise<void>;
715
+ /**
716
+ * Creates a new client instance with a signer
717
+ *
718
+ * @param signer - The signer to use for authentication
719
+ * @param options - Optional configuration for the client
720
+ * @returns A new client instance
721
+ */
722
+ static create(signer: Signer, options?: ClientOptions): Promise<Client>;
723
+ /**
724
+ * Creates a new client instance with an identifier
725
+ *
726
+ * Clients created with this method must already be registered.
727
+ * Any methods called that require a signer will throw an error.
728
+ *
729
+ * @param identifier - The identifier to use
730
+ * @param options - Optional configuration for the client
731
+ * @returns A new client instance
732
+ */
733
+ static build(identifier: Identifier, options?: ClientOptions): Promise<Client>;
734
+ /**
735
+ * Gets the client options
736
+ */
737
+ get options(): ClientOptions | undefined;
738
+ /**
739
+ * Gets the signer associated with this client
740
+ */
741
+ get signer(): Signer | undefined;
742
+ /**
743
+ * Gets the account identifier for this client
744
+ */
745
+ get accountIdentifier(): Identifier | undefined;
746
+ /**
747
+ * Gets the inbox ID associated with this client
748
+ */
254
749
  get inboxId(): string;
750
+ /**
751
+ * Gets the installation ID for this client
752
+ */
255
753
  get installationId(): string;
754
+ /**
755
+ * Gets the installation ID bytes for this client
756
+ */
256
757
  get installationIdBytes(): Uint8Array<ArrayBufferLike>;
758
+ /**
759
+ * Gets whether the client is registered with the XMTP network
760
+ *
761
+ * @throws {ClientNotInitializedError} if the client is not initialized
762
+ */
257
763
  get isRegistered(): boolean;
764
+ /**
765
+ * Gets the conversations manager for this client
766
+ *
767
+ * @throws {ClientNotInitializedError} if the client is not initialized
768
+ */
258
769
  get conversations(): Conversations;
770
+ /**
771
+ * Gets the preferences manager for this client
772
+ *
773
+ * @throws {ClientNotInitializedError} if the client is not initialized
774
+ */
259
775
  get preferences(): Preferences;
260
776
  /**
777
+ * Creates signature text for creating a new inbox
778
+ *
261
779
  * WARNING: This function should be used with caution. It is only provided
262
780
  * for use in special cases where the provided workflows do not meet the
263
781
  * requirements of an application.
264
782
  *
265
- * It is highly recommended to use the `register` function instead.
783
+ * It is highly recommended to use the `register` method instead.
784
+ *
785
+ * @returns The signature text
786
+ * @throws {ClientNotInitializedError} if the client is not initialized
266
787
  */
267
788
  unsafe_createInboxSignatureText(): Promise<string | null | undefined>;
268
789
  /**
790
+ * Creates signature text for adding a new account to the client's inbox
791
+ *
269
792
  * WARNING: This function should be used with caution. It is only provided
270
793
  * for use in special cases where the provided workflows do not meet the
271
794
  * requirements of an application.
272
795
  *
273
- * It is highly recommended to use the `unsafe_addAccount` function instead.
796
+ * It is highly recommended to use the `unsafe_addAccount` method instead.
274
797
  *
275
798
  * The `allowInboxReassign` parameter must be true or this function will
276
799
  * throw an error.
800
+ *
801
+ * @param newAccountIdentifier - The identifier of the new account
802
+ * @param allowInboxReassign - Whether to allow inbox reassignment
803
+ * @returns The signature text
804
+ * @throws {ClientNotInitializedError} if the client is not initialized
277
805
  */
278
806
  unsafe_addAccountSignatureText(newAccountIdentifier: Identifier, allowInboxReassign?: boolean): Promise<string | undefined>;
279
807
  /**
808
+ * Creates signature text for removing an account from the client's inbox
809
+ *
280
810
  * WARNING: This function should be used with caution. It is only provided
281
811
  * for use in special cases where the provided workflows do not meet the
282
812
  * requirements of an application.
283
813
  *
284
- * It is highly recommended to use the `removeAccount` function instead.
814
+ * It is highly recommended to use the `removeAccount` method instead.
815
+ *
816
+ * @param identifier - The identifier of the account to remove
817
+ * @returns The signature text
818
+ * @throws {ClientNotInitializedError} if the client is not initialized
285
819
  */
286
820
  unsafe_removeAccountSignatureText(identifier: Identifier): Promise<string | undefined>;
287
821
  /**
822
+ * Creates signature text for revoking all other installations of the
823
+ * client's inbox
824
+ *
288
825
  * WARNING: This function should be used with caution. It is only provided
289
826
  * for use in special cases where the provided workflows do not meet the
290
827
  * requirements of an application.
291
828
  *
292
- * It is highly recommended to use the `revokeAllOtherInstallations` function
293
- * instead.
829
+ * It is highly recommended to use the `revokeAllOtherInstallations` method instead.
830
+ *
831
+ * @returns The signature text
832
+ * @throws {ClientNotInitializedError} if the client is not initialized
294
833
  */
295
834
  unsafe_revokeAllOtherInstallationsSignatureText(): Promise<string | undefined>;
296
835
  /**
836
+ * Creates signature text for revoking specific installations of the
837
+ * client's inbox
838
+ *
297
839
  * WARNING: This function should be used with caution. It is only provided
298
840
  * for use in special cases where the provided workflows do not meet the
299
841
  * requirements of an application.
300
842
  *
301
- * It is highly recommended to use the `revokeInstallations` function instead.
843
+ * It is highly recommended to use the `revokeInstallations` method instead.
844
+ *
845
+ * @param installationIds - The installation IDs to revoke
846
+ * @returns The signature text
847
+ * @throws {ClientNotInitializedError} if the client is not initialized
302
848
  */
303
849
  unsafe_revokeInstallationsSignatureText(installationIds: Uint8Array[]): Promise<string | undefined>;
304
850
  /**
851
+ * Creates signature text for changing the recovery identifier for this
852
+ * client's inbox
853
+ *
305
854
  * WARNING: This function should be used with caution. It is only provided
306
855
  * for use in special cases where the provided workflows do not meet the
307
856
  * requirements of an application.
308
857
  *
309
- * It is highly recommended to use the `changeRecoveryIdentifer` function instead.
858
+ * It is highly recommended to use the `changeRecoveryIdentifier` method instead.
859
+ *
860
+ * @param identifier - The new recovery identifier
861
+ * @returns The signature text
862
+ * @throws {ClientNotInitializedError} if the client is not initialized
310
863
  */
311
864
  unsafe_changeRecoveryIdentifierSignatureText(identifier: Identifier): Promise<string | undefined>;
312
865
  /**
866
+ * Adds a signature for a specific request type
867
+ *
313
868
  * WARNING: This function should be used with caution. It is only provided
314
869
  * for use in special cases where the provided workflows do not meet the
315
870
  * requirements of an application.
316
871
  *
317
872
  * It is highly recommended to use the `register`, `unsafe_addAccount`,
318
873
  * `removeAccount`, `revokeAllOtherInstallations`, or `revokeInstallations`
319
- * functions instead.
874
+ * methods instead.
875
+ *
876
+ * @param signatureType - The type of signature request
877
+ * @param signatureText - The text to sign
878
+ * @param signer - The signer to use
879
+ * @throws {ClientNotInitializedError} if the client is not initialized
320
880
  */
321
881
  unsafe_addSignature(signatureType: SignatureRequestType, signatureText: string, signer: Signer): Promise<void>;
322
882
  /**
883
+ * Applies all pending signatures
884
+ *
323
885
  * WARNING: This function should be used with caution. It is only provided
324
886
  * for use in special cases where the provided workflows do not meet the
325
887
  * requirements of an application.
326
888
  *
327
889
  * It is highly recommended to use the `register`, `unsafe_addAccount`,
328
890
  * `removeAccount`, `revokeAllOtherInstallations`, or `revokeInstallations`
329
- * functions instead.
891
+ * methods instead.
892
+ *
893
+ * @throws {ClientNotInitializedError} if the client is not initialized
330
894
  */
331
895
  unsafe_applySignatures(): Promise<void>;
896
+ /**
897
+ * Registers the client with the XMTP network
898
+ *
899
+ * Requires a signer, use `Client.create` to create a client with a signer.
900
+ *
901
+ * @throws {ClientNotInitializedError} if the client is not initialized
902
+ * @throws {SignerUnavailableError} if no signer is available
903
+ */
332
904
  register(): Promise<void>;
333
905
  /**
906
+ * Adds a new account to the client inbox
907
+ *
334
908
  * WARNING: This function should be used with caution. Adding a wallet already
335
- * associated with an inboxId will cause the wallet to lose access to
909
+ * associated with an inbox ID will cause the wallet to lose access to
336
910
  * that inbox.
337
911
  *
338
912
  * The `allowInboxReassign` parameter must be true to reassign an inbox
339
913
  * already associated with a different account.
914
+ *
915
+ * Requires a signer, use `Client.create` to create a client with a signer.
916
+ *
917
+ * @param newAccountSigner - The signer for the new account
918
+ * @param allowInboxReassign - Whether to allow inbox reassignment
919
+ * @throws {ClientNotInitializedError} if the client is not initialized
920
+ * @throws {AccountAlreadyAssociatedError} if the account is already associated with an inbox ID
921
+ * @throws {GenerateSignatureError} if the signature cannot be generated
922
+ * @throws {SignerUnavailableError} if no signer is available
340
923
  */
341
924
  unsafe_addAccount(newAccountSigner: Signer, allowInboxReassign?: boolean): Promise<void>;
925
+ /**
926
+ * Removes an account from the client's inbox
927
+ *
928
+ * Requires a signer, use `Client.create` to create a client with a signer.
929
+ *
930
+ * @param identifier - The identifier of the account to remove
931
+ * @throws {ClientNotInitializedError} if the client is not initialized
932
+ * @throws {GenerateSignatureError} if the signature cannot be generated
933
+ * @throws {SignerUnavailableError} if no signer is available
934
+ */
342
935
  removeAccount(identifier: Identifier): Promise<void>;
936
+ /**
937
+ * Revokes all other installations of the client's inbox
938
+ *
939
+ * Requires a signer, use `Client.create` to create a client with a signer.
940
+ *
941
+ * @throws {ClientNotInitializedError} if the client is not initialized
942
+ * @throws {GenerateSignatureError} if the signature cannot be generated
943
+ * @throws {SignerUnavailableError} if no signer is available
944
+ */
343
945
  revokeAllOtherInstallations(): Promise<void>;
946
+ /**
947
+ * Revokes specific installations of the client's inbox
948
+ *
949
+ * Requires a signer, use `Client.create` to create a client with a signer.
950
+ *
951
+ * @param installationIds - The installation IDs to revoke
952
+ * @throws {ClientNotInitializedError} if the client is not initialized
953
+ * @throws {SignerUnavailableError} if no signer is available
954
+ * @throws {GenerateSignatureError} if the signature cannot be generated
955
+ */
344
956
  revokeInstallations(installationIds: Uint8Array[]): Promise<void>;
957
+ /**
958
+ * Changes the recovery identifier for the client's inbox
959
+ *
960
+ * Requires a signer, use `Client.create` to create a client with a signer.
961
+ *
962
+ * @param identifier - The new recovery identifier
963
+ * @throws {ClientNotInitializedError} if the client is not initialized
964
+ * @throws {SignerUnavailableError} if no signer is available
965
+ * @throws {GenerateSignatureError} if the signature cannot be generated
966
+ */
345
967
  changeRecoveryIdentifier(identifier: Identifier): Promise<void>;
968
+ /**
969
+ * Checks if the client can message the specified identifiers
970
+ *
971
+ * @param identifiers - The identifiers to check
972
+ * @returns Whether the client can message the identifiers
973
+ * @throws {ClientNotInitializedError} if the client is not initialized
974
+ */
346
975
  canMessage(identifiers: Identifier[]): Promise<Map<string, boolean>>;
976
+ /**
977
+ * Checks if the specified identifiers can be messaged
978
+ *
979
+ * @param identifiers - The identifiers to check
980
+ * @param env - Optional XMTP environment
981
+ * @returns Map of identifiers to whether they can be messaged
982
+ */
347
983
  static canMessage(identifiers: Identifier[], env?: XmtpEnv): Promise<Map<string, boolean>>;
984
+ /**
985
+ * Gets the key package statuses for the specified installation IDs
986
+ *
987
+ * @param installationIds - The installation IDs to check
988
+ * @returns The key package statuses
989
+ * @throws {ClientNotInitializedError} if the client is not initialized
990
+ */
348
991
  getKeyPackageStatusesForInstallationIds(installationIds: string[]): Promise<Record<string, _xmtp_node_bindings.KeyPackageStatus>>;
349
- codecFor(contentType: ContentTypeId): ContentCodec | undefined;
350
- encodeContent(content: any, contentType: ContentTypeId): EncodedContent<Record<string, string>>;
351
- decodeContent(message: Message, contentType: ContentTypeId): any;
352
- requestHistorySync(): Promise<void>;
992
+ /**
993
+ * Gets the codec for a given content type
994
+ *
995
+ * @param contentType - The content type to get the codec for
996
+ * @returns The codec, if found
997
+ */
998
+ codecFor<T = unknown>(contentType: ContentTypeId): ContentCodec<T> | undefined;
999
+ /**
1000
+ * Encodes content for a given content type
1001
+ *
1002
+ * @param content - The content to encode
1003
+ * @param contentType - The content type to encode for
1004
+ * @returns The encoded content
1005
+ * @throws {CodecNotFoundError} if no codec is found for the content type
1006
+ */
1007
+ encodeContent(content: unknown, contentType: ContentTypeId): EncodedContent<Record<string, string>>;
1008
+ /**
1009
+ * Decodes a message for a given content type
1010
+ *
1011
+ * @param message - The message to decode
1012
+ * @param contentType - The content type to decode for
1013
+ * @returns The decoded content
1014
+ * @throws {CodecNotFoundError} if no codec is found for the content type
1015
+ * @throws {InvalidGroupMembershipChangeError} if the message is an invalid group membership change
1016
+ */
1017
+ decodeContent<T = unknown>(message: Message, contentType: ContentTypeId): T;
1018
+ /**
1019
+ * Finds the inbox ID for a given identifier
1020
+ *
1021
+ * @param identifier - The identifier to look up
1022
+ * @returns The inbox ID, if found
1023
+ * @throws {ClientNotInitializedError} if the client is not initialized
1024
+ */
353
1025
  getInboxIdByIdentifier(identifier: Identifier): Promise<string | null>;
1026
+ /**
1027
+ * Signs a message with the installation key
1028
+ *
1029
+ * @param signatureText - The text to sign
1030
+ * @returns The signature
1031
+ * @throws {ClientNotInitializedError} if the client is not initialized
1032
+ */
354
1033
  signWithInstallationKey(signatureText: string): Uint8Array<ArrayBufferLike>;
1034
+ /**
1035
+ * Verifies a signature was made with the installation key
1036
+ *
1037
+ * @param signatureText - The text that was signed
1038
+ * @param signatureBytes - The signature bytes to verify
1039
+ * @returns Whether the signature is valid
1040
+ * @throws {ClientNotInitializedError} if the client is not initialized
1041
+ */
355
1042
  verifySignedWithInstallationKey(signatureText: string, signatureBytes: Uint8Array): boolean;
1043
+ /**
1044
+ * Verifies a signature was made with a public key
1045
+ *
1046
+ * @param signatureText - The text that was signed
1047
+ * @param signatureBytes - The signature bytes to verify
1048
+ * @param publicKey - The public key to verify against
1049
+ * @returns Whether the signature is valid
1050
+ */
356
1051
  static verifySignedWithPublicKey(signatureText: string, signatureBytes: Uint8Array, publicKey: Uint8Array): boolean;
1052
+ /**
1053
+ * Checks if an address is authorized for an inbox
1054
+ *
1055
+ * @param inboxId - The inbox ID to check
1056
+ * @param address - The address to check
1057
+ * @param options - Optional network options
1058
+ * @returns Whether the address is authorized
1059
+ */
357
1060
  static isAddressAuthorized(inboxId: string, address: string, options?: NetworkOptions): Promise<boolean>;
1061
+ /**
1062
+ * Checks if an installation is authorized for an inbox
1063
+ *
1064
+ * @param inboxId - The inbox ID to check
1065
+ * @param installation - The installation to check
1066
+ * @param options - Optional network options
1067
+ * @returns Whether the installation is authorized
1068
+ */
358
1069
  static isInstallationAuthorized(inboxId: string, installation: Uint8Array, options?: NetworkOptions): Promise<boolean>;
1070
+ /**
1071
+ * Gets the version of the Node bindings
1072
+ */
359
1073
  static get version(): string;
360
1074
  }
361
1075