@xmtp/browser-sdk 1.0.0-rc1 → 1.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.
@@ -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 Consent,\n CreateDMOptions,\n CreateGroupOptions,\n GroupMember,\n GroupPermissionsOptions,\n ListConversationsOptions,\n ListMessagesOptions,\n MessageDisappearingSettings,\n PermissionPolicySet,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ContentType,\n type DeliveryStatus,\n type GroupMessageKind,\n type HmacKey,\n type Identifier,\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 contentTypes?: ContentType[];\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 contentTypes: options.contentTypes,\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 options.contentTypes,\n );\n\nexport type SafeListConversationsOptions = {\n consentStates?: ConsentState[];\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n includeDuplicateDms?: boolean;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n consentStates: options.consentStates,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n includeDuplicateDms: options.includeDuplicateDms,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.consentStates,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.includeDuplicateDms ?? false,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateMessageDisappearingPolicy: PermissionPolicy;\n};\n\nexport const toSafePermissionPolicySet = (\n policySet: PermissionPolicySet,\n): SafePermissionPolicySet => ({\n addAdminPolicy: policySet.addAdminPolicy,\n addMemberPolicy: policySet.addMemberPolicy,\n removeAdminPolicy: policySet.removeAdminPolicy,\n removeMemberPolicy: policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy: policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy: policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy: policySet.updateGroupNamePolicy,\n updateMessageDisappearingPolicy: policySet.updateMessageDisappearingPolicy,\n});\n\nexport const fromSafePermissionPolicySet = (\n policySet: SafePermissionPolicySet,\n): PermissionPolicySet =>\n new PermissionPolicySet(\n policySet.addMemberPolicy,\n policySet.removeMemberPolicy,\n policySet.addAdminPolicy,\n policySet.removeAdminPolicy,\n policySet.updateGroupNamePolicy,\n policySet.updateGroupDescriptionPolicy,\n policySet.updateGroupImageUrlSquarePolicy,\n policySet.updateMessageDisappearingPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n messageDisappearingSettings?: SafeMessageDisappearingSettings;\n name?: string;\n permissions?: GroupPermissionsOptions;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n customPermissionPolicySet: options.customPermissionPolicySet,\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n messageDisappearingSettings: options.messageDisappearingSettings\n ? toSafeMessageDisappearingSettings(options.messageDisappearingSettings)\n : undefined,\n name: options.groupName,\n permissions: options.permissions,\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 // only include custom policy set if permissions are set to CustomPolicy\n options.customPermissionPolicySet &&\n options.permissions === GroupPermissionsOptions.CustomPolicy\n ? fromSafePermissionPolicySet(options.customPermissionPolicySet)\n : undefined,\n options.messageDisappearingSettings\n ? fromSafeMessageDisappearingSettings(options.messageDisappearingSettings)\n : undefined,\n );\n\nexport type SafeCreateDmOptions = {\n messageDisappearingSettings?: SafeMessageDisappearingSettings;\n};\n\nexport const toSafeCreateDmOptions = (\n options: CreateDMOptions,\n): SafeCreateDmOptions => ({\n messageDisappearingSettings: options.messageDisappearingSettings\n ? toSafeMessageDisappearingSettings(options.messageDisappearingSettings)\n : undefined,\n});\n\nexport const fromSafeCreateDmOptions = (\n options: SafeCreateDmOptions,\n): CreateDMOptions =>\n new CreateDMOptions(\n options.messageDisappearingSettings\n ? fromSafeMessageDisappearingSettings(options.messageDisappearingSettings)\n : undefined,\n );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: 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 updateMessageDisappearingPolicy: 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 = async (\n conversation: WorkerConversation,\n): Promise<SafeConversation> => {\n const id = conversation.id;\n const name = conversation.name;\n const imageUrl = conversation.imageUrl;\n const description = conversation.description;\n const permissions = conversation.permissions;\n const isActive = conversation.isActive;\n const addedByInboxId = conversation.addedByInboxId;\n const metadata = await conversation.metadata();\n const admins = conversation.admins;\n const superAdmins = conversation.superAdmins;\n const createdAtNs = conversation.createdAtNs;\n const policyType = permissions.policyType;\n const policySet = permissions.policySet;\n return {\n id,\n name,\n imageUrl,\n description,\n permissions: {\n policyType,\n policySet: {\n addAdminPolicy: policySet.addAdminPolicy,\n addMemberPolicy: policySet.addMemberPolicy,\n removeAdminPolicy: policySet.removeAdminPolicy,\n removeMemberPolicy: policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy: policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy: policySet.updateGroupNamePolicy,\n updateMessageDisappearingPolicy:\n policySet.updateMessageDisappearingPolicy,\n },\n },\n isActive,\n addedByInboxId,\n metadata,\n admins,\n superAdmins,\n createdAtNs,\n };\n};\n\nexport type SafeInstallation = {\n bytes: Uint8Array;\n clientTimestampNs?: bigint;\n id: string;\n};\n\nexport const toSafeInstallation = (\n installation: Installation,\n): SafeInstallation => ({\n bytes: installation.bytes,\n clientTimestampNs: installation.clientTimestampNs,\n id: installation.id,\n});\n\nexport type SafeInboxState = {\n accountIdentifiers: Identifier[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryIdentifier: Identifier;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountIdentifiers: inboxState.accountIdentifiers,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryIdentifier: inboxState.recoveryIdentifier,\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 accountIdentifiers: Identifier[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountIdentifiers: member.accountIdentifiers,\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.accountIdentifiers,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n\nexport type SafeHmacKey = {\n key: Uint8Array;\n epoch: bigint;\n};\n\nexport const toSafeHmacKey = (hmacKey: HmacKey): SafeHmacKey => ({\n key: hmacKey.key,\n epoch: hmacKey.epoch,\n});\n\nexport type HmacKeys = Map<string, HmacKey[]>;\nexport type SafeHmacKeys = Record<string, SafeHmacKey[]>;\n\nexport type SafeMessageDisappearingSettings = {\n fromNs: bigint;\n inNs: bigint;\n};\n\nexport const toSafeMessageDisappearingSettings = (\n settings: MessageDisappearingSettings,\n): SafeMessageDisappearingSettings => ({\n fromNs: settings.fromNs,\n inNs: settings.inNs,\n});\n\nexport const fromSafeMessageDisappearingSettings = (\n settings: SafeMessageDisappearingSettings,\n): MessageDisappearingSettings =>\n new MessageDisappearingSettings(settings.fromNs, settings.inNs);\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\nexport const HistorySyncUrls = {\n local: \"http://localhost:5558\",\n dev: \"https://message-history.dev.ephemera.network\",\n production: \"https://message-history.production.ephemera.network\",\n} as const;\n","import {\n MessageDisappearingSettings,\n type ConsentState,\n type Conversation,\n type EncodedContent,\n type GroupMember,\n type Identifier,\n type Message,\n type MetadataField,\n type PermissionPolicy,\n type PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport { type StreamCallback } from \"@/AsyncStream\";\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 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 async metadata() {\n const metadata = await 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 async updatePermission(\n permissionType: PermissionUpdateType,\n policy: PermissionPolicy,\n metadataField?: MetadataField,\n ) {\n return this.#group.updatePermissionPolicy(\n permissionType,\n policy,\n metadataField,\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 addMembersByIdentifiers(identifiers: Identifier[]) {\n return this.#group.addMembers(identifiers);\n }\n\n async addMembers(inboxIds: string[]) {\n return this.#group.addMembersByInboxId(inboxIds);\n }\n\n async removeMembersByIdentifiers(identifiers: Identifier[]) {\n return this.#group.removeMembers(identifiers);\n }\n\n async removeMembers(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 async 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 messageDisappearingSettings() {\n return this.#group.messageDisappearingSettings();\n }\n\n async updateMessageDisappearingSettings(fromNs: bigint, inNs: bigint) {\n const settings = new MessageDisappearingSettings(fromNs, inNs);\n return this.#group.updateMessageDisappearingSettings(settings);\n }\n\n async removeMessageDisappearingSettings() {\n return this.#group.removeMessageDisappearingSettings();\n }\n\n isMessageDisappearingEnabled() {\n return this.#group.isMessageDisappearingEnabled();\n }\n\n stream(callback?: StreamCallback<Message>) {\n const on_message = (message: Message) => {\n void callback?.(null, message);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#group.stream({ on_message, on_error });\n }\n\n pausedForVersion() {\n return this.#group.pausedForVersion();\n }\n}\n","import {\n ConversationType,\n type Consent,\n type ConsentState,\n type Conversation,\n type ConversationListItem,\n type Conversations,\n type Identifier,\n type Message,\n type UserPreference,\n} from \"@xmtp/wasm-bindings\";\nimport type { StreamCallback } from \"@/AsyncStream\";\nimport {\n fromSafeCreateDmOptions,\n fromSafeCreateGroupOptions,\n fromSafeListConversationsOptions,\n type HmacKeys,\n type SafeCreateDmOptions,\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 async syncAll(consentStates?: ConsentState[]) {\n return this.#conversations.syncAllConversations(consentStates);\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 return this.#conversations.findMessageById(id);\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 list(options?: SafeListConversationsOptions) {\n const groups = this.#conversations.list(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as ConversationListItem[];\n return groups.map(\n (item) => new WorkerConversation(this.#client, item.conversation),\n );\n }\n\n listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = this.#conversations.listGroups(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as ConversationListItem[];\n return groups.map(\n (item) => new WorkerConversation(this.#client, item.conversation),\n );\n }\n\n listDms(options?: Omit<SafeListConversationsOptions, \"conversation_type\">) {\n const groups = this.#conversations.listDms(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as ConversationListItem[];\n return groups.map(\n (item) => new WorkerConversation(this.#client, item.conversation),\n );\n }\n\n async newGroupWithIdentifiers(\n identifiers: Identifier[],\n options?: SafeCreateGroupOptions,\n ) {\n const group = await this.#conversations.createGroup(\n identifiers,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newGroup(inboxIds: string[], options?: SafeCreateGroupOptions) {\n const group = await this.#conversations.createGroupByInboxIds(\n inboxIds,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDmWithIdentifier(\n identifier: Identifier,\n options?: SafeCreateDmOptions,\n ) {\n const group = await this.#conversations.createDm(\n identifier,\n options ? fromSafeCreateDmOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDm(inboxId: string, options?: SafeCreateDmOptions) {\n const group = await this.#conversations.createDmByInboxId(\n inboxId,\n options ? fromSafeCreateDmOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n getHmacKeys() {\n return this.#conversations.getHmacKeys() as HmacKeys;\n }\n\n stream(\n callback?: StreamCallback<Conversation>,\n conversationType?: ConversationType,\n ) {\n const on_conversation = (conversation: Conversation) => {\n void callback?.(null, conversation);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#conversations.stream(\n { on_conversation, on_error },\n conversationType,\n );\n }\n\n streamGroups(callback?: StreamCallback<Conversation>) {\n return this.#conversations.stream(callback, ConversationType.Group);\n }\n\n streamDms(callback?: StreamCallback<Conversation>) {\n return this.#conversations.stream(callback, ConversationType.Dm);\n }\n\n streamAllMessages(\n callback?: StreamCallback<Message>,\n conversationType?: ConversationType,\n ) {\n const on_message = (message: Message) => {\n void callback?.(null, message);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#conversations.streamAllMessages(\n { on_message, on_error },\n conversationType,\n );\n }\n\n streamConsent(callback?: StreamCallback<Consent[]>) {\n const on_consent_update = (consent: Consent[]) => {\n void callback?.(null, consent);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#conversations.streamConsent({ on_consent_update, on_error });\n }\n\n streamPreferences(callback?: StreamCallback<UserPreference[]>) {\n const on_user_preference_update = (preferences: UserPreference[]) => {\n void callback?.(null, preferences);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#conversations.streamPreferences({\n on_user_preference_update,\n on_error,\n });\n }\n}\n","import {\n verifySignedWithPublicKey,\n type Client,\n type ConsentEntityType,\n type Identifier,\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 constructor(client: Client) {\n this.#client = client;\n this.#conversations = new WorkerConversations(this, client.conversations());\n }\n\n static async create(\n identifier: Identifier,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n ) {\n const client = await createClient(identifier, encryptionKey, options);\n return new WorkerClient(client);\n }\n\n get accountIdentifier() {\n return this.#client.accountIdentifier;\n }\n\n get inboxId() {\n return this.#client.inboxId;\n }\n\n get installationId() {\n return this.#client.installationId;\n }\n\n get installationIdBytes() {\n return this.#client.installationIdBytes;\n }\n\n get isRegistered() {\n return this.#client.isRegistered;\n }\n\n createInboxSignatureText() {\n try {\n return this.#client.createInboxSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async addAccountSignatureText(identifier: Identifier) {\n try {\n return await this.#client.addWalletSignatureText(identifier);\n } catch {\n return undefined;\n }\n }\n\n async removeAccountSignatureText(identifier: Identifier) {\n try {\n return await this.#client.revokeWalletSignatureText(identifier);\n } catch {\n return undefined;\n }\n }\n\n async revokeAllAOtherInstallationsSignatureText() {\n try {\n return await this.#client.revokeAllOtherInstallationsSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async revokeInstallationsSignatureText(installationIds: Uint8Array[]) {\n try {\n return await this.#client.revokeInstallationsSignatureText(\n installationIds,\n );\n } catch {\n return undefined;\n }\n }\n\n async addEcdsaSignature(type: SignatureRequestType, bytes: Uint8Array) {\n return this.#client.addEcdsaSignature(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(identifiers: Identifier[]) {\n return this.#client.canMessage(identifiers) as Promise<\n Map<string, boolean>\n >;\n }\n\n async registerIdentity() {\n return this.#client.registerIdentity();\n }\n\n async findInboxIdByIdentifier(identifier: Identifier) {\n return this.#client.findInboxIdByIdentifier(identifier);\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 signWithInstallationKey(signatureText: string) {\n return this.#client.signWithInstallationKey(signatureText);\n }\n\n verifySignedWithInstallationKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n ) {\n try {\n this.#client.verifySignedWithInstallationKey(\n signatureText,\n signatureBytes,\n );\n return true;\n } catch {\n return false;\n }\n }\n\n verifySignedWithPublicKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n publicKey: Uint8Array,\n ) {\n try {\n verifySignedWithPublicKey(signatureText, signatureBytes, publicKey);\n return true;\n } catch {\n return false;\n }\n }\n}\n","import {\n createClient as createWasmClient,\n generateInboxId,\n getInboxIdForIdentifier,\n LogOptions,\n type Identifier,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls, HistorySyncUrls } from \"@/constants\";\nimport type { ClientOptions } from \"@/types\";\n\nexport const createClient = async (\n identifier: Identifier,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n) => {\n const host = options?.apiUrl || ApiUrls[options?.env || \"dev\"];\n const inboxId =\n (await getInboxIdForIdentifier(host, identifier)) ||\n generateInboxId(identifier);\n const dbPath =\n options?.dbPath || `xmtp-${options?.env || \"dev\"}-${inboxId}.db3`;\n const isLogging =\n options &&\n (options.loggingLevel !== undefined ||\n options.structuredLogging ||\n options.performanceLogging);\n\n const historySyncUrl =\n options?.historySyncUrl || HistorySyncUrls[options?.env || \"dev\"];\n\n return createWasmClient(\n host,\n inboxId,\n identifier,\n dbPath,\n encryptionKey,\n historySyncUrl,\n isLogging\n ? new LogOptions(\n options.structuredLogging ?? false,\n options.performanceLogging ?? false,\n options.loggingLevel,\n )\n : undefined,\n );\n};\n","import init, {\n type Consent,\n type Conversation,\n type Message,\n type StreamCloser,\n type UserPreference,\n} from \"@xmtp/wasm-bindings\";\nimport type {\n ClientEventsActions,\n ClientEventsClientMessageData,\n ClientEventsErrorData,\n ClientEventsWorkerPostMessageData,\n} from \"@/types\";\nimport type {\n ClientStreamEventsErrorData,\n ClientStreamEventsTypes,\n ClientStreamEventsWorkerPostMessageData,\n} from \"@/types/clientStreamEvents\";\nimport {\n fromEncodedContent,\n fromSafeEncodedContent,\n toSafeConsent,\n toSafeConversation,\n toSafeHmacKey,\n toSafeInboxState,\n toSafeMessage,\n toSafeMessageDisappearingSettings,\n} from \"@/utils/conversions\";\nimport { WorkerClient } from \"@/WorkerClient\";\nimport { WorkerConversation } from \"@/WorkerConversation\";\n\nlet maybeClient: WorkerClient | undefined;\nlet enableLogging = false;\n\nconst streamClosers = new Map<string, StreamCloser>();\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\n/**\n * Type-safe postMessage for streams\n */\nconst postStreamMessage = <A extends ClientStreamEventsTypes>(\n data: ClientStreamEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for stream errors\n */\nconst postStreamMessageError = (data: ClientStreamEventsErrorData) => {\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 // initialize WASM module\n await init();\n\n try {\n // init is a special action that initializes the client\n if (action === \"init\" && !maybeClient) {\n maybeClient = await WorkerClient.create(\n data.identifier,\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: maybeClient.inboxId,\n installationId: maybeClient.installationId,\n installationIdBytes: maybeClient.installationIdBytes,\n },\n });\n return;\n }\n\n // a client is required for all other actions\n if (!maybeClient) {\n throw new Error(\"Client not initialized\");\n }\n\n // let typescript know that a client will be available for the rest\n // of this code block\n const client = maybeClient;\n\n // helper function that throws an error if the group is not found\n const getGroup = (groupId: string) => {\n const group = client.conversations.getConversationById(groupId);\n if (!group) {\n throw new Error(`Group \"${groupId}\" not found`);\n }\n return group;\n };\n\n switch (action) {\n /**\n * Stream actions\n */\n case \"endStream\": {\n const streamCloser = streamClosers.get(data.streamId);\n if (streamCloser) {\n streamCloser.end();\n streamClosers.delete(data.streamId);\n postMessage({ id, action, result: undefined });\n } else {\n throw new Error(`Stream \"${data.streamId}\" not found`);\n }\n break;\n }\n /**\n * Client actions\n */\n case \"createInboxSignatureText\": {\n const result = client.createInboxSignatureText();\n postMessage({ id, action, result });\n break;\n }\n case \"addAccountSignatureText\": {\n const result = await client.addAccountSignatureText(data.newIdentifier);\n postMessage({ id, action, result });\n break;\n }\n case \"removeAccountSignatureText\": {\n const result = await client.removeAccountSignatureText(data.identifier);\n postMessage({ id, action, result });\n break;\n }\n case \"revokeAllOtherInstallationsSignatureText\": {\n const result = await client.revokeAllAOtherInstallationsSignatureText();\n postMessage({ id, action, result });\n break;\n }\n case \"revokeInstallationsSignatureText\": {\n const result = await client.revokeInstallationsSignatureText(\n data.installationIds,\n );\n postMessage({ id, action, result });\n break;\n }\n case \"addEcdsaSignature\":\n await client.addEcdsaSignature(data.type, data.bytes);\n postMessage({ id, action, result: undefined });\n break;\n case \"addScwSignature\":\n await client.addScwSignature(\n data.type,\n data.bytes,\n data.chainId,\n data.blockNumber,\n );\n postMessage({ id, action, result: undefined });\n break;\n case \"applySignatures\":\n await client.applySignatures();\n postMessage({ id, action, result: undefined });\n break;\n case \"registerIdentity\":\n await client.registerIdentity();\n postMessage({ id, action, result: undefined });\n break;\n case \"isRegistered\": {\n const result = client.isRegistered;\n postMessage({ id, action, result });\n break;\n }\n case \"canMessage\": {\n const result = await client.canMessage(data.identifiers);\n postMessage({ id, action, result });\n break;\n }\n case \"inboxState\": {\n const inboxState = await client.inboxState(data.refreshFromNetwork);\n const result = toSafeInboxState(inboxState);\n postMessage({ id, action, result });\n break;\n }\n case \"getLatestInboxState\": {\n const inboxState = await client.getLatestInboxState(data.inboxId);\n const result = toSafeInboxState(inboxState);\n postMessage({ id, action, result });\n break;\n }\n case \"setConsentStates\": {\n await client.setConsentStates(data.records);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"getConsentState\": {\n const result = await client.getConsentState(\n data.entityType,\n data.entity,\n );\n postMessage({ id, action, result });\n break;\n }\n case \"findInboxIdByIdentifier\": {\n const result = await client.findInboxIdByIdentifier(data.identifier);\n postMessage({ id, action, result });\n break;\n }\n case \"signWithInstallationKey\": {\n const result = client.signWithInstallationKey(data.signatureText);\n postMessage({ id, action, result });\n break;\n }\n case \"verifySignedWithInstallationKey\": {\n const result = client.verifySignedWithInstallationKey(\n data.signatureText,\n data.signatureBytes,\n );\n postMessage({ id, action, result });\n break;\n }\n case \"verifySignedWithPublicKey\": {\n const result = client.verifySignedWithPublicKey(\n data.signatureText,\n data.signatureBytes,\n data.publicKey,\n );\n postMessage({ id, action, result });\n break;\n }\n /**\n * Conversations actions\n */\n case \"streamAllGroups\": {\n const streamCallback = async (\n error: Error | null,\n value: Conversation | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"group\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"group\",\n streamId: data.streamId,\n result: value\n ? await toSafeConversation(\n new WorkerConversation(client, value),\n )\n : undefined,\n });\n }\n };\n const streamCloser = client.conversations.stream(\n streamCallback,\n data.conversationType,\n );\n streamClosers.set(data.streamId, streamCloser);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"streamAllMessages\": {\n const streamCallback = (\n error: Error | null,\n value: Message | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"message\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"message\",\n streamId: data.streamId,\n result: value ? toSafeMessage(value) : undefined,\n });\n }\n };\n const streamCloser = client.conversations.streamAllMessages(\n streamCallback,\n data.conversationType,\n );\n streamClosers.set(data.streamId, streamCloser);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"streamConsent\": {\n const streamCallback = (\n error: Error | null,\n value: Consent[] | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"consent\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"consent\",\n streamId: data.streamId,\n result: value?.map(toSafeConsent) ?? [],\n });\n }\n };\n const streamCloser = client.conversations.streamConsent(streamCallback);\n streamClosers.set(data.streamId, streamCloser);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"streamPreferences\": {\n const streamCallback = (\n error: Error | null,\n value: UserPreference[] | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"preferences\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"preferences\",\n streamId: data.streamId,\n result: value ?? undefined,\n });\n }\n };\n const streamCloser =\n client.conversations.streamPreferences(streamCallback);\n streamClosers.set(data.streamId, streamCloser);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConversations\": {\n const conversations = client.conversations.list(data.options);\n const result = await Promise.all(\n conversations.map((conversation) => toSafeConversation(conversation)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"getGroups\": {\n const conversations = client.conversations.listGroups(data.options);\n const result = await Promise.all(\n conversations.map((conversation) => toSafeConversation(conversation)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"getDms\": {\n const conversations = client.conversations.listDms(data.options);\n const result = await Promise.all(\n conversations.map((conversation) => toSafeConversation(conversation)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"newGroupWithIdentifiers\": {\n const conversation = await client.conversations.newGroupWithIdentifiers(\n data.identifiers,\n data.options,\n );\n const result = await toSafeConversation(conversation);\n postMessage({ id, action, result });\n break;\n }\n case \"newGroupWithInboxIds\": {\n const conversation = await client.conversations.newGroup(\n data.inboxIds,\n data.options,\n );\n const result = await toSafeConversation(conversation);\n postMessage({ id, action, result });\n break;\n }\n case \"newDmWithIdentifier\": {\n const conversation = await client.conversations.newDmWithIdentifier(\n data.identifier,\n data.options,\n );\n const result = await toSafeConversation(conversation);\n postMessage({ id, action, result });\n break;\n }\n case \"newDmWithInboxId\": {\n const conversation = await client.conversations.newDm(\n data.inboxId,\n data.options,\n );\n const result = await toSafeConversation(conversation);\n postMessage({ id, action, result });\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 \"syncAllConversations\": {\n await client.conversations.syncAll(data.consentStates);\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 const result = conversation\n ? await toSafeConversation(conversation)\n : undefined;\n postMessage({ id, action, result });\n break;\n }\n case \"getMessageById\": {\n const message = client.conversations.getMessageById(data.id);\n const result = message ? toSafeMessage(message) : undefined;\n postMessage({ id, action, result });\n break;\n }\n case \"getDmByInboxId\": {\n const conversation = client.conversations.getDmByInboxId(data.inboxId);\n const result = conversation\n ? await toSafeConversation(conversation)\n : undefined;\n postMessage({ id, action, result });\n break;\n }\n case \"getHmacKeys\": {\n const hmacKeys = client.conversations.getHmacKeys();\n const result = Object.fromEntries(\n Array.from(hmacKeys.entries()).map(([groupId, hmacKeys]) => [\n groupId,\n hmacKeys.map(toSafeHmacKey),\n ]),\n );\n postMessage({ id, action, result });\n break;\n }\n /**\n * Group actions\n */\n case \"syncGroup\": {\n const group = getGroup(data.id);\n await group.sync();\n const result = await toSafeConversation(group);\n postMessage({ id, action, result });\n break;\n }\n case \"updateGroupName\": {\n const group = getGroup(data.id);\n await group.updateName(data.name);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"updateGroupDescription\": {\n const group = getGroup(data.id);\n await group.updateDescription(data.description);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"updateGroupImageUrlSquare\": {\n const group = getGroup(data.id);\n await group.updateImageUrl(data.imageUrl);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"sendGroupMessage\": {\n const group = getGroup(data.id);\n const result = await group.send(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"sendOptimisticGroupMessage\": {\n const group = getGroup(data.id);\n const result = group.sendOptimistic(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"publishGroupMessages\": {\n const group = getGroup(data.id);\n await group.publishMessages();\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"getGroupMessages\": {\n const group = getGroup(data.id);\n const messages = await group.messages(data.options);\n const result = messages.map((message) => toSafeMessage(message));\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupMembers\": {\n const group = getGroup(data.id);\n const result = await group.members();\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupAdmins\": {\n const group = getGroup(data.id);\n const result = group.admins;\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupSuperAdmins\": {\n const group = getGroup(data.id);\n const result = group.superAdmins;\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupConsentState\": {\n const group = getGroup(data.id);\n const result = group.consentState;\n postMessage({ id, action, result });\n break;\n }\n case \"updateGroupConsentState\": {\n const group = getGroup(data.id);\n group.updateConsentState(data.state);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"addGroupAdmin\": {\n const group = getGroup(data.id);\n await group.addAdmin(data.inboxId);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupAdmin\": {\n const group = getGroup(data.id);\n await group.removeAdmin(data.inboxId);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"addGroupSuperAdmin\": {\n const group = getGroup(data.id);\n await group.addSuperAdmin(data.inboxId);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupSuperAdmin\": {\n const group = getGroup(data.id);\n await group.removeSuperAdmin(data.inboxId);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"addGroupMembers\": {\n const group = getGroup(data.id);\n await group.addMembersByIdentifiers(data.identifiers);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupMembers\": {\n const group = getGroup(data.id);\n await group.removeMembersByIdentifiers(data.identifiers);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"addGroupMembersByInboxId\": {\n const group = getGroup(data.id);\n await group.addMembers(data.inboxIds);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupMembersByInboxId\": {\n const group = getGroup(data.id);\n await group.removeMembers(data.inboxIds);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"isGroupAdmin\": {\n const group = getGroup(data.id);\n const result = group.isAdmin(data.inboxId);\n postMessage({ id, action, result });\n break;\n }\n case \"isGroupSuperAdmin\": {\n const group = getGroup(data.id);\n const result = group.isSuperAdmin(data.inboxId);\n postMessage({ id, action, result });\n break;\n }\n case \"getDmPeerInboxId\": {\n const group = getGroup(data.id);\n const result = group.dmPeerInboxId();\n postMessage({ id, action, result });\n break;\n }\n case \"updateGroupPermissionPolicy\": {\n const group = getGroup(data.id);\n await group.updatePermission(\n data.permissionType,\n data.policy,\n data.metadataField,\n );\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"getGroupPermissions\": {\n const group = getGroup(data.id);\n const safeConversation = await toSafeConversation(group);\n const result = safeConversation.permissions;\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupMessageDisappearingSettings\": {\n const group = getGroup(data.id);\n const settings = group.messageDisappearingSettings();\n const result = settings\n ? toSafeMessageDisappearingSettings(settings)\n : undefined;\n postMessage({ id, action, result });\n break;\n }\n case \"updateGroupMessageDisappearingSettings\": {\n const group = getGroup(data.id);\n await group.updateMessageDisappearingSettings(data.fromNs, data.inNs);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupMessageDisappearingSettings\": {\n const group = getGroup(data.id);\n await group.removeMessageDisappearingSettings();\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"isGroupMessageDisappearingEnabled\": {\n const group = getGroup(data.id);\n const result = group.isMessageDisappearingEnabled();\n postMessage({ id, action, result });\n break;\n }\n case \"streamGroupMessages\": {\n const group = getGroup(data.groupId);\n const streamCallback = (\n error: Error | null,\n value: Message | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"message\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"message\",\n streamId: data.streamId,\n result: value ? toSafeMessage(value) : undefined,\n });\n }\n };\n const streamCloser = group.stream(streamCallback);\n streamClosers.set(data.streamId, streamCloser);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"getGroupPausedForVersion\": {\n const group = getGroup(data.id);\n const result = group.pausedForVersion();\n postMessage({ id, action, result });\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","consentStates","createdAfterNs","createdBeforeNs","includeDuplicateDms","limit","fromSafeCreateGroupOptions","CreateGroupOptions","permissions","name","imageUrlSquare","description","customPermissionPolicySet","GroupPermissionsOptions","CustomPolicy","policySet","PermissionPolicySet","addMemberPolicy","removeMemberPolicy","addAdminPolicy","removeAdminPolicy","updateGroupNamePolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateMessageDisappearingPolicy","undefined","messageDisappearingSettings","fromSafeMessageDisappearingSettings","fromSafeCreateDmOptions","CreateDMOptions","toSafeConversation","async","conversation","imageUrl","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","policyType","toSafeInstallation","installation","bytes","clientTimestampNs","toSafeInboxState","inboxState","accountIdentifiers","inboxId","installations","map","recoveryIdentifier","toSafeConsent","consent","entity","entityType","state","fromSafeConsent","Consent","toSafeHmacKey","hmacKey","key","epoch","settings","MessageDisappearingSettings","fromNs","inNs","ApiUrls","local","dev","production","HistorySyncUrls","WorkerConversation","client","group","constructor","this","groupName","updateName","updateGroupName","groupImageUrlSquare","updateImageUrl","updateGroupImageUrlSquare","groupDescription","updateDescription","updateGroupDescription","groupMetadata","creatorInboxId","conversationType","members","listMembers","member","consentState","installationIds","permissionLevel","toSafeGroupMember","adminList","superAdminList","groupPermissions","updatePermission","permissionType","policy","metadataField","updatePermissionPolicy","isAdmin","isSuperAdmin","sync","addMembersByIdentifiers","identifiers","addMembers","inboxIds","addMembersByInboxId","removeMembersByIdentifiers","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","encodedContent","send","messages","findMessages","ListMessagesOptions","sentBeforeNs","sentAfterNs","direction","contentTypes","fromSafeListMessagesOptions","updateConsentState","dmPeerInboxId","updateMessageDisappearingSettings","removeMessageDisappearingSettings","isMessageDisappearingEnabled","stream","callback","on_message","on_error","error","pausedForVersion","WorkerConversations","conversations","syncAll","syncAllConversations","getConversationById","findGroupById","getMessageById","findMessageById","getDmByInboxId","findDmByTargetInboxId","list","item","listGroups","listDms","newGroupWithIdentifiers","createGroup","newGroup","createGroupByInboxIds","newDmWithIdentifier","identifier","createDm","newDm","createDmByInboxId","getHmacKeys","on_conversation","streamGroups","ConversationType","Group","streamDms","Dm","streamAllMessages","streamConsent","on_consent_update","streamPreferences","on_user_preference_update","preferences","WorkerClient","create","encryptionKey","host","apiUrl","env","getInboxIdForIdentifier","generateInboxId","dbPath","isLogging","loggingLevel","structuredLogging","performanceLogging","createWasmClient","historySyncUrl","LogOptions","createClient","accountIdentifier","installationId","installationIdBytes","isRegistered","createInboxSignatureText","addAccountSignatureText","addWalletSignatureText","removeAccountSignatureText","revokeWalletSignatureText","revokeAllAOtherInstallationsSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addEcdsaSignature","addScwSignature","chainId","blockNumber","applySignatures","applySignatureRequests","canMessage","registerIdentity","findInboxIdByIdentifier","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","signWithInstallationKey","signatureText","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","maybeClient","enableLogging","streamClosers","postMessage","data","self","postStreamMessage","postStreamMessageError","onmessage","event","action","console","log","init","result","Error","getGroup","groupId","streamCloser","get","streamId","end","delete","newIdentifier","streamCallback","value","set","Promise","all","hmacKeys","Array","from","toSafeMessageDisappearingSettings","e","postMessageError"],"mappings":"0dAgCO,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,aAC5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utils/conversions.ts","../../src/constants.ts","../../src/WorkerConversation.ts","../../src/WorkerConversations.ts","../../src/WorkerPreferences.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 CreateDMOptions,\n CreateGroupOptions,\n GroupMember,\n GroupPermissionsOptions,\n ListConversationsOptions,\n ListMessagesOptions,\n MessageDisappearingSettings,\n PermissionPolicySet,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ContentType,\n type DeliveryStatus,\n type GroupMessageKind,\n type HmacKey,\n type Identifier,\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 contentTypes?: ContentType[];\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 contentTypes: options.contentTypes,\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 options.contentTypes,\n );\n\nexport type SafeListConversationsOptions = {\n consentStates?: ConsentState[];\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n includeDuplicateDms?: boolean;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n consentStates: options.consentStates,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n includeDuplicateDms: options.includeDuplicateDms,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.consentStates,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.includeDuplicateDms ?? false,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateMessageDisappearingPolicy: PermissionPolicy;\n};\n\nexport const toSafePermissionPolicySet = (\n policySet: PermissionPolicySet,\n): SafePermissionPolicySet => ({\n addAdminPolicy: policySet.addAdminPolicy,\n addMemberPolicy: policySet.addMemberPolicy,\n removeAdminPolicy: policySet.removeAdminPolicy,\n removeMemberPolicy: policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy: policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy: policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy: policySet.updateGroupNamePolicy,\n updateMessageDisappearingPolicy: policySet.updateMessageDisappearingPolicy,\n});\n\nexport const fromSafePermissionPolicySet = (\n policySet: SafePermissionPolicySet,\n): PermissionPolicySet =>\n new PermissionPolicySet(\n policySet.addMemberPolicy,\n policySet.removeMemberPolicy,\n policySet.addAdminPolicy,\n policySet.removeAdminPolicy,\n policySet.updateGroupNamePolicy,\n policySet.updateGroupDescriptionPolicy,\n policySet.updateGroupImageUrlSquarePolicy,\n policySet.updateMessageDisappearingPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n messageDisappearingSettings?: SafeMessageDisappearingSettings;\n name?: string;\n permissions?: GroupPermissionsOptions;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n customPermissionPolicySet: options.customPermissionPolicySet,\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n messageDisappearingSettings: options.messageDisappearingSettings\n ? toSafeMessageDisappearingSettings(options.messageDisappearingSettings)\n : undefined,\n name: options.groupName,\n permissions: options.permissions,\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 // only include custom policy set if permissions are set to CustomPolicy\n options.customPermissionPolicySet &&\n options.permissions === GroupPermissionsOptions.CustomPolicy\n ? fromSafePermissionPolicySet(options.customPermissionPolicySet)\n : undefined,\n options.messageDisappearingSettings\n ? fromSafeMessageDisappearingSettings(options.messageDisappearingSettings)\n : undefined,\n );\n\nexport type SafeCreateDmOptions = {\n messageDisappearingSettings?: SafeMessageDisappearingSettings;\n};\n\nexport const toSafeCreateDmOptions = (\n options: CreateDMOptions,\n): SafeCreateDmOptions => ({\n messageDisappearingSettings: options.messageDisappearingSettings\n ? toSafeMessageDisappearingSettings(options.messageDisappearingSettings)\n : undefined,\n});\n\nexport const fromSafeCreateDmOptions = (\n options: SafeCreateDmOptions,\n): CreateDMOptions =>\n new CreateDMOptions(\n options.messageDisappearingSettings\n ? fromSafeMessageDisappearingSettings(options.messageDisappearingSettings)\n : undefined,\n );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: 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 updateMessageDisappearingPolicy: 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 = async (\n conversation: WorkerConversation,\n): Promise<SafeConversation> => {\n const id = conversation.id;\n const name = conversation.name;\n const imageUrl = conversation.imageUrl;\n const description = conversation.description;\n const permissions = conversation.permissions;\n const isActive = conversation.isActive;\n const addedByInboxId = conversation.addedByInboxId;\n const metadata = await conversation.metadata();\n const admins = conversation.admins;\n const superAdmins = conversation.superAdmins;\n const createdAtNs = conversation.createdAtNs;\n const policyType = permissions.policyType;\n const policySet = permissions.policySet;\n return {\n id,\n name,\n imageUrl,\n description,\n permissions: {\n policyType,\n policySet: {\n addAdminPolicy: policySet.addAdminPolicy,\n addMemberPolicy: policySet.addMemberPolicy,\n removeAdminPolicy: policySet.removeAdminPolicy,\n removeMemberPolicy: policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy: policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy: policySet.updateGroupNamePolicy,\n updateMessageDisappearingPolicy:\n policySet.updateMessageDisappearingPolicy,\n },\n },\n isActive,\n addedByInboxId,\n metadata,\n admins,\n superAdmins,\n createdAtNs,\n };\n};\n\nexport type SafeInstallation = {\n bytes: Uint8Array;\n clientTimestampNs?: bigint;\n id: string;\n};\n\nexport const toSafeInstallation = (\n installation: Installation,\n): SafeInstallation => ({\n bytes: installation.bytes,\n clientTimestampNs: installation.clientTimestampNs,\n id: installation.id,\n});\n\nexport type SafeInboxState = {\n accountIdentifiers: Identifier[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryIdentifier: Identifier;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountIdentifiers: inboxState.accountIdentifiers,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryIdentifier: inboxState.recoveryIdentifier,\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 accountIdentifiers: Identifier[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountIdentifiers: member.accountIdentifiers,\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.accountIdentifiers,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n\nexport type SafeHmacKey = {\n key: Uint8Array;\n epoch: bigint;\n};\n\nexport const toSafeHmacKey = (hmacKey: HmacKey): SafeHmacKey => ({\n key: hmacKey.key,\n epoch: hmacKey.epoch,\n});\n\nexport type HmacKeys = Map<string, HmacKey[]>;\nexport type SafeHmacKeys = Record<string, SafeHmacKey[]>;\n\nexport type SafeMessageDisappearingSettings = {\n fromNs: bigint;\n inNs: bigint;\n};\n\nexport const toSafeMessageDisappearingSettings = (\n settings: MessageDisappearingSettings,\n): SafeMessageDisappearingSettings => ({\n fromNs: settings.fromNs,\n inNs: settings.inNs,\n});\n\nexport const fromSafeMessageDisappearingSettings = (\n settings: SafeMessageDisappearingSettings,\n): MessageDisappearingSettings =>\n new MessageDisappearingSettings(settings.fromNs, settings.inNs);\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\nexport const HistorySyncUrls = {\n local: \"http://localhost:5558\",\n dev: \"https://message-history.dev.ephemera.network\",\n production: \"https://message-history.production.ephemera.network\",\n} as const;\n","import {\n MessageDisappearingSettings,\n type ConsentState,\n type Conversation,\n type EncodedContent,\n type GroupMember,\n type Identifier,\n type Message,\n type MetadataField,\n type PermissionPolicy,\n type PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport { type StreamCallback } from \"@/AsyncStream\";\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 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 async metadata() {\n const metadata = await 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 async updatePermission(\n permissionType: PermissionUpdateType,\n policy: PermissionPolicy,\n metadataField?: MetadataField,\n ) {\n return this.#group.updatePermissionPolicy(\n permissionType,\n policy,\n metadataField,\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 addMembersByIdentifiers(identifiers: Identifier[]) {\n return this.#group.addMembers(identifiers);\n }\n\n async addMembers(inboxIds: string[]) {\n return this.#group.addMembersByInboxId(inboxIds);\n }\n\n async removeMembersByIdentifiers(identifiers: Identifier[]) {\n return this.#group.removeMembers(identifiers);\n }\n\n async removeMembers(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 async 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 messageDisappearingSettings() {\n return this.#group.messageDisappearingSettings();\n }\n\n async updateMessageDisappearingSettings(fromNs: bigint, inNs: bigint) {\n const settings = new MessageDisappearingSettings(fromNs, inNs);\n return this.#group.updateMessageDisappearingSettings(settings);\n }\n\n async removeMessageDisappearingSettings() {\n return this.#group.removeMessageDisappearingSettings();\n }\n\n isMessageDisappearingEnabled() {\n return this.#group.isMessageDisappearingEnabled();\n }\n\n stream(callback?: StreamCallback<Message>) {\n const on_message = (message: Message) => {\n void callback?.(null, message);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#group.stream({ on_message, on_error });\n }\n\n pausedForVersion() {\n return this.#group.pausedForVersion();\n }\n}\n","import {\n ConversationType,\n type ConsentState,\n type Conversation,\n type ConversationListItem,\n type Conversations,\n type Identifier,\n type Message,\n} from \"@xmtp/wasm-bindings\";\nimport type { StreamCallback } from \"@/AsyncStream\";\nimport {\n fromSafeCreateDmOptions,\n fromSafeCreateGroupOptions,\n fromSafeListConversationsOptions,\n type HmacKeys,\n type SafeCreateDmOptions,\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 async syncAll(consentStates?: ConsentState[]) {\n return this.#conversations.syncAllConversations(consentStates);\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 return this.#conversations.findMessageById(id);\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 list(options?: SafeListConversationsOptions) {\n const groups = this.#conversations.list(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as ConversationListItem[];\n return groups.map(\n (item) => new WorkerConversation(this.#client, item.conversation),\n );\n }\n\n listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = this.#conversations.listGroups(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as ConversationListItem[];\n return groups.map(\n (item) => new WorkerConversation(this.#client, item.conversation),\n );\n }\n\n listDms(options?: Omit<SafeListConversationsOptions, \"conversation_type\">) {\n const groups = this.#conversations.listDms(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as ConversationListItem[];\n return groups.map(\n (item) => new WorkerConversation(this.#client, item.conversation),\n );\n }\n\n async newGroupWithIdentifiers(\n identifiers: Identifier[],\n options?: SafeCreateGroupOptions,\n ) {\n const group = await this.#conversations.createGroup(\n identifiers,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newGroup(inboxIds: string[], options?: SafeCreateGroupOptions) {\n const group = await this.#conversations.createGroupByInboxIds(\n inboxIds,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDmWithIdentifier(\n identifier: Identifier,\n options?: SafeCreateDmOptions,\n ) {\n const group = await this.#conversations.createDm(\n identifier,\n options ? fromSafeCreateDmOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDm(inboxId: string, options?: SafeCreateDmOptions) {\n const group = await this.#conversations.createDmByInboxId(\n inboxId,\n options ? fromSafeCreateDmOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n getHmacKeys() {\n return this.#conversations.getHmacKeys() as HmacKeys;\n }\n\n stream(\n callback?: StreamCallback<Conversation>,\n conversationType?: ConversationType,\n ) {\n const on_conversation = (conversation: Conversation) => {\n void callback?.(null, conversation);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#conversations.stream(\n { on_conversation, on_error },\n conversationType,\n );\n }\n\n streamGroups(callback?: StreamCallback<Conversation>) {\n return this.#conversations.stream(callback, ConversationType.Group);\n }\n\n streamDms(callback?: StreamCallback<Conversation>) {\n return this.#conversations.stream(callback, ConversationType.Dm);\n }\n\n streamAllMessages(\n callback?: StreamCallback<Message>,\n conversationType?: ConversationType,\n ) {\n const on_message = (message: Message) => {\n void callback?.(null, message);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#conversations.streamAllMessages(\n { on_message, on_error },\n conversationType,\n );\n }\n}\n","import {\n type Client,\n type Consent,\n type ConsentEntityType,\n type Conversations,\n type UserPreference,\n} from \"@xmtp/wasm-bindings\";\nimport type { StreamCallback } from \"@/AsyncStream\";\nimport { fromSafeConsent, type SafeConsent } from \"@/utils/conversions\";\n\nexport class WorkerPreferences {\n #client: Client;\n #conversations: Conversations;\n\n constructor(client: Client, conversations: Conversations) {\n this.#client = client;\n this.#conversations = conversations;\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 streamConsent(callback?: StreamCallback<Consent[]>) {\n const on_consent_update = (consent: Consent[]) => {\n void callback?.(null, consent);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#conversations.streamConsent({ on_consent_update, on_error });\n }\n\n streamPreferences(callback?: StreamCallback<UserPreference[]>) {\n const on_user_preference_update = (preferences: UserPreference[]) => {\n void callback?.(null, preferences);\n };\n const on_error = (error: Error | null) => {\n void callback?.(error, undefined);\n };\n return this.#conversations.streamPreferences({\n on_user_preference_update,\n on_error,\n });\n }\n}\n","import {\n verifySignedWithPublicKey,\n type Client,\n type Identifier,\n type SignatureRequestType,\n} from \"@xmtp/wasm-bindings\";\nimport type { ClientOptions } from \"@/types\";\nimport { createClient } from \"@/utils/createClient\";\nimport { WorkerConversations } from \"@/WorkerConversations\";\nimport { WorkerPreferences } from \"@/WorkerPreferences\";\n\nexport class WorkerClient {\n #client: Client;\n #conversations: WorkerConversations;\n #preferences: WorkerPreferences;\n\n constructor(client: Client) {\n this.#client = client;\n const conversations = client.conversations();\n this.#conversations = new WorkerConversations(this, conversations);\n this.#preferences = new WorkerPreferences(client, conversations);\n }\n\n static async create(\n identifier: Identifier,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n ) {\n const client = await createClient(identifier, encryptionKey, options);\n return new WorkerClient(client);\n }\n\n get accountIdentifier() {\n return this.#client.accountIdentifier;\n }\n\n get inboxId() {\n return this.#client.inboxId;\n }\n\n get installationId() {\n return this.#client.installationId;\n }\n\n get installationIdBytes() {\n return this.#client.installationIdBytes;\n }\n\n get isRegistered() {\n return this.#client.isRegistered;\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n get preferences() {\n return this.#preferences;\n }\n\n createInboxSignatureText() {\n try {\n return this.#client.createInboxSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async addAccountSignatureText(identifier: Identifier) {\n try {\n return await this.#client.addWalletSignatureText(identifier);\n } catch {\n return undefined;\n }\n }\n\n async removeAccountSignatureText(identifier: Identifier) {\n try {\n return await this.#client.revokeWalletSignatureText(identifier);\n } catch {\n return undefined;\n }\n }\n\n async revokeAllAOtherInstallationsSignatureText() {\n try {\n return await this.#client.revokeAllOtherInstallationsSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async revokeInstallationsSignatureText(installationIds: Uint8Array[]) {\n try {\n return await this.#client.revokeInstallationsSignatureText(\n installationIds,\n );\n } catch {\n return undefined;\n }\n }\n\n async addEcdsaSignature(type: SignatureRequestType, bytes: Uint8Array) {\n return this.#client.addEcdsaSignature(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(identifiers: Identifier[]) {\n return this.#client.canMessage(identifiers) as Promise<\n Map<string, boolean>\n >;\n }\n\n async registerIdentity() {\n return this.#client.registerIdentity();\n }\n\n async findInboxIdByIdentifier(identifier: Identifier) {\n return this.#client.findInboxIdByIdentifier(identifier);\n }\n\n signWithInstallationKey(signatureText: string) {\n return this.#client.signWithInstallationKey(signatureText);\n }\n\n verifySignedWithInstallationKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n ) {\n try {\n this.#client.verifySignedWithInstallationKey(\n signatureText,\n signatureBytes,\n );\n return true;\n } catch {\n return false;\n }\n }\n\n verifySignedWithPublicKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n publicKey: Uint8Array,\n ) {\n try {\n verifySignedWithPublicKey(signatureText, signatureBytes, publicKey);\n return true;\n } catch {\n return false;\n }\n }\n}\n","import {\n createClient as createWasmClient,\n generateInboxId,\n getInboxIdForIdentifier,\n LogOptions,\n type Identifier,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls, HistorySyncUrls } from \"@/constants\";\nimport type { ClientOptions } from \"@/types\";\n\nexport const createClient = async (\n identifier: Identifier,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n) => {\n const host = options?.apiUrl || ApiUrls[options?.env || \"dev\"];\n const inboxId =\n (await getInboxIdForIdentifier(host, identifier)) ||\n generateInboxId(identifier);\n const dbPath =\n options?.dbPath || `xmtp-${options?.env || \"dev\"}-${inboxId}.db3`;\n const isLogging =\n options &&\n (options.loggingLevel !== undefined ||\n options.structuredLogging ||\n options.performanceLogging);\n\n const historySyncUrl =\n options?.historySyncUrl || HistorySyncUrls[options?.env || \"dev\"];\n\n return createWasmClient(\n host,\n inboxId,\n identifier,\n dbPath,\n encryptionKey,\n historySyncUrl,\n isLogging\n ? new LogOptions(\n options.structuredLogging ?? false,\n options.performanceLogging ?? false,\n options.loggingLevel,\n )\n : undefined,\n );\n};\n","import init, {\n type Consent,\n type Conversation,\n type Message,\n type StreamCloser,\n type UserPreference,\n} from \"@xmtp/wasm-bindings\";\nimport type {\n ClientEventsActions,\n ClientEventsClientMessageData,\n ClientEventsErrorData,\n ClientEventsWorkerPostMessageData,\n} from \"@/types\";\nimport type {\n ClientStreamEventsErrorData,\n ClientStreamEventsTypes,\n ClientStreamEventsWorkerPostMessageData,\n} from \"@/types/clientStreamEvents\";\nimport {\n fromEncodedContent,\n fromSafeEncodedContent,\n toSafeConsent,\n toSafeConversation,\n toSafeHmacKey,\n toSafeInboxState,\n toSafeMessage,\n toSafeMessageDisappearingSettings,\n} from \"@/utils/conversions\";\nimport { WorkerClient } from \"@/WorkerClient\";\nimport { WorkerConversation } from \"@/WorkerConversation\";\n\nlet maybeClient: WorkerClient | undefined;\nlet enableLogging = false;\n\nconst streamClosers = new Map<string, StreamCloser>();\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\n/**\n * Type-safe postMessage for streams\n */\nconst postStreamMessage = <A extends ClientStreamEventsTypes>(\n data: ClientStreamEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for stream errors\n */\nconst postStreamMessageError = (data: ClientStreamEventsErrorData) => {\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 // initialize WASM module\n await init();\n\n try {\n // init is a special action that initializes the client\n if (action === \"init\" && !maybeClient) {\n maybeClient = await WorkerClient.create(\n data.identifier,\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: maybeClient.inboxId,\n installationId: maybeClient.installationId,\n installationIdBytes: maybeClient.installationIdBytes,\n },\n });\n return;\n }\n\n // a client is required for all other actions\n if (!maybeClient) {\n throw new Error(\"Client not initialized\");\n }\n\n // let typescript know that a client will be available for the rest\n // of this code block\n const client = maybeClient;\n\n // helper function that throws an error if the group is not found\n const getGroup = (groupId: string) => {\n const group = client.conversations.getConversationById(groupId);\n if (!group) {\n throw new Error(`Group \"${groupId}\" not found`);\n }\n return group;\n };\n\n switch (action) {\n /**\n * Stream actions\n */\n case \"endStream\": {\n const streamCloser = streamClosers.get(data.streamId);\n if (streamCloser) {\n streamCloser.end();\n streamClosers.delete(data.streamId);\n postMessage({ id, action, result: undefined });\n } else {\n throw new Error(`Stream \"${data.streamId}\" not found`);\n }\n break;\n }\n /**\n * Client actions\n */\n case \"createInboxSignatureText\": {\n const result = client.createInboxSignatureText();\n postMessage({ id, action, result });\n break;\n }\n case \"addAccountSignatureText\": {\n const result = await client.addAccountSignatureText(data.newIdentifier);\n postMessage({ id, action, result });\n break;\n }\n case \"removeAccountSignatureText\": {\n const result = await client.removeAccountSignatureText(data.identifier);\n postMessage({ id, action, result });\n break;\n }\n case \"revokeAllOtherInstallationsSignatureText\": {\n const result = await client.revokeAllAOtherInstallationsSignatureText();\n postMessage({ id, action, result });\n break;\n }\n case \"revokeInstallationsSignatureText\": {\n const result = await client.revokeInstallationsSignatureText(\n data.installationIds,\n );\n postMessage({ id, action, result });\n break;\n }\n case \"addEcdsaSignature\":\n await client.addEcdsaSignature(data.type, data.bytes);\n postMessage({ id, action, result: undefined });\n break;\n case \"addScwSignature\":\n await client.addScwSignature(\n data.type,\n data.bytes,\n data.chainId,\n data.blockNumber,\n );\n postMessage({ id, action, result: undefined });\n break;\n case \"applySignatures\":\n await client.applySignatures();\n postMessage({ id, action, result: undefined });\n break;\n case \"registerIdentity\":\n await client.registerIdentity();\n postMessage({ id, action, result: undefined });\n break;\n case \"isRegistered\": {\n const result = client.isRegistered;\n postMessage({ id, action, result });\n break;\n }\n case \"canMessage\": {\n const result = await client.canMessage(data.identifiers);\n postMessage({ id, action, result });\n break;\n }\n case \"inboxState\": {\n const inboxState = await client.preferences.inboxState(\n data.refreshFromNetwork,\n );\n const result = toSafeInboxState(inboxState);\n postMessage({ id, action, result });\n break;\n }\n case \"getLatestInboxState\": {\n const inboxState = await client.preferences.getLatestInboxState(\n data.inboxId,\n );\n const result = toSafeInboxState(inboxState);\n postMessage({ id, action, result });\n break;\n }\n case \"setConsentStates\": {\n await client.preferences.setConsentStates(data.records);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"getConsentState\": {\n const result = await client.preferences.getConsentState(\n data.entityType,\n data.entity,\n );\n postMessage({ id, action, result });\n break;\n }\n case \"findInboxIdByIdentifier\": {\n const result = await client.findInboxIdByIdentifier(data.identifier);\n postMessage({ id, action, result });\n break;\n }\n case \"signWithInstallationKey\": {\n const result = client.signWithInstallationKey(data.signatureText);\n postMessage({ id, action, result });\n break;\n }\n case \"verifySignedWithInstallationKey\": {\n const result = client.verifySignedWithInstallationKey(\n data.signatureText,\n data.signatureBytes,\n );\n postMessage({ id, action, result });\n break;\n }\n case \"verifySignedWithPublicKey\": {\n const result = client.verifySignedWithPublicKey(\n data.signatureText,\n data.signatureBytes,\n data.publicKey,\n );\n postMessage({ id, action, result });\n break;\n }\n /**\n * Conversations actions\n */\n case \"streamAllGroups\": {\n const streamCallback = async (\n error: Error | null,\n value: Conversation | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"group\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"group\",\n streamId: data.streamId,\n result: value\n ? await toSafeConversation(\n new WorkerConversation(client, value),\n )\n : undefined,\n });\n }\n };\n const streamCloser = client.conversations.stream(\n streamCallback,\n data.conversationType,\n );\n streamClosers.set(data.streamId, streamCloser);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"streamAllMessages\": {\n const streamCallback = (\n error: Error | null,\n value: Message | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"message\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"message\",\n streamId: data.streamId,\n result: value ? toSafeMessage(value) : undefined,\n });\n }\n };\n const streamCloser = client.conversations.streamAllMessages(\n streamCallback,\n data.conversationType,\n );\n streamClosers.set(data.streamId, streamCloser);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"streamConsent\": {\n const streamCallback = (\n error: Error | null,\n value: Consent[] | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"consent\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"consent\",\n streamId: data.streamId,\n result: value?.map(toSafeConsent) ?? [],\n });\n }\n };\n const streamCloser = client.preferences.streamConsent(streamCallback);\n streamClosers.set(data.streamId, streamCloser);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"streamPreferences\": {\n const streamCallback = (\n error: Error | null,\n value: UserPreference[] | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"preferences\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"preferences\",\n streamId: data.streamId,\n result: value ?? undefined,\n });\n }\n };\n const streamCloser =\n client.preferences.streamPreferences(streamCallback);\n streamClosers.set(data.streamId, streamCloser);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConversations\": {\n const conversations = client.conversations.list(data.options);\n const result = await Promise.all(\n conversations.map((conversation) => toSafeConversation(conversation)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"getGroups\": {\n const conversations = client.conversations.listGroups(data.options);\n const result = await Promise.all(\n conversations.map((conversation) => toSafeConversation(conversation)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"getDms\": {\n const conversations = client.conversations.listDms(data.options);\n const result = await Promise.all(\n conversations.map((conversation) => toSafeConversation(conversation)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"newGroupWithIdentifiers\": {\n const conversation = await client.conversations.newGroupWithIdentifiers(\n data.identifiers,\n data.options,\n );\n const result = await toSafeConversation(conversation);\n postMessage({ id, action, result });\n break;\n }\n case \"newGroupWithInboxIds\": {\n const conversation = await client.conversations.newGroup(\n data.inboxIds,\n data.options,\n );\n const result = await toSafeConversation(conversation);\n postMessage({ id, action, result });\n break;\n }\n case \"newDmWithIdentifier\": {\n const conversation = await client.conversations.newDmWithIdentifier(\n data.identifier,\n data.options,\n );\n const result = await toSafeConversation(conversation);\n postMessage({ id, action, result });\n break;\n }\n case \"newDmWithInboxId\": {\n const conversation = await client.conversations.newDm(\n data.inboxId,\n data.options,\n );\n const result = await toSafeConversation(conversation);\n postMessage({ id, action, result });\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 \"syncAllConversations\": {\n await client.conversations.syncAll(data.consentStates);\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 const result = conversation\n ? await toSafeConversation(conversation)\n : undefined;\n postMessage({ id, action, result });\n break;\n }\n case \"getMessageById\": {\n const message = client.conversations.getMessageById(data.id);\n const result = message ? toSafeMessage(message) : undefined;\n postMessage({ id, action, result });\n break;\n }\n case \"getDmByInboxId\": {\n const conversation = client.conversations.getDmByInboxId(data.inboxId);\n const result = conversation\n ? await toSafeConversation(conversation)\n : undefined;\n postMessage({ id, action, result });\n break;\n }\n case \"getHmacKeys\": {\n const hmacKeys = client.conversations.getHmacKeys();\n const result = Object.fromEntries(\n Array.from(hmacKeys.entries()).map(([groupId, hmacKeys]) => [\n groupId,\n hmacKeys.map(toSafeHmacKey),\n ]),\n );\n postMessage({ id, action, result });\n break;\n }\n /**\n * Group actions\n */\n case \"syncGroup\": {\n const group = getGroup(data.id);\n await group.sync();\n const result = await toSafeConversation(group);\n postMessage({ id, action, result });\n break;\n }\n case \"updateGroupName\": {\n const group = getGroup(data.id);\n await group.updateName(data.name);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"updateGroupDescription\": {\n const group = getGroup(data.id);\n await group.updateDescription(data.description);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"updateGroupImageUrlSquare\": {\n const group = getGroup(data.id);\n await group.updateImageUrl(data.imageUrl);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"sendGroupMessage\": {\n const group = getGroup(data.id);\n const result = await group.send(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"sendOptimisticGroupMessage\": {\n const group = getGroup(data.id);\n const result = group.sendOptimistic(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({ id, action, result });\n break;\n }\n case \"publishGroupMessages\": {\n const group = getGroup(data.id);\n await group.publishMessages();\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"getGroupMessages\": {\n const group = getGroup(data.id);\n const messages = await group.messages(data.options);\n const result = messages.map((message) => toSafeMessage(message));\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupMembers\": {\n const group = getGroup(data.id);\n const result = await group.members();\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupAdmins\": {\n const group = getGroup(data.id);\n const result = group.admins;\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupSuperAdmins\": {\n const group = getGroup(data.id);\n const result = group.superAdmins;\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupConsentState\": {\n const group = getGroup(data.id);\n const result = group.consentState;\n postMessage({ id, action, result });\n break;\n }\n case \"updateGroupConsentState\": {\n const group = getGroup(data.id);\n group.updateConsentState(data.state);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"addGroupAdmin\": {\n const group = getGroup(data.id);\n await group.addAdmin(data.inboxId);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupAdmin\": {\n const group = getGroup(data.id);\n await group.removeAdmin(data.inboxId);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"addGroupSuperAdmin\": {\n const group = getGroup(data.id);\n await group.addSuperAdmin(data.inboxId);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupSuperAdmin\": {\n const group = getGroup(data.id);\n await group.removeSuperAdmin(data.inboxId);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"addGroupMembers\": {\n const group = getGroup(data.id);\n await group.addMembersByIdentifiers(data.identifiers);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupMembers\": {\n const group = getGroup(data.id);\n await group.removeMembersByIdentifiers(data.identifiers);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"addGroupMembersByInboxId\": {\n const group = getGroup(data.id);\n await group.addMembers(data.inboxIds);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupMembersByInboxId\": {\n const group = getGroup(data.id);\n await group.removeMembers(data.inboxIds);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"isGroupAdmin\": {\n const group = getGroup(data.id);\n const result = group.isAdmin(data.inboxId);\n postMessage({ id, action, result });\n break;\n }\n case \"isGroupSuperAdmin\": {\n const group = getGroup(data.id);\n const result = group.isSuperAdmin(data.inboxId);\n postMessage({ id, action, result });\n break;\n }\n case \"getDmPeerInboxId\": {\n const group = getGroup(data.id);\n const result = group.dmPeerInboxId();\n postMessage({ id, action, result });\n break;\n }\n case \"updateGroupPermissionPolicy\": {\n const group = getGroup(data.id);\n await group.updatePermission(\n data.permissionType,\n data.policy,\n data.metadataField,\n );\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"getGroupPermissions\": {\n const group = getGroup(data.id);\n const safeConversation = await toSafeConversation(group);\n const result = safeConversation.permissions;\n postMessage({ id, action, result });\n break;\n }\n case \"getGroupMessageDisappearingSettings\": {\n const group = getGroup(data.id);\n const settings = group.messageDisappearingSettings();\n const result = settings\n ? toSafeMessageDisappearingSettings(settings)\n : undefined;\n postMessage({ id, action, result });\n break;\n }\n case \"updateGroupMessageDisappearingSettings\": {\n const group = getGroup(data.id);\n await group.updateMessageDisappearingSettings(data.fromNs, data.inNs);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"removeGroupMessageDisappearingSettings\": {\n const group = getGroup(data.id);\n await group.removeMessageDisappearingSettings();\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"isGroupMessageDisappearingEnabled\": {\n const group = getGroup(data.id);\n const result = group.isMessageDisappearingEnabled();\n postMessage({ id, action, result });\n break;\n }\n case \"streamGroupMessages\": {\n const group = getGroup(data.groupId);\n const streamCallback = (\n error: Error | null,\n value: Message | undefined,\n ) => {\n if (error) {\n postStreamMessageError({\n type: \"message\",\n streamId: data.streamId,\n error: error.message,\n });\n } else {\n postStreamMessage({\n type: \"message\",\n streamId: data.streamId,\n result: value ? toSafeMessage(value) : undefined,\n });\n }\n };\n const streamCloser = group.stream(streamCallback);\n streamClosers.set(data.streamId, streamCloser);\n postMessage({ id, action, result: undefined });\n break;\n }\n case \"getGroupPausedForVersion\": {\n const group = getGroup(data.id);\n const result = group.pausedForVersion();\n postMessage({ id, action, result });\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","consentStates","createdAfterNs","createdBeforeNs","includeDuplicateDms","limit","fromSafeCreateGroupOptions","CreateGroupOptions","permissions","name","imageUrlSquare","description","customPermissionPolicySet","GroupPermissionsOptions","CustomPolicy","policySet","PermissionPolicySet","addMemberPolicy","removeMemberPolicy","addAdminPolicy","removeAdminPolicy","updateGroupNamePolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateMessageDisappearingPolicy","undefined","messageDisappearingSettings","fromSafeMessageDisappearingSettings","fromSafeCreateDmOptions","CreateDMOptions","toSafeConversation","async","conversation","imageUrl","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","policyType","toSafeInstallation","installation","bytes","clientTimestampNs","toSafeInboxState","inboxState","accountIdentifiers","inboxId","installations","map","recoveryIdentifier","toSafeConsent","consent","entity","entityType","state","fromSafeConsent","Consent","toSafeHmacKey","hmacKey","key","epoch","settings","MessageDisappearingSettings","fromNs","inNs","ApiUrls","local","dev","production","HistorySyncUrls","WorkerConversation","client","group","constructor","this","groupName","updateName","updateGroupName","groupImageUrlSquare","updateImageUrl","updateGroupImageUrlSquare","groupDescription","updateDescription","updateGroupDescription","groupMetadata","creatorInboxId","conversationType","members","listMembers","member","consentState","installationIds","permissionLevel","toSafeGroupMember","adminList","superAdminList","groupPermissions","updatePermission","permissionType","policy","metadataField","updatePermissionPolicy","isAdmin","isSuperAdmin","sync","addMembersByIdentifiers","identifiers","addMembers","inboxIds","addMembersByInboxId","removeMembersByIdentifiers","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","encodedContent","send","messages","findMessages","ListMessagesOptions","sentBeforeNs","sentAfterNs","direction","contentTypes","fromSafeListMessagesOptions","updateConsentState","dmPeerInboxId","updateMessageDisappearingSettings","removeMessageDisappearingSettings","isMessageDisappearingEnabled","stream","callback","on_message","on_error","error","pausedForVersion","WorkerConversations","conversations","syncAll","syncAllConversations","getConversationById","findGroupById","getMessageById","findMessageById","getDmByInboxId","findDmByTargetInboxId","list","item","listGroups","listDms","newGroupWithIdentifiers","createGroup","newGroup","createGroupByInboxIds","newDmWithIdentifier","identifier","createDm","newDm","createDmByInboxId","getHmacKeys","on_conversation","streamGroups","ConversationType","Group","streamDms","Dm","streamAllMessages","WorkerPreferences","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","streamConsent","on_consent_update","streamPreferences","on_user_preference_update","preferences","WorkerClient","create","encryptionKey","host","apiUrl","env","getInboxIdForIdentifier","generateInboxId","dbPath","isLogging","loggingLevel","structuredLogging","performanceLogging","createWasmClient","historySyncUrl","LogOptions","createClient","accountIdentifier","installationId","installationIdBytes","isRegistered","createInboxSignatureText","addAccountSignatureText","addWalletSignatureText","removeAccountSignatureText","revokeWalletSignatureText","revokeAllAOtherInstallationsSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addEcdsaSignature","addScwSignature","chainId","blockNumber","applySignatures","applySignatureRequests","canMessage","registerIdentity","findInboxIdByIdentifier","signWithInstallationKey","signatureText","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","maybeClient","enableLogging","streamClosers","postMessage","data","self","postStreamMessage","postStreamMessageError","onmessage","event","action","console","log","init","result","Error","getGroup","groupId","streamCloser","get","streamId","end","delete","newIdentifier","streamCallback","value","set","Promise","all","hmacKeys","Array","from","toSafeMessageDisappearingSettings","e","postMessageError"],"mappings":"0dAgCO,MAyDMA,EACXC,IAEA,WAAIC,GAjDJC,EAkDoBF,EAAQG,KAhD5B,IAAIC,EACFF,EAAcG,YACdH,EAAcI,OACdJ,EAAcK,aACdL,EAAcM,eA6Cd,IAAIC,IAAIC,OAAOC,QAAQX,EA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,CACrBrQ,KAAM,UACNkR,SAAUhB,EAAKgB,SACf5G,MAAOA,EAAMtJ,UAGfoP,EAAkB,CAChBpQ,KAAM,UACNkR,SAAUhB,EAAKgB,SACfN,OAAQW,EAAQxQ,EAAcwQ,QAASpO,KAIvC6N,EAAe5K,EAAM8D,OAAOoH,GAClCtB,EAAcwB,IAAItB,EAAKgB,SAAUF,GACjCf,EAAY,CAAE7O,KAAIoP,SAAQI,YAAQzN,IAClC,MAEF,IAAK,2BAA4B,CAC/B,MACMyN,EADQE,EAASZ,EAAK9O,IACPmJ,mBACrB0F,EAAY,CAAE7O,KAAIoP,SAAQI,WAC1B,QAGJ,MAAOmB,GArpBc,CAAC7B,IACxBC,KAAKF,YAAYC,EAAK,EAqpBpB8B,CAAiB,CACf5Q,KACAoP,SACAlG,MAAQyH,EAAY/Q"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmtp/browser-sdk",
3
- "version": "1.0.0-rc1",
3
+ "version": "1.0.0",
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": "^2.0.0",
66
66
  "@xmtp/content-type-text": "^2.0.0",
67
67
  "@xmtp/proto": "^3.72.3",
68
- "@xmtp/wasm-bindings": "^1.0.0-rc4",
68
+ "@xmtp/wasm-bindings": "^1.0.0",
69
69
  "uuid": "^11.0.3"
70
70
  },
