@xmtp/browser-sdk 2.0.13 → 2.1.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.
Files changed (43) hide show
  1. package/dist/index.d.ts +849 -678
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/workers/client.js +1 -1
  5. package/dist/workers/client.js.map +1 -1
  6. package/dist/workers/utils.js +1 -1
  7. package/dist/workers/utils.js.map +1 -1
  8. package/package.json +9 -11
  9. package/src/Client.ts +71 -31
  10. package/src/ClientWorkerClass.ts +62 -19
  11. package/src/Conversation.ts +60 -33
  12. package/src/Conversations.ts +96 -48
  13. package/src/DecodedMessage.ts +8 -5
  14. package/src/Dm.ts +14 -4
  15. package/src/Group.ts +27 -20
  16. package/src/Preferences.ts +21 -10
  17. package/src/Utils.ts +2 -2
  18. package/src/UtilsWorkerClass.ts +56 -15
  19. package/src/WorkerClient.ts +25 -3
  20. package/src/WorkerConversation.ts +11 -2
  21. package/src/WorkerConversations.ts +19 -4
  22. package/src/WorkerPreferences.ts +4 -0
  23. package/src/index.ts +3 -1
  24. package/src/types/actions/client.ts +181 -0
  25. package/src/types/actions/conversation.ts +146 -0
  26. package/src/types/actions/conversations.ts +146 -0
  27. package/src/types/actions/dm.ts +19 -0
  28. package/src/types/actions/group.ts +161 -0
  29. package/src/types/actions/preferences.ts +68 -0
  30. package/src/types/actions/streams.ts +44 -0
  31. package/src/types/actions/utils.ts +29 -0
  32. package/src/types/actions.ts +75 -0
  33. package/src/types/options.ts +18 -0
  34. package/src/utils/conversions.ts +60 -0
  35. package/src/utils/createClient.ts +6 -1
  36. package/src/utils/errors.ts +3 -1
  37. package/src/workers/client.ts +243 -190
  38. package/src/workers/utils.ts +25 -29
  39. package/src/types/clientEvents.ts +0 -693
  40. package/src/types/clientStreamEvents.ts +0 -45
  41. package/src/types/index.ts +0 -4
  42. package/src/types/utils.ts +0 -72
  43. package/src/types/utilsEvents.ts +0 -60
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { ContentCodec, ContentTypeId as ContentTypeId$1, EncodedContent as EncodedContent$1 } from '@xmtp/content-type-primitives';
2
2
  import * as _xmtp_wasm_bindings from '@xmtp/wasm-bindings';
3
- import { Identifier, SignatureRequestType, ConsentState, ConsentEntityType, ConversationType, PermissionUpdateType, PermissionPolicy, MetadataField, Conversations as Conversations$1, Message, Conversation as Conversation$1, Client as Client$1, Consent, UserPreference, KeyPackageStatus, EncodedContent, MessageDisappearingSettings, HmacKey, GroupPermissionsOptions, DeliveryStatus, GroupMessageKind, ContentType, SortDirection, PermissionLevel, ContentTypeId, ListMessagesOptions, ListConversationsOptions, PermissionPolicySet, CreateGroupOptions, CreateDMOptions, Installation, InboxState, GroupMember } from '@xmtp/wasm-bindings';
3
+ import { Conversations as Conversations$1, ConsentState, Message, Identifier, Conversation as Conversation$1, ConversationType, Client as Client$1, ConsentEntityType, Consent, UserPreference, SignatureRequestType, KeyPackageStatus, PermissionUpdateType, PermissionPolicy, MetadataField, EncodedContent, MessageDisappearingSettings, HmacKey, ConversationDebugInfo, GroupPermissionsOptions, DeliveryStatus, GroupMessageKind, ContentType, SortDirection, PermissionLevel, ContentTypeId, ListMessagesOptions, ListConversationsOptions, PermissionPolicySet, CreateGroupOptions, CreateDMOptions, Installation, InboxState, GroupMember, ApiStats, IdentityStats } from '@xmtp/wasm-bindings';
4
4
  export { Consent, ConsentEntityType, ConsentState, ContentType, ContentTypeId, ConversationListItem, ConversationType, CreateDMOptions, CreateGroupOptions, DeliveryStatus, EncodedContent, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, HmacKey, Identifier, IdentifierKind, InboxState, Installation, ListConversationsOptions, ListMessagesOptions, LogOptions, Message, MessageDisappearingSettings, MetadataField, PermissionLevel, PermissionPolicy, PermissionPolicySet, PermissionUpdateType, SignatureRequestType, SortDirection, UserPreference } from '@xmtp/wasm-bindings';
5
+ import { GroupUpdatedCodec } from '@xmtp/content-type-group-updated';
6
+ import { TextCodec } from '@xmtp/content-type-text';
5
7
 
