@xmtp/browser-sdk 6.5.0 → 7.0.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
@@ -57,6 +57,23 @@ pnpm install @xmtp/browser-sdk
57
57
  yarn add @xmtp/browser-sdk
58
58
  ```
59
59
 
60
+ ## Signer utilities
61
+
62
+ The SDK exports `createEOASigner` and `createSCWSigner` helper functions for creating XMTP-compatible signers. These require `viem` as a peer dependency, which is optional and only needs to be installed if you use these utilities.
63
+
64
+ ```bash
65
+ npm install viem
66
+ ```
67
+
68
+ **Example**
69
+
70
+ ```ts
71
+ import { createEOASigner } from "@xmtp/browser-sdk";
72
+
73
+ // Create an EOA signer (generates a random key if none provided)
74
+ const eoaSigner = createEOASigner();
75
+ ```
76
+
60
77
  ## Developing
61
78
 
62
79
  Run `yarn dev` to build the SDK and watch for changes, which will trigger a rebuild.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _xmtp_wasm_bindings from '@xmtp/wasm-bindings';
2
- import { ContentTypeId as ContentTypeId$1, DeliveryStatus, GroupMessageKind, Reaction, DecodedMessage as DecodedMessage$1, LeaveRequest, ReadReceipt, Attachment, RemoteAttachment, TransactionReference, WalletSendCalls, Actions, Intent, MultiRemoteAttachment, GroupUpdated, DeletedMessage, LogLevel, Identifier, Conversations as Conversations$1, ConsentState, ListConversationsOptions, CreateGroupOptions, CreateDmOptions, Conversation as Conversation$1, ConversationType, Message, Client as Client$1, Consent, ConsentEntityType, UserPreferenceUpdate, SignatureRequestHandle, KeyPackageStatus, GroupMember, PermissionUpdateType, PermissionPolicy, MetadataField, EncodedContent, SendMessageOpts, Reply, ListMessagesOptions, MessageDisappearingSettings, HmacKey, ConversationDebugInfo, GroupPermissionsOptions, PermissionPolicySet, GroupMetadata, ApiStats, IdentityStats, InboxState, GroupSyncSummary } from '@xmtp/wasm-bindings';
3
- export { Action, ActionStyle, Actions, ApiStats, Attachment, Consent, ConsentEntityType, ConsentState, ContentType, ConversationDebugInfo, ConversationListItem, ConversationType, CreateDmOptions, CreateGroupOptions, Cursor, DeliveryStatus, EncryptedAttachment, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, GroupSyncSummary, GroupUpdated, HmacKey, Identifier, IdentifierKind, IdentityStats, Inbox, InboxState, Installation, Intent, KeyPackageStatus, LeaveRequest, Lifetime, ListConversationsOptions, ListConversationsOrderBy, ListMessagesOptions, LogLevel, LogOptions, Message, MessageDisappearingSettings, MessageSortBy, MetadataField, MetadataFieldChange, MultiRemoteAttachment, PermissionLevel, PermissionPolicy, PermissionPolicySet, PermissionUpdateType, Reaction, ReactionAction, ReactionSchema, ReadReceipt, RemoteAttachment, RemoteAttachmentInfo, Reply, SendMessageOpts, SignatureRequestHandle, SortDirection, TransactionMetadata, TransactionReference, UserPreferenceUpdate, WalletCall, WalletSendCalls } from '@xmtp/wasm-bindings';
2
+ import { ContentTypeId as ContentTypeId$1, DeliveryStatus, GroupMessageKind, Reaction, DecodedMessage as DecodedMessage$1, LeaveRequest, ReadReceipt, Attachment, RemoteAttachment, TransactionReference, WalletSendCalls, Actions, Intent, MultiRemoteAttachment, GroupUpdated, DeletedMessage, Backend, LogLevel, Identifier, Conversations as Conversations$1, ConsentState, ListConversationsOptions, CreateGroupOptions, CreateDmOptions, Conversation as Conversation$1, ConversationType, Message, Client as Client$1, Consent, ConsentEntityType, UserPreferenceUpdate, SignatureRequestHandle, KeyPackageStatus, ArchiveOptions, AvailableArchiveInfo, ArchiveMetadata, GroupSyncSummary, GroupMember, PermissionUpdateType, PermissionPolicy, MetadataField, EncodedContent, SendMessageOpts, Reply, ListMessagesOptions, MessageDisappearingSettings, HmacKey, ConversationDebugInfo, GroupPermissionsOptions, PermissionPolicySet, GroupMetadata, ApiStats, IdentityStats, InboxState } from '@xmtp/wasm-bindings';
3
+ export { Action, ActionStyle, Actions, ApiStats, ArchiveMetadata, ArchiveOptions, Attachment, AvailableArchiveInfo, Backend, BackendBuilder, BackupElementSelectionOption, Consent, ConsentEntityType, ConsentState, ContentType, ConversationDebugInfo, ConversationListItem, ConversationType, CreateDmOptions, CreateGroupOptions, Cursor, DeliveryStatus, EncryptedAttachment, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, GroupSyncSummary, GroupUpdated, HmacKey, Identifier, IdentifierKind, IdentityStats, Inbox, InboxState, Installation, Intent, KeyPackageStatus, LeaveRequest, Lifetime, ListConversationsOptions, ListConversationsOrderBy, ListMessagesOptions, LogLevel, LogOptions, Message, MessageDisappearingSettings, MessageSortBy, MetadataField, MetadataFieldChange, MultiRemoteAttachment, PermissionLevel, PermissionPolicy, PermissionPolicySet, PermissionUpdateType, Reaction, ReactionAction, ReactionSchema, ReadReceipt, RemoteAttachment, Reply, SendMessageOpts, SignatureRequestHandle, SortDirection, TransactionMetadata, TransactionReference, UserPreferenceUpdate, WalletCall, WalletSendCalls } from '@xmtp/wasm-bindings';
4
4
  import { ContentCodec, ContentTypeId } from '@xmtp/content-type-primitives';
5
5
 
6
6
  type ResolveValue<T> = {
@@ -82,33 +82,6 @@ type StreamValueMutator<T = unknown, V = T> = (value: T) => V | Promise<V>;
82
82
  */
83
83
  declare const createStream: <T = unknown, V = T>(streamFunction: StreamFunction<T>, streamValueMutator?: StreamValueMutator<T, V | undefined>, options?: StreamOptions<T, V>) => Promise<AsyncStreamProxy<V>>;
84
84
 
85
- /**
86
- * Pre-configured URLs for the XMTP network based on the environment
87
- *
88
- * @constant
89
- * @property {string} local - The local URL for the XMTP network
90
- * @property {string} dev - The development URL for the XMTP network
91
- * @property {string} production - The production URL for the XMTP network
92
- */
93
- declare const ApiUrls: {
94
- readonly local: "http://localhost:5557";
95
- readonly dev: "https://api.dev.xmtp.network:5558";
96
- readonly production: "https://api.production.xmtp.network:5558";
97
- };
98
- /**
99
- * Pre-configured URLs for the XMTP history sync service based on the environment
100
- *
101
- * @constant
102
- * @property {string} local - The local URL for the XMTP history sync service
103
- * @property {string} dev - The development URL for the XMTP history sync service
104
- * @property {string} production - The production URL for the XMTP history sync service
105
- */
106
- declare const HistorySyncUrls: {
107
- readonly local: "http://localhost:5558";
108
- readonly dev: "https://message-history.dev.ephemera.network";
109
- readonly production: "https://message-history.production.ephemera.network";
110
- };
111
-
112
85
  declare class CodecRegistry {
113
86
  #private;
114
87
  constructor(codecs: ContentCodec[]);
@@ -158,7 +131,7 @@ declare class DecodedMessage<ContentTypes = unknown> {
158
131
  constructor(codecRegistry: CodecRegistry, message: DecodedMessage$1);
159
132
  }
160
133
 
161
- type XmtpEnv = keyof typeof ApiUrls;
134
+ type XmtpEnv = "local" | "dev" | "production" | "testnet-staging" | "testnet-dev" | "testnet" | "mainnet";
162
135
  /**
163
136
  * Network options
164
137
  */
@@ -172,15 +145,28 @@ type NetworkOptions = {
172
145
  * specific endpoint
173
146
  */
174
147
  apiUrl?: string;
148
+ /**
149
+ * gatewayHost can be used to override the gateway endpoint
150
+ */
151
+ gatewayHost?: string;
152
+ /**
153
+ * Custom app version
154
+ */
155
+ appVersion?: string;
156
+ };
157
+ /**
158
+ * Device sync options
159
+ */
160
+ type DeviceSyncOptions = {
175
161
  /**
176
162
  * historySyncUrl can be used to override the `env` flag and connect to a
177
163
  * specific endpoint for syncing history
178
164
  */
179
165
  historySyncUrl?: string | null;
180
166
  /**
181
- * gatewayHost can be used to override the gateway endpoint
167
+ * Disable device sync
182
168
  */
183
- gatewayHost?: string | null;
169
+ disableDeviceSync?: boolean;
184
170
  };
185
171
  type ContentOptions = {
186
172
  /**
@@ -232,16 +218,10 @@ type OtherOptions = {
232
218
  * Disable automatic registration when creating a client
233
219
  */
234
220
  disableAutoRegister?: boolean;
235
- /**
236
- * Disable device sync
237
- */
238
- disableDeviceSync?: boolean;
239
- /**
240
- * Custom app version
241
- */
242
- appVersion?: string;
243
221
  };
244
- type ClientOptions = NetworkOptions & ContentOptions & StorageOptions & OtherOptions;
222
+ type ClientOptions = (NetworkOptions | {
223
+ backend: Backend;
224
+ }) & DeviceSyncOptions & ContentOptions & StorageOptions & OtherOptions;
245
225
  type EnrichedReply<T = unknown, U = unknown> = {
246
226
  referenceId: string;
247
227
  content: T;
@@ -283,6 +263,8 @@ type SafeSigner = {
283
263
  chainId: bigint;
284
264
  blockNumber?: bigint;
285
265
  };
266
+ declare const createEOASigner: (key?: `0x${string}`) => Signer;
267
+ declare const createSCWSigner: (address: `0x${string}`, signMessage: (message: string) => Promise<string> | string, chainId: bigint) => Signer;
286
268
  declare const toSafeSigner: (signer: Signer, signature: Uint8Array) => Promise<SafeSigner>;
287
269
 
288
270
  declare class WorkerConversations {
@@ -337,10 +319,11 @@ declare class WorkerPreferences {
337
319
 
338
320
  declare class WorkerClient {
339
321
  #private;
340
- constructor(client: Client$1);
322
+ constructor(client: Client$1, env: XmtpEnv);
341
323
  static create(identifier: Identifier, options?: Omit<ClientOptions, "codecs">): Promise<WorkerClient>;
342
324
  get libxmtpVersion(): string;
343
325
  get appVersion(): string;
326
+ get env(): XmtpEnv;
344
327
  get accountIdentifier(): Identifier;
345
328
  get inboxId(): string;
346
329
  get installationId(): string;
@@ -365,7 +348,14 @@ declare class WorkerClient {
365
348
  verifySignedWithInstallationKey(signatureText: string, signatureBytes: Uint8Array): boolean;
366
349
  verifySignedWithPublicKey(signatureText: string, signatureBytes: Uint8Array, publicKey: Uint8Array): boolean;
367
350
  fetchKeyPackageStatuses(installationIds: string[]): Promise<Map<string, KeyPackageStatus>>;
368
- sendSyncRequest(): Promise<void>;
351
+ sendSyncRequest(options: ArchiveOptions, serverUrl: string): Promise<void>;
352
+ sendSyncArchive(options: ArchiveOptions, serverUrl: string, pin: string): Promise<void>;
353
+ processSyncArchive(archivePin?: string | null): Promise<void>;
354
+ listAvailableArchives(daysCutoff: number): AvailableArchiveInfo[];
355
+ createArchive(opts: ArchiveOptions, key: Uint8Array): Promise<Uint8Array>;
356
+ importArchive(data: Uint8Array, key: Uint8Array): Promise<void>;
357
+ archiveMetadata(data: Uint8Array, key: Uint8Array): Promise<ArchiveMetadata>;
358
+ syncAllDeviceSyncGroups(): Promise<GroupSyncSummary>;
369
359
  }
370
360
 
371
361
  declare class WorkerConversation {
@@ -463,6 +453,7 @@ type ClientAction = {
463
453
  id: string;
464
454
  result: {
465
455
  appVersion: string;
456
+ env: string;
466
457
  inboxId: string;
467
458
  installationId: string;
468
459
  installationIdBytes: Uint8Array;
@@ -650,6 +641,61 @@ type ClientAction = {
650
641
  action: "client.sendSyncRequest";
651
642
  id: string;
652
643
  result: undefined;
644
+ data: {
645
+ options: ArchiveOptions;
646
+ serverUrl: string;
647
+ };
648
+ } | {
649
+ action: "client.sendSyncArchive";
650
+ id: string;
651
+ result: undefined;
652
+ data: {
653
+ options: ArchiveOptions;
654
+ serverUrl: string;
655
+ pin: string;
656
+ };
657
+ } | {
658
+ action: "client.processSyncArchive";
659
+ id: string;
660
+ result: undefined;
661
+ data: {
662
+ archivePin?: string | null;
663
+ };
664
+ } | {
665
+ action: "client.listAvailableArchives";
666
+ id: string;
667
+ result: AvailableArchiveInfo[];
668
+ data: {
669
+ daysCutoff: number;
670
+ };
671
+ } | {
672
+ action: "client.createArchive";
673
+ id: string;
674
+ result: Uint8Array;
675
+ data: {
676
+ opts: ArchiveOptions;
677
+ key: Uint8Array;
678
+ };
679
+ } | {
680
+ action: "client.importArchive";
681
+ id: string;
682
+ result: undefined;
683
+ data: {
684
+ data: Uint8Array;
685
+ key: Uint8Array;
686
+ };
687
+ } | {
688
+ action: "client.archiveMetadata";
689
+ id: string;
690
+ result: ArchiveMetadata;
691
+ data: {
692
+ data: Uint8Array;
693
+ key: Uint8Array;
694
+ };
695
+ } | {
696
+ action: "client.syncAllDeviceSyncGroups";
697
+ id: string;
698
+ result: GroupSyncSummary;
653
699
  data: undefined;
654
700
  };
655
701
 
@@ -2197,6 +2243,10 @@ declare class Client<ContentTypes = ExtractCodecContentTypes> {
2197
2243
  * Gets the app version used by the client
2198
2244
  */
2199
2245
  get appVersion(): string | undefined;
2246
+ /**
2247
+ * Gets the XMTP environment used by this client
2248
+ */
2249
+ get env(): XmtpEnv | undefined;
2200
2250
  /**
2201
2251
  * Creates signature text for creating a new inbox
2202
2252
  *
@@ -2367,21 +2417,45 @@ declare class Client<ContentTypes = ExtractCodecContentTypes> {
2367
2417
  /**
2368
2418
  * Revokes specific installations of the client's inbox without a client
2369
2419
  *
2370
- * @param env - The environment to use
2371
2420
  * @param signer - The signer to use
2372
2421
  * @param inboxId - The inbox ID to revoke installations for
2373
2422
  * @param installationIds - The installation IDs to revoke
2423
+ * @param backend - Optional `Backend` instance created with `createBackend()`
2424
+ */
2425
+ static revokeInstallations(signer: Signer, inboxId: string, installationIds: Uint8Array[], backend?: Backend): Promise<void>;
2426
+ /**
2427
+ * Revokes specific installations of the client's inbox without a client
2428
+ *
2429
+ * @param signer - The signer to use
2430
+ * @param inboxId - The inbox ID to revoke installations for
2431
+ * @param installationIds - The installation IDs to revoke
2432
+ * @param env - The environment to use
2433
+ * @param gatewayHost - Optional gateway host
2434
+ * @deprecated Pass a `Backend` instance created with `createBackend()` instead
2435
+ * of `XmtpEnv` and `gatewayHost`.
2374
2436
  */
2375
2437
  static revokeInstallations(signer: Signer, inboxId: string, installationIds: Uint8Array[], env?: XmtpEnv, gatewayHost?: string): Promise<void>;
2438
+ /**
2439
+ * Fetches the inbox states for the specified inbox IDs from the network
2440
+ * without a client
2441
+ *
2442
+ * @param inboxIds - The inbox IDs to get the state for
2443
+ * @param backend - Optional `Backend` instance created with `createBackend()`
2444
+ * @returns The inbox states for the specified inbox IDs
2445
+ */
2446
+ static fetchInboxStates(inboxIds: string[], backend?: Backend): Promise<InboxState[]>;
2376
2447
  /**
2377
2448
  * Fetches the inbox states for the specified inbox IDs from the network
2378
2449
  * without a client
2379
2450
  *
2380
2451
  * @param inboxIds - The inbox IDs to get the state for
2381
2452
  * @param env - The environment to use
2453
+ * @param gatewayHost - Optional gateway host
2382
2454
  * @returns The inbox states for the specified inbox IDs
2455
+ * @deprecated Pass a `Backend` instance created with `createBackend()` instead
2456
+ * of `XmtpEnv` and `gatewayHost`.
2383
2457
  */
2384
- static fetchInboxStates(inboxIds: string[], env?: XmtpEnv, gatewayHost?: string): Promise<_xmtp_wasm_bindings.InboxState[]>;
2458
+ static fetchInboxStates(inboxIds: string[], env?: XmtpEnv, gatewayHost?: string): Promise<InboxState[]>;
2385
2459
  /**
2386
2460
  * Changes the recovery identifier for the client's inbox
2387
2461
  *
@@ -2404,12 +2478,22 @@ declare class Client<ContentTypes = ExtractCodecContentTypes> {
2404
2478
  * @returns Whether the client can message the identifiers
2405
2479
  */
2406
2480
  canMessage(identifiers: Identifier[]): Promise<Map<string, boolean>>;
2481
+ /**
2482
+ * Checks if the specified identifiers can be messaged
2483
+ *
2484
+ * @param identifiers - The identifiers to check
2485
+ * @param backend - Optional `Backend` instance created with `createBackend()`
2486
+ * @returns Map of identifiers to whether they can be messaged
2487
+ */
2488
+ static canMessage(identifiers: Identifier[], backend?: Backend): Promise<Map<string, boolean>>;
2407
2489
  /**
2408
2490
  * Checks if the specified identifiers can be messaged
2409
2491
  *
2410
2492
  * @param identifiers - The identifiers to check
2411
2493
  * @param env - Optional XMTP environment
2412
2494
  * @returns Map of identifiers to whether they can be messaged
2495
+ * @deprecated Pass a `Backend` instance created with `createBackend()` instead
2496
+ * of `XmtpEnv`.
2413
2497
  */
2414
2498
  static canMessage(identifiers: Identifier[], env?: XmtpEnv): Promise<Map<string, boolean>>;
2415
2499
  /**
@@ -2455,9 +2539,67 @@ declare class Client<ContentTypes = ExtractCodecContentTypes> {
2455
2539
  /**
2456
2540
  * Send a sync request to other devices on the network
2457
2541
  *
2542
+ * @param options - Archive options specifying what to sync (defaults to consent and messages)
2543
+ * @param serverUrl - The server URL for the sync request (defaults to environment-specific URL)
2458
2544
  * @returns Promise that resolves when the sync request is sent
2459
2545
  */
2460
- sendSyncRequest(): Promise<void>;
2546
+ sendSyncRequest(options?: ArchiveOptions, serverUrl?: string): Promise<void>;
2547
+ /**
2548
+ * Send a sync archive to the sync group
2549
+ *
2550
+ * @param pin - The pin used for reference when importing
2551
+ * @param options - Archive options specifying what to sync (defaults to consent and messages)
2552
+ * @param serverUrl - The server URL for the sync archive (defaults to environment-specific URL)
2553
+ * @returns Promise that resolves when the sync archive is sent
2554
+ */
2555
+ sendSyncArchive(pin: string, options?: ArchiveOptions, serverUrl?: string): Promise<void>;
2556
+ /**
2557
+ * Process a sync archive that matches the pin given
2558
+ *
2559
+ * @param archivePin - Optional pin to match. If not provided, processes the last archive sent
2560
+ * @returns Promise that resolves when the archive is processed
2561
+ */
2562
+ processSyncArchive(archivePin?: string | null): Promise<void>;
2563
+ /**
2564
+ * List the archives available for import in the sync group
2565
+ *
2566
+ * You may need to manually sync the sync group before calling
2567
+ * this function to see recently uploaded archives.
2568
+ *
2569
+ * @param daysCutoff - Number of days to look back for archives
2570
+ * @returns Promise that resolves with array of available archive information
2571
+ */
2572
+ listAvailableArchives(daysCutoff: number): Promise<AvailableArchiveInfo[]>;
2573
+ /**
2574
+ * Export archive data to bytes for later restoration
2575
+ *
2576
+ * @param key - Encryption key for the archive
2577
+ * @param opts - Archive options specifying what to include (defaults to consent and messages)
2578
+ * @returns Promise that resolves with the archive data as bytes
2579
+ */
2580
+ createArchive(key: Uint8Array, opts?: ArchiveOptions): Promise<Uint8Array>;
2581
+ /**
2582
+ * Import an archive from bytes
2583
+ *
2584
+ * @param data - The archive data as bytes
2585
+ * @param key - Encryption key for the archive
2586
+ * @returns Promise that resolves when the archive is imported
2587
+ */
2588
+ importArchive(data: Uint8Array, key: Uint8Array): Promise<void>;
2589
+ /**
2590
+ * Load the metadata for an archive to see what it contains
2591
+ *
2592
+ * @param data - The archive data as bytes
2593
+ * @param key - Encryption key for the archive
2594
+ * @returns Promise that resolves with the archive metadata
2595
+ */
2596
+ archiveMetadata(data: Uint8Array, key: Uint8Array): Promise<ArchiveMetadata>;
2597
+ /**
2598
+ * Manually sync all device sync groups
2599
+ *
2600
+ * @returns Promise that resolves with a summary of the sync operation
2601
+ */
2602
+ syncAllDeviceSyncGroups(): Promise<GroupSyncSummary>;
2461
2603
  }
2462
2604
 
2463
2605
  declare class Opfs {
@@ -2476,6 +2618,8 @@ declare class Opfs {
2476
2618
  clearAll(): Promise<void>;
2477
2619
  }
2478
2620
 
2621
+ declare const createBackend: (options?: NetworkOptions) => Promise<Backend>;
2622
+
2479
2623
  /**
2480
2624
  * Generates an inbox ID for a given identifier
2481
2625
  *
@@ -2485,14 +2629,13 @@ declare class Opfs {
2485
2629
  */
2486
2630
  declare const generateInboxId: (identifier: Identifier, nonce?: bigint) => Promise<string>;
2487
2631
  /**
2488
- * Gets the inbox ID for a specific identifier and optional environment
2632
+ * Gets the inbox ID for a specific identifier using a Backend
2489
2633
  *
2634
+ * @param backend - The Backend instance for API communication
2490
2635
  * @param identifier - The identifier to get the inbox ID for
2491
- * @param env - Optional XMTP environment configuration (default: "dev")
2492
- * @param gatewayHost - Optional gateway host override
2493
2636
  * @returns Promise that resolves with the inbox ID for the identifier
2494
2637
  */
2495
- declare const getInboxIdForIdentifier: (identifier: Identifier, env?: XmtpEnv, gatewayHost?: string) => Promise<string | undefined>;
2638
+ declare const getInboxIdForIdentifier: (backend: Backend, identifier: Identifier) => Promise<string | undefined>;
2496
2639
 
2497
2640
  /**
2498
2641
  * Gets the name of a metadata field
@@ -2502,6 +2645,38 @@ declare const getInboxIdForIdentifier: (identifier: Identifier, env?: XmtpEnv, g
2502
2645
  */
2503
2646
  declare const metadataFieldName: (field: MetadataField) => Promise<string>;
2504
2647
 
2648
+ /**
2649
+ * Pre-configured URLs for the XMTP network based on the environment
2650
+ *
2651
+ * @deprecated Use `createBackend()` instead.
2652
+ * @constant
2653
+ * @property {string} local - The local URL for the XMTP network
2654
+ * @property {string} dev - The development URL for the XMTP network
2655
+ * @property {string} production - The production URL for the XMTP network
2656
+ */
2657
+ declare const ApiUrls: {
2658
+ readonly local: "http://localhost:5557";
2659
+ readonly dev: "https://api.dev.xmtp.network:5558";
2660
+ readonly production: "https://api.production.xmtp.network:5558";
2661
+ };
2662
+ /**
2663
+ * Pre-configured URLs for the XMTP history sync service based on the environment
2664
+ *
2665
+ * @constant
2666
+ * @property {string} local - The local URL for the XMTP history sync service
2667
+ * @property {string} dev - The development URL for the XMTP history sync service
2668
+ * @property {string} production - The production URL for the XMTP history sync service
2669
+ */
2670
+ declare const HistorySyncUrls: {
2671
+ readonly local: "http://localhost:5558";
2672
+ readonly dev: "https://message-history.dev.ephemera.network";
2673
+ readonly production: "https://message-history.production.ephemera.network";
2674
+ readonly "testnet-staging": "https://message-history.dev.ephemera.network";
2675
+ readonly "testnet-dev": "https://message-history.dev.ephemera.network";
2676
+ readonly testnet: "https://message-history.dev.ephemera.network";
2677
+ readonly mainnet: "https://message-history.production.ephemera.network";
2678
+ };
2679
+
2505
2680
  declare const encodeActions: (actions: _xmtp_wasm_bindings.Actions) => Promise<_xmtp_wasm_bindings.EncodedContent>;
2506
2681
  declare const encodeAttachment: (attachment: _xmtp_wasm_bindings.Attachment) => Promise<_xmtp_wasm_bindings.EncodedContent>;
2507
2682
  declare const encodeIntent: (intent: _xmtp_wasm_bindings.Intent) => Promise<_xmtp_wasm_bindings.EncodedContent>;
@@ -2577,5 +2752,5 @@ declare const isIntent: (m: DecodedMessage) => m is DecodedMessage<Intent>;
2577
2752
  declare const isActions: (m: DecodedMessage) => m is DecodedMessage<Actions>;
2578
2753
  declare const isMarkdown: (m: DecodedMessage) => m is DecodedMessage<string>;
2579
2754
 
2580
- export { AccountAlreadyAssociatedError, ApiUrls, Client, ClientNotInitializedError, Conversation, Conversations, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY, DecodedMessage, Dm, Group, GroupNotFoundError, HistorySyncUrls, InboxReassignError, Opfs, OpfsInitializationError, OpfsNotInitializedError, SignerUnavailableError, StreamFailedError, StreamInvalidRetryAttemptsError, StreamNotFoundError, contentTypeActions, contentTypeAttachment, contentTypeGroupUpdated, contentTypeIntent, contentTypeLeaveRequest, contentTypeMarkdown, contentTypeMultiRemoteAttachment, contentTypeReaction, contentTypeReadReceipt, contentTypeRemoteAttachment, contentTypeReply, contentTypeText, contentTypeTransactionReference, contentTypeWalletSendCalls, createStream, decryptAttachment, encodeActions, encodeAttachment, encodeIntent, encodeMarkdown, encodeMultiRemoteAttachment, encodeReaction, encodeReadReceipt, encodeRemoteAttachment, encodeText, encodeTransactionReference, encodeWalletSendCalls, encryptAttachment, generateInboxId, getInboxIdForIdentifier, isActions, isAttachment, isGroupUpdated, isIntent, isLeaveRequest, isMarkdown, isMultiRemoteAttachment, isReaction, isReadReceipt, isRemoteAttachment, isReply, isText, isTextReply, isTransactionReference, isWalletSendCalls, metadataFieldName, toSafeConversation, toSafeSigner };
2581
- export type { AsyncStreamProxy, BuiltInContentTypes, ClientOptions, ContentOptions, EOASigner, EnrichedReply, ExtractCodecContentTypes, HmacKeys, LastReadTimes, NetworkOptions, OtherOptions, SCWSigner, SafeConversation, SafeSigner, Signer, StorageOptions, StreamCallback, StreamFunction, StreamOptions, StreamValueMutator, XmtpEnv };
2755
+ export { AccountAlreadyAssociatedError, ApiUrls, Client, ClientNotInitializedError, Conversation, Conversations, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY, DecodedMessage, Dm, Group, GroupNotFoundError, HistorySyncUrls, InboxReassignError, Opfs, OpfsInitializationError, OpfsNotInitializedError, SignerUnavailableError, StreamFailedError, StreamInvalidRetryAttemptsError, StreamNotFoundError, contentTypeActions, contentTypeAttachment, contentTypeGroupUpdated, contentTypeIntent, contentTypeLeaveRequest, contentTypeMarkdown, contentTypeMultiRemoteAttachment, contentTypeReaction, contentTypeReadReceipt, contentTypeRemoteAttachment, contentTypeReply, contentTypeText, contentTypeTransactionReference, contentTypeWalletSendCalls, createBackend, createEOASigner, createSCWSigner, createStream, decryptAttachment, encodeActions, encodeAttachment, encodeIntent, encodeMarkdown, encodeMultiRemoteAttachment, encodeReaction, encodeReadReceipt, encodeRemoteAttachment, encodeText, encodeTransactionReference, encodeWalletSendCalls, encryptAttachment, generateInboxId, getInboxIdForIdentifier, isActions, isAttachment, isGroupUpdated, isIntent, isLeaveRequest, isMarkdown, isMultiRemoteAttachment, isReaction, isReadReceipt, isRemoteAttachment, isReply, isText, isTextReply, isTransactionReference, isWalletSendCalls, metadataFieldName, toSafeConversation, toSafeSigner };
2756
+ export type { AsyncStreamProxy, BuiltInContentTypes, ClientOptions, ContentOptions, DeviceSyncOptions, EOASigner, EnrichedReply, ExtractCodecContentTypes, HmacKeys, LastReadTimes, NetworkOptions, OtherOptions, SCWSigner, SafeConversation, SafeSigner, Signer, StorageOptions, StreamCallback, StreamFunction, StreamOptions, StreamValueMutator, XmtpEnv };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import e,{encodeActions as t,encodeAttachment as n,encodeIntent as s,encodeMarkdown as i,encodeMultiRemoteAttachment as r,encodeReaction as a,encodeReadReceipt as o,encodeRemoteAttachment as c,encodeText as d,encodeTransactionReference as u,encodeWalletSendCalls as h,contentTypeActions as p,contentTypeAttachment as l,contentTypeGroupUpdated as y,contentTypeIntent as g,contentTypeLeaveRequest as w,contentTypeMarkdown as m,contentTypeMultiRemoteAttachment as I,contentTypeReaction as k,contentTypeReadReceipt as f,contentTypeRemoteAttachment as v,contentTypeReply as x,contentTypeText as R,contentTypeTransactionReference as b,contentTypeWalletSendCalls as S,encryptAttachment as A,decryptAttachment as T,ConversationType as M,generateInboxId as D,getInboxIdForIdentifier as C,inboxStateFromInboxIds as q,applySignatureRequest as B,revokeInstallationsSignatureRequest as E,LogLevel as N,metadataFieldName as O}from"@xmtp/wasm-bindings";export{ActionStyle,ConsentEntityType,ConsentState,ContentType,ConversationType,DeliveryStatus,GroupMembershipState,GroupMessageKind,GroupPermissionsOptions,IdentifierKind,ListConversationsOrderBy,LogLevel,MessageSortBy,MetadataField,PermissionLevel,PermissionPolicy,PermissionUpdateType,ReactionAction,ReactionSchema,SortDirection}from"@xmtp/wasm-bindings";import{contentTypeToString as P}from"@xmtp/content-type-primitives";class F{#e;constructor(e){this.#e=new Map(e.map(e=>[P(e.contentType),e]))}getCodec(e){return this.#e.get(P(e))}}const L=t=>async(...n)=>(await e(),t(...n)),G=L(t),U=L(n),W=L(s),K=L(i),_=L(r),V=L(a),$=L(o),j=L(c),z=L(d),X=L(u),H=L(h),J=L(p),Q=L(l),Y=L(y),Z=L(g),ee=L(w),te=L(m),ne=L(I),se=L(k),ie=L(f),re=L(v),ae=L(x),oe=L(R),ce=L(b),de=L(S),ue=L(A),he=L(T);function pe(e){return new Date(Number(e/1000000n))}const le=e=>{switch(e.type){case"text":case"markdown":case"reply":case"reaction":case"attachment":case"remoteAttachment":case"multiRemoteAttachment":case"transactionReference":case"groupUpdated":case"readReceipt":case"leaveRequest":case"walletSendCalls":case"intent":case"actions":case"deletedMessage":case"custom":return e.content;default:return null}};class ye{content;contentType;conversationId;deliveryStatus;expiresAtNs;expiresAt;fallback;id;kind;numReplies;reactions;senderInboxId;sentAt;sentAtNs;constructor(e,t){switch(this.id=t.id,this.expiresAtNs=t.expiresAtNs,this.expiresAt=t.expiresAtNs?pe(t.expiresAtNs):void 0,this.sentAtNs=t.sentAtNs,this.sentAt=pe(t.sentAtNs),this.conversationId=t.conversationId,this.senderInboxId=t.senderInboxId,this.contentType=t.contentType,this.fallback=t.fallback??void 0,this.kind=t.kind,this.deliveryStatus=t.deliveryStatus,this.numReplies=t.numReplies,this.reactions=t.reactions.map(t=>new ye(e,t)),this.content=le(t.content)??void 0,t.content.type){case"reply":{const n=t.content.content;let s=le(n.content);if("custom"===n.content.type){const t=e.getCodec(n.content.content.type);if(t)try{s=t.decode(s)}catch(e){e instanceof Error?console.warn(`Error decoding custom content: ${e.message}`):console.warn("Error decoding custom content")}}this.content={referenceId:n.referenceId,content:s,contentType:()=>(async e=>{switch(e.type){case"text":return oe();case"markdown":return te();case"reply":return ae();case"reaction":return se();case"attachment":return Q();case"remoteAttachment":return re();case"multiRemoteAttachment":return ne();case"transactionReference":return ce();case"groupUpdated":return Y();case"readReceipt":return ie();case"leaveRequest":return ee();case"walletSendCalls":return de();case"intent":return Z();case"actions":return J();case"deletedMessage":default:return;case"custom":return e.content.type}})(n.content),inReplyTo:n.inReplyTo?new ye(e,n.inReplyTo):null};break}case"custom":{const n=t.content.content,s=e.getCodec(this.contentType);if(s)try{this.content=s.decode(n)}catch(e){e instanceof Error?console.warn(`Error decoding custom content: ${e.message}`):console.warn("Error decoding custom content"),this.content=void 0}else console.warn(`No codec found for content type "${P(this.contentType)}"`),this.content=void 0;break}}}}class ge{isDone=!1;#t=[];#n;onDone;onReturn;constructor(){this.#n=[],this.isDone=!1}flush(){for(;this.#t.length>0;){const e=this.#t.shift();e&&e({done:!0,value:void 0})}}done(){this.flush(),this.#n=[],this.#t=[],this.isDone=!0,this.onDone?.()}push=e=>{if(this.isDone)return;const t=this.#t.shift();t?t({done:!1,value:e}):this.#n.push(e)};next=()=>this.isDone?Promise.resolve({done:!0,value:void 0}):this.#n.length>0?Promise.resolve({done:!1,value:this.#n.shift()}):new Promise(e=>{this.#t.push(e)});return=()=>(this.onReturn?.(),this.done(),Promise.resolve({done:!0,value:void 0}));end=()=>this.return();[Symbol.asyncIterator](){return this}}const we=["end","isDone","next","return",Symbol.asyncIterator],me=e=>we.includes(e);class Ie extends Error{constructor(){super("Client not initialized, use Client.create or Client.build to create a client")}}class ke extends Error{constructor(){super("Signer unavailable, use Client.create to create a client with a signer")}}class fe extends Error{constructor(){super("Unable to create add account signature text, `allowInboxReassign` must be true")}}class ve extends Error{constructor(e){super(`Account already associated with inbox ${e}`)}}class xe extends Error{constructor(e){super(`Group "${e}" not found`)}}class Re extends Error{constructor(e){super(`Stream "${e}" not found`)}}class be extends Error{constructor(e){super(`Stream failed, retried ${e} ${"time"+(1!==e?"s":"")}`)}}class Se extends Error{constructor(){super("Stream retry attempts must be greater than 0")}}class Ae extends Error{constructor(){super("OPFS must be initialized before accessing its methods")}}class Te extends Error{constructor(){super("Failed to initialize OPFS, ensure that there are no other active XMTP clients or Opfs instances")}}const Me=1e4,De=6,Ce=async(e,t,n)=>{const{onEnd:s,onError:i,onFail:r,onRestart:a,onRetry:o,onValue:c,retryAttempts:d=De,retryDelay:u=Me,retryOnFail:h=!0}=n??{};if(h&&d<0)throw new Se;const p=new ge,l=(e,n)=>{if(e)i?.(e);else if(void 0!==n)try{if(t){const e=t(n);(e=>!!e&&("object"==typeof e||"function"==typeof e)&&"then"in e&&"function"==typeof e.then)(e)?e.then(e=>{void 0!==e&&(p.push(e),c?.(e))}).catch(e=>{i?.(e)}):void 0!==e&&(p.push(e),c?.(e))}else p.push(n),c?.(n)}catch(e){i?.(e)}},y=async(t=d)=>{try{if(0===t)throw p.end(),new be(d);await(n=u,new Promise(e=>setTimeout(e,n))),o?.(d-t+1,d);const i=await e(l,()=>{r?.(),y()});p.onDone=()=>{i(),s?.()},a?.()}catch(e){i?.(e),y(t-1)}var n},g=()=>{if(!h)throw p.end(),new be(0);y()};try{const t=await e(l,()=>{r?.(),g()});p.onDone=()=>{t(),s?.()}}catch(e){i?.(e),g()}return new Proxy(p,{get(e,t,n){if(me(t))return Reflect.get(e,t,n)},set:()=>!0,has:(e,t)=>me(t),ownKeys:()=>we,getOwnPropertyDescriptor(e,t){if(me(t))return{enumerable:!0,configurable:!0,value:Reflect.get(e,t)}}})},qe=()=>{const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")};class Be{#s;#i;#r;#a;#o;#c;constructor(e,t,n,s){this.#c=e,this.#i=t,this.#a=n,this.#d(s)}#d(e){this.#s=e?.addedByInboxId,this.#o=e?.metadata,this.#r=e?.createdAtNs}get id(){return this.#a}get addedByInboxId(){return this.#s}get createdAtNs(){return this.#r}get createdAt(){return this.#r?pe(this.#r):void 0}get metadata(){return this.#o}get topic(){return`/xmtp/mls/1/g-${this.id}/proto`}async lastMessage(){const e=await this.#c.action("conversation.lastMessage",{id:this.#a});return e?new ye(this.#i,e):void 0}async isActive(){return this.#c.action("conversation.isActive",{id:this.#a})}async members(){return this.#c.action("conversation.members",{id:this.#a})}async sync(){const e=await this.#c.action("conversation.sync",{id:this.#a});return this.#d(e),e}async publishMessages(){return this.#c.action("conversation.publishMessages",{id:this.#a})}async processStreamedMessage(e){return this.#c.action("conversation.processStreamedMessage",{id:this.#a,envelopeBytes:e})}async send(e,t){return this.#c.action("conversation.send",{id:this.#a,content:e,options:t})}async sendText(e,t){return this.#c.action("conversation.sendText",{id:this.#a,text:e,isOptimistic:t})}async sendMarkdown(e,t){return this.#c.action("conversation.sendMarkdown",{id:this.#a,markdown:e,isOptimistic:t})}async sendReaction(e,t){return this.#c.action("conversation.sendReaction",{id:this.#a,reaction:e,isOptimistic:t})}async sendReadReceipt(e){return this.#c.action("conversation.sendReadReceipt",{id:this.#a,isOptimistic:e})}async sendReply(e,t){return this.#c.action("conversation.sendReply",{id:this.#a,reply:e,isOptimistic:t})}async sendTransactionReference(e,t){return this.#c.action("conversation.sendTransactionReference",{id:this.#a,transactionReference:e,isOptimistic:t})}async sendWalletSendCalls(e,t){return this.#c.action("conversation.sendWalletSendCalls",{id:this.#a,walletSendCalls:e,isOptimistic:t})}async sendActions(e,t){return this.#c.action("conversation.sendActions",{id:this.#a,actions:e,isOptimistic:t})}async sendIntent(e,t){return this.#c.action("conversation.sendIntent",{id:this.#a,intent:e,isOptimistic:t})}async sendAttachment(e,t){return this.#c.action("conversation.sendAttachment",{id:this.#a,attachment:e,isOptimistic:t})}async sendMultiRemoteAttachment(e,t){return this.#c.action("conversation.sendMultiRemoteAttachment",{id:this.#a,multiRemoteAttachment:e,isOptimistic:t})}async sendRemoteAttachment(e,t){return this.#c.action("conversation.sendRemoteAttachment",{id:this.#a,remoteAttachment:e,isOptimistic:t})}async messages(e){return(await this.#c.action("conversation.messages",{id:this.#a,options:e})).map(e=>new ye(this.#i,e))}async countMessages(e){return await this.#c.action("conversation.countMessages",{id:this.#a,options:e})}async consentState(){return this.#c.action("conversation.consentState",{id:this.#a})}async updateConsentState(e){return this.#c.action("conversation.updateConsentState",{id:this.#a,state:e})}async messageDisappearingSettings(){return this.#c.action("conversation.messageDisappearingSettings",{id:this.#a})}async updateMessageDisappearingSettings(e,t){return this.#c.action("conversation.updateMessageDisappearingSettings",{id:this.#a,fromNs:e,inNs:t})}async removeMessageDisappearingSettings(){return this.#c.action("conversation.removeMessageDisappearingSettings",{id:this.#a})}async isMessageDisappearingEnabled(){return this.#c.action("conversation.isMessageDisappearingEnabled",{id:this.#a})}async stream(e){return Ce(async(t,n)=>{const s=qe();return e?.disableSync||await this.sync(),await this.#c.action("conversation.stream",{groupId:this.#a,streamId:s}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},e=>new ye(this.#i,e),e)}async pausedForVersion(){return this.#c.action("conversation.pausedForVersion",{id:this.#a})}async hmacKeys(){return this.#c.action("conversation.hmacKeys",{id:this.#a})}async debugInfo(){return this.#c.action("conversation.debugInfo",{id:this.#a})}async lastReadTimes(){return this.#c.action("conversation.lastReadTimes",{id:this.#a})}}class Ee extends Be{#i;#c;#a;constructor(e,t,n,s){super(e,t,n,s),this.#c=e,this.#i=t,this.#a=n}async peerInboxId(){return this.#c.action("dm.peerInboxId",{id:this.#a})}async duplicateDms(){return(await this.#c.action("dm.duplicateDms",{id:this.#a})).map(e=>new Ee(this.#c,this.#i,e.id,e))}}class Ne extends Be{#u=[];#h;#c;#p;#a;#l;#y;#g=[];#d(e){this.#y=e?.name??"",this.#l=e?.imageUrl??"",this.#p=e?.description??"",this.#h=e?.appData??"",this.#u=e?.admins??[],this.#g=e?.superAdmins??[]}constructor(e,t,n,s){super(e,t,n,s),this.#c=e,this.#a=n,this.#d(s)}async sync(){const e=await super.sync();return this.#d(e),e}get name(){return this.#y}async updateName(e){await this.#c.action("group.updateName",{id:this.#a,name:e}),this.#y=e}get imageUrl(){return this.#l}async updateImageUrl(e){await this.#c.action("group.updateImageUrl",{id:this.#a,imageUrl:e}),this.#l=e}get description(){return this.#p}async updateDescription(e){await this.#c.action("group.updateDescription",{id:this.#a,description:e}),this.#p=e}get appData(){return this.#h}async updateAppData(e){await this.#c.action("group.updateAppData",{id:this.#a,appData:e}),this.#h=e}get admins(){return this.#u}get superAdmins(){return this.#g}async listAdmins(){const e=await this.#c.action("group.listAdmins",{id:this.#a});return this.#u=e,e}async listSuperAdmins(){const e=await this.#c.action("group.listSuperAdmins",{id:this.#a});return this.#g=e,e}async permissions(){return this.#c.action("group.permissions",{id:this.#a})}async updatePermission(e,t,n){return this.#c.action("group.updatePermission",{id:this.#a,permissionType:e,policy:t,metadataField:n})}async isAdmin(e){return(await this.listAdmins()).includes(e)}async isSuperAdmin(e){return(await this.listSuperAdmins()).includes(e)}async addMembersByIdentifiers(e){return this.#c.action("group.addMembersByIdentifiers",{id:this.#a,identifiers:e})}async addMembers(e){return this.#c.action("group.addMembers",{id:this.#a,inboxIds:e})}async removeMembersByIdentifiers(e){return this.#c.action("group.removeMembersByIdentifiers",{id:this.#a,identifiers:e})}async removeMembers(e){return this.#c.action("group.removeMembers",{id:this.#a,inboxIds:e})}async addAdmin(e){return this.#c.action("group.addAdmin",{id:this.#a,inboxId:e})}async removeAdmin(e){return this.#c.action("group.removeAdmin",{id:this.#a,inboxId:e})}async addSuperAdmin(e){return this.#c.action("group.addSuperAdmin",{id:this.#a,inboxId:e})}async removeSuperAdmin(e){return this.#c.action("group.removeSuperAdmin",{id:this.#a,inboxId:e})}async requestRemoval(){return this.#c.action("group.requestRemoval",{id:this.#a})}async isPendingRemoval(){return this.#c.action("group.isPendingRemoval",{id:this.#a})}}class Oe{#w;#i;#c;constructor(e,t,n){this.#w=e,this.#c=t,this.#i=n}get topic(){return this.#w.installationId?`/xmtp/mls/1/w-${this.#w.installationId}/proto`:void 0}async sync(){return this.#c.action("conversations.sync")}async syncAll(e){return this.#c.action("conversations.syncAll",{consentStates:e})}async getConversationById(e){const t=await this.#c.action("conversations.getConversationById",{id:e});if(t)switch(t.metadata.conversationType){case M.Group:return new Ne(this.#c,this.#i,t.id,t);case M.Dm:return new Ee(this.#c,this.#i,t.id,t);default:return}}async getMessageById(e){const t=await this.#c.action("conversations.getMessageById",{id:e});return t?new ye(this.#i,t):void 0}async getDmByInboxId(e){const t=await this.#c.action("conversations.getDmByInboxId",{inboxId:e});return t?new Ee(this.#c,this.#i,t.id,t):void 0}async fetchDmByIdentifier(e){const t=await this.#c.action("client.getInboxIdByIdentifier",{identifier:e});if(t)return this.getDmByInboxId(t)}async list(e){return(await this.#c.action("conversations.list",{options:e})).map(e=>{switch(e.metadata.conversationType){case M.Dm:return new Ee(this.#c,this.#i,e.id,e);case M.Group:return new Ne(this.#c,this.#i,e.id,e);default:return}}).filter(e=>void 0!==e)}async listGroups(e){return(await this.#c.action("conversations.listGroups",{options:e})).map(e=>new Ne(this.#c,this.#i,e.id,e))}async listDms(e){return(await this.#c.action("conversations.listDms",{options:e})).map(e=>new Ee(this.#c,this.#i,e.id,e))}async createGroupOptimistic(e){const t=await this.#c.action("conversations.createGroupOptimistic",{options:e});return new Ne(this.#c,this.#i,t.id,t)}async createGroupWithIdentifiers(e,t){const n=await this.#c.action("conversations.createGroupWithIdentifiers",{identifiers:e,options:t});return new Ne(this.#c,this.#i,n.id,n)}async createGroup(e,t){const n=await this.#c.action("conversations.createGroup",{inboxIds:e,options:t});return new Ne(this.#c,this.#i,n.id,n)}async createDmWithIdentifier(e,t){const n=await this.#c.action("conversations.createDmWithIdentifier",{identifier:e,options:t});return new Ee(this.#c,this.#i,n.id,n)}async createDm(e,t){const n=await this.#c.action("conversations.createDm",{inboxId:e,options:t});return new Ee(this.#c,this.#i,n.id,n)}async hmacKeys(){return this.#c.action("conversations.hmacKeys")}async stream(e){return Ce(async(t,n)=>{const s=qe();return e?.disableSync||await this.sync(),await this.#c.action("conversations.stream",{streamId:s,conversationType:e?.conversationType}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},e=>{switch(e.metadata.conversationType){case M.Group:return new Ne(this.#c,this.#i,e.id,e);case M.Dm:return new Ee(this.#c,this.#i,e.id,e);default:return void console.warn(`Unknown conversation type: ${e.metadata.conversationType}`)}},e)}async streamGroups(e){return this.stream({...e,conversationType:M.Group})}async streamDms(e){return this.stream({...e,conversationType:M.Dm})}async streamAllMessages(e){return Ce(async(t,n)=>{const s=qe();return e?.disableSync||await this.sync(),await this.#c.action("conversations.streamAllMessages",{streamId:s,conversationType:e?.conversationType,consentStates:e?.consentStates}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},e=>new ye(this.#i,e),e)}async streamAllGroupMessages(e){return this.streamAllMessages({...e,conversationType:M.Group})}async streamAllDmMessages(e){return this.streamAllMessages({...e,conversationType:M.Dm})}async streamMessageDeletions(e){return Ce(async t=>{const n=qe();return await this.#c.action("conversations.streamDeletedMessages",{streamId:n}),this.#c.handleStreamMessage(n,t,e)},e=>e.id,e)}async streamDeletedMessages(e){return Ce(async t=>{const n=qe();return await this.#c.action("conversations.streamDeletedMessages",{streamId:n}),this.#c.handleStreamMessage(n,t,e)},e=>new ye(this.#i,e),e)}}class Pe{#c;constructor(e){this.#c=e}apiStatistics(){return this.#c.action("debugInformation.apiStatistics")}apiIdentityStatistics(){return this.#c.action("debugInformation.apiIdentityStatistics")}apiAggregateStatistics(){return this.#c.action("debugInformation.apiAggregateStatistics")}clearAllStatistics(){return this.#c.action("debugInformation.clearAllStatistics")}}class Fe{#c;constructor(e){this.#c=e}sync(){return this.#c.action("preferences.sync")}async inboxState(){return this.#c.action("preferences.inboxState",{refreshFromNetwork:!1})}async fetchInboxState(){return this.#c.action("preferences.inboxState",{refreshFromNetwork:!0})}async getInboxStates(e){return this.#c.action("preferences.getInboxStates",{inboxIds:e,refreshFromNetwork:!1})}async fetchInboxStates(e){return this.#c.action("preferences.getInboxStates",{inboxIds:e,refreshFromNetwork:!0})}async setConsentStates(e){return this.#c.action("preferences.setConsentStates",{records:e})}async getConsentState(e,t){return this.#c.action("preferences.getConsentState",{entityType:e,entity:t})}async streamConsent(e){return Ce(async(t,n)=>{const s=qe();return e?.disableSync||await this.sync(),await this.#c.action("preferences.streamConsent",{streamId:s}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},void 0,e)}async streamPreferences(e){return Ce(async(t,n)=>{const s=qe();return e?.disableSync||await this.sync(),await this.#c.action("preferences.streamPreferences",{streamId:s}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},void 0,e)}}const Le={local:"http://localhost:5557",dev:"https://api.dev.xmtp.network:5558",production:"https://api.production.xmtp.network:5558"},Ge={local:"http://localhost:5558",dev:"https://message-history.dev.ephemera.network",production:"https://message-history.production.ephemera.network"},Ue=async(t,n)=>(await e(),D(t,n)),We=async(t,n,s)=>{await e();const i=n?Le[n]:Le.dev,r=i.startsWith("https");return C(i,s??null,r,t)},Ke=async(t,n,s,i,r)=>{await e();const a=await t.getIdentifier(),{signatureText:o,signatureRequest:c}=await(async(t,n,s,i,r)=>{await e();const a=E(Le[i??"dev"],r??null,t,n,s);return{signatureText:await a.signatureText(),signatureRequest:a}})(a,n,s,i,r),d=await t.signMessage(o),u=Le[i??"dev"];switch(t.type){case"EOA":await c.addEcdsaSignature(d);break;case"SCW":await c.addScwSignature(a,d,t.getChainId(),t.getBlockNumber?.())}await B(u,r??null,c)},_e=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?.()}}},Ve=e=>{console.error(`[worker] error: ${e.message}`)};class $e{#c;#m;#I=new Map;constructor(e,t){this.#c=e,this.#c.addEventListener("message",this.handleMessage),this.#c.addEventListener("error",Ve),this.#m=t??!1}action(e,...t){const n=qe();this.#c.postMessage({action:e,id:n,data:t[0]});return new Promise((e,t)=>{this.#I.set(n,{resolve:e,reject:t})})}handleMessage=e=>{const t=e.data;this.#m&&console.log("[worker] client received event data",t);const n=this.#I.get(t.id);n&&(this.#I.delete(t.id),"error"in t?n.reject(t.error):n.resolve(t.result))};handleStreamMessage=(e,t,n)=>{const s=s=>{const i=s.data;if(i.streamId===e){if("stream.fail"===i.action)return void n?.onFail?.();"error"in i?t(i.error,void 0):t(null,i.result)}};return this.#c.addEventListener("message",s),async()=>{await this.action("endStream",{streamId:e}),this.#c.removeEventListener("message",s)}};close(){this.#c.removeEventListener("message",this.handleMessage),this.#c.removeEventListener("error",Ve),this.#c.terminate()}}class je{#k;#i;#f;#v;#x;#R;#b;#S;#A=!1;#T;#M;#D;#C;#c;constructor(e){e&&Object.defineProperty(e,"codecs",{value:e.codecs,enumerable:!1});const t=new Worker(new URL("./workers/client",import.meta.url),{type:"module"}),n=void 0!==e?.loggingLevel&&e.loggingLevel!==N.Off;this.#c=new $e(t,n),this.#i=new F([...e?.codecs??[]]),this.#M=e,this.#f=new Oe(this,this.#c,this.#i),this.#v=new Pe(this.#c),this.#D=new Fe(this.#c)}async init(e){const t=await this.#c.action("client.init",{identifier:e,options:this.#M});this.#k=t.appVersion,this.#x=e,this.#R=t.inboxId,this.#b=t.installationId,this.#S=t.installationIdBytes,this.#T=t.libxmtpVersion,this.#A=!0}close(){this.#c.close(),this.#A=!1}static async create(e,t){const n=new je(t);return n.#C=e,await n.init(await e.getIdentifier()),t?.disableAutoRegister||await n.register(),n}static async build(e,t){const n=new je({...t,disableAutoRegister:!0});return await n.init(e),n}get options(){return this.#M}get signer(){return this.#C}get isReady(){return this.#A}get inboxId(){return this.#R}get accountIdentifier(){return this.#x}get installationId(){return this.#b}get installationIdBytes(){return this.#S}get conversations(){return this.#f}get debugInformation(){return this.#v}get preferences(){return this.#D}get libxmtpVersion(){return this.#T}get appVersion(){return this.#k}async unsafe_createInboxSignatureText(){return this.#c.action("client.createInboxSignatureText",{signatureRequestId:qe()})}async unsafe_addAccountSignatureText(e,t=!1){if(!t)throw new fe;return this.#c.action("client.addAccountSignatureText",{newIdentifier:e,signatureRequestId:qe()})}async unsafe_removeAccountSignatureText(e){return this.#c.action("client.removeAccountSignatureText",{identifier:e,signatureRequestId:qe()})}async unsafe_revokeAllOtherInstallationsSignatureText(){return this.#c.action("client.revokeAllOtherInstallationsSignatureText",{signatureRequestId:qe()})}async unsafe_revokeInstallationsSignatureText(e){return this.#c.action("client.revokeInstallationsSignatureText",{installationIds:e,signatureRequestId:qe()})}async unsafe_changeRecoveryIdentifierSignatureText(e){return this.#c.action("client.changeRecoveryIdentifierSignatureText",{identifier:e,signatureRequestId:qe()})}async unsafe_applySignatureRequest(e,t){return this.#c.action("client.applySignatureRequest",{signer:e,signatureRequestId:t})}async register(){if(!this.#C)throw new ke;const{signatureText:e,signatureRequestId:t}=await this.unsafe_createInboxSignatureText();if(!e||!t)return;const n=await this.#C.signMessage(e),s=await _e(this.#C,n);return this.#c.action("client.registerIdentity",{signer:s,signatureRequestId:t})}async unsafe_addAccount(e,t=!1){if(!this.#C)throw new ke;if(!t)throw new fe;const n=await this.fetchInboxIdByIdentifier(await e.getIdentifier());if(n)throw new ve(n);const{signatureText:s,signatureRequestId:i}=await this.unsafe_addAccountSignatureText(await e.getIdentifier(),!0),r=await e.signMessage(s),a=await _e(e,r);return this.#c.action("client.addAccount",{identifier:a.identifier,signer:a,signatureRequestId:i})}async removeAccount(e){if(!this.#C)throw new ke;const{signatureText:t,signatureRequestId:n}=await this.unsafe_removeAccountSignatureText(e),s=await this.#C.signMessage(t),i=await _e(this.#C,s);return this.#c.action("client.removeAccount",{identifier:e,signer:i,signatureRequestId:n})}async revokeAllOtherInstallations(){if(!this.#C)throw new ke;const{signatureText:e,signatureRequestId:t}=await this.unsafe_revokeAllOtherInstallationsSignatureText();if(!e)return;const n=await this.#C.signMessage(e),s=await _e(this.#C,n);return this.#c.action("client.revokeAllOtherInstallations",{signer:s,signatureRequestId:t})}async revokeInstallations(e){if(!this.#C)throw new ke;const{signatureText:t,signatureRequestId:n}=await this.unsafe_revokeInstallationsSignatureText(e),s=await this.#C.signMessage(t),i=await _e(this.#C,s);return this.#c.action("client.revokeInstallations",{installationIds:e,signer:i,signatureRequestId:n})}static async revokeInstallations(e,t,n,s,i){await Ke(e,t,n,s,i)}static async fetchInboxStates(t,n,s){return(async(t,n,s)=>(await e(),q(Le[n??"dev"],s??null,t)))(t,n,s)}async changeRecoveryIdentifier(e){if(!this.#C)throw new ke;const{signatureText:t,signatureRequestId:n}=await this.unsafe_changeRecoveryIdentifierSignatureText(e),s=await this.#C.signMessage(t),i=await _e(this.#C,s);return this.#c.action("client.changeRecoveryIdentifier",{identifier:e,signer:i,signatureRequestId:n})}async isRegistered(){return this.#c.action("client.isRegistered")}async canMessage(e){return this.#c.action("client.canMessage",{identifiers:e})}static async canMessage(e,t){const n=new Map;for(const s of e){const e=await We(s,t);n.set(s.identifier.toLowerCase(),void 0!==e)}return n}async fetchInboxIdByIdentifier(e){return this.#c.action("client.getInboxIdByIdentifier",{identifier:e})}signWithInstallationKey(e){return this.#c.action("client.signWithInstallationKey",{signatureText:e})}verifySignedWithInstallationKey(e,t){return this.#c.action("client.verifySignedWithInstallationKey",{signatureText:e,signatureBytes:t})}verifySignedWithPublicKey(e,t,n){return this.#c.action("client.verifySignedWithPublicKey",{signatureText:e,signatureBytes:t,publicKey:n})}async fetchKeyPackageStatuses(e){return this.#c.action("client.fetchKeyPackageStatuses",{installationIds:e})}async sendSyncRequest(){return this.#c.action("client.sendSyncRequest")}}class ze{#c;#m;constructor(e){const t=new Worker(new URL("./workers/opfs",import.meta.url),{type:"module"});this.#c=new $e(t,e),this.#m=e??!1}async init(){await this.#c.action("opfs.init",{enableLogging:this.#m})}close(){this.#c.close()}static async create(e){const t=new ze(e);return await t.init(),t}async listFiles(){return this.#c.action("opfs.listFiles")}async fileCount(){return this.#c.action("opfs.fileCount")}async poolCapacity(){return this.#c.action("opfs.poolCapacity")}async fileExists(e){return this.#c.action("opfs.fileExists",{path:e})}async deleteFile(e){return this.#c.action("opfs.deleteFile",{path:e})}async exportDb(e){return this.#c.action("opfs.exportDb",{path:e})}async importDb(e,t){return this.#c.action("opfs.importDb",{path:e,data:t})}async clearAll(){return this.#c.action("opfs.clearAll")}}const Xe=async t=>(await e(),O(t)),He=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,appData:e.appData,permissions:e.permissions(),addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.listAdmins(),superAdmins:e.listSuperAdmins(),createdAtNs:e.createdAtNs}),Je=e=>"xmtp.org"===e.contentType.authorityId&&"reaction"===e.contentType.typeId,Qe=e=>"xmtp.org"===e.contentType.authorityId&&"reply"===e.contentType.typeId,Ye=e=>Qe(e)&&"string"==typeof e.content?.content,Ze=e=>"xmtp.org"===e.contentType.authorityId&&"text"===e.contentType.typeId,et=e=>"xmtp.org"===e.contentType.authorityId&&"remoteStaticAttachment"===e.contentType.typeId,tt=e=>"xmtp.org"===e.contentType.authorityId&&"attachment"===e.contentType.typeId,nt=e=>"xmtp.org"===e.contentType.authorityId&&"multiRemoteStaticAttachment"===e.contentType.typeId,st=e=>"xmtp.org"===e.contentType.authorityId&&"transactionReference"===e.contentType.typeId,it=e=>"xmtp.org"===e.contentType.authorityId&&"group_updated"===e.contentType.typeId,rt=e=>"xmtp.org"===e.contentType.authorityId&&"readReceipt"===e.contentType.typeId,at=e=>"xmtp.org"===e.contentType.authorityId&&"leave_request"===e.contentType.typeId,ot=e=>"xmtp.org"===e.contentType.authorityId&&"walletSendCalls"===e.contentType.typeId,ct=e=>"coinbase.com"===e.contentType.authorityId&&"intent"===e.contentType.typeId,dt=e=>"coinbase.com"===e.contentType.authorityId&&"actions"===e.contentType.typeId,ut=e=>"xmtp.org"===e.contentType.authorityId&&"markdown"===e.contentType.typeId;export{ve as AccountAlreadyAssociatedError,Le as ApiUrls,je as Client,Ie as ClientNotInitializedError,Be as Conversation,Oe as Conversations,ye as DecodedMessage,Ee as Dm,Ne as Group,xe as GroupNotFoundError,Ge as HistorySyncUrls,fe as InboxReassignError,ze as Opfs,Te as OpfsInitializationError,Ae as OpfsNotInitializedError,ke as SignerUnavailableError,be as StreamFailedError,Se as StreamInvalidRetryAttemptsError,Re as StreamNotFoundError,J as contentTypeActions,Q as contentTypeAttachment,Y as contentTypeGroupUpdated,Z as contentTypeIntent,ee as contentTypeLeaveRequest,te as contentTypeMarkdown,ne as contentTypeMultiRemoteAttachment,se as contentTypeReaction,ie as contentTypeReadReceipt,re as contentTypeRemoteAttachment,ae as contentTypeReply,oe as contentTypeText,ce as contentTypeTransactionReference,de as contentTypeWalletSendCalls,he as decryptAttachment,G as encodeActions,U as encodeAttachment,W as encodeIntent,K as encodeMarkdown,_ as encodeMultiRemoteAttachment,V as encodeReaction,$ as encodeReadReceipt,j as encodeRemoteAttachment,z as encodeText,X as encodeTransactionReference,H as encodeWalletSendCalls,ue as encryptAttachment,Ue as generateInboxId,We as getInboxIdForIdentifier,dt as isActions,tt as isAttachment,it as isGroupUpdated,ct as isIntent,at as isLeaveRequest,ut as isMarkdown,nt as isMultiRemoteAttachment,Je as isReaction,rt as isReadReceipt,et as isRemoteAttachment,Qe as isReply,Ze as isText,Ye as isTextReply,st as isTransactionReference,ot as isWalletSendCalls,Xe as metadataFieldName,He as toSafeConversation,_e as toSafeSigner};
1
+ import e,{encodeActions as t,encodeAttachment as n,encodeIntent as s,encodeMarkdown as i,encodeMultiRemoteAttachment as r,encodeReaction as a,encodeReadReceipt as o,encodeRemoteAttachment as c,encodeText as d,encodeTransactionReference as u,encodeWalletSendCalls as h,contentTypeActions as p,contentTypeAttachment as l,contentTypeGroupUpdated as y,contentTypeIntent as g,contentTypeLeaveRequest as w,contentTypeMarkdown as m,contentTypeMultiRemoteAttachment as v,contentTypeReaction as k,contentTypeReadReceipt as I,contentTypeRemoteAttachment as f,contentTypeReply as x,contentTypeText as R,contentTypeTransactionReference as A,contentTypeWalletSendCalls as b,encryptAttachment as S,decryptAttachment as T,ConversationType as D,XmtpEnv as M,BackendBuilder as C,generateInboxId as q,getInboxIdForIdentifier as E,inboxStateFromInboxIds as O,applySignatureRequest as B,revokeInstallationsSignatureRequest as N,IdentifierKind as P,LogLevel as U,BackupElementSelectionOption as L,Backend as F,metadataFieldName as G}from"@xmtp/wasm-bindings";export{ActionStyle,BackupElementSelectionOption,ConsentEntityType,ConsentState,ContentType,ConversationType,DeliveryStatus,GroupMembershipState,GroupMessageKind,GroupPermissionsOptions,IdentifierKind,ListConversationsOrderBy,LogLevel,MessageSortBy,MetadataField,PermissionLevel,PermissionPolicy,PermissionUpdateType,ReactionAction,ReactionSchema,SortDirection}from"@xmtp/wasm-bindings";import{contentTypeToString as W}from"@xmtp/content-type-primitives";import{toBytes as K}from"viem";import{privateKeyToAccount as V,generatePrivateKey as _}from"viem/accounts";class ${#e;constructor(e){this.#e=new Map(e.map(e=>[W(e.contentType),e]))}getCodec(e){return this.#e.get(W(e))}}const j={local:"http://localhost:5557",dev:"https://api.dev.xmtp.network:5558",production:"https://api.production.xmtp.network:5558"},H={local:"http://localhost:5558",dev:"https://message-history.dev.ephemera.network",production:"https://message-history.production.ephemera.network","testnet-staging":"https://message-history.dev.ephemera.network","testnet-dev":"https://message-history.dev.ephemera.network",testnet:"https://message-history.dev.ephemera.network",mainnet:"https://message-history.production.ephemera.network"},z=t=>async(...n)=>(await e(),t(...n)),X=z(t),J=z(n),Q=z(s),Y=z(i),Z=z(r),ee=z(a),te=z(o),ne=z(c),se=z(d),ie=z(u),re=z(h),ae=z(p),oe=z(l),ce=z(y),de=z(g),ue=z(w),he=z(m),pe=z(v),le=z(k),ye=z(I),ge=z(f),we=z(x),me=z(R),ve=z(A),ke=z(b),Ie=z(S),fe=z(T);function xe(e){return new Date(Number(e/1000000n))}const Re=e=>{switch(e.type){case"text":case"markdown":case"reply":case"reaction":case"attachment":case"remoteAttachment":case"multiRemoteAttachment":case"transactionReference":case"groupUpdated":case"readReceipt":case"leaveRequest":case"walletSendCalls":case"intent":case"actions":case"deletedMessage":case"custom":return e.content;default:return null}};class Ae{content;contentType;conversationId;deliveryStatus;expiresAtNs;expiresAt;fallback;id;kind;numReplies;reactions;senderInboxId;sentAt;sentAtNs;constructor(e,t){switch(this.id=t.id,this.expiresAtNs=t.expiresAtNs,this.expiresAt=t.expiresAtNs?xe(t.expiresAtNs):void 0,this.sentAtNs=t.sentAtNs,this.sentAt=xe(t.sentAtNs),this.conversationId=t.conversationId,this.senderInboxId=t.senderInboxId,this.contentType=t.contentType,this.fallback=t.fallback??void 0,this.kind=t.kind,this.deliveryStatus=t.deliveryStatus,this.numReplies=t.numReplies,this.reactions=t.reactions.map(t=>new Ae(e,t)),this.content=Re(t.content)??void 0,t.content.type){case"reply":{const n=t.content.content;let s=Re(n.content);if("custom"===n.content.type){const t=e.getCodec(n.content.content.type);if(t)try{s=t.decode(s)}catch(e){e instanceof Error?console.warn(`Error decoding custom content: ${e.message}`):console.warn("Error decoding custom content")}}this.content={referenceId:n.referenceId,content:s,contentType:()=>(async e=>{switch(e.type){case"text":return me();case"markdown":return he();case"reply":return we();case"reaction":return le();case"attachment":return oe();case"remoteAttachment":return ge();case"multiRemoteAttachment":return pe();case"transactionReference":return ve();case"groupUpdated":return ce();case"readReceipt":return ye();case"leaveRequest":return ue();case"walletSendCalls":return ke();case"intent":return de();case"actions":return ae();case"deletedMessage":default:return;case"custom":return e.content.type}})(n.content),inReplyTo:n.inReplyTo?new Ae(e,n.inReplyTo):null};break}case"custom":{const n=t.content.content,s=e.getCodec(this.contentType);if(s)try{this.content=s.decode(n)}catch(e){e instanceof Error?console.warn(`Error decoding custom content: ${e.message}`):console.warn("Error decoding custom content"),this.content=void 0}else console.warn(`No codec found for content type "${W(this.contentType)}"`),this.content=void 0;break}}}}class be{isDone=!1;#t=[];#n;onDone;onReturn;constructor(){this.#n=[],this.isDone=!1}flush(){for(;this.#t.length>0;){const e=this.#t.shift();e&&e({done:!0,value:void 0})}}done(){this.flush(),this.#n=[],this.#t=[],this.isDone=!0,this.onDone?.()}push=e=>{if(this.isDone)return;const t=this.#t.shift();t?t({done:!1,value:e}):this.#n.push(e)};next=()=>this.isDone?Promise.resolve({done:!0,value:void 0}):this.#n.length>0?Promise.resolve({done:!1,value:this.#n.shift()}):new Promise(e=>{this.#t.push(e)});return=()=>(this.onReturn?.(),this.done(),Promise.resolve({done:!0,value:void 0}));end=()=>this.return();[Symbol.asyncIterator](){return this}}const Se=["end","isDone","next","return",Symbol.asyncIterator],Te=e=>Se.includes(e);class De extends Error{constructor(){super("Client not initialized, use Client.create or Client.build to create a client")}}class Me extends Error{constructor(){super("Signer unavailable, use Client.create to create a client with a signer")}}class Ce extends Error{constructor(){super("Unable to create add account signature text, `allowInboxReassign` must be true")}}class qe extends Error{constructor(e){super(`Account already associated with inbox ${e}`)}}class Ee extends Error{constructor(e){super(`Group "${e}" not found`)}}class Oe extends Error{constructor(e){super(`Stream "${e}" not found`)}}class Be extends Error{constructor(e){super(`Stream failed, retried ${e} ${"time"+(1!==e?"s":"")}`)}}class Ne extends Error{constructor(){super("Stream retry attempts must be greater than 0")}}class Pe extends Error{constructor(){super("OPFS must be initialized before accessing its methods")}}class Ue extends Error{constructor(){super("Failed to initialize OPFS, ensure that there are no other active XMTP clients or Opfs instances")}}const Le=1e4,Fe=6,Ge=async(e,t,n)=>{const{onEnd:s,onError:i,onFail:r,onRestart:a,onRetry:o,onValue:c,retryAttempts:d=Fe,retryDelay:u=Le,retryOnFail:h=!0}=n??{};if(h&&d<0)throw new Ne;const p=new be,l=(e,n)=>{if(e)i?.(e);else if(void 0!==n)try{if(t){const e=t(n);(e=>!!e&&("object"==typeof e||"function"==typeof e)&&"then"in e&&"function"==typeof e.then)(e)?e.then(e=>{void 0!==e&&(p.push(e),c?.(e))}).catch(e=>{i?.(e)}):void 0!==e&&(p.push(e),c?.(e))}else p.push(n),c?.(n)}catch(e){i?.(e)}},y=async(t=d)=>{try{if(0===t)throw p.end(),new Be(d);await(n=u,new Promise(e=>setTimeout(e,n))),o?.(d-t+1,d);const i=await e(l,()=>{r?.(),y()});p.onDone=()=>{i(),s?.()},a?.()}catch(e){i?.(e),y(t-1)}var n},g=()=>{if(!h)throw p.end(),new Be(0);y()};try{const t=await e(l,()=>{r?.(),g()});p.onDone=()=>{t(),s?.()}}catch(e){i?.(e),g()}return new Proxy(p,{get(e,t,n){if(Te(t))return Reflect.get(e,t,n)},set:()=>!0,has:(e,t)=>Te(t),ownKeys:()=>Se,getOwnPropertyDescriptor(e,t){if(Te(t))return{enumerable:!0,configurable:!0,value:Reflect.get(e,t)}}})},We=()=>{const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")};class Ke{#s;#i;#r;#a;#o;#c;constructor(e,t,n,s){this.#c=e,this.#i=t,this.#a=n,this.#d(s)}#d(e){this.#s=e?.addedByInboxId,this.#o=e?.metadata,this.#r=e?.createdAtNs}get id(){return this.#a}get addedByInboxId(){return this.#s}get createdAtNs(){return this.#r}get createdAt(){return this.#r?xe(this.#r):void 0}get metadata(){return this.#o}get topic(){return`/xmtp/mls/1/g-${this.id}/proto`}async lastMessage(){const e=await this.#c.action("conversation.lastMessage",{id:this.#a});return e?new Ae(this.#i,e):void 0}async isActive(){return this.#c.action("conversation.isActive",{id:this.#a})}async members(){return this.#c.action("conversation.members",{id:this.#a})}async sync(){const e=await this.#c.action("conversation.sync",{id:this.#a});return this.#d(e),e}async publishMessages(){return this.#c.action("conversation.publishMessages",{id:this.#a})}async processStreamedMessage(e){return this.#c.action("conversation.processStreamedMessage",{id:this.#a,envelopeBytes:e})}async send(e,t){return this.#c.action("conversation.send",{id:this.#a,content:e,options:t})}async sendText(e,t){return this.#c.action("conversation.sendText",{id:this.#a,text:e,isOptimistic:t})}async sendMarkdown(e,t){return this.#c.action("conversation.sendMarkdown",{id:this.#a,markdown:e,isOptimistic:t})}async sendReaction(e,t){return this.#c.action("conversation.sendReaction",{id:this.#a,reaction:e,isOptimistic:t})}async sendReadReceipt(e){return this.#c.action("conversation.sendReadReceipt",{id:this.#a,isOptimistic:e})}async sendReply(e,t){return this.#c.action("conversation.sendReply",{id:this.#a,reply:e,isOptimistic:t})}async sendTransactionReference(e,t){return this.#c.action("conversation.sendTransactionReference",{id:this.#a,transactionReference:e,isOptimistic:t})}async sendWalletSendCalls(e,t){return this.#c.action("conversation.sendWalletSendCalls",{id:this.#a,walletSendCalls:e,isOptimistic:t})}async sendActions(e,t){return this.#c.action("conversation.sendActions",{id:this.#a,actions:e,isOptimistic:t})}async sendIntent(e,t){return this.#c.action("conversation.sendIntent",{id:this.#a,intent:e,isOptimistic:t})}async sendAttachment(e,t){return this.#c.action("conversation.sendAttachment",{id:this.#a,attachment:e,isOptimistic:t})}async sendMultiRemoteAttachment(e,t){return this.#c.action("conversation.sendMultiRemoteAttachment",{id:this.#a,multiRemoteAttachment:e,isOptimistic:t})}async sendRemoteAttachment(e,t){return this.#c.action("conversation.sendRemoteAttachment",{id:this.#a,remoteAttachment:e,isOptimistic:t})}async messages(e){return(await this.#c.action("conversation.messages",{id:this.#a,options:e})).map(e=>new Ae(this.#i,e))}async countMessages(e){return await this.#c.action("conversation.countMessages",{id:this.#a,options:e})}async consentState(){return this.#c.action("conversation.consentState",{id:this.#a})}async updateConsentState(e){return this.#c.action("conversation.updateConsentState",{id:this.#a,state:e})}async messageDisappearingSettings(){return this.#c.action("conversation.messageDisappearingSettings",{id:this.#a})}async updateMessageDisappearingSettings(e,t){return this.#c.action("conversation.updateMessageDisappearingSettings",{id:this.#a,fromNs:e,inNs:t})}async removeMessageDisappearingSettings(){return this.#c.action("conversation.removeMessageDisappearingSettings",{id:this.#a})}async isMessageDisappearingEnabled(){return this.#c.action("conversation.isMessageDisappearingEnabled",{id:this.#a})}async stream(e){return Ge(async(t,n)=>{const s=We();return e?.disableSync||await this.sync(),await this.#c.action("conversation.stream",{groupId:this.#a,streamId:s}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},e=>new Ae(this.#i,e),e)}async pausedForVersion(){return this.#c.action("conversation.pausedForVersion",{id:this.#a})}async hmacKeys(){return this.#c.action("conversation.hmacKeys",{id:this.#a})}async debugInfo(){return this.#c.action("conversation.debugInfo",{id:this.#a})}async lastReadTimes(){return this.#c.action("conversation.lastReadTimes",{id:this.#a})}}class Ve extends Ke{#i;#c;#a;constructor(e,t,n,s){super(e,t,n,s),this.#c=e,this.#i=t,this.#a=n}async peerInboxId(){return this.#c.action("dm.peerInboxId",{id:this.#a})}async duplicateDms(){return(await this.#c.action("dm.duplicateDms",{id:this.#a})).map(e=>new Ve(this.#c,this.#i,e.id,e))}}class _e extends Ke{#u=[];#h;#c;#p;#a;#l;#y;#g=[];#d(e){this.#y=e?.name??"",this.#l=e?.imageUrl??"",this.#p=e?.description??"",this.#h=e?.appData??"",this.#u=e?.admins??[],this.#g=e?.superAdmins??[]}constructor(e,t,n,s){super(e,t,n,s),this.#c=e,this.#a=n,this.#d(s)}async sync(){const e=await super.sync();return this.#d(e),e}get name(){return this.#y}async updateName(e){await this.#c.action("group.updateName",{id:this.#a,name:e}),this.#y=e}get imageUrl(){return this.#l}async updateImageUrl(e){await this.#c.action("group.updateImageUrl",{id:this.#a,imageUrl:e}),this.#l=e}get description(){return this.#p}async updateDescription(e){await this.#c.action("group.updateDescription",{id:this.#a,description:e}),this.#p=e}get appData(){return this.#h}async updateAppData(e){await this.#c.action("group.updateAppData",{id:this.#a,appData:e}),this.#h=e}get admins(){return this.#u}get superAdmins(){return this.#g}async listAdmins(){const e=await this.#c.action("group.listAdmins",{id:this.#a});return this.#u=e,e}async listSuperAdmins(){const e=await this.#c.action("group.listSuperAdmins",{id:this.#a});return this.#g=e,e}async permissions(){return this.#c.action("group.permissions",{id:this.#a})}async updatePermission(e,t,n){return this.#c.action("group.updatePermission",{id:this.#a,permissionType:e,policy:t,metadataField:n})}async isAdmin(e){return(await this.listAdmins()).includes(e)}async isSuperAdmin(e){return(await this.listSuperAdmins()).includes(e)}async addMembersByIdentifiers(e){return this.#c.action("group.addMembersByIdentifiers",{id:this.#a,identifiers:e})}async addMembers(e){return this.#c.action("group.addMembers",{id:this.#a,inboxIds:e})}async removeMembersByIdentifiers(e){return this.#c.action("group.removeMembersByIdentifiers",{id:this.#a,identifiers:e})}async removeMembers(e){return this.#c.action("group.removeMembers",{id:this.#a,inboxIds:e})}async addAdmin(e){return this.#c.action("group.addAdmin",{id:this.#a,inboxId:e})}async removeAdmin(e){return this.#c.action("group.removeAdmin",{id:this.#a,inboxId:e})}async addSuperAdmin(e){return this.#c.action("group.addSuperAdmin",{id:this.#a,inboxId:e})}async removeSuperAdmin(e){return this.#c.action("group.removeSuperAdmin",{id:this.#a,inboxId:e})}async requestRemoval(){return this.#c.action("group.requestRemoval",{id:this.#a})}async isPendingRemoval(){return this.#c.action("group.isPendingRemoval",{id:this.#a})}}class $e{#w;#i;#c;constructor(e,t,n){this.#w=e,this.#c=t,this.#i=n}get topic(){return this.#w.installationId?`/xmtp/mls/1/w-${this.#w.installationId}/proto`:void 0}async sync(){return this.#c.action("conversations.sync")}async syncAll(e){return this.#c.action("conversations.syncAll",{consentStates:e})}async getConversationById(e){const t=await this.#c.action("conversations.getConversationById",{id:e});if(t)switch(t.metadata.conversationType){case D.Group:return new _e(this.#c,this.#i,t.id,t);case D.Dm:return new Ve(this.#c,this.#i,t.id,t);default:return}}async getMessageById(e){const t=await this.#c.action("conversations.getMessageById",{id:e});return t?new Ae(this.#i,t):void 0}async getDmByInboxId(e){const t=await this.#c.action("conversations.getDmByInboxId",{inboxId:e});return t?new Ve(this.#c,this.#i,t.id,t):void 0}async fetchDmByIdentifier(e){const t=await this.#c.action("client.getInboxIdByIdentifier",{identifier:e});if(t)return this.getDmByInboxId(t)}async list(e){return(await this.#c.action("conversations.list",{options:e})).map(e=>{switch(e.metadata.conversationType){case D.Dm:return new Ve(this.#c,this.#i,e.id,e);case D.Group:return new _e(this.#c,this.#i,e.id,e);default:return}}).filter(e=>void 0!==e)}async listGroups(e){return(await this.#c.action("conversations.listGroups",{options:e})).map(e=>new _e(this.#c,this.#i,e.id,e))}async listDms(e){return(await this.#c.action("conversations.listDms",{options:e})).map(e=>new Ve(this.#c,this.#i,e.id,e))}async createGroupOptimistic(e){const t=await this.#c.action("conversations.createGroupOptimistic",{options:e});return new _e(this.#c,this.#i,t.id,t)}async createGroupWithIdentifiers(e,t){const n=await this.#c.action("conversations.createGroupWithIdentifiers",{identifiers:e,options:t});return new _e(this.#c,this.#i,n.id,n)}async createGroup(e,t){const n=await this.#c.action("conversations.createGroup",{inboxIds:e,options:t});return new _e(this.#c,this.#i,n.id,n)}async createDmWithIdentifier(e,t){const n=await this.#c.action("conversations.createDmWithIdentifier",{identifier:e,options:t});return new Ve(this.#c,this.#i,n.id,n)}async createDm(e,t){const n=await this.#c.action("conversations.createDm",{inboxId:e,options:t});return new Ve(this.#c,this.#i,n.id,n)}async hmacKeys(){return this.#c.action("conversations.hmacKeys")}async stream(e){return Ge(async(t,n)=>{const s=We();return e?.disableSync||await this.sync(),await this.#c.action("conversations.stream",{streamId:s,conversationType:e?.conversationType}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},e=>{switch(e.metadata.conversationType){case D.Group:return new _e(this.#c,this.#i,e.id,e);case D.Dm:return new Ve(this.#c,this.#i,e.id,e);default:return void console.warn(`Unknown conversation type: ${e.metadata.conversationType}`)}},e)}async streamGroups(e){return this.stream({...e,conversationType:D.Group})}async streamDms(e){return this.stream({...e,conversationType:D.Dm})}async streamAllMessages(e){return Ge(async(t,n)=>{const s=We();return e?.disableSync||await this.sync(),await this.#c.action("conversations.streamAllMessages",{streamId:s,conversationType:e?.conversationType,consentStates:e?.consentStates}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},e=>new Ae(this.#i,e),e)}async streamAllGroupMessages(e){return this.streamAllMessages({...e,conversationType:D.Group})}async streamAllDmMessages(e){return this.streamAllMessages({...e,conversationType:D.Dm})}async streamMessageDeletions(e){return Ge(async t=>{const n=We();return await this.#c.action("conversations.streamDeletedMessages",{streamId:n}),this.#c.handleStreamMessage(n,t,e)},e=>e.id,e)}async streamDeletedMessages(e){return Ge(async t=>{const n=We();return await this.#c.action("conversations.streamDeletedMessages",{streamId:n}),this.#c.handleStreamMessage(n,t,e)},e=>new Ae(this.#i,e),e)}}class je{#c;constructor(e){this.#c=e}apiStatistics(){return this.#c.action("debugInformation.apiStatistics")}apiIdentityStatistics(){return this.#c.action("debugInformation.apiIdentityStatistics")}apiAggregateStatistics(){return this.#c.action("debugInformation.apiAggregateStatistics")}clearAllStatistics(){return this.#c.action("debugInformation.clearAllStatistics")}}class He{#c;constructor(e){this.#c=e}sync(){return this.#c.action("preferences.sync")}async inboxState(){return this.#c.action("preferences.inboxState",{refreshFromNetwork:!1})}async fetchInboxState(){return this.#c.action("preferences.inboxState",{refreshFromNetwork:!0})}async getInboxStates(e){return this.#c.action("preferences.getInboxStates",{inboxIds:e,refreshFromNetwork:!1})}async fetchInboxStates(e){return this.#c.action("preferences.getInboxStates",{inboxIds:e,refreshFromNetwork:!0})}async setConsentStates(e){return this.#c.action("preferences.setConsentStates",{records:e})}async getConsentState(e,t){return this.#c.action("preferences.getConsentState",{entityType:e,entity:t})}async streamConsent(e){return Ge(async(t,n)=>{const s=We();return e?.disableSync||await this.sync(),await this.#c.action("preferences.streamConsent",{streamId:s}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},void 0,e)}async streamPreferences(e){return Ge(async(t,n)=>{const s=We();return e?.disableSync||await this.sync(),await this.#c.action("preferences.streamPreferences",{streamId:s}),this.#c.handleStreamMessage(s,t,{...e,onFail:n})},void 0,e)}}const ze={local:M.Local,dev:M.Dev,production:M.Production,"testnet-staging":M.TestnetStaging,"testnet-dev":M.TestnetDev,testnet:M.Testnet,mainnet:M.Mainnet};M.Local,M.Dev,M.Production,M.TestnetStaging,M.TestnetDev,M.Testnet,M.Mainnet;const Xe=async t=>{await e();let n=new C(ze[t?.env??"dev"]);return t?.apiUrl&&(n=n.setApiUrl(t.apiUrl)),t?.gatewayHost&&(n=n.setGatewayHost(t.gatewayHost)),t?.appVersion&&(n=n.setAppVersion(t.appVersion)),n.build()},Je=async(t,n)=>(await e(),q(t,n)),Qe=async(t,n)=>(await e(),E(t,n)),Ye=async(t,n,s,i)=>{await e();const r=await n.getIdentifier(),{signatureText:a,signatureRequest:o}=await(async(t,n,s,i)=>{await e();const r=N(t,n,s,i);return{signatureText:await r.signatureText(),signatureRequest:r}})(t,r,s,i),c=await n.signMessage(a);switch(n.type){case"EOA":await o.addEcdsaSignature(c);break;case"SCW":await o.addScwSignature(r,c,n.getChainId(),n.getBlockNumber?.())}await B(t,o)},Ze=(e=_())=>{const t=V(e);return{type:"EOA",getIdentifier:()=>({identifier:t.address.toLowerCase(),identifierKind:P.Ethereum}),signMessage:async e=>{const n=await t.signMessage({message:e});return K(n)}}},et=(e,t,n)=>({type:"SCW",getIdentifier:()=>({identifier:e.toLowerCase(),identifierKind:P.Ethereum}),signMessage:async e=>{const n=await t(e);return K(n)},getChainId:()=>n}),tt=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?.()}}},nt=e=>{console.error(`[worker] error: ${e.message}`)};class st{#c;#m;#v=new Map;constructor(e,t){this.#c=e,this.#c.addEventListener("message",this.handleMessage),this.#c.addEventListener("error",nt),this.#m=t??!1}action(e,...t){const n=We();this.#c.postMessage({action:e,id:n,data:t[0]});return new Promise((e,t)=>{this.#v.set(n,{resolve:e,reject:t})})}handleMessage=e=>{const t=e.data;this.#m&&console.log("[worker] client received event data",t);const n=this.#v.get(t.id);n&&(this.#v.delete(t.id),"error"in t?n.reject(t.error):n.resolve(t.result))};handleStreamMessage=(e,t,n)=>{const s=s=>{const i=s.data;if(i.streamId===e){if("stream.fail"===i.action)return void n?.onFail?.();"error"in i?t(i.error,void 0):t(null,i.result)}};return this.#c.addEventListener("message",s),async()=>{await this.action("endStream",{streamId:e}),this.#c.removeEventListener("message",s)}};close(){this.#c.removeEventListener("message",this.handleMessage),this.#c.removeEventListener("error",nt),this.#c.terminate()}}const it=async(e,t)=>e instanceof F?e:Xe({env:e,gatewayHost:t});class rt{#k;#i;#I;#f;#x;#R;#A;#b;#S;#T=!1;#D;#M;#C;#q;#c;constructor(e){e&&Object.defineProperty(e,"codecs",{value:e.codecs,enumerable:!1});const t=new Worker(new URL("./workers/client",import.meta.url),{type:"module"}),n=void 0!==e?.loggingLevel&&e.loggingLevel!==U.Off;this.#c=new st(t,n),this.#i=new $([...e?.codecs??[]]),this.#M=e,this.#I=new $e(this,this.#c,this.#i),this.#f=new je(this.#c),this.#C=new He(this.#c)}async init(e){const t=await this.#c.action("client.init",{identifier:e,options:this.#M});this.#k=t.appVersion,this.#x=t.env,this.#R=e,this.#A=t.inboxId,this.#b=t.installationId,this.#S=t.installationIdBytes,this.#D=t.libxmtpVersion,this.#T=!0}close(){this.#c.close(),this.#T=!1}static async create(e,t){const n=new rt(t);return n.#q=e,await n.init(await e.getIdentifier()),t?.disableAutoRegister||await n.register(),n}static async build(e,t){const n=new rt({...t,disableAutoRegister:!0});return await n.init(e),n}get options(){return this.#M}get signer(){return this.#q}get isReady(){return this.#T}get inboxId(){return this.#A}get accountIdentifier(){return this.#R}get installationId(){return this.#b}get installationIdBytes(){return this.#S}get conversations(){return this.#I}get debugInformation(){return this.#f}get preferences(){return this.#C}get libxmtpVersion(){return this.#D}get appVersion(){return this.#k}get env(){return this.#x}async unsafe_createInboxSignatureText(){return this.#c.action("client.createInboxSignatureText",{signatureRequestId:We()})}async unsafe_addAccountSignatureText(e,t=!1){if(!t)throw new Ce;return this.#c.action("client.addAccountSignatureText",{newIdentifier:e,signatureRequestId:We()})}async unsafe_removeAccountSignatureText(e){return this.#c.action("client.removeAccountSignatureText",{identifier:e,signatureRequestId:We()})}async unsafe_revokeAllOtherInstallationsSignatureText(){return this.#c.action("client.revokeAllOtherInstallationsSignatureText",{signatureRequestId:We()})}async unsafe_revokeInstallationsSignatureText(e){return this.#c.action("client.revokeInstallationsSignatureText",{installationIds:e,signatureRequestId:We()})}async unsafe_changeRecoveryIdentifierSignatureText(e){return this.#c.action("client.changeRecoveryIdentifierSignatureText",{identifier:e,signatureRequestId:We()})}async unsafe_applySignatureRequest(e,t){return this.#c.action("client.applySignatureRequest",{signer:e,signatureRequestId:t})}async register(){if(!this.#q)throw new Me;const{signatureText:e,signatureRequestId:t}=await this.unsafe_createInboxSignatureText();if(!e||!t)return;const n=await this.#q.signMessage(e),s=await tt(this.#q,n);return this.#c.action("client.registerIdentity",{signer:s,signatureRequestId:t})}async unsafe_addAccount(e,t=!1){if(!this.#q)throw new Me;if(!t)throw new Ce;const n=await this.fetchInboxIdByIdentifier(await e.getIdentifier());if(n)throw new qe(n);const{signatureText:s,signatureRequestId:i}=await this.unsafe_addAccountSignatureText(await e.getIdentifier(),!0),r=await e.signMessage(s),a=await tt(e,r);return this.#c.action("client.addAccount",{identifier:a.identifier,signer:a,signatureRequestId:i})}async removeAccount(e){if(!this.#q)throw new Me;const{signatureText:t,signatureRequestId:n}=await this.unsafe_removeAccountSignatureText(e),s=await this.#q.signMessage(t),i=await tt(this.#q,s);return this.#c.action("client.removeAccount",{identifier:e,signer:i,signatureRequestId:n})}async revokeAllOtherInstallations(){if(!this.#q)throw new Me;const{signatureText:e,signatureRequestId:t}=await this.unsafe_revokeAllOtherInstallationsSignatureText();if(!e)return;const n=await this.#q.signMessage(e),s=await tt(this.#q,n);return this.#c.action("client.revokeAllOtherInstallations",{signer:s,signatureRequestId:t})}async revokeInstallations(e){if(!this.#q)throw new Me;const{signatureText:t,signatureRequestId:n}=await this.unsafe_revokeInstallationsSignatureText(e),s=await this.#q.signMessage(t),i=await tt(this.#q,s);return this.#c.action("client.revokeInstallations",{installationIds:e,signer:i,signatureRequestId:n})}static async revokeInstallations(e,t,n,s,i){const r=await it(s,i);await Ye(r,e,t,n)}static async fetchInboxStates(t,n,s){return(async(t,n)=>(await e(),O(t,n)))(await it(n,s),t)}async changeRecoveryIdentifier(e){if(!this.#q)throw new Me;const{signatureText:t,signatureRequestId:n}=await this.unsafe_changeRecoveryIdentifierSignatureText(e),s=await this.#q.signMessage(t),i=await tt(this.#q,s);return this.#c.action("client.changeRecoveryIdentifier",{identifier:e,signer:i,signatureRequestId:n})}async isRegistered(){return this.#c.action("client.isRegistered")}async canMessage(e){return this.#c.action("client.canMessage",{identifiers:e})}static async canMessage(e,t){const n=await it(t),s=new Map;for(const t of e){const e=await Qe(n,t);s.set(t.identifier.toLowerCase(),void 0!==e)}return s}async fetchInboxIdByIdentifier(e){return this.#c.action("client.getInboxIdByIdentifier",{identifier:e})}signWithInstallationKey(e){return this.#c.action("client.signWithInstallationKey",{signatureText:e})}verifySignedWithInstallationKey(e,t){return this.#c.action("client.verifySignedWithInstallationKey",{signatureText:e,signatureBytes:t})}verifySignedWithPublicKey(e,t,n){return this.#c.action("client.verifySignedWithPublicKey",{signatureText:e,signatureBytes:t,publicKey:n})}async fetchKeyPackageStatuses(e){return this.#c.action("client.fetchKeyPackageStatuses",{installationIds:e})}#E(){return{elements:[L.Consent,L.Messages],excludeDisappearingMessages:!1}}#O(){const e=this.#x??"dev";return H[e]}async sendSyncRequest(e,t){const n=e??this.#E(),s=t??this.#O();return this.#c.action("client.sendSyncRequest",{options:n,serverUrl:s})}async sendSyncArchive(e,t,n){const s=t??this.#E(),i=n??this.#O();return this.#c.action("client.sendSyncArchive",{options:s,serverUrl:i,pin:e})}async processSyncArchive(e){return this.#c.action("client.processSyncArchive",{archivePin:e})}async listAvailableArchives(e){return this.#c.action("client.listAvailableArchives",{daysCutoff:e})}async createArchive(e,t){const n=t??this.#E();return this.#c.action("client.createArchive",{opts:n,key:e})}async importArchive(e,t){return this.#c.action("client.importArchive",{data:e,key:t})}async archiveMetadata(e,t){return this.#c.action("client.archiveMetadata",{data:e,key:t})}async syncAllDeviceSyncGroups(){return this.#c.action("client.syncAllDeviceSyncGroups")}}class at{#c;#m;constructor(e){const t=new Worker(new URL("./workers/opfs",import.meta.url),{type:"module"});this.#c=new st(t,e),this.#m=e??!1}async init(){await this.#c.action("opfs.init",{enableLogging:this.#m})}close(){this.#c.close()}static async create(e){const t=new at(e);return await t.init(),t}async listFiles(){return this.#c.action("opfs.listFiles")}async fileCount(){return this.#c.action("opfs.fileCount")}async poolCapacity(){return this.#c.action("opfs.poolCapacity")}async fileExists(e){return this.#c.action("opfs.fileExists",{path:e})}async deleteFile(e){return this.#c.action("opfs.deleteFile",{path:e})}async exportDb(e){return this.#c.action("opfs.exportDb",{path:e})}async importDb(e,t){return this.#c.action("opfs.importDb",{path:e,data:t})}async clearAll(){return this.#c.action("opfs.clearAll")}}const ot=async t=>(await e(),G(t)),ct=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,appData:e.appData,permissions:e.permissions(),addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.listAdmins(),superAdmins:e.listSuperAdmins(),createdAtNs:e.createdAtNs}),dt=e=>"xmtp.org"===e.contentType.authorityId&&"reaction"===e.contentType.typeId,ut=e=>"xmtp.org"===e.contentType.authorityId&&"reply"===e.contentType.typeId,ht=e=>ut(e)&&"string"==typeof e.content?.content,pt=e=>"xmtp.org"===e.contentType.authorityId&&"text"===e.contentType.typeId,lt=e=>"xmtp.org"===e.contentType.authorityId&&"remoteStaticAttachment"===e.contentType.typeId,yt=e=>"xmtp.org"===e.contentType.authorityId&&"attachment"===e.contentType.typeId,gt=e=>"xmtp.org"===e.contentType.authorityId&&"multiRemoteStaticAttachment"===e.contentType.typeId,wt=e=>"xmtp.org"===e.contentType.authorityId&&"transactionReference"===e.contentType.typeId,mt=e=>"xmtp.org"===e.contentType.authorityId&&"group_updated"===e.contentType.typeId,vt=e=>"xmtp.org"===e.contentType.authorityId&&"readReceipt"===e.contentType.typeId,kt=e=>"xmtp.org"===e.contentType.authorityId&&"leave_request"===e.contentType.typeId,It=e=>"xmtp.org"===e.contentType.authorityId&&"walletSendCalls"===e.contentType.typeId,ft=e=>"coinbase.com"===e.contentType.authorityId&&"intent"===e.contentType.typeId,xt=e=>"coinbase.com"===e.contentType.authorityId&&"actions"===e.contentType.typeId,Rt=e=>"xmtp.org"===e.contentType.authorityId&&"markdown"===e.contentType.typeId;export{qe as AccountAlreadyAssociatedError,j as ApiUrls,rt as Client,De as ClientNotInitializedError,Ke as Conversation,$e as Conversations,Ae as DecodedMessage,Ve as Dm,_e as Group,Ee as GroupNotFoundError,H as HistorySyncUrls,Ce as InboxReassignError,at as Opfs,Ue as OpfsInitializationError,Pe as OpfsNotInitializedError,Me as SignerUnavailableError,Be as StreamFailedError,Ne as StreamInvalidRetryAttemptsError,Oe as StreamNotFoundError,ae as contentTypeActions,oe as contentTypeAttachment,ce as contentTypeGroupUpdated,de as contentTypeIntent,ue as contentTypeLeaveRequest,he as contentTypeMarkdown,pe as contentTypeMultiRemoteAttachment,le as contentTypeReaction,ye as contentTypeReadReceipt,ge as contentTypeRemoteAttachment,we as contentTypeReply,me as contentTypeText,ve as contentTypeTransactionReference,ke as contentTypeWalletSendCalls,Xe as createBackend,Ze as createEOASigner,et as createSCWSigner,fe as decryptAttachment,X as encodeActions,J as encodeAttachment,Q as encodeIntent,Y as encodeMarkdown,Z as encodeMultiRemoteAttachment,ee as encodeReaction,te as encodeReadReceipt,ne as encodeRemoteAttachment,se as encodeText,ie as encodeTransactionReference,re as encodeWalletSendCalls,Ie as encryptAttachment,Je as generateInboxId,Qe as getInboxIdForIdentifier,xt as isActions,yt as isAttachment,mt as isGroupUpdated,ft as isIntent,kt as isLeaveRequest,Rt as isMarkdown,gt as isMultiRemoteAttachment,dt as isReaction,vt as isReadReceipt,lt as isRemoteAttachment,ut as isReply,pt as isText,ht as isTextReply,wt as isTransactionReference,It as isWalletSendCalls,ot as metadataFieldName,ct as toSafeConversation,tt as toSafeSigner};
2
2
  //# sourceMappingURL=index.js.map