71
71
  "devDependencies": {
@@ -95,6 +95,7 @@
95
95
  },
96
96
  "publishConfig": {
97
97
  "access": "public",
98
+ "provenance": true,
98
99
  "registry": "https://registry.npmjs.org/"
99
100
  }
100
101
  }
package/src/Client.ts CHANGED
@@ -10,16 +10,15 @@ import { TextCodec } from "@xmtp/content-type-text";
10
10
  import {
11
11
  GroupMessageKind,
12
12
  SignatureRequestType,
13
- type ConsentEntityType,
14
13
  type Identifier,
15
14
  } from "@xmtp/wasm-bindings";
16
15
  import { ClientWorkerClass } from "@/ClientWorkerClass";
17
16
  import { Conversations } from "@/Conversations";
17
+ import { Preferences } from "@/Preferences";
18
18
  import type { ClientOptions, XmtpEnv } from "@/types";
19
19
  import {
20
20
  fromSafeEncodedContent,
21
21
  toSafeEncodedContent,
22
- type SafeConsent,
23
22
  type SafeMessage,
24
23
  } from "@/utils/conversions";
25
24
  import { type Signer } from "@/utils/signer";
@@ -32,6 +31,7 @@ export class Client extends ClientWorkerClass {
32
31
  #installationId: string | undefined;
33
32
  #installationIdBytes: Uint8Array | undefined;
34
33
  #isReady = false;
34
+ #preferences: Preferences;
35
35
  #signer: Signer;
36
36
  options?: ClientOptions;
37
37
 
@@ -51,6 +51,7 @@ export class Client extends ClientWorkerClass {
51
51
  this.#encryptionKey = encryptionKey;
52
52
  this.#signer = signer;
53
53
  this.#conversations = new Conversations(this);
54
+ this.#preferences = new Preferences(this);
54
55
  const codecs = [
55
56
  new GroupUpdatedCodec(),
56
57
  new TextCodec(),
@@ -109,6 +110,14 @@ export class Client extends ClientWorkerClass {
109
110
  return this.#installationIdBytes;
110
111
  }
111
112
 
113
+ get conversations() {
114
+ return this.#conversations;
115
+ }
116
+
117
+ get preferences() {
118
+ return this.#preferences;
119
+ }
120
+
112
121
  /**
113
122
  * WARNING: This function should be used with caution. It is only provided
114
123
  * for use in special cases where the provided workflows do not meet the
@@ -376,28 +385,6 @@ export class Client extends ClientWorkerClass {
376
385
  return this.sendMessage("findInboxIdByIdentifier", { identifier });
377
386
  }
378
387
 
379
- async inboxState(refreshFromNetwork?: boolean) {
380
- return this.sendMessage("inboxState", {
381
- refreshFromNetwork: refreshFromNetwork ?? false,
382
- });
383
- }
384
-
385
- async getLatestInboxState(inboxId: string) {
386
- return this.sendMessage("getLatestInboxState", { inboxId });
387
- }
388
-
389
- async setConsentStates(records: SafeConsent[]) {
390
- return this.sendMessage("setConsentStates", { records });
391
- }
392
-
393
- async getConsentState(entityType: ConsentEntityType, entity: string) {
394
- return this.sendMessage("getConsentState", { entityType, entity });
395
- }
396
-
397
- get conversations() {
398
- return this.#conversations;
399
- }
400
-
401
388
  codecFor(contentType: ContentTypeId) {
402
389
  return this.#codecs.get(contentType.toString());
403
390
  }
@@ -2,7 +2,6 @@ import {
2
2
  ConversationType,
3
3
  type ConsentState,
4
4
  type Identifier,
5
- type UserPreference,
6
5
  } from "@xmtp/wasm-bindings";
7
6
  import { v4 } from "uuid";
8
7
  import { AsyncStream, type StreamCallback } from "@/AsyncStream";
@@ -11,7 +10,6 @@ import { DecodedMessage } from "@/DecodedMessage";
11
10
  import { Dm } from "@/Dm";
12
11
  import { Group } from "@/Group";
13
12
  import type {
14
- SafeConsent,
15
13
  SafeConversation,
16
14
  SafeCreateDmOptions,
17
15
  SafeCreateGroupOptions,
@@ -241,48 +239,4 @@ export class Conversations {
241
239
  async streamAllDmMessages(callback?: StreamCallback<DecodedMessage>) {
242
240
  return this.streamAllMessages(callback, ConversationType.Dm);
243
241
  }
244
-
245
- async streamConsent(callback?: StreamCallback<SafeConsent[]>) {
246
- const streamId = v4();
247
- const asyncStream = new AsyncStream<SafeConsent[]>();
248
- const endStream = this.#client.handleStreamMessage<SafeConsent[]>(
249
- streamId,
250
- (error, value) => {
251
- void asyncStream.callback(error, value ?? undefined);
252
- void callback?.(error, value ?? undefined);
253
- },
254
- );
255
- await this.#client.sendMessage("streamConsent", {
256
- streamId,
257
- });
258
- asyncStream.onReturn = () => {
259
- void this.#client.sendMessage("endStream", {
260
- streamId,
261
- });
262
- endStream();
263
- };
264
- return asyncStream;
265
- }
266
-
267
- async streamPreferences(callback?: StreamCallback<UserPreference[]>) {
268
- const streamId = v4();
269
- const asyncStream = new AsyncStream<UserPreference[]>();
270
- const endStream = this.#client.handleStreamMessage<UserPreference[]>(
271
- streamId,
272
- (error, value) => {
273
- void asyncStream.callback(error, value ?? undefined);
274
- void callback?.(error, value ?? undefined);
275
- },
276
- );
277
- await this.#client.sendMessage("streamPreferences", {
278
- streamId,
279
- });
280
- asyncStream.onReturn = () => {
281
- void this.#client.sendMessage("endStream", {
282
- streamId,
283
- });
284
- endStream();
285
- };
286
- return asyncStream;
287
- }
288
242
  }