6
8
  type ResolveValue<T> = {
7
9
  value: T | undefined;
@@ -87,6 +89,20 @@ type ContentOptions = {
87
89
  type StorageOptions = {
88
90
  /**
89
91
  * Path to the local DB
92
+ *
93
+ * There are 3 value types that can be used to specify the database path:
94
+ *
95
+ * - `undefined` (or excluded from the client options)
96
+ * The database will be created in the current working directory and is based on
97
+ * the XMTP environment and client inbox ID.
98
+ * Example: `xmtp-dev-<inbox-id>.db3`
99
+ *
100
+ * - `null`
101
+ * No database will be created and all data will be lost once the client disconnects.
102
+ *
103
+ * - `string`
104
+ * The given path will be used to create the database.
105
+ * Example: `./my-db.db3`
90
106
  */
91
107
  dbPath?: string | null;
92
108
  /**
@@ -111,26 +127,320 @@ type OtherOptions = {
111
127
  * Disable automatic registration when creating a client
112
128
  */
113
129
  disableAutoRegister?: boolean;
130
+ /**
131
+ * Disable device sync
132
+ */
133
+ disableDeviceSync?: boolean;
114
134
  };
115
135
  type ClientOptions = NetworkOptions & ContentOptions & StorageOptions & OtherOptions;
116
136
 
117
- type ClientEvents =
118
- /**
119
- * Stream actions
120
- */
121
- {
122
- action: "endStream";
123
- id: string;
124
- result: undefined;
125
- data: {
126
- streamId: string;
137
+ declare class WorkerConversations {
138
+ #private;
139
+ constructor(client: WorkerClient, conversations: Conversations$1);
140
+ sync(): Promise<void>;
141
+ syncAll(consentStates?: ConsentState[]): Promise<number>;
142
+ getConversationById(id: string): WorkerConversation | undefined;
143
+ getMessageById(id: string): Message | undefined;
144
+ getDmByInboxId(inboxId: string): WorkerConversation | undefined;
145
+ list(options?: SafeListConversationsOptions): WorkerConversation[];
146
+ listGroups(options?: Omit<SafeListConversationsOptions, "conversation_type">): WorkerConversation[];
147
+ listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">): WorkerConversation[];
148
+ newGroupOptimistic(options?: SafeCreateGroupOptions): WorkerConversation;
149
+ newGroupWithIdentifiers(identifiers: Identifier[], options?: SafeCreateGroupOptions): Promise<WorkerConversation>;
150
+ newGroup(inboxIds: string[], options?: SafeCreateGroupOptions): Promise<WorkerConversation>;
151
+ newDmWithIdentifier(identifier: Identifier, options?: SafeCreateDmOptions): Promise<WorkerConversation>;
152
+ newDm(inboxId: string, options?: SafeCreateDmOptions): Promise<WorkerConversation>;
153
+ getHmacKeys(): HmacKeys;
154
+ stream(callback?: StreamCallback<Conversation$1>, conversationType?: ConversationType): _xmtp_wasm_bindings.StreamCloser;
155
+ streamGroups(callback?: StreamCallback<Conversation$1>): _xmtp_wasm_bindings.StreamCloser;
156
+ streamDms(callback?: StreamCallback<Conversation$1>): _xmtp_wasm_bindings.StreamCloser;
157
+ streamAllMessages(callback?: StreamCallback<Message>, conversationType?: ConversationType, consentStates?: ConsentState[]): _xmtp_wasm_bindings.StreamCloser;
158
+ }
159
+
160
+ declare class WorkerPreferences {
161
+ #private;
162
+ constructor(client: Client$1, conversations: Conversations$1);
163
+ sync(): Promise<number>;
164
+ inboxState(refreshFromNetwork: boolean): Promise<_xmtp_wasm_bindings.InboxState>;
165
+ inboxStateFromInboxIds(inboxIds: string[], refreshFromNetwork?: boolean): Promise<_xmtp_wasm_bindings.InboxState[]>;
166
+ getLatestInboxState(inboxId: string): Promise<_xmtp_wasm_bindings.InboxState>;
167
+ setConsentStates(records: SafeConsent[]): Promise<void>;
168
+ getConsentState(entityType: ConsentEntityType, entity: string): Promise<_xmtp_wasm_bindings.ConsentState>;
169
+ streamConsent(callback?: StreamCallback<Consent[]>): _xmtp_wasm_bindings.StreamCloser;
170
+ streamPreferences(callback?: StreamCallback<UserPreference[]>): _xmtp_wasm_bindings.StreamCloser;
171
+ }
172
+
173
+ declare class WorkerClient {
174
+ #private;
175
+ constructor(client: Client$1, options?: ClientOptions);
176
+ static create(identifier: Identifier, options?: Omit<ClientOptions, "codecs">): Promise<WorkerClient>;
177
+ get accountIdentifier(): Identifier;
178
+ get inboxId(): string;
179
+ get installationId(): string;
180
+ get installationIdBytes(): Uint8Array<ArrayBufferLike>;
181
+ get isRegistered(): boolean;
182
+ get conversations(): WorkerConversations;
183
+ get preferences(): WorkerPreferences;
184
+ createInboxSignatureText(): string | undefined;
185
+ addAccountSignatureText(identifier: Identifier): Promise<string | undefined>;
186
+ removeAccountSignatureText(identifier: Identifier): Promise<string | undefined>;
187
+ revokeAllAOtherInstallationsSignatureText(): Promise<string | undefined>;
188
+ revokeInstallationsSignatureText(installationIds: Uint8Array[]): Promise<string | undefined>;
189
+ changeRecoveryIdentifierSignatureText(identifier: Identifier): Promise<string | undefined>;
190
+ addEcdsaSignature(type: SignatureRequestType, bytes: Uint8Array): Promise<void>;
191
+ addScwSignature(type: SignatureRequestType, bytes: Uint8Array, chainId: bigint, blockNumber?: bigint): Promise<void>;
192
+ applySignatures(): Promise<void>;
193
+ canMessage(identifiers: Identifier[]): Promise<Map<string, boolean>>;
194
+ registerIdentity(): Promise<void>;
195
+ findInboxIdByIdentifier(identifier: Identifier): Promise<string | undefined>;
196
+ signWithInstallationKey(signatureText: string): Uint8Array<ArrayBufferLike>;
197
+ verifySignedWithInstallationKey(signatureText: string, signatureBytes: Uint8Array): boolean;
198
+ verifySignedWithPublicKey(signatureText: string, signatureBytes: Uint8Array, publicKey: Uint8Array): boolean;
199
+ getKeyPackageStatusesForInstallationIds(installationIds: string[]): Promise<Map<string, KeyPackageStatus>>;
200
+ apiStatistics(): _xmtp_wasm_bindings.ApiStats;
201
+ apiIdentityStatistics(): _xmtp_wasm_bindings.IdentityStats;
202
+ apiAggregateStatistics(): string;
203
+ uploadDebugArchive(serverUrl?: string): Promise<string>;
204
+ }
205
+
206
+ declare class WorkerConversation {
207
+ #private;
208
+ constructor(client: WorkerClient, group: Conversation$1);
209
+ get id(): string;
210
+ get name(): string;
211
+ updateName(name: string): Promise<void>;
212
+ get imageUrl(): string;
213
+ updateImageUrl(imageUrl: string): Promise<void>;
214
+ get description(): string;
215
+ updateDescription(description: string): Promise<void>;
216
+ get isActive(): boolean;
217
+ get addedByInboxId(): string;
218
+ get createdAtNs(): bigint;
219
+ metadata(): Promise<{
220
+ creatorInboxId: string;
221
+ conversationType: string;
222
+ }>;
223
+ members(): Promise<SafeGroupMember[]>;
224
+ get admins(): string[];
225
+ get superAdmins(): string[];
226
+ get permissions(): {
227
+ policyType: _xmtp_wasm_bindings.GroupPermissionsOptions;
228
+ policySet: _xmtp_wasm_bindings.PermissionPolicySet;
127
229
  };
230
+ updatePermission(permissionType: PermissionUpdateType, policy: PermissionPolicy, metadataField?: MetadataField): Promise<void>;
231
+ isAdmin(inboxId: string): boolean;
232
+ isSuperAdmin(inboxId: string): boolean;
233
+ sync(): Promise<void>;
234
+ addMembersByIdentifiers(identifiers: Identifier[]): Promise<void>;
235
+ addMembers(inboxIds: string[]): Promise<void>;
236
+ removeMembersByIdentifiers(identifiers: Identifier[]): Promise<void>;
237
+ removeMembers(inboxIds: string[]): Promise<void>;
238
+ addAdmin(inboxId: string): Promise<void>;
239
+ removeAdmin(inboxId: string): Promise<void>;
240
+ addSuperAdmin(inboxId: string): Promise<void>;
241
+ removeSuperAdmin(inboxId: string): Promise<void>;
242
+ publishMessages(): Promise<void>;
243
+ sendOptimistic(encodedContent: EncodedContent): string;
244
+ send(encodedContent: EncodedContent): Promise<string>;
245
+ messages(options?: SafeListMessagesOptions): Promise<Message[]>;
246
+ get consentState(): ConsentState;
247
+ updateConsentState(state: ConsentState): void;
248
+ dmPeerInboxId(): string;
249
+ messageDisappearingSettings(): MessageDisappearingSettings | undefined;
250
+ updateMessageDisappearingSettings(fromNs: bigint, inNs: bigint): Promise<void>;
251
+ removeMessageDisappearingSettings(): Promise<void>;
252
+ isMessageDisappearingEnabled(): boolean;
253
+ stream(callback?: StreamCallback<Message>): _xmtp_wasm_bindings.StreamCloser;
254
+ pausedForVersion(): string | undefined;
255
+ getHmacKeys(): Map<string, HmacKey[]>;
256
+ debugInfo(): Promise<ConversationDebugInfo>;
257
+ getDuplicateDms(): Promise<WorkerConversation[]>;
128
258
  }
129
- /**
130
- * Client actions
131
- */
132
- | {
133
- action: "init";
259
+
260
+ declare const toContentTypeId: (contentTypeId: ContentTypeId) => ContentTypeId$1;
261
+ declare const fromContentTypeId: (contentTypeId: ContentTypeId$1) => ContentTypeId;
262
+ type SafeContentTypeId = {
263
+ authorityId: string;
264
+ typeId: string;
265
+ versionMajor: number;
266
+ versionMinor: number;
267
+ };
268
+ declare const toSafeContentTypeId: (contentTypeId: ContentTypeId$1) => SafeContentTypeId;
269
+ declare const fromSafeContentTypeId: (contentTypeId: SafeContentTypeId) => ContentTypeId$1;
270
+ declare const toEncodedContent: (content: EncodedContent) => EncodedContent$1;
271
+ declare const fromEncodedContent: (content: EncodedContent$1) => EncodedContent;
272
+ type SafeEncodedContent = {
273
+ type: SafeContentTypeId;
274
+ parameters: Record<string, string>;
275
+ fallback?: string;
276
+ compression?: number;
277
+ content: Uint8Array;
278
+ };
279
+ declare const toSafeEncodedContent: (content: EncodedContent$1) => SafeEncodedContent;
280
+ declare const fromSafeEncodedContent: (content: SafeEncodedContent) => EncodedContent$1;
281
+ type SafeMessage = {
282
+ content: SafeEncodedContent;
283
+ convoId: string;
284
+ deliveryStatus: DeliveryStatus;
285
+ id: string;
286
+ kind: GroupMessageKind;
287
+ senderInboxId: string;
288
+ sentAtNs: bigint;
289
+ };
290
+ declare const toSafeMessage: (message: Message) => SafeMessage;
291
+ type SafeListMessagesOptions = {
292
+ contentTypes?: ContentType[];
293
+ deliveryStatus?: DeliveryStatus;
294
+ direction?: SortDirection;
295
+ limit?: bigint;
296
+ sentAfterNs?: bigint;
297
+ sentBeforeNs?: bigint;
298
+ };
299
+ declare const toSafeListMessagesOptions: (options: ListMessagesOptions) => SafeListMessagesOptions;
300
+ declare const fromSafeListMessagesOptions: (options: SafeListMessagesOptions) => ListMessagesOptions;
301
+ type SafeListConversationsOptions = {
302
+ consentStates?: ConsentState[];
303
+ conversationType?: ConversationType;
304
+ createdAfterNs?: bigint;
305
+ createdBeforeNs?: bigint;
306
+ includeDuplicateDms?: boolean;
307
+ limit?: bigint;
308
+ };
309
+ declare const toSafeListConversationsOptions: (options: ListConversationsOptions) => SafeListConversationsOptions;
310
+ declare const fromSafeListConversationsOptions: (options: SafeListConversationsOptions) => ListConversationsOptions;
311
+ type SafePermissionPolicySet = {
312
+ addAdminPolicy: PermissionPolicy;
313
+ addMemberPolicy: PermissionPolicy;
314
+ removeAdminPolicy: PermissionPolicy;
315
+ removeMemberPolicy: PermissionPolicy;
316
+ updateGroupDescriptionPolicy: PermissionPolicy;
317
+ updateGroupImageUrlSquarePolicy: PermissionPolicy;
318
+ updateGroupNamePolicy: PermissionPolicy;
319
+ updateMessageDisappearingPolicy: PermissionPolicy;
320
+ };
321
+ declare const toSafePermissionPolicySet: (policySet: PermissionPolicySet) => SafePermissionPolicySet;
322
+ declare const fromSafePermissionPolicySet: (policySet: SafePermissionPolicySet) => PermissionPolicySet;
323
+ type SafeCreateGroupOptions = {
324
+ customPermissionPolicySet?: SafePermissionPolicySet;
325
+ description?: string;
326
+ imageUrlSquare?: string;
327
+ messageDisappearingSettings?: SafeMessageDisappearingSettings;
328
+ name?: string;
329
+ permissions?: GroupPermissionsOptions;
330
+ };
331
+ declare const toSafeCreateGroupOptions: (options: CreateGroupOptions) => SafeCreateGroupOptions;
332
+ declare const fromSafeCreateGroupOptions: (options: SafeCreateGroupOptions) => CreateGroupOptions;
333
+ type SafeCreateDmOptions = {
334
+ messageDisappearingSettings?: SafeMessageDisappearingSettings;
335
+ };
336
+ declare const toSafeCreateDmOptions: (options: CreateDMOptions) => SafeCreateDmOptions;
337
+ declare const fromSafeCreateDmOptions: (options: SafeCreateDmOptions) => CreateDMOptions;
338
+ type SafeConversation = {
339
+ id: string;
340
+ name: string;
341
+ imageUrl: string;
342
+ description: string;
343
+ permissions: {
344
+ policyType: GroupPermissionsOptions;
345
+ policySet: {
346
+ addAdminPolicy: PermissionPolicy;
347
+ addMemberPolicy: PermissionPolicy;
348
+ removeAdminPolicy: PermissionPolicy;
349
+ removeMemberPolicy: PermissionPolicy;
350
+ updateGroupDescriptionPolicy: PermissionPolicy;
351
+ updateGroupImageUrlSquarePolicy: PermissionPolicy;
352
+ updateGroupNamePolicy: PermissionPolicy;
353
+ updateMessageDisappearingPolicy: PermissionPolicy;
354
+ };
355
+ };
356
+ isActive: boolean;
357
+ addedByInboxId: string;
358
+ metadata: {
359
+ creatorInboxId: string;
360
+ conversationType: string;
361
+ };
362
+ admins: string[];
363
+ superAdmins: string[];
364
+ createdAtNs: bigint;
365
+ };
366
+ declare const toSafeConversation: (conversation: WorkerConversation) => Promise<SafeConversation>;
367
+ type SafeInstallation = {
368
+ bytes: Uint8Array;
369
+ clientTimestampNs?: bigint;
370
+ id: string;
371
+ };
372
+ declare const toSafeInstallation: (installation: Installation) => SafeInstallation;
373
+ type SafeInboxState = {
374
+ accountIdentifiers: Identifier[];
375
+ inboxId: string;
376
+ installations: SafeInstallation[];
377
+ recoveryIdentifier: Identifier;
378
+ };
379
+ declare const toSafeInboxState: (inboxState: InboxState) => SafeInboxState;
380
+ type SafeConsent = {
381
+ entity: string;
382
+ entityType: ConsentEntityType;
383
+ state: ConsentState;
384
+ };
385
+ declare const toSafeConsent: (consent: Consent) => SafeConsent;
386
+ declare const fromSafeConsent: (consent: SafeConsent) => Consent;
387
+ type SafeGroupMember = {
388
+ accountIdentifiers: Identifier[];
389
+ consentState: ConsentState;
390
+ inboxId: string;
391
+ installationIds: string[];
392
+ permissionLevel: PermissionLevel;
393
+ };
394
+ declare const toSafeGroupMember: (member: GroupMember) => SafeGroupMember;
395
+ declare const fromSafeGroupMember: (member: SafeGroupMember) => GroupMember;
396
+ type SafeHmacKey = {
397
+ key: Uint8Array;
398
+ epoch: bigint;
399
+ };
400
+ declare const toSafeHmacKey: (hmacKey: HmacKey) => SafeHmacKey;
401
+ type HmacKeys = Map<string, HmacKey[]>;
402
+ type SafeHmacKeys = Record<string, SafeHmacKey[]>;
403
+ type SafeMessageDisappearingSettings = {
404
+ fromNs: bigint;
405
+ inNs: bigint;
406
+ };
407
+ declare const toSafeMessageDisappearingSettings: (settings: MessageDisappearingSettings) => SafeMessageDisappearingSettings;
408
+ declare const fromSafeMessageDisappearingSettings: (settings: SafeMessageDisappearingSettings) => MessageDisappearingSettings;
409
+ type SafeKeyPackageStatus = {
410
+ lifetime?: {
411
+ notBefore: bigint;
412
+ notAfter: bigint;
413
+ };
414
+ validationError?: string;
415
+ };
416
+ declare const toSafeKeyPackageStatus: (status: KeyPackageStatus) => SafeKeyPackageStatus;
417
+ type SafeConversationDebugInfo = {
418
+ epoch: bigint;
419
+ maybeForked: boolean;
420
+ forkDetails: string;
421
+ };
422
+ declare const toSafeConversationDebugInfo: (debugInfo: ConversationDebugInfo) => SafeConversationDebugInfo;
423
+ type SafeApiStats = {
424
+ fetchKeyPackage: bigint;
425
+ queryGroupMessages: bigint;
426
+ queryWelcomeMessages: bigint;
427
+ sendGroupMessages: bigint;
428
+ sendWelcomeMessages: bigint;
429
+ subscribeMessages: bigint;
430
+ subscribeWelcomes: bigint;
431
+ uploadKeyPackage: bigint;
432
+ };
433
+ declare const toSafeApiStats: (stats: ApiStats) => SafeApiStats;
434
+ type SafeIdentityStats = {
435
+ getIdentityUpdatesV2: bigint;
436
+ getInboxIds: bigint;
437
+ publishIdentityUpdate: bigint;
438
+ verifySmartContractWalletSignature: bigint;
439
+ };
440
+ declare const toSafeIdentityStats: (stats: IdentityStats) => SafeIdentityStats;
441
+
442
+ type ClientAction = {
443
+ action: "client.init";
134
444
  id: string;
135
445
  result: {
136
446
  inboxId: string;
@@ -142,45 +452,45 @@ type ClientEvents =
142
452
  options?: ClientOptions;
143
453
  };
144
454
  } | {
145
- action: "createInboxSignatureText";
455
+ action: "client.createInboxSignatureText";
146
456
  id: string;
147
457
  result: string | undefined;
148
458
  data: undefined;
149
459
  } | {
150
- action: "addAccountSignatureText";
460
+ action: "client.addAccountSignatureText";
151
461
  id: string;
152
462
  result: string | undefined;
153
463
  data: {
154
464
  newIdentifier: Identifier;
155
465
  };
156
466
  } | {
157
- action: "removeAccountSignatureText";
467
+ action: "client.removeAccountSignatureText";
158
468
  id: string;
159
469
  result: string | undefined;
160
470
  data: {
161
471
  identifier: Identifier;
162
472
  };
163
473
  } | {
164
- action: "revokeAllOtherInstallationsSignatureText";
474
+ action: "client.revokeAllOtherInstallationsSignatureText";
165
475
  id: string;
166
476
  result: string | undefined;
167
477
  data: undefined;
168
478
  } | {
169
- action: "revokeInstallationsSignatureText";
479
+ action: "client.revokeInstallationsSignatureText";
170
480
  id: string;
171
481
  result: string | undefined;
172
482
  data: {
173
483
  installationIds: Uint8Array[];
174
484
  };
175
485
  } | {
176
- action: "changeRecoveryIdentifierSignatureText";
486
+ action: "client.changeRecoveryIdentifierSignatureText";
177
487
  id: string;
178
488
  result: string | undefined;
179
489
  data: {
180
490
  identifier: Identifier;
181
491
  };
182
492
  } | {
183
- action: "addEcdsaSignature";
493
+ action: "client.addEcdsaSignature";
184
494
  id: string;
185
495
  result: undefined;
186
496
  data: {
@@ -188,7 +498,7 @@ type ClientEvents =
188
498
  bytes: Uint8Array;
189
499
  };
190
500
  } | {
191
- action: "addScwSignature";
501
+ action: "client.addScwSignature";
192
502
  id: string;
193
503
  result: undefined;
194
504
  data: {
@@ -198,80 +508,43 @@ type ClientEvents =
198
508
  blockNumber?: bigint;
199
509
  };
200
510
  } | {
201
- action: "applySignatures";
511
+ action: "client.applySignatures";
202
512
  id: string;
203
513
  result: undefined;
204
514
  data: undefined;
205
515
  } | {
206
- action: "registerIdentity";
516
+ action: "client.registerIdentity";
207
517
  id: string;
208
518
  result: undefined;
209
519
  data: undefined;
210
520
  } | {
211
- action: "isRegistered";
521
+ action: "client.isRegistered";
212
522
  id: string;
213
523
  result: boolean;
214
524
  data: undefined;
215
525
  } | {
216
- action: "canMessage";
526
+ action: "client.canMessage";
217
527
  id: string;
218
528
  result: Map<string, boolean>;
219
529
  data: {
220
530
  identifiers: Identifier[];
221
531
  };
222
532
  } | {
223
- action: "inboxState";
224
- id: string;
225
- result: SafeInboxState;
226
- data: {
227
- refreshFromNetwork: boolean;
228
- };
229
- } | {
230
- action: "inboxStateFromInboxIds";
231
- id: string;
232
- result: SafeInboxState[];
233
- data: {
234
- inboxIds: string[];
235
- refreshFromNetwork: boolean;
236
- };
237
- } | {
238
- action: "getLatestInboxState";
239
- id: string;
240
- result: SafeInboxState;
241
- data: {
242
- inboxId: string;
243
- };
244
- } | {
245
- action: "setConsentStates";
246
- id: string;
247
- result: undefined;
248
- data: {
249
- records: SafeConsent[];
250
- };
251
- } | {
252
- action: "getConsentState";
253
- id: string;
254
- result: ConsentState;
255
- data: {
256
- entityType: ConsentEntityType;
257
- entity: string;
258
- };
259
- } | {
260
- action: "findInboxIdByIdentifier";
533
+ action: "client.findInboxIdByIdentifier";
261
534
  id: string;
262
535
  result: string | undefined;
263
536
  data: {
264
537
  identifier: Identifier;
265
538
  };
266
539
  } | {
267
- action: "signWithInstallationKey";
540
+ action: "client.signWithInstallationKey";
268
541
  id: string;
269
542
  result: Uint8Array;
270
543
  data: {
271
544
  signatureText: string;
272
545
  };
273
546
  } | {
274
- action: "verifySignedWithInstallationKey";
547
+ action: "client.verifySignedWithInstallationKey";
275
548
  id: string;
276
549
  result: boolean;
277
550
  data: {
@@ -279,7 +552,7 @@ type ClientEvents =
279
552
  signatureBytes: Uint8Array;
280
553
  };
281
554
  } | {
282
- action: "verifySignedWithPublicKey";
555
+ action: "client.verifySignedWithPublicKey";
283
556
  id: string;
284
557
  result: boolean;
285
558
  data: {
@@ -288,786 +561,570 @@ type ClientEvents =
288
561
  publicKey: Uint8Array;
289
562
  };
290
563
  } | {
291
- action: "getKeyPackageStatusesForInstallationIds";
564
+ action: "client.getKeyPackageStatusesForInstallationIds";
292
565
  id: string;
293
566
  result: Map<string, SafeKeyPackageStatus>;
294
567
  data: {
295
568
  installationIds: string[];
296
569
  };
297
- }
298
- /**
299
- * Conversations actions
300
- */
301
- | {
302
- action: "getConversationById";
570
+ } | {
571
+ action: "client.apiStatistics";
303
572
  id: string;
304
- result: SafeConversation | undefined;
305
- data: {
306
- id: string;
307
- };
573
+ result: SafeApiStats;
574
+ data: undefined;
308
575
  } | {
309
- action: "getMessageById";
576
+ action: "client.apiIdentityStatistics";
310
577
  id: string;
311
- result: SafeMessage | undefined;
312
- data: {
313
- id: string;
314
- };
578
+ result: SafeIdentityStats;
579
+ data: undefined;
315
580
  } | {
316
- action: "getDmByInboxId";
581
+ action: "client.apiAggregateStatistics";
317
582
  id: string;
318
- result: SafeConversation | undefined;
319
- data: {
320
- inboxId: string;
321
- };
583
+ result: string;
584
+ data: undefined;
322
585
  } | {
323
- action: "getConversations";
586
+ action: "client.uploadDebugArchive";
324
587
  id: string;
325
- result: SafeConversation[];
588
+ result: string;
326
589
  data: {
327
- options?: SafeListConversationsOptions;
590
+ serverUrl?: string;
328
591
  };
329
- } | {
330
- action: "getGroups";
592
+ };
593
+
594
+ type ConversationAction = {
595
+ action: "conversation.sync";
331
596
  id: string;
332
- result: SafeConversation[];
597
+ result: SafeConversation;
333
598
  data: {
334
- options?: Omit<SafeListConversationsOptions, "conversation_type">;
599
+ id: string;
335
600
  };
336
601
  } | {
337
- action: "getDms";
602
+ action: "conversation.send";
338
603
  id: string;
339
- result: SafeConversation[];
604
+ result: string;
340
605
  data: {
341
- options?: Omit<SafeListConversationsOptions, "conversation_type">;
606
+ id: string;
607
+ content: SafeEncodedContent;
342
608
  };
343
609
  } | {
344
- action: "newGroupWithIdentifiers";
610
+ action: "conversation.sendOptimistic";
345
611
  id: string;
346
- result: SafeConversation;
612
+ result: string;
347
613
  data: {
348
- identifiers: Identifier[];
349
- options?: SafeCreateGroupOptions;
614
+ id: string;
615
+ content: SafeEncodedContent;
350
616
  };
351
617
  } | {
352
- action: "newGroupWithInboxIds";
618
+ action: "conversation.publishMessages";
353
619
  id: string;
354
- result: SafeConversation;
620
+ result: undefined;
355
621
  data: {
356
- inboxIds: string[];
357
- options?: SafeCreateGroupOptions;
622
+ id: string;
358
623
  };
359
624
  } | {
360
- action: "newDmWithIdentifier";
625
+ action: "conversation.messages";
361
626
  id: string;
362
- result: SafeConversation;
627
+ result: SafeMessage[];
363
628
  data: {
364
- identifier: Identifier;
365
- options?: SafeCreateDmOptions;
629
+ id: string;
630
+ options?: SafeListMessagesOptions;
366
631
  };
367
632
  } | {
368
- action: "newDmWithInboxId";
633
+ action: "conversation.members";
369
634
  id: string;
370
- result: SafeConversation;
635
+ result: SafeGroupMember[];
371
636
  data: {
372
- inboxId: string;
373
- options?: SafeCreateDmOptions;
637
+ id: string;
374
638
  };
375
639
  } | {
376
- action: "syncConversations";
377
- id: string;
378
- result: undefined;
379
- data: undefined;
380
- } | {
381
- action: "syncAllConversations";
640
+ action: "conversation.messageDisappearingSettings";
382
641
  id: string;
383
- result: undefined;
642
+ result: SafeMessageDisappearingSettings | undefined;
384
643
  data: {
385
- consentStates?: ConsentState[];
644
+ id: string;
386
645
  };
387
646
  } | {
388
- action: "getHmacKeys";
389
- id: string;
390
- result: SafeHmacKeys;
391
- data: undefined;
392
- } | {
393
- action: "streamAllGroups";
647
+ action: "conversation.updateMessageDisappearingSettings";
394
648
  id: string;
395
649
  result: undefined;
396
- data: {
397
- streamId: string;
398
- conversationType?: ConversationType;
650
+ data: SafeMessageDisappearingSettings & {
651
+ id: string;
399
652
  };
400
653
  } | {
401
- action: "streamAllMessages";
654
+ action: "conversation.removeMessageDisappearingSettings";
402
655
  id: string;
403
656
  result: undefined;
404
657
  data: {
405
- streamId: string;
406
- conversationType?: ConversationType;
658
+ id: string;
407
659
  };
408
660
  } | {
409
- action: "streamConsent";
661
+ action: "conversation.isMessageDisappearingEnabled";
410
662
  id: string;
411
- result: undefined;
663
+ result: boolean;
412
664
  data: {
413
- streamId: string;
665
+ id: string;
414
666
  };
415
667
  } | {
416
- action: "streamPreferences";
668
+ action: "conversation.stream";
417
669
  id: string;
418
670
  result: undefined;
419
671
  data: {
672
+ groupId: string;
420
673
  streamId: string;
421
674
  };
422
- }
423
- /**
424
- * Group actions
425
- */
426
- | {
427
- action: "syncGroup";
428
- id: string;
429
- result: SafeConversation;
430
- data: {
431
- id: string;
432
- };
433
675
  } | {
434
- action: "sendGroupMessage";
676
+ action: "conversation.pausedForVersion";
435
677
  id: string;
436
- result: string;
678
+ result: string | undefined;
437
679
  data: {
438
680
  id: string;
439
- content: SafeEncodedContent;
440
681
  };
441
682
  } | {
442
- action: "sendOptimisticGroupMessage";
683
+ action: "conversation.getHmacKeys";
443
684
  id: string;
444
- result: string;
685
+ result: Map<string, SafeHmacKey[]>;
445
686
  data: {
446
687
  id: string;
447
- content: SafeEncodedContent;
448
688
  };
449
689
  } | {
450
- action: "publishGroupMessages";
690
+ action: "conversation.debugInfo";
451
691
  id: string;
452
- result: undefined;
692
+ result: SafeConversationDebugInfo;
453
693
  data: {
454
694
  id: string;
455
695
  };
456
696
  } | {
457
- action: "getGroupMessages";
697
+ action: "conversation.consentState";
458
698
  id: string;
459
- result: SafeMessage[];
699
+ result: ConsentState;
460
700
  data: {
461
701
  id: string;
462
- options?: SafeListMessagesOptions;
463
702
  };
464
703
  } | {
465
- action: "getGroupMembers";
704
+ action: "conversation.updateConsentState";
466
705
  id: string;
467
- result: SafeGroupMember[];
706
+ result: undefined;
468
707
  data: {
469
708
  id: string;
709
+ state: ConsentState;
470
710
  };
471
- } | {
472
- action: "getGroupAdmins";
711
+ };
712
+
713
+ type ConversationsAction = {
714
+ action: "conversations.getConversationById";
473
715
  id: string;
474
- result: string[];
716
+ result: SafeConversation | undefined;
475
717
  data: {
476
718
  id: string;
477
719
  };
478
720
  } | {
479
- action: "getGroupSuperAdmins";
721
+ action: "conversations.getMessageById";
480
722
  id: string;
481
- result: string[];
723
+ result: SafeMessage | undefined;
482
724
  data: {
483
725
  id: string;
484
726
  };
485
727
  } | {
486
- action: "isGroupAdmin";
728
+ action: "conversations.getDmByInboxId";
487
729
  id: string;
488
- result: boolean;
730
+ result: SafeConversation | undefined;
489
731
  data: {
490
- id: string;
491
732
  inboxId: string;
492
733
  };
493
734
  } | {
494
- action: "isGroupSuperAdmin";
735
+ action: "conversations.list";
495
736
  id: string;
496
- result: boolean;
737
+ result: SafeConversation[];
497
738
  data: {
498
- id: string;
499
- inboxId: string;
739
+ options?: SafeListConversationsOptions;
500
740
  };
501
741
  } | {
502
- action: "addGroupMembers";
742
+ action: "conversations.listGroups";
503
743
  id: string;
504
- result: undefined;
744
+ result: SafeConversation[];
505
745
  data: {
506
- id: string;
507
- identifiers: Identifier[];
746
+ options?: Omit<SafeListConversationsOptions, "conversation_type">;
508
747
  };
509
748
  } | {
510
- action: "removeGroupMembers";
749
+ action: "conversations.listDms";
511
750
  id: string;
512
- result: undefined;
751
+ result: SafeConversation[];
513
752
  data: {
514
- id: string;
515
- identifiers: Identifier[];
753
+ options?: Omit<SafeListConversationsOptions, "conversation_type">;
516
754
  };
517
755
  } | {
518
- action: "addGroupMembersByInboxId";
756
+ action: "conversations.newGroupOptimistic";
519
757
  id: string;
520
- result: undefined;
758
+ result: SafeConversation;
521
759
  data: {
522
- id: string;
523
- inboxIds: string[];
760
+ options?: SafeCreateGroupOptions;
524
761
  };
525
762
  } | {
526
- action: "removeGroupMembersByInboxId";
763
+ action: "conversations.newGroupWithIdentifiers";
527
764
  id: string;
528
- result: undefined;
765
+ result: SafeConversation;
529
766
  data: {
530
- id: string;
531
- inboxIds: string[];
767
+ identifiers: Identifier[];
768
+ options?: SafeCreateGroupOptions;
532
769
  };
533
770
  } | {
534
- action: "addGroupAdmin";
771
+ action: "conversations.newGroup";
535
772
  id: string;
536
- result: undefined;
773
+ result: SafeConversation;
537
774
  data: {
538
- id: string;
539
- inboxId: string;
775
+ inboxIds: string[];
776
+ options?: SafeCreateGroupOptions;
540
777
  };
541
778
  } | {
542
- action: "removeGroupAdmin";
779
+ action: "conversations.newDmWithIdentifier";
543
780
  id: string;
544
- result: undefined;
781
+ result: SafeConversation;
545
782
  data: {
546
- id: string;
547
- inboxId: string;
783
+ identifier: Identifier;
784
+ options?: SafeCreateDmOptions;
548
785
  };
549
786
  } | {
550
- action: "addGroupSuperAdmin";
787
+ action: "conversations.newDm";
551
788
  id: string;
552
- result: undefined;
789
+ result: SafeConversation;
553
790
  data: {
554
- id: string;
555
791
  inboxId: string;
792
+ options?: SafeCreateDmOptions;
556
793
  };
557
794
  } | {
558
- action: "removeGroupSuperAdmin";
795
+ action: "conversations.sync";
559
796
  id: string;
560
797
  result: undefined;
561
- data: {
562
- id: string;
563
- inboxId: string;
564
- };
798
+ data: undefined;
565
799
  } | {
566
- action: "updateGroupName";
800
+ action: "conversations.syncAll";
567
801
  id: string;
568
802
  result: undefined;
569
803
  data: {
570
- id: string;
571
- name: string;
804
+ consentStates?: ConsentState[];
572
805
  };
573
806
  } | {
574
- action: "updateGroupDescription";
807
+ action: "conversations.getHmacKeys";
575
808
  id: string;
576
- result: undefined;
577
- data: {
578
- id: string;
579
- description: string;
580
- };
809
+ result: SafeHmacKeys;
810
+ data: undefined;
581
811
  } | {
582
- action: "updateGroupImageUrlSquare";
812
+ action: "conversations.stream";
583
813
  id: string;
584
814
  result: undefined;
585
815
  data: {
586
- id: string;
587
- imageUrl: string;
588
- };
589
- } | {
590
- action: "getGroupConsentState";
591
- id: string;
592
- result: ConsentState;
593
- data: {
594
- id: string;
816
+ streamId: string;
817
+ conversationType?: ConversationType;
595
818
  };
596
819
  } | {
597
- action: "updateGroupConsentState";
820
+ action: "conversations.streamAllMessages";
598
821
  id: string;
599
822
  result: undefined;
600
823
  data: {
601
- id: string;
602
- state: ConsentState;
603
- };
604
- } | {
605
- action: "getDmPeerInboxId";
606
- id: string;
607
- result: string;
608
- data: {
609
- id: string;
824
+ streamId: string;
825
+ conversationType?: ConversationType;
826
+ consentStates?: ConsentState[];
610
827
  };
611
- } | {
612
- action: "updateGroupPermissionPolicy";
828
+ };
829
+
830
+ type DmAction = {
831
+ action: "dm.peerInboxId";
613
832
  id: string;
614
- result: undefined;
833
+ result: string;
615
834
  data: {
616
835
  id: string;
617
- permissionType: PermissionUpdateType;
618
- policy: PermissionPolicy;
619
- metadataField?: MetadataField;
620
836
  };
621
837
  } | {
622
- action: "getGroupPermissions";
838
+ action: "dm.getDuplicateDms";
623
839
  id: string;
624
- result: SafeConversation["permissions"];
840
+ result: SafeConversation[];
625
841
  data: {
626
842
  id: string;
627
843
  };
628
- } | {
629
- action: "getGroupMessageDisappearingSettings";
844
+ };
845
+
846
+ type GroupAction = {
847
+ action: "group.listAdmins";
630
848
  id: string;
631
- result: SafeMessageDisappearingSettings | undefined;
849
+ result: string[];
632
850
  data: {
633
851
  id: string;
634
852
  };
635
853
  } | {
636
- action: "updateGroupMessageDisappearingSettings";
854
+ action: "group.listSuperAdmins";
637
855
  id: string;
638
- result: undefined;
639
- data: SafeMessageDisappearingSettings & {
856
+ result: string[];
857
+ data: {
640
858
  id: string;
641
859
  };
642
860
  } | {
643
- action: "removeGroupMessageDisappearingSettings";
861
+ action: "group.isAdmin";
644
862
  id: string;
645
- result: undefined;
863
+ result: boolean;
646
864
  data: {
647
865
  id: string;
866
+ inboxId: string;
648
867
  };
649
868
  } | {
650
- action: "isGroupMessageDisappearingEnabled";
869
+ action: "group.isSuperAdmin";
651
870
  id: string;
652
871
  result: boolean;
653
872
  data: {
654
873
  id: string;
874
+ inboxId: string;
655
875
  };
656
876
  } | {
657
- action: "streamGroupMessages";
877
+ action: "group.addMembersByIdentifiers";
658
878
  id: string;
659
879
  result: undefined;
660
880
  data: {
661
- groupId: string;
662
- streamId: string;
881
+ id: string;
882
+ identifiers: Identifier[];
663
883
  };
664
884
  } | {
665
- action: "getGroupPausedForVersion";
885
+ action: "group.removeMembersByIdentifiers";
666
886
  id: string;
667
- result: string | undefined;
887
+ result: undefined;
668
888
  data: {
669
889
  id: string;
890
+ identifiers: Identifier[];
670
891
  };
671
892
  } | {
672
- action: "getGroupHmacKeys";
893
+ action: "group.addMembers";
673
894
  id: string;
674
- result: SafeHmacKey[];
895
+ result: undefined;
675
896
  data: {
676
897
  id: string;
898
+ inboxIds: string[];
677
899
  };
678
- };
679
- type ClientEventsActions = ClientEvents["action"];
680
- type ClientEventsClientMessageData = EventsClientMessageData<ClientEvents>;
681
- type ClientEventsWorkerMessageData = EventsWorkerMessageData<ClientEvents>;
682
- type ClientEventsResult<A extends ClientEventsActions> = EventsResult<ClientEvents, A>;
683
- type ClientSendMessageData<A extends ClientEventsActions> = SendMessageData<ClientEvents, A>;
684
- type ClientEventsWorkerPostMessageData<A extends ClientEventsActions> = EventsWorkerPostMessageData<ClientEvents, A>;
685
- type ClientEventsClientPostMessageData<A extends ClientEventsActions> = EventsClientPostMessageData<ClientEvents, A>;
686
- type ClientEventsErrorData = EventsErrorData<ClientEvents>;
687
-
688
- type UtilsEvents = {
689
- action: "init";
900
+ } | {
901
+ action: "group.removeMembers";
690
902
  id: string;
691
903
  result: undefined;
692
904
  data: {
693
- enableLogging: boolean;
905
+ id: string;
906
+ inboxIds: string[];
694
907
  };
695
908
  } | {
696
- action: "generateInboxId";
909
+ action: "group.addAdmin";
697
910
  id: string;
698
- result: string;
911
+ result: undefined;
699
912
  data: {
700
- identifier: Identifier;
913
+ id: string;
914
+ inboxId: string;
701
915
  };
702
916
  } | {
703
- action: "getInboxIdForIdentifier";
917
+ action: "group.removeAdmin";
704
918
  id: string;
705
- result: string | undefined;
919
+ result: undefined;
706
920
  data: {
707
- identifier: Identifier;
708
- env?: XmtpEnv;
921
+ id: string;
922
+ inboxId: string;
709
923
  };
710
- };
711
- type UtilsEventsActions = UtilsEvents["action"];
712
- type UtilsEventsClientMessageData = EventsClientMessageData<UtilsEvents>;
713
- type UtilsEventsWorkerMessageData = EventsWorkerMessageData<UtilsEvents>;
714
- type UtilsEventsResult<A extends UtilsEventsActions> = EventsResult<UtilsEvents, A>;
715
- type UtilsSendMessageData<A extends UtilsEventsActions> = SendMessageData<UtilsEvents, A>;
716
- type UtilsEventsWorkerPostMessageData<A extends UtilsEventsActions> = EventsWorkerPostMessageData<UtilsEvents, A>;
717
- type UtilsEventsClientPostMessageData<A extends UtilsEventsActions> = EventsClientPostMessageData<UtilsEvents, A>;
718
- type UtilsEventsErrorData = EventsErrorData<UtilsEvents>;
719
-
720
- type GenericEvent = {
721
- action: string;
924
+ } | {
925
+ action: "group.addSuperAdmin";
722
926
  id: string;
723
- result: unknown;
724
- data: unknown;
725
- };
726
- type EventsClientMessageData<Events extends GenericEvent> = {
727
- [Action in Events["action"]]: Omit<Extract<Events, {
728
- action: Action;
729
- }>, "result">;
730
- }[Events["action"]];
731
- type EventsWorkerMessageData<Events extends GenericEvent> = {
732
- [Action in Events["action"]]: Omit<Extract<Events, {
733
- action: Action;
734
- }>, "data">;
735
- }[Events["action"]];
736
- type EventsResult<Events extends GenericEvent, Action extends Events["action"]> = Extract<Events, {
737
- action: Action;
738
- }>["result"];
739
- type SendMessageData<Events extends GenericEvent, Action extends Events["action"]> = Extract<Events, {
740
- action: Action;
741
- }>["data"];
742
- type EventsWorkerPostMessageData<Events extends GenericEvent, Action extends Events["action"]> = Omit<Extract<Events, {
743
- action: Action;
744
- }>, "data">;
745
- type EventsClientPostMessageData<Events extends GenericEvent, Action extends Events["action"]> = Omit<Extract<Events, {
746
- action: Action;
747
- }>, "result">;
748
- type EventsErrorData<Events extends GenericEvent> = {
749
- id: string;
750
- action: Events["action"];
751
- error: Error;
752
- };
753
- type GenericStreamEvent = {
754
- type: string;
755
- streamId: string;
756
- result: unknown;
757
- };
758
- type StreamEventsClientMessageData<Events extends GenericStreamEvent> = {
759
- [Type in Events["type"]]: Omit<Extract<Events, {
760
- type: Type;
761
- }>, "result">;
762
- }[Events["type"]];
763
- type StreamEventsResult<Events extends GenericStreamEvent, Type extends Events["type"]> = Extract<Events, {
764
- type: Type;
765
- }>["result"];
766
- type StreamEventsClientPostMessageData<Events extends GenericStreamEvent, Type extends Events["type"]> = Extract<Events, {
767
- type: Type;
768
- }>;
769
- type StreamEventsErrorData<Events extends GenericStreamEvent> = {
770
- streamId: string;
771
- type: Events["type"];
772
- error: Error;
773
- };
774
-
775
- declare class WorkerConversations {
776
- #private;
777
- constructor(client: WorkerClient, conversations: Conversations$1);
778
- sync(): Promise<void>;
779
- syncAll(consentStates?: ConsentState[]): Promise<number>;
780
- getConversationById(id: string): WorkerConversation | undefined;
781
- getMessageById(id: string): Message | undefined;
782
- getDmByInboxId(inboxId: string): WorkerConversation | undefined;
783
- list(options?: SafeListConversationsOptions): WorkerConversation[];
784
- listGroups(options?: Omit<SafeListConversationsOptions, "conversation_type">): WorkerConversation[];
785
- listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">): WorkerConversation[];
786
- newGroupWithIdentifiers(identifiers: Identifier[], options?: SafeCreateGroupOptions): Promise<WorkerConversation>;
787
- newGroup(inboxIds: string[], options?: SafeCreateGroupOptions): Promise<WorkerConversation>;
788
- newDmWithIdentifier(identifier: Identifier, options?: SafeCreateDmOptions): Promise<WorkerConversation>;
789
- newDm(inboxId: string, options?: SafeCreateDmOptions): Promise<WorkerConversation>;
790
- getHmacKeys(): HmacKeys;
791
- stream(callback?: StreamCallback<Conversation$1>, conversationType?: ConversationType): _xmtp_wasm_bindings.StreamCloser;
792
- streamGroups(callback?: StreamCallback<Conversation$1>): _xmtp_wasm_bindings.StreamCloser;
793
- streamDms(callback?: StreamCallback<Conversation$1>): _xmtp_wasm_bindings.StreamCloser;
794
- streamAllMessages(callback?: StreamCallback<Message>, conversationType?: ConversationType): _xmtp_wasm_bindings.StreamCloser;
795
- }
796
-
797
- declare class WorkerPreferences {
798
- #private;
799
- constructor(client: Client$1, conversations: Conversations$1);
800
- inboxState(refreshFromNetwork: boolean): Promise<_xmtp_wasm_bindings.InboxState>;
801
- inboxStateFromInboxIds(inboxIds: string[], refreshFromNetwork?: boolean): Promise<_xmtp_wasm_bindings.InboxState[]>;
802
- getLatestInboxState(inboxId: string): Promise<_xmtp_wasm_bindings.InboxState>;
803
- setConsentStates(records: SafeConsent[]): Promise<void>;
804
- getConsentState(entityType: ConsentEntityType, entity: string): Promise<_xmtp_wasm_bindings.ConsentState>;
805
- streamConsent(callback?: StreamCallback<Consent[]>): _xmtp_wasm_bindings.StreamCloser;
806
- streamPreferences(callback?: StreamCallback<UserPreference[]>): _xmtp_wasm_bindings.StreamCloser;
807
- }
808
-
809
- declare class WorkerClient {
810
- #private;
811
- constructor(client: Client$1);
812
- static create(identifier: Identifier, options?: Omit<ClientOptions, "codecs">): Promise<WorkerClient>;
813
- get accountIdentifier(): Identifier;
814
- get inboxId(): string;
815
- get installationId(): string;
816
- get installationIdBytes(): Uint8Array<ArrayBufferLike>;
817
- get isRegistered(): boolean;
818
- get conversations(): WorkerConversations;
819
- get preferences(): WorkerPreferences;
820
- createInboxSignatureText(): string | undefined;
821
- addAccountSignatureText(identifier: Identifier): Promise<string | undefined>;
822
- removeAccountSignatureText(identifier: Identifier): Promise<string | undefined>;
823
- revokeAllAOtherInstallationsSignatureText(): Promise<string | undefined>;
824
- revokeInstallationsSignatureText(installationIds: Uint8Array[]): Promise<string | undefined>;
825
- changeRecoveryIdentifierSignatureText(identifier: Identifier): Promise<string | undefined>;
826
- addEcdsaSignature(type: SignatureRequestType, bytes: Uint8Array): Promise<void>;
827
- addScwSignature(type: SignatureRequestType, bytes: Uint8Array, chainId: bigint, blockNumber?: bigint): Promise<void>;
828
- applySignatures(): Promise<void>;
829
- canMessage(identifiers: Identifier[]): Promise<Map<string, boolean>>;
830
- registerIdentity(): Promise<void>;
831
- findInboxIdByIdentifier(identifier: Identifier): Promise<string | undefined>;
832
- signWithInstallationKey(signatureText: string): Uint8Array<ArrayBufferLike>;
833
- verifySignedWithInstallationKey(signatureText: string, signatureBytes: Uint8Array): boolean;
834
- verifySignedWithPublicKey(signatureText: string, signatureBytes: Uint8Array, publicKey: Uint8Array): boolean;
835
- getKeyPackageStatusesForInstallationIds(installationIds: string[]): Promise<Map<string, KeyPackageStatus>>;
836
- }
837
-
838
- declare class WorkerConversation {
839
- #private;
840
- constructor(client: WorkerClient, group: Conversation$1);
841
- get id(): string;
842
- get name(): string;
843
- updateName(name: string): Promise<void>;
844
- get imageUrl(): string;
845
- updateImageUrl(imageUrl: string): Promise<void>;
846
- get description(): string;
847
- updateDescription(description: string): Promise<void>;
848
- get isActive(): boolean;
849
- get addedByInboxId(): string;
850
- get createdAtNs(): bigint;
851
- metadata(): Promise<{
852
- creatorInboxId: string;
853
- conversationType: string;
854
- }>;
855
- members(): Promise<SafeGroupMember[]>;
856
- get admins(): string[];
857
- get superAdmins(): string[];
858
- get permissions(): {
859
- policyType: _xmtp_wasm_bindings.GroupPermissionsOptions;
860
- policySet: _xmtp_wasm_bindings.PermissionPolicySet;
927
+ result: undefined;
928
+ data: {
929
+ id: string;
930
+ inboxId: string;
861
931
  };
862
- updatePermission(permissionType: PermissionUpdateType, policy: PermissionPolicy, metadataField?: MetadataField): Promise<void>;
863
- isAdmin(inboxId: string): boolean;
864
- isSuperAdmin(inboxId: string): boolean;
865
- sync(): Promise<void>;
866
- addMembersByIdentifiers(identifiers: Identifier[]): Promise<void>;
867
- addMembers(inboxIds: string[]): Promise<void>;
868
- removeMembersByIdentifiers(identifiers: Identifier[]): Promise<void>;
869
- removeMembers(inboxIds: string[]): Promise<void>;
870
- addAdmin(inboxId: string): Promise<void>;
871
- removeAdmin(inboxId: string): Promise<void>;
872
- addSuperAdmin(inboxId: string): Promise<void>;
873
- removeSuperAdmin(inboxId: string): Promise<void>;
874
- publishMessages(): Promise<void>;
875
- sendOptimistic(encodedContent: EncodedContent): string;
876
- send(encodedContent: EncodedContent): Promise<string>;
877
- messages(options?: SafeListMessagesOptions): Promise<Message[]>;
878
- get consentState(): ConsentState;
879
- updateConsentState(state: ConsentState): void;
880
- dmPeerInboxId(): string;
881
- messageDisappearingSettings(): MessageDisappearingSettings | undefined;
882
- updateMessageDisappearingSettings(fromNs: bigint, inNs: bigint): Promise<void>;
883
- removeMessageDisappearingSettings(): Promise<void>;
884
- isMessageDisappearingEnabled(): boolean;
885
- stream(callback?: StreamCallback<Message>): _xmtp_wasm_bindings.StreamCloser;
886
- pausedForVersion(): string | undefined;
887
- getHmacKeys(): HmacKey[];
888
- }
889
-
890
- declare const toContentTypeId: (contentTypeId: ContentTypeId) => ContentTypeId$1;
891
- declare const fromContentTypeId: (contentTypeId: ContentTypeId$1) => ContentTypeId;
892
- type SafeContentTypeId = {
893
- authorityId: string;
894
- typeId: string;
895
- versionMajor: number;
896
- versionMinor: number;
897
- };
898
- declare const toSafeContentTypeId: (contentTypeId: ContentTypeId$1) => SafeContentTypeId;
899
- declare const fromSafeContentTypeId: (contentTypeId: SafeContentTypeId) => ContentTypeId$1;
900
- declare const toEncodedContent: (content: EncodedContent) => EncodedContent$1;
901
- declare const fromEncodedContent: (content: EncodedContent$1) => EncodedContent;
902
- type SafeEncodedContent = {
903
- type: SafeContentTypeId;
904
- parameters: Record<string, string>;
905
- fallback?: string;
906
- compression?: number;
907
- content: Uint8Array;
908
- };
909
- declare const toSafeEncodedContent: (content: EncodedContent$1) => SafeEncodedContent;
910
- declare const fromSafeEncodedContent: (content: SafeEncodedContent) => EncodedContent$1;
911
- type SafeMessage = {
912
- content: SafeEncodedContent;
913
- convoId: string;
914
- deliveryStatus: DeliveryStatus;
915
- id: string;
916
- kind: GroupMessageKind;
917
- senderInboxId: string;
918
- sentAtNs: bigint;
919
- };
920
- declare const toSafeMessage: (message: Message) => SafeMessage;
921
- type SafeListMessagesOptions = {
922
- contentTypes?: ContentType[];
923
- deliveryStatus?: DeliveryStatus;
924
- direction?: SortDirection;
925
- limit?: bigint;
926
- sentAfterNs?: bigint;
927
- sentBeforeNs?: bigint;
928
- };
929
- declare const toSafeListMessagesOptions: (options: ListMessagesOptions) => SafeListMessagesOptions;
930
- declare const fromSafeListMessagesOptions: (options: SafeListMessagesOptions) => ListMessagesOptions;
931
- type SafeListConversationsOptions = {
932
- consentStates?: ConsentState[];
933
- createdAfterNs?: bigint;
934
- createdBeforeNs?: bigint;
935
- includeDuplicateDms?: boolean;
936
- limit?: bigint;
937
- };
938
- declare const toSafeListConversationsOptions: (options: ListConversationsOptions) => SafeListConversationsOptions;
939
- declare const fromSafeListConversationsOptions: (options: SafeListConversationsOptions) => ListConversationsOptions;
940
- type SafePermissionPolicySet = {
941
- addAdminPolicy: PermissionPolicy;
942
- addMemberPolicy: PermissionPolicy;
943
- removeAdminPolicy: PermissionPolicy;
944
- removeMemberPolicy: PermissionPolicy;
945
- updateGroupDescriptionPolicy: PermissionPolicy;
946
- updateGroupImageUrlSquarePolicy: PermissionPolicy;
947
- updateGroupNamePolicy: PermissionPolicy;
948
- updateMessageDisappearingPolicy: PermissionPolicy;
949
- };
950
- declare const toSafePermissionPolicySet: (policySet: PermissionPolicySet) => SafePermissionPolicySet;
951
- declare const fromSafePermissionPolicySet: (policySet: SafePermissionPolicySet) => PermissionPolicySet;
952
- type SafeCreateGroupOptions = {
953
- customPermissionPolicySet?: SafePermissionPolicySet;
954
- description?: string;
955
- imageUrlSquare?: string;
956
- messageDisappearingSettings?: SafeMessageDisappearingSettings;
957
- name?: string;
958
- permissions?: GroupPermissionsOptions;
959
- };
960
- declare const toSafeCreateGroupOptions: (options: CreateGroupOptions) => SafeCreateGroupOptions;
961
- declare const fromSafeCreateGroupOptions: (options: SafeCreateGroupOptions) => CreateGroupOptions;
962
- type SafeCreateDmOptions = {
963
- messageDisappearingSettings?: SafeMessageDisappearingSettings;
964
- };
965
- declare const toSafeCreateDmOptions: (options: CreateDMOptions) => SafeCreateDmOptions;
966
- declare const fromSafeCreateDmOptions: (options: SafeCreateDmOptions) => CreateDMOptions;
967
- type SafeConversation = {
932
+ } | {
933
+ action: "group.removeSuperAdmin";
968
934
  id: string;
969
- name: string;
970
- imageUrl: string;
971
- description: string;
972
- permissions: {
973
- policyType: GroupPermissionsOptions;
974
- policySet: {
975
- addAdminPolicy: PermissionPolicy;
976
- addMemberPolicy: PermissionPolicy;
977
- removeAdminPolicy: PermissionPolicy;
978
- removeMemberPolicy: PermissionPolicy;
979
- updateGroupDescriptionPolicy: PermissionPolicy;
980
- updateGroupImageUrlSquarePolicy: PermissionPolicy;
981
- updateGroupNamePolicy: PermissionPolicy;
982
- updateMessageDisappearingPolicy: PermissionPolicy;
983
- };
935
+ result: undefined;
936
+ data: {
937
+ id: string;
938
+ inboxId: string;
984
939
  };
985
- isActive: boolean;
986
- addedByInboxId: string;
987
- metadata: {
988
- creatorInboxId: string;
989
- conversationType: string;
940
+ } | {
941
+ action: "group.updateName";
942
+ id: string;
943
+ result: undefined;
944
+ data: {
945
+ id: string;
946
+ name: string;
990
947
  };
991
- admins: string[];
992
- superAdmins: string[];
993
- createdAtNs: bigint;
994
- };
995
- declare const toSafeConversation: (conversation: WorkerConversation) => Promise<SafeConversation>;
996
- type SafeInstallation = {
997
- bytes: Uint8Array;
998
- clientTimestampNs?: bigint;
948
+ } | {
949
+ action: "group.updateDescription";
999
950
  id: string;
951
+ result: undefined;
952
+ data: {
953
+ id: string;
954
+ description: string;
955
+ };
956
+ } | {
957
+ action: "group.updateImageUrl";
958
+ id: string;
959
+ result: undefined;
960
+ data: {
961
+ id: string;
962
+ imageUrl: string;
963
+ };
964
+ } | {
965
+ action: "group.updatePermission";
966
+ id: string;
967
+ result: undefined;
968
+ data: {
969
+ id: string;
970
+ permissionType: PermissionUpdateType;
971
+ policy: PermissionPolicy;
972
+ metadataField?: MetadataField;
973
+ };
974
+ } | {
975
+ action: "group.permissions";
976
+ id: string;
977
+ result: SafeConversation["permissions"];
978
+ data: {
979
+ id: string;
980
+ };
1000
981
  };
1001
- declare const toSafeInstallation: (installation: Installation) => SafeInstallation;
1002
- type SafeInboxState = {
1003
- accountIdentifiers: Identifier[];
1004
- inboxId: string;
1005
- installations: SafeInstallation[];
1006
- recoveryIdentifier: Identifier;
1007
- };
1008
- declare const toSafeInboxState: (inboxState: InboxState) => SafeInboxState;
1009
- type SafeConsent = {
1010
- entity: string;
1011
- entityType: ConsentEntityType;
1012
- state: ConsentState;
1013
- };
1014
- declare const toSafeConsent: (consent: Consent) => SafeConsent;
1015
- declare const fromSafeConsent: (consent: SafeConsent) => Consent;
1016
- type SafeGroupMember = {
1017
- accountIdentifiers: Identifier[];
1018
- consentState: ConsentState;
1019
- inboxId: string;
1020
- installationIds: string[];
1021
- permissionLevel: PermissionLevel;
1022
- };
1023
- declare const toSafeGroupMember: (member: GroupMember) => SafeGroupMember;
1024
- declare const fromSafeGroupMember: (member: SafeGroupMember) => GroupMember;
1025
- type SafeHmacKey = {
1026
- key: Uint8Array;
1027
- epoch: bigint;
982
+
983
+ type PreferencesAction = {
984
+ action: "preferences.inboxState";
985
+ id: string;
986
+ result: SafeInboxState;
987
+ data: {
988
+ refreshFromNetwork: boolean;
989
+ };
990
+ } | {
991
+ action: "preferences.inboxStateFromInboxIds";
992
+ id: string;
993
+ result: SafeInboxState[];
994
+ data: {
995
+ inboxIds: string[];
996
+ refreshFromNetwork: boolean;
997
+ };
998
+ } | {
999
+ action: "preferences.getLatestInboxState";
1000
+ id: string;
1001
+ result: SafeInboxState;
1002
+ data: {
1003
+ inboxId: string;
1004
+ };
1005
+ } | {
1006
+ action: "preferences.setConsentStates";
1007
+ id: string;
1008
+ result: undefined;
1009
+ data: {
1010
+ records: SafeConsent[];
1011
+ };
1012
+ } | {
1013
+ action: "preferences.getConsentState";
1014
+ id: string;
1015
+ result: ConsentState;
1016
+ data: {
1017
+ entityType: ConsentEntityType;
1018
+ entity: string;
1019
+ };
1020
+ } | {
1021
+ action: "preferences.sync";
1022
+ id: string;
1023
+ result: number;
1024
+ data: undefined;
1025
+ } | {
1026
+ action: "preferences.streamConsent";
1027
+ id: string;
1028
+ result: undefined;
1029
+ data: {
1030
+ streamId: string;
1031
+ };
1032
+ } | {
1033
+ action: "preferences.streamPreferences";
1034
+ id: string;
1035
+ result: undefined;
1036
+ data: {
1037
+ streamId: string;
1038
+ };
1028
1039
  };
1029
- declare const toSafeHmacKey: (hmacKey: HmacKey) => SafeHmacKey;
1030
- type HmacKeys = Map<string, HmacKey[]>;
1031
- type SafeHmacKeys = Record<string, SafeHmacKey[]>;
1032
- type SafeMessageDisappearingSettings = {
1033
- fromNs: bigint;
1034
- inNs: bigint;
1040
+
1041
+ type UnknownAction = {
1042
+ action: string;
1043
+ id: string;
1044
+ result: unknown;
1045
+ data: unknown;
1035
1046
  };
1036
- declare const toSafeMessageDisappearingSettings: (settings: MessageDisappearingSettings) => SafeMessageDisappearingSettings;
1037
- declare const fromSafeMessageDisappearingSettings: (settings: SafeMessageDisappearingSettings) => MessageDisappearingSettings;
1038
- type SafeKeyPackageStatus = {
1039
- lifetime?: {
1040
- notBefore: bigint;
1041
- notAfter: bigint;
1047
+ type ClientWorkerAction = {
1048
+ action: "endStream";
1049
+ id: string;
1050
+ result: undefined;
1051
+ data: {
1052
+ streamId: string;
1042
1053
  };
1043
- validationError?: string;
1054
+ } | ClientAction | ConversationAction | ConversationsAction | DmAction | GroupAction | PreferencesAction;
1055
+ type ActionName<T extends UnknownAction> = T["action"];
1056
+ type ExtractAction<T extends UnknownAction, A extends ActionName<T>> = Extract<T, {
1057
+ action: A;
1058
+ }>;
1059
+ type ExtractActionData<T extends UnknownAction, A extends ActionName<T>> = ExtractAction<T, A>["data"];
1060
+ type ExtractActionResult<T extends UnknownAction, A extends ActionName<T>> = ExtractAction<T, A>["result"];
1061
+ type ActionWithoutData<T extends UnknownAction> = {
1062
+ [A in T["action"]]: Omit<Extract<T, {
1063
+ action: A;
1064
+ }>, "data">;
1065
+ }[T["action"]];
1066
+ type ActionErrorData<T extends UnknownAction> = {
1067
+ id: string;
1068
+ action: ActionName<T>;
1069
+ error: Error;
1044
1070
  };
1045
- declare const toSafeKeyPackageStatus: (status: KeyPackageStatus) => SafeKeyPackageStatus;
1046
1071
 
1047
- type ClientStreamEvents = {
1048
- type: "message";
1072
+ type StreamAction = {
1073
+ action: "stream.message";
1049
1074
  streamId: string;
1050
1075
  result: SafeMessage | undefined;
1051
1076
  } | {
1052
- type: "group";
1077
+ action: "stream.conversation";
1053
1078
  streamId: string;
1054
1079
  result: SafeConversation | undefined;
1055
1080
  } | {
1056
- type: "consent";
1081
+ action: "stream.consent";
1057
1082
  streamId: string;
1058
1083
  result: SafeConsent[] | undefined;
1059
1084
  } | {
1060
- type: "preferences";
1085
+ action: "stream.preferences";
1061
1086
  streamId: string;
1062
1087
  result: UserPreference[] | undefined;
1063
1088
  };
1064
1089
 
1090
+ /**
1091
+ * Class that sets up a worker and provides communications for client functions
1092
+ *
1093
+ * This class is not meant to be used directly, it is extended by the Client class
1094
+ * to provide an interface to the worker.
1095
+ *
1096
+ * @param worker - The worker to use for the client class
1097
+ * @param enableLogging - Whether to enable logging in the worker
1098
+ * @returns A new ClientWorkerClass instance
1099
+ */
1065
1100
  declare class ClientWorkerClass {
1066
1101
  #private;
1067
1102
  constructor(worker: Worker, enableLogging: boolean);
1068
- sendMessage<A extends ClientEventsActions>(action: A, data: ClientSendMessageData<A>): Promise<ClientEventsResult<A>>;
1069
- handleMessage: (event: MessageEvent<ClientEventsWorkerMessageData | ClientEventsErrorData>) => void;
1070
- handleStreamMessage: <T extends ClientStreamEvents["result"]>(streamId: string, callback: (error: Error | null, value: T | null) => void) => () => void;
1103
+ /**
1104
+ * Sends an action message to the client worker
1105
+ *
1106
+ * @param action - The action to send to the worker
1107
+ * @param data - The data to send to the worker
1108
+ * @returns A promise that resolves when the action is completed
1109
+ */
1110
+ sendMessage<A extends ActionName<ClientWorkerAction>>(action: A, data: ExtractActionData<ClientWorkerAction, A>): [ExtractActionResult<ClientWorkerAction, A>] extends [undefined] ? Promise<void> : Promise<ExtractActionResult<ClientWorkerAction, A>>;
1111
+ /**
1112
+ * Handles a message from the client worker
1113
+ *
1114
+ * @param event - The event to handle
1115
+ */
1116
+ handleMessage: (event: MessageEvent<ActionWithoutData<ClientWorkerAction> | ActionErrorData<ClientWorkerAction>>) => void;
1117
+ /**
1118
+ * Handles a stream message from the client worker
1119
+ *
1120
+ * @param streamId - The ID of the stream to handle
1121
+ * @param callback - The callback to handle the stream message
1122
+ * @returns A function to remove the stream handler
1123
+ */
1124
+ handleStreamMessage: <T extends StreamAction["result"]>(streamId: string, callback: (error: Error | null, value: T | null) => void) => () => void;
1125
+ /**
1126
+ * Removes all event listeners and terminates the worker
1127
+ */
1071
1128
  close(): void;
1072
1129
  }
1073
1130
 
@@ -1093,9 +1150,9 @@ type MessageDeliveryStatus = "unpublished" | "published" | "failed";
1093
1150
  * @property {string} senderInboxId - Identifier for the sender's inbox
1094
1151
  * @property {bigint} sentAtNs - Timestamp when the message was sent (in nanoseconds)
1095
1152
  */
1096
- declare class DecodedMessage<T = unknown> {
1153
+ declare class DecodedMessage<ContentTypes = unknown> {
1097
1154
  #private;
1098
- content: T | undefined;
1155
+ content: ContentTypes | undefined;
1099
1156
  contentType: ContentTypeId$1;
1100
1157
  conversationId: string;
1101
1158
  deliveryStatus: MessageDeliveryStatus;
@@ -1107,7 +1164,7 @@ declare class DecodedMessage<T = unknown> {
1107
1164
  encodedContent: SafeMessage["content"];
1108
1165
  senderInboxId: string;
1109
1166
  sentAtNs: bigint;
1110
- constructor(client: Client, message: SafeMessage);
1167
+ constructor(client: Client<ContentTypes>, message: SafeMessage);
1111
1168
  }
1112
1169
 
1113
1170
  /**
@@ -1115,7 +1172,7 @@ declare class DecodedMessage<T = unknown> {
1115
1172
  *
1116
1173
  * This class is not intended to be initialized directly.
1117
1174
  */
1118
- declare class Conversation {
1175
+ declare class Conversation<ContentTypes = unknown> {
1119
1176
  #private;
1120
1177
  /**
1121
1178
  * Creates a new conversation instance
@@ -1124,7 +1181,7 @@ declare class Conversation {
1124
1181
  * @param id - The unique identifier for this conversation
1125
1182
  * @param data - Optional conversation data to initialize with
1126
1183
  */
1127
- constructor(client: Client, id: string, data?: SafeConversation);
1184
+ constructor(client: Client<ContentTypes>, id: string, data?: SafeConversation);
1128
1185
  get id(): string;
1129
1186
  get isActive(): boolean | undefined;
1130
1187
  get addedByInboxId(): string | undefined;
@@ -1151,7 +1208,7 @@ declare class Conversation {
1151
1208
  *
1152
1209
  * @returns Promise that resolves when publishing is complete
1153
1210
  */
1154
- publishMessages(): Promise<undefined>;
1211
+ publishMessages(): Promise<void>;
1155
1212
  /**
1156
1213
  * Prepares a message to be published
1157
1214
  *
@@ -1160,7 +1217,7 @@ declare class Conversation {
1160
1217
  * @returns Promise that resolves with the message ID
1161
1218
  * @throws {MissingContentTypeError} if content type is required but not provided
1162
1219
  */
1163
- sendOptimistic(content: unknown, contentType?: ContentTypeId$1): Promise<string>;
1220
+ sendOptimistic(content: ContentTypes, contentType?: ContentTypeId$1): Promise<string>;
1164
1221
  /**
1165
1222
  * Publishes a new message
1166
1223
  *
@@ -1169,14 +1226,14 @@ declare class Conversation {
1169
1226
  * @returns Promise that resolves with the message ID after it has been sent
1170
1227
  * @throws {MissingContentTypeError} if content type is required but not provided
1171
1228
  */
1172
- send(content: unknown, contentType?: ContentTypeId$1): Promise<string>;
1229
+ send(content: ContentTypes, contentType?: ContentTypeId$1): Promise<string>;
1173
1230
  /**
1174
1231
  * Lists messages in this conversation
1175
1232
  *
1176
1233
  * @param options - Optional filtering and pagination options
1177
1234
  * @returns Promise that resolves with an array of decoded messages
1178
1235
  */
1179
- messages(options?: SafeListMessagesOptions): Promise<DecodedMessage<unknown>[]>;
1236
+ messages(options?: SafeListMessagesOptions): Promise<DecodedMessage<ContentTypes>[]>;
1180
1237
  /**
1181
1238
  * Gets the consent state for this conversation
1182
1239
  *
@@ -1189,7 +1246,7 @@ declare class Conversation {
1189
1246
  * @param state - The new consent state to set
1190
1247
  * @returns Promise that resolves when the update is complete
1191
1248
  */
1192
- updateConsentState(state: ConsentState): Promise<undefined>;
1249
+ updateConsentState(state: ConsentState): Promise<void>;
1193
1250
  /**
1194
1251
  * Gets the message disappearing settings for this conversation
1195
1252
  *
@@ -1203,13 +1260,13 @@ declare class Conversation {
1203
1260
  * @param inNs - The duration after which messages should disappear
1204
1261
  * @returns Promise that resolves when the update is complete
1205
1262
  */
1206
- updateMessageDisappearingSettings(fromNs: bigint, inNs: bigint): Promise<undefined>;
1263
+ updateMessageDisappearingSettings(fromNs: bigint, inNs: bigint): Promise<void>;
1207
1264
  /**
1208
1265
  * Removes message disappearing settings from this conversation
1209
1266
  *
1210
1267
  * @returns Promise that resolves when the settings are removed
1211
1268
  */
1212
- removeMessageDisappearingSettings(): Promise<undefined>;
1269
+ removeMessageDisappearingSettings(): Promise<void>;
1213
1270
  /**
1214
1271
  * Checks if message disappearing is enabled for this conversation
1215
1272
  *
@@ -1222,14 +1279,20 @@ declare class Conversation {
1222
1279
  * @param callback - Optional callback function for handling new stream values
1223
1280
  * @returns Stream instance for new messages
1224
1281
  */
1225
- stream(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage<unknown>>>;
1282
+ stream(callback?: StreamCallback<DecodedMessage<ContentTypes>>): Promise<AsyncStream<DecodedMessage<ContentTypes>>>;
1226
1283
  pausedForVersion(): Promise<string | undefined>;
1227
1284
  /**
1228
1285
  * Retrieves HMAC keys for this conversation
1229
1286
  *
1230
1287
  * @returns Promise that resolves with the HMAC keys
1231
1288
  */
1232
- getHmacKeys(): Promise<SafeHmacKey[]>;
1289
+ getHmacKeys(): Promise<Map<string, SafeHmacKey[]>>;
1290
+ /**
1291
+ * Retrieves information for this conversation to help with debugging
1292
+ *
1293
+ * @returns The debug information for this conversation
1294
+ */
1295
+ debugInfo(): Promise<SafeConversationDebugInfo>;
1233
1296
  }
1234
1297
 
1235
1298
  /**
@@ -1237,7 +1300,7 @@ declare class Conversation {
1237
1300
  *
1238
1301
  * This class is not intended to be initialized directly.
1239
1302
  */
1240
- declare class Dm extends Conversation {
1303
+ declare class Dm<ContentTypes = unknown> extends Conversation<ContentTypes> {
1241
1304
  #private;
1242
1305
  /**
1243
1306
  * Creates a new direct message conversation instance
@@ -1246,13 +1309,14 @@ declare class Dm extends Conversation {
1246
1309
  * @param id - Identifier for the direct message conversation
1247
1310
  * @param data - Optional conversation data to initialize with
1248
1311
  */
1249
- constructor(client: Client, id: string, data?: SafeConversation);
1312
+ constructor(client: Client<ContentTypes>, id: string, data?: SafeConversation);
1250
1313
  /**
1251
1314
  * Retrieves the inbox ID of the other participant in the DM
1252
1315
  *
1253
1316
  * @returns Promise that resolves with the peer's inbox ID
1254
1317
  */
1255
1318
  peerInboxId(): Promise<string>;
1319
+ getDuplicateDms(): Promise<SafeConversation[]>;
1256
1320
  }
1257
1321
 
1258
1322
  /**
@@ -1260,7 +1324,7 @@ declare class Dm extends Conversation {
1260
1324
  *
1261
1325
  * This class is not intended to be initialized directly.
1262
1326
  */
1263
- declare class Group extends Conversation {
1327
+ declare class Group<ContentTypes = unknown> extends Conversation<ContentTypes> {
1264
1328
  #private;
1265
1329
  /**
1266
1330
  * Creates a new group conversation instance
@@ -1269,7 +1333,7 @@ declare class Group extends Conversation {
1269
1333
  * @param id - Identifier for the group conversation
1270
1334
  * @param data - Optional conversation data to initialize with
1271
1335
  */
1272
- constructor(client: Client, id: string, data?: SafeConversation);
1336
+ constructor(client: Client<ContentTypes>, id: string, data?: SafeConversation);
1273
1337
  /**
1274
1338
  * Synchronizes the group's data with the network
1275
1339
  *
@@ -1351,7 +1415,7 @@ declare class Group extends Conversation {
1351
1415
  * @param policy The new permission policy
1352
1416
  * @param metadataField Optional metadata field for the permission
1353
1417
  */
1354
- updatePermission(permissionType: PermissionUpdateType, policy: PermissionPolicy, metadataField?: MetadataField): Promise<undefined>;
1418
+ updatePermission(permissionType: PermissionUpdateType, policy: PermissionPolicy, metadataField?: MetadataField): Promise<void>;
1355
1419
  /**
1356
1420
  * Checks if an inbox is an admin of the group
1357
1421
  *
@@ -1371,49 +1435,49 @@ declare class Group extends Conversation {
1371
1435
  *
1372
1436
  * @param identifiers Array of member identifiers to add
1373
1437
  */
1374
- addMembersByIdentifiers(identifiers: Identifier[]): Promise<undefined>;
1438
+ addMembersByIdentifiers(identifiers: Identifier[]): Promise<void>;
1375
1439
  /**
1376
1440
  * Adds members to the group using inbox IDs
1377
1441
  *
1378
1442
  * @param inboxIds Array of inbox IDs to add
1379
1443
  */
1380
- addMembers(inboxIds: string[]): Promise<undefined>;
1444
+ addMembers(inboxIds: string[]): Promise<void>;
1381
1445
  /**
1382
1446
  * Removes members from the group using identifiers
1383
1447
  *
1384
1448
  * @param identifiers Array of member identifiers to remove
1385
1449
  */
1386
- removeMembersByIdentifiers(identifiers: Identifier[]): Promise<undefined>;
1450
+ removeMembersByIdentifiers(identifiers: Identifier[]): Promise<void>;
1387
1451
  /**
1388
1452
  * Removes members from the group using inbox IDs
1389
1453
  *
1390
1454
  * @param inboxIds Array of inbox IDs to remove
1391
1455
  */
1392
- removeMembers(inboxIds: string[]): Promise<undefined>;
1456
+ removeMembers(inboxIds: string[]): Promise<void>;
1393
1457
  /**
1394
1458
  * Promotes a group member to admin status
1395
1459
  *
1396
1460
  * @param inboxId The inbox ID of the member to promote
1397
1461
  */
1398
- addAdmin(inboxId: string): Promise<undefined>;
1462
+ addAdmin(inboxId: string): Promise<void>;
1399
1463
  /**
1400
1464
  * Removes admin status from a group member
1401
1465
  *
1402
1466
  * @param inboxId The inbox ID of the admin to demote
1403
1467
  */
1404
- removeAdmin(inboxId: string): Promise<undefined>;
1468
+ removeAdmin(inboxId: string): Promise<void>;
1405
1469
  /**
1406
1470
  * Promotes a group member to super admin status
1407
1471
  *
1408
1472
  * @param inboxId The inbox ID of the member to promote
1409
1473
  */
1410
- addSuperAdmin(inboxId: string): Promise<undefined>;
1474
+ addSuperAdmin(inboxId: string): Promise<void>;
1411
1475
  /**
1412
1476
  * Removes super admin status from a group member
1413
1477
  *
1414
1478
  * @param inboxId The inbox ID of the super admin to demote
1415
1479
  */
1416
- removeSuperAdmin(inboxId: string): Promise<undefined>;
1480
+ removeSuperAdmin(inboxId: string): Promise<void>;
1417
1481
  }
1418
1482
 
1419
1483
  /**
@@ -1421,20 +1485,20 @@ declare class Group extends Conversation {
1421
1485
  *
1422
1486
  * This class is not intended to be initialized directly.
1423
1487
  */
1424
- declare class Conversations {
1488
+ declare class Conversations<ContentTypes = unknown> {
1425
1489
  #private;
1426
1490
  /**
1427
1491
  * Creates a new conversations instance
1428
1492
  *
1429
1493
  * @param client - The client instance managing the conversations
1430
1494
  */
1431
- constructor(client: Client);
1495
+ constructor(client: Client<ContentTypes>);
1432
1496
  /**
1433
1497
  * Synchronizes conversations for the current client from the network
1434
1498
  *
1435
1499
  * @returns Promise that resolves when sync is complete
1436
1500
  */
1437
- sync(): Promise<undefined>;
1501
+ sync(): Promise<void>;
1438
1502
  /**
1439
1503
  * Synchronizes all conversations and messages from the network with optional
1440
1504
  * consent state filtering, then uploads conversation and message history to
@@ -1443,49 +1507,56 @@ declare class Conversations {
1443
1507
  * @param consentStates - Optional array of consent states to filter by
1444
1508
  * @returns Promise that resolves when sync is complete
1445
1509
  */
1446
- syncAll(consentStates?: ConsentState[]): Promise<undefined>;
1510
+ syncAll(consentStates?: ConsentState[]): Promise<void>;
1447
1511
  /**
1448
1512
  * Retrieves a conversation by its ID
1449
1513
  *
1450
1514
  * @param id - The conversation ID to look up
1451
1515
  * @returns Promise that resolves with the conversation, if found
1452
1516
  */
1453
- getConversationById(id: string): Promise<Dm | Group | undefined>;
1517
+ getConversationById(id: string): Promise<Group<ContentTypes> | Dm<ContentTypes> | undefined>;
1454
1518
  /**
1455
1519
  * Retrieves a message by its ID
1456
1520
  *
1457
1521
  * @param id - The message ID to look up
1458
1522
  * @returns Promise that resolves with the decoded message, if found
1459
1523
  */
1460
- getMessageById<T = unknown>(id: string): Promise<DecodedMessage<T> | undefined>;
1524
+ getMessageById(id: string): Promise<DecodedMessage<ContentTypes> | undefined>;
1461
1525
  /**
1462
1526
  * Retrieves a DM by inbox ID
1463
1527
  *
1464
1528
  * @param inboxId - The inbox ID to look up
1465
1529
  * @returns Promise that resolves with the DM, if found
1466
1530
  */
1467
- getDmByInboxId(inboxId: string): Promise<Dm | undefined>;
1531
+ getDmByInboxId(inboxId: string): Promise<Dm<ContentTypes> | undefined>;
1468
1532
  /**
1469
1533
  * Lists all conversations with optional filtering
1470
1534
  *
1471
1535
  * @param options - Optional filtering and pagination options
1472
1536
  * @returns Promise that resolves with an array of conversations
1473
1537
  */
1474
- list(options?: SafeListConversationsOptions): Promise<(Dm | Group)[]>;
1538
+ list(options?: SafeListConversationsOptions): Promise<(Group<ContentTypes> | Dm<ContentTypes>)[]>;
1475
1539
  /**
1476
1540
  * Lists all group conversations with optional filtering
1477
1541
  *
1478
1542
  * @param options - Optional filtering and pagination options
1479
1543
  * @returns Promise that resolves with an array of groups
1480
1544
  */
1481
- listGroups(options?: Omit<SafeListConversationsOptions, "conversation_type">): Promise<Group[]>;
1545
+ listGroups(options?: Omit<SafeListConversationsOptions, "conversation_type">): Promise<Group<ContentTypes>[]>;
1482
1546
  /**
1483
1547
  * Lists all DM conversations with optional filtering
1484
1548
  *
1485
1549
  * @param options - Optional filtering and pagination options
1486
1550
  * @returns Promise that resolves with an array of DMs
1487
1551
  */
1488
- listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">): Promise<Dm[]>;
1552
+ listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">): Promise<Dm<ContentTypes>[]>;
1553
+ /**
1554
+ * Creates a new group without syncing to the network
1555
+ *
1556
+ * @param options - Optional group creation options
1557
+ * @returns Promise that resolves with the new group
1558
+ */
1559
+ newGroupOptimistic(options?: SafeCreateGroupOptions): Promise<Group<ContentTypes>>;
1489
1560
  /**
1490
1561
  * Creates a new group conversation with the specified identifiers
1491
1562
  *
@@ -1493,7 +1564,7 @@ declare class Conversations {
1493
1564
  * @param options - Optional group creation options
1494
1565
  * @returns Promise that resolves with the new group
1495
1566
  */
1496
- newGroupWithIdentifiers(identifiers: Identifier[], options?: SafeCreateGroupOptions): Promise<Group>;
1567
+ newGroupWithIdentifiers(identifiers: Identifier[], options?: SafeCreateGroupOptions): Promise<Group<ContentTypes>>;
1497
1568
  /**
1498
1569
  * Creates a new group conversation with the specified inbox IDs
1499
1570
  *
@@ -1501,7 +1572,7 @@ declare class Conversations {
1501
1572
  * @param options - Optional group creation options
1502
1573
  * @returns Promise that resolves with the new group
1503
1574
  */
1504
- newGroup(inboxIds: string[], options?: SafeCreateGroupOptions): Promise<Group>;
1575
+ newGroup(inboxIds: string[], options?: SafeCreateGroupOptions): Promise<Group<ContentTypes>>;
1505
1576
  /**
1506
1577
  * Creates a new DM conversation with the specified identifier
1507
1578
  *
@@ -1509,7 +1580,7 @@ declare class Conversations {
1509
1580
  * @param options - Optional DM creation options
1510
1581
  * @returns Promise that resolves with the new DM
1511
1582
  */
1512
- newDmWithIdentifier(identifier: Identifier, options?: SafeCreateDmOptions): Promise<Dm>;
1583
+ newDmWithIdentifier(identifier: Identifier, options?: SafeCreateDmOptions): Promise<Dm<ContentTypes>>;
1513
1584
  /**
1514
1585
  * Creates a new DM conversation with the specified inbox ID
1515
1586
  *
@@ -1517,7 +1588,7 @@ declare class Conversations {
1517
1588
  * @param options - Optional DM creation options
1518
1589
  * @returns Promise that resolves with the new DM
1519
1590
  */
1520
- newDm(inboxId: string, options?: SafeCreateDmOptions): Promise<Dm>;
1591
+ newDm(inboxId: string, options?: SafeCreateDmOptions): Promise<Dm<ContentTypes>>;
1521
1592
  /**
1522
1593
  * Retrieves HMAC keys for all conversations
1523
1594
  *
@@ -1531,21 +1602,21 @@ declare class Conversations {
1531
1602
  * @param conversationType - Optional type to filter conversations
1532
1603
  * @returns Stream instance for new conversations
1533
1604
  */
1534
- stream<T extends Group | Dm = Group | Dm>(callback?: StreamCallback<T>, conversationType?: ConversationType): Promise<AsyncStream<T>>;
1605
+ stream<T extends Group<ContentTypes> | Dm<ContentTypes> = Group<ContentTypes> | Dm<ContentTypes>>(callback?: StreamCallback<T>, conversationType?: ConversationType): Promise<AsyncStream<T>>;
1535
1606
  /**
1536
1607
  * Creates a stream for new group conversations
1537
1608
  *
1538
1609
  * @param callback - Optional callback function for handling new stream value
1539
1610
  * @returns Stream instance for new group conversations
1540
1611
  */
1541
- streamGroups(callback?: StreamCallback<Group>): Promise<AsyncStream<Group>>;
1612
+ streamGroups(callback?: StreamCallback<Group<ContentTypes>>): Promise<AsyncStream<Group<ContentTypes>>>;
1542
1613
  /**
1543
1614
  * Creates a stream for new DM conversations
1544
1615
  *
1545
1616
  * @param callback - Optional callback function for handling new stream value
1546
1617
  * @returns Stream instance for new DM conversations
1547
1618
  */
1548
- streamDms(callback?: StreamCallback<Dm>): Promise<AsyncStream<Dm>>;
1619
+ streamDms(callback?: StreamCallback<Dm<ContentTypes>>): Promise<AsyncStream<Dm<ContentTypes>>>;
1549
1620
  /**
1550
1621
  * Creates a stream for all new messages
1551
1622
  *
@@ -1553,21 +1624,21 @@ declare class Conversations {
1553
1624
  * @param conversationType - Optional conversation type to filter messages
1554
1625
  * @returns Stream instance for new messages
1555
1626
  */
1556
- streamAllMessages(callback?: StreamCallback<DecodedMessage>, conversationType?: ConversationType): Promise<AsyncStream<DecodedMessage<unknown>>>;
1627
+ streamAllMessages(callback?: StreamCallback<DecodedMessage<ContentTypes>>, conversationType?: ConversationType, consentStates?: ConsentState[]): Promise<AsyncStream<DecodedMessage<ContentTypes>>>;
1557
1628
  /**
1558
1629
  * Creates a stream for all new group messages
1559
1630
  *
1560
1631
  * @param callback - Optional callback function for handling new stream value
1561
1632
  * @returns Stream instance for new group messages
1562
1633
  */
1563
- streamAllGroupMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage<unknown>>>;
1634
+ streamAllGroupMessages(callback?: StreamCallback<DecodedMessage<ContentTypes>>, consentStates?: ConsentState[]): Promise<AsyncStream<DecodedMessage<ContentTypes>>>;
1564
1635
  /**
1565
1636
  * Creates a stream for all new DM messages
1566
1637
  *
1567
1638
  * @param callback - Optional callback function for handling new stream value
1568
1639
  * @returns Stream instance for new DM messages
1569
1640
  */
1570
- streamAllDmMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage<unknown>>>;
1641
+ streamAllDmMessages(callback?: StreamCallback<DecodedMessage<ContentTypes>>, consentStates?: ConsentState[]): Promise<AsyncStream<DecodedMessage<ContentTypes>>>;
1571
1642
  }
1572
1643
 
1573
1644
  /**
@@ -1575,14 +1646,15 @@ declare class Conversations {
1575
1646
  *
1576
1647
  * This class is not intended to be initialized directly.
1577
1648
  */
1578
- declare class Preferences {
1649
+ declare class Preferences<ContentTypes = unknown> {
1579
1650
  #private;
1580
1651
  /**
1581
1652
  * Creates a new preferences instance
1582
1653
  *
1583
1654
  * @param client - The client instance managing preferences
1584
1655
  */
1585
- constructor(client: Client);
1656
+ constructor(client: Client<ContentTypes>);
1657
+ sync(): Promise<number>;
1586
1658
  /**
1587
1659
  * Retrieves the current inbox state
1588
1660
  *
@@ -1611,7 +1683,7 @@ declare class Preferences {
1611
1683
  * @param records - Array of consent records to update
1612
1684
  * @returns Promise that resolves when consent states are updated
1613
1685
  */
1614
- setConsentStates(records: SafeConsent[]): Promise<undefined>;
1686
+ setConsentStates(records: SafeConsent[]): Promise<void>;
1615
1687
  /**
1616
1688
  * Retrieves consent state for a specific entity
1617
1689
  *
@@ -1652,10 +1724,15 @@ type Signer = {
1652
1724
  getChainId: GetChainId;
1653
1725
  };
1654
1726
 
1727
+ type ExtractCodecContentTypes<C extends ContentCodec[] = []> = [
1728
+ ...C,
1729
+ GroupUpdatedCodec,
1730
+ TextCodec
1731
+ ][number] extends ContentCodec<infer T> ? T : never;
1655
1732
  /**
1656
1733
  * Client for interacting with the XMTP network
1657
1734
  */
1658
- declare class Client extends ClientWorkerClass {
1735
+ declare class Client<ContentTypes = ExtractCodecContentTypes> extends ClientWorkerClass {
1659
1736
  #private;
1660
1737
  /**
1661
1738
  * Creates a new XMTP client instance
@@ -1682,7 +1759,9 @@ declare class Client extends ClientWorkerClass {
1682
1759
  * @param options - Optional configuration for the client
1683
1760
  * @returns A new client instance
1684
1761
  */
1685
- static create(signer: Signer, options?: ClientOptions): Promise<Client>;
1762
+ static create<ContentCodecs extends ContentCodec[] = []>(signer: Signer, options?: Omit<ClientOptions, "codecs"> & {
1763
+ codecs?: ContentCodecs;
1764
+ }): Promise<Client<ExtractCodecContentTypes<ContentCodecs>>>;
1686
1765
  /**
1687
1766
  * Creates a new client instance with an identifier
1688
1767
  *
@@ -1693,7 +1772,9 @@ declare class Client extends ClientWorkerClass {
1693
1772
  * @param options - Optional configuration for the client
1694
1773
  * @returns A new client instance
1695
1774
  */
1696
- static build(identifier: Identifier, options?: ClientOptions): Promise<Client>;
1775
+ static build<ContentCodecs extends ContentCodec[] = []>(identifier: Identifier, options?: Omit<ClientOptions, "codecs"> & {
1776
+ codecs?: ContentCodecs;
1777
+ }): Promise<Client<ExtractCodecContentTypes<ContentCodecs>>>;
1697
1778
  /**
1698
1779
  * Gets the client options
1699
1780
  */
@@ -1725,11 +1806,11 @@ declare class Client extends ClientWorkerClass {
1725
1806
  /**
1726
1807
  * Gets the conversations manager for this client
1727
1808
  */
1728
- get conversations(): Conversations;
1809
+ get conversations(): Conversations<ContentTypes>;
1729
1810
  /**
1730
1811
  * Gets the preferences manager for this client
1731
1812
  */
1732
- get preferences(): Preferences;
1813
+ get preferences(): Preferences<ContentTypes>;
1733
1814
  /**
1734
1815
  * Creates signature text for creating a new inbox
1735
1816
  *
@@ -1838,7 +1919,7 @@ declare class Client extends ClientWorkerClass {
1838
1919
  * `removeAccount`, `revokeAllOtherInstallations`, or `revokeInstallations`
1839
1920
  * methods instead.
1840
1921
  */
1841
- unsafe_applySignatures(): Promise<undefined>;
1922
+ unsafe_applySignatures(): Promise<void>;
1842
1923
  /**
1843
1924
  * Registers the client with the XMTP network
1844
1925
  *
@@ -1846,7 +1927,7 @@ declare class Client extends ClientWorkerClass {
1846
1927
  *
1847
1928
  * @throws {SignerUnavailableError} if no signer is available
1848
1929
  */
1849
- register(): Promise<undefined>;
1930
+ register(): Promise<void>;
1850
1931
  /**
1851
1932
  * Adds a new account to the client inbox
1852
1933
  *
@@ -1939,7 +2020,7 @@ declare class Client extends ClientWorkerClass {
1939
2020
  * @param contentType - The content type to get the codec for
1940
2021
  * @returns The codec, if found
1941
2022
  */
1942
- codecFor<T = unknown>(contentType: ContentTypeId$1): ContentCodec<T> | undefined;
2023
+ codecFor<ContentType = unknown>(contentType: ContentTypeId$1): ContentCodec<ContentType> | undefined;
1943
2024
  /**
1944
2025
  * Encodes content for a given content type
1945
2026
  *
@@ -1948,7 +2029,7 @@ declare class Client extends ClientWorkerClass {
1948
2029
  * @returns The encoded content
1949
2030
  * @throws {CodecNotFoundError} if no codec is found for the content type
1950
2031
  */
1951
- encodeContent(content: unknown, contentType: ContentTypeId$1): SafeEncodedContent;
2032
+ encodeContent(content: ContentTypes, contentType: ContentTypeId$1): SafeEncodedContent;
1952
2033
  /**
1953
2034
  * Decodes a message for a given content type
1954
2035
  *
@@ -1958,7 +2039,7 @@ declare class Client extends ClientWorkerClass {
1958
2039
  * @throws {CodecNotFoundError} if no codec is found for the content type
1959
2040
  * @throws {InvalidGroupMembershipChangeError} if the message is an invalid group membership change
1960
2041
  */
1961
- decodeContent<T = unknown>(message: SafeMessage, contentType: ContentTypeId$1): T;
2042
+ decodeContent<ContentType = unknown>(message: SafeMessage, contentType: ContentTypeId$1): ContentType;
1962
2043
  /**
1963
2044
  * Signs a message with the installation key
1964
2045
  *
@@ -1990,14 +2071,73 @@ declare class Client extends ClientWorkerClass {
1990
2071
  * @returns The key package statuses
1991
2072
  */
1992
2073
  getKeyPackageStatusesForInstallationIds(installationIds: string[]): Promise<Map<string, SafeKeyPackageStatus>>;
2074
+ apiStatistics(): Promise<SafeApiStats>;
2075
+ apiIdentityStatistics(): Promise<SafeIdentityStats>;
2076
+ apiAggregateStatistics(): Promise<string>;
2077
+ uploadDebugArchive(serverUrl?: string): Promise<string>;
1993
2078
  }
1994
2079
 
2080
+ type UtilsWorkerAction = {
2081
+ action: "utils.init";
2082
+ id: string;
2083
+ result: undefined;
2084
+ data: {
2085
+ enableLogging: boolean;
2086
+ };
2087
+ } | {
2088
+ action: "utils.generateInboxId";
2089
+ id: string;
2090
+ result: string;
2091
+ data: {
2092
+ identifier: Identifier;
2093
+ };
2094
+ } | {
2095
+ action: "utils.getInboxIdForIdentifier";
2096
+ id: string;
2097
+ result: string | undefined;
2098
+ data: {
2099
+ identifier: Identifier;
2100
+ env?: XmtpEnv;
2101
+ };
2102
+ };
2103
+
2104
+ /**
2105
+ * Class that sets up a worker and provides communications for utility functions
2106
+ *
2107
+ * This class is not meant to be used directly, it is extended by the Utils class
2108
+ * to provide an interface to the worker.
2109
+ *
2110
+ * @param worker - The worker to use for the utils class
2111
+ * @param enableLogging - Whether to enable logging in the worker
2112
+ * @returns A new UtilsWorkerClass instance
2113
+ */
1995
2114
  declare class UtilsWorkerClass {
1996
2115
  #private;
1997
2116
  constructor(worker: Worker, enableLogging: boolean);
1998
- init(enableLogging: boolean): Promise<undefined>;
1999
- sendMessage<A extends UtilsEventsActions>(action: A, data: UtilsSendMessageData<A>): Promise<UtilsEventsResult<A>>;
2000
- handleMessage: (event: MessageEvent<UtilsEventsWorkerMessageData | UtilsEventsErrorData>) => void;
2117
+ /**
2118
+ * Initializes the utils worker
2119
+ *
2120
+ * @param enableLogging - Whether to enable logging in the worker
2121
+ * @returns A promise that resolves when the worker is initialized
2122
+ */
2123
+ init(enableLogging: boolean): Promise<void>;
2124
+ /**
2125
+ * Sends an action message to the utils worker
2126
+ *
2127
+ * @param action - The action to send to the worker
2128
+ * @param data - The data to send to the worker
2129
+ * @returns A promise that resolves when the action is completed
2130
+ */
2131
+ sendMessage<A extends ActionName<UtilsWorkerAction>>(action: A, data: ExtractActionData<UtilsWorkerAction, A>): [ExtractActionResult<UtilsWorkerAction, A>] extends [undefined] ? Promise<void> : Promise<ExtractActionResult<UtilsWorkerAction, A>>;
2132
+ /**
2133
+ * Handles a message from the utils worker
2134
+ *
2135
+ * @param event - The event to handle
2136
+ */
2137
+ handleMessage: (event: MessageEvent<ActionWithoutData<UtilsWorkerAction> | ActionErrorData<UtilsWorkerAction>>) => void;
2138
+ /**
2139
+ * Removes all event listeners and terminates the worker
2140
+ */
2001
2141
  close(): void;
2002
2142
  }
2003
2143
 
@@ -2028,4 +2168,35 @@ declare class Utils extends UtilsWorkerClass {
2028
2168
  getInboxIdForIdentifier(identifier: Identifier, env?: XmtpEnv): Promise<string | undefined>;
2029
2169
  }
2030
2170
 
2031
- export { ApiUrls, AsyncStream, Client, type ClientEvents, type ClientEventsActions, type ClientEventsClientMessageData, type ClientEventsClientPostMessageData, type ClientEventsErrorData, type ClientEventsResult, type ClientEventsWorkerMessageData, type ClientEventsWorkerPostMessageData, type ClientOptions, type ClientSendMessageData, type ContentOptions, Conversation, Conversations, DecodedMessage, Dm, type EventsClientMessageData, type EventsClientPostMessageData, type EventsErrorData, type EventsResult, type EventsWorkerMessageData, type EventsWorkerPostMessageData, type GenericEvent, type GenericStreamEvent, Group, HistorySyncUrls, type HmacKeys, type MessageDeliveryStatus, type MessageKind, type NetworkOptions, type OtherOptions, type SafeConsent, type SafeContentTypeId, type SafeConversation, type SafeCreateDmOptions, type SafeCreateGroupOptions, type SafeEncodedContent, type SafeGroupMember, type SafeHmacKey, type SafeHmacKeys, type SafeInboxState, type SafeInstallation, type SafeKeyPackageStatus, type SafeListConversationsOptions, type SafeListMessagesOptions, type SafeMessage, type SafeMessageDisappearingSettings, type SafePermissionPolicySet, type SendMessageData, type Signer, type StorageOptions, type StreamCallback, type StreamEventsClientMessageData, type StreamEventsClientPostMessageData, type StreamEventsErrorData, type StreamEventsResult, Utils, type UtilsEvents, type UtilsEventsActions, type UtilsEventsClientMessageData, type UtilsEventsClientPostMessageData, type UtilsEventsErrorData, type UtilsEventsResult, type UtilsEventsWorkerMessageData, type UtilsEventsWorkerPostMessageData, type UtilsSendMessageData, type XmtpEnv, fromContentTypeId, fromEncodedContent, fromSafeConsent, fromSafeContentTypeId, fromSafeCreateDmOptions, fromSafeCreateGroupOptions, fromSafeEncodedContent, fromSafeGroupMember, fromSafeListConversationsOptions, fromSafeListMessagesOptions, fromSafeMessageDisappearingSettings, fromSafePermissionPolicySet, toContentTypeId, toEncodedContent, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeCreateDmOptions, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeHmacKey, toSafeInboxState, toSafeInstallation, toSafeKeyPackageStatus, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage, toSafeMessageDisappearingSettings, toSafePermissionPolicySet };
2171
+ declare class ClientNotInitializedError extends Error {
2172
+ constructor();
2173
+ }
2174
+ declare class SignerUnavailableError extends Error {
2175
+ constructor();
2176
+ }
2177
+ declare class CodecNotFoundError extends Error {
2178
+ constructor(contentType: ContentTypeId$1);
2179
+ }
2180
+ declare class InboxReassignError extends Error {
2181
+ constructor();
2182
+ }
2183
+ declare class AccountAlreadyAssociatedError extends Error {
2184
+ constructor(inboxId: string);
2185
+ }
2186
+ declare class GenerateSignatureError extends Error {
2187
+ constructor(signatureType: SignatureRequestType);
2188
+ }
2189
+ declare class GroupNotFoundError extends Error {
2190
+ constructor(groupId: string);
2191
+ }
2192
+ declare class StreamNotFoundError extends Error {
2193
+ constructor(streamId: string);
2194
+ }
2195
+ declare class InvalidGroupMembershipChangeError extends Error {
2196
+ constructor(messageId: string);
2197
+ }
2198
+ declare class MissingContentTypeError extends Error {
2199
+ constructor();
2200
+ }
2201
+
2202
+ export { AccountAlreadyAssociatedError, ApiUrls, AsyncStream, Client, ClientNotInitializedError, type ClientOptions, CodecNotFoundError, type ContentOptions, Conversation, Conversations, DecodedMessage, Dm, type ExtractCodecContentTypes, GenerateSignatureError, Group, GroupNotFoundError, HistorySyncUrls, type HmacKeys, InboxReassignError, InvalidGroupMembershipChangeError, type MessageDeliveryStatus, type MessageKind, MissingContentTypeError, type NetworkOptions, type OtherOptions, type SafeApiStats, type SafeConsent, type SafeContentTypeId, type SafeConversation, type SafeConversationDebugInfo, type SafeCreateDmOptions, type SafeCreateGroupOptions, type SafeEncodedContent, type SafeGroupMember, type SafeHmacKey, type SafeHmacKeys, type SafeIdentityStats, type SafeInboxState, type SafeInstallation, type SafeKeyPackageStatus, type SafeListConversationsOptions, type SafeListMessagesOptions, type SafeMessage, type SafeMessageDisappearingSettings, type SafePermissionPolicySet, type Signer, SignerUnavailableError, type StorageOptions, type StreamCallback, StreamNotFoundError, Utils, type XmtpEnv, fromContentTypeId, fromEncodedContent, fromSafeConsent, fromSafeContentTypeId, fromSafeCreateDmOptions, fromSafeCreateGroupOptions, fromSafeEncodedContent, fromSafeGroupMember, fromSafeListConversationsOptions, fromSafeListMessagesOptions, fromSafeMessageDisappearingSettings, fromSafePermissionPolicySet, toContentTypeId, toEncodedContent, toSafeApiStats, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeConversationDebugInfo, toSafeCreateDmOptions, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeHmacKey, toSafeIdentityStats, toSafeInboxState, toSafeInstallation, toSafeKeyPackageStatus, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage, toSafeMessageDisappearingSettings, toSafePermissionPolicySet };