@xmtp/browser-sdk 2.0.12 → 2.1.0

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