@xmtp/browser-sdk 0.0.1 → 0.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sources":["../../src/utils/conversions.ts","../../src/constants.ts","../../src/WorkerConversation.ts","../../src/WorkerConversations.ts","../../src/WorkerClient.ts","../../src/utils/createClient.ts","../../src/workers/client.ts"],"sourcesContent":["import {\n ContentTypeId,\n type EncodedContent,\n} from \"@xmtp/content-type-primitives\";\nimport {\n WasmConsent,\n WasmContentTypeId,\n WasmCreateGroupOptions,\n WasmEncodedContent,\n WasmGroupMember,\n WasmListConversationsOptions,\n WasmListMessagesOptions,\n type WasmConsentEntityType,\n type WasmConsentState,\n type WasmDeliveryStatus,\n type WasmGroupMessageKind,\n type WasmGroupPermissionsOptions,\n type WasmInboxState,\n type WasmInstallation,\n type WasmMessage,\n type WasmPermissionLevel,\n type WasmPermissionPolicy,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authority_id,\n typeId: contentTypeId.type_id,\n versionMajor: contentTypeId.version_major,\n versionMinor: contentTypeId.version_minor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: WasmDeliveryStatus;\n id: string;\n kind: WasmGroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: WasmMessage): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convo_id,\n deliveryStatus: message.delivery_status,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.sender_inbox_id,\n sentAtNs: message.sent_at_ns,\n});\n\nexport type SafeListMessagesOptions = {\n delivery_status?: WasmDeliveryStatus;\n limit?: bigint;\n sent_after_ns?: bigint;\n sent_before_ns?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: WasmListMessagesOptions,\n): SafeListMessagesOptions => ({\n delivery_status: options.delivery_status,\n limit: options.limit,\n sent_after_ns: options.sent_after_ns,\n sent_before_ns: options.sent_before_ns,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): WasmListMessagesOptions =>\n new WasmListMessagesOptions(\n options.sent_before_ns,\n options.sent_after_ns,\n options.limit,\n options.delivery_status,\n );\n\nexport type SafeListConversationsOptions = {\n created_after_ns?: bigint;\n created_before_ns?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: WasmListConversationsOptions,\n): SafeListConversationsOptions => ({\n created_after_ns: options.created_after_ns,\n created_before_ns: options.created_before_ns,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): WasmListConversationsOptions =>\n new WasmListConversationsOptions(\n options.created_after_ns,\n options.created_before_ns,\n options.limit,\n );\n\nexport type SafeCreateGroupOptions = {\n permissions?: WasmGroupPermissionsOptions;\n name?: string;\n imageUrlSquare?: string;\n description?: string;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: WasmCreateGroupOptions,\n): SafeCreateGroupOptions => ({\n permissions: options.permissions,\n name: options.group_name,\n imageUrlSquare: options.group_image_url_square,\n description: options.group_description,\n pinnedFrameUrl: options.group_pinned_frame_url,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): WasmCreateGroupOptions =>\n new WasmCreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: WasmGroupPermissionsOptions;\n policySet: {\n addAdminPolicy: WasmPermissionPolicy;\n addMemberPolicy: WasmPermissionPolicy;\n removeAdminPolicy: WasmPermissionPolicy;\n removeMemberPolicy: WasmPermissionPolicy;\n updateGroupDescriptionPolicy: WasmPermissionPolicy;\n updateGroupImageUrlSquarePolicy: WasmPermissionPolicy;\n updateGroupNamePolicy: WasmPermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: WasmPermissionPolicy;\n };\n };\n isActive: boolean;\n addedByInboxId: string;\n metadata: {\n creatorInboxId: string;\n conversationType: string;\n };\n admins: string[];\n superAdmins: string[];\n createdAtNs: bigint;\n};\n\nexport const toSafeConversation = (\n conversation: WorkerConversation,\n): SafeConversation => ({\n id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.add_admin_policy,\n addMemberPolicy: conversation.permissions.policySet.add_member_policy,\n removeAdminPolicy: conversation.permissions.policySet.remove_admin_policy,\n removeMemberPolicy:\n conversation.permissions.policySet.remove_member_policy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.update_group_description_policy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.update_group_image_url_square_policy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.update_group_name_policy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.update_group_pinned_frame_url_policy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: conversation.metadata,\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\n});\n\nexport type SafeInstallation = {\n id: string;\n clientTimestampNs?: bigint;\n};\n\nexport const toSafeInstallation = (\n installation: WasmInstallation,\n): SafeInstallation => ({\n id: installation.id,\n clientTimestampNs: installation.client_timestamp_ns,\n});\n\nexport type SafeInboxState = {\n accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (\n inboxState: WasmInboxState,\n): SafeInboxState => ({\n accountAddresses: inboxState.account_addresses,\n inboxId: inboxState.inbox_id,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recovery_address,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: WasmConsentEntityType;\n state: WasmConsentState;\n};\n\nexport const toSafeConsent = (consent: WasmConsent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entity_type,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): WasmConsent =>\n new WasmConsent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: WasmConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: WasmPermissionLevel;\n};\n\nexport const toSafeGroupMember = (\n member: WasmGroupMember,\n): SafeGroupMember => ({\n accountAddresses: member.account_addresses,\n consentState: member.consent_state,\n inboxId: member.inbox_id,\n installationIds: member.installation_ids,\n permissionLevel: member.permission_level,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): WasmGroupMember =>\n new WasmGroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n","import type {\n WasmConsentState,\n WasmEncodedContent,\n WasmGroup,\n WasmGroupMember,\n} from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeListMessagesOptions,\n type SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\n\nexport class WorkerConversation {\n // eslint-disable-next-line no-unused-private-class-members\n #client: WorkerClient;\n\n #group: WasmGroup;\n\n constructor(client: WorkerClient, group: WasmGroup) {\n this.#client = client;\n this.#group = group;\n }\n\n get id() {\n return this.#group.id();\n }\n\n get name() {\n return this.#group.group_name();\n }\n\n async updateName(name: string) {\n return this.#group.update_group_name(name);\n }\n\n get imageUrl() {\n return this.#group.group_image_url_square();\n }\n\n async updateImageUrl(imageUrl: string) {\n return this.#group.update_group_image_url_square(imageUrl);\n }\n\n get description() {\n return this.#group.group_description();\n }\n\n async updateDescription(description: string) {\n return this.#group.update_group_description(description);\n }\n\n get pinnedFrameUrl() {\n return this.#group.group_pinned_frame_url();\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n return this.#group.update_group_pinned_frame_url(pinnedFrameUrl);\n }\n\n get isActive() {\n return this.#group.is_active();\n }\n\n get addedByInboxId() {\n return this.#group.added_by_inbox_id();\n }\n\n get createdAtNs() {\n return this.#group.created_at_ns();\n }\n\n get metadata() {\n const metadata = this.#group.group_metadata();\n return {\n creatorInboxId: metadata.creator_inbox_id(),\n conversationType: metadata.conversation_type(),\n };\n }\n\n async members() {\n return this.#group.list_members() as Promise<WasmGroupMember[]>;\n }\n\n get admins() {\n return this.#group.admin_list();\n }\n\n get superAdmins() {\n return this.#group.super_admin_list();\n }\n\n get permissions() {\n const permissions = this.#group.group_permissions();\n return {\n policyType: permissions.policy_type(),\n policySet: permissions.policy_set(),\n };\n }\n\n isAdmin(inboxId: string) {\n return this.#group.is_admin(inboxId);\n }\n\n isSuperAdmin(inboxId: string) {\n return this.#group.is_super_admin(inboxId);\n }\n\n async sync() {\n return this.#group.sync();\n }\n\n async addMembers(accountAddresses: string[]) {\n return this.#group.add_members(accountAddresses);\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#group.add_members_by_inbox_id(inboxIds);\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#group.remove_members(accountAddresses);\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#group.remove_members_by_inbox_id(inboxIds);\n }\n\n async addAdmin(inboxId: string) {\n return this.#group.add_admin(inboxId);\n }\n\n async removeAdmin(inboxId: string) {\n return this.#group.remove_admin(inboxId);\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#group.add_super_admin(inboxId);\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#group.remove_super_admin(inboxId);\n }\n\n async publishMessages() {\n return this.#group.publish_messages();\n }\n\n sendOptimistic(encodedContent: WasmEncodedContent) {\n return this.#group.send_optimistic(encodedContent);\n }\n\n async send(encodedContent: WasmEncodedContent) {\n return this.#group.send(encodedContent);\n }\n\n messages(options?: SafeListMessagesOptions) {\n return this.#group.find_messages(\n options ? fromSafeListMessagesOptions(options) : undefined,\n );\n }\n\n get consentState() {\n return this.#group.consent_state();\n }\n\n updateConsentState(state: WasmConsentState) {\n this.#group.update_consent_state(state);\n }\n}\n","import type { WasmConversations, WasmGroup } from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeCreateGroupOptions,\n fromSafeListConversationsOptions,\n toSafeMessage,\n type SafeCreateGroupOptions,\n type SafeListConversationsOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\nimport { WorkerConversation } from \"@/WorkerConversation\";\n\nexport class WorkerConversations {\n #client: WorkerClient;\n\n #conversations: WasmConversations;\n\n constructor(client: WorkerClient, conversations: WasmConversations) {\n this.#client = client;\n this.#conversations = conversations;\n }\n\n async sync() {\n return this.#conversations.sync();\n }\n\n getConversationById(id: string) {\n try {\n const group = this.#conversations.find_group_by_id(id);\n // findGroupById will throw if group is not found\n return new WorkerConversation(this.#client, group);\n } catch {\n return undefined;\n }\n }\n\n getMessageById(id: string) {\n try {\n // findMessageById will throw if message is not found\n const message = this.#conversations.find_message_by_id(id);\n return toSafeMessage(message);\n } catch {\n return undefined;\n }\n }\n\n async list(options?: SafeListConversationsOptions) {\n const groups = (await this.#conversations.list(\n options ? fromSafeListConversationsOptions(options) : undefined,\n )) as WasmGroup[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const group = await this.#conversations.create_group(\n accountAddresses,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n}\n","import {\n type WasmClient,\n type WasmConsentEntityType,\n type WasmSignatureRequestType,\n} from \"@xmtp/wasm-bindings\";\nimport type { ClientOptions } from \"@/types\";\nimport { fromSafeConsent, type SafeConsent } from \"@/utils/conversions\";\nimport { createClient } from \"@/utils/createClient\";\nimport { WorkerConversations } from \"@/WorkerConversations\";\n\nexport class WorkerClient {\n #client: WasmClient;\n\n #conversations: WorkerConversations;\n\n #accountAddress: string;\n\n constructor(client: WasmClient) {\n this.#client = client;\n this.#accountAddress = client.accountAddress;\n this.#conversations = new WorkerConversations(this, client.conversations());\n }\n\n static async create(\n accountAddress: string,\n options?: Omit<ClientOptions, \"codecs\">,\n ) {\n const client = await createClient(accountAddress, options);\n return new WorkerClient(client);\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n get inboxId() {\n return this.#client.inboxId;\n }\n\n get installationId() {\n return this.#client.installationId;\n }\n\n get isRegistered() {\n return this.#client.isRegistered;\n }\n\n async getCreateInboxSignatureText() {\n try {\n return await this.#client.createInboxSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async getAddWalletSignatureText(accountAddress: string) {\n try {\n return await this.#client.addWalletSignatureText(\n this.#accountAddress,\n accountAddress,\n );\n } catch {\n return undefined;\n }\n }\n\n async getRevokeWalletSignatureText(accountAddress: string) {\n try {\n return await this.#client.revokeWalletSignatureText(accountAddress);\n } catch {\n return undefined;\n }\n }\n\n async getRevokeInstallationsSignatureText() {\n try {\n return await this.#client.revokeInstallationsSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async addSignature(type: WasmSignatureRequestType, bytes: Uint8Array) {\n return this.#client.addSignature(type, bytes);\n }\n\n async applySignaturesRequests() {\n return this.#client.applySignatureRequests();\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.#client.canMessage(accountAddresses) as Promise<\n Map<string, boolean>\n >;\n }\n\n async registerIdentity() {\n return this.#client.registerIdentity();\n }\n\n async findInboxIdByAddress(address: string) {\n return this.#client.findInboxIdByAddress(address);\n }\n\n async inboxState(refreshFromNetwork: boolean) {\n return this.#client.inboxState(refreshFromNetwork);\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.#client.getLatestInboxState(inboxId);\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.#client.setConsentStates(records.map(fromSafeConsent));\n }\n\n async getConsentState(entityType: WasmConsentEntityType, entity: string) {\n return this.#client.getConsentState(entityType, entity);\n }\n\n get conversations() {\n return this.#conversations;\n }\n}\n","import init, {\n createClient as createWasmClient,\n generateInboxId,\n getInboxIdForAddress,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls } from \"@/constants\";\nimport type { ClientOptions } from \"@/types\";\n\nexport const createClient = async (\n accountAddress: string,\n options?: Omit<ClientOptions, \"codecs\">,\n) => {\n // initialize WASM module\n await init();\n\n const host = options?.apiUrl ?? ApiUrls[options?.env ?? \"dev\"];\n const dbPath = `xmtp-${options?.env ?? \"dev\"}-${accountAddress}.db3`;\n\n const inboxId =\n (await getInboxIdForAddress(host, accountAddress)) ||\n generateInboxId(accountAddress);\n\n return createWasmClient(\n host,\n inboxId,\n accountAddress,\n dbPath,\n options?.encryptionKey,\n );\n};\n","import type {\n ClientEventsActions,\n ClientEventsClientMessageData,\n ClientEventsErrorData,\n ClientEventsWorkerPostMessageData,\n} from \"@/types\";\nimport {\n fromEncodedContent,\n fromSafeEncodedContent,\n toSafeConversation,\n toSafeGroupMember,\n toSafeInboxState,\n toSafeMessage,\n} from \"@/utils/conversions\";\nimport { WorkerClient } from \"@/WorkerClient\";\n\nlet client: WorkerClient;\nlet enableLogging = false;\n\n/**\n * Type-safe postMessage\n */\nconst postMessage = <A extends ClientEventsActions>(\n data: ClientEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for errors\n */\nconst postMessageError = (data: ClientEventsErrorData) => {\n self.postMessage(data);\n};\n\nself.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {\n const { action, id, data } = event.data;\n\n if (enableLogging) {\n console.log(\"client worker received event data\", event.data);\n }\n\n // a client is required for all actions except init\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (action !== \"init\" && !client) {\n postMessageError({\n id,\n action,\n error: \"Client not initialized\",\n });\n return;\n }\n\n try {\n switch (action) {\n /**\n * Client actions\n */\n case \"init\":\n client = await WorkerClient.create(data.address, data.options);\n enableLogging = data.options?.enableLogging ?? false;\n postMessage({\n id,\n action,\n result: {\n inboxId: client.inboxId,\n installationId: client.installationId,\n },\n });\n break;\n case \"getCreateInboxSignatureText\": {\n const result = await client.getCreateInboxSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"getAddWalletSignatureText\": {\n const result = await client.getAddWalletSignatureText(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"getRevokeWalletSignatureText\": {\n const result = await client.getRevokeWalletSignatureText(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addSignature\":\n await client.addSignature(data.type, data.bytes);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"applySignaturesRequests\":\n await client.applySignaturesRequests();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"registerIdentity\":\n await client.registerIdentity();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"isRegistered\": {\n const result = client.isRegistered;\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"canMessage\": {\n const result = await client.canMessage(data.accountAddresses);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"inboxState\": {\n const result = await client.inboxState(data.refreshFromNetwork);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"getLatestInboxState\": {\n const result = await client.getLatestInboxState(data.inboxId);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"setConsentStates\": {\n await client.setConsentStates(data.records);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConsentState\": {\n const result = await client.getConsentState(\n data.entityType,\n data.entity,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"findInboxIdByAddress\": {\n const result = await client.findInboxIdByAddress(data.address);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n /**\n * Conversations actions\n */\n case \"getConversations\": {\n const conversations = await client.conversations.list(data.options);\n postMessage({\n id,\n action,\n result: conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n });\n break;\n }\n case \"newGroup\": {\n const conversation = await client.conversations.newGroup(\n data.accountAddresses,\n data.options,\n );\n postMessage({\n id,\n action,\n result: toSafeConversation(conversation),\n });\n break;\n }\n case \"syncConversations\": {\n await client.conversations.sync();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConversationById\": {\n const conversation = client.conversations.getConversationById(data.id);\n postMessage({\n id,\n action,\n result: conversation ? toSafeConversation(conversation) : undefined,\n });\n break;\n }\n case \"getMessageById\": {\n const message = client.conversations.getMessageById(data.id);\n postMessage({\n id,\n action,\n result: message,\n });\n break;\n }\n /**\n * Group actions\n */\n case \"syncGroup\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.sync();\n postMessage({\n id,\n action,\n result: toSafeConversation(group),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupName\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateName(data.name);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupDescription\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateDescription(data.description);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupImageUrlSquare\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateImageUrl(data.imageUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPinnedFrameUrl\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePinnedFrameUrl(data.pinnedFrameUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.send(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendOptimisticGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.sendOptimistic(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"publishGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.publishMessages();\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const messages = group.messages(data.options);\n postMessage({\n id,\n action,\n result: messages.map((message) => toSafeMessage(message)),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const members = await group.members();\n postMessage({\n id,\n action,\n result: members.map((member) => toSafeGroupMember(member)),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.admins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupSuperAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.superAdmins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.consentState,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n group.updateConsentState(data.state);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n }\n } catch (e) {\n postMessageError({\n id,\n action,\n error: (e as Error).message,\n });\n }\n};\n"],"names":["fromEncodedContent","content","WasmEncodedContent","contentTypeId","type","WasmContentTypeId","authorityId","typeId","versionMajor","versionMinor","Map","Object","entries","parameters","fallback","compression","toSafeEncodedContent","fromSafeEncodedContent","ContentTypeId","toSafeMessage","message","authority_id","type_id","version_major","version_minor","fromEntries","convoId","convo_id","deliveryStatus","delivery_status","id","kind","senderInboxId","sender_inbox_id","sentAtNs","sent_at_ns","toSafeConversation","conversation","name","imageUrl","description","pinnedFrameUrl","permissions","policyType","policySet","addAdminPolicy","add_admin_policy","addMemberPolicy","add_member_policy","removeAdminPolicy","remove_admin_policy","removeMemberPolicy","remove_member_policy","updateGroupDescriptionPolicy","update_group_description_policy","updateGroupImageUrlSquarePolicy","update_group_image_url_square_policy","updateGroupNamePolicy","update_group_name_policy","updateGroupPinnedFrameUrlPolicy","update_group_pinned_frame_url_policy","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","clientTimestampNs","client_timestamp_ns","toSafeInboxState","inboxState","accountAddresses","account_addresses","inboxId","inbox_id","installations","map","recoveryAddress","recovery_address","fromSafeConsent","consent","WasmConsent","entityType","state","entity","ApiUrls","local","dev","production","WorkerConversation","client","group","constructor","this","group_name","updateName","update_group_name","group_image_url_square","updateImageUrl","update_group_image_url_square","group_description","updateDescription","update_group_description","group_pinned_frame_url","updatePinnedFrameUrl","update_group_pinned_frame_url","is_active","added_by_inbox_id","created_at_ns","group_metadata","creatorInboxId","creator_inbox_id","conversationType","conversation_type","members","list_members","admin_list","super_admin_list","group_permissions","policy_type","policy_set","isAdmin","is_admin","isSuperAdmin","is_super_admin","sync","addMembers","add_members","addMembersByInboxId","inboxIds","add_members_by_inbox_id","removeMembers","remove_members","removeMembersByInboxId","remove_members_by_inbox_id","addAdmin","add_admin","removeAdmin","remove_admin","addSuperAdmin","add_super_admin","removeSuperAdmin","remove_super_admin","publishMessages","publish_messages","sendOptimistic","encodedContent","send_optimistic","send","messages","options","find_messages","WasmListMessagesOptions","sent_before_ns","sent_after_ns","limit","fromSafeListMessagesOptions","undefined","consentState","consent_state","updateConsentState","update_consent_state","WorkerConversations","conversations","getConversationById","find_group_by_id","getMessageById","find_message_by_id","list","groups","WasmListConversationsOptions","created_after_ns","created_before_ns","fromSafeListConversationsOptions","newGroup","create_group","WasmCreateGroupOptions","imageUrlSquare","fromSafeCreateGroupOptions","WorkerClient","accountAddress","create","async","init","host","apiUrl","env","dbPath","getInboxIdForAddress","generateInboxId","createWasmClient","encryptionKey","createClient","installationId","isRegistered","getCreateInboxSignatureText","createInboxSignatureText","getAddWalletSignatureText","addWalletSignatureText","getRevokeWalletSignatureText","revokeWalletSignatureText","getRevokeInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","bytes","applySignaturesRequests","applySignatureRequests","canMessage","registerIdentity","findInboxIdByAddress","address","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","enableLogging","postMessage","data","self","postMessageError","onmessage","event","action","console","log","result","error","member","installationIds","installation_ids","permissionLevel","permission_level","toSafeGroupMember","e"],"mappings":"8TAyBO,MAyDMA,EACXC,IAEA,WAAIC,GAjDJC,EAkDoBF,EAAQG,KAhD5B,IAAIC,EACFF,EAAcG,YACdH,EAAcI,OACdJ,EAAcK,aACdL,EAAcM,eA6Cd,IAAIC,IAAIC,OAAOC,QAAQX,EAAQY,aAC/BZ,EAAQa,SACRb,EAAQc,YACRd,EAAQA,SAvDqB,IAC/BE,CAuDC,EAUUa,EACXf,IACwB,OACxBG,MAnDAD,EAmD0BF,EAAQG,KAlDX,CACvBE,YAAaH,EAAcG,YAC3BC,OAAQJ,EAAcI,OACtBC,aAAcL,EAAcK,aAC5BC,aAAcN,EAAcM,eA+C5BI,WAAYZ,EAAQY,WACpBC,SAAUb,EAAQa,SAClBC,YAAad,EAAQc,YACrBd,QAASA,EAAQA,SAxDgB,IACjCE,CAwDA,EAEWc,EACXhB,IACoB,OACpBG,MApDAD,EAoD4BF,EAAQG,KAlDpC,IAAIc,EAAc,CAChBZ,YAAaH,EAAcG,YAC3BC,OAAQJ,EAAcI,OACtBC,aAAcL,EAAcK,aAC5BC,aAAcN,EAAcM,gBA+C9BI,WAAYZ,EAAQY,WACpBC,SAAUb,EAAQa,SAClBC,YAAad,EAAQc,YACrBd,QAASA,EAAQA,SAzDkB,IACnCE,CAyDA,EAYWgB,EAAiBC,IAAuC,OACnEnB,QAASe,GA5DTf,EA4D+CmB,EAAQnB,QA3DnC,CAEpBG,MAjDAD,EAi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AK,2BAA4B,CAC/B,MAAMxI,EAAQD,EAAOyE,cAAcC,oBAAoBsD,EAAK9L,IACxD+D,SACIA,EAAMqC,oBAAoB0F,EAAKzF,UACrCwF,EAAY,CACV7L,KACAmM,SACAG,YAAQrE,KAGV+D,EAAiB,CACfhM,KACAmM,SACAI,MAAO,oBAGX,KACD,CACD,IAAK,8BAA+B,CAClC,MAAMxI,EAAQD,EAAOyE,cAAcC,oBAAoBsD,EAAK9L,IACxD+D,SACIA,EAAM0C,uBAAuBqF,EAAKzF,UACxCwF,EAAY,CACV7L,KACAmM,SACAG,YAAQrE,KAGV+D,EAAiB,CACfhM,KACAmM,SACAI,MAAO,oBAGX,KACD,CACD,IAAK,eAAgB,CACnB,MAAMxI,EAAQD,EAAOyE,cAAcC,oBAAoBsD,EAAK9L,IAC5D,GAAI+D,EAAO,CACT,MAAMuI,EAASvI,EAAM8B,QAAQiG,EAAKjJ,SAClCgJ,EAAY,CACV7L,KACAmM,SACAG,UAEH,MACCN,EAAiB,CACfhM,KACAmM,SACAI,MAAO,oBAGX,KACD,CACD,IAAK,oBAAqB,CACxB,MAAMxI,EAAQD,EAAOyE,cAAcC,oBAAoBsD,EAAK9L,IAC5D,GAAI+D,EAAO,CACT,MAAMuI,EAASvI,EAAMgC,aAAa+F,EAAKjJ,SACvCgJ,EAAY,CACV7L,KACAmM,SACAG,UAEH,MACCN,EAAiB,CACfhM,KACAmM,SACAI,MAAO,oBAGX,KACD,EAEJ,CAAC,MAAOO,GACPd,EAAiB,CACfhM,KACAmM,SACAI,MAAQO,EAAYxN,SAEvB,MAloBC0M,EAAiB,CACfhM,KACAmM,SACAI,MAAO,0BA+nBV"}
1
+ {"version":3,"file":"client.js","sources":["../../src/utils/conversions.ts","../../src/constants.ts","../../src/WorkerConversation.ts","../../src/WorkerConversations.ts","../../src/WorkerClient.ts","../../src/utils/createClient.ts","../../src/workers/client.ts"],"sourcesContent":["import {\n ContentTypeId,\n type EncodedContent,\n} from \"@xmtp/content-type-primitives\";\nimport {\n Consent,\n CreateGroupOptions,\n GroupMember,\n ListConversationsOptions,\n ListMessagesOptions,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ConversationType,\n type DeliveryStatus,\n type GroupMembershipState,\n type GroupMessageKind,\n type GroupPermissionsOptions,\n type InboxState,\n type Installation,\n type Message,\n type PermissionLevel,\n type PermissionPolicy,\n type SortDirection,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: DeliveryStatus;\n id: string;\n kind: GroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: Message): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convoId,\n deliveryStatus: message.deliveryStatus,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.senderInboxId,\n sentAtNs: message.sentAtNs,\n});\n\nexport type SafeListMessagesOptions = {\n deliveryStatus?: DeliveryStatus;\n direction?: SortDirection;\n limit?: bigint;\n sentAfterNs?: bigint;\n sentBeforeNs?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: ListMessagesOptions,\n): SafeListMessagesOptions => ({\n deliveryStatus: options.deliveryStatus,\n direction: options.direction,\n limit: options.limit,\n sentAfterNs: options.sentAfterNs,\n sentBeforeNs: options.sentBeforeNs,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): ListMessagesOptions =>\n new ListMessagesOptions(\n options.sentBeforeNs,\n options.sentAfterNs,\n options.limit,\n options.deliveryStatus,\n options.direction,\n );\n\nexport type SafeListConversationsOptions = {\n allowedStates?: GroupMembershipState[];\n conversationType?: ConversationType;\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n allowedStates: options.allowedStates,\n conversationType: options.conversationType,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.allowedStates,\n options.conversationType,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.limit,\n );\n\nexport type SafeCreateGroupOptions = {\n permissions?: GroupPermissionsOptions;\n name?: string;\n imageUrlSquare?: string;\n description?: string;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n permissions: options.permissions,\n name: options.groupName,\n imageUrlSquare: options.groupImageUrlSquare,\n description: options.groupDescription,\n pinnedFrameUrl: options.groupPinnedFrameUrl,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): CreateGroupOptions =>\n new CreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: GroupPermissionsOptions;\n policySet: {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n };\n };\n isActive: boolean;\n addedByInboxId: string;\n metadata: {\n creatorInboxId: string;\n conversationType: string;\n };\n admins: string[];\n superAdmins: string[];\n createdAtNs: bigint;\n};\n\nexport const toSafeConversation = (\n conversation: WorkerConversation,\n): SafeConversation => ({\n id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,\n addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,\n removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,\n removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: conversation.metadata,\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\n});\n\nexport type SafeInstallation = {\n id: string;\n clientTimestampNs?: bigint;\n};\n\nexport const toSafeInstallation = (\n installation: Installation,\n): SafeInstallation => ({\n id: installation.id,\n clientTimestampNs: installation.clientTimestampNs,\n});\n\nexport type SafeInboxState = {\n accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountAddresses: inboxState.accountAddresses,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recoveryAddress,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: ConsentEntityType;\n state: ConsentState;\n};\n\nexport const toSafeConsent = (consent: Consent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entityType,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): Consent =>\n new Consent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountAddresses: member.accountAddresses,\n consentState: member.consentState,\n inboxId: member.inboxId,\n installationIds: member.installationIds,\n permissionLevel: member.permissionLevel,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>\n new GroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n","import type {\n ConsentState,\n Conversation,\n EncodedContent,\n GroupMember,\n} from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeListMessagesOptions,\n toSafeGroupMember,\n type SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\n\nexport class WorkerConversation {\n // eslint-disable-next-line no-unused-private-class-members\n #client: WorkerClient;\n\n #group: Conversation;\n\n constructor(client: WorkerClient, group: Conversation) {\n this.#client = client;\n this.#group = group;\n }\n\n get id() {\n return this.#group.id();\n }\n\n get name() {\n return this.#group.groupName();\n }\n\n async updateName(name: string) {\n return this.#group.updateGroupName(name);\n }\n\n get imageUrl() {\n return this.#group.groupImageUrlSquare();\n }\n\n async updateImageUrl(imageUrl: string) {\n return this.#group.updateGroupImageUrlSquare(imageUrl);\n }\n\n get description() {\n return this.#group.groupDescription();\n }\n\n async updateDescription(description: string) {\n return this.#group.updateGroupDescription(description);\n }\n\n get pinnedFrameUrl() {\n return this.#group.groupPinnedFrameUrl();\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n return this.#group.updateGroupPinnedFrameUrl(pinnedFrameUrl);\n }\n\n get isActive() {\n return this.#group.isActive();\n }\n\n get addedByInboxId() {\n return this.#group.addedByInboxId();\n }\n\n get createdAtNs() {\n return this.#group.createdAtNs();\n }\n\n get metadata() {\n const metadata = this.#group.groupMetadata();\n return {\n creatorInboxId: metadata.creatorInboxId(),\n conversationType: metadata.conversationType(),\n };\n }\n\n async members() {\n const members = (await this.#group.listMembers()) as GroupMember[];\n return members.map((member) => toSafeGroupMember(member));\n }\n\n get admins() {\n return this.#group.adminList();\n }\n\n get superAdmins() {\n return this.#group.superAdminList();\n }\n\n get permissions() {\n const permissions = this.#group.groupPermissions();\n return {\n policyType: permissions.policyType(),\n policySet: permissions.policySet(),\n };\n }\n\n isAdmin(inboxId: string) {\n return this.#group.isAdmin(inboxId);\n }\n\n isSuperAdmin(inboxId: string) {\n return this.#group.isSuperAdmin(inboxId);\n }\n\n async sync() {\n return this.#group.sync();\n }\n\n async addMembers(accountAddresses: string[]) {\n return this.#group.addMembers(accountAddresses);\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#group.addMembersByInboxId(inboxIds);\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#group.removeMembers(accountAddresses);\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#group.removeMembersByInboxId(inboxIds);\n }\n\n async addAdmin(inboxId: string) {\n return this.#group.addAdmin(inboxId);\n }\n\n async removeAdmin(inboxId: string) {\n return this.#group.removeAdmin(inboxId);\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#group.addSuperAdmin(inboxId);\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#group.removeSuperAdmin(inboxId);\n }\n\n async publishMessages() {\n return this.#group.publishMessages();\n }\n\n sendOptimistic(encodedContent: EncodedContent) {\n return this.#group.sendOptimistic(encodedContent);\n }\n\n async send(encodedContent: EncodedContent) {\n return this.#group.send(encodedContent);\n }\n\n messages(options?: SafeListMessagesOptions) {\n return this.#group.findMessages(\n options ? fromSafeListMessagesOptions(options) : undefined,\n );\n }\n\n get consentState() {\n return this.#group.consentState();\n }\n\n updateConsentState(state: ConsentState) {\n this.#group.updateConsentState(state);\n }\n\n dmPeerInboxId() {\n return this.#group.dmPeerInboxId();\n }\n}\n","import type { Conversation, Conversations } from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeCreateGroupOptions,\n fromSafeListConversationsOptions,\n toSafeMessage,\n type SafeCreateGroupOptions,\n type SafeListConversationsOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\nimport { WorkerConversation } from \"@/WorkerConversation\";\n\nexport class WorkerConversations {\n #client: WorkerClient;\n\n #conversations: Conversations;\n\n constructor(client: WorkerClient, conversations: Conversations) {\n this.#client = client;\n this.#conversations = conversations;\n }\n\n async sync() {\n return this.#conversations.sync();\n }\n\n getConversationById(id: string) {\n try {\n const group = this.#conversations.findGroupById(id);\n // findGroupById will throw if group is not found\n return new WorkerConversation(this.#client, group);\n } catch {\n return undefined;\n }\n }\n\n getMessageById(id: string) {\n try {\n // findMessageById will throw if message is not found\n const message = this.#conversations.findMessageById(id);\n return toSafeMessage(message);\n } catch {\n return undefined;\n }\n }\n\n getDmByInboxId(inboxId: string) {\n try {\n const group = this.#conversations.findDmByTargetInboxId(inboxId);\n return new WorkerConversation(this.#client, group);\n } catch {\n return undefined;\n }\n }\n\n async list(options?: SafeListConversationsOptions) {\n const groups = (await this.#conversations.list(\n options ? fromSafeListConversationsOptions(options) : undefined,\n )) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = (await this.#conversations.listGroups(\n options ? fromSafeListConversationsOptions(options) : undefined,\n )) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async listDms(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = (await this.#conversations.listDms(\n options ? fromSafeListConversationsOptions(options) : undefined,\n )) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const group = await this.#conversations.createGroup(\n accountAddresses,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDm(accountAddress: string) {\n const group = await this.#conversations.createDm(accountAddress);\n return new WorkerConversation(this.#client, group);\n }\n}\n","import {\n type Client,\n type ConsentEntityType,\n type SignatureRequestType,\n} from \"@xmtp/wasm-bindings\";\nimport type { ClientOptions } from \"@/types\";\nimport { fromSafeConsent, type SafeConsent } from \"@/utils/conversions\";\nimport { createClient } from \"@/utils/createClient\";\nimport { WorkerConversations } from \"@/WorkerConversations\";\n\nexport class WorkerClient {\n #client: Client;\n\n #conversations: WorkerConversations;\n\n #accountAddress: string;\n\n constructor(client: Client) {\n this.#client = client;\n this.#accountAddress = client.accountAddress;\n this.#conversations = new WorkerConversations(this, client.conversations());\n }\n\n static async create(\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n ) {\n const client = await createClient(accountAddress, encryptionKey, options);\n return new WorkerClient(client);\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n get inboxId() {\n return this.#client.inboxId;\n }\n\n get installationId() {\n return this.#client.installationId;\n }\n\n get isRegistered() {\n return this.#client.isRegistered;\n }\n\n async getCreateInboxSignatureText() {\n try {\n return await this.#client.createInboxSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async getAddWalletSignatureText(accountAddress: string) {\n try {\n return await this.#client.addWalletSignatureText(\n this.#accountAddress,\n accountAddress,\n );\n } catch {\n return undefined;\n }\n }\n\n async getRevokeWalletSignatureText(accountAddress: string) {\n try {\n return await this.#client.revokeWalletSignatureText(accountAddress);\n } catch {\n return undefined;\n }\n }\n\n async getRevokeInstallationsSignatureText() {\n try {\n return await this.#client.revokeInstallationsSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async addSignature(type: SignatureRequestType, bytes: Uint8Array) {\n return this.#client.addSignature(type, bytes);\n }\n\n async addScwSignature(\n type: SignatureRequestType,\n bytes: Uint8Array,\n chainId: bigint,\n blockNumber?: bigint,\n ) {\n return this.#client.addScwSignature(type, bytes, chainId, blockNumber);\n }\n\n async applySignatures() {\n return this.#client.applySignatureRequests();\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.#client.canMessage(accountAddresses) as Promise<\n Map<string, boolean>\n >;\n }\n\n async registerIdentity() {\n return this.#client.registerIdentity();\n }\n\n async findInboxIdByAddress(address: string) {\n return this.#client.findInboxIdByAddress(address);\n }\n\n async inboxState(refreshFromNetwork: boolean) {\n return this.#client.inboxState(refreshFromNetwork);\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.#client.getLatestInboxState(inboxId);\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.#client.setConsentStates(records.map(fromSafeConsent));\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.#client.getConsentState(entityType, entity);\n }\n\n get conversations() {\n return this.#conversations;\n }\n}\n","import init, {\n createClient as createWasmClient,\n generateInboxId,\n getInboxIdForAddress,\n LogOptions,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls } from \"@/constants\";\nimport type { ClientOptions } from \"@/types\";\n\nexport const createClient = async (\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n) => {\n // initialize WASM module\n await init();\n\n const host = options?.apiUrl ?? ApiUrls[options?.env ?? \"dev\"];\n // TODO: add db path validation\n // - must end with .db3\n // - must not contain invalid characters\n // - must not start with a dot\n const dbPath =\n options?.dbPath ?? `xmtp-${options?.env ?? \"dev\"}-${accountAddress}.db3`;\n\n const inboxId =\n (await getInboxIdForAddress(host, accountAddress)) ||\n generateInboxId(accountAddress);\n\n const isLogging =\n options &&\n (options.loggingLevel !== undefined ||\n options.structuredLogging ||\n options.performanceLogging);\n\n return createWasmClient(\n host,\n inboxId,\n accountAddress,\n dbPath,\n encryptionKey,\n undefined,\n isLogging\n ? new LogOptions(\n options.structuredLogging ?? false,\n options.performanceLogging ?? false,\n options.loggingLevel,\n )\n : undefined,\n );\n};\n","import type {\n ClientEventsActions,\n ClientEventsClientMessageData,\n ClientEventsErrorData,\n ClientEventsWorkerPostMessageData,\n} from \"@/types\";\nimport {\n fromEncodedContent,\n fromSafeEncodedContent,\n toSafeConversation,\n toSafeInboxState,\n toSafeMessage,\n} from \"@/utils/conversions\";\nimport { WorkerClient } from \"@/WorkerClient\";\n\nlet client: WorkerClient;\nlet enableLogging = false;\n\n/**\n * Type-safe postMessage\n */\nconst postMessage = <A extends ClientEventsActions>(\n data: ClientEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for errors\n */\nconst postMessageError = (data: ClientEventsErrorData) => {\n self.postMessage(data);\n};\n\nself.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {\n const { action, id, data } = event.data;\n\n if (enableLogging) {\n console.log(\"client worker received event data\", event.data);\n }\n\n // a client is required for all actions except init\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (action !== \"init\" && !client) {\n postMessageError({\n id,\n action,\n error: \"Client not initialized\",\n });\n return;\n }\n\n try {\n switch (action) {\n /**\n * Client actions\n */\n case \"init\":\n client = await WorkerClient.create(\n data.address,\n data.encryptionKey,\n data.options,\n );\n enableLogging =\n data.options?.loggingLevel !== undefined &&\n data.options.loggingLevel !== \"off\";\n postMessage({\n id,\n action,\n result: {\n inboxId: client.inboxId,\n installationId: client.installationId,\n },\n });\n break;\n case \"getCreateInboxSignatureText\": {\n const result = await client.getCreateInboxSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"getAddWalletSignatureText\": {\n const result = await client.getAddWalletSignatureText(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"getRevokeWalletSignatureText\": {\n const result = await client.getRevokeWalletSignatureText(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"getRevokeInstallationsSignatureText\": {\n const result = await client.getRevokeInstallationsSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addSignature\":\n await client.addSignature(data.type, data.bytes);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"addScwSignature\":\n await client.addScwSignature(\n data.type,\n data.bytes,\n data.chainId,\n data.blockNumber,\n );\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"applySignatures\":\n await client.applySignatures();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"registerIdentity\":\n await client.registerIdentity();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"isRegistered\": {\n const result = client.isRegistered;\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"canMessage\": {\n const result = await client.canMessage(data.accountAddresses);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"inboxState\": {\n const result = await client.inboxState(data.refreshFromNetwork);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"getLatestInboxState\": {\n const result = await client.getLatestInboxState(data.inboxId);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"setConsentStates\": {\n await client.setConsentStates(data.records);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConsentState\": {\n const result = await client.getConsentState(\n data.entityType,\n data.entity,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"findInboxIdByAddress\": {\n const result = await client.findInboxIdByAddress(data.address);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n /**\n * Conversations actions\n */\n case \"getConversations\": {\n const conversations = await client.conversations.list(data.options);\n postMessage({\n id,\n action,\n result: conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n });\n break;\n }\n case \"getGroups\": {\n const conversations = await client.conversations.listGroups(\n data.options,\n );\n postMessage({\n id,\n action,\n result: conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n });\n break;\n }\n case \"getDms\": {\n const conversations = await client.conversations.listDms(data.options);\n postMessage({\n id,\n action,\n result: conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n });\n break;\n }\n case \"newGroup\": {\n const conversation = await client.conversations.newGroup(\n data.accountAddresses,\n data.options,\n );\n postMessage({\n id,\n action,\n result: toSafeConversation(conversation),\n });\n break;\n }\n case \"newDm\": {\n const conversation = await client.conversations.newDm(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result: toSafeConversation(conversation),\n });\n break;\n }\n case \"syncConversations\": {\n await client.conversations.sync();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConversationById\": {\n const conversation = client.conversations.getConversationById(data.id);\n postMessage({\n id,\n action,\n result: conversation ? toSafeConversation(conversation) : undefined,\n });\n break;\n }\n case \"getMessageById\": {\n const message = client.conversations.getMessageById(data.id);\n postMessage({\n id,\n action,\n result: message,\n });\n break;\n }\n case \"getDmByInboxId\": {\n const conversation = client.conversations.getDmByInboxId(data.inboxId);\n postMessage({\n id,\n action,\n result: conversation ? toSafeConversation(conversation) : undefined,\n });\n break;\n }\n /**\n * Group actions\n */\n case \"syncGroup\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.sync();\n postMessage({\n id,\n action,\n result: toSafeConversation(group),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupName\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateName(data.name);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupDescription\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateDescription(data.description);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupImageUrlSquare\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateImageUrl(data.imageUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPinnedFrameUrl\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePinnedFrameUrl(data.pinnedFrameUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.send(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendOptimisticGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.sendOptimistic(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"publishGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.publishMessages();\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const messages = group.messages(data.options);\n postMessage({\n id,\n action,\n result: messages.map((message) => toSafeMessage(message)),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.members();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.admins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupSuperAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.superAdmins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.consentState,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n group.updateConsentState(data.state);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getDmPeerInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.dmPeerInboxId();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n }\n } catch (e) {\n postMessageError({\n id,\n action,\n error: (e as Error).message,\n });\n }\n};\n"],"names":["fromEncodedContent","content","WasmEncodedContent","contentTypeId","type","WasmContentTypeId","authorityId","typeId","versionMajor","versionMinor","Map","Object","entries","parameters","fallback","compression","toSafeEncodedContent","fromSafeEncodedContent","ContentTypeId","toSafeMessage","message","fromEntries","convoId","deliveryStatus","id","kind","senderInboxId","sentAtNs","fromSafeListConversationsOptions","options","ListConversationsOptions","allowedStates","conversationType","createdAfterNs","createdBeforeNs","limit","toSafeConversation","conversation","name","imageUrl","description","pinnedFrameUrl","permissions","policyType","policySet","addAdminPolicy","addMemberPolicy","removeAdminPolicy","removeMemberPolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateGroupNamePolicy","updateGroupPinnedFrameUrlPolicy","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","clientTimestampNs","toSafeInboxState","inboxState","accountAddresses","inboxId","installations","map","recoveryAddress","fromSafeConsent","consent","Consent","entityType","state","entity","ApiUrls","local","dev","production","WorkerConversation","client","group","constructor","this","groupName","updateName","updateGroupName","groupImageUrlSquare","updateImageUrl","updateGroupImageUrlSquare","groupDescription","updateDescription","updateGroupDescription","groupPinnedFrameUrl","updatePinnedFrameUrl","updateGroupPinnedFrameUrl","groupMetadata","creatorInboxId","members","listMembers","member","consentState","installationIds","permissionLevel","toSafeGroupMember","adminList","superAdminList","groupPermissions","isAdmin","isSuperAdmin","sync","addMembers","addMembersByInboxId","inboxIds","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","encodedContent","send","messages","findMessages","ListMessagesOptions","sentBeforeNs","sentAfterNs","direction","fromSafeListMessagesOptions","undefined","updateConsentState","dmPeerInboxId","WorkerConversations","conversations","getConversationById","findGroupById","getMessageById","findMessageById","getDmByInboxId","findDmByTargetInboxId","list","listGroups","listDms","newGroup","createGroup","CreateGroupOptions","imageUrlSquare","fromSafeCreateGroupOptions","newDm","accountAddress","createDm","WorkerClient","create","encryptionKey","async","init","host","apiUrl","env","dbPath","getInboxIdForAddress","generateInboxId","isLogging","loggingLevel","structuredLogging","performanceLogging","createWasmClient","LogOptions","createClient","installationId","isRegistered","getCreateInboxSignatureText","createInboxSignatureText","getAddWalletSignatureText","addWalletSignatureText","getRevokeWalletSignatureText","revokeWalletSignatureText","getRevokeInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","bytes","addScwSignature","chainId","blockNumber","applySignatures","applySignatureRequests","canMessage","registerIdentity","findInboxIdByAddress","address","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","enableLogging","postMessage","data","self","postMessageError","onmessage","event","action","console","log","result","error","e"],"mappings":"sTA4BO,MAyDMA,EACXC,IAEA,WAAIC,GAjDJC,EAkDoBF,EAAQG,KAhD5B,IAAIC,EACFF,EAAcG,YACdH,EAAcI,OACdJ,EAAcK,aACdL,EAAcM,eA6Cd,IAAIC,IAAIC,OAAOC,QAAQX,EAAQY,aAC/BZ,EAAQa,SACRb,EAAQc,YACRd,EAAQA,SAvDqB,IAC/BE,CAuDC,EAUUa,EACXf,IACwB,OACxBG,MAnDAD,EAmD0BF,EAAQG,KAlDX,CACvBE,YAAaH,EAAcG,YAC3BC,OAAQJ,EAAcI,OACtBC,aAAcL,EAAcK,aAC5BC,aAAcN,EAAcM,eA+C5BI,WAAYZ,EAAQY,WACpBC,SAAUb,EAAQa,SAClBC,YAAad,EAAQc,YACrBd,QAASA,EAAQA,SAxDgB,IACjCE,CAwDA,EAEWc,EACXhB,IACoB,OACpBG,MApDAD,EAoD4BF,EAAQG,KAlDpC,IAAIc,EAAc,CAChBZ,YAAaH,EAAcG,YAC3BC,OAAQJ,EAAcI,OACtBC,aAAcL,EAAcK,aAC5BC,aAAcN,EAAcM,gBA+C9BI,WAAYZ,EAAQY,WACpBC,SAAUb,EAAQa,SAClBC,YAAad,EAAQc,YACrBd,QAASA,EAAQA,SAzDkB,IACnCE,CAyDA,EAYWgB,EAAiBC,IAAmC,OAC/DnB,QAASe,GA5DTf,EA4D+CmB,EAAQnB,QA3DnC,CAEp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AAO,oBAGX,KACD,CACD,IAAK,oBAAqB,CACxB,MAAM/H,EAAQD,EAAOuD,cAAcC,oBAAoB+D,EAAK/K,IAC5D,GAAIyD,EAAO,CACT,MAAM8H,EAAS9H,EAAM4B,aAAa0F,EAAKtI,SACvCqI,EAAY,CACV9K,KACAoL,SACAG,UAEH,MACCN,EAAiB,CACfjL,KACAoL,SACAI,MAAO,oBAGX,KACD,CACD,IAAK,mBAAoB,CACvB,MAAM/H,EAAQD,EAAOuD,cAAcC,oBAAoB+D,EAAK/K,IAC5D,GAAIyD,EAAO,CACT,MAAM8H,EAAS9H,EAAMoD,gBACrBiE,EAAY,CACV9K,KACAoL,SACAG,UAEH,MACCN,EAAiB,CACfjL,KACAoL,SACAI,MAAO,oBAGX,KACD,EAEJ,CAAC,MAAOC,GACPR,EAAiB,CACfjL,KACAoL,SACAI,MAAQC,EAAY7L,SAEvB,MA5tBCqL,EAAiB,CACfjL,KACAoL,SACAI,MAAO,0BAytBV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmtp/browser-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "XMTP client SDK for browsers written in TypeScript",
5
5
  "keywords": [
6
6
  "xmtp",
@@ -65,7 +65,7 @@
65
65
  "@xmtp/content-type-primitives": "^1.0.1",
66
66
  "@xmtp/content-type-text": "^1.0.0",
67
67
  "@xmtp/proto": "^3.70.0",
68
- "@xmtp/wasm-bindings": "^0.0.1",
68
+ "@xmtp/wasm-bindings": "^0.0.4",
69
69
  "uuid": "^10.0.0"
70
70
  },
71
71
  "devDependencies": {
package/src/Client.ts CHANGED
@@ -8,9 +8,9 @@ import type {
8
8
  } from "@xmtp/content-type-primitives";
9
9
  import { TextCodec } from "@xmtp/content-type-text";
10
10
  import {
11
- WasmGroupMessageKind,
12
- type WasmConsentEntityType,
13
- type WasmSignatureRequestType,
11
+ GroupMessageKind,
12
+ type ConsentEntityType,
13
+ type SignatureRequestType,
14
14
  } from "@xmtp/wasm-bindings";
15
15
  import { ClientWorkerClass } from "@/ClientWorkerClass";
16
16
  import { Conversations } from "@/Conversations";
@@ -37,13 +37,23 @@ export class Client extends ClientWorkerClass {
37
37
 
38
38
  #codecs: Map<string, ContentCodec>;
39
39
 
40
- constructor(address: string, options?: ClientOptions) {
40
+ #encryptionKey: Uint8Array;
41
+
42
+ constructor(
43
+ address: string,
44
+ encryptionKey: Uint8Array,
45
+ options?: ClientOptions,
46
+ ) {
41
47
  const worker = new Worker(new URL("./workers/client", import.meta.url), {
42
48
  type: "module",
43
49
  });
44
- super(worker, options?.enableLogging ?? false);
50
+ super(
51
+ worker,
52
+ options?.loggingLevel !== undefined && options.loggingLevel !== "off",
53
+ );
45
54
  this.address = address;
46
55
  this.options = options;
56
+ this.#encryptionKey = encryptionKey;
47
57
  this.#conversations = new Conversations(this);
48
58
  const codecs = [
49
59
  new GroupUpdatedCodec(),
@@ -58,6 +68,7 @@ export class Client extends ClientWorkerClass {
58
68
  async init() {
59
69
  const result = await this.sendMessage("init", {
60
70
  address: this.address,
71
+ encryptionKey: this.#encryptionKey,
61
72
  options: this.options,
62
73
  });
63
74
  this.#inboxId = result.inboxId;
@@ -65,8 +76,12 @@ export class Client extends ClientWorkerClass {
65
76
  this.#isReady = true;
66
77
  }
67
78
 
68
- static async create(address: string, options?: ClientOptions) {
69
- const client = new Client(address, options);
79
+ static async create(
80
+ address: string,
81
+ encryptionKey: Uint8Array,
82
+ options?: ClientOptions,
83
+ ) {
84
+ const client = new Client(address, encryptionKey, options);
70
85
  await client.init();
71
86
  return client;
72
87
  }
@@ -95,12 +110,30 @@ export class Client extends ClientWorkerClass {
95
110
  return this.sendMessage("getRevokeWalletSignatureText", { accountAddress });
96
111
  }
97
112
 
98
- async addSignature(type: WasmSignatureRequestType, bytes: Uint8Array) {
113
+ async getRevokeInstallationsSignatureText() {
114
+ return this.sendMessage("getRevokeInstallationsSignatureText", undefined);
115
+ }
116
+
117
+ async addSignature(type: SignatureRequestType, bytes: Uint8Array) {
99
118
  return this.sendMessage("addSignature", { type, bytes });
100
119
  }
101
120
 
102
- async applySignaturesRequests() {
103
- return this.sendMessage("applySignaturesRequests", undefined);
121
+ async addScwSignature(
122
+ type: SignatureRequestType,
123
+ bytes: Uint8Array,
124
+ chainId: bigint,
125
+ blockNumber?: bigint,
126
+ ) {
127
+ return this.sendMessage("addScwSignature", {
128
+ type,
129
+ bytes,
130
+ chainId,
131
+ blockNumber,
132
+ });
133
+ }
134
+
135
+ async applySignatures() {
136
+ return this.sendMessage("applySignatures", undefined);
104
137
  }
105
138
 
106
139
  async registerIdentity() {
@@ -119,8 +152,10 @@ export class Client extends ClientWorkerClass {
119
152
  return this.sendMessage("findInboxIdByAddress", { address });
120
153
  }
121
154
 
122
- async inboxState(refreshFromNetwork: boolean) {
123
- return this.sendMessage("inboxState", { refreshFromNetwork });
155
+ async inboxState(refreshFromNetwork?: boolean) {
156
+ return this.sendMessage("inboxState", {
157
+ refreshFromNetwork: refreshFromNetwork ?? false,
158
+ });
124
159
  }
125
160
 
126
161
  async getLatestInboxState(inboxId: string) {
@@ -131,7 +166,7 @@ export class Client extends ClientWorkerClass {
131
166
  return this.sendMessage("setConsentStates", { records });
132
167
  }
133
168
 
134
- async getConsentState(entityType: WasmConsentEntityType, entity: string) {
169
+ async getConsentState(entityType: ConsentEntityType, entity: string) {
135
170
  return this.sendMessage("getConsentState", { entityType, entity });
136
171
  }
137
172
 
@@ -169,7 +204,7 @@ export class Client extends ClientWorkerClass {
169
204
  // throw an error if there's an invalid group membership change message
170
205
  if (
171
206
  contentType.sameAs(ContentTypeGroupUpdated) &&
172
- message.kind !== WasmGroupMessageKind.MembershipChange
207
+ message.kind !== GroupMessageKind.MembershipChange
173
208
  ) {
174
209
  throw new Error("Error decoding group membership change");
175
210
  }
@@ -1,6 +1,6 @@
1
1
  import type { ContentTypeId } from "@xmtp/content-type-primitives";
2
2
  import { ContentTypeText } from "@xmtp/content-type-text";
3
- import type { WasmConsentState } from "@xmtp/wasm-bindings";
3
+ import type { ConsentState } from "@xmtp/wasm-bindings";
4
4
  import type { Client } from "@/Client";
5
5
  import { DecodedMessage } from "@/DecodedMessage";
6
6
  import type {
@@ -276,10 +276,16 @@ export class Conversation {
276
276
  });
277
277
  }
278
278
 
279
- async updateConsentState(state: WasmConsentState) {
279
+ async updateConsentState(state: ConsentState) {
280
280
  return this.#client.sendMessage("updateGroupConsentState", {
281
281
  id: this.#id,
282
282
  state,
283
283
  });
284
284
  }
285
+
286
+ async dmPeerInboxId() {
287
+ return this.#client.sendMessage("getDmPeerInboxId", {
288
+ id: this.#id,
289
+ });
290
+ }
285
291
  }
@@ -28,6 +28,12 @@ export class Conversations {
28
28
  });
29
29
  }
30
30
 
31
+ async getDmByInboxId(inboxId: string) {
32
+ return this.#client.sendMessage("getDmByInboxId", {
33
+ inboxId,
34
+ });
35
+ }
36
+
31
37
  async list(options?: SafeListConversationsOptions) {
32
38
  const conversations = await this.#client.sendMessage("getConversations", {
33
39
  options,
@@ -39,6 +45,22 @@ export class Conversations {
39
45
  );
40
46
  }
41
47
 
48
+ async listGroups(
49
+ options?: Omit<SafeListConversationsOptions, "conversation_type">,
50
+ ) {
51
+ return this.#client.sendMessage("getGroups", {
52
+ options,
53
+ });
54
+ }
55
+
56
+ async listDms(
57
+ options?: Omit<SafeListConversationsOptions, "conversation_type">,
58
+ ) {
59
+ return this.#client.sendMessage("getDms", {
60
+ options,
61
+ });
62
+ }
63
+
42
64
  async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {
43
65
  const conversation = await this.#client.sendMessage("newGroup", {
44
66
  accountAddresses,
@@ -47,4 +69,12 @@ export class Conversations {
47
69
 
48
70
  return new Conversation(this.#client, conversation.id, conversation);
49
71
  }
72
+
73
+ async newDm(accountAddress: string) {
74
+ const conversation = await this.#client.sendMessage("newDm", {
75
+ accountAddress,
76
+ });
77
+
78
+ return new Conversation(this.#client, conversation.id, conversation);
79
+ }
50
80
  }
@@ -1,5 +1,5 @@
1
1
  import type { ContentTypeId } from "@xmtp/content-type-primitives";
2
- import { WasmDeliveryStatus, WasmGroupMessageKind } from "@xmtp/wasm-bindings";
2
+ import { DeliveryStatus, GroupMessageKind } from "@xmtp/wasm-bindings";
3
3
  import type { Client } from "@/Client";
4
4
  import { fromSafeContentTypeId, type SafeMessage } from "@/utils/conversions";
5
5
 
@@ -39,23 +39,23 @@ export class DecodedMessage {
39
39
  this.senderInboxId = message.senderInboxId;
40
40
 
41
41
  switch (message.kind) {
42
- case WasmGroupMessageKind.Application:
42
+ case GroupMessageKind.Application:
43
43
  this.kind = "application";
44
44
  break;
45
- case WasmGroupMessageKind.MembershipChange:
45
+ case GroupMessageKind.MembershipChange:
46
46
  this.kind = "membership_change";
47
47
  break;
48
48
  // no default
49
49
  }
50
50
 
51
51
  switch (message.deliveryStatus) {
52
- case WasmDeliveryStatus.Unpublished:
52
+ case DeliveryStatus.Unpublished:
53
53
  this.deliveryStatus = "unpublished";
54
54
  break;
55
- case WasmDeliveryStatus.Published:
55
+ case DeliveryStatus.Published:
56
56
  this.deliveryStatus = "published";
57
57
  break;
58
- case WasmDeliveryStatus.Failed:
58
+ case DeliveryStatus.Failed:
59
59
  this.deliveryStatus = "failed";
60
60
  break;
61
61
  // no default
@@ -1,7 +1,7 @@
1
1
  import {
2
- type WasmClient,
3
- type WasmConsentEntityType,
4
- type WasmSignatureRequestType,
2
+ type Client,
3
+ type ConsentEntityType,
4
+ type SignatureRequestType,
5
5
  } from "@xmtp/wasm-bindings";
6
6
  import type { ClientOptions } from "@/types";
7
7
  import { fromSafeConsent, type SafeConsent } from "@/utils/conversions";
@@ -9,13 +9,13 @@ import { createClient } from "@/utils/createClient";
9
9
  import { WorkerConversations } from "@/WorkerConversations";
10
10
 
11
11
  export class WorkerClient {
12
- #client: WasmClient;
12
+ #client: Client;
13
13
 
14
14
  #conversations: WorkerConversations;
15
15
 
16
16
  #accountAddress: string;
17
17
 
18
- constructor(client: WasmClient) {
18
+ constructor(client: Client) {
19
19
  this.#client = client;
20
20
  this.#accountAddress = client.accountAddress;
21
21
  this.#conversations = new WorkerConversations(this, client.conversations());
@@ -23,9 +23,10 @@ export class WorkerClient {
23
23
 
24
24
  static async create(
25
25
  accountAddress: string,
26
+ encryptionKey: Uint8Array,
26
27
  options?: Omit<ClientOptions, "codecs">,
27
28
  ) {
28
- const client = await createClient(accountAddress, options);
29
+ const client = await createClient(accountAddress, encryptionKey, options);
29
30
  return new WorkerClient(client);
30
31
  }
31
32
 
@@ -80,11 +81,20 @@ export class WorkerClient {
80
81
  }
81
82
  }
82
83
 
83
- async addSignature(type: WasmSignatureRequestType, bytes: Uint8Array) {
84
+ async addSignature(type: SignatureRequestType, bytes: Uint8Array) {
84
85
  return this.#client.addSignature(type, bytes);
85
86
  }
86
87
 
87
- async applySignaturesRequests() {
88
+ async addScwSignature(
89
+ type: SignatureRequestType,
90
+ bytes: Uint8Array,
91
+ chainId: bigint,
92
+ blockNumber?: bigint,
93
+ ) {
94
+ return this.#client.addScwSignature(type, bytes, chainId, blockNumber);
95
+ }
96
+
97
+ async applySignatures() {
88
98
  return this.#client.applySignatureRequests();
89
99
  }
90
100
 
@@ -114,7 +124,7 @@ export class WorkerClient {
114
124
  return this.#client.setConsentStates(records.map(fromSafeConsent));
115
125
  }
116
126
 
117
- async getConsentState(entityType: WasmConsentEntityType, entity: string) {
127
+ async getConsentState(entityType: ConsentEntityType, entity: string) {
118
128
  return this.#client.getConsentState(entityType, entity);
119
129
  }
120
130