@xmtp/browser-sdk 5.0.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,9 +4,6 @@ This package provides the XMTP client SDK for browsers.
4
4
 
5
5
  To keep up with the latest SDK developments, see the [Issues tab](https://github.com/xmtp/xmtp-js/issues) in this repo.
6
6
 
7
- > [!CAUTION]
8
- > This SDK is in beta status and ready for you to build with in production. Software in this status may change based on feedback.
9
-
10
7
  ## Documentation
11
8
 
12
9
  To learn how to use the XMTP client SDK for browsers, see [Get started with the XMTP Browser SDK](https://docs.xmtp.org/sdks/browser).
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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, Conversations as Conversations$1, ConsentState, Message, Conversation as Conversation$1, ConversationType, Client as Client$1, ConsentEntityType, Consent, UserPreference, SignatureRequestHandle, 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
- 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, SignatureRequestHandle, SortDirection, UserPreference } from '@xmtp/wasm-bindings';
3
+ import { Identifier, Conversations as Conversations$1, ConsentState, Message, Conversation as Conversation$1, ConversationType, Client as Client$1, ConsentEntityType, Consent, UserPreference, SignatureRequestHandle, KeyPackageStatus, PermissionUpdateType, PermissionPolicy, MetadataField, EncodedContent, SendMessageOpts, MessageDisappearingSettings, HmacKey, ConversationDebugInfo, GroupPermissionsOptions, DeliveryStatus, GroupMessageKind, ContentType, SortDirection, MessageSortBy, PermissionLevel, ListConversationsOrderBy, ContentTypeId, ListMessagesOptions, ListConversationsOptions, PermissionPolicySet, CreateGroupOptions, CreateDMOptions, Installation, InboxState, GroupMember, ApiStats, IdentityStats, GroupSyncSummary } from '@xmtp/wasm-bindings';
4
+ export { Consent, ConsentEntityType, ConsentState, ContentType, ContentTypeId, ConversationListItem, ConversationType, CreateDMOptions, CreateGroupOptions, DeliveryStatus, EncodedContent, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, GroupSyncSummary, HmacKey, Identifier, IdentifierKind, InboxState, Installation, ListConversationsOptions, ListMessagesOptions, LogOptions, Message, MessageDisappearingSettings, MetadataField, PermissionLevel, PermissionPolicy, PermissionPolicySet, PermissionUpdateType, SignatureRequestHandle, SortDirection, UserPreference } from '@xmtp/wasm-bindings';
5
5
  import { GroupUpdatedCodec } from '@xmtp/content-type-group-updated';
6
6
  import { TextCodec } from '@xmtp/content-type-text';
7
7
 
@@ -58,6 +58,11 @@ type StreamOptions<T = unknown, V = T> = {
58
58
  * (default: true)
59
59
  */
60
60
  retryOnFail?: boolean;
61
+ /**
62
+ * Whether to disable network sync before starting the stream
63
+ * (default: false)
64
+ */
65
+ disableSync?: boolean;
61
66
  };
62
67
  type StreamCallback<T = unknown> = (error: Error | null, value: T | undefined) => void;
63
68
  type StreamFunction<T = unknown> = (callback: StreamCallback<T>, onFail: () => void) => Promise<() => void>;
@@ -88,9 +93,9 @@ declare const createStream: <T = unknown, V = T>(streamFunction: StreamFunction<
88
93
  * @property {string} production - The production URL for the XMTP network
89
94
  */
90
95
  declare const ApiUrls: {
91
- readonly local: "http://localhost:5555";
92
- readonly dev: "https://dev.xmtp.network";
93
- readonly production: "https://production.xmtp.network";
96
+ readonly local: "http://localhost:5557";
97
+ readonly dev: "https://api.dev.xmtp.network:5558";
98
+ readonly production: "https://api.production.xmtp.network:5558";
94
99
  };
95
100
  /**
96
101
  * Pre-configured URLs for the XMTP history sync service based on the environment
@@ -125,6 +130,10 @@ type NetworkOptions = {
125
130
  * specific endpoint for syncing history
126
131
  */
127
132
  historySyncUrl?: string | null;
133
+ /**
134
+ * gatewayHost can be used to override the gateway endpoint
135
+ */
136
+ gatewayHost?: string | null;
128
137
  };
129
138
  type ContentOptions = {
130
139
  /**
@@ -230,7 +239,7 @@ declare class WorkerConversations {
230
239
  #private;
231
240
  constructor(client: WorkerClient, conversations: Conversations$1);
232
241
  sync(): Promise<void>;
233
- syncAll(consentStates?: ConsentState[]): Promise<number>;
242
+ syncAll(consentStates?: ConsentState[]): Promise<_xmtp_wasm_bindings.GroupSyncSummary>;
234
243
  getConversationById(id: string): WorkerConversation | undefined;
235
244
  getMessageById(id: string): Message | undefined;
236
245
  getDmByInboxId(inboxId: string): WorkerConversation | undefined;
@@ -247,6 +256,7 @@ declare class WorkerConversations {
247
256
  streamGroups(callback: StreamCallback<Conversation$1>, onFail: () => void): _xmtp_wasm_bindings.StreamCloser;
248
257
  streamDms(callback: StreamCallback<Conversation$1>, onFail: () => void): _xmtp_wasm_bindings.StreamCloser;
249
258
  streamAllMessages(callback: StreamCallback<Message>, onFail: () => void, conversationType?: ConversationType, consentStates?: ConsentState[]): _xmtp_wasm_bindings.StreamCloser;
259
+ streamMessageDeletions(callback: StreamCallback<string>): _xmtp_wasm_bindings.StreamCloser;
250
260
  }
251
261
 
252
262
  /**
@@ -267,7 +277,7 @@ declare class WorkerDebugInformation {
267
277
  declare class WorkerPreferences {
268
278
  #private;
269
279
  constructor(client: Client$1, conversations: Conversations$1);
270
- sync(): Promise<number>;
280
+ sync(): Promise<_xmtp_wasm_bindings.GroupSyncSummary>;
271
281
  inboxState(refreshFromNetwork: boolean): Promise<_xmtp_wasm_bindings.InboxState>;
272
282
  inboxStateFromInboxIds(inboxIds: string[], refreshFromNetwork?: boolean): Promise<_xmtp_wasm_bindings.InboxState[]>;
273
283
  getLatestInboxState(inboxId: string): Promise<_xmtp_wasm_bindings.InboxState>;
@@ -281,6 +291,8 @@ declare class WorkerClient {
281
291
  #private;
282
292
  constructor(client: Client$1, options?: ClientOptions);
283
293
  static create(identifier: Identifier, options?: Omit<ClientOptions, "codecs">): Promise<WorkerClient>;
294
+ get libxmtpVersion(): string;
295
+ get appVersion(): string;
284
296
  get accountIdentifier(): Identifier;
285
297
  get inboxId(): string;
286
298
  get installationId(): string;
@@ -296,7 +308,7 @@ declare class WorkerClient {
296
308
  createInboxSignatureRequest(): SignatureRequestHandle | undefined;
297
309
  addAccountSignatureRequest(newAccountIdentifier: Identifier): Promise<SignatureRequestHandle>;
298
310
  removeAccountSignatureRequest(identifier: Identifier): Promise<SignatureRequestHandle>;
299
- revokeAllOtherInstallationsSignatureRequest(): Promise<SignatureRequestHandle>;
311
+ revokeAllOtherInstallationsSignatureRequest(): Promise<SignatureRequestHandle | undefined>;
300
312
  revokeInstallationsSignatureRequest(installationIds: Uint8Array[]): Promise<SignatureRequestHandle>;
301
313
  changeRecoveryIdentifierSignatureRequest(identifier: Identifier): Promise<SignatureRequestHandle>;
302
314
  registerIdentity(signer: SafeSigner, signatureRequest: SignatureRequestHandle): Promise<void>;
@@ -346,9 +358,10 @@ declare class WorkerConversation {
346
358
  addSuperAdmin(inboxId: string): Promise<void>;
347
359
  removeSuperAdmin(inboxId: string): Promise<void>;
348
360
  publishMessages(): Promise<void>;
349
- sendOptimistic(encodedContent: EncodedContent): string;
350
- send(encodedContent: EncodedContent): Promise<string>;
361
+ sendOptimistic(encodedContent: EncodedContent, opts: SendMessageOpts): string;
362
+ send(encodedContent: EncodedContent, opts: SendMessageOpts): Promise<string>;
351
363
  messages(options?: SafeListMessagesOptions): Promise<Message[]>;
364
+ countMessages(options?: SafeListMessagesOptions): Promise<bigint>;
352
365
  get consentState(): ConsentState;
353
366
  updateConsentState(state: ConsentState): void;
354
367
  dmPeerInboxId(): string;
@@ -398,12 +411,23 @@ type SafeListMessagesOptions = {
398
411
  contentTypes?: ContentType[];
399
412
  deliveryStatus?: DeliveryStatus;
400
413
  direction?: SortDirection;
414
+ excludeContentTypes?: ContentType[];
415
+ excludeSenderInboxIds?: string[];
416
+ insertedAfterNs?: bigint;
417
+ insertedBeforeNs?: bigint;
418
+ kind?: GroupMessageKind;
401
419
  limit?: bigint;
402
420
  sentAfterNs?: bigint;
403
421
  sentBeforeNs?: bigint;
422
+ sortBy?: MessageSortBy;
404
423
  };
405
424
  declare const toSafeListMessagesOptions: (options: ListMessagesOptions) => SafeListMessagesOptions;
406
425
  declare const fromSafeListMessagesOptions: (options: SafeListMessagesOptions) => ListMessagesOptions;
426
+ type SafeSendMessageOpts = {
427
+ shouldPush: boolean;
428
+ };
429
+ declare const toSafeSendMessageOpts: (opts: SendMessageOpts) => SafeSendMessageOpts;
430
+ declare const fromSafeSendMessageOpts: (opts: SafeSendMessageOpts) => SendMessageOpts;
407
431
  type SafeListConversationsOptions = {
408
432
  consentStates?: ConsentState[];
409
433
  conversationType?: ConversationType;
@@ -411,6 +435,7 @@ type SafeListConversationsOptions = {
411
435
  createdBeforeNs?: bigint;
412
436
  includeDuplicateDms?: boolean;
413
437
  limit?: bigint;
438
+ orderBy?: ListConversationsOrderBy;
414
439
  };
415
440
  declare const toSafeListConversationsOptions: (options: ListConversationsOptions) => SafeListConversationsOptions;
416
441
  declare const fromSafeListConversationsOptions: (options: SafeListConversationsOptions) => ListConversationsOptions;
@@ -520,6 +545,10 @@ type SafeKeyPackageStatus = {
520
545
  validationError?: string;
521
546
  };
522
547
  declare const toSafeKeyPackageStatus: (status: KeyPackageStatus) => SafeKeyPackageStatus;
548
+ type SafeXMTPCursor = {
549
+ originatorID: number;
550
+ sequenceID: bigint;
551
+ };
523
552
  type SafeConversationDebugInfo = {
524
553
  epoch: bigint;
525
554
  maybeForked: boolean;
@@ -527,7 +556,7 @@ type SafeConversationDebugInfo = {
527
556
  isCommitLogForked?: boolean;
528
557
  localCommitLog: string;
529
558
  remoteCommitLog: string;
530
- cursor: bigint;
559
+ cursor: SafeXMTPCursor[];
531
560
  };
532
561
  declare const toSafeConversationDebugInfo: (debugInfo: ConversationDebugInfo) => SafeConversationDebugInfo;
533
562
  type SafeApiStats = {
@@ -605,7 +634,7 @@ type ClientAction = {
605
634
  action: "client.revokeAllOtherInstallationsSignatureText";
606
635
  id: string;
607
636
  result: {
608
- signatureText: string;
637
+ signatureText: string | undefined;
609
638
  signatureRequestId: string;
610
639
  };
611
640
  data: {
@@ -735,6 +764,16 @@ type ClientAction = {
735
764
  data: {
736
765
  installationIds: string[];
737
766
  };
767
+ } | {
768
+ action: "client.libxmtpVersion";
769
+ id: string;
770
+ result: string;
771
+ data: undefined;
772
+ } | {
773
+ action: "client.appVersion";
774
+ id: string;
775
+ result: string;
776
+ data: undefined;
738
777
  };
739
778
 
740
779
  type ConversationAction = {
@@ -751,6 +790,7 @@ type ConversationAction = {
751
790
  data: {
752
791
  id: string;
753
792
  content: SafeEncodedContent;
793
+ sendOptions: SafeSendMessageOpts;
754
794
  };
755
795
  } | {
756
796
  action: "conversation.sendOptimistic";
@@ -759,6 +799,7 @@ type ConversationAction = {
759
799
  data: {
760
800
  id: string;
761
801
  content: SafeEncodedContent;
802
+ sendOptions: SafeSendMessageOpts;
762
803
  };
763
804
  } | {
764
805
  action: "conversation.publishMessages";
@@ -775,6 +816,14 @@ type ConversationAction = {
775
816
  id: string;
776
817
  options?: SafeListMessagesOptions;
777
818
  };
819
+ } | {
820
+ action: "conversation.countMessages";
821
+ id: string;
822
+ result: bigint;
823
+ data: {
824
+ id: string;
825
+ options?: Omit<SafeListMessagesOptions, "limit" | "direction">;
826
+ };
778
827
  } | {
779
828
  action: "conversation.members";
780
829
  id: string;
@@ -985,6 +1034,13 @@ type ConversationsAction = {
985
1034
  conversationType?: ConversationType;
986
1035
  consentStates?: ConsentState[];
987
1036
  };
1037
+ } | {
1038
+ action: "conversations.streamMessageDeletions";
1039
+ id: string;
1040
+ result: undefined;
1041
+ data: {
1042
+ streamId: string;
1043
+ };
988
1044
  };
989
1045
 
990
1046
  type DebugInformationAction = {
@@ -1209,7 +1265,7 @@ type PreferencesAction = {
1209
1265
  } | {
1210
1266
  action: "preferences.sync";
1211
1267
  id: string;
1212
- result: number;
1268
+ result: GroupSyncSummary;
1213
1269
  data: undefined;
1214
1270
  } | {
1215
1271
  action: "preferences.streamConsent";
@@ -1274,6 +1330,10 @@ type StreamAction = {
1274
1330
  action: "stream.preferences";
1275
1331
  streamId: string;
1276
1332
  result: UserPreference[] | undefined;
1333
+ } | {
1334
+ action: "stream.messageDeleted";
1335
+ streamId: string;
1336
+ result: string | undefined;
1277
1337
  } | {
1278
1338
  action: "stream.fail";
1279
1339
  streamId: string;
@@ -1429,6 +1489,13 @@ declare class Conversation<ContentTypes = unknown> {
1429
1489
  * @returns Promise that resolves with an array of decoded messages
1430
1490
  */
1431
1491
  messages(options?: SafeListMessagesOptions): Promise<DecodedMessage<ContentTypes>[]>;
1492
+ /**
1493
+ * Counts messages in this conversation
1494
+ *
1495
+ * @param options - Optional filtering options
1496
+ * @returns Promise that resolves with the count of messages
1497
+ */
1498
+ countMessages(options?: Omit<SafeListMessagesOptions, "limit" | "direction">): Promise<bigint>;
1432
1499
  /**
1433
1500
  * Gets the consent state for this conversation
1434
1501
  *
@@ -1724,6 +1791,13 @@ declare class Conversations<ContentTypes = unknown> {
1724
1791
  * @returns Promise that resolves with the DM, if found
1725
1792
  */
1726
1793
  getDmByInboxId(inboxId: string): Promise<Dm<ContentTypes> | undefined>;
1794
+ /**
1795
+ * Retrieves a DM by identifier
1796
+ *
1797
+ * @param identifier - The identifier to look up
1798
+ * @returns Promise that resolves with the DM, if found
1799
+ */
1800
+ getDmByIdentifier(identifier: Identifier): Promise<Dm<ContentTypes> | undefined>;
1727
1801
  /**
1728
1802
  * Lists all conversations with optional filtering
1729
1803
  *
@@ -1846,6 +1920,13 @@ declare class Conversations<ContentTypes = unknown> {
1846
1920
  streamAllDmMessages(options?: StreamOptions<SafeMessage, DecodedMessage<ContentTypes>> & {
1847
1921
  consentStates?: ConsentState[];
1848
1922
  }): Promise<AsyncStreamProxy<DecodedMessage<ContentTypes>>>;
1923
+ /**
1924
+ * Creates a stream for message deletions
1925
+ *
1926
+ * @param options - Optional stream options
1927
+ * @returns Stream instance for message deletions
1928
+ */
1929
+ streamMessageDeletions(options?: Omit<StreamOptions<string>, "disableSync" | "onFail" | "onRetry" | "onRestart" | "retryAttempts" | "retryDelay" | "retryOnFail">): Promise<AsyncStreamProxy<string>>;
1849
1930
  }
1850
1931
 
1851
1932
  /**
@@ -1876,7 +1957,7 @@ declare class Preferences<ContentTypes = unknown> {
1876
1957
  * @param client - The client instance managing preferences
1877
1958
  */
1878
1959
  constructor(client: Client<ContentTypes>);
1879
- sync(): Promise<number>;
1960
+ sync(): Promise<_xmtp_wasm_bindings.GroupSyncSummary>;
1880
1961
  /**
1881
1962
  * Retrieves the current inbox state
1882
1963
  *
@@ -2021,6 +2102,14 @@ declare class Client<ContentTypes = ExtractCodecContentTypes> extends ClientWork
2021
2102
  * Gets the preferences manager for this client
2022
2103
  */
2023
2104
  get preferences(): Preferences<ContentTypes>;
2105
+ /**
2106
+ * Gets the version of libxmtp used in the bindings
2107
+ */
2108
+ libxmtpVersion(): Promise<string>;
2109
+ /**
2110
+ * Gets the app version used by the client
2111
+ */
2112
+ appVersion(): Promise<string>;
2024
2113
  /**
2025
2114
  * Creates signature text for creating a new inbox
2026
2115
  *
@@ -2083,7 +2172,7 @@ declare class Client<ContentTypes = ExtractCodecContentTypes> extends ClientWork
2083
2172
  * @returns The signature text and signature request ID
2084
2173
  */
2085
2174
  unsafe_revokeAllOtherInstallationsSignatureText(): Promise<{
2086
- signatureText: string;
2175
+ signatureText: string | undefined;
2087
2176
  signatureRequestId: string;
2088
2177
  }>;
2089
2178
  /**
@@ -2196,7 +2285,7 @@ declare class Client<ContentTypes = ExtractCodecContentTypes> extends ClientWork
2196
2285
  * @param inboxId - The inbox ID to revoke installations for
2197
2286
  * @param installationIds - The installation IDs to revoke
2198
2287
  */
2199
- static revokeInstallations(signer: Signer, inboxId: string, installationIds: Uint8Array[], env?: XmtpEnv, enableLogging?: boolean): Promise<void>;
2288
+ static revokeInstallations(signer: Signer, inboxId: string, installationIds: Uint8Array[], env?: XmtpEnv, gatewayHost?: string, enableLogging?: boolean): Promise<void>;
2200
2289
  /**
2201
2290
  * Gets the inbox state for the specified inbox IDs without a client
2202
2291
  *
@@ -2204,7 +2293,7 @@ declare class Client<ContentTypes = ExtractCodecContentTypes> extends ClientWork
2204
2293
  * @param env - The environment to use
2205
2294
  * @returns The inbox state for the specified inbox IDs
2206
2295
  */
2207
- static inboxStateFromInboxIds(inboxIds: string[], env?: XmtpEnv, enableLogging?: boolean): Promise<SafeInboxState[]>;
2296
+ static inboxStateFromInboxIds(inboxIds: string[], env?: XmtpEnv, enableLogging?: boolean, gatewayHost?: string): Promise<SafeInboxState[]>;
2208
2297
  /**
2209
2298
  * Changes the recovery identifier for the client's inbox
2210
2299
  *
@@ -2258,6 +2347,20 @@ declare class Client<ContentTypes = ExtractCodecContentTypes> extends ClientWork
2258
2347
  * @throws {CodecNotFoundError} if no codec is found for the content type
2259
2348
  */
2260
2349
  encodeContent(content: ContentTypes, contentType: ContentTypeId$1): SafeEncodedContent;
2350
+ /**
2351
+ * Prepares content for sending by encoding it and generating send options from the codec
2352
+ *
2353
+ * @param content - The message content to prepare for sending
2354
+ * @param contentType - The content type identifier for the appropriate codec
2355
+ * @returns An object containing the encoded content and send options
2356
+ * @throws {CodecNotFoundError} When no codec is registered for the specified content type
2357
+ */
2358
+ prepareForSend(content: ContentTypes, contentType: ContentTypeId$1): {
2359
+ encodedContent: SafeEncodedContent;
2360
+ sendOptions: {
2361
+ shouldPush: boolean;
2362
+ };
2363
+ };
2261
2364
  /**
2262
2365
  * Decodes a message for a given content type
2263
2366
  *
@@ -2322,6 +2425,7 @@ type UtilsWorkerAction = {
2322
2425
  data: {
2323
2426
  identifier: Identifier;
2324
2427
  env?: XmtpEnv;
2428
+ gatewayHost?: string;
2325
2429
  };
2326
2430
  } | {
2327
2431
  action: "utils.revokeInstallationsSignatureText";
@@ -2334,6 +2438,7 @@ type UtilsWorkerAction = {
2334
2438
  env?: XmtpEnv;
2335
2439
  identifier: Identifier;
2336
2440
  inboxId: string;
2441
+ gatewayHost?: string;
2337
2442
  installationIds: Uint8Array[];
2338
2443
  signatureRequestId: string;
2339
2444
  };
@@ -2345,6 +2450,7 @@ type UtilsWorkerAction = {
2345
2450
  env?: XmtpEnv;
2346
2451
  signer: SafeSigner;
2347
2452
  signatureRequestId: string;
2453
+ gatewayHost?: string;
2348
2454
  };
2349
2455
  } | {
2350
2456
  action: "utils.inboxStateFromInboxIds";
@@ -2353,6 +2459,7 @@ type UtilsWorkerAction = {
2353
2459
  data: {
2354
2460
  inboxIds: string[];
2355
2461
  env?: XmtpEnv;
2462
+ gatewayHost?: string;
2356
2463
  };
2357
2464
  };
2358
2465
 
@@ -2418,9 +2525,10 @@ declare class Utils extends UtilsWorkerClass {
2418
2525
  *
2419
2526
  * @param identifier - The identifier to get the inbox ID for
2420
2527
  * @param env - Optional XMTP environment configuration (default: "dev")
2528
+ * @param gatewayHost - Optional gateway host override
2421
2529
  * @returns Promise that resolves with the inbox ID for the identifier
2422
2530
  */
2423
- getInboxIdForIdentifier(identifier: Identifier, env?: XmtpEnv): Promise<string | undefined>;
2531
+ getInboxIdForIdentifier(identifier: Identifier, env?: XmtpEnv, gatewayHost?: string): Promise<string | undefined>;
2424
2532
  /**
2425
2533
  * Creates signature text for revoking installations
2426
2534
  *
@@ -2434,9 +2542,10 @@ declare class Utils extends UtilsWorkerClass {
2434
2542
  * @param identifier - The identifier to revoke installations for
2435
2543
  * @param inboxId - The inbox ID to revoke installations for
2436
2544
  * @param installationIds - The installation IDs to revoke
2545
+ * @param gatewayHost - Optional gateway host override
2437
2546
  * @returns The signature text and signature request ID
2438
2547
  */
2439
- revokeInstallationsSignatureText(identifier: Identifier, inboxId: string, installationIds: Uint8Array[], env?: XmtpEnv): Promise<{
2548
+ revokeInstallationsSignatureText(identifier: Identifier, inboxId: string, installationIds: Uint8Array[], env?: XmtpEnv, gatewayHost?: string): Promise<{
2440
2549
  signatureText: string;
2441
2550
  signatureRequestId: string;
2442
2551
  }>;
@@ -2447,9 +2556,10 @@ declare class Utils extends UtilsWorkerClass {
2447
2556
  * @param signer - The signer to use
2448
2557
  * @param inboxId - The inbox ID to revoke installations for
2449
2558
  * @param installationIds - The installation IDs to revoke
2559
+ * @param gatewayHost - Optional gateway host override
2450
2560
  * @returns Promise that resolves with the result of the revoke installations operation
2451
2561
  */
2452
- revokeInstallations(signer: Signer, inboxId: string, installationIds: Uint8Array[], env?: XmtpEnv): Promise<void>;
2562
+ revokeInstallations(signer: Signer, inboxId: string, installationIds: Uint8Array[], env?: XmtpEnv, gatewayHost?: string): Promise<void>;
2453
2563
  /**
2454
2564
  * Gets the inbox state for the specified inbox IDs without a client
2455
2565
  *
@@ -2457,7 +2567,7 @@ declare class Utils extends UtilsWorkerClass {
2457
2567
  * @param env - The environment to use
2458
2568
  * @returns The inbox state for the specified inbox IDs
2459
2569
  */
2460
- inboxStateFromInboxIds(inboxIds: string[], env?: XmtpEnv): Promise<SafeInboxState[]>;
2570
+ inboxStateFromInboxIds(inboxIds: string[], env?: XmtpEnv, gatewayHost?: string): Promise<SafeInboxState[]>;
2461
2571
  }
2462
2572
 
2463
2573
  declare class ClientNotInitializedError extends Error {
@@ -2494,5 +2604,5 @@ declare class StreamInvalidRetryAttemptsError extends Error {
2494
2604
  constructor();
2495
2605
  }
2496
2606
 
2497
- export { AccountAlreadyAssociatedError, ApiUrls, Client, ClientNotInitializedError, CodecNotFoundError, Conversation, Conversations, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY, DecodedMessage, Dm, Group, GroupNotFoundError, HistorySyncUrls, InboxReassignError, InvalidGroupMembershipChangeError, MissingContentTypeError, SignerUnavailableError, StreamFailedError, StreamInvalidRetryAttemptsError, StreamNotFoundError, Utils, createStream, 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, toSafeSigner };
2498
- export type { AsyncStreamProxy, ClientOptions, ContentOptions, EOASigner, ExtractCodecContentTypes, HmacKeys, MessageDeliveryStatus, MessageKind, NetworkOptions, OtherOptions, SCWSigner, SafeApiStats, SafeConsent, SafeContentTypeId, SafeConversation, SafeConversationDebugInfo, SafeCreateDmOptions, SafeCreateGroupOptions, SafeEncodedContent, SafeGroupMember, SafeHmacKey, SafeHmacKeys, SafeIdentityStats, SafeInboxState, SafeInstallation, SafeKeyPackageStatus, SafeListConversationsOptions, SafeListMessagesOptions, SafeMessage, SafeMessageDisappearingSettings, SafePermissionPolicySet, SafeSigner, Signer, StorageOptions, StreamCallback, StreamFunction, StreamOptions, StreamValueMutator, XmtpEnv };
2607
+ export { AccountAlreadyAssociatedError, ApiUrls, Client, ClientNotInitializedError, CodecNotFoundError, Conversation, Conversations, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY, DecodedMessage, Dm, Group, GroupNotFoundError, HistorySyncUrls, InboxReassignError, InvalidGroupMembershipChangeError, MissingContentTypeError, SignerUnavailableError, StreamFailedError, StreamInvalidRetryAttemptsError, StreamNotFoundError, Utils, createStream, fromContentTypeId, fromEncodedContent, fromSafeConsent, fromSafeContentTypeId, fromSafeCreateDmOptions, fromSafeCreateGroupOptions, fromSafeEncodedContent, fromSafeGroupMember, fromSafeListConversationsOptions, fromSafeListMessagesOptions, fromSafeMessageDisappearingSettings, fromSafePermissionPolicySet, fromSafeSendMessageOpts, toContentTypeId, toEncodedContent, toSafeApiStats, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeConversationDebugInfo, toSafeCreateDmOptions, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeHmacKey, toSafeIdentityStats, toSafeInboxState, toSafeInstallation, toSafeKeyPackageStatus, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage, toSafeMessageDisappearingSettings, toSafePermissionPolicySet, toSafeSendMessageOpts, toSafeSigner };
2608
+ export type { AsyncStreamProxy, ClientOptions, ContentOptions, EOASigner, ExtractCodecContentTypes, HmacKeys, MessageDeliveryStatus, MessageKind, NetworkOptions, OtherOptions, SCWSigner, SafeApiStats, SafeConsent, SafeContentTypeId, SafeConversation, SafeConversationDebugInfo, SafeCreateDmOptions, SafeCreateGroupOptions, SafeEncodedContent, SafeGroupMember, SafeHmacKey, SafeHmacKeys, SafeIdentityStats, SafeInboxState, SafeInstallation, SafeKeyPackageStatus, SafeListConversationsOptions, SafeListMessagesOptions, SafeMessage, SafeMessageDisappearingSettings, SafePermissionPolicySet, SafeSendMessageOpts, SafeSigner, SafeXMTPCursor, Signer, StorageOptions, StreamCallback, StreamFunction, StreamOptions, StreamValueMutator, XmtpEnv };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{GroupUpdatedCodec as e,ContentTypeGroupUpdated as t}from"@xmtp/content-type-group-updated";import{ContentTypeText as s,TextCodec as n}from"@xmtp/content-type-text";import{ContentTypeId as i,EncodedContent as r,ListMessagesOptions as a,ListConversationsOptions as o,PermissionPolicySet as c,CreateGroupOptions as d,CreateDMOptions as l,Consent as u,GroupMember as g,MessageDisappearingSettings as h,GroupPermissionsOptions as p,GroupMessageKind as m,DeliveryStatus as y,ConversationType as I}from"@xmtp/wasm-bindings";export{Consent,ConsentEntityType,ConsentState,ContentType,ContentTypeId,ConversationListItem,ConversationType,CreateDMOptions,CreateGroupOptions,DeliveryStatus,EncodedContent,GroupMember,GroupMembershipState,GroupMessageKind,GroupMetadata,GroupPermissions,GroupPermissionsOptions,HmacKey,InboxState,Installation,ListConversationsOptions,ListMessagesOptions,LogOptions,Message,MessageDisappearingSettings,MetadataField,PermissionLevel,PermissionPolicy,PermissionPolicySet,PermissionUpdateType,SignatureRequestHandle,SortDirection}from"@xmtp/wasm-bindings";import{v4 as v}from"uuid";import{ContentTypeId as w}from"@xmtp/content-type-primitives";const f=e=>{console.error(e.message)};class M{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),t&&this.#e.addEventListener("error",f),this.#t=t}sendMessage(e,t){const s=v();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("client received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(t.error):s.resolve(t.result))};handleStreamMessage=(e,t,s)=>{const n=n=>{const i=n.data;if(i.streamId===e){if("stream.fail"===i.action)return void s?.onFail?.();"error"in i?t(i.error,void 0):t(null,i.result)}};return this.#e.addEventListener("message",n),async()=>{await this.sendMessage("endStream",{streamId:e}),this.#e.removeEventListener("message",n)}};close(){this.#e.removeEventListener("message",this.handleMessage),this.#t&&this.#e.removeEventListener("error",f),this.#e.terminate()}}const b=e=>new w({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),S=e=>new i(e.authorityId,e.typeId,e.versionMajor,e.versionMinor),x=e=>({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),A=e=>new w({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),k=e=>({type:b(e.type),parameters:Object.fromEntries(e.parameters),fallback:e.fallback,compression:e.compression,content:e.content}),D=e=>new r(S(e.type),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content),P=e=>({type:x(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),T=e=>({type:A(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),C=e=>({content:P(k(e.content)),convoId:e.convoId,deliveryStatus:e.deliveryStatus,id:e.id,kind:e.kind,senderInboxId:e.senderInboxId,sentAtNs:e.sentAtNs}),R=e=>({contentTypes:e.contentTypes,deliveryStatus:e.deliveryStatus,direction:e.direction,limit:e.limit,sentAfterNs:e.sentAfterNs,sentBeforeNs:e.sentBeforeNs}),N=e=>new a(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction,e.contentTypes),L=e=>({consentStates:e.consentStates,conversationType:e.conversationType,createdAfterNs:e.createdAfterNs,createdBeforeNs:e.createdBeforeNs,includeDuplicateDms:e.includeDuplicateDms,limit:e.limit}),q=e=>new o(e.consentStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.includeDuplicateDms??!1,e.limit),_=e=>({addAdminPolicy:e.addAdminPolicy,addMemberPolicy:e.addMemberPolicy,removeAdminPolicy:e.removeAdminPolicy,removeMemberPolicy:e.removeMemberPolicy,updateGroupDescriptionPolicy:e.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.updateGroupNamePolicy,updateMessageDisappearingPolicy:e.updateMessageDisappearingPolicy}),F=e=>new c(e.addMemberPolicy,e.removeMemberPolicy,e.addAdminPolicy,e.removeAdminPolicy,e.updateGroupNamePolicy,e.updateGroupDescriptionPolicy,e.updateGroupImageUrlSquarePolicy,e.updateMessageDisappearingPolicy),G=e=>({customPermissionPolicySet:e.customPermissionPolicySet,description:e.groupDescription,imageUrlSquare:e.groupImageUrlSquare,messageDisappearingSettings:e.messageDisappearingSettings?J(e.messageDisappearingSettings):void 0,name:e.groupName,permissions:e.permissions}),B=e=>new d(e.permissions,e.name,e.imageUrlSquare,e.description,e.customPermissionPolicySet&&e.permissions===p.CustomPolicy?F(e.customPermissionPolicySet):void 0,e.messageDisappearingSettings?Q(e.messageDisappearingSettings):void 0),E=e=>({messageDisappearingSettings:e.messageDisappearingSettings?J(e.messageDisappearingSettings):void 0}),U=e=>new l(e.messageDisappearingSettings?Q(e.messageDisappearingSettings):void 0),O=async e=>{const t=e.id,s=e.name,n=e.imageUrl,i=e.description,r=e.permissions,a=e.addedByInboxId,o=await e.metadata(),c=e.admins,d=e.superAdmins,l=e.createdAtNs,u=r.policyType,g=r.policySet,h=e.isCommitLogForked;return{id:t,name:s,imageUrl:n,description:i,permissions:{policyType:u,policySet:{addAdminPolicy:g.addAdminPolicy,addMemberPolicy:g.addMemberPolicy,removeAdminPolicy:g.removeAdminPolicy,removeMemberPolicy:g.removeMemberPolicy,updateGroupDescriptionPolicy:g.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:g.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:g.updateGroupNamePolicy,updateMessageDisappearingPolicy:g.updateMessageDisappearingPolicy}},addedByInboxId:a,metadata:o,admins:c,superAdmins:d,createdAtNs:l,isCommitLogForked:h}},K=e=>({bytes:e.bytes,clientTimestampNs:e.clientTimestampNs,id:e.id}),W=e=>({identifiers:e.accountIdentifiers,inboxId:e.inboxId,installations:e.installations.map(K),recoveryIdentifier:e.recoveryIdentifier}),j=e=>({entity:e.entity,entityType:e.entityType,state:e.state}),$=e=>new u(e.entityType,e.state,e.entity),H=e=>({accountIdentifiers:e.accountIdentifiers,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}),V=e=>new g(e.inboxId,e.accountIdentifiers,e.installationIds,e.permissionLevel,e.consentState),z=e=>({key:e.key,epoch:e.epoch}),J=e=>({fromNs:e.fromNs,inNs:e.inNs}),Q=e=>new h(e.fromNs,e.inNs),X=e=>({lifetime:e.lifetime?{notBefore:e.lifetime.not_before,notAfter:e.lifetime.not_after}:void 0,validationError:e.validationError}),Y=e=>({epoch:e.epoch,maybeForked:e.maybeForked,forkDetails:e.forkDetails,isCommitLogForked:e.isCommitLogForked,localCommitLog:e.localCommitLog,remoteCommitLog:e.remoteCommitLog,cursor:e.cursor}),Z=e=>({uploadKeyPackage:e.upload_key_package,fetchKeyPackage:e.fetch_key_package,sendGroupMessages:e.send_group_messages,sendWelcomeMessages:e.send_welcome_messages,queryGroupMessages:e.query_group_messages,queryWelcomeMessages:e.query_welcome_messages,subscribeMessages:e.subscribe_messages,subscribeWelcomes:e.subscribe_welcomes}),ee=e=>({getIdentityUpdatesV2:e.get_identity_updates_v2,getInboxIds:e.get_inbox_ids,publishIdentityUpdate:e.publish_identity_update,verifySmartContractWalletSignature:e.verify_smart_contract_wallet_signature});class te{#n;content;contentType;conversationId;deliveryStatus;fallback;compression;id;kind;parameters;encodedContent;senderInboxId;sentAtNs;constructor(e,t){switch(this.#n=e,this.id=t.id,this.sentAtNs=t.sentAtNs,this.conversationId=t.convoId,this.senderInboxId=t.senderInboxId,this.encodedContent=t.content,t.kind){case m.Application:this.kind="application";break;case m.MembershipChange:this.kind="membership_change"}switch(t.deliveryStatus){case y.Unpublished:this.deliveryStatus="unpublished";break;case y.Published:this.deliveryStatus="published";break;case y.Failed:this.deliveryStatus="failed"}this.contentType=A(t.content.type),this.parameters=new Map(Object.entries(t.content.parameters)),this.fallback=t.content.fallback,this.compression=t.content.compression;try{this.content=this.#n.decodeContent(t,this.contentType)}catch{this.content=void 0}}}class se extends Error{constructor(){super("Client not initialized, use Client.create or Client.build to create a client")}}class ne extends Error{constructor(){super("Signer unavailable, use Client.create to create a client with a signer")}}class ie extends Error{constructor(e){super(`Codec not found for "${e.toString()}" content type`)}}class re extends Error{constructor(){super("Unable to create add account signature text, `allowInboxReassign` must be true")}}class ae extends Error{constructor(e){super(`Account already associated with inbox ${e}`)}}class oe extends Error{constructor(e){super(`Group "${e}" not found`)}}class ce extends Error{constructor(e){super(`Stream "${e}" not found`)}}class de extends Error{constructor(e){super(`Invalid group membership change for message ${e}`)}}class le extends Error{constructor(){super("Content type is required when sending content other than text")}}class ue extends Error{constructor(e){super(`Stream failed, retried ${e} ${"time"+(1!==e?"s":"")}`)}}class ge extends Error{constructor(){super("Stream retry attempts must be greater than 0")}}class he{isDone=!1;#i=[];#r;onDone;onReturn;constructor(){this.#r=[],this.isDone=!1}flush(){for(;this.#i.length>0;){const e=this.#i.shift();e&&e({done:!0,value:void 0})}}done(){this.flush(),this.#r=[],this.#i=[],this.isDone=!0,this.onDone?.()}push=e=>{if(this.isDone)return;const t=this.#i.shift();t?t({done:!1,value:e}):this.#r.push(e)};next=()=>this.isDone?Promise.resolve({done:!0,value:void 0}):this.#r.length>0?Promise.resolve({done:!1,value:this.#r.shift()}):new Promise((e=>{this.#i.push(e)}));return=()=>(this.onReturn?.(),this.done(),Promise.resolve({done:!0,value:void 0}));end=()=>this.return();[Symbol.asyncIterator](){return this}}const pe=["end","isDone","next","return",Symbol.asyncIterator],me=e=>pe.includes(e);const ye=1e4,Ie=6,ve=async(e,t,s)=>{const{onEnd:n,onError:i,onFail:r,onRestart:a,onRetry:o,onValue:c,retryAttempts:d=Ie,retryDelay:l=ye,retryOnFail:u=!0}=s??{};if(u&&d<0)throw new ge;const g=new he,h=(e,s)=>{if(e)i?.(e);else if(void 0!==s)try{if(t){const e=t(s);(e=>!!e&&("object"==typeof e||"function"==typeof e)&&"then"in e&&"function"==typeof e.then)(e)?e.then((e=>{g.push(e),c?.(e)})).catch((e=>{i?.(e)})):(g.push(e),c?.(e))}else g.push(s),c?.(s)}catch(e){i?.(e)}},p=async(t=d)=>{try{if(0===t)throw g.end(),new ue(d);await(s=l,new Promise((e=>setTimeout(e,s)))),o?.(d-t+1,d);const i=await e(h,(()=>{r?.(),p()}));g.onDone=()=>{i(),n?.()},a?.()}catch(e){i?.(e),p(t-1)}var s},m=()=>{if(!u)throw g.end(),new ue(0);p()};try{const t=await e(h,(()=>{r?.(),m()}));g.onDone=()=>{t(),n?.()}}catch(e){i?.(e),m()}return new Proxy(g,{get(e,t,s){if(me(t))return Reflect.get(e,t,s)},set:()=>!0,has:(e,t)=>me(t),ownKeys:()=>pe,getOwnPropertyDescriptor(e,t){if(me(t))return{enumerable:!0,configurable:!0,value:Reflect.get(e,t)}}})};class we{#a;#n;#o;#c;#d;#l;constructor(e,t,s){this.#n=e,this.#c=t,this.#u(s)}#u(e){this.#a=e?.addedByInboxId,this.#d=e?.metadata,this.#o=e?.createdAtNs,this.#l=e?.isCommitLogForked}get id(){return this.#c}get isCommitLogForked(){return this.#l}get addedByInboxId(){return this.#a}get createdAtNs(){return this.#o}get createdAt(){return this.#o?(e=this.#o,new Date(Number(e/1000000n))):void 0;var e}get metadata(){return this.#d}async lastMessage(){const e=await this.#n.sendMessage("conversation.lastMessage",{id:this.#c});return e?new te(this.#n,e):void 0}async isActive(){return this.#n.sendMessage("conversation.isActive",{id:this.#c})}async members(){return this.#n.sendMessage("conversation.members",{id:this.#c})}async sync(){const e=await this.#n.sendMessage("conversation.sync",{id:this.#c});return this.#u(e),e}async publishMessages(){return this.#n.sendMessage("conversation.publishMessages",{id:this.#c})}async sendOptimistic(e,t){if("string"!=typeof e&&!t)throw new le;const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("conversation.sendOptimistic",{id:this.#c,content:n})}async send(e,t){if("string"!=typeof e&&!t)throw new le;const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("conversation.send",{id:this.#c,content:n})}async messages(e){return(await this.#n.sendMessage("conversation.messages",{id:this.#c,options:e})).map((e=>new te(this.#n,e)))}async consentState(){return this.#n.sendMessage("conversation.consentState",{id:this.#c})}async updateConsentState(e){return this.#n.sendMessage("conversation.updateConsentState",{id:this.#c,state:e})}async messageDisappearingSettings(){return this.#n.sendMessage("conversation.messageDisappearingSettings",{id:this.#c})}async updateMessageDisappearingSettings(e,t){return this.#n.sendMessage("conversation.updateMessageDisappearingSettings",{id:this.#c,fromNs:e,inNs:t})}async removeMessageDisappearingSettings(){return this.#n.sendMessage("conversation.removeMessageDisappearingSettings",{id:this.#c})}async isMessageDisappearingEnabled(){return this.#n.sendMessage("conversation.isMessageDisappearingEnabled",{id:this.#c})}async stream(e){return ve((async(t,s)=>{const n=v();return await this.sync(),await this.#n.sendMessage("conversation.stream",{groupId:this.#c,streamId:n}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),(e=>new te(this.#n,e)),e)}async pausedForVersion(){return this.#n.sendMessage("conversation.pausedForVersion",{id:this.#c})}async getHmacKeys(){return this.#n.sendMessage("conversation.getHmacKeys",{id:this.#c})}async debugInfo(){return this.#n.sendMessage("conversation.debugInfo",{id:this.#c})}}class fe extends we{#n;#c;constructor(e,t,s){super(e,t,s),this.#n=e,this.#c=t}async peerInboxId(){return this.#n.sendMessage("dm.peerInboxId",{id:this.#c})}async getDuplicateDms(){return this.#n.sendMessage("dm.getDuplicateDms",{id:this.#c})}}class Me extends we{#g=[];#n;#h;#c;#p;#m;#y=[];#u(e){this.#m=e?.name??"",this.#p=e?.imageUrl??"",this.#h=e?.description??"",this.#g=e?.admins??[],this.#y=e?.superAdmins??[]}constructor(e,t,s){super(e,t,s),this.#n=e,this.#c=t,this.#u(s)}async sync(){const e=await super.sync();return this.#u(e),e}get name(){return this.#m}async updateName(e){await this.#n.sendMessage("group.updateName",{id:this.#c,name:e}),this.#m=e}get imageUrl(){return this.#p}async updateImageUrl(e){await this.#n.sendMessage("group.updateImageUrl",{id:this.#c,imageUrl:e}),this.#p=e}get description(){return this.#h}async updateDescription(e){await this.#n.sendMessage("group.updateDescription",{id:this.#c,description:e}),this.#h=e}get admins(){return this.#g}get superAdmins(){return this.#y}async listAdmins(){const e=await this.#n.sendMessage("group.listAdmins",{id:this.#c});return this.#g=e,e}async listSuperAdmins(){const e=await this.#n.sendMessage("group.listSuperAdmins",{id:this.#c});return this.#y=e,e}async permissions(){return this.#n.sendMessage("group.permissions",{id:this.#c})}async updatePermission(e,t,s){return this.#n.sendMessage("group.updatePermission",{id:this.#c,permissionType:e,policy:t,metadataField:s})}async isAdmin(e){return(await this.listAdmins()).includes(e)}async isSuperAdmin(e){return(await this.listSuperAdmins()).includes(e)}async addMembersByIdentifiers(e){return this.#n.sendMessage("group.addMembersByIdentifiers",{id:this.#c,identifiers:e})}async addMembers(e){return this.#n.sendMessage("group.addMembers",{id:this.#c,inboxIds:e})}async removeMembersByIdentifiers(e){return this.#n.sendMessage("group.removeMembersByIdentifiers",{id:this.#c,identifiers:e})}async removeMembers(e){return this.#n.sendMessage("group.removeMembers",{id:this.#c,inboxIds:e})}async addAdmin(e){return this.#n.sendMessage("group.addAdmin",{id:this.#c,inboxId:e})}async removeAdmin(e){return this.#n.sendMessage("group.removeAdmin",{id:this.#c,inboxId:e})}async addSuperAdmin(e){return this.#n.sendMessage("group.addSuperAdmin",{id:this.#c,inboxId:e})}async removeSuperAdmin(e){return this.#n.sendMessage("group.removeSuperAdmin",{id:this.#c,inboxId:e})}}class be{#n;constructor(e){this.#n=e}async sync(){return this.#n.sendMessage("conversations.sync",void 0)}async syncAll(e){return this.#n.sendMessage("conversations.syncAll",{consentStates:e})}async getConversationById(e){const t=await this.#n.sendMessage("conversations.getConversationById",{id:e});if(t)return"group"===t.metadata.conversationType?new Me(this.#n,t.id,t):new fe(this.#n,t.id,t)}async getMessageById(e){const t=await this.#n.sendMessage("conversations.getMessageById",{id:e});return t?new te(this.#n,t):void 0}async getDmByInboxId(e){const t=await this.#n.sendMessage("conversations.getDmByInboxId",{inboxId:e});return t?new fe(this.#n,t.id,t):void 0}async list(e){return(await this.#n.sendMessage("conversations.list",{options:e})).map((e=>{switch(e.metadata.conversationType){case"dm":return new fe(this.#n,e.id,e);case"group":return new Me(this.#n,e.id,e);default:return}})).filter((e=>void 0!==e))}async listGroups(e){return(await this.#n.sendMessage("conversations.listGroups",{options:e})).map((e=>new Me(this.#n,e.id,e)))}async listDms(e){return(await this.#n.sendMessage("conversations.listDms",{options:e})).map((e=>new fe(this.#n,e.id,e)))}async newGroupOptimistic(e){const t=await this.#n.sendMessage("conversations.newGroupOptimistic",{options:e});return new Me(this.#n,t.id,t)}async newGroupWithIdentifiers(e,t){const s=await this.#n.sendMessage("conversations.newGroupWithIdentifiers",{identifiers:e,options:t});return new Me(this.#n,s.id,s)}async newGroup(e,t){const s=await this.#n.sendMessage("conversations.newGroup",{inboxIds:e,options:t});return new Me(this.#n,s.id,s)}async newDmWithIdentifier(e,t){const s=await this.#n.sendMessage("conversations.newDmWithIdentifier",{identifier:e,options:t});return new fe(this.#n,s.id,s)}async newDm(e,t){const s=await this.#n.sendMessage("conversations.newDm",{inboxId:e,options:t});return new fe(this.#n,s.id,s)}async getHmacKeys(){return this.#n.sendMessage("conversations.getHmacKeys",void 0)}async stream(e){return ve((async(t,s)=>{const n=v();return await this.sync(),await this.#n.sendMessage("conversations.stream",{streamId:n,conversationType:e?.conversationType}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),(e=>"group"===e.metadata.conversationType?new Me(this.#n,e.id,e):new fe(this.#n,e.id,e)),e)}async streamGroups(e){return this.stream({...e,conversationType:I.Group})}async streamDms(e){return this.stream({...e,conversationType:I.Dm})}async streamAllMessages(e){return ve((async(t,s)=>{const n=v();return await this.sync(),await this.#n.sendMessage("conversations.streamAllMessages",{streamId:n,conversationType:e?.conversationType,consentStates:e?.consentStates}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),(e=>new te(this.#n,e)),e)}async streamAllGroupMessages(e){return this.streamAllMessages({...e,conversationType:I.Group})}async streamAllDmMessages(e){return this.streamAllMessages({...e,conversationType:I.Dm})}}class Se{#n;constructor(e){this.#n=e}apiStatistics(){return this.#n.sendMessage("debugInformation.apiStatistics",void 0)}apiIdentityStatistics(){return this.#n.sendMessage("debugInformation.apiIdentityStatistics",void 0)}apiAggregateStatistics(){return this.#n.sendMessage("debugInformation.apiAggregateStatistics",void 0)}clearAllStatistics(){return this.#n.sendMessage("debugInformation.clearAllStatistics",void 0)}uploadDebugArchive(e){return this.#n.sendMessage("debugInformation.uploadDebugArchive",{serverUrl:e})}}class xe{#n;constructor(e){this.#n=e}sync(){return this.#n.sendMessage("preferences.sync",void 0)}async inboxState(e){return this.#n.sendMessage("preferences.inboxState",{refreshFromNetwork:e??!1})}async inboxStateFromInboxIds(e,t){return this.#n.sendMessage("preferences.inboxStateFromInboxIds",{inboxIds:e,refreshFromNetwork:t??!1})}async getLatestInboxState(e){return this.#n.sendMessage("preferences.getLatestInboxState",{inboxId:e})}async setConsentStates(e){return this.#n.sendMessage("preferences.setConsentStates",{records:e})}async getConsentState(e,t){return this.#n.sendMessage("preferences.getConsentState",{entityType:e,entity:t})}async streamConsent(e){return ve((async(t,s)=>{const n=v();return await this.sync(),await this.#n.sendMessage("preferences.streamConsent",{streamId:n}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),void 0,e)}async streamPreferences(e){return ve((async(t,s)=>{const n=v();return await this.sync(),await this.#n.sendMessage("preferences.streamPreferences",{streamId:n}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),void 0,e)}}const Ae=async(e,t)=>{switch(e.type){case"EOA":return{type:"EOA",identifier:await e.getIdentifier(),signature:t};case"SCW":return{type:"SCW",identifier:await e.getIdentifier(),signature:t,chainId:e.getChainId(),blockNumber:e.getBlockNumber?.()}}},ke=e=>{console.error(e.message)};class De{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),t&&this.#e.addEventListener("error",ke),this.#t=t}async init(){return this.sendMessage("utils.init",{enableLogging:this.#t})}sendMessage(e,t){const s=v();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("utils received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(t.error):s.resolve(t.result))};close(){this.#e.removeEventListener("message",this.handleMessage),this.#t&&this.#e.removeEventListener("error",ke),this.#e.terminate()}}class Pe extends De{constructor(e){super(new Worker(new URL("./workers/utils",import.meta.url),{type:"module"}),e??!1)}async generateInboxId(e){return this.sendMessage("utils.generateInboxId",{identifier:e})}async getInboxIdForIdentifier(e,t){return this.sendMessage("utils.getInboxIdForIdentifier",{identifier:e,env:t})}async revokeInstallationsSignatureText(e,t,s,n){return this.sendMessage("utils.revokeInstallationsSignatureText",{env:n,identifier:e,inboxId:t,installationIds:s,signatureRequestId:v()})}async revokeInstallations(e,t,s,n){const i=await e.getIdentifier(),{signatureText:r,signatureRequestId:a}=await this.revokeInstallationsSignatureText(i,t,s,n),o=await e.signMessage(r),c=await Ae(e,o);return this.sendMessage("utils.revokeInstallations",{signer:c,signatureRequestId:a,env:n})}async inboxStateFromInboxIds(e,t){return this.sendMessage("utils.inboxStateFromInboxIds",{inboxIds:e,env:t})}}class Te extends M{#I;#v;#w;#f;#M;#b;#S;#x=!1;#A;#k;#D;constructor(t){super(new Worker(new URL("./workers/client",import.meta.url),{type:"module"}),void 0!==t?.loggingLevel&&"off"!==t.loggingLevel),this.#D=t,this.#v=new be(this),this.#w=new Se(this),this.#A=new xe(this);const s=[new e,new n,...t?.codecs??[]];this.#I=new Map(s.map((e=>[e.contentType.toString(),e])))}async init(e){const t=await this.sendMessage("client.init",{identifier:e,options:this.#D});this.#f=e,this.#M=t.inboxId,this.#b=t.installationId,this.#S=t.installationIdBytes,this.#x=!0}static async create(e,t){const s=new Te(t);return s.#k=e,await s.init(await e.getIdentifier()),t?.disableAutoRegister||await s.register(),s}static async build(e,t){const s=new Te({...t,disableAutoRegister:!0});return await s.init(e),s}get options(){return this.#D}get signer(){return this.#k}get isReady(){return this.#x}get inboxId(){return this.#M}get accountIdentifier(){return this.#f}get installationId(){return this.#b}get installationIdBytes(){return this.#S}get conversations(){return this.#v}get debugInformation(){return this.#w}get preferences(){return this.#A}async unsafe_createInboxSignatureText(){return this.sendMessage("client.createInboxSignatureText",{signatureRequestId:v()})}async unsafe_addAccountSignatureText(e,t=!1){if(!t)throw new re;return this.sendMessage("client.addAccountSignatureText",{newIdentifier:e,signatureRequestId:v()})}async unsafe_removeAccountSignatureText(e){return this.sendMessage("client.removeAccountSignatureText",{identifier:e,signatureRequestId:v()})}async unsafe_revokeAllOtherInstallationsSignatureText(){return this.sendMessage("client.revokeAllOtherInstallationsSignatureText",{signatureRequestId:v()})}async unsafe_revokeInstallationsSignatureText(e){return this.sendMessage("client.revokeInstallationsSignatureText",{installationIds:e,signatureRequestId:v()})}async unsafe_changeRecoveryIdentifierSignatureText(e){return this.sendMessage("client.changeRecoveryIdentifierSignatureText",{identifier:e,signatureRequestId:v()})}async unsafe_applySignatureRequest(e,t){return this.sendMessage("client.applySignatureRequest",{signer:e,signatureRequestId:t})}async register(){if(!this.#k)throw new ne;const{signatureText:e,signatureRequestId:t}=await this.unsafe_createInboxSignatureText();if(!e||!t)return;const s=await this.#k.signMessage(e),n=await Ae(this.#k,s);return this.sendMessage("client.registerIdentity",{signer:n,signatureRequestId:t})}async unsafe_addAccount(e,t=!1){if(!this.#k)throw new ne;if(!t)throw new re;const s=await this.findInboxIdByIdentifier(await e.getIdentifier());if(s)throw new ae(s);const{signatureText:n,signatureRequestId:i}=await this.unsafe_addAccountSignatureText(await e.getIdentifier(),!0),r=await e.signMessage(n),a=await Ae(e,r);return this.sendMessage("client.addAccount",{identifier:a.identifier,signer:a,signatureRequestId:i})}async removeAccount(e){if(!this.#k)throw new ne;const{signatureText:t,signatureRequestId:s}=await this.unsafe_removeAccountSignatureText(e),n=await this.#k.signMessage(t),i=await Ae(this.#k,n);return this.sendMessage("client.removeAccount",{identifier:e,signer:i,signatureRequestId:s})}async revokeAllOtherInstallations(){if(!this.#k)throw new ne;const{signatureText:e,signatureRequestId:t}=await this.unsafe_revokeAllOtherInstallationsSignatureText(),s=await this.#k.signMessage(e),n=await Ae(this.#k,s);return this.sendMessage("client.revokeAllOtherInstallations",{signer:n,signatureRequestId:t})}async revokeInstallations(e){if(!this.#k)throw new ne;const{signatureText:t,signatureRequestId:s}=await this.unsafe_revokeInstallationsSignatureText(e),n=await this.#k.signMessage(t),i=await Ae(this.#k,n);return this.sendMessage("client.revokeInstallations",{installationIds:e,signer:i,signatureRequestId:s})}static async revokeInstallations(e,t,s,n,i){const r=new Pe(i);await r.init(),await r.revokeInstallations(e,t,s,n),r.close()}static async inboxStateFromInboxIds(e,t,s){const n=new Pe(s);await n.init();const i=await n.inboxStateFromInboxIds(e,t);return n.close(),i}async changeRecoveryIdentifier(e){if(!this.#k)throw new ne;const{signatureText:t,signatureRequestId:s}=await this.unsafe_changeRecoveryIdentifierSignatureText(e),n=await this.#k.signMessage(t),i=await Ae(this.#k,n);return this.sendMessage("client.changeRecoveryIdentifier",{identifier:e,signer:i,signatureRequestId:s})}async isRegistered(){return this.sendMessage("client.isRegistered",void 0)}async canMessage(e){return this.sendMessage("client.canMessage",{identifiers:e})}static async canMessage(e,t){const s=new Map,n=new Pe;for(const i of e){const e=await n.getInboxIdForIdentifier(i,t);s.set(i.identifier.toLowerCase(),void 0!==e)}return n.close(),s}async findInboxIdByIdentifier(e){return this.sendMessage("client.findInboxIdByIdentifier",{identifier:e})}codecFor(e){return this.#I.get(e.toString())}encodeContent(e,t){const s=this.codecFor(t);if(!s)throw new ie(t);const n=s.encode(e,this),i=s.fallback(e);return i&&(n.fallback=i),P(n)}decodeContent(e,s){const n=this.codecFor(s);if(!n)throw new ie(s);if(s.sameAs(t)&&e.kind!==m.MembershipChange)throw new de(e.id);const i=T(e.content);return n.decode(i,this)}signWithInstallationKey(e){return this.sendMessage("client.signWithInstallationKey",{signatureText:e})}verifySignedWithInstallationKey(e,t){return this.sendMessage("client.verifySignedWithInstallationKey",{signatureText:e,signatureBytes:t})}verifySignedWithPublicKey(e,t,s){return this.sendMessage("client.verifySignedWithPublicKey",{signatureText:e,signatureBytes:t,publicKey:s})}async getKeyPackageStatusesForInstallationIds(e){return this.sendMessage("client.getKeyPackageStatusesForInstallationIds",{installationIds:e})}}const Ce={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"},Re={local:"http://localhost:5558",dev:"https://message-history.dev.ephemera.network",production:"https://message-history.production.ephemera.network"};export{ae as AccountAlreadyAssociatedError,Ce as ApiUrls,Te as Client,se as ClientNotInitializedError,ie as CodecNotFoundError,we as Conversation,be as Conversations,te as DecodedMessage,fe as Dm,Me as Group,oe as GroupNotFoundError,Re as HistorySyncUrls,re as InboxReassignError,de as InvalidGroupMembershipChangeError,le as MissingContentTypeError,ne as SignerUnavailableError,ue as StreamFailedError,ge as StreamInvalidRetryAttemptsError,ce as StreamNotFoundError,Pe as Utils,S as fromContentTypeId,D as fromEncodedContent,$ as fromSafeConsent,A as fromSafeContentTypeId,U as fromSafeCreateDmOptions,B as fromSafeCreateGroupOptions,T as fromSafeEncodedContent,V as fromSafeGroupMember,q as fromSafeListConversationsOptions,N as fromSafeListMessagesOptions,Q as fromSafeMessageDisappearingSettings,F as fromSafePermissionPolicySet,b as toContentTypeId,k as toEncodedContent,Z as toSafeApiStats,j as toSafeConsent,x as toSafeContentTypeId,O as toSafeConversation,Y as toSafeConversationDebugInfo,E as toSafeCreateDmOptions,G as toSafeCreateGroupOptions,P as toSafeEncodedContent,H as toSafeGroupMember,z as toSafeHmacKey,ee as toSafeIdentityStats,W as toSafeInboxState,K as toSafeInstallation,X as toSafeKeyPackageStatus,L as toSafeListConversationsOptions,R as toSafeListMessagesOptions,C as toSafeMessage,J as toSafeMessageDisappearingSettings,_ as toSafePermissionPolicySet,Ae as toSafeSigner};
1
+ import{GroupUpdatedCodec as e,ContentTypeGroupUpdated as t}from"@xmtp/content-type-group-updated";import{ContentTypeText as s,TextCodec as n}from"@xmtp/content-type-text";import{ContentTypeId as i,EncodedContent as r,ListMessagesOptions as a,ListConversationsOptions as o,PermissionPolicySet as d,CreateGroupOptions as c,CreateDMOptions as l,Consent as u,GroupMember as g,MessageDisappearingSettings as h,SendMessageOpts as p,GroupPermissionsOptions as m,GroupMessageKind as y,DeliveryStatus as I,ConversationType as v}from"@xmtp/wasm-bindings";export{Consent,ConsentEntityType,ConsentState,ContentType,ContentTypeId,ConversationListItem,ConversationType,CreateDMOptions,CreateGroupOptions,DeliveryStatus,EncodedContent,GroupMember,GroupMembershipState,GroupMessageKind,GroupMetadata,GroupPermissions,GroupPermissionsOptions,HmacKey,InboxState,Installation,ListConversationsOptions,ListMessagesOptions,LogOptions,Message,MessageDisappearingSettings,MetadataField,PermissionLevel,PermissionPolicy,PermissionPolicySet,PermissionUpdateType,SignatureRequestHandle,SortDirection}from"@xmtp/wasm-bindings";import{v4 as w}from"uuid";import{ContentTypeId as f}from"@xmtp/content-type-primitives";const M=e=>{console.error(e.message)};class b{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),t&&this.#e.addEventListener("error",M),this.#t=t}sendMessage(e,t){const s=w();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("client received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(t.error):s.resolve(t.result))};handleStreamMessage=(e,t,s)=>{const n=n=>{const i=n.data;if(i.streamId===e){if("stream.fail"===i.action)return void s?.onFail?.();"error"in i?t(i.error,void 0):t(null,i.result)}};return this.#e.addEventListener("message",n),async()=>{await this.sendMessage("endStream",{streamId:e}),this.#e.removeEventListener("message",n)}};close(){this.#e.removeEventListener("message",this.handleMessage),this.#t&&this.#e.removeEventListener("error",M),this.#e.terminate()}}const S=e=>new f({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),x=e=>new i(e.authorityId,e.typeId,e.versionMajor,e.versionMinor),A=e=>({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),k=e=>new f({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),D=e=>({type:S(e.type),parameters:Object.fromEntries(e.parameters),fallback:e.fallback,compression:e.compression,content:e.content}),P=e=>new r(x(e.type),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content),T=e=>({type:A(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),C=e=>({type:k(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),N=e=>({content:T(D(e.content)),convoId:e.convoId,deliveryStatus:e.deliveryStatus,id:e.id,kind:e.kind,senderInboxId:e.senderInboxId,sentAtNs:e.sentAtNs}),R=e=>({contentTypes:e.contentTypes,deliveryStatus:e.deliveryStatus,direction:e.direction,excludeContentTypes:e.excludeContentTypes,excludeSenderInboxIds:e.excludeSenderInboxIds,insertedAfterNs:e.insertedAfterNs,insertedBeforeNs:e.insertedBeforeNs,kind:e.kind,limit:e.limit,sentAfterNs:e.sentAfterNs,sentBeforeNs:e.sentBeforeNs,sortBy:e.sortBy}),L=e=>new a(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction,e.contentTypes,e.excludeContentTypes,e.kind,e.excludeSenderInboxIds,e.sortBy,e.insertedAfterNs,e.insertedBeforeNs),B=e=>({shouldPush:e.shouldPush}),q=e=>new p(e.shouldPush),F=e=>({consentStates:e.consentStates,conversationType:e.conversationType,createdAfterNs:e.createdAfterNs,createdBeforeNs:e.createdBeforeNs,includeDuplicateDms:e.includeDuplicateDms,limit:e.limit,orderBy:e.orderBy}),_=e=>new o(e.consentStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.includeDuplicateDms??!1,e.limit,e.orderBy),G=e=>({addAdminPolicy:e.addAdminPolicy,addMemberPolicy:e.addMemberPolicy,removeAdminPolicy:e.removeAdminPolicy,removeMemberPolicy:e.removeMemberPolicy,updateGroupDescriptionPolicy:e.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.updateGroupNamePolicy,updateMessageDisappearingPolicy:e.updateMessageDisappearingPolicy}),E=e=>new d(e.addMemberPolicy,e.removeMemberPolicy,e.addAdminPolicy,e.removeAdminPolicy,e.updateGroupNamePolicy,e.updateGroupDescriptionPolicy,e.updateGroupImageUrlSquarePolicy,e.updateMessageDisappearingPolicy),O=e=>({customPermissionPolicySet:e.customPermissionPolicySet,description:e.groupDescription,imageUrlSquare:e.groupImageUrlSquare,messageDisappearingSettings:e.messageDisappearingSettings?Y(e.messageDisappearingSettings):void 0,name:e.groupName,permissions:e.permissions}),U=e=>new c(e.permissions,e.name,e.imageUrlSquare,e.description,e.customPermissionPolicySet&&e.permissions===m.CustomPolicy?E(e.customPermissionPolicySet):void 0,e.messageDisappearingSettings?Z(e.messageDisappearingSettings):void 0),W=e=>({messageDisappearingSettings:e.messageDisappearingSettings?Y(e.messageDisappearingSettings):void 0}),K=e=>new l(e.messageDisappearingSettings?Z(e.messageDisappearingSettings):void 0),j=async e=>{const t=e.id,s=e.name,n=e.imageUrl,i=e.description,r=e.permissions,a=e.addedByInboxId,o=await e.metadata(),d=e.admins,c=e.superAdmins,l=e.createdAtNs,u=r.policyType,g=r.policySet,h=e.isCommitLogForked;return{id:t,name:s,imageUrl:n,description:i,permissions:{policyType:u,policySet:{addAdminPolicy:g.addAdminPolicy,addMemberPolicy:g.addMemberPolicy,removeAdminPolicy:g.removeAdminPolicy,removeMemberPolicy:g.removeMemberPolicy,updateGroupDescriptionPolicy:g.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:g.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:g.updateGroupNamePolicy,updateMessageDisappearingPolicy:g.updateMessageDisappearingPolicy}},addedByInboxId:a,metadata:o,admins:d,superAdmins:c,createdAtNs:l,isCommitLogForked:h}},H=e=>({bytes:e.bytes,clientTimestampNs:e.clientTimestampNs,id:e.id}),V=e=>({identifiers:e.accountIdentifiers,inboxId:e.inboxId,installations:e.installations.map(H),recoveryIdentifier:e.recoveryIdentifier}),$=e=>({entity:e.entity,entityType:e.entityType,state:e.state}),z=e=>new u(e.entityType,e.state,e.entity),J=e=>({accountIdentifiers:e.accountIdentifiers,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}),Q=e=>new g(e.inboxId,e.accountIdentifiers,e.installationIds,e.permissionLevel,e.consentState),X=e=>({key:e.key,epoch:e.epoch}),Y=e=>({fromNs:e.fromNs,inNs:e.inNs}),Z=e=>new h(e.fromNs,e.inNs),ee=e=>({lifetime:e.lifetime?{notBefore:e.lifetime.not_before,notAfter:e.lifetime.not_after}:void 0,validationError:e.validationError}),te=e=>({epoch:e.epoch,maybeForked:e.maybeForked,forkDetails:e.forkDetails,isCommitLogForked:e.isCommitLogForked,localCommitLog:e.localCommitLog,remoteCommitLog:e.remoteCommitLog,cursor:e.cursor.map((e=>({originatorID:e.originator_id,sequenceID:e.sequence_id})))}),se=e=>({uploadKeyPackage:e.upload_key_package,fetchKeyPackage:e.fetch_key_package,sendGroupMessages:e.send_group_messages,sendWelcomeMessages:e.send_welcome_messages,queryGroupMessages:e.query_group_messages,queryWelcomeMessages:e.query_welcome_messages,subscribeMessages:e.subscribe_messages,subscribeWelcomes:e.subscribe_welcomes}),ne=e=>({getIdentityUpdatesV2:e.get_identity_updates_v2,getInboxIds:e.get_inbox_ids,publishIdentityUpdate:e.publish_identity_update,verifySmartContractWalletSignature:e.verify_smart_contract_wallet_signature});class ie{#n;content;contentType;conversationId;deliveryStatus;fallback;compression;id;kind;parameters;encodedContent;senderInboxId;sentAtNs;constructor(e,t){switch(this.#n=e,this.id=t.id,this.sentAtNs=t.sentAtNs,this.conversationId=t.convoId,this.senderInboxId=t.senderInboxId,this.encodedContent=t.content,t.kind){case y.Application:this.kind="application";break;case y.MembershipChange:this.kind="membership_change"}switch(t.deliveryStatus){case I.Unpublished:this.deliveryStatus="unpublished";break;case I.Published:this.deliveryStatus="published";break;case I.Failed:this.deliveryStatus="failed"}this.contentType=k(t.content.type),this.parameters=new Map(Object.entries(t.content.parameters)),this.fallback=t.content.fallback,this.compression=t.content.compression;try{this.content=this.#n.decodeContent(t,this.contentType)}catch{this.content=void 0}}}class re extends Error{constructor(){super("Client not initialized, use Client.create or Client.build to create a client")}}class ae extends Error{constructor(){super("Signer unavailable, use Client.create to create a client with a signer")}}class oe extends Error{constructor(e){super(`Codec not found for "${e.toString()}" content type`)}}class de extends Error{constructor(){super("Unable to create add account signature text, `allowInboxReassign` must be true")}}class ce extends Error{constructor(e){super(`Account already associated with inbox ${e}`)}}class le extends Error{constructor(e){super(`Group "${e}" not found`)}}class ue extends Error{constructor(e){super(`Stream "${e}" not found`)}}class ge extends Error{constructor(e){super(`Invalid group membership change for message ${e}`)}}class he extends Error{constructor(){super("Content type is required when sending content other than text")}}class pe extends Error{constructor(e){super(`Stream failed, retried ${e} ${"time"+(1!==e?"s":"")}`)}}class me extends Error{constructor(){super("Stream retry attempts must be greater than 0")}}class ye{isDone=!1;#i=[];#r;onDone;onReturn;constructor(){this.#r=[],this.isDone=!1}flush(){for(;this.#i.length>0;){const e=this.#i.shift();e&&e({done:!0,value:void 0})}}done(){this.flush(),this.#r=[],this.#i=[],this.isDone=!0,this.onDone?.()}push=e=>{if(this.isDone)return;const t=this.#i.shift();t?t({done:!1,value:e}):this.#r.push(e)};next=()=>this.isDone?Promise.resolve({done:!0,value:void 0}):this.#r.length>0?Promise.resolve({done:!1,value:this.#r.shift()}):new Promise((e=>{this.#i.push(e)}));return=()=>(this.onReturn?.(),this.done(),Promise.resolve({done:!0,value:void 0}));end=()=>this.return();[Symbol.asyncIterator](){return this}}const Ie=["end","isDone","next","return",Symbol.asyncIterator],ve=e=>Ie.includes(e);const we=1e4,fe=6,Me=async(e,t,s)=>{const{onEnd:n,onError:i,onFail:r,onRestart:a,onRetry:o,onValue:d,retryAttempts:c=fe,retryDelay:l=we,retryOnFail:u=!0}=s??{};if(u&&c<0)throw new me;const g=new ye,h=(e,s)=>{if(e)i?.(e);else if(void 0!==s)try{if(t){const e=t(s);(e=>!!e&&("object"==typeof e||"function"==typeof e)&&"then"in e&&"function"==typeof e.then)(e)?e.then((e=>{g.push(e),d?.(e)})).catch((e=>{i?.(e)})):(g.push(e),d?.(e))}else g.push(s),d?.(s)}catch(e){i?.(e)}},p=async(t=c)=>{try{if(0===t)throw g.end(),new pe(c);await(s=l,new Promise((e=>setTimeout(e,s)))),o?.(c-t+1,c);const i=await e(h,(()=>{r?.(),p()}));g.onDone=()=>{i(),n?.()},a?.()}catch(e){i?.(e),p(t-1)}var s},m=()=>{if(!u)throw g.end(),new pe(0);p()};try{const t=await e(h,(()=>{r?.(),m()}));g.onDone=()=>{t(),n?.()}}catch(e){i?.(e),m()}return new Proxy(g,{get(e,t,s){if(ve(t))return Reflect.get(e,t,s)},set:()=>!0,has:(e,t)=>ve(t),ownKeys:()=>Ie,getOwnPropertyDescriptor(e,t){if(ve(t))return{enumerable:!0,configurable:!0,value:Reflect.get(e,t)}}})};class be{#a;#n;#o;#d;#c;#l;constructor(e,t,s){this.#n=e,this.#d=t,this.#u(s)}#u(e){this.#a=e?.addedByInboxId,this.#c=e?.metadata,this.#o=e?.createdAtNs,this.#l=e?.isCommitLogForked}get id(){return this.#d}get isCommitLogForked(){return this.#l}get addedByInboxId(){return this.#a}get createdAtNs(){return this.#o}get createdAt(){return this.#o?(e=this.#o,new Date(Number(e/1000000n))):void 0;var e}get metadata(){return this.#c}async lastMessage(){const e=await this.#n.sendMessage("conversation.lastMessage",{id:this.#d});return e?new ie(this.#n,e):void 0}async isActive(){return this.#n.sendMessage("conversation.isActive",{id:this.#d})}async members(){return this.#n.sendMessage("conversation.members",{id:this.#d})}async sync(){const e=await this.#n.sendMessage("conversation.sync",{id:this.#d});return this.#u(e),e}async publishMessages(){return this.#n.sendMessage("conversation.publishMessages",{id:this.#d})}async sendOptimistic(e,t){if("string"!=typeof e&&!t)throw new he;const{encodedContent:n,sendOptions:i}="string"==typeof e?this.#n.prepareForSend(e,t??s):this.#n.prepareForSend(e,t);return this.#n.sendMessage("conversation.sendOptimistic",{id:this.#d,content:n,sendOptions:i})}async send(e,t){if("string"!=typeof e&&!t)throw new he;const{encodedContent:n,sendOptions:i}="string"==typeof e?this.#n.prepareForSend(e,t??s):this.#n.prepareForSend(e,t);return this.#n.sendMessage("conversation.send",{id:this.#d,content:n,sendOptions:i})}async messages(e){return(await this.#n.sendMessage("conversation.messages",{id:this.#d,options:e})).map((e=>new ie(this.#n,e)))}async countMessages(e){return await this.#n.sendMessage("conversation.countMessages",{id:this.#d,options:e})}async consentState(){return this.#n.sendMessage("conversation.consentState",{id:this.#d})}async updateConsentState(e){return this.#n.sendMessage("conversation.updateConsentState",{id:this.#d,state:e})}async messageDisappearingSettings(){return this.#n.sendMessage("conversation.messageDisappearingSettings",{id:this.#d})}async updateMessageDisappearingSettings(e,t){return this.#n.sendMessage("conversation.updateMessageDisappearingSettings",{id:this.#d,fromNs:e,inNs:t})}async removeMessageDisappearingSettings(){return this.#n.sendMessage("conversation.removeMessageDisappearingSettings",{id:this.#d})}async isMessageDisappearingEnabled(){return this.#n.sendMessage("conversation.isMessageDisappearingEnabled",{id:this.#d})}async stream(e){return Me((async(t,s)=>{const n=w();return e?.disableSync||await this.sync(),await this.#n.sendMessage("conversation.stream",{groupId:this.#d,streamId:n}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),(e=>new ie(this.#n,e)),e)}async pausedForVersion(){return this.#n.sendMessage("conversation.pausedForVersion",{id:this.#d})}async getHmacKeys(){return this.#n.sendMessage("conversation.getHmacKeys",{id:this.#d})}async debugInfo(){return this.#n.sendMessage("conversation.debugInfo",{id:this.#d})}}class Se extends be{#n;#d;constructor(e,t,s){super(e,t,s),this.#n=e,this.#d=t}async peerInboxId(){return this.#n.sendMessage("dm.peerInboxId",{id:this.#d})}async getDuplicateDms(){return this.#n.sendMessage("dm.getDuplicateDms",{id:this.#d})}}class xe extends be{#g=[];#n;#h;#d;#p;#m;#y=[];#u(e){this.#m=e?.name??"",this.#p=e?.imageUrl??"",this.#h=e?.description??"",this.#g=e?.admins??[],this.#y=e?.superAdmins??[]}constructor(e,t,s){super(e,t,s),this.#n=e,this.#d=t,this.#u(s)}async sync(){const e=await super.sync();return this.#u(e),e}get name(){return this.#m}async updateName(e){await this.#n.sendMessage("group.updateName",{id:this.#d,name:e}),this.#m=e}get imageUrl(){return this.#p}async updateImageUrl(e){await this.#n.sendMessage("group.updateImageUrl",{id:this.#d,imageUrl:e}),this.#p=e}get description(){return this.#h}async updateDescription(e){await this.#n.sendMessage("group.updateDescription",{id:this.#d,description:e}),this.#h=e}get admins(){return this.#g}get superAdmins(){return this.#y}async listAdmins(){const e=await this.#n.sendMessage("group.listAdmins",{id:this.#d});return this.#g=e,e}async listSuperAdmins(){const e=await this.#n.sendMessage("group.listSuperAdmins",{id:this.#d});return this.#y=e,e}async permissions(){return this.#n.sendMessage("group.permissions",{id:this.#d})}async updatePermission(e,t,s){return this.#n.sendMessage("group.updatePermission",{id:this.#d,permissionType:e,policy:t,metadataField:s})}async isAdmin(e){return(await this.listAdmins()).includes(e)}async isSuperAdmin(e){return(await this.listSuperAdmins()).includes(e)}async addMembersByIdentifiers(e){return this.#n.sendMessage("group.addMembersByIdentifiers",{id:this.#d,identifiers:e})}async addMembers(e){return this.#n.sendMessage("group.addMembers",{id:this.#d,inboxIds:e})}async removeMembersByIdentifiers(e){return this.#n.sendMessage("group.removeMembersByIdentifiers",{id:this.#d,identifiers:e})}async removeMembers(e){return this.#n.sendMessage("group.removeMembers",{id:this.#d,inboxIds:e})}async addAdmin(e){return this.#n.sendMessage("group.addAdmin",{id:this.#d,inboxId:e})}async removeAdmin(e){return this.#n.sendMessage("group.removeAdmin",{id:this.#d,inboxId:e})}async addSuperAdmin(e){return this.#n.sendMessage("group.addSuperAdmin",{id:this.#d,inboxId:e})}async removeSuperAdmin(e){return this.#n.sendMessage("group.removeSuperAdmin",{id:this.#d,inboxId:e})}}class Ae{#n;constructor(e){this.#n=e}async sync(){return this.#n.sendMessage("conversations.sync",void 0)}async syncAll(e){return this.#n.sendMessage("conversations.syncAll",{consentStates:e})}async getConversationById(e){const t=await this.#n.sendMessage("conversations.getConversationById",{id:e});if(t)return"group"===t.metadata.conversationType?new xe(this.#n,t.id,t):new Se(this.#n,t.id,t)}async getMessageById(e){const t=await this.#n.sendMessage("conversations.getMessageById",{id:e});return t?new ie(this.#n,t):void 0}async getDmByInboxId(e){const t=await this.#n.sendMessage("conversations.getDmByInboxId",{inboxId:e});return t?new Se(this.#n,t.id,t):void 0}async getDmByIdentifier(e){const t=await this.#n.findInboxIdByIdentifier(e);if(t)return this.getDmByInboxId(t)}async list(e){return(await this.#n.sendMessage("conversations.list",{options:e})).map((e=>{switch(e.metadata.conversationType){case"dm":return new Se(this.#n,e.id,e);case"group":return new xe(this.#n,e.id,e);default:return}})).filter((e=>void 0!==e))}async listGroups(e){return(await this.#n.sendMessage("conversations.listGroups",{options:e})).map((e=>new xe(this.#n,e.id,e)))}async listDms(e){return(await this.#n.sendMessage("conversations.listDms",{options:e})).map((e=>new Se(this.#n,e.id,e)))}async newGroupOptimistic(e){const t=await this.#n.sendMessage("conversations.newGroupOptimistic",{options:e});return new xe(this.#n,t.id,t)}async newGroupWithIdentifiers(e,t){const s=await this.#n.sendMessage("conversations.newGroupWithIdentifiers",{identifiers:e,options:t});return new xe(this.#n,s.id,s)}async newGroup(e,t){const s=await this.#n.sendMessage("conversations.newGroup",{inboxIds:e,options:t});return new xe(this.#n,s.id,s)}async newDmWithIdentifier(e,t){const s=await this.#n.sendMessage("conversations.newDmWithIdentifier",{identifier:e,options:t});return new Se(this.#n,s.id,s)}async newDm(e,t){const s=await this.#n.sendMessage("conversations.newDm",{inboxId:e,options:t});return new Se(this.#n,s.id,s)}async getHmacKeys(){return this.#n.sendMessage("conversations.getHmacKeys",void 0)}async stream(e){return Me((async(t,s)=>{const n=w();return e?.disableSync||await this.sync(),await this.#n.sendMessage("conversations.stream",{streamId:n,conversationType:e?.conversationType}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),(e=>"group"===e.metadata.conversationType?new xe(this.#n,e.id,e):new Se(this.#n,e.id,e)),e)}async streamGroups(e){return this.stream({...e,conversationType:v.Group})}async streamDms(e){return this.stream({...e,conversationType:v.Dm})}async streamAllMessages(e){return Me((async(t,s)=>{const n=w();return e?.disableSync||await this.sync(),await this.#n.sendMessage("conversations.streamAllMessages",{streamId:n,conversationType:e?.conversationType,consentStates:e?.consentStates}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),(e=>new ie(this.#n,e)),e)}async streamAllGroupMessages(e){return this.streamAllMessages({...e,conversationType:v.Group})}async streamAllDmMessages(e){return this.streamAllMessages({...e,conversationType:v.Dm})}async streamMessageDeletions(e){return Me((async t=>{const s=w();return await this.#n.sendMessage("conversations.streamMessageDeletions",{streamId:s}),this.#n.handleStreamMessage(s,t,e)}),void 0,e)}}class ke{#n;constructor(e){this.#n=e}apiStatistics(){return this.#n.sendMessage("debugInformation.apiStatistics",void 0)}apiIdentityStatistics(){return this.#n.sendMessage("debugInformation.apiIdentityStatistics",void 0)}apiAggregateStatistics(){return this.#n.sendMessage("debugInformation.apiAggregateStatistics",void 0)}clearAllStatistics(){return this.#n.sendMessage("debugInformation.clearAllStatistics",void 0)}uploadDebugArchive(e){return this.#n.sendMessage("debugInformation.uploadDebugArchive",{serverUrl:e})}}class De{#n;constructor(e){this.#n=e}sync(){return this.#n.sendMessage("preferences.sync",void 0)}async inboxState(e){return this.#n.sendMessage("preferences.inboxState",{refreshFromNetwork:e??!1})}async inboxStateFromInboxIds(e,t){return this.#n.sendMessage("preferences.inboxStateFromInboxIds",{inboxIds:e,refreshFromNetwork:t??!1})}async getLatestInboxState(e){return this.#n.sendMessage("preferences.getLatestInboxState",{inboxId:e})}async setConsentStates(e){return this.#n.sendMessage("preferences.setConsentStates",{records:e})}async getConsentState(e,t){return this.#n.sendMessage("preferences.getConsentState",{entityType:e,entity:t})}async streamConsent(e){return Me((async(t,s)=>{const n=w();return await this.sync(),await this.#n.sendMessage("preferences.streamConsent",{streamId:n}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),void 0,e)}async streamPreferences(e){return Me((async(t,s)=>{const n=w();return await this.sync(),await this.#n.sendMessage("preferences.streamPreferences",{streamId:n}),this.#n.handleStreamMessage(n,t,{...e,onFail:s})}),void 0,e)}}const Pe=async(e,t)=>{switch(e.type){case"EOA":return{type:"EOA",identifier:await e.getIdentifier(),signature:t};case"SCW":return{type:"SCW",identifier:await e.getIdentifier(),signature:t,chainId:e.getChainId(),blockNumber:e.getBlockNumber?.()}}},Te=e=>{console.error(e.message)};class Ce{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),t&&this.#e.addEventListener("error",Te),this.#t=t}async init(){return this.sendMessage("utils.init",{enableLogging:this.#t})}sendMessage(e,t){const s=w();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("utils received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(t.error):s.resolve(t.result))};close(){this.#e.removeEventListener("message",this.handleMessage),this.#t&&this.#e.removeEventListener("error",Te),this.#e.terminate()}}class Ne extends Ce{constructor(e){super(new Worker(new URL("./workers/utils",import.meta.url),{type:"module"}),e??!1)}async generateInboxId(e){return this.sendMessage("utils.generateInboxId",{identifier:e})}async getInboxIdForIdentifier(e,t,s){return this.sendMessage("utils.getInboxIdForIdentifier",{identifier:e,env:t,gatewayHost:s})}async revokeInstallationsSignatureText(e,t,s,n,i){return this.sendMessage("utils.revokeInstallationsSignatureText",{env:n,identifier:e,inboxId:t,installationIds:s,signatureRequestId:w(),gatewayHost:i})}async revokeInstallations(e,t,s,n,i){const r=await e.getIdentifier(),{signatureText:a,signatureRequestId:o}=await this.revokeInstallationsSignatureText(r,t,s,n,i),d=await e.signMessage(a),c=await Pe(e,d);return this.sendMessage("utils.revokeInstallations",{signer:c,signatureRequestId:o,env:n,gatewayHost:i})}async inboxStateFromInboxIds(e,t,s){return this.sendMessage("utils.inboxStateFromInboxIds",{inboxIds:e,env:t,gatewayHost:s})}}class Re extends b{#I;#v;#w;#f;#M;#b;#S;#x=!1;#A;#k;#D;constructor(t){super(new Worker(new URL("./workers/client",import.meta.url),{type:"module"}),void 0!==t?.loggingLevel&&"off"!==t.loggingLevel),this.#D=t,this.#v=new Ae(this),this.#w=new ke(this),this.#A=new De(this);const s=[new e,new n,...t?.codecs??[]];this.#I=new Map(s.map((e=>[e.contentType.toString(),e])))}async init(e){const t=await this.sendMessage("client.init",{identifier:e,options:this.#D});this.#f=e,this.#M=t.inboxId,this.#b=t.installationId,this.#S=t.installationIdBytes,this.#x=!0}static async create(e,t){const s=new Re(t);return s.#k=e,await s.init(await e.getIdentifier()),t?.disableAutoRegister||await s.register(),s}static async build(e,t){const s=new Re({...t,disableAutoRegister:!0});return await s.init(e),s}get options(){return this.#D}get signer(){return this.#k}get isReady(){return this.#x}get inboxId(){return this.#M}get accountIdentifier(){return this.#f}get installationId(){return this.#b}get installationIdBytes(){return this.#S}get conversations(){return this.#v}get debugInformation(){return this.#w}get preferences(){return this.#A}async libxmtpVersion(){return this.sendMessage("client.libxmtpVersion",void 0)}async appVersion(){return this.sendMessage("client.appVersion",void 0)}async unsafe_createInboxSignatureText(){return this.sendMessage("client.createInboxSignatureText",{signatureRequestId:w()})}async unsafe_addAccountSignatureText(e,t=!1){if(!t)throw new de;return this.sendMessage("client.addAccountSignatureText",{newIdentifier:e,signatureRequestId:w()})}async unsafe_removeAccountSignatureText(e){return this.sendMessage("client.removeAccountSignatureText",{identifier:e,signatureRequestId:w()})}async unsafe_revokeAllOtherInstallationsSignatureText(){return this.sendMessage("client.revokeAllOtherInstallationsSignatureText",{signatureRequestId:w()})}async unsafe_revokeInstallationsSignatureText(e){return this.sendMessage("client.revokeInstallationsSignatureText",{installationIds:e,signatureRequestId:w()})}async unsafe_changeRecoveryIdentifierSignatureText(e){return this.sendMessage("client.changeRecoveryIdentifierSignatureText",{identifier:e,signatureRequestId:w()})}async unsafe_applySignatureRequest(e,t){return this.sendMessage("client.applySignatureRequest",{signer:e,signatureRequestId:t})}async register(){if(!this.#k)throw new ae;const{signatureText:e,signatureRequestId:t}=await this.unsafe_createInboxSignatureText();if(!e||!t)return;const s=await this.#k.signMessage(e),n=await Pe(this.#k,s);return this.sendMessage("client.registerIdentity",{signer:n,signatureRequestId:t})}async unsafe_addAccount(e,t=!1){if(!this.#k)throw new ae;if(!t)throw new de;const s=await this.findInboxIdByIdentifier(await e.getIdentifier());if(s)throw new ce(s);const{signatureText:n,signatureRequestId:i}=await this.unsafe_addAccountSignatureText(await e.getIdentifier(),!0),r=await e.signMessage(n),a=await Pe(e,r);return this.sendMessage("client.addAccount",{identifier:a.identifier,signer:a,signatureRequestId:i})}async removeAccount(e){if(!this.#k)throw new ae;const{signatureText:t,signatureRequestId:s}=await this.unsafe_removeAccountSignatureText(e),n=await this.#k.signMessage(t),i=await Pe(this.#k,n);return this.sendMessage("client.removeAccount",{identifier:e,signer:i,signatureRequestId:s})}async revokeAllOtherInstallations(){if(!this.#k)throw new ae;const{signatureText:e,signatureRequestId:t}=await this.unsafe_revokeAllOtherInstallationsSignatureText();if(!e)return;const s=await this.#k.signMessage(e),n=await Pe(this.#k,s);return this.sendMessage("client.revokeAllOtherInstallations",{signer:n,signatureRequestId:t})}async revokeInstallations(e){if(!this.#k)throw new ae;const{signatureText:t,signatureRequestId:s}=await this.unsafe_revokeInstallationsSignatureText(e),n=await this.#k.signMessage(t),i=await Pe(this.#k,n);return this.sendMessage("client.revokeInstallations",{installationIds:e,signer:i,signatureRequestId:s})}static async revokeInstallations(e,t,s,n,i,r){const a=new Ne(r);await a.init(),await a.revokeInstallations(e,t,s,n,i),a.close()}static async inboxStateFromInboxIds(e,t,s,n){const i=new Ne(s);await i.init();const r=await i.inboxStateFromInboxIds(e,t,n);return i.close(),r}async changeRecoveryIdentifier(e){if(!this.#k)throw new ae;const{signatureText:t,signatureRequestId:s}=await this.unsafe_changeRecoveryIdentifierSignatureText(e),n=await this.#k.signMessage(t),i=await Pe(this.#k,n);return this.sendMessage("client.changeRecoveryIdentifier",{identifier:e,signer:i,signatureRequestId:s})}async isRegistered(){return this.sendMessage("client.isRegistered",void 0)}async canMessage(e){return this.sendMessage("client.canMessage",{identifiers:e})}static async canMessage(e,t){const s=new Map,n=new Ne;for(const i of e){const e=await n.getInboxIdForIdentifier(i,t);s.set(i.identifier.toLowerCase(),void 0!==e)}return n.close(),s}async findInboxIdByIdentifier(e){return this.sendMessage("client.findInboxIdByIdentifier",{identifier:e})}codecFor(e){return this.#I.get(e.toString())}encodeContent(e,t){const s=this.codecFor(t);if(!s)throw new oe(t);return this.#P(e,s)}prepareForSend(e,t){const s=this.codecFor(t);if(!s)throw new oe(t);return{encodedContent:this.#P(e,s),sendOptions:this.#T(e,s)}}#P(e,t){const s=t.encode(e,this),n=t.fallback(e);return n&&(s.fallback=n),T(s)}#T(e,t){return{shouldPush:t.shouldPush(e)}}decodeContent(e,s){const n=this.codecFor(s);if(!n)throw new oe(s);if(s.sameAs(t)&&e.kind!==y.MembershipChange)throw new ge(e.id);const i=C(e.content);return n.decode(i,this)}signWithInstallationKey(e){return this.sendMessage("client.signWithInstallationKey",{signatureText:e})}verifySignedWithInstallationKey(e,t){return this.sendMessage("client.verifySignedWithInstallationKey",{signatureText:e,signatureBytes:t})}verifySignedWithPublicKey(e,t,s){return this.sendMessage("client.verifySignedWithPublicKey",{signatureText:e,signatureBytes:t,publicKey:s})}async getKeyPackageStatusesForInstallationIds(e){return this.sendMessage("client.getKeyPackageStatusesForInstallationIds",{installationIds:e})}}const Le={local:"http://localhost:5557",dev:"https://api.dev.xmtp.network:5558",production:"https://api.production.xmtp.network:5558"},Be={local:"http://localhost:5558",dev:"https://message-history.dev.ephemera.network",production:"https://message-history.production.ephemera.network"};export{ce as AccountAlreadyAssociatedError,Le as ApiUrls,Re as Client,re as ClientNotInitializedError,oe as CodecNotFoundError,be as Conversation,Ae as Conversations,ie as DecodedMessage,Se as Dm,xe as Group,le as GroupNotFoundError,Be as HistorySyncUrls,de as InboxReassignError,ge as InvalidGroupMembershipChangeError,he as MissingContentTypeError,ae as SignerUnavailableError,pe as StreamFailedError,me as StreamInvalidRetryAttemptsError,ue as StreamNotFoundError,Ne as Utils,x as fromContentTypeId,P as fromEncodedContent,z as fromSafeConsent,k as fromSafeContentTypeId,K as fromSafeCreateDmOptions,U as fromSafeCreateGroupOptions,C as fromSafeEncodedContent,Q as fromSafeGroupMember,_ as fromSafeListConversationsOptions,L as fromSafeListMessagesOptions,Z as fromSafeMessageDisappearingSettings,E as fromSafePermissionPolicySet,q as fromSafeSendMessageOpts,S as toContentTypeId,D as toEncodedContent,se as toSafeApiStats,$ as toSafeConsent,A as toSafeContentTypeId,j as toSafeConversation,te as toSafeConversationDebugInfo,W as toSafeCreateDmOptions,O as toSafeCreateGroupOptions,T as toSafeEncodedContent,J as toSafeGroupMember,X as toSafeHmacKey,ne as toSafeIdentityStats,V as toSafeInboxState,H as toSafeInstallation,ee as toSafeKeyPackageStatus,F as toSafeListConversationsOptions,R as toSafeListMessagesOptions,N as toSafeMessage,Y as toSafeMessageDisappearingSettings,G as toSafePermissionPolicySet,B as toSafeSendMessageOpts,Pe as toSafeSigner};
2
2
  //# sourceMappingURL=index.js.map