@xmtp/browser-sdk 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _xmtp_wasm_bindings from '@xmtp/wasm-bindings';
2
- import { SignatureRequestType, ConsentState, ConsentEntityType, PermissionUpdateType, PermissionPolicy, MetadataField, Conversations as Conversations$1, Client as Client$1, Conversation as Conversation$1, EncodedContent, ContentTypeId, DeliveryStatus, GroupMessageKind, Message, SortDirection, ListMessagesOptions, GroupMembershipState, ConversationType, ListConversationsOptions, PermissionPolicySet, GroupPermissionsOptions, CreateGroupOptions, Installation, InboxState, Consent, PermissionLevel, GroupMember } from '@xmtp/wasm-bindings';
3
- export { Consent, ConsentEntityType, ConsentState, ContentTypeId, ConversationType, CreateGroupOptions, DeliveryStatus, EncodedContent, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, InboxState, Installation, ListConversationsOptions, ListMessagesOptions, Message, MetadataField, PermissionLevel, PermissionPolicy, PermissionPolicySet, PermissionUpdateType, SignatureRequestType, SortDirection } from '@xmtp/wasm-bindings';
2
+ import { SignatureRequestType, ConsentState, ConsentEntityType, PermissionUpdateType, PermissionPolicy, MetadataField, Conversations as Conversations$1, Client as Client$1, Conversation as Conversation$1, EncodedContent, ContentTypeId, DeliveryStatus, GroupMessageKind, Message, SortDirection, ListMessagesOptions, GroupMembershipState, ConversationType, ListConversationsOptions, PermissionPolicySet, GroupPermissionsOptions, CreateGroupOptions, Installation, InboxState, Consent, PermissionLevel, GroupMember, HmacKey } from '@xmtp/wasm-bindings';
3
+ export { Consent, ConsentEntityType, ConsentState, ContentTypeId, ConversationType, CreateGroupOptions, DeliveryStatus, EncodedContent, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, HmacKey, InboxState, Installation, ListConversationsOptions, ListMessagesOptions, Message, MetadataField, PermissionLevel, PermissionPolicy, PermissionPolicySet, PermissionUpdateType, SignatureRequestType, SortDirection } from '@xmtp/wasm-bindings';
4
4
  import { ContentCodec, ContentTypeId as ContentTypeId$1, EncodedContent as EncodedContent$1 } from '@xmtp/content-type-primitives';
5
5
 
6
6
  declare const ApiUrls: {
@@ -278,6 +278,11 @@ type ClientEvents =
278
278
  id: string;
279
279
  result: undefined;
280
280
  data: undefined;
281
+ } | {
282
+ action: "getHmacKeys";
283
+ id: string;
284
+ result: SafeHmacKeys;
285
+ data: undefined;
281
286
  }
282
287
  /**
283
288
  * Group actions
@@ -576,6 +581,7 @@ declare class WorkerConversations {
576
581
  listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">): WorkerConversation[];
577
582
  newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions): Promise<WorkerConversation>;
578
583
  newDm(accountAddress: string): Promise<WorkerConversation>;
584
+ getHmacKeys(): HmacKeys;
579
585
  }
580
586
 
581
587
  declare class WorkerClient {
@@ -713,6 +719,7 @@ type SafePermissionPolicySet = {
713
719
  updateGroupImageUrlSquarePolicy: PermissionPolicy;
714
720
  updateGroupNamePolicy: PermissionPolicy;
715
721
  updateGroupPinnedFrameUrlPolicy: PermissionPolicy;
722
+ updateMessageExpirationPolicy: PermissionPolicy;
716
723
  };
717
724
  declare const toSafePermissionPolicySet: (policySet: PermissionPolicySet) => SafePermissionPolicySet;
718
725
  declare const fromSafePermissionPolicySet: (policySet: SafePermissionPolicySet) => PermissionPolicySet;
@@ -743,6 +750,7 @@ type SafeConversation = {
743
750
  updateGroupImageUrlSquarePolicy: PermissionPolicy;
744
751
  updateGroupNamePolicy: PermissionPolicy;
745
752
  updateGroupPinnedFrameUrlPolicy: PermissionPolicy;
753
+ updateMessageExpirationPolicy: PermissionPolicy;
746
754
  };
747
755
  };
748
756
  isActive: boolean;
@@ -757,8 +765,9 @@ type SafeConversation = {
757
765
  };
758
766
  declare const toSafeConversation: (conversation: WorkerConversation) => Promise<SafeConversation>;
759
767
  type SafeInstallation = {
760
- id: string;
768
+ bytes: Uint8Array;
761
769
  clientTimestampNs?: bigint;
770
+ id: string;
762
771
  };
763
772
  declare const toSafeInstallation: (installation: Installation) => SafeInstallation;
764
773
  type SafeInboxState = {
@@ -784,6 +793,13 @@ type SafeGroupMember = {
784
793
  };
785
794
  declare const toSafeGroupMember: (member: GroupMember) => SafeGroupMember;
786
795
  declare const fromSafeGroupMember: (member: SafeGroupMember) => GroupMember;
796
+ type SafeHmacKey = {
797
+ key: Uint8Array;
798
+ epoch: bigint;
799
+ };
800
+ declare const toSafeHmacKey: (hmacKey: HmacKey) => SafeHmacKey;
801
+ type HmacKeys = Map<string, HmacKey[]>;
802
+ type SafeHmacKeys = Record<string, SafeHmacKey[]>;
787
803
 
788
804
  declare class ClientWorkerClass {
789
805
  #private;
@@ -848,6 +864,7 @@ declare class Conversation {
848
864
  updateGroupImageUrlSquarePolicy: PermissionPolicy;
849
865
  updateGroupNamePolicy: PermissionPolicy;
850
866
  updateGroupPinnedFrameUrlPolicy: PermissionPolicy;
867
+ updateMessageExpirationPolicy: PermissionPolicy;
851
868
  };
852
869
  }>;
853
870
  updatePermission(permissionType: PermissionUpdateType, policy: PermissionPolicy, metadataField?: MetadataField): Promise<undefined>;
@@ -884,6 +901,7 @@ declare class Conversations {
884
901
  listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">): Promise<Conversation[]>;
885
902
  newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions): Promise<Conversation>;
886
903
  newDm(accountAddress: string): Promise<Conversation>;
904
+ getHmacKeys(): Promise<SafeHmacKeys>;
887
905
  }
888
906
 
889
907
  type SignMessage = (message: string) => Promise<Uint8Array> | Uint8Array;
@@ -947,4 +965,4 @@ declare class Utils extends UtilsWorkerClass {
947
965
  getInboxIdForAddress(address: string, env?: XmtpEnv): Promise<string | undefined>;
948
966
  }
949
967
 
950
- export { ApiUrls, Client, type ClientEvents, type ClientEventsActions, type ClientEventsClientMessageData, type ClientEventsClientPostMessageData, type ClientEventsErrorData, type ClientEventsResult, type ClientEventsWorkerMessageData, type ClientEventsWorkerPostMessageData, type ClientOptions, type ClientSendMessageData, type ContentOptions, Conversation, Conversations, DecodedMessage, type EventsClientMessageData, type EventsClientPostMessageData, type EventsErrorData, type EventsResult, type EventsWorkerMessageData, type EventsWorkerPostMessageData, type GenericEvent, type MessageDeliveryStatus, type MessageKind, type NetworkOptions, type OtherOptions, type SafeConsent, type SafeContentTypeId, type SafeConversation, type SafeCreateGroupOptions, type SafeEncodedContent, type SafeGroupMember, type SafeInboxState, type SafeInstallation, type SafeListConversationsOptions, type SafeListMessagesOptions, type SafeMessage, type SafePermissionPolicySet, type SendMessageData, type Signer, type SmartContractSigner, type StorageOptions, Utils, type UtilsEvents, type UtilsEventsActions, type UtilsEventsClientMessageData, type UtilsEventsClientPostMessageData, type UtilsEventsErrorData, type UtilsEventsResult, type UtilsEventsWorkerMessageData, type UtilsEventsWorkerPostMessageData, type UtilsSendMessageData, type XmtpEnv, fromContentTypeId, fromEncodedContent, fromSafeConsent, fromSafeContentTypeId, fromSafeCreateGroupOptions, fromSafeEncodedContent, fromSafeGroupMember, fromSafeListConversationsOptions, fromSafeListMessagesOptions, fromSafePermissionPolicySet, isSmartContractSigner, toContentTypeId, toEncodedContent, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeInboxState, toSafeInstallation, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage, toSafePermissionPolicySet };
968
+ export { ApiUrls, Client, type ClientEvents, type ClientEventsActions, type ClientEventsClientMessageData, type ClientEventsClientPostMessageData, type ClientEventsErrorData, type ClientEventsResult, type ClientEventsWorkerMessageData, type ClientEventsWorkerPostMessageData, type ClientOptions, type ClientSendMessageData, type ContentOptions, Conversation, Conversations, DecodedMessage, type EventsClientMessageData, type EventsClientPostMessageData, type EventsErrorData, type EventsResult, type EventsWorkerMessageData, type EventsWorkerPostMessageData, type GenericEvent, type HmacKeys, type MessageDeliveryStatus, type MessageKind, type NetworkOptions, type OtherOptions, type SafeConsent, type SafeContentTypeId, type SafeConversation, type SafeCreateGroupOptions, type SafeEncodedContent, type SafeGroupMember, type SafeHmacKey, type SafeHmacKeys, type SafeInboxState, type SafeInstallation, type SafeListConversationsOptions, type SafeListMessagesOptions, type SafeMessage, type SafePermissionPolicySet, type SendMessageData, type Signer, type SmartContractSigner, type StorageOptions, Utils, type UtilsEvents, type UtilsEventsActions, type UtilsEventsClientMessageData, type UtilsEventsClientPostMessageData, type UtilsEventsErrorData, type UtilsEventsResult, type UtilsEventsWorkerMessageData, type UtilsEventsWorkerPostMessageData, type UtilsSendMessageData, type XmtpEnv, fromContentTypeId, fromEncodedContent, fromSafeConsent, fromSafeContentTypeId, fromSafeCreateGroupOptions, fromSafeEncodedContent, fromSafeGroupMember, fromSafeListConversationsOptions, fromSafeListMessagesOptions, fromSafePermissionPolicySet, isSmartContractSigner, toContentTypeId, toEncodedContent, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeHmacKey, toSafeInboxState, toSafeInstallation, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage, toSafePermissionPolicySet };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{GroupUpdatedCodec as e,ContentTypeGroupUpdated as t}from"@xmtp/content-type-group-updated";import{ContentTypeText as s,TextCodec as n}from"@xmtp/content-type-text";import{ContentTypeId as i,EncodedContent as r,ListMessagesOptions as a,ListConversationsOptions as o,PermissionPolicySet as d,CreateGroupOptions as c,GroupPermissionsOptions as l,Consent as p,GroupMember as u,GroupMessageKind as m,DeliveryStatus as g,SignatureRequestType as h}from"@xmtp/wasm-bindings";export{Consent,ConsentEntityType,ConsentState,ContentTypeId,ConversationType,CreateGroupOptions,DeliveryStatus,EncodedContent,GroupMember,GroupMembershipState,GroupMessageKind,GroupMetadata,GroupPermissions,GroupPermissionsOptions,InboxState,Installation,ListConversationsOptions,ListMessagesOptions,Message,MetadataField,PermissionLevel,PermissionPolicy,PermissionPolicySet,PermissionUpdateType,SignatureRequestType,SortDirection}from"@xmtp/wasm-bindings";import{v4 as y}from"uuid";import{ContentTypeId as I}from"@xmtp/content-type-primitives";const v=e=>{console.error(`Worker error on line ${e.lineno} in "${e.filename}"`),console.error(e.message)};class w{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),this.#e.addEventListener("error",v),this.#t=t}sendMessage(e,t){const s=y();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("client received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(new Error(t.error)):s.resolve(t.result))};close(){this.#e.removeEventListener("message",this.handleMessage),this.#e.removeEventListener("error",v),this.#e.terminate()}}const b=e=>new I({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),M=e=>new i(e.authorityId,e.typeId,e.versionMajor,e.versionMinor),A=e=>({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),S=e=>new I({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),x=e=>({type:b(e.type),parameters:Object.fromEntries(e.parameters),fallback:e.fallback,compression:e.compression,content:e.content}),P=e=>new r(M(e.type),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content),k=e=>({type:A(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),f=e=>({type:S(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),G=e=>({content:k(x(e.content)),convoId:e.convoId,deliveryStatus:e.deliveryStatus,id:e.id,kind:e.kind,senderInboxId:e.senderInboxId,sentAtNs:e.sentAtNs}),U=e=>({deliveryStatus:e.deliveryStatus,direction:e.direction,limit:e.limit,sentAfterNs:e.sentAfterNs,sentBeforeNs:e.sentBeforeNs}),N=e=>new a(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction),C=e=>({allowedStates:e.allowedStates,conversationType:e.conversationType,createdAfterNs:e.createdAfterNs,createdBeforeNs:e.createdBeforeNs,limit:e.limit}),T=e=>new o(e.allowedStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.limit),B=e=>({addAdminPolicy:e.addAdminPolicy,addMemberPolicy:e.addMemberPolicy,removeAdminPolicy:e.removeAdminPolicy,removeMemberPolicy:e.removeMemberPolicy,updateGroupDescriptionPolicy:e.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.updateGroupPinnedFrameUrlPolicy}),L=e=>new d(e.addMemberPolicy,e.removeMemberPolicy,e.addAdminPolicy,e.removeAdminPolicy,e.updateGroupNamePolicy,e.updateGroupDescriptionPolicy,e.updateGroupImageUrlSquarePolicy,e.updateGroupPinnedFrameUrlPolicy),F=e=>({description:e.groupDescription,imageUrlSquare:e.groupImageUrlSquare,name:e.groupName,pinnedFrameUrl:e.groupPinnedFrameUrl,permissions:e.permissions,customPermissionPolicySet:e.customPermissionPolicySet}),E=e=>new c(e.permissions,e.name,e.imageUrlSquare,e.description,e.pinnedFrameUrl,e.customPermissionPolicySet&&e.permissions===l.CustomPolicy?L(e.customPermissionPolicySet):void 0),D=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,pinnedFrameUrl:e.pinnedFrameUrl,permissions:{policyType:e.permissions.policyType,policySet:{addAdminPolicy:e.permissions.policySet.addAdminPolicy,addMemberPolicy:e.permissions.policySet.addMemberPolicy,removeAdminPolicy:e.permissions.policySet.removeAdminPolicy,removeMemberPolicy:e.permissions.policySet.removeMemberPolicy,updateGroupDescriptionPolicy:e.permissions.policySet.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.permissions.policySet.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.permissions.policySet.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.permissions.policySet.updateGroupPinnedFrameUrlPolicy}},isActive:e.isActive,addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.admins,superAdmins:e.superAdmins,createdAtNs:e.createdAtNs}),R=e=>({id:e.id,clientTimestampNs:e.clientTimestampNs}),j=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(R),recoveryAddress:e.recoveryAddress}),O=e=>({entity:e.entity,entityType:e.entityType,state:e.state}),q=e=>new p(e.entityType,e.state,e.entity),K=e=>({accountAddresses:e.accountAddresses,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}),W=e=>new u(e.inboxId,e.accountAddresses,e.installationIds,e.permissionLevel,e.consentState);class ${#n;content;contentType;conversationId;deliveryStatus;fallback;compression;id;kind;parameters;encodedContent;senderInboxId;sentAtNs;constructor(e,t){switch(this.#n=e,this.id=t.id,this.sentAtNs=t.sentAtNs,this.conversationId=t.convoId,this.senderInboxId=t.senderInboxId,this.encodedContent=t.content,t.kind){case m.Application:this.kind="application";break;case m.MembershipChange:this.kind="membership_change"}switch(t.deliveryStatus){case g.Unpublished:this.deliveryStatus="unpublished";break;case g.Published:this.deliveryStatus="published";break;case g.Failed:this.deliveryStatus="failed"}this.contentType=S(t.content.type),this.parameters=new Map(Object.entries(t.content.parameters)),this.fallback=t.content.fallback,this.compression=t.content.compression,this.content=this.#n.decodeContent(t,this.contentType)}}class V{#n;#i;#r;#a;#o;#d;#c;#l;#p;#u;#m=[];#g=[];constructor(e,t,s){this.#n=e,this.#i=t,this.#h(s)}#h(e){this.#r=e?.name??"",this.#a=e?.imageUrl??"",this.#o=e?.description??"",this.#d=e?.pinnedFrameUrl??"",this.#c=e?.isActive??void 0,this.#l=e?.addedByInboxId??"",this.#p=e?.metadata??void 0,this.#u=e?.createdAtNs??void 0,this.#m=e?.admins??[],this.#g=e?.superAdmins??[]}get id(){return this.#i}get name(){return this.#r}async updateName(e){await this.#n.sendMessage("updateGroupName",{id:this.#i,name:e}),this.#r=e}get imageUrl(){return this.#a}async updateImageUrl(e){await this.#n.sendMessage("updateGroupImageUrlSquare",{id:this.#i,imageUrl:e}),this.#a=e}get description(){return this.#o}async updateDescription(e){await this.#n.sendMessage("updateGroupDescription",{id:this.#i,description:e}),this.#o=e}get pinnedFrameUrl(){return this.#d}async updatePinnedFrameUrl(e){await this.#n.sendMessage("updateGroupPinnedFrameUrl",{id:this.#i,pinnedFrameUrl:e}),this.#d=e}get isActive(){return this.#c}get addedByInboxId(){return this.#l}get createdAtNs(){return this.#u}get createdAt(){return this.#u?(e=this.#u,new Date(Number(e/1000000n))):void 0;var e}get metadata(){return this.#p}async members(){return this.#n.sendMessage("getGroupMembers",{id:this.#i})}get admins(){return this.#m}get superAdmins(){return this.#g}async syncAdmins(){const e=await this.#n.sendMessage("getGroupAdmins",{id:this.#i});this.#m=e}async syncSuperAdmins(){const e=await this.#n.sendMessage("getGroupSuperAdmins",{id:this.#i});this.#g=e}async permissions(){return this.#n.sendMessage("getGroupPermissions",{id:this.#i})}async updatePermission(e,t,s){return this.#n.sendMessage("updateGroupPermissionPolicy",{id:this.#i,permissionType:e,policy:t,metadataField:s})}async isAdmin(e){return await this.syncAdmins(),this.#m.includes(e)}async isSuperAdmin(e){return await this.syncSuperAdmins(),this.#g.includes(e)}async sync(){const e=await this.#n.sendMessage("syncGroup",{id:this.#i});this.#h(e)}async addMembers(e){return this.#n.sendMessage("addGroupMembers",{id:this.#i,accountAddresses:e})}async addMembersByInboxId(e){return this.#n.sendMessage("addGroupMembersByInboxId",{id:this.#i,inboxIds:e})}async removeMembers(e){return this.#n.sendMessage("removeGroupMembers",{id:this.#i,accountAddresses:e})}async removeMembersByInboxId(e){return this.#n.sendMessage("removeGroupMembersByInboxId",{id:this.#i,inboxIds:e})}async addAdmin(e){return this.#n.sendMessage("addGroupAdmin",{id:this.#i,inboxId:e})}async removeAdmin(e){return this.#n.sendMessage("removeGroupAdmin",{id:this.#i,inboxId:e})}async addSuperAdmin(e){return this.#n.sendMessage("addGroupSuperAdmin",{id:this.#i,inboxId:e})}async removeSuperAdmin(e){return this.#n.sendMessage("removeGroupSuperAdmin",{id:this.#i,inboxId:e})}async publishMessages(){return this.#n.sendMessage("publishGroupMessages",{id:this.#i})}async sendOptimistic(e,t){if("string"!=typeof e&&!t)throw new Error("Content type is required when sending content other than text");const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("sendOptimisticGroupMessage",{id:this.#i,content:n})}async send(e,t){if("string"!=typeof e&&!t)throw new Error("Content type is required when sending content other than text");const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("sendGroupMessage",{id:this.#i,content:n})}async messages(e){return(await this.#n.sendMessage("getGroupMessages",{id:this.#i,options:e})).map((e=>new $(this.#n,e)))}async consentState(){return this.#n.sendMessage("getGroupConsentState",{id:this.#i})}async updateConsentState(e){return this.#n.sendMessage("updateGroupConsentState",{id:this.#i,state:e})}async dmPeerInboxId(){return this.#n.sendMessage("getDmPeerInboxId",{id:this.#i})}}class _{#n;constructor(e){this.#n=e}async sync(){return this.#n.sendMessage("syncConversations",void 0)}async syncAll(){return this.#n.sendMessage("syncAllConversations",void 0)}async getConversationById(e){const t=await this.#n.sendMessage("getConversationById",{id:e});return t?new V(this.#n,e,t):void 0}async getMessageById(e){const t=await this.#n.sendMessage("getMessageById",{id:e});return t?new $(this.#n,t):void 0}async getDmByInboxId(e){const t=await this.#n.sendMessage("getDmByInboxId",{inboxId:e});return t?new V(this.#n,t.id,t):void 0}async list(e){return(await this.#n.sendMessage("getConversations",{options:e})).map((e=>new V(this.#n,e.id,e)))}async listGroups(e){return(await this.#n.sendMessage("getGroups",{options:e})).map((e=>new V(this.#n,e.id,e)))}async listDms(e){return(await this.#n.sendMessage("getDms",{options:e})).map((e=>new V(this.#n,e.id,e)))}async newGroup(e,t){const s=await this.#n.sendMessage("newGroup",{accountAddresses:e,options:t});return new V(this.#n,s.id,s)}async newDm(e){const t=await this.#n.sendMessage("newDm",{accountAddress:e});return new V(this.#n,t.id,t)}}const z=e=>"getBlockNumber"in e&&"getChainId"in e;class H extends w{#y;#I;#v;#w;#b;#M;#A;#S=!1;#x;options;constructor(t,s,i,r){super(new Worker(new URL("./workers/client",import.meta.url),{type:"module"}),void 0!==r?.loggingLevel&&"off"!==r.loggingLevel),this.#y=s,this.options=r,this.#w=i,this.#x=t,this.#v=new _(this);const a=[new e,new n,...r?.codecs??[]];this.#I=new Map(a.map((e=>[e.contentType.toString(),e])))}get accountAddress(){return this.#y}async init(){const e=await this.sendMessage("init",{address:this.accountAddress,encryptionKey:this.#w,options:this.options});this.#b=e.inboxId,this.#M=e.installationId,this.#A=e.installationIdBytes,this.#S=!0}static async create(e,t,s){const n=await e.getAddress(),i=new H(e,n,t,s);return await i.init(),s?.disableAutoRegister||await i.register(),i}get isReady(){return this.#S}get inboxId(){return this.#b}get installationId(){return this.#M}get installationIdBytes(){return this.#A}async#P(){return this.sendMessage("createInboxSignatureText",void 0)}async#k(e){return this.sendMessage("addAccountSignatureText",{newAccountAddress:e})}async#f(e){return this.sendMessage("removeAccountSignatureText",{accountAddress:e})}async#G(){return this.sendMessage("revokeAllOtherInstallationsSignatureText",void 0)}async#U(e){return this.sendMessage("revokeInstallationsSignatureText",{installationIds:e})}async#N(e,t,s){const n=await s.signMessage(t);z(s)?await this.sendMessage("addScwSignature",{type:e,bytes:n,chainId:s.getChainId(),blockNumber:s.getBlockNumber()}):await this.sendMessage("addSignature",{type:e,bytes:n})}async#C(){return this.sendMessage("applySignatures",void 0)}async register(){const e=await this.#P();if(e)return await this.#N(h.CreateInbox,e,this.#x),this.sendMessage("registerIdentity",void 0)}async addAccount(e){const t=await this.#k(await e.getAddress());if(!t)throw new Error("Unable to generate add account signature text");await this.#N(h.AddWallet,t,e),await this.#C()}async removeAccount(e){const t=await this.#f(e);if(!t)throw new Error("Unable to generate remove account signature text");await this.#N(h.RevokeWallet,t,this.#x),await this.#C()}async revokeAllOtherInstallations(){const e=await this.#G();if(!e)throw new Error("Unable to generate revoke all other installations signature text");await this.#N(h.RevokeInstallations,e,this.#x),await this.#C()}async revokeInstallations(e){const t=await this.#U(e);if(!t)throw new Error("Unable to generate revoke installations signature text");await this.#N(h.RevokeInstallations,t,this.#x),await this.#C()}async isRegistered(){return this.sendMessage("isRegistered",void 0)}async canMessage(e){return this.sendMessage("canMessage",{accountAddresses:e})}static async canMessage(e,t){const s={getAddress:()=>"0x0000000000000000000000000000000000000000",signMessage:()=>new Uint8Array};return(await H.create(s,window.crypto.getRandomValues(new Uint8Array(32)),{disableAutoRegister:!0,env:t})).canMessage(e)}async findInboxIdByAddress(e){return this.sendMessage("findInboxIdByAddress",{address:e})}async inboxState(e){return this.sendMessage("inboxState",{refreshFromNetwork:e??!1})}async getLatestInboxState(e){return this.sendMessage("getLatestInboxState",{inboxId:e})}async setConsentStates(e){return this.sendMessage("setConsentStates",{records:e})}async getConsentState(e,t){return this.sendMessage("getConsentState",{entityType:e,entity:t})}get conversations(){return this.#v}codecFor(e){return this.#I.get(e.toString())}encodeContent(e,t){const s=this.codecFor(t);if(!s)throw new Error(`Codec not found for "${t.toString()}" content type`);const n=s.encode(e,this),i=s.fallback(e);return i&&(n.fallback=i),k(n)}decodeContent(e,s){const n=this.codecFor(s);if(!n)throw new Error(`Codec not found for "${s.toString()}" content type`);if(s.sameAs(t)&&e.kind!==m.MembershipChange)throw new Error("Error decoding group membership change");const i=f(e.content);return n.decode(i,this)}signWithInstallationKey(e){return this.sendMessage("signWithInstallationKey",{signatureText:e})}verifySignedWithInstallationKey(e,t){return this.sendMessage("verifySignedWithInstallationKey",{signatureText:e,signatureBytes:t})}verifySignedWithPublicKey(e,t,s){return this.sendMessage("verifySignedWithPublicKey",{signatureText:e,signatureBytes:t,publicKey:s})}}const J=e=>{console.error(`Worker error on line ${e.lineno} in "${e.filename}"`),console.error(e.message)};class Q{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),this.#e.addEventListener("error",J),this.#t=t}sendMessage(e,t){const s=y();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("utils received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(new Error(t.error)):s.resolve(t.result))};close(){this.#e.removeEventListener("message",this.handleMessage),this.#e.removeEventListener("error",J),this.#e.terminate()}}class X extends Q{#t;constructor(e){super(new Worker(new URL("./workers/utils",import.meta.url),{type:"module"}),e??!1),this.#t=e??!1}async generateInboxId(e){return this.sendMessage("generateInboxId",{address:e,enableLogging:this.#t})}async getInboxIdForAddress(e,t){return this.sendMessage("getInboxIdForAddress",{address:e,env:t,enableLogging:this.#t})}}const Y={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"};export{Y as ApiUrls,H as Client,V as Conversation,_ as Conversations,$ as DecodedMessage,X as Utils,M as fromContentTypeId,P as fromEncodedContent,q as fromSafeConsent,S as fromSafeContentTypeId,E as fromSafeCreateGroupOptions,f as fromSafeEncodedContent,W as fromSafeGroupMember,T as fromSafeListConversationsOptions,N as fromSafeListMessagesOptions,L as fromSafePermissionPolicySet,z as isSmartContractSigner,b as toContentTypeId,x as toEncodedContent,O as toSafeConsent,A as toSafeContentTypeId,D as toSafeConversation,F as toSafeCreateGroupOptions,k as toSafeEncodedContent,K as toSafeGroupMember,j as toSafeInboxState,R as toSafeInstallation,C as toSafeListConversationsOptions,U as toSafeListMessagesOptions,G as toSafeMessage,B as toSafePermissionPolicySet};
1
+ import{GroupUpdatedCodec as e,ContentTypeGroupUpdated as t}from"@xmtp/content-type-group-updated";import{ContentTypeText as s,TextCodec as n}from"@xmtp/content-type-text";import{ContentTypeId as i,EncodedContent as r,ListMessagesOptions as a,ListConversationsOptions as o,PermissionPolicySet as d,CreateGroupOptions as c,GroupPermissionsOptions as l,Consent as p,GroupMember as u,GroupMessageKind as m,DeliveryStatus as g,SignatureRequestType as h}from"@xmtp/wasm-bindings";export{Consent,ConsentEntityType,ConsentState,ContentTypeId,ConversationType,CreateGroupOptions,DeliveryStatus,EncodedContent,GroupMember,GroupMembershipState,GroupMessageKind,GroupMetadata,GroupPermissions,GroupPermissionsOptions,HmacKey,InboxState,Installation,ListConversationsOptions,ListMessagesOptions,Message,MetadataField,PermissionLevel,PermissionPolicy,PermissionPolicySet,PermissionUpdateType,SignatureRequestType,SortDirection}from"@xmtp/wasm-bindings";import{v4 as y}from"uuid";import{ContentTypeId as I}from"@xmtp/content-type-primitives";const v=e=>{console.error(`Worker error on line ${e.lineno} in "${e.filename}"`),console.error(e.message)};class w{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),this.#e.addEventListener("error",v),this.#t=t}sendMessage(e,t){const s=y();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("client received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(new Error(t.error)):s.resolve(t.result))};close(){this.#e.removeEventListener("message",this.handleMessage),this.#e.removeEventListener("error",v),this.#e.terminate()}}const b=e=>new I({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),M=e=>new i(e.authorityId,e.typeId,e.versionMajor,e.versionMinor),A=e=>({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),S=e=>new I({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),x=e=>({type:b(e.type),parameters:Object.fromEntries(e.parameters),fallback:e.fallback,compression:e.compression,content:e.content}),P=e=>new r(M(e.type),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content),k=e=>({type:A(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),f=e=>({type:S(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),G=e=>({content:k(x(e.content)),convoId:e.convoId,deliveryStatus:e.deliveryStatus,id:e.id,kind:e.kind,senderInboxId:e.senderInboxId,sentAtNs:e.sentAtNs}),U=e=>({deliveryStatus:e.deliveryStatus,direction:e.direction,limit:e.limit,sentAfterNs:e.sentAfterNs,sentBeforeNs:e.sentBeforeNs}),N=e=>new a(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction),C=e=>({allowedStates:e.allowedStates,conversationType:e.conversationType,createdAfterNs:e.createdAfterNs,createdBeforeNs:e.createdBeforeNs,limit:e.limit}),T=e=>new o(e.allowedStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.limit),B=e=>({addAdminPolicy:e.addAdminPolicy,addMemberPolicy:e.addMemberPolicy,removeAdminPolicy:e.removeAdminPolicy,removeMemberPolicy:e.removeMemberPolicy,updateGroupDescriptionPolicy:e.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.updateGroupPinnedFrameUrlPolicy,updateMessageExpirationPolicy:e.updateMessageExpirationPolicy}),L=e=>new d(e.addMemberPolicy,e.removeMemberPolicy,e.addAdminPolicy,e.removeAdminPolicy,e.updateGroupNamePolicy,e.updateGroupDescriptionPolicy,e.updateGroupImageUrlSquarePolicy,e.updateGroupPinnedFrameUrlPolicy,e.updateMessageExpirationPolicy),E=e=>({description:e.groupDescription,imageUrlSquare:e.groupImageUrlSquare,name:e.groupName,pinnedFrameUrl:e.groupPinnedFrameUrl,permissions:e.permissions,customPermissionPolicySet:e.customPermissionPolicySet}),F=e=>new c(e.permissions,e.name,e.imageUrlSquare,e.description,e.pinnedFrameUrl,e.customPermissionPolicySet&&e.permissions===l.CustomPolicy?L(e.customPermissionPolicySet):void 0),D=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,pinnedFrameUrl:e.pinnedFrameUrl,permissions:{policyType:e.permissions.policyType,policySet:{addAdminPolicy:e.permissions.policySet.addAdminPolicy,addMemberPolicy:e.permissions.policySet.addMemberPolicy,removeAdminPolicy:e.permissions.policySet.removeAdminPolicy,removeMemberPolicy:e.permissions.policySet.removeMemberPolicy,updateGroupDescriptionPolicy:e.permissions.policySet.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.permissions.policySet.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.permissions.policySet.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.permissions.policySet.updateGroupPinnedFrameUrlPolicy,updateMessageExpirationPolicy:e.permissions.policySet.updateMessageExpirationPolicy}},isActive:e.isActive,addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.admins,superAdmins:e.superAdmins,createdAtNs:e.createdAtNs}),K=e=>({bytes:e.bytes,clientTimestampNs:e.clientTimestampNs,id:e.id}),R=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(K),recoveryAddress:e.recoveryAddress}),j=e=>({entity:e.entity,entityType:e.entityType,state:e.state}),O=e=>new p(e.entityType,e.state,e.entity),q=e=>({accountAddresses:e.accountAddresses,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}),W=e=>new u(e.inboxId,e.accountAddresses,e.installationIds,e.permissionLevel,e.consentState),$=e=>({key:e.key,epoch:e.epoch});class H{#n;content;contentType;conversationId;deliveryStatus;fallback;compression;id;kind;parameters;encodedContent;senderInboxId;sentAtNs;constructor(e,t){switch(this.#n=e,this.id=t.id,this.sentAtNs=t.sentAtNs,this.conversationId=t.convoId,this.senderInboxId=t.senderInboxId,this.encodedContent=t.content,t.kind){case m.Application:this.kind="application";break;case m.MembershipChange:this.kind="membership_change"}switch(t.deliveryStatus){case g.Unpublished:this.deliveryStatus="unpublished";break;case g.Published:this.deliveryStatus="published";break;case g.Failed:this.deliveryStatus="failed"}this.contentType=S(t.content.type),this.parameters=new Map(Object.entries(t.content.parameters)),this.fallback=t.content.fallback,this.compression=t.content.compression,this.content=this.#n.decodeContent(t,this.contentType)}}class V{#n;#i;#r;#a;#o;#d;#c;#l;#p;#u;#m=[];#g=[];constructor(e,t,s){this.#n=e,this.#i=t,this.#h(s)}#h(e){this.#r=e?.name??"",this.#a=e?.imageUrl??"",this.#o=e?.description??"",this.#d=e?.pinnedFrameUrl??"",this.#c=e?.isActive??void 0,this.#l=e?.addedByInboxId??"",this.#p=e?.metadata??void 0,this.#u=e?.createdAtNs??void 0,this.#m=e?.admins??[],this.#g=e?.superAdmins??[]}get id(){return this.#i}get name(){return this.#r}async updateName(e){await this.#n.sendMessage("updateGroupName",{id:this.#i,name:e}),this.#r=e}get imageUrl(){return this.#a}async updateImageUrl(e){await this.#n.sendMessage("updateGroupImageUrlSquare",{id:this.#i,imageUrl:e}),this.#a=e}get description(){return this.#o}async updateDescription(e){await this.#n.sendMessage("updateGroupDescription",{id:this.#i,description:e}),this.#o=e}get pinnedFrameUrl(){return this.#d}async updatePinnedFrameUrl(e){await this.#n.sendMessage("updateGroupPinnedFrameUrl",{id:this.#i,pinnedFrameUrl:e}),this.#d=e}get isActive(){return this.#c}get addedByInboxId(){return this.#l}get createdAtNs(){return this.#u}get createdAt(){return this.#u?(e=this.#u,new Date(Number(e/1000000n))):void 0;var e}get metadata(){return this.#p}async members(){return this.#n.sendMessage("getGroupMembers",{id:this.#i})}get admins(){return this.#m}get superAdmins(){return this.#g}async syncAdmins(){const e=await this.#n.sendMessage("getGroupAdmins",{id:this.#i});this.#m=e}async syncSuperAdmins(){const e=await this.#n.sendMessage("getGroupSuperAdmins",{id:this.#i});this.#g=e}async permissions(){return this.#n.sendMessage("getGroupPermissions",{id:this.#i})}async updatePermission(e,t,s){return this.#n.sendMessage("updateGroupPermissionPolicy",{id:this.#i,permissionType:e,policy:t,metadataField:s})}async isAdmin(e){return await this.syncAdmins(),this.#m.includes(e)}async isSuperAdmin(e){return await this.syncSuperAdmins(),this.#g.includes(e)}async sync(){const e=await this.#n.sendMessage("syncGroup",{id:this.#i});this.#h(e)}async addMembers(e){return this.#n.sendMessage("addGroupMembers",{id:this.#i,accountAddresses:e})}async addMembersByInboxId(e){return this.#n.sendMessage("addGroupMembersByInboxId",{id:this.#i,inboxIds:e})}async removeMembers(e){return this.#n.sendMessage("removeGroupMembers",{id:this.#i,accountAddresses:e})}async removeMembersByInboxId(e){return this.#n.sendMessage("removeGroupMembersByInboxId",{id:this.#i,inboxIds:e})}async addAdmin(e){return this.#n.sendMessage("addGroupAdmin",{id:this.#i,inboxId:e})}async removeAdmin(e){return this.#n.sendMessage("removeGroupAdmin",{id:this.#i,inboxId:e})}async addSuperAdmin(e){return this.#n.sendMessage("addGroupSuperAdmin",{id:this.#i,inboxId:e})}async removeSuperAdmin(e){return this.#n.sendMessage("removeGroupSuperAdmin",{id:this.#i,inboxId:e})}async publishMessages(){return this.#n.sendMessage("publishGroupMessages",{id:this.#i})}async sendOptimistic(e,t){if("string"!=typeof e&&!t)throw new Error("Content type is required when sending content other than text");const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("sendOptimisticGroupMessage",{id:this.#i,content:n})}async send(e,t){if("string"!=typeof e&&!t)throw new Error("Content type is required when sending content other than text");const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("sendGroupMessage",{id:this.#i,content:n})}async messages(e){return(await this.#n.sendMessage("getGroupMessages",{id:this.#i,options:e})).map((e=>new H(this.#n,e)))}async consentState(){return this.#n.sendMessage("getGroupConsentState",{id:this.#i})}async updateConsentState(e){return this.#n.sendMessage("updateGroupConsentState",{id:this.#i,state:e})}async dmPeerInboxId(){return this.#n.sendMessage("getDmPeerInboxId",{id:this.#i})}}class _{#n;constructor(e){this.#n=e}async sync(){return this.#n.sendMessage("syncConversations",void 0)}async syncAll(){return this.#n.sendMessage("syncAllConversations",void 0)}async getConversationById(e){const t=await this.#n.sendMessage("getConversationById",{id:e});return t?new V(this.#n,e,t):void 0}async getMessageById(e){const t=await this.#n.sendMessage("getMessageById",{id:e});return t?new H(this.#n,t):void 0}async getDmByInboxId(e){const t=await this.#n.sendMessage("getDmByInboxId",{inboxId:e});return t?new V(this.#n,t.id,t):void 0}async list(e){return(await this.#n.sendMessage("getConversations",{options:e})).map((e=>new V(this.#n,e.id,e)))}async listGroups(e){return(await this.#n.sendMessage("getGroups",{options:e})).map((e=>new V(this.#n,e.id,e)))}async listDms(e){return(await this.#n.sendMessage("getDms",{options:e})).map((e=>new V(this.#n,e.id,e)))}async newGroup(e,t){const s=await this.#n.sendMessage("newGroup",{accountAddresses:e,options:t});return new V(this.#n,s.id,s)}async newDm(e){const t=await this.#n.sendMessage("newDm",{accountAddress:e});return new V(this.#n,t.id,t)}async getHmacKeys(){return this.#n.sendMessage("getHmacKeys",void 0)}}const z=e=>"getBlockNumber"in e&&"getChainId"in e;class J extends w{#y;#I;#v;#w;#b;#M;#A;#S=!1;#x;options;constructor(t,s,i,r){super(new Worker(new URL("./workers/client",import.meta.url),{type:"module"}),void 0!==r?.loggingLevel&&"off"!==r.loggingLevel),this.#y=s,this.options=r,this.#w=i,this.#x=t,this.#v=new _(this);const a=[new e,new n,...r?.codecs??[]];this.#I=new Map(a.map((e=>[e.contentType.toString(),e])))}get accountAddress(){return this.#y}async init(){const e=await this.sendMessage("init",{address:this.accountAddress,encryptionKey:this.#w,options:this.options});this.#b=e.inboxId,this.#M=e.installationId,this.#A=e.installationIdBytes,this.#S=!0}static async create(e,t,s){const n=await e.getAddress(),i=new J(e,n,t,s);return await i.init(),s?.disableAutoRegister||await i.register(),i}get isReady(){return this.#S}get inboxId(){return this.#b}get installationId(){return this.#M}get installationIdBytes(){return this.#A}async#P(){return this.sendMessage("createInboxSignatureText",void 0)}async#k(e){return this.sendMessage("addAccountSignatureText",{newAccountAddress:e})}async#f(e){return this.sendMessage("removeAccountSignatureText",{accountAddress:e})}async#G(){return this.sendMessage("revokeAllOtherInstallationsSignatureText",void 0)}async#U(e){return this.sendMessage("revokeInstallationsSignatureText",{installationIds:e})}async#N(e,t,s){const n=await s.signMessage(t);z(s)?await this.sendMessage("addScwSignature",{type:e,bytes:n,chainId:s.getChainId(),blockNumber:s.getBlockNumber()}):await this.sendMessage("addSignature",{type:e,bytes:n})}async#C(){return this.sendMessage("applySignatures",void 0)}async register(){const e=await this.#P();if(e)return await this.#N(h.CreateInbox,e,this.#x),this.sendMessage("registerIdentity",void 0)}async addAccount(e){const t=await this.#k(await e.getAddress());if(!t)throw new Error("Unable to generate add account signature text");await this.#N(h.AddWallet,t,e),await this.#C()}async removeAccount(e){const t=await this.#f(e);if(!t)throw new Error("Unable to generate remove account signature text");await this.#N(h.RevokeWallet,t,this.#x),await this.#C()}async revokeAllOtherInstallations(){const e=await this.#G();if(!e)throw new Error("Unable to generate revoke all other installations signature text");await this.#N(h.RevokeInstallations,e,this.#x),await this.#C()}async revokeInstallations(e){const t=await this.#U(e);if(!t)throw new Error("Unable to generate revoke installations signature text");await this.#N(h.RevokeInstallations,t,this.#x),await this.#C()}async isRegistered(){return this.sendMessage("isRegistered",void 0)}async canMessage(e){return this.sendMessage("canMessage",{accountAddresses:e})}static async canMessage(e,t){const s={getAddress:()=>"0x0000000000000000000000000000000000000000",signMessage:()=>new Uint8Array};return(await J.create(s,window.crypto.getRandomValues(new Uint8Array(32)),{disableAutoRegister:!0,env:t})).canMessage(e)}async findInboxIdByAddress(e){return this.sendMessage("findInboxIdByAddress",{address:e})}async inboxState(e){return this.sendMessage("inboxState",{refreshFromNetwork:e??!1})}async getLatestInboxState(e){return this.sendMessage("getLatestInboxState",{inboxId:e})}async setConsentStates(e){return this.sendMessage("setConsentStates",{records:e})}async getConsentState(e,t){return this.sendMessage("getConsentState",{entityType:e,entity:t})}get conversations(){return this.#v}codecFor(e){return this.#I.get(e.toString())}encodeContent(e,t){const s=this.codecFor(t);if(!s)throw new Error(`Codec not found for "${t.toString()}" content type`);const n=s.encode(e,this),i=s.fallback(e);return i&&(n.fallback=i),k(n)}decodeContent(e,s){const n=this.codecFor(s);if(!n)throw new Error(`Codec not found for "${s.toString()}" content type`);if(s.sameAs(t)&&e.kind!==m.MembershipChange)throw new Error("Error decoding group membership change");const i=f(e.content);return n.decode(i,this)}signWithInstallationKey(e){return this.sendMessage("signWithInstallationKey",{signatureText:e})}verifySignedWithInstallationKey(e,t){return this.sendMessage("verifySignedWithInstallationKey",{signatureText:e,signatureBytes:t})}verifySignedWithPublicKey(e,t,s){return this.sendMessage("verifySignedWithPublicKey",{signatureText:e,signatureBytes:t,publicKey:s})}}const Q=e=>{console.error(`Worker error on line ${e.lineno} in "${e.filename}"`),console.error(e.message)};class X{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),this.#e.addEventListener("error",Q),this.#t=t}sendMessage(e,t){const s=y();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("utils received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(new Error(t.error)):s.resolve(t.result))};close(){this.#e.removeEventListener("message",this.handleMessage),this.#e.removeEventListener("error",Q),this.#e.terminate()}}class Y extends X{#t;constructor(e){super(new Worker(new URL("./workers/utils",import.meta.url),{type:"module"}),e??!1),this.#t=e??!1}async generateInboxId(e){return this.sendMessage("generateInboxId",{address:e,enableLogging:this.#t})}async getInboxIdForAddress(e,t){return this.sendMessage("getInboxIdForAddress",{address:e,env:t,enableLogging:this.#t})}}const Z={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"};export{Z as ApiUrls,J as Client,V as Conversation,_ as Conversations,H as DecodedMessage,Y as Utils,M as fromContentTypeId,P as fromEncodedContent,O as fromSafeConsent,S as fromSafeContentTypeId,F as fromSafeCreateGroupOptions,f as fromSafeEncodedContent,W as fromSafeGroupMember,T as fromSafeListConversationsOptions,N as fromSafeListMessagesOptions,L as fromSafePermissionPolicySet,z as isSmartContractSigner,b as toContentTypeId,x as toEncodedContent,j as toSafeConsent,A as toSafeContentTypeId,D as toSafeConversation,E as toSafeCreateGroupOptions,k as toSafeEncodedContent,q as toSafeGroupMember,$ as toSafeHmacKey,R as toSafeInboxState,K as toSafeInstallation,C as toSafeListConversationsOptions,U as toSafeListMessagesOptions,G as toSafeMessage,B as toSafePermissionPolicySet};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/ClientWorkerClass.ts","../src/utils/conversions.ts","../src/DecodedMessage.ts","../src/Conversation.ts","../src/utils/date.ts","../src/Conversations.ts","../src/utils/signer.ts","../src/Client.ts","../src/UtilsWorkerClass.ts","../src/Utils.ts","../src/constants.ts"],"sourcesContent":["import { v4 } from \"uuid\";\nimport type {\n ClientEventsActions,\n ClientEventsErrorData,\n ClientEventsResult,\n ClientEventsWorkerMessageData,\n ClientSendMessageData,\n} from \"@/types\";\n\nconst handleError = (event: ErrorEvent) => {\n console.error(`Worker error on line ${event.lineno} in \"${event.filename}\"`);\n console.error(event.message);\n};\n\nexport class ClientWorkerClass {\n #worker: Worker;\n\n #enableLogging: boolean;\n\n #promises = new Map<\n string,\n { resolve: (value: any) => void; reject: (reason?: any) => void }\n >();\n\n constructor(worker: Worker, enableLogging: boolean) {\n this.#worker = worker;\n this.#worker.addEventListener(\"message\", this.handleMessage);\n this.#worker.addEventListener(\"error\", handleError);\n this.#enableLogging = enableLogging;\n }\n\n sendMessage<A extends ClientEventsActions>(\n action: A,\n data: ClientSendMessageData<A>,\n ) {\n const promiseId = v4();\n this.#worker.postMessage({\n action,\n id: promiseId,\n data,\n });\n const promise = new Promise<ClientEventsResult<A>>((resolve, reject) => {\n this.#promises.set(promiseId, { resolve, reject });\n });\n return promise;\n }\n\n handleMessage = (\n event: MessageEvent<ClientEventsWorkerMessageData | ClientEventsErrorData>,\n ) => {\n const eventData = event.data;\n if (this.#enableLogging) {\n console.log(\"client received event data\", eventData);\n }\n const promise = this.#promises.get(eventData.id);\n if (promise) {\n this.#promises.delete(eventData.id);\n if (\"error\" in eventData) {\n promise.reject(new Error(eventData.error));\n } else {\n promise.resolve(eventData.result);\n }\n }\n };\n\n close() {\n this.#worker.removeEventListener(\"message\", this.handleMessage);\n this.#worker.removeEventListener(\"error\", handleError);\n this.#worker.terminate();\n }\n}\n","import {\n ContentTypeId,\n type EncodedContent,\n} from \"@xmtp/content-type-primitives\";\nimport {\n Consent,\n CreateGroupOptions,\n GroupMember,\n GroupPermissionsOptions,\n ListConversationsOptions,\n ListMessagesOptions,\n PermissionPolicySet,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ConversationType,\n type DeliveryStatus,\n type GroupMembershipState,\n type GroupMessageKind,\n type InboxState,\n type Installation,\n type Message,\n type PermissionLevel,\n type PermissionPolicy,\n type SortDirection,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: DeliveryStatus;\n id: string;\n kind: GroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: Message): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convoId,\n deliveryStatus: message.deliveryStatus,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.senderInboxId,\n sentAtNs: message.sentAtNs,\n});\n\nexport type SafeListMessagesOptions = {\n deliveryStatus?: DeliveryStatus;\n direction?: SortDirection;\n limit?: bigint;\n sentAfterNs?: bigint;\n sentBeforeNs?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: ListMessagesOptions,\n): SafeListMessagesOptions => ({\n deliveryStatus: options.deliveryStatus,\n direction: options.direction,\n limit: options.limit,\n sentAfterNs: options.sentAfterNs,\n sentBeforeNs: options.sentBeforeNs,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): ListMessagesOptions =>\n new ListMessagesOptions(\n options.sentBeforeNs,\n options.sentAfterNs,\n options.limit,\n options.deliveryStatus,\n options.direction,\n );\n\nexport type SafeListConversationsOptions = {\n allowedStates?: GroupMembershipState[];\n conversationType?: ConversationType;\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n allowedStates: options.allowedStates,\n conversationType: options.conversationType,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.allowedStates,\n options.conversationType,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n};\n\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 updateGroupPinnedFrameUrlPolicy: policySet.updateGroupPinnedFrameUrlPolicy,\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.updateGroupPinnedFrameUrlPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n name?: string;\n permissions?: GroupPermissionsOptions;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n name: options.groupName,\n pinnedFrameUrl: options.groupPinnedFrameUrl,\n permissions: options.permissions,\n customPermissionPolicySet: options.customPermissionPolicySet,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): CreateGroupOptions =>\n new CreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n // 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 );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: GroupPermissionsOptions;\n policySet: {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n };\n };\n isActive: boolean;\n addedByInboxId: string;\n metadata: {\n creatorInboxId: string;\n conversationType: string;\n };\n admins: string[];\n superAdmins: string[];\n createdAtNs: bigint;\n};\n\nexport const toSafeConversation = async (\n conversation: WorkerConversation,\n): Promise<SafeConversation> => ({\n id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,\n addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,\n removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,\n removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: await conversation.metadata(),\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\n});\n\nexport type SafeInstallation = {\n id: string;\n clientTimestampNs?: bigint;\n};\n\nexport const toSafeInstallation = (\n installation: Installation,\n): SafeInstallation => ({\n id: installation.id,\n clientTimestampNs: installation.clientTimestampNs,\n});\n\nexport type SafeInboxState = {\n accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountAddresses: inboxState.accountAddresses,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recoveryAddress,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: ConsentEntityType;\n state: ConsentState;\n};\n\nexport const toSafeConsent = (consent: Consent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entityType,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): Consent =>\n new Consent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountAddresses: member.accountAddresses,\n consentState: member.consentState,\n inboxId: member.inboxId,\n installationIds: member.installationIds,\n permissionLevel: member.permissionLevel,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>\n new GroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n","import type { ContentTypeId } from \"@xmtp/content-type-primitives\";\nimport { DeliveryStatus, GroupMessageKind } from \"@xmtp/wasm-bindings\";\nimport type { Client } from \"@/Client\";\nimport { fromSafeContentTypeId, type SafeMessage } from \"@/utils/conversions\";\n\nexport type MessageKind = \"application\" | \"membership_change\";\nexport type MessageDeliveryStatus = \"unpublished\" | \"published\" | \"failed\";\n\nexport class DecodedMessage {\n #client: Client;\n\n content: any;\n\n contentType: ContentTypeId;\n\n conversationId: string;\n\n deliveryStatus: MessageDeliveryStatus;\n\n fallback?: string;\n\n compression?: number;\n\n id: string;\n\n kind: MessageKind;\n\n parameters: Map<string, string>;\n\n encodedContent: SafeMessage[\"content\"];\n\n senderInboxId: string;\n\n sentAtNs: bigint;\n\n constructor(client: Client, message: SafeMessage) {\n this.#client = client;\n this.id = message.id;\n this.sentAtNs = message.sentAtNs;\n this.conversationId = message.convoId;\n this.senderInboxId = message.senderInboxId;\n this.encodedContent = message.content;\n\n switch (message.kind) {\n case GroupMessageKind.Application:\n this.kind = \"application\";\n break;\n case GroupMessageKind.MembershipChange:\n this.kind = \"membership_change\";\n break;\n // no default\n }\n\n switch (message.deliveryStatus) {\n case DeliveryStatus.Unpublished:\n this.deliveryStatus = \"unpublished\";\n break;\n case DeliveryStatus.Published:\n this.deliveryStatus = \"published\";\n break;\n case DeliveryStatus.Failed:\n this.deliveryStatus = \"failed\";\n break;\n // no default\n }\n\n this.contentType = fromSafeContentTypeId(message.content.type);\n this.parameters = new Map(Object.entries(message.content.parameters));\n this.fallback = message.content.fallback;\n this.compression = message.content.compression;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this.content = this.#client.decodeContent(message, this.contentType);\n }\n}\n","import type { ContentTypeId } from \"@xmtp/content-type-primitives\";\nimport { ContentTypeText } from \"@xmtp/content-type-text\";\nimport type {\n ConsentState,\n MetadataField,\n PermissionPolicy,\n PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport type { Client } from \"@/Client\";\nimport { DecodedMessage } from \"@/DecodedMessage\";\nimport type {\n SafeConversation,\n SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport { nsToDate } from \"@/utils/date\";\n\nexport class Conversation {\n #client: Client;\n\n #id: string;\n\n #name?: SafeConversation[\"name\"];\n\n #imageUrl?: SafeConversation[\"imageUrl\"];\n\n #description?: SafeConversation[\"description\"];\n\n #pinnedFrameUrl?: SafeConversation[\"pinnedFrameUrl\"];\n\n #isActive?: SafeConversation[\"isActive\"];\n\n #addedByInboxId?: SafeConversation[\"addedByInboxId\"];\n\n #metadata?: SafeConversation[\"metadata\"];\n\n #createdAtNs?: SafeConversation[\"createdAtNs\"];\n\n #admins: SafeConversation[\"admins\"] = [];\n\n #superAdmins: SafeConversation[\"superAdmins\"] = [];\n\n constructor(client: Client, id: string, data?: SafeConversation) {\n this.#client = client;\n this.#id = id;\n this.#syncData(data);\n }\n\n #syncData(data?: SafeConversation) {\n this.#name = data?.name ?? \"\";\n this.#imageUrl = data?.imageUrl ?? \"\";\n this.#description = data?.description ?? \"\";\n this.#pinnedFrameUrl = data?.pinnedFrameUrl ?? \"\";\n this.#isActive = data?.isActive ?? undefined;\n this.#addedByInboxId = data?.addedByInboxId ?? \"\";\n this.#metadata = data?.metadata ?? undefined;\n this.#createdAtNs = data?.createdAtNs ?? undefined;\n this.#admins = data?.admins ?? [];\n this.#superAdmins = data?.superAdmins ?? [];\n }\n\n get id() {\n return this.#id;\n }\n\n get name() {\n return this.#name;\n }\n\n async updateName(name: string) {\n await this.#client.sendMessage(\"updateGroupName\", {\n id: this.#id,\n name,\n });\n this.#name = name;\n }\n\n get imageUrl() {\n return this.#imageUrl;\n }\n\n async updateImageUrl(imageUrl: string) {\n await this.#client.sendMessage(\"updateGroupImageUrlSquare\", {\n id: this.#id,\n imageUrl,\n });\n this.#imageUrl = imageUrl;\n }\n\n get description() {\n return this.#description;\n }\n\n async updateDescription(description: string) {\n await this.#client.sendMessage(\"updateGroupDescription\", {\n id: this.#id,\n description,\n });\n this.#description = description;\n }\n\n get pinnedFrameUrl() {\n return this.#pinnedFrameUrl;\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n await this.#client.sendMessage(\"updateGroupPinnedFrameUrl\", {\n id: this.#id,\n pinnedFrameUrl,\n });\n this.#pinnedFrameUrl = pinnedFrameUrl;\n }\n\n get isActive() {\n return this.#isActive;\n }\n\n get addedByInboxId() {\n return this.#addedByInboxId;\n }\n\n get createdAtNs() {\n return this.#createdAtNs;\n }\n\n get createdAt() {\n return this.#createdAtNs ? nsToDate(this.#createdAtNs) : undefined;\n }\n\n get metadata() {\n return this.#metadata;\n }\n\n async members() {\n return this.#client.sendMessage(\"getGroupMembers\", {\n id: this.#id,\n });\n }\n\n get admins() {\n return this.#admins;\n }\n\n get superAdmins() {\n return this.#superAdmins;\n }\n\n async syncAdmins() {\n const admins = await this.#client.sendMessage(\"getGroupAdmins\", {\n id: this.#id,\n });\n this.#admins = admins;\n }\n\n async syncSuperAdmins() {\n const superAdmins = await this.#client.sendMessage(\"getGroupSuperAdmins\", {\n id: this.#id,\n });\n this.#superAdmins = superAdmins;\n }\n\n async permissions() {\n return this.#client.sendMessage(\"getGroupPermissions\", {\n id: this.#id,\n });\n }\n\n async updatePermission(\n permissionType: PermissionUpdateType,\n policy: PermissionPolicy,\n metadataField?: MetadataField,\n ) {\n return this.#client.sendMessage(\"updateGroupPermissionPolicy\", {\n id: this.#id,\n permissionType,\n policy,\n metadataField,\n });\n }\n\n async isAdmin(inboxId: string) {\n await this.syncAdmins();\n return this.#admins.includes(inboxId);\n }\n\n async isSuperAdmin(inboxId: string) {\n await this.syncSuperAdmins();\n return this.#superAdmins.includes(inboxId);\n }\n\n async sync() {\n const data = await this.#client.sendMessage(\"syncGroup\", {\n id: this.#id,\n });\n this.#syncData(data);\n }\n\n async addMembers(accountAddresses: string[]) {\n return this.#client.sendMessage(\"addGroupMembers\", {\n id: this.#id,\n accountAddresses,\n });\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#client.sendMessage(\"addGroupMembersByInboxId\", {\n id: this.#id,\n inboxIds,\n });\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#client.sendMessage(\"removeGroupMembers\", {\n id: this.#id,\n accountAddresses,\n });\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#client.sendMessage(\"removeGroupMembersByInboxId\", {\n id: this.#id,\n inboxIds,\n });\n }\n\n async addAdmin(inboxId: string) {\n return this.#client.sendMessage(\"addGroupAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async removeAdmin(inboxId: string) {\n return this.#client.sendMessage(\"removeGroupAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#client.sendMessage(\"addGroupSuperAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#client.sendMessage(\"removeGroupSuperAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async publishMessages() {\n return this.#client.sendMessage(\"publishGroupMessages\", {\n id: this.#id,\n });\n }\n\n async sendOptimistic(content: any, contentType?: ContentTypeId) {\n if (typeof content !== \"string\" && !contentType) {\n throw new Error(\n \"Content type is required when sending content other than text\",\n );\n }\n\n const safeEncodedContent =\n typeof content === \"string\"\n ? this.#client.encodeContent(content, contentType ?? ContentTypeText)\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.#client.encodeContent(content, contentType!);\n\n return this.#client.sendMessage(\"sendOptimisticGroupMessage\", {\n id: this.#id,\n content: safeEncodedContent,\n });\n }\n\n async send(content: any, contentType?: ContentTypeId) {\n if (typeof content !== \"string\" && !contentType) {\n throw new Error(\n \"Content type is required when sending content other than text\",\n );\n }\n\n const safeEncodedContent =\n typeof content === \"string\"\n ? this.#client.encodeContent(content, contentType ?? ContentTypeText)\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.#client.encodeContent(content, contentType!);\n\n return this.#client.sendMessage(\"sendGroupMessage\", {\n id: this.#id,\n content: safeEncodedContent,\n });\n }\n\n async messages(options?: SafeListMessagesOptions) {\n const messages = await this.#client.sendMessage(\"getGroupMessages\", {\n id: this.#id,\n options,\n });\n\n return messages.map((message) => new DecodedMessage(this.#client, message));\n }\n\n async consentState() {\n return this.#client.sendMessage(\"getGroupConsentState\", {\n id: this.#id,\n });\n }\n\n async updateConsentState(state: ConsentState) {\n return this.#client.sendMessage(\"updateGroupConsentState\", {\n id: this.#id,\n state,\n });\n }\n\n async dmPeerInboxId() {\n return this.#client.sendMessage(\"getDmPeerInboxId\", {\n id: this.#id,\n });\n }\n}\n","export function nsToDate(ns: bigint): Date {\n return new Date(Number(ns / 1_000_000n));\n}\n","import type { Client } from \"@/Client\";\nimport { Conversation } from \"@/Conversation\";\nimport { DecodedMessage } from \"@/DecodedMessage\";\nimport type {\n SafeCreateGroupOptions,\n SafeListConversationsOptions,\n} from \"@/utils/conversions\";\n\nexport class Conversations {\n #client: Client;\n\n constructor(client: Client) {\n this.#client = client;\n }\n\n async sync() {\n return this.#client.sendMessage(\"syncConversations\", undefined);\n }\n\n async syncAll() {\n return this.#client.sendMessage(\"syncAllConversations\", undefined);\n }\n\n async getConversationById(id: string) {\n const data = await this.#client.sendMessage(\"getConversationById\", {\n id,\n });\n return data ? new Conversation(this.#client, id, data) : undefined;\n }\n\n async getMessageById(id: string) {\n const data = await this.#client.sendMessage(\"getMessageById\", {\n id,\n });\n return data ? new DecodedMessage(this.#client, data) : undefined;\n }\n\n async getDmByInboxId(inboxId: string) {\n const data = await this.#client.sendMessage(\"getDmByInboxId\", {\n inboxId,\n });\n return data ? new Conversation(this.#client, data.id, data) : undefined;\n }\n\n async list(options?: SafeListConversationsOptions) {\n const conversations = await this.#client.sendMessage(\"getConversations\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const conversations = await this.#client.sendMessage(\"getGroups\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async listDms(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const conversations = await this.#client.sendMessage(\"getDms\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const conversation = await this.#client.sendMessage(\"newGroup\", {\n accountAddresses,\n options,\n });\n\n return new Conversation(this.#client, conversation.id, conversation);\n }\n\n async newDm(accountAddress: string) {\n const conversation = await this.#client.sendMessage(\"newDm\", {\n accountAddress,\n });\n\n return new Conversation(this.#client, conversation.id, conversation);\n }\n}\n","export type SignMessage = (message: string) => Promise<Uint8Array> | Uint8Array;\nexport type GetAddress = () => Promise<string> | string;\nexport type GetChainId = () => bigint;\nexport type GetBlockNumber = () => bigint;\n\nexport type Signer = {\n getAddress: GetAddress;\n signMessage: SignMessage;\n // these fields indicate that the signer is a smart contract wallet\n getBlockNumber?: GetBlockNumber;\n getChainId?: GetChainId;\n};\n\nexport type SmartContractSigner = Required<Signer>;\n\nexport const isSmartContractSigner = (\n signer: Signer,\n): signer is SmartContractSigner =>\n \"getBlockNumber\" in signer && \"getChainId\" in signer;\n","import {\n ContentTypeGroupUpdated,\n GroupUpdatedCodec,\n} from \"@xmtp/content-type-group-updated\";\nimport type {\n ContentCodec,\n ContentTypeId,\n} from \"@xmtp/content-type-primitives\";\nimport { TextCodec } from \"@xmtp/content-type-text\";\nimport {\n GroupMessageKind,\n SignatureRequestType,\n type ConsentEntityType,\n} from \"@xmtp/wasm-bindings\";\nimport { ClientWorkerClass } from \"@/ClientWorkerClass\";\nimport { Conversations } from \"@/Conversations\";\nimport type { ClientOptions, XmtpEnv } from \"@/types\";\nimport {\n fromSafeEncodedContent,\n toSafeEncodedContent,\n type SafeConsent,\n type SafeMessage,\n} from \"@/utils/conversions\";\nimport { isSmartContractSigner, type Signer } from \"@/utils/signer\";\n\nexport class Client extends ClientWorkerClass {\n #accountAddress: string;\n #codecs: Map<string, ContentCodec>;\n #conversations: Conversations;\n #encryptionKey: Uint8Array;\n #inboxId: string | undefined;\n #installationId: string | undefined;\n #installationIdBytes: Uint8Array | undefined;\n #isReady = false;\n #signer: Signer;\n options?: ClientOptions;\n\n constructor(\n signer: Signer,\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: ClientOptions,\n ) {\n const worker = new Worker(new URL(\"./workers/client\", import.meta.url), {\n type: \"module\",\n });\n super(\n worker,\n options?.loggingLevel !== undefined && options.loggingLevel !== \"off\",\n );\n this.#accountAddress = accountAddress;\n this.options = options;\n this.#encryptionKey = encryptionKey;\n this.#signer = signer;\n this.#conversations = new Conversations(this);\n const codecs = [\n new GroupUpdatedCodec(),\n new TextCodec(),\n ...(options?.codecs ?? []),\n ];\n this.#codecs = new Map(\n codecs.map((codec) => [codec.contentType.toString(), codec]),\n );\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n async init() {\n const result = await this.sendMessage(\"init\", {\n address: this.accountAddress,\n encryptionKey: this.#encryptionKey,\n options: this.options,\n });\n this.#inboxId = result.inboxId;\n this.#installationId = result.installationId;\n this.#installationIdBytes = result.installationIdBytes;\n this.#isReady = true;\n }\n\n static async create(\n signer: Signer,\n encryptionKey: Uint8Array,\n options?: ClientOptions,\n ) {\n const address = await signer.getAddress();\n const client = new Client(signer, address, encryptionKey, options);\n\n await client.init();\n\n if (!options?.disableAutoRegister) {\n await client.register();\n }\n\n return client;\n }\n\n get isReady() {\n return this.#isReady;\n }\n\n get inboxId() {\n return this.#inboxId;\n }\n\n get installationId() {\n return this.#installationId;\n }\n\n get installationIdBytes() {\n return this.#installationIdBytes;\n }\n\n async #createInboxSignatureText() {\n return this.sendMessage(\"createInboxSignatureText\", undefined);\n }\n\n async #addAccountSignatureText(newAccountAddress: string) {\n return this.sendMessage(\"addAccountSignatureText\", {\n newAccountAddress,\n });\n }\n\n async #removeAccountSignatureText(accountAddress: string) {\n return this.sendMessage(\"removeAccountSignatureText\", { accountAddress });\n }\n\n async #revokeAllOtherInstallationsSignatureText() {\n return this.sendMessage(\n \"revokeAllOtherInstallationsSignatureText\",\n undefined,\n );\n }\n\n async #revokeInstallationsSignatureText(installationIds: Uint8Array[]) {\n return this.sendMessage(\"revokeInstallationsSignatureText\", {\n installationIds,\n });\n }\n\n async #addSignature(\n signatureType: SignatureRequestType,\n signatureText: string,\n signer: Signer,\n ) {\n const signature = await signer.signMessage(signatureText);\n\n if (isSmartContractSigner(signer)) {\n await this.sendMessage(\"addScwSignature\", {\n type: signatureType,\n bytes: signature,\n chainId: signer.getChainId(),\n blockNumber: signer.getBlockNumber(),\n });\n } else {\n await this.sendMessage(\"addSignature\", {\n type: signatureType,\n bytes: signature,\n });\n }\n }\n\n async #applySignatures() {\n return this.sendMessage(\"applySignatures\", undefined);\n }\n\n async register() {\n const signatureText = await this.#createInboxSignatureText();\n\n // if the signature text is not available, the client is already registered\n if (!signatureText) {\n return;\n }\n\n await this.#addSignature(\n SignatureRequestType.CreateInbox,\n signatureText,\n this.#signer,\n );\n\n return this.sendMessage(\"registerIdentity\", undefined);\n }\n\n async addAccount(newAccountSigner: Signer) {\n const signatureText = await this.#addAccountSignatureText(\n await newAccountSigner.getAddress(),\n );\n\n if (!signatureText) {\n throw new Error(\"Unable to generate add account signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.AddWallet,\n signatureText,\n newAccountSigner,\n );\n\n await this.#applySignatures();\n }\n\n async removeAccount(accountAddress: string) {\n const signatureText =\n await this.#removeAccountSignatureText(accountAddress);\n\n if (!signatureText) {\n throw new Error(\"Unable to generate remove account signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeWallet,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async revokeAllOtherInstallations() {\n const signatureText =\n await this.#revokeAllOtherInstallationsSignatureText();\n\n if (!signatureText) {\n throw new Error(\n \"Unable to generate revoke all other installations signature text\",\n );\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeInstallations,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async revokeInstallations(installationIds: Uint8Array[]) {\n const signatureText =\n await this.#revokeInstallationsSignatureText(installationIds);\n\n if (!signatureText) {\n throw new Error(\"Unable to generate revoke installations signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeInstallations,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async isRegistered() {\n return this.sendMessage(\"isRegistered\", undefined);\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.sendMessage(\"canMessage\", { accountAddresses });\n }\n\n static async canMessage(accountAddresses: string[], env?: XmtpEnv) {\n const accountAddress = \"0x0000000000000000000000000000000000000000\";\n const signer: Signer = {\n getAddress: () => accountAddress,\n signMessage: () => new Uint8Array(),\n };\n const client = await Client.create(\n signer,\n window.crypto.getRandomValues(new Uint8Array(32)),\n {\n disableAutoRegister: true,\n env,\n },\n );\n return client.canMessage(accountAddresses);\n }\n\n async findInboxIdByAddress(address: string) {\n return this.sendMessage(\"findInboxIdByAddress\", { address });\n }\n\n async inboxState(refreshFromNetwork?: boolean) {\n return this.sendMessage(\"inboxState\", {\n refreshFromNetwork: refreshFromNetwork ?? false,\n });\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.sendMessage(\"getLatestInboxState\", { inboxId });\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.sendMessage(\"setConsentStates\", { records });\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.sendMessage(\"getConsentState\", { entityType, entity });\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n codecFor(contentType: ContentTypeId) {\n return this.#codecs.get(contentType.toString());\n }\n\n encodeContent(content: any, contentType: ContentTypeId) {\n const codec = this.codecFor(contentType);\n if (!codec) {\n throw new Error(\n `Codec not found for \"${contentType.toString()}\" content type`,\n );\n }\n const encoded = codec.encode(content, this);\n const fallback = codec.fallback(content);\n if (fallback) {\n encoded.fallback = fallback;\n }\n return toSafeEncodedContent(encoded);\n }\n\n decodeContent(message: SafeMessage, contentType: ContentTypeId) {\n const codec = this.codecFor(contentType);\n if (!codec) {\n throw new Error(\n `Codec not found for \"${contentType.toString()}\" content type`,\n );\n }\n\n // throw an error if there's an invalid group membership change message\n if (\n contentType.sameAs(ContentTypeGroupUpdated) &&\n message.kind !== GroupMessageKind.MembershipChange\n ) {\n throw new Error(\"Error decoding group membership change\");\n }\n\n const encodedContent = fromSafeEncodedContent(message.content);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return codec.decode(encodedContent, this);\n }\n\n signWithInstallationKey(signatureText: string) {\n return this.sendMessage(\"signWithInstallationKey\", { signatureText });\n }\n\n verifySignedWithInstallationKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n ) {\n return this.sendMessage(\"verifySignedWithInstallationKey\", {\n signatureText,\n signatureBytes,\n });\n }\n\n verifySignedWithPublicKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n publicKey: Uint8Array,\n ) {\n return this.sendMessage(\"verifySignedWithPublicKey\", {\n signatureText,\n signatureBytes,\n publicKey,\n });\n }\n}\n","import { v4 } from \"uuid\";\nimport type {\n UtilsEventsActions,\n UtilsEventsErrorData,\n UtilsEventsResult,\n UtilsEventsWorkerMessageData,\n UtilsSendMessageData,\n} from \"@/types\";\n\nconst handleError = (event: ErrorEvent) => {\n console.error(`Worker error on line ${event.lineno} in \"${event.filename}\"`);\n console.error(event.message);\n};\n\nexport class UtilsWorkerClass {\n #worker: Worker;\n\n #enableLogging: boolean;\n\n #promises = new Map<\n string,\n { resolve: (value: any) => void; reject: (reason?: any) => void }\n >();\n\n constructor(worker: Worker, enableLogging: boolean) {\n this.#worker = worker;\n this.#worker.addEventListener(\"message\", this.handleMessage);\n this.#worker.addEventListener(\"error\", handleError);\n this.#enableLogging = enableLogging;\n }\n\n sendMessage<A extends UtilsEventsActions>(\n action: A,\n data: UtilsSendMessageData<A>,\n ) {\n const promiseId = v4();\n this.#worker.postMessage({\n action,\n id: promiseId,\n data,\n });\n const promise = new Promise<UtilsEventsResult<A>>((resolve, reject) => {\n this.#promises.set(promiseId, { resolve, reject });\n });\n return promise;\n }\n\n handleMessage = (\n event: MessageEvent<UtilsEventsWorkerMessageData | UtilsEventsErrorData>,\n ) => {\n const eventData = event.data;\n if (this.#enableLogging) {\n console.log(\"utils received event data\", eventData);\n }\n const promise = this.#promises.get(eventData.id);\n if (promise) {\n this.#promises.delete(eventData.id);\n if (\"error\" in eventData) {\n promise.reject(new Error(eventData.error));\n } else {\n promise.resolve(eventData.result);\n }\n }\n };\n\n close() {\n this.#worker.removeEventListener(\"message\", this.handleMessage);\n this.#worker.removeEventListener(\"error\", handleError);\n this.#worker.terminate();\n }\n}\n","import type { XmtpEnv } from \"@/types/options\";\nimport { UtilsWorkerClass } from \"@/UtilsWorkerClass\";\n\nexport class Utils extends UtilsWorkerClass {\n #enableLogging: boolean;\n constructor(enableLogging?: boolean) {\n const worker = new Worker(new URL(\"./workers/utils\", import.meta.url), {\n type: \"module\",\n });\n super(worker, enableLogging ?? false);\n this.#enableLogging = enableLogging ?? false;\n }\n\n async generateInboxId(address: string) {\n return this.sendMessage(\"generateInboxId\", {\n address,\n enableLogging: this.#enableLogging,\n });\n }\n\n async getInboxIdForAddress(address: string, env?: XmtpEnv) {\n return this.sendMessage(\"getInboxIdForAddress\", {\n address,\n env,\n enableLogging: this.#enableLogging,\n });\n }\n}\n","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n"],"names":["handleError","event","console","error","lineno","filename","message","ClientWorkerClass","worker","enableLogging","promises","Map","constructor","this","addEventListener","handleMessage","sendMessage","action","data","promiseId","v4","postMessage","id","Promise","resolve","reject","set","eventData","log","promise","get","delete","Error","result","close","removeEventListener","terminate","toContentTypeId","contentTypeId","ContentTypeId","authorityId","typeId","versionMajor","versionMinor","fromContentTypeId","WasmContentTypeId","toSafeContentTypeId","fromSafeContentTypeId","toEncodedContent","content","type","parameters","Object","fromEntries","fallback","compression","fromEncodedContent","WasmEncodedContent","entries","toSafeEncodedContent","fromSafeEncodedContent","toSafeMessage","convoId","deliveryStatus","kind","senderInboxId","sentAtNs","toSafeListMessagesOptions","options","direction","limit","sentAfterNs","sentBeforeNs","fromSafeListMessagesOptions","ListMessagesOptions","toSafeListConversationsOptions","allowedStates","conversationType","createdAfterNs","createdBeforeNs","fromSafeListConversationsOptions","ListConversationsOptions","toSafePermissionPolicySet","policySet","addAdminPolicy","addMemberPolicy","removeAdminPolicy","removeMemberPolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateGroupNamePolicy","updateGroupPinnedFrameUrlPolicy","fromSafePermissionPolicySet","PermissionPolicySet","toSafeCreateGroupOptions","description","groupDescription","imageUrlSquare","groupImageUrlSquare","name","groupName","pinnedFrameUrl","groupPinnedFrameUrl","permissions","customPermissionPolicySet","fromSafeCreateGroupOptions","CreateGroupOptions","GroupPermissionsOptions","CustomPolicy","undefined","toSafeConversation","async","conversation","imageUrl","policyType","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","clientTimestampNs","toSafeInboxState","inboxState","accountAddresses","inboxId","installations","map","recoveryAddress","toSafeConsent","consent","entity","entityType","state","fromSafeConsent","Consent","toSafeGroupMember","member","consentState","installationIds","permissionLevel","fromSafeGroupMember","GroupMember","DecodedMessage","client","contentType","conversationId","encodedContent","GroupMessageKind","Application","MembershipChange","DeliveryStatus","Unpublished","Published","Failed","decodeContent","Conversation","syncData","updateName","updateImageUrl","updateDescription","updatePinnedFrameUrl","createdAt","ns","Date","Number","members","syncAdmins","syncSuperAdmins","updatePermission","permissionType","policy","metadataField","isAdmin","includes","isSuperAdmin","sync","addMembers","addMembersByInboxId","inboxIds","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","safeEncodedContent","encodeContent","ContentTypeText","send","messages","updateConsentState","dmPeerInboxId","Conversations","syncAll","getConversationById","getMessageById","getDmByInboxId","list","listGroups","listDms","newGroup","newDm","accountAddress","isSmartContractSigner","signer","Client","codecs","conversations","encryptionKey","installationId","installationIdBytes","isReady","super","Worker","URL","url","loggingLevel","GroupUpdatedCodec","TextCodec","codec","toString","init","address","create","getAddress","disableAutoRegister","register","createInboxSignatureText","addAccountSignatureText","newAccountAddress","removeAccountSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","signatureType","signatureText","signature","signMessage","bytes","chainId","getChainId","blockNumber","getBlockNumber","applySignatures","SignatureRequestType","CreateInbox","addAccount","newAccountSigner","AddWallet","removeAccount","RevokeWallet","revokeAllOtherInstallations","RevokeInstallations","revokeInstallations","isRegistered","canMessage","env","Uint8Array","window","crypto","getRandomValues","findInboxIdByAddress","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","codecFor","encoded","encode","sameAs","ContentTypeGroupUpdated","decode","signWithInstallationKey","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","UtilsWorkerClass","Utils","generateInboxId","getInboxIdForAddress","ApiUrls","local","dev","production"],"mappings":"2/BASA,MAAMA,EAAeC,IACnBC,QAAQC,MAAM,wBAAwBF,EAAMG,cAAcH,EAAMI,aAChEH,QAAQC,MAAMF,EAAMK,QAAQ,QAGjBC,EACXC,GAEAC,GAEAC,GAAY,IAAIC,IAKhB,WAAAC,CAAYJ,EAAgBC,GAC1BI,MAAKL,EAAUA,EACfK,MAAKL,EAAQM,iBAAiB,UAAWD,KAAKE,eAC9CF,MAAKL,EAAQM,iBAAiB,QAASd,GACvCa,MAAKJ,EAAiBA,EAGxB,WAAAO,CACEC,EACAC,GAEA,MAAMC,EAAYC,IAClBP,MAAKL,EAAQa,YAAY,CACvBJ,SACAK,GAAIH,EACJD,SAKF,OAHgB,IAAIK,SAA+B,CAACC,EAASC,KAC3DZ,MAAKH,EAAUgB,IAAIP,EAAW,CAAEK,UAASC,UAAS,IAKtDV,cACEd,IAEA,MAAM0B,EAAY1B,EAAMiB,KACpBL,MAAKJ,GACPP,QAAQ0B,IAAI,6BAA8BD,GAE5C,MAAME,EAAUhB,MAAKH,EAAUoB,IAAIH,EAAUL,IACzCO,IACFhB,MAAKH,EAAUqB,OAAOJ,EAAUL,IAC5B,UAAWK,EACbE,EAAQJ,OAAO,IAAIO,MAAML,EAAUxB,QAEnC0B,EAAQL,QAAQG,EAAUM,UAKhC,KAAA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R,CAAgB1D,GACpB,OAAOtN,KAAKG,YAAY,kBAAmB,CACzCmN,UACA1N,cAAeI,MAAKJ,IAIxB,0BAAMqR,CAAqB3D,EAAiBkC,GAC1C,OAAOxP,KAAKG,YAAY,uBAAwB,CAC9CmN,UACAkC,MACA5P,cAAeI,MAAKJ,KCxBb,MAAAsR,EAAU,CACrBC,MAAO,wBACPC,IAAK,2BACLC,WAAY"}
1
+ {"version":3,"file":"index.js","sources":["../src/ClientWorkerClass.ts","../src/utils/conversions.ts","../src/DecodedMessage.ts","../src/Conversation.ts","../src/utils/date.ts","../src/Conversations.ts","../src/utils/signer.ts","../src/Client.ts","../src/UtilsWorkerClass.ts","../src/Utils.ts","../src/constants.ts"],"sourcesContent":["import { v4 } from \"uuid\";\nimport type {\n ClientEventsActions,\n ClientEventsErrorData,\n ClientEventsResult,\n ClientEventsWorkerMessageData,\n ClientSendMessageData,\n} from \"@/types\";\n\nconst handleError = (event: ErrorEvent) => {\n console.error(`Worker error on line ${event.lineno} in \"${event.filename}\"`);\n console.error(event.message);\n};\n\nexport class ClientWorkerClass {\n #worker: Worker;\n\n #enableLogging: boolean;\n\n #promises = new Map<\n string,\n { resolve: (value: any) => void; reject: (reason?: any) => void }\n >();\n\n constructor(worker: Worker, enableLogging: boolean) {\n this.#worker = worker;\n this.#worker.addEventListener(\"message\", this.handleMessage);\n this.#worker.addEventListener(\"error\", handleError);\n this.#enableLogging = enableLogging;\n }\n\n sendMessage<A extends ClientEventsActions>(\n action: A,\n data: ClientSendMessageData<A>,\n ) {\n const promiseId = v4();\n this.#worker.postMessage({\n action,\n id: promiseId,\n data,\n });\n const promise = new Promise<ClientEventsResult<A>>((resolve, reject) => {\n this.#promises.set(promiseId, { resolve, reject });\n });\n return promise;\n }\n\n handleMessage = (\n event: MessageEvent<ClientEventsWorkerMessageData | ClientEventsErrorData>,\n ) => {\n const eventData = event.data;\n if (this.#enableLogging) {\n console.log(\"client received event data\", eventData);\n }\n const promise = this.#promises.get(eventData.id);\n if (promise) {\n this.#promises.delete(eventData.id);\n if (\"error\" in eventData) {\n promise.reject(new Error(eventData.error));\n } else {\n promise.resolve(eventData.result);\n }\n }\n };\n\n close() {\n this.#worker.removeEventListener(\"message\", this.handleMessage);\n this.#worker.removeEventListener(\"error\", handleError);\n this.#worker.terminate();\n }\n}\n","import {\n ContentTypeId,\n type EncodedContent,\n} from \"@xmtp/content-type-primitives\";\nimport {\n Consent,\n CreateGroupOptions,\n GroupMember,\n GroupPermissionsOptions,\n ListConversationsOptions,\n ListMessagesOptions,\n PermissionPolicySet,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ConversationType,\n type DeliveryStatus,\n type GroupMembershipState,\n type GroupMessageKind,\n type HmacKey,\n type InboxState,\n type Installation,\n type Message,\n type PermissionLevel,\n type PermissionPolicy,\n type SortDirection,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: DeliveryStatus;\n id: string;\n kind: GroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: Message): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convoId,\n deliveryStatus: message.deliveryStatus,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.senderInboxId,\n sentAtNs: message.sentAtNs,\n});\n\nexport type SafeListMessagesOptions = {\n deliveryStatus?: DeliveryStatus;\n direction?: SortDirection;\n limit?: bigint;\n sentAfterNs?: bigint;\n sentBeforeNs?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: ListMessagesOptions,\n): SafeListMessagesOptions => ({\n deliveryStatus: options.deliveryStatus,\n direction: options.direction,\n limit: options.limit,\n sentAfterNs: options.sentAfterNs,\n sentBeforeNs: options.sentBeforeNs,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): ListMessagesOptions =>\n new ListMessagesOptions(\n options.sentBeforeNs,\n options.sentAfterNs,\n options.limit,\n options.deliveryStatus,\n options.direction,\n );\n\nexport type SafeListConversationsOptions = {\n allowedStates?: GroupMembershipState[];\n conversationType?: ConversationType;\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n allowedStates: options.allowedStates,\n conversationType: options.conversationType,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.allowedStates,\n options.conversationType,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: 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 updateGroupPinnedFrameUrlPolicy: policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy: policySet.updateMessageExpirationPolicy,\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.updateGroupPinnedFrameUrlPolicy,\n policySet.updateMessageExpirationPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n name?: string;\n permissions?: GroupPermissionsOptions;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n name: options.groupName,\n pinnedFrameUrl: options.groupPinnedFrameUrl,\n permissions: options.permissions,\n customPermissionPolicySet: options.customPermissionPolicySet,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): CreateGroupOptions =>\n new CreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n // 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 );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: GroupPermissionsOptions;\n policySet: {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: 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 id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,\n addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,\n removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,\n removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy:\n conversation.permissions.policySet.updateMessageExpirationPolicy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: await conversation.metadata(),\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\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 accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountAddresses: inboxState.accountAddresses,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recoveryAddress,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: ConsentEntityType;\n state: ConsentState;\n};\n\nexport const toSafeConsent = (consent: Consent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entityType,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): Consent =>\n new Consent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountAddresses: member.accountAddresses,\n consentState: member.consentState,\n inboxId: member.inboxId,\n installationIds: member.installationIds,\n permissionLevel: member.permissionLevel,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>\n new GroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n\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","import type { ContentTypeId } from \"@xmtp/content-type-primitives\";\nimport { DeliveryStatus, GroupMessageKind } from \"@xmtp/wasm-bindings\";\nimport type { Client } from \"@/Client\";\nimport { fromSafeContentTypeId, type SafeMessage } from \"@/utils/conversions\";\n\nexport type MessageKind = \"application\" | \"membership_change\";\nexport type MessageDeliveryStatus = \"unpublished\" | \"published\" | \"failed\";\n\nexport class DecodedMessage {\n #client: Client;\n\n content: any;\n\n contentType: ContentTypeId;\n\n conversationId: string;\n\n deliveryStatus: MessageDeliveryStatus;\n\n fallback?: string;\n\n compression?: number;\n\n id: string;\n\n kind: MessageKind;\n\n parameters: Map<string, string>;\n\n encodedContent: SafeMessage[\"content\"];\n\n senderInboxId: string;\n\n sentAtNs: bigint;\n\n constructor(client: Client, message: SafeMessage) {\n this.#client = client;\n this.id = message.id;\n this.sentAtNs = message.sentAtNs;\n this.conversationId = message.convoId;\n this.senderInboxId = message.senderInboxId;\n this.encodedContent = message.content;\n\n switch (message.kind) {\n case GroupMessageKind.Application:\n this.kind = \"application\";\n break;\n case GroupMessageKind.MembershipChange:\n this.kind = \"membership_change\";\n break;\n // no default\n }\n\n switch (message.deliveryStatus) {\n case DeliveryStatus.Unpublished:\n this.deliveryStatus = \"unpublished\";\n break;\n case DeliveryStatus.Published:\n this.deliveryStatus = \"published\";\n break;\n case DeliveryStatus.Failed:\n this.deliveryStatus = \"failed\";\n break;\n // no default\n }\n\n this.contentType = fromSafeContentTypeId(message.content.type);\n this.parameters = new Map(Object.entries(message.content.parameters));\n this.fallback = message.content.fallback;\n this.compression = message.content.compression;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this.content = this.#client.decodeContent(message, this.contentType);\n }\n}\n","import type { ContentTypeId } from \"@xmtp/content-type-primitives\";\nimport { ContentTypeText } from \"@xmtp/content-type-text\";\nimport type {\n ConsentState,\n MetadataField,\n PermissionPolicy,\n PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport type { Client } from \"@/Client\";\nimport { DecodedMessage } from \"@/DecodedMessage\";\nimport type {\n SafeConversation,\n SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport { nsToDate } from \"@/utils/date\";\n\nexport class Conversation {\n #client: Client;\n\n #id: string;\n\n #name?: SafeConversation[\"name\"];\n\n #imageUrl?: SafeConversation[\"imageUrl\"];\n\n #description?: SafeConversation[\"description\"];\n\n #pinnedFrameUrl?: SafeConversation[\"pinnedFrameUrl\"];\n\n #isActive?: SafeConversation[\"isActive\"];\n\n #addedByInboxId?: SafeConversation[\"addedByInboxId\"];\n\n #metadata?: SafeConversation[\"metadata\"];\n\n #createdAtNs?: SafeConversation[\"createdAtNs\"];\n\n #admins: SafeConversation[\"admins\"] = [];\n\n #superAdmins: SafeConversation[\"superAdmins\"] = [];\n\n constructor(client: Client, id: string, data?: SafeConversation) {\n this.#client = client;\n this.#id = id;\n this.#syncData(data);\n }\n\n #syncData(data?: SafeConversation) {\n this.#name = data?.name ?? \"\";\n this.#imageUrl = data?.imageUrl ?? \"\";\n this.#description = data?.description ?? \"\";\n this.#pinnedFrameUrl = data?.pinnedFrameUrl ?? \"\";\n this.#isActive = data?.isActive ?? undefined;\n this.#addedByInboxId = data?.addedByInboxId ?? \"\";\n this.#metadata = data?.metadata ?? undefined;\n this.#createdAtNs = data?.createdAtNs ?? undefined;\n this.#admins = data?.admins ?? [];\n this.#superAdmins = data?.superAdmins ?? [];\n }\n\n get id() {\n return this.#id;\n }\n\n get name() {\n return this.#name;\n }\n\n async updateName(name: string) {\n await this.#client.sendMessage(\"updateGroupName\", {\n id: this.#id,\n name,\n });\n this.#name = name;\n }\n\n get imageUrl() {\n return this.#imageUrl;\n }\n\n async updateImageUrl(imageUrl: string) {\n await this.#client.sendMessage(\"updateGroupImageUrlSquare\", {\n id: this.#id,\n imageUrl,\n });\n this.#imageUrl = imageUrl;\n }\n\n get description() {\n return this.#description;\n }\n\n async updateDescription(description: string) {\n await this.#client.sendMessage(\"updateGroupDescription\", {\n id: this.#id,\n description,\n });\n this.#description = description;\n }\n\n get pinnedFrameUrl() {\n return this.#pinnedFrameUrl;\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n await this.#client.sendMessage(\"updateGroupPinnedFrameUrl\", {\n id: this.#id,\n pinnedFrameUrl,\n });\n this.#pinnedFrameUrl = pinnedFrameUrl;\n }\n\n get isActive() {\n return this.#isActive;\n }\n\n get addedByInboxId() {\n return this.#addedByInboxId;\n }\n\n get createdAtNs() {\n return this.#createdAtNs;\n }\n\n get createdAt() {\n return this.#createdAtNs ? nsToDate(this.#createdAtNs) : undefined;\n }\n\n get metadata() {\n return this.#metadata;\n }\n\n async members() {\n return this.#client.sendMessage(\"getGroupMembers\", {\n id: this.#id,\n });\n }\n\n get admins() {\n return this.#admins;\n }\n\n get superAdmins() {\n return this.#superAdmins;\n }\n\n async syncAdmins() {\n const admins = await this.#client.sendMessage(\"getGroupAdmins\", {\n id: this.#id,\n });\n this.#admins = admins;\n }\n\n async syncSuperAdmins() {\n const superAdmins = await this.#client.sendMessage(\"getGroupSuperAdmins\", {\n id: this.#id,\n });\n this.#superAdmins = superAdmins;\n }\n\n async permissions() {\n return this.#client.sendMessage(\"getGroupPermissions\", {\n id: this.#id,\n });\n }\n\n async updatePermission(\n permissionType: PermissionUpdateType,\n policy: PermissionPolicy,\n metadataField?: MetadataField,\n ) {\n return this.#client.sendMessage(\"updateGroupPermissionPolicy\", {\n id: this.#id,\n permissionType,\n policy,\n metadataField,\n });\n }\n\n async isAdmin(inboxId: string) {\n await this.syncAdmins();\n return this.#admins.includes(inboxId);\n }\n\n async isSuperAdmin(inboxId: string) {\n await this.syncSuperAdmins();\n return this.#superAdmins.includes(inboxId);\n }\n\n async sync() {\n const data = await this.#client.sendMessage(\"syncGroup\", {\n id: this.#id,\n });\n this.#syncData(data);\n }\n\n async addMembers(accountAddresses: string[]) {\n return this.#client.sendMessage(\"addGroupMembers\", {\n id: this.#id,\n accountAddresses,\n });\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#client.sendMessage(\"addGroupMembersByInboxId\", {\n id: this.#id,\n inboxIds,\n });\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#client.sendMessage(\"removeGroupMembers\", {\n id: this.#id,\n accountAddresses,\n });\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#client.sendMessage(\"removeGroupMembersByInboxId\", {\n id: this.#id,\n inboxIds,\n });\n }\n\n async addAdmin(inboxId: string) {\n return this.#client.sendMessage(\"addGroupAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async removeAdmin(inboxId: string) {\n return this.#client.sendMessage(\"removeGroupAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#client.sendMessage(\"addGroupSuperAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#client.sendMessage(\"removeGroupSuperAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async publishMessages() {\n return this.#client.sendMessage(\"publishGroupMessages\", {\n id: this.#id,\n });\n }\n\n async sendOptimistic(content: any, contentType?: ContentTypeId) {\n if (typeof content !== \"string\" && !contentType) {\n throw new Error(\n \"Content type is required when sending content other than text\",\n );\n }\n\n const safeEncodedContent =\n typeof content === \"string\"\n ? this.#client.encodeContent(content, contentType ?? ContentTypeText)\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.#client.encodeContent(content, contentType!);\n\n return this.#client.sendMessage(\"sendOptimisticGroupMessage\", {\n id: this.#id,\n content: safeEncodedContent,\n });\n }\n\n async send(content: any, contentType?: ContentTypeId) {\n if (typeof content !== \"string\" && !contentType) {\n throw new Error(\n \"Content type is required when sending content other than text\",\n );\n }\n\n const safeEncodedContent =\n typeof content === \"string\"\n ? this.#client.encodeContent(content, contentType ?? ContentTypeText)\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.#client.encodeContent(content, contentType!);\n\n return this.#client.sendMessage(\"sendGroupMessage\", {\n id: this.#id,\n content: safeEncodedContent,\n });\n }\n\n async messages(options?: SafeListMessagesOptions) {\n const messages = await this.#client.sendMessage(\"getGroupMessages\", {\n id: this.#id,\n options,\n });\n\n return messages.map((message) => new DecodedMessage(this.#client, message));\n }\n\n async consentState() {\n return this.#client.sendMessage(\"getGroupConsentState\", {\n id: this.#id,\n });\n }\n\n async updateConsentState(state: ConsentState) {\n return this.#client.sendMessage(\"updateGroupConsentState\", {\n id: this.#id,\n state,\n });\n }\n\n async dmPeerInboxId() {\n return this.#client.sendMessage(\"getDmPeerInboxId\", {\n id: this.#id,\n });\n }\n}\n","export function nsToDate(ns: bigint): Date {\n return new Date(Number(ns / 1_000_000n));\n}\n","import type { Client } from \"@/Client\";\nimport { Conversation } from \"@/Conversation\";\nimport { DecodedMessage } from \"@/DecodedMessage\";\nimport type {\n SafeCreateGroupOptions,\n SafeListConversationsOptions,\n} from \"@/utils/conversions\";\n\nexport class Conversations {\n #client: Client;\n\n constructor(client: Client) {\n this.#client = client;\n }\n\n async sync() {\n return this.#client.sendMessage(\"syncConversations\", undefined);\n }\n\n async syncAll() {\n return this.#client.sendMessage(\"syncAllConversations\", undefined);\n }\n\n async getConversationById(id: string) {\n const data = await this.#client.sendMessage(\"getConversationById\", {\n id,\n });\n return data ? new Conversation(this.#client, id, data) : undefined;\n }\n\n async getMessageById(id: string) {\n const data = await this.#client.sendMessage(\"getMessageById\", {\n id,\n });\n return data ? new DecodedMessage(this.#client, data) : undefined;\n }\n\n async getDmByInboxId(inboxId: string) {\n const data = await this.#client.sendMessage(\"getDmByInboxId\", {\n inboxId,\n });\n return data ? new Conversation(this.#client, data.id, data) : undefined;\n }\n\n async list(options?: SafeListConversationsOptions) {\n const conversations = await this.#client.sendMessage(\"getConversations\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const conversations = await this.#client.sendMessage(\"getGroups\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async listDms(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const conversations = await this.#client.sendMessage(\"getDms\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const conversation = await this.#client.sendMessage(\"newGroup\", {\n accountAddresses,\n options,\n });\n\n return new Conversation(this.#client, conversation.id, conversation);\n }\n\n async newDm(accountAddress: string) {\n const conversation = await this.#client.sendMessage(\"newDm\", {\n accountAddress,\n });\n\n return new Conversation(this.#client, conversation.id, conversation);\n }\n\n async getHmacKeys() {\n return this.#client.sendMessage(\"getHmacKeys\", undefined);\n }\n}\n","export type SignMessage = (message: string) => Promise<Uint8Array> | Uint8Array;\nexport type GetAddress = () => Promise<string> | string;\nexport type GetChainId = () => bigint;\nexport type GetBlockNumber = () => bigint;\n\nexport type Signer = {\n getAddress: GetAddress;\n signMessage: SignMessage;\n // these fields indicate that the signer is a smart contract wallet\n getBlockNumber?: GetBlockNumber;\n getChainId?: GetChainId;\n};\n\nexport type SmartContractSigner = Required<Signer>;\n\nexport const isSmartContractSigner = (\n signer: Signer,\n): signer is SmartContractSigner =>\n \"getBlockNumber\" in signer && \"getChainId\" in signer;\n","import {\n ContentTypeGroupUpdated,\n GroupUpdatedCodec,\n} from \"@xmtp/content-type-group-updated\";\nimport type {\n ContentCodec,\n ContentTypeId,\n} from \"@xmtp/content-type-primitives\";\nimport { TextCodec } from \"@xmtp/content-type-text\";\nimport {\n GroupMessageKind,\n SignatureRequestType,\n type ConsentEntityType,\n} from \"@xmtp/wasm-bindings\";\nimport { ClientWorkerClass } from \"@/ClientWorkerClass\";\nimport { Conversations } from \"@/Conversations\";\nimport type { ClientOptions, XmtpEnv } from \"@/types\";\nimport {\n fromSafeEncodedContent,\n toSafeEncodedContent,\n type SafeConsent,\n type SafeMessage,\n} from \"@/utils/conversions\";\nimport { isSmartContractSigner, type Signer } from \"@/utils/signer\";\n\nexport class Client extends ClientWorkerClass {\n #accountAddress: string;\n #codecs: Map<string, ContentCodec>;\n #conversations: Conversations;\n #encryptionKey: Uint8Array;\n #inboxId: string | undefined;\n #installationId: string | undefined;\n #installationIdBytes: Uint8Array | undefined;\n #isReady = false;\n #signer: Signer;\n options?: ClientOptions;\n\n constructor(\n signer: Signer,\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: ClientOptions,\n ) {\n const worker = new Worker(new URL(\"./workers/client\", import.meta.url), {\n type: \"module\",\n });\n super(\n worker,\n options?.loggingLevel !== undefined && options.loggingLevel !== \"off\",\n );\n this.#accountAddress = accountAddress;\n this.options = options;\n this.#encryptionKey = encryptionKey;\n this.#signer = signer;\n this.#conversations = new Conversations(this);\n const codecs = [\n new GroupUpdatedCodec(),\n new TextCodec(),\n ...(options?.codecs ?? []),\n ];\n this.#codecs = new Map(\n codecs.map((codec) => [codec.contentType.toString(), codec]),\n );\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n async init() {\n const result = await this.sendMessage(\"init\", {\n address: this.accountAddress,\n encryptionKey: this.#encryptionKey,\n options: this.options,\n });\n this.#inboxId = result.inboxId;\n this.#installationId = result.installationId;\n this.#installationIdBytes = result.installationIdBytes;\n this.#isReady = true;\n }\n\n static async create(\n signer: Signer,\n encryptionKey: Uint8Array,\n options?: ClientOptions,\n ) {\n const address = await signer.getAddress();\n const client = new Client(signer, address, encryptionKey, options);\n\n await client.init();\n\n if (!options?.disableAutoRegister) {\n await client.register();\n }\n\n return client;\n }\n\n get isReady() {\n return this.#isReady;\n }\n\n get inboxId() {\n return this.#inboxId;\n }\n\n get installationId() {\n return this.#installationId;\n }\n\n get installationIdBytes() {\n return this.#installationIdBytes;\n }\n\n async #createInboxSignatureText() {\n return this.sendMessage(\"createInboxSignatureText\", undefined);\n }\n\n async #addAccountSignatureText(newAccountAddress: string) {\n return this.sendMessage(\"addAccountSignatureText\", {\n newAccountAddress,\n });\n }\n\n async #removeAccountSignatureText(accountAddress: string) {\n return this.sendMessage(\"removeAccountSignatureText\", { accountAddress });\n }\n\n async #revokeAllOtherInstallationsSignatureText() {\n return this.sendMessage(\n \"revokeAllOtherInstallationsSignatureText\",\n undefined,\n );\n }\n\n async #revokeInstallationsSignatureText(installationIds: Uint8Array[]) {\n return this.sendMessage(\"revokeInstallationsSignatureText\", {\n installationIds,\n });\n }\n\n async #addSignature(\n signatureType: SignatureRequestType,\n signatureText: string,\n signer: Signer,\n ) {\n const signature = await signer.signMessage(signatureText);\n\n if (isSmartContractSigner(signer)) {\n await this.sendMessage(\"addScwSignature\", {\n type: signatureType,\n bytes: signature,\n chainId: signer.getChainId(),\n blockNumber: signer.getBlockNumber(),\n });\n } else {\n await this.sendMessage(\"addSignature\", {\n type: signatureType,\n bytes: signature,\n });\n }\n }\n\n async #applySignatures() {\n return this.sendMessage(\"applySignatures\", undefined);\n }\n\n async register() {\n const signatureText = await this.#createInboxSignatureText();\n\n // if the signature text is not available, the client is already registered\n if (!signatureText) {\n return;\n }\n\n await this.#addSignature(\n SignatureRequestType.CreateInbox,\n signatureText,\n this.#signer,\n );\n\n return this.sendMessage(\"registerIdentity\", undefined);\n }\n\n async addAccount(newAccountSigner: Signer) {\n const signatureText = await this.#addAccountSignatureText(\n await newAccountSigner.getAddress(),\n );\n\n if (!signatureText) {\n throw new Error(\"Unable to generate add account signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.AddWallet,\n signatureText,\n newAccountSigner,\n );\n\n await this.#applySignatures();\n }\n\n async removeAccount(accountAddress: string) {\n const signatureText =\n await this.#removeAccountSignatureText(accountAddress);\n\n if (!signatureText) {\n throw new Error(\"Unable to generate remove account signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeWallet,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async revokeAllOtherInstallations() {\n const signatureText =\n await this.#revokeAllOtherInstallationsSignatureText();\n\n if (!signatureText) {\n throw new Error(\n \"Unable to generate revoke all other installations signature text\",\n );\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeInstallations,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async revokeInstallations(installationIds: Uint8Array[]) {\n const signatureText =\n await this.#revokeInstallationsSignatureText(installationIds);\n\n if (!signatureText) {\n throw new Error(\"Unable to generate revoke installations signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeInstallations,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async isRegistered() {\n return this.sendMessage(\"isRegistered\", undefined);\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.sendMessage(\"canMessage\", { accountAddresses });\n }\n\n static async canMessage(accountAddresses: string[], env?: XmtpEnv) {\n const accountAddress = \"0x0000000000000000000000000000000000000000\";\n const signer: Signer = {\n getAddress: () => accountAddress,\n signMessage: () => new Uint8Array(),\n };\n const client = await Client.create(\n signer,\n window.crypto.getRandomValues(new Uint8Array(32)),\n {\n disableAutoRegister: true,\n env,\n },\n );\n return client.canMessage(accountAddresses);\n }\n\n async findInboxIdByAddress(address: string) {\n return this.sendMessage(\"findInboxIdByAddress\", { address });\n }\n\n async inboxState(refreshFromNetwork?: boolean) {\n return this.sendMessage(\"inboxState\", {\n refreshFromNetwork: refreshFromNetwork ?? false,\n });\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.sendMessage(\"getLatestInboxState\", { inboxId });\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.sendMessage(\"setConsentStates\", { records });\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.sendMessage(\"getConsentState\", { entityType, entity });\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n codecFor(contentType: ContentTypeId) {\n return this.#codecs.get(contentType.toString());\n }\n\n encodeContent(content: any, contentType: ContentTypeId) {\n const codec = this.codecFor(contentType);\n if (!codec) {\n throw new Error(\n `Codec not found for \"${contentType.toString()}\" content type`,\n );\n }\n const encoded = codec.encode(content, this);\n const fallback = codec.fallback(content);\n if (fallback) {\n encoded.fallback = fallback;\n }\n return toSafeEncodedContent(encoded);\n }\n\n decodeContent(message: SafeMessage, contentType: ContentTypeId) {\n const codec = this.codecFor(contentType);\n if (!codec) {\n throw new Error(\n `Codec not found for \"${contentType.toString()}\" content type`,\n );\n }\n\n // throw an error if there's an invalid group membership change message\n if (\n contentType.sameAs(ContentTypeGroupUpdated) &&\n message.kind !== GroupMessageKind.MembershipChange\n ) {\n throw new Error(\"Error decoding group membership change\");\n }\n\n const encodedContent = fromSafeEncodedContent(message.content);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return codec.decode(encodedContent, this);\n }\n\n signWithInstallationKey(signatureText: string) {\n return this.sendMessage(\"signWithInstallationKey\", { signatureText });\n }\n\n verifySignedWithInstallationKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n ) {\n return this.sendMessage(\"verifySignedWithInstallationKey\", {\n signatureText,\n signatureBytes,\n });\n }\n\n verifySignedWithPublicKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n publicKey: Uint8Array,\n ) {\n return this.sendMessage(\"verifySignedWithPublicKey\", {\n signatureText,\n signatureBytes,\n publicKey,\n });\n }\n}\n","import { v4 } from \"uuid\";\nimport type {\n UtilsEventsActions,\n UtilsEventsErrorData,\n UtilsEventsResult,\n UtilsEventsWorkerMessageData,\n UtilsSendMessageData,\n} from \"@/types\";\n\nconst handleError = (event: ErrorEvent) => {\n console.error(`Worker error on line ${event.lineno} in \"${event.filename}\"`);\n console.error(event.message);\n};\n\nexport class UtilsWorkerClass {\n #worker: Worker;\n\n #enableLogging: boolean;\n\n #promises = new Map<\n string,\n { resolve: (value: any) => void; reject: (reason?: any) => void }\n >();\n\n constructor(worker: Worker, enableLogging: boolean) {\n this.#worker = worker;\n this.#worker.addEventListener(\"message\", this.handleMessage);\n this.#worker.addEventListener(\"error\", handleError);\n this.#enableLogging = enableLogging;\n }\n\n sendMessage<A extends UtilsEventsActions>(\n action: A,\n data: UtilsSendMessageData<A>,\n ) {\n const promiseId = v4();\n this.#worker.postMessage({\n action,\n id: promiseId,\n data,\n });\n const promise = new Promise<UtilsEventsResult<A>>((resolve, reject) => {\n this.#promises.set(promiseId, { resolve, reject });\n });\n return promise;\n }\n\n handleMessage = (\n event: MessageEvent<UtilsEventsWorkerMessageData | UtilsEventsErrorData>,\n ) => {\n const eventData = event.data;\n if (this.#enableLogging) {\n console.log(\"utils received event data\", eventData);\n }\n const promise = this.#promises.get(eventData.id);\n if (promise) {\n this.#promises.delete(eventData.id);\n if (\"error\" in eventData) {\n promise.reject(new Error(eventData.error));\n } else {\n promise.resolve(eventData.result);\n }\n }\n };\n\n close() {\n this.#worker.removeEventListener(\"message\", this.handleMessage);\n this.#worker.removeEventListener(\"error\", handleError);\n this.#worker.terminate();\n }\n}\n","import type { XmtpEnv } from \"@/types/options\";\nimport { UtilsWorkerClass } from \"@/UtilsWorkerClass\";\n\nexport class Utils extends UtilsWorkerClass {\n #enableLogging: boolean;\n constructor(enableLogging?: boolean) {\n const worker = new Worker(new URL(\"./workers/utils\", import.meta.url), {\n type: \"module\",\n });\n super(worker, enableLogging ?? false);\n this.#enableLogging = enableLogging ?? false;\n }\n\n async generateInboxId(address: string) {\n return this.sendMessage(\"generateInboxId\", {\n address,\n enableLogging: this.#enableLogging,\n });\n }\n\n async getInboxIdForAddress(address: string, env?: XmtpEnv) {\n return this.sendMessage(\"getInboxIdForAddress\", {\n address,\n env,\n enableLogging: this.#enableLogging,\n });\n }\n}\n","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n"],"names":["handleError","event","console","error","lineno","filename","message","ClientWorkerClass","worker","enableLogging","promises","Map","constructor","this","addEventListener","handleMessage","sendMessage","action","data","promiseId","v4","postMessage","id","Promise","resolve","reject","set","eventData","log","promise","get","delete","Error","result","close","removeEventListener","terminate","toContentTypeId","contentTypeId","ContentTypeId","authorityId","typeId","versionMajor","versionMinor","fromContentTypeId","WasmContentTypeId","toSafeContentTypeId","fromSafeContentTypeId","toEncodedContent","content","type","parameters","Object","fromEntries","fallback","compression","fromEncodedContent","WasmEncodedContent","entries","toSafeEncodedContent","fromSafeEncodedContent","toSafeMessage","convoId","deliveryStatus","kind","senderInboxId","sentAtNs","toSafeListMessagesOptions","options","direction","limit","sentAfterNs","sentBeforeNs","fromSafeListMessagesOptions","ListMessagesOptions","toSafeListConversationsOptions","allowedStates","conversationType","createdAfterNs","createdBeforeNs","fromSafeListConversationsOptions","ListConversationsOptions","toSafePermissionPolicySet","policySet","addAdminPolicy","addMemberPolicy","removeAdminPolicy","removeMemberPolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateGroupNamePolicy","updateGroupPinnedFrameUrlPolicy","updateMessageExpirationPolicy","fromSafePermissionPolicySet","PermissionPolicySet","toSafeCreateGroupOptions","description","groupDescription","imageUrlSquare","groupImageUrlSquare","name","groupName","pinnedFrameUrl","groupPinnedFrameUrl","permissions","customPermissionPolicySet","fromSafeCreateGroupOptions","CreateGroupOptions","GroupPermissionsOptions","CustomPolicy","undefined","toSafeConversation","async","conversation","imageUrl","policyType","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","bytes","clientTimestampNs","toSafeInboxState","inboxState","accountAddresses","inboxId","installations","map","recoveryAddress","toSafeConsent","consent","entity","entityType","state","fromSafeConsent","Consent","toSafeGroupMember","member","consentState","installationIds","permissionLevel","fromSafeGroupMember","GroupMember","toSafeHmacKey","hmacKey","key","epoch","DecodedMessage","client","contentType","conversationId","encodedContent","GroupMessageKind","Application","MembershipChange","DeliveryStatus","Unpublished","Published","Failed","decodeContent","Conversation","syncData","updateName","updateImageUrl","updateDescription","updatePinnedFrameUrl","createdAt","ns","Date","Number","members","syncAdmins","syncSuperAdmins","updatePermission","permissionType","policy","metadataField","isAdmin","includes","isSuperAdmin","sync","addMembers","addMembersByInboxId","inboxIds","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","safeEncodedContent","encodeContent","ContentTypeText","send","messages","updateConsentState","dmPeerInboxId","Conversations","syncAll","getConversationById","getMessageById","getDmByInboxId","list","listGroups","listDms","newGroup","newDm","accountAddress","getHmacKeys","isSmartContractSigner","signer","Client","codecs","conversations","encryptionKey","installationId","installationIdBytes","isReady","super","Worker","URL","url","loggingLevel","GroupUpdatedCodec","TextCodec","codec","toString","init","address","create","getAddress","disableAutoRegister","register","createInboxSignatureText","addAccountSignatureText","newAccountAddress","removeAccountSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","signatureType","signatureText","signature","signMessage","chainId","getChainId","blockNumber","getBlockNumber","applySignatures","SignatureRequestType","CreateInbox","addAccount","newAccountSigner","AddWallet","removeAccount","RevokeWallet","revokeAllOtherInstallations","RevokeInstallations","revokeInstallations","isRegistered","canMessage","env","Uint8Array","window","crypto","getRandomValues","findInboxIdByAddress","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","codecFor","encoded","encode","sameAs","ContentTypeGroupUpdated","decode","signWithInstallationKey","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","UtilsWorkerClass","Utils","generateInboxId","getInboxIdForAddress","ApiUrls","local","dev","production"],"mappings":"mgCASA,MAAMA,EAAeC,IACnBC,QAAQC,MAAM,wBAAwBF,EAAMG,cAAcH,EAAMI,aAChEH,QAAQC,MAAMF,EAAMK,QAAQ,QAGjBC,EACXC,GAEAC,GAEAC,GAAY,IAAIC,IAKhB,WAAAC,CAAYJ,EAAgBC,GAC1BI,MAAKL,EAAUA,EACfK,MAAKL,EAAQM,iBAAiB,UAAWD,KAAKE,eAC9CF,MAAKL,EAAQM,iBAAiB,QAASd,GACvCa,MAAKJ,EAAiBA,EAGxB,WAAAO,CACEC,EACAC,GAEA,MAAMC,EAAYC,IAClBP,MAAKL,EAAQa,YAAY,CACvBJ,SACAK,GAAIH,EACJD,SAKF,OAHgB,IAAIK,SAA+B,CAACC,EAASC,KAC3DZ,MAAKH,EAAUgB,IAAIP,EAAW,CAAEK,UAASC,UAAS,IAKtDV,cACEd,IAEA,MAAM0B,EAAY1B,EAAMiB,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IAAI,4BAA6BD,GAE3C,MAAME,EAAUhB,MAAKH,EAAUoB,IAAIH,EAAUL,IACzCO,IACFhB,MAAKH,EAAUqB,OAAOJ,EAAUL,IAC5B,UAAWK,EACbE,EAAQJ,OAAO,IAAIO,MAAML,EAAUxB,QAEnC0B,EAAQL,QAAQG,EAAUM,UAKhC,KAAAC,GACErB,MAAKL,EAAQ2B,oBAAoB,UAAWtB,KAAKE,eACjDF,MAAKL,EAAQ2B,oBAAoB,QAASnC,GAC1Ca,MAAKL,EAAQ4B,aCjEX,MAAO8P,UAAcD,EACzBxR,GACA,WAAAG,CAAYH,GAIVuN,MAHe,IAAIC,OAAO,IAAIC,IAAI,8BAA+BC,KAAM,CACrEjL,KAAM,WAEMzC,IAAiB,GAC/BI,MAAKJ,EAAiBA,IAAiB,EAGzC,qBAAM0R,CAAgBzD,GACpB,OAAO7N,KAAKG,YAAY,kBAAmB,CACzC0N,UACAjO,cAAeI,MAAKJ,IAIxB,0BAAM2R,CAAqB1D,EAAiBiC,GAC1C,OAAO9P,KAAKG,YAAY,uBAAwB,CAC9C0N,UACAiC,MACAlQ,cAAeI,MAAKJ,KCxBb,MAAA4R,EAAU,CACrBC,MAAO,wBACPC,IAAK,2BACLC,WAAY"}
@@ -1,2 +1,2 @@
1
- import{ContentTypeId as e}from"@xmtp/content-type-primitives";import t,{EncodedContent as n,ContentTypeId as i,Consent as r,ListConversationsOptions as s,CreateGroupOptions as o,GroupPermissionsOptions as a,ListMessagesOptions as d,PermissionPolicySet as c,getInboxIdForAddress as u,generateInboxId as l,createClient as p,LogOptions as y,verifySignedWithPublicKey as m}from"@xmtp/wasm-bindings";const g=e=>{return new n((t=e.type,new i(t.authorityId,t.typeId,t.versionMajor,t.versionMinor)),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content);var t},v=e=>{return{type:(t=e.type,{authorityId:t.authorityId,typeId:t.typeId,versionMajor:t.versionMajor,versionMinor:t.versionMinor}),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content};var t},I=t=>{return{type:(n=t.type,new e({authorityId:n.authorityId,typeId:n.typeId,versionMajor:n.versionMajor,versionMinor:n.versionMinor})),parameters:t.parameters,fallback:t.fallback,compression:t.compression,content:t.content};var n},b=t=>{return{content:v((n=t.content,{type:(i=n.type,new e({authorityId:i.authorityId,typeId:i.typeId,versionMajor:i.versionMajor,versionMinor:i.versionMinor})),parameters:Object.fromEntries(n.parameters),fallback:n.fallback,compression:n.compression,content:n.content})),convoId:t.convoId,deliveryStatus:t.deliveryStatus,id:t.id,kind:t.kind,senderInboxId:t.senderInboxId,sentAtNs:t.sentAtNs};var n,i},h=e=>new s(e.allowedStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.limit),S=e=>{return new o(e.permissions,e.name,e.imageUrlSquare,e.description,e.pinnedFrameUrl,e.customPermissionPolicySet&&e.permissions===a.CustomPolicy?(t=e.customPermissionPolicySet,new c(t.addMemberPolicy,t.removeMemberPolicy,t.addAdminPolicy,t.removeAdminPolicy,t.updateGroupNamePolicy,t.updateGroupDescriptionPolicy,t.updateGroupImageUrlSquarePolicy,t.updateGroupPinnedFrameUrlPolicy)):void 0);var t},w=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,pinnedFrameUrl:e.pinnedFrameUrl,permissions:{policyType:e.permissions.policyType,policySet:{addAdminPolicy:e.permissions.policySet.addAdminPolicy,addMemberPolicy:e.permissions.policySet.addMemberPolicy,removeAdminPolicy:e.permissions.policySet.removeAdminPolicy,removeMemberPolicy:e.permissions.policySet.removeMemberPolicy,updateGroupDescriptionPolicy:e.permissions.policySet.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.permissions.policySet.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.permissions.policySet.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.permissions.policySet.updateGroupPinnedFrameUrlPolicy}},isActive:e.isActive,addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.admins,superAdmins:e.superAdmins,createdAtNs:e.createdAtNs}),A=e=>({id:e.id,clientTimestampNs:e.clientTimestampNs}),x=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(A),recoveryAddress:e.recoveryAddress}),k=e=>new r(e.entityType,e.state,e.entity),G={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"};class f{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get id(){return this.#t.id()}get name(){return this.#t.groupName()}async updateName(e){return this.#t.updateGroupName(e)}get imageUrl(){return this.#t.groupImageUrlSquare()}async updateImageUrl(e){return this.#t.updateGroupImageUrlSquare(e)}get description(){return this.#t.groupDescription()}async updateDescription(e){return this.#t.updateGroupDescription(e)}get pinnedFrameUrl(){return this.#t.groupPinnedFrameUrl()}async updatePinnedFrameUrl(e){return this.#t.updateGroupPinnedFrameUrl(e)}get isActive(){return this.#t.isActive()}get addedByInboxId(){return this.#t.addedByInboxId()}get createdAtNs(){return this.#t.createdAtNs()}async metadata(){const e=await this.#t.groupMetadata();return{creatorInboxId:e.creatorInboxId(),conversationType:e.conversationType()}}async members(){return(await this.#t.listMembers()).map((e=>(e=>({accountAddresses:e.accountAddresses,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}))(e)))}get admins(){return this.#t.adminList()}get superAdmins(){return this.#t.superAdminList()}get permissions(){const e=this.#t.groupPermissions();return{policyType:e.policyType(),policySet:e.policySet()}}async updatePermission(e,t,n){return this.#t.updatePermissionPolicy(e,t,n)}isAdmin(e){return this.#t.isAdmin(e)}isSuperAdmin(e){return this.#t.isSuperAdmin(e)}async sync(){return this.#t.sync()}async addMembers(e){return this.#t.addMembers(e)}async addMembersByInboxId(e){return this.#t.addMembersByInboxId(e)}async removeMembers(e){return this.#t.removeMembers(e)}async removeMembersByInboxId(e){return this.#t.removeMembersByInboxId(e)}async addAdmin(e){return this.#t.addAdmin(e)}async removeAdmin(e){return this.#t.removeAdmin(e)}async addSuperAdmin(e){return this.#t.addSuperAdmin(e)}async removeSuperAdmin(e){return this.#t.removeSuperAdmin(e)}async publishMessages(){return this.#t.publishMessages()}sendOptimistic(e){return this.#t.sendOptimistic(e)}async send(e){return this.#t.send(e)}async messages(e){return this.#t.findMessages(e?(e=>new d(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction))(e):void 0)}get consentState(){return this.#t.consentState()}updateConsentState(e){this.#t.updateConsentState(e)}dmPeerInboxId(){return this.#t.dmPeerInboxId()}}class B{#e;#n;constructor(e,t){this.#e=e,this.#n=t}async sync(){return this.#n.sync()}async syncAll(){return this.#n.syncAllConversations()}getConversationById(e){try{const t=this.#n.findGroupById(e);return new f(this.#e,t)}catch{return}}getMessageById(e){try{return this.#n.findMessageById(e)}catch{return}}getDmByInboxId(e){try{const t=this.#n.findDmByTargetInboxId(e);return new f(this.#e,t)}catch{return}}list(e){return this.#n.list(e?h(e):void 0).map((e=>new f(this.#e,e)))}listGroups(e){return this.#n.listGroups(e?h(e):void 0).map((e=>new f(this.#e,e)))}listDms(e){return this.#n.listDms(e?h(e):void 0).map((e=>new f(this.#e,e)))}async newGroup(e,t){const n=await this.#n.createGroup(e,t?S(t):void 0);return new f(this.#e,n)}async newDm(e){const t=await this.#n.createDm(e);return new f(this.#e,t)}}class M{#e;#n;#i;constructor(e){this.#e=e,this.#i=e.accountAddress,this.#n=new B(this,e.conversations())}static async create(e,n,i){const r=await(async(e,n,i)=>{await t();const r=i?.apiUrl??G[i?.env??"dev"],s=i?.dbPath??`xmtp-${i?.env??"dev"}-${e}.db3`,o=await u(r,e)||l(e),a=i&&(void 0!==i.loggingLevel||i.structuredLogging||i.performanceLogging);return p(r,o,e,s,n,void 0,a?new y(i.structuredLogging??!1,i.performanceLogging??!1,i.loggingLevel):void 0)})(e,n,i);return new M(r)}get accountAddress(){return this.#i}get inboxId(){return this.#e.inboxId}get installationId(){return this.#e.installationId}get installationIdBytes(){return this.#e.installationIdBytes}get isRegistered(){return this.#e.isRegistered}async createInboxSignatureText(){try{return await this.#e.createInboxSignatureText()}catch{return}}async addAccountSignatureText(e){try{return await this.#e.addWalletSignatureText(e)}catch{return}}async removeAccountSignatureText(e){try{return await this.#e.revokeWalletSignatureText(e)}catch{return}}async revokeAllAOtherInstallationsSignatureText(){try{return await this.#e.revokeAllOtherInstallationsSignatureText()}catch{return}}async revokeInstallationsSignatureText(e){try{return await this.#e.revokeInstallationsSignatureText(e)}catch{return}}async addSignature(e,t){return this.#e.addSignature(e,t)}async addScwSignature(e,t,n,i){return this.#e.addScwSignature(e,t,n,i)}async applySignatures(){return this.#e.applySignatureRequests()}async canMessage(e){return this.#e.canMessage(e)}async registerIdentity(){return this.#e.registerIdentity()}async findInboxIdByAddress(e){return this.#e.findInboxIdByAddress(e)}async inboxState(e){return this.#e.inboxState(e)}async getLatestInboxState(e){return this.#e.getLatestInboxState(e)}async setConsentStates(e){return this.#e.setConsentStates(e.map(k))}async getConsentState(e,t){return this.#e.getConsentState(e,t)}get conversations(){return this.#n}signWithInstallationKey(e){return this.#e.signWithInstallationKey(e)}verifySignedWithInstallationKey(e,t){try{return this.#e.verifySignedWithInstallationKey(e,t),!0}catch{return!1}}verifySignedWithPublicKey(e,t,n){try{return m(e,t,n),!0}catch{return!1}}}let P,C=!1;const T=e=>{self.postMessage(e)},U=e=>{self.postMessage(e)};self.onmessage=async e=>{const{action:t,id:n,data:i}=e.data;if(C&&console.log("client worker received event data",e.data),"init"===t||P)try{switch(t){case"init":P=await M.create(i.address,i.encryptionKey,i.options),C=void 0!==i.options?.loggingLevel&&"off"!==i.options.loggingLevel,T({id:n,action:t,result:{inboxId:P.inboxId,installationId:P.installationId,installationIdBytes:P.installationIdBytes}});break;case"createInboxSignatureText":{const e=await P.createInboxSignatureText();T({id:n,action:t,result:e});break}case"addAccountSignatureText":{const e=await P.addAccountSignatureText(i.newAccountAddress);T({id:n,action:t,result:e});break}case"removeAccountSignatureText":{const e=await P.removeAccountSignatureText(i.accountAddress);T({id:n,action:t,result:e});break}case"revokeAllOtherInstallationsSignatureText":{const e=await P.revokeAllAOtherInstallationsSignatureText();T({id:n,action:t,result:e});break}case"revokeInstallationsSignatureText":{const e=await P.revokeInstallationsSignatureText(i.installationIds);T({id:n,action:t,result:e});break}case"addSignature":await P.addSignature(i.type,i.bytes),T({id:n,action:t,result:void 0});break;case"addScwSignature":await P.addScwSignature(i.type,i.bytes,i.chainId,i.blockNumber),T({id:n,action:t,result:void 0});break;case"applySignatures":await P.applySignatures(),T({id:n,action:t,result:void 0});break;case"registerIdentity":await P.registerIdentity(),T({id:n,action:t,result:void 0});break;case"isRegistered":{const e=P.isRegistered;T({id:n,action:t,result:e});break}case"canMessage":{const e=await P.canMessage(i.accountAddresses);T({id:n,action:t,result:e});break}case"inboxState":{const e=await P.inboxState(i.refreshFromNetwork);T({id:n,action:t,result:x(e)});break}case"getLatestInboxState":{const e=await P.getLatestInboxState(i.inboxId);T({id:n,action:t,result:x(e)});break}case"setConsentStates":await P.setConsentStates(i.records),T({id:n,action:t,result:void 0});break;case"getConsentState":{const e=await P.getConsentState(i.entityType,i.entity);T({id:n,action:t,result:e});break}case"findInboxIdByAddress":{const e=await P.findInboxIdByAddress(i.address);T({id:n,action:t,result:e});break}case"signWithInstallationKey":{const e=P.signWithInstallationKey(i.signatureText);T({id:n,action:t,result:e});break}case"verifySignedWithInstallationKey":{const e=P.verifySignedWithInstallationKey(i.signatureText,i.signatureBytes);T({id:n,action:t,result:e});break}case"verifySignedWithPublicKey":{const e=P.verifySignedWithPublicKey(i.signatureText,i.signatureBytes,i.publicKey);T({id:n,action:t,result:e});break}case"getConversations":{const e=P.conversations.list(i.options);T({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"getGroups":{const e=P.conversations.listGroups(i.options);T({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"getDms":{const e=P.conversations.listDms(i.options);T({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"newGroup":{const e=await P.conversations.newGroup(i.accountAddresses,i.options);T({id:n,action:t,result:await w(e)});break}case"newDm":{const e=await P.conversations.newDm(i.accountAddress);T({id:n,action:t,result:await w(e)});break}case"syncConversations":await P.conversations.sync(),T({id:n,action:t,result:void 0});break;case"syncAllConversations":await P.conversations.syncAll(),T({id:n,action:t,result:void 0});break;case"getConversationById":{const e=P.conversations.getConversationById(i.id);T({id:n,action:t,result:e?await w(e):void 0});break}case"getMessageById":{const e=P.conversations.getMessageById(i.id);T({id:n,action:t,result:e?b(e):void 0});break}case"getDmByInboxId":{const e=P.conversations.getDmByInboxId(i.inboxId);T({id:n,action:t,result:e?await w(e):void 0});break}case"syncGroup":{const e=P.conversations.getConversationById(i.id);e?(await e.sync(),T({id:n,action:t,result:await w(e)})):U({id:n,action:t,error:"Group not found"});break}case"updateGroupName":{const e=P.conversations.getConversationById(i.id);e?(await e.updateName(i.name),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"updateGroupDescription":{const e=P.conversations.getConversationById(i.id);e?(await e.updateDescription(i.description),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"updateGroupImageUrlSquare":{const e=P.conversations.getConversationById(i.id);e?(await e.updateImageUrl(i.imageUrl),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"updateGroupPinnedFrameUrl":{const e=P.conversations.getConversationById(i.id);e?(await e.updatePinnedFrameUrl(i.pinnedFrameUrl),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"sendGroupMessage":{const e=P.conversations.getConversationById(i.id);if(e){const r=await e.send(g(I(i.content)));T({id:n,action:t,result:r})}else U({id:n,action:t,error:"Group not found"});break}case"sendOptimisticGroupMessage":{const e=P.conversations.getConversationById(i.id);if(e){const r=e.sendOptimistic(g(I(i.content)));T({id:n,action:t,result:r})}else U({id:n,action:t,error:"Group not found"});break}case"publishGroupMessages":{const e=P.conversations.getConversationById(i.id);e?(await e.publishMessages(),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"getGroupMessages":{const e=P.conversations.getConversationById(i.id);if(e){const r=await e.messages(i.options);T({id:n,action:t,result:r.map((e=>b(e)))})}else U({id:n,action:t,error:"Group not found"});break}case"getGroupMembers":{const e=P.conversations.getConversationById(i.id);if(e){const i=await e.members();T({id:n,action:t,result:i})}else U({id:n,action:t,error:"Group not found"});break}case"getGroupAdmins":{const e=P.conversations.getConversationById(i.id);e?T({id:n,action:t,result:e.admins}):U({id:n,action:t,error:"Group not found"});break}case"getGroupSuperAdmins":{const e=P.conversations.getConversationById(i.id);e?T({id:n,action:t,result:e.superAdmins}):U({id:n,action:t,error:"Group not found"});break}case"getGroupConsentState":{const e=P.conversations.getConversationById(i.id);e?T({id:n,action:t,result:e.consentState}):U({id:n,action:t,error:"Group not found"});break}case"updateGroupConsentState":{const e=P.conversations.getConversationById(i.id);e?(e.updateConsentState(i.state),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"addGroupAdmin":{const e=P.conversations.getConversationById(i.id);e?(await e.addAdmin(i.inboxId),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"removeGroupAdmin":{const e=P.conversations.getConversationById(i.id);e?(await e.removeAdmin(i.inboxId),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"addGroupSuperAdmin":{const e=P.conversations.getConversationById(i.id);e?(await e.addSuperAdmin(i.inboxId),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"removeGroupSuperAdmin":{const e=P.conversations.getConversationById(i.id);e?(await e.removeSuperAdmin(i.inboxId),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"addGroupMembers":{const e=P.conversations.getConversationById(i.id);e?(await e.addMembers(i.accountAddresses),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"removeGroupMembers":{const e=P.conversations.getConversationById(i.id);e?(await e.removeMembers(i.accountAddresses),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"addGroupMembersByInboxId":{const e=P.conversations.getConversationById(i.id);e?(await e.addMembersByInboxId(i.inboxIds),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"removeGroupMembersByInboxId":{const e=P.conversations.getConversationById(i.id);e?(await e.removeMembersByInboxId(i.inboxIds),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"isGroupAdmin":{const e=P.conversations.getConversationById(i.id);if(e){const r=e.isAdmin(i.inboxId);T({id:n,action:t,result:r})}else U({id:n,action:t,error:"Group not found"});break}case"isGroupSuperAdmin":{const e=P.conversations.getConversationById(i.id);if(e){const r=e.isSuperAdmin(i.inboxId);T({id:n,action:t,result:r})}else U({id:n,action:t,error:"Group not found"});break}case"getDmPeerInboxId":{const e=P.conversations.getConversationById(i.id);if(e){const i=e.dmPeerInboxId();T({id:n,action:t,result:i})}else U({id:n,action:t,error:"Group not found"});break}case"updateGroupPermissionPolicy":{const e=P.conversations.getConversationById(i.id);e?(await e.updatePermission(i.permissionType,i.policy,i.metadataField),T({id:n,action:t,result:void 0})):U({id:n,action:t,error:"Group not found"});break}case"getGroupPermissions":{const e=P.conversations.getConversationById(i.id);if(e){const i=await w(e);T({id:n,action:t,result:i.permissions})}else U({id:n,action:t,error:"Group not found"});break}}}catch(e){U({id:n,action:t,error:e.message})}else U({id:n,action:t,error:"Client not initialized"})};
1
+ import{ContentTypeId as e}from"@xmtp/content-type-primitives";import t,{EncodedContent as n,ContentTypeId as i,Consent as r,ListConversationsOptions as s,CreateGroupOptions as o,GroupPermissionsOptions as a,ListMessagesOptions as c,PermissionPolicySet as d,getInboxIdForAddress as u,generateInboxId as p,createClient as l,LogOptions as y,verifySignedWithPublicKey as m}from"@xmtp/wasm-bindings";const g=e=>{return new n((t=e.type,new i(t.authorityId,t.typeId,t.versionMajor,t.versionMinor)),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content);var t},v=e=>{return{type:(t=e.type,{authorityId:t.authorityId,typeId:t.typeId,versionMajor:t.versionMajor,versionMinor:t.versionMinor}),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content};var t},I=t=>{return{type:(n=t.type,new e({authorityId:n.authorityId,typeId:n.typeId,versionMajor:n.versionMajor,versionMinor:n.versionMinor})),parameters:t.parameters,fallback:t.fallback,compression:t.compression,content:t.content};var n},b=t=>{return{content:v((n=t.content,{type:(i=n.type,new e({authorityId:i.authorityId,typeId:i.typeId,versionMajor:i.versionMajor,versionMinor:i.versionMinor})),parameters:Object.fromEntries(n.parameters),fallback:n.fallback,compression:n.compression,content:n.content})),convoId:t.convoId,deliveryStatus:t.deliveryStatus,id:t.id,kind:t.kind,senderInboxId:t.senderInboxId,sentAtNs:t.sentAtNs};var n,i},h=e=>new s(e.allowedStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.limit),S=e=>{return new o(e.permissions,e.name,e.imageUrlSquare,e.description,e.pinnedFrameUrl,e.customPermissionPolicySet&&e.permissions===a.CustomPolicy?(t=e.customPermissionPolicySet,new d(t.addMemberPolicy,t.removeMemberPolicy,t.addAdminPolicy,t.removeAdminPolicy,t.updateGroupNamePolicy,t.updateGroupDescriptionPolicy,t.updateGroupImageUrlSquarePolicy,t.updateGroupPinnedFrameUrlPolicy,t.updateMessageExpirationPolicy)):void 0);var t},w=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,pinnedFrameUrl:e.pinnedFrameUrl,permissions:{policyType:e.permissions.policyType,policySet:{addAdminPolicy:e.permissions.policySet.addAdminPolicy,addMemberPolicy:e.permissions.policySet.addMemberPolicy,removeAdminPolicy:e.permissions.policySet.removeAdminPolicy,removeMemberPolicy:e.permissions.policySet.removeMemberPolicy,updateGroupDescriptionPolicy:e.permissions.policySet.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.permissions.policySet.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.permissions.policySet.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.permissions.policySet.updateGroupPinnedFrameUrlPolicy,updateMessageExpirationPolicy:e.permissions.policySet.updateMessageExpirationPolicy}},isActive:e.isActive,addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.admins,superAdmins:e.superAdmins,createdAtNs:e.createdAtNs}),x=e=>({bytes:e.bytes,clientTimestampNs:e.clientTimestampNs,id:e.id}),A=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(x),recoveryAddress:e.recoveryAddress}),k=e=>new r(e.entityType,e.state,e.entity),G=e=>({key:e.key,epoch:e.epoch}),f={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"};class B{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get id(){return this.#t.id()}get name(){return this.#t.groupName()}async updateName(e){return this.#t.updateGroupName(e)}get imageUrl(){return this.#t.groupImageUrlSquare()}async updateImageUrl(e){return this.#t.updateGroupImageUrlSquare(e)}get description(){return this.#t.groupDescription()}async updateDescription(e){return this.#t.updateGroupDescription(e)}get pinnedFrameUrl(){return this.#t.groupPinnedFrameUrl()}async updatePinnedFrameUrl(e){return this.#t.updateGroupPinnedFrameUrl(e)}get isActive(){return this.#t.isActive()}get addedByInboxId(){return this.#t.addedByInboxId()}get createdAtNs(){return this.#t.createdAtNs()}async metadata(){const e=await this.#t.groupMetadata();return{creatorInboxId:e.creatorInboxId(),conversationType:e.conversationType()}}async members(){return(await this.#t.listMembers()).map((e=>(e=>({accountAddresses:e.accountAddresses,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}))(e)))}get admins(){return this.#t.adminList()}get superAdmins(){return this.#t.superAdminList()}get permissions(){const e=this.#t.groupPermissions();return{policyType:e.policyType(),policySet:e.policySet()}}async updatePermission(e,t,n){return this.#t.updatePermissionPolicy(e,t,n)}isAdmin(e){return this.#t.isAdmin(e)}isSuperAdmin(e){return this.#t.isSuperAdmin(e)}async sync(){return this.#t.sync()}async addMembers(e){return this.#t.addMembers(e)}async addMembersByInboxId(e){return this.#t.addMembersByInboxId(e)}async removeMembers(e){return this.#t.removeMembers(e)}async removeMembersByInboxId(e){return this.#t.removeMembersByInboxId(e)}async addAdmin(e){return this.#t.addAdmin(e)}async removeAdmin(e){return this.#t.removeAdmin(e)}async addSuperAdmin(e){return this.#t.addSuperAdmin(e)}async removeSuperAdmin(e){return this.#t.removeSuperAdmin(e)}async publishMessages(){return this.#t.publishMessages()}sendOptimistic(e){return this.#t.sendOptimistic(e)}async send(e){return this.#t.send(e)}async messages(e){return this.#t.findMessages(e?(e=>new c(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction))(e):void 0)}get consentState(){return this.#t.consentState()}updateConsentState(e){this.#t.updateConsentState(e)}dmPeerInboxId(){return this.#t.dmPeerInboxId()}}class M{#e;#n;constructor(e,t){this.#e=e,this.#n=t}async sync(){return this.#n.sync()}async syncAll(){return this.#n.syncAllConversations()}getConversationById(e){try{const t=this.#n.findGroupById(e);return new B(this.#e,t)}catch{return}}getMessageById(e){try{return this.#n.findMessageById(e)}catch{return}}getDmByInboxId(e){try{const t=this.#n.findDmByTargetInboxId(e);return new B(this.#e,t)}catch{return}}list(e){return this.#n.list(e?h(e):void 0).map((e=>new B(this.#e,e)))}listGroups(e){return this.#n.listGroups(e?h(e):void 0).map((e=>new B(this.#e,e)))}listDms(e){return this.#n.listDms(e?h(e):void 0).map((e=>new B(this.#e,e)))}async newGroup(e,t){const n=await this.#n.createGroup(e,t?S(t):void 0);return new B(this.#e,n)}async newDm(e){const t=await this.#n.createDm(e);return new B(this.#e,t)}getHmacKeys(){return this.#n.getHmacKeys()}}class P{#e;#n;#i;constructor(e){this.#e=e,this.#i=e.accountAddress,this.#n=new M(this,e.conversations())}static async create(e,n,i){const r=await(async(e,n,i)=>{await t();const r=i?.apiUrl??f[i?.env??"dev"],s=i?.dbPath??`xmtp-${i?.env??"dev"}-${e}.db3`,o=await u(r,e)||p(e),a=i&&(void 0!==i.loggingLevel||i.structuredLogging||i.performanceLogging);return l(r,o,e,s,n,void 0,a?new y(i.structuredLogging??!1,i.performanceLogging??!1,i.loggingLevel):void 0)})(e,n,i);return new P(r)}get accountAddress(){return this.#i}get inboxId(){return this.#e.inboxId}get installationId(){return this.#e.installationId}get installationIdBytes(){return this.#e.installationIdBytes}get isRegistered(){return this.#e.isRegistered}async createInboxSignatureText(){try{return await this.#e.createInboxSignatureText()}catch{return}}async addAccountSignatureText(e){try{return await this.#e.addWalletSignatureText(e)}catch{return}}async removeAccountSignatureText(e){try{return await this.#e.revokeWalletSignatureText(e)}catch{return}}async revokeAllAOtherInstallationsSignatureText(){try{return await this.#e.revokeAllOtherInstallationsSignatureText()}catch{return}}async revokeInstallationsSignatureText(e){try{return await this.#e.revokeInstallationsSignatureText(e)}catch{return}}async addSignature(e,t){return this.#e.addSignature(e,t)}async addScwSignature(e,t,n,i){return this.#e.addScwSignature(e,t,n,i)}async applySignatures(){return this.#e.applySignatureRequests()}async canMessage(e){return this.#e.canMessage(e)}async registerIdentity(){return this.#e.registerIdentity()}async findInboxIdByAddress(e){return this.#e.findInboxIdByAddress(e)}async inboxState(e){return this.#e.inboxState(e)}async getLatestInboxState(e){return this.#e.getLatestInboxState(e)}async setConsentStates(e){return this.#e.setConsentStates(e.map(k))}async getConsentState(e,t){return this.#e.getConsentState(e,t)}get conversations(){return this.#n}signWithInstallationKey(e){return this.#e.signWithInstallationKey(e)}verifySignedWithInstallationKey(e,t){try{return this.#e.verifySignedWithInstallationKey(e,t),!0}catch{return!1}}verifySignedWithPublicKey(e,t,n){try{return m(e,t,n),!0}catch{return!1}}}let C,T=!1;const U=e=>{self.postMessage(e)},N=e=>{self.postMessage(e)};self.onmessage=async e=>{const{action:t,id:n,data:i}=e.data;if(T&&console.log("client worker received event data",e.data),"init"===t||C)try{switch(t){case"init":C=await P.create(i.address,i.encryptionKey,i.options),T=void 0!==i.options?.loggingLevel&&"off"!==i.options.loggingLevel,U({id:n,action:t,result:{inboxId:C.inboxId,installationId:C.installationId,installationIdBytes:C.installationIdBytes}});break;case"createInboxSignatureText":{const e=await C.createInboxSignatureText();U({id:n,action:t,result:e});break}case"addAccountSignatureText":{const e=await C.addAccountSignatureText(i.newAccountAddress);U({id:n,action:t,result:e});break}case"removeAccountSignatureText":{const e=await C.removeAccountSignatureText(i.accountAddress);U({id:n,action:t,result:e});break}case"revokeAllOtherInstallationsSignatureText":{const e=await C.revokeAllAOtherInstallationsSignatureText();U({id:n,action:t,result:e});break}case"revokeInstallationsSignatureText":{const e=await C.revokeInstallationsSignatureText(i.installationIds);U({id:n,action:t,result:e});break}case"addSignature":await C.addSignature(i.type,i.bytes),U({id:n,action:t,result:void 0});break;case"addScwSignature":await C.addScwSignature(i.type,i.bytes,i.chainId,i.blockNumber),U({id:n,action:t,result:void 0});break;case"applySignatures":await C.applySignatures(),U({id:n,action:t,result:void 0});break;case"registerIdentity":await C.registerIdentity(),U({id:n,action:t,result:void 0});break;case"isRegistered":{const e=C.isRegistered;U({id:n,action:t,result:e});break}case"canMessage":{const e=await C.canMessage(i.accountAddresses);U({id:n,action:t,result:e});break}case"inboxState":{const e=await C.inboxState(i.refreshFromNetwork);U({id:n,action:t,result:A(e)});break}case"getLatestInboxState":{const e=await C.getLatestInboxState(i.inboxId);U({id:n,action:t,result:A(e)});break}case"setConsentStates":await C.setConsentStates(i.records),U({id:n,action:t,result:void 0});break;case"getConsentState":{const e=await C.getConsentState(i.entityType,i.entity);U({id:n,action:t,result:e});break}case"findInboxIdByAddress":{const e=await C.findInboxIdByAddress(i.address);U({id:n,action:t,result:e});break}case"signWithInstallationKey":{const e=C.signWithInstallationKey(i.signatureText);U({id:n,action:t,result:e});break}case"verifySignedWithInstallationKey":{const e=C.verifySignedWithInstallationKey(i.signatureText,i.signatureBytes);U({id:n,action:t,result:e});break}case"verifySignedWithPublicKey":{const e=C.verifySignedWithPublicKey(i.signatureText,i.signatureBytes,i.publicKey);U({id:n,action:t,result:e});break}case"getConversations":{const e=C.conversations.list(i.options);U({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"getGroups":{const e=C.conversations.listGroups(i.options);U({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"getDms":{const e=C.conversations.listDms(i.options);U({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"newGroup":{const e=await C.conversations.newGroup(i.accountAddresses,i.options);U({id:n,action:t,result:await w(e)});break}case"newDm":{const e=await C.conversations.newDm(i.accountAddress);U({id:n,action:t,result:await w(e)});break}case"syncConversations":await C.conversations.sync(),U({id:n,action:t,result:void 0});break;case"syncAllConversations":await C.conversations.syncAll(),U({id:n,action:t,result:void 0});break;case"getConversationById":{const e=C.conversations.getConversationById(i.id);U({id:n,action:t,result:e?await w(e):void 0});break}case"getMessageById":{const e=C.conversations.getMessageById(i.id);U({id:n,action:t,result:e?b(e):void 0});break}case"getDmByInboxId":{const e=C.conversations.getDmByInboxId(i.inboxId);U({id:n,action:t,result:e?await w(e):void 0});break}case"getHmacKeys":{const e=C.conversations.getHmacKeys();U({id:n,action:t,result:Object.fromEntries(Array.from(e.entries()).map((([e,t])=>[e,t.map(G)])))});break}case"syncGroup":{const e=C.conversations.getConversationById(i.id);e?(await e.sync(),U({id:n,action:t,result:await w(e)})):N({id:n,action:t,error:"Group not found"});break}case"updateGroupName":{const e=C.conversations.getConversationById(i.id);e?(await e.updateName(i.name),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"updateGroupDescription":{const e=C.conversations.getConversationById(i.id);e?(await e.updateDescription(i.description),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"updateGroupImageUrlSquare":{const e=C.conversations.getConversationById(i.id);e?(await e.updateImageUrl(i.imageUrl),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"updateGroupPinnedFrameUrl":{const e=C.conversations.getConversationById(i.id);e?(await e.updatePinnedFrameUrl(i.pinnedFrameUrl),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"sendGroupMessage":{const e=C.conversations.getConversationById(i.id);if(e){const r=await e.send(g(I(i.content)));U({id:n,action:t,result:r})}else N({id:n,action:t,error:"Group not found"});break}case"sendOptimisticGroupMessage":{const e=C.conversations.getConversationById(i.id);if(e){const r=e.sendOptimistic(g(I(i.content)));U({id:n,action:t,result:r})}else N({id:n,action:t,error:"Group not found"});break}case"publishGroupMessages":{const e=C.conversations.getConversationById(i.id);e?(await e.publishMessages(),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"getGroupMessages":{const e=C.conversations.getConversationById(i.id);if(e){const r=await e.messages(i.options);U({id:n,action:t,result:r.map((e=>b(e)))})}else N({id:n,action:t,error:"Group not found"});break}case"getGroupMembers":{const e=C.conversations.getConversationById(i.id);if(e){const i=await e.members();U({id:n,action:t,result:i})}else N({id:n,action:t,error:"Group not found"});break}case"getGroupAdmins":{const e=C.conversations.getConversationById(i.id);e?U({id:n,action:t,result:e.admins}):N({id:n,action:t,error:"Group not found"});break}case"getGroupSuperAdmins":{const e=C.conversations.getConversationById(i.id);e?U({id:n,action:t,result:e.superAdmins}):N({id:n,action:t,error:"Group not found"});break}case"getGroupConsentState":{const e=C.conversations.getConversationById(i.id);e?U({id:n,action:t,result:e.consentState}):N({id:n,action:t,error:"Group not found"});break}case"updateGroupConsentState":{const e=C.conversations.getConversationById(i.id);e?(e.updateConsentState(i.state),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"addGroupAdmin":{const e=C.conversations.getConversationById(i.id);e?(await e.addAdmin(i.inboxId),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"removeGroupAdmin":{const e=C.conversations.getConversationById(i.id);e?(await e.removeAdmin(i.inboxId),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"addGroupSuperAdmin":{const e=C.conversations.getConversationById(i.id);e?(await e.addSuperAdmin(i.inboxId),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"removeGroupSuperAdmin":{const e=C.conversations.getConversationById(i.id);e?(await e.removeSuperAdmin(i.inboxId),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"addGroupMembers":{const e=C.conversations.getConversationById(i.id);e?(await e.addMembers(i.accountAddresses),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"removeGroupMembers":{const e=C.conversations.getConversationById(i.id);e?(await e.removeMembers(i.accountAddresses),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"addGroupMembersByInboxId":{const e=C.conversations.getConversationById(i.id);e?(await e.addMembersByInboxId(i.inboxIds),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"removeGroupMembersByInboxId":{const e=C.conversations.getConversationById(i.id);e?(await e.removeMembersByInboxId(i.inboxIds),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"isGroupAdmin":{const e=C.conversations.getConversationById(i.id);if(e){const r=e.isAdmin(i.inboxId);U({id:n,action:t,result:r})}else N({id:n,action:t,error:"Group not found"});break}case"isGroupSuperAdmin":{const e=C.conversations.getConversationById(i.id);if(e){const r=e.isSuperAdmin(i.inboxId);U({id:n,action:t,result:r})}else N({id:n,action:t,error:"Group not found"});break}case"getDmPeerInboxId":{const e=C.conversations.getConversationById(i.id);if(e){const i=e.dmPeerInboxId();U({id:n,action:t,result:i})}else N({id:n,action:t,error:"Group not found"});break}case"updateGroupPermissionPolicy":{const e=C.conversations.getConversationById(i.id);e?(await e.updatePermission(i.permissionType,i.policy,i.metadataField),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"getGroupPermissions":{const e=C.conversations.getConversationById(i.id);if(e){const i=await w(e);U({id:n,action:t,result:i.permissions})}else N({id:n,action:t,error:"Group not found"});break}}}catch(e){N({id:n,action:t,error:e.message})}else N({id:n,action:t,error:"Client not initialized"})};
2
2
  //# sourceMappingURL=client.js.map
@@ -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 CreateGroupOptions,\n GroupMember,\n GroupPermissionsOptions,\n ListConversationsOptions,\n ListMessagesOptions,\n PermissionPolicySet,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ConversationType,\n type DeliveryStatus,\n type GroupMembershipState,\n type GroupMessageKind,\n type InboxState,\n type Installation,\n type Message,\n type PermissionLevel,\n type PermissionPolicy,\n type SortDirection,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: DeliveryStatus;\n id: string;\n kind: GroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: Message): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convoId,\n deliveryStatus: message.deliveryStatus,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.senderInboxId,\n sentAtNs: message.sentAtNs,\n});\n\nexport type SafeListMessagesOptions = {\n deliveryStatus?: DeliveryStatus;\n direction?: SortDirection;\n limit?: bigint;\n sentAfterNs?: bigint;\n sentBeforeNs?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: ListMessagesOptions,\n): SafeListMessagesOptions => ({\n deliveryStatus: options.deliveryStatus,\n direction: options.direction,\n limit: options.limit,\n sentAfterNs: options.sentAfterNs,\n sentBeforeNs: options.sentBeforeNs,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): ListMessagesOptions =>\n new ListMessagesOptions(\n options.sentBeforeNs,\n options.sentAfterNs,\n options.limit,\n options.deliveryStatus,\n options.direction,\n );\n\nexport type SafeListConversationsOptions = {\n allowedStates?: GroupMembershipState[];\n conversationType?: ConversationType;\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n allowedStates: options.allowedStates,\n conversationType: options.conversationType,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.allowedStates,\n options.conversationType,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n};\n\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 updateGroupPinnedFrameUrlPolicy: policySet.updateGroupPinnedFrameUrlPolicy,\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.updateGroupPinnedFrameUrlPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n name?: string;\n permissions?: GroupPermissionsOptions;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n name: options.groupName,\n pinnedFrameUrl: options.groupPinnedFrameUrl,\n permissions: options.permissions,\n customPermissionPolicySet: options.customPermissionPolicySet,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): CreateGroupOptions =>\n new CreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n // 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 );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: GroupPermissionsOptions;\n policySet: {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n };\n };\n isActive: boolean;\n addedByInboxId: string;\n metadata: {\n creatorInboxId: string;\n conversationType: string;\n };\n admins: string[];\n superAdmins: string[];\n createdAtNs: bigint;\n};\n\nexport const toSafeConversation = async (\n conversation: WorkerConversation,\n): Promise<SafeConversation> => ({\n id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,\n addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,\n removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,\n removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: await conversation.metadata(),\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\n});\n\nexport type SafeInstallation = {\n id: string;\n clientTimestampNs?: bigint;\n};\n\nexport const toSafeInstallation = (\n installation: Installation,\n): SafeInstallation => ({\n id: installation.id,\n clientTimestampNs: installation.clientTimestampNs,\n});\n\nexport type SafeInboxState = {\n accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountAddresses: inboxState.accountAddresses,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recoveryAddress,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: ConsentEntityType;\n state: ConsentState;\n};\n\nexport const toSafeConsent = (consent: Consent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entityType,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): Consent =>\n new Consent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountAddresses: member.accountAddresses,\n consentState: member.consentState,\n inboxId: member.inboxId,\n installationIds: member.installationIds,\n permissionLevel: member.permissionLevel,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>\n new GroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n","import type {\n ConsentState,\n Conversation,\n EncodedContent,\n GroupMember,\n MetadataField,\n PermissionPolicy,\n PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeListMessagesOptions,\n toSafeGroupMember,\n type SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\n\nexport class WorkerConversation {\n // eslint-disable-next-line no-unused-private-class-members\n #client: WorkerClient;\n\n #group: Conversation;\n\n constructor(client: WorkerClient, group: Conversation) {\n this.#client = client;\n this.#group = group;\n }\n\n get id() {\n return this.#group.id();\n }\n\n get name() {\n return this.#group.groupName();\n }\n\n async updateName(name: string) {\n return this.#group.updateGroupName(name);\n }\n\n get imageUrl() {\n return this.#group.groupImageUrlSquare();\n }\n\n async updateImageUrl(imageUrl: string) {\n return this.#group.updateGroupImageUrlSquare(imageUrl);\n }\n\n get description() {\n return this.#group.groupDescription();\n }\n\n async updateDescription(description: string) {\n return this.#group.updateGroupDescription(description);\n }\n\n get pinnedFrameUrl() {\n return this.#group.groupPinnedFrameUrl();\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n return this.#group.updateGroupPinnedFrameUrl(pinnedFrameUrl);\n }\n\n get isActive() {\n return this.#group.isActive();\n }\n\n get addedByInboxId() {\n return this.#group.addedByInboxId();\n }\n\n get createdAtNs() {\n return this.#group.createdAtNs();\n }\n\n 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 addMembers(accountAddresses: string[]) {\n return this.#group.addMembers(accountAddresses);\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#group.addMembersByInboxId(inboxIds);\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#group.removeMembers(accountAddresses);\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#group.removeMembersByInboxId(inboxIds);\n }\n\n async addAdmin(inboxId: string) {\n return this.#group.addAdmin(inboxId);\n }\n\n async removeAdmin(inboxId: string) {\n return this.#group.removeAdmin(inboxId);\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#group.addSuperAdmin(inboxId);\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#group.removeSuperAdmin(inboxId);\n }\n\n async publishMessages() {\n return this.#group.publishMessages();\n }\n\n sendOptimistic(encodedContent: EncodedContent) {\n return this.#group.sendOptimistic(encodedContent);\n }\n\n async send(encodedContent: EncodedContent) {\n return this.#group.send(encodedContent);\n }\n\n 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","import type { Conversation, Conversations } from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeCreateGroupOptions,\n fromSafeListConversationsOptions,\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() {\n return this.#conversations.syncAllConversations();\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 Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = this.#conversations.listGroups(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n listDms(options?: Omit<SafeListConversationsOptions, \"conversation_type\">) {\n const groups = this.#conversations.listDms(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const group = await this.#conversations.createGroup(\n accountAddresses,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDm(accountAddress: string) {\n const group = await this.#conversations.createDm(accountAddress);\n return new WorkerConversation(this.#client, group);\n }\n}\n","import {\n verifySignedWithPublicKey,\n type Client,\n type ConsentEntityType,\n type SignatureRequestType,\n} from \"@xmtp/wasm-bindings\";\nimport type { ClientOptions } from \"@/types\";\nimport { fromSafeConsent, type SafeConsent } from \"@/utils/conversions\";\nimport { createClient } from \"@/utils/createClient\";\nimport { WorkerConversations } from \"@/WorkerConversations\";\n\nexport class WorkerClient {\n #client: Client;\n\n #conversations: WorkerConversations;\n\n #accountAddress: string;\n\n constructor(client: Client) {\n this.#client = client;\n this.#accountAddress = client.accountAddress;\n this.#conversations = new WorkerConversations(this, client.conversations());\n }\n\n static async create(\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n ) {\n const client = await createClient(accountAddress, encryptionKey, options);\n return new WorkerClient(client);\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n get inboxId() {\n return this.#client.inboxId;\n }\n\n get installationId() {\n return this.#client.installationId;\n }\n\n get installationIdBytes() {\n return this.#client.installationIdBytes;\n }\n\n get isRegistered() {\n return this.#client.isRegistered;\n }\n\n async createInboxSignatureText() {\n try {\n return await this.#client.createInboxSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async addAccountSignatureText(accountAddress: string) {\n try {\n return await this.#client.addWalletSignatureText(accountAddress);\n } catch {\n return undefined;\n }\n }\n\n async removeAccountSignatureText(accountAddress: string) {\n try {\n return await this.#client.revokeWalletSignatureText(accountAddress);\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 addSignature(type: SignatureRequestType, bytes: Uint8Array) {\n return this.#client.addSignature(type, bytes);\n }\n\n async addScwSignature(\n type: SignatureRequestType,\n bytes: Uint8Array,\n chainId: bigint,\n blockNumber?: bigint,\n ) {\n return this.#client.addScwSignature(type, bytes, chainId, blockNumber);\n }\n\n async applySignatures() {\n return this.#client.applySignatureRequests();\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.#client.canMessage(accountAddresses) as Promise<\n Map<string, boolean>\n >;\n }\n\n async registerIdentity() {\n return this.#client.registerIdentity();\n }\n\n async findInboxIdByAddress(address: string) {\n return this.#client.findInboxIdByAddress(address);\n }\n\n async inboxState(refreshFromNetwork: boolean) {\n return this.#client.inboxState(refreshFromNetwork);\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.#client.getLatestInboxState(inboxId);\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.#client.setConsentStates(records.map(fromSafeConsent));\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.#client.getConsentState(entityType, entity);\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n 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 init, {\n createClient as createWasmClient,\n generateInboxId,\n getInboxIdForAddress,\n LogOptions,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls } from \"@/constants\";\nimport type { ClientOptions } from \"@/types\";\n\nexport const createClient = async (\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n) => {\n // initialize WASM module\n await init();\n\n const host = options?.apiUrl ?? ApiUrls[options?.env ?? \"dev\"];\n // TODO: add db path validation\n // - must end with .db3\n // - must not contain invalid characters\n // - must not start with a dot\n const dbPath =\n options?.dbPath ?? `xmtp-${options?.env ?? \"dev\"}-${accountAddress}.db3`;\n\n const inboxId =\n (await getInboxIdForAddress(host, accountAddress)) ||\n generateInboxId(accountAddress);\n\n const isLogging =\n options &&\n (options.loggingLevel !== undefined ||\n options.structuredLogging ||\n options.performanceLogging);\n\n return createWasmClient(\n host,\n inboxId,\n accountAddress,\n dbPath,\n encryptionKey,\n undefined,\n isLogging\n ? new LogOptions(\n options.structuredLogging ?? false,\n options.performanceLogging ?? false,\n options.loggingLevel,\n )\n : undefined,\n );\n};\n","import type {\n ClientEventsActions,\n ClientEventsClientMessageData,\n ClientEventsErrorData,\n ClientEventsWorkerPostMessageData,\n} from \"@/types\";\nimport {\n fromEncodedContent,\n fromSafeEncodedContent,\n toSafeConversation,\n toSafeInboxState,\n toSafeMessage,\n} from \"@/utils/conversions\";\nimport { WorkerClient } from \"@/WorkerClient\";\n\nlet client: WorkerClient;\nlet enableLogging = false;\n\n/**\n * Type-safe postMessage\n */\nconst postMessage = <A extends ClientEventsActions>(\n data: ClientEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for errors\n */\nconst postMessageError = (data: ClientEventsErrorData) => {\n self.postMessage(data);\n};\n\nself.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {\n const { action, id, data } = event.data;\n\n if (enableLogging) {\n console.log(\"client worker received event data\", event.data);\n }\n\n // a client is required for all actions except init\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (action !== \"init\" && !client) {\n postMessageError({\n id,\n action,\n error: \"Client not initialized\",\n });\n return;\n }\n\n try {\n switch (action) {\n /**\n * Client actions\n */\n case \"init\":\n client = await WorkerClient.create(\n data.address,\n data.encryptionKey,\n data.options,\n );\n enableLogging =\n data.options?.loggingLevel !== undefined &&\n data.options.loggingLevel !== \"off\";\n postMessage({\n id,\n action,\n result: {\n inboxId: client.inboxId,\n installationId: client.installationId,\n installationIdBytes: client.installationIdBytes,\n },\n });\n break;\n case \"createInboxSignatureText\": {\n const result = await client.createInboxSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addAccountSignatureText\": {\n const result = await client.addAccountSignatureText(\n data.newAccountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"removeAccountSignatureText\": {\n const result = await client.removeAccountSignatureText(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"revokeAllOtherInstallationsSignatureText\": {\n const result = await client.revokeAllAOtherInstallationsSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"revokeInstallationsSignatureText\": {\n const result = await client.revokeInstallationsSignatureText(\n data.installationIds,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addSignature\":\n await client.addSignature(data.type, data.bytes);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"addScwSignature\":\n await client.addScwSignature(\n data.type,\n data.bytes,\n data.chainId,\n data.blockNumber,\n );\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"applySignatures\":\n await client.applySignatures();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"registerIdentity\":\n await client.registerIdentity();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"isRegistered\": {\n const result = client.isRegistered;\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"canMessage\": {\n const result = await client.canMessage(data.accountAddresses);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"inboxState\": {\n const result = await client.inboxState(data.refreshFromNetwork);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"getLatestInboxState\": {\n const result = await client.getLatestInboxState(data.inboxId);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"setConsentStates\": {\n await client.setConsentStates(data.records);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConsentState\": {\n const result = await client.getConsentState(\n data.entityType,\n data.entity,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"findInboxIdByAddress\": {\n const result = await client.findInboxIdByAddress(data.address);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"signWithInstallationKey\": {\n const result = client.signWithInstallationKey(data.signatureText);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"verifySignedWithInstallationKey\": {\n const result = client.verifySignedWithInstallationKey(\n data.signatureText,\n data.signatureBytes,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"verifySignedWithPublicKey\": {\n const result = client.verifySignedWithPublicKey(\n data.signatureText,\n data.signatureBytes,\n data.publicKey,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n /**\n * Conversations actions\n */\n case \"getConversations\": {\n const conversations = client.conversations.list(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"getGroups\": {\n const conversations = client.conversations.listGroups(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"getDms\": {\n const conversations = client.conversations.listDms(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"newGroup\": {\n const conversation = await client.conversations.newGroup(\n data.accountAddresses,\n data.options,\n );\n postMessage({\n id,\n action,\n result: await toSafeConversation(conversation),\n });\n break;\n }\n case \"newDm\": {\n const conversation = await client.conversations.newDm(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result: await toSafeConversation(conversation),\n });\n break;\n }\n case \"syncConversations\": {\n await client.conversations.sync();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"syncAllConversations\": {\n await client.conversations.syncAll();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConversationById\": {\n const conversation = client.conversations.getConversationById(data.id);\n postMessage({\n id,\n action,\n result: conversation\n ? await toSafeConversation(conversation)\n : undefined,\n });\n break;\n }\n case \"getMessageById\": {\n const message = client.conversations.getMessageById(data.id);\n postMessage({\n id,\n action,\n result: message ? toSafeMessage(message) : undefined,\n });\n break;\n }\n case \"getDmByInboxId\": {\n const conversation = client.conversations.getDmByInboxId(data.inboxId);\n postMessage({\n id,\n action,\n result: conversation\n ? await toSafeConversation(conversation)\n : undefined,\n });\n break;\n }\n /**\n * Group actions\n */\n case \"syncGroup\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.sync();\n postMessage({\n id,\n action,\n result: await toSafeConversation(group),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupName\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateName(data.name);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupDescription\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateDescription(data.description);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupImageUrlSquare\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateImageUrl(data.imageUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPinnedFrameUrl\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePinnedFrameUrl(data.pinnedFrameUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.send(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendOptimisticGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.sendOptimistic(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"publishGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.publishMessages();\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const messages = await group.messages(data.options);\n postMessage({\n id,\n action,\n result: messages.map((message) => toSafeMessage(message)),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.members();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.admins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupSuperAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.superAdmins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.consentState,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n group.updateConsentState(data.state);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getDmPeerInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.dmPeerInboxId();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPermissionPolicy\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePermission(\n data.permissionType,\n data.policy,\n data.metadataField,\n );\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupPermissions\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const safeConversation = await toSafeConversation(group);\n postMessage({\n id,\n action,\n result: safeConversation.permissions,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n }\n } catch (e) {\n postMessageError({\n id,\n action,\n error: (e as Error).message,\n });\n }\n};\n"],"names":["fromEncodedContent","content","WasmEncodedContent","contentTypeId","type","WasmContentTypeId","authorityId","typeId","versionMajor","versionMinor","Map","Object","entries","parameters","fallback","compression","toSafeEncodedContent","fromSafeEncodedContent","ContentTypeId","toSafeMessage","message","fromEntries","convoId","deliveryStatus","id","kind","senderInboxId","sentAtNs","fromSafeListConversationsOptions","options","ListConversationsOptions","allowedStates","conversationType","createdAfterNs","createdBeforeNs","limit","fromSafeCreateGroupOptions","CreateGroupOptions","permissions","name","imageUrlSquare","description","pinnedFrameUrl","customPermissionPolicySet","GroupPermissionsOptions","CustomPolicy","policySet","PermissionPolicySet","addMemberPolicy","removeMemberPolicy","addAdminPolicy","removeAdminPolicy","updateGroupNamePolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateGroupPinnedFrameUrlPolicy","undefined","toSafeConversation","async","conversation","imageUrl","policyType","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","clientTimestampNs","toSafeInboxState","inboxState","accountAddresses","inboxId","installations","map","recoveryAddress","fromSafeConsent","consent","Consent","entityType","state","entity","ApiUrls","local","dev","production","WorkerConversation","client","group","constructor","this","groupName","updateName","updateGroupName","groupImageUrlSquare","updateImageUrl","updateGroupImageUrlSquare","groupDescription","updateDescription","updateGroupDescription","groupPinnedFrameUrl","updatePinnedFrameUrl","updateGroupPinnedFrameUrl","groupMetadata","creatorInboxId","members","listMembers","member","consentState","installationIds","permissionLevel","toSafeGroupMember","adminList","superAdminList","groupPermissions","updatePermission","permissionType","policy","metadataField","updatePermissionPolicy","isAdmin","isSuperAdmin","sync","addMembers","addMembersByInboxId","inboxIds","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","encodedContent","send","messages","findMessages","ListMessagesOptions","sentBeforeNs","sentAfterNs","direction","fromSafeListMessagesOptions","updateConsentState","dmPeerInboxId","WorkerConversations","conversations","syncAll","syncAllConversations","getConversationById","findGroupById","getMessageById","findMessageById","getDmByInboxId","findDmByTargetInboxId","list","listGroups","listDms","newGroup","createGroup","newDm","accountAddress","createDm","WorkerClient","create","encryptionKey","init","host","apiUrl","env","dbPath","getInboxIdForAddress","generateInboxId","isLogging","loggingLevel","structuredLogging","performanceLogging","createWasmClient","LogOptions","createClient","installationId","installationIdBytes","isRegistered","createInboxSignatureText","addAccountSignatureText","addWalletSignatureText","removeAccountSignatureText","revokeWalletSignatureText","revokeAllAOtherInstallationsSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","bytes","addScwSignature","chainId","blockNumber","applySignatures","applySignatureRequests","canMessage","registerIdentity","findInboxIdByAddress","address","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","signWithInstallationKey","signatureText","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","enableLogging","postMessage","data","self","postMessageError","onmessage","event","action","console","log","result","newAccountAddress","Promise","all","error","safeConversation","e"],"mappings":"2YA6BO,MAyDMA,EACXC,IAEA,WAAIC,GAjDJC,EAkDoBF,EAAQG,KAhD5B,IAAIC,EACFF,EAAcG,YACdH,EAAcI,OACdJ,EAAcK,aACdL,EAAcM,eA6Cd,IAAIC,IAAIC,OAAOC,QAAQX,EAAQY,a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O,oBAGX,QAGJ,MAAOE,GACPZ,EAAiB,CACfnM,KACAsM,SACAO,MAAQE,EAAYnN,eAj0BtBuM,EAAiB,CACfnM,KACAsM,SACAO,MAAO"}
1
+ {"version":3,"file":"client.js","sources":["../../src/utils/conversions.ts","../../src/constants.ts","../../src/WorkerConversation.ts","../../src/WorkerConversations.ts","../../src/WorkerClient.ts","../../src/utils/createClient.ts","../../src/workers/client.ts"],"sourcesContent":["import {\n ContentTypeId,\n type EncodedContent,\n} from \"@xmtp/content-type-primitives\";\nimport {\n Consent,\n CreateGroupOptions,\n GroupMember,\n GroupPermissionsOptions,\n ListConversationsOptions,\n ListMessagesOptions,\n PermissionPolicySet,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ConversationType,\n type DeliveryStatus,\n type GroupMembershipState,\n type GroupMessageKind,\n type HmacKey,\n type InboxState,\n type Installation,\n type Message,\n type PermissionLevel,\n type PermissionPolicy,\n type SortDirection,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: DeliveryStatus;\n id: string;\n kind: GroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: Message): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convoId,\n deliveryStatus: message.deliveryStatus,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.senderInboxId,\n sentAtNs: message.sentAtNs,\n});\n\nexport type SafeListMessagesOptions = {\n deliveryStatus?: DeliveryStatus;\n direction?: SortDirection;\n limit?: bigint;\n sentAfterNs?: bigint;\n sentBeforeNs?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: ListMessagesOptions,\n): SafeListMessagesOptions => ({\n deliveryStatus: options.deliveryStatus,\n direction: options.direction,\n limit: options.limit,\n sentAfterNs: options.sentAfterNs,\n sentBeforeNs: options.sentBeforeNs,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): ListMessagesOptions =>\n new ListMessagesOptions(\n options.sentBeforeNs,\n options.sentAfterNs,\n options.limit,\n options.deliveryStatus,\n options.direction,\n );\n\nexport type SafeListConversationsOptions = {\n allowedStates?: GroupMembershipState[];\n conversationType?: ConversationType;\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n allowedStates: options.allowedStates,\n conversationType: options.conversationType,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.allowedStates,\n options.conversationType,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: 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 updateGroupPinnedFrameUrlPolicy: policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy: policySet.updateMessageExpirationPolicy,\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.updateGroupPinnedFrameUrlPolicy,\n policySet.updateMessageExpirationPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n name?: string;\n permissions?: GroupPermissionsOptions;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n name: options.groupName,\n pinnedFrameUrl: options.groupPinnedFrameUrl,\n permissions: options.permissions,\n customPermissionPolicySet: options.customPermissionPolicySet,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): CreateGroupOptions =>\n new CreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n // 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 );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: GroupPermissionsOptions;\n policySet: {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: 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 id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,\n addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,\n removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,\n removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy:\n conversation.permissions.policySet.updateMessageExpirationPolicy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: await conversation.metadata(),\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\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 accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountAddresses: inboxState.accountAddresses,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recoveryAddress,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: ConsentEntityType;\n state: ConsentState;\n};\n\nexport const toSafeConsent = (consent: Consent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entityType,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): Consent =>\n new Consent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountAddresses: member.accountAddresses,\n consentState: member.consentState,\n inboxId: member.inboxId,\n installationIds: member.installationIds,\n permissionLevel: member.permissionLevel,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>\n new GroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n\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","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n","import type {\n ConsentState,\n Conversation,\n EncodedContent,\n GroupMember,\n MetadataField,\n PermissionPolicy,\n PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeListMessagesOptions,\n toSafeGroupMember,\n type SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\n\nexport class WorkerConversation {\n // eslint-disable-next-line no-unused-private-class-members\n #client: WorkerClient;\n\n #group: Conversation;\n\n constructor(client: WorkerClient, group: Conversation) {\n this.#client = client;\n this.#group = group;\n }\n\n get id() {\n return this.#group.id();\n }\n\n get name() {\n return this.#group.groupName();\n }\n\n async updateName(name: string) {\n return this.#group.updateGroupName(name);\n }\n\n get imageUrl() {\n return this.#group.groupImageUrlSquare();\n }\n\n async updateImageUrl(imageUrl: string) {\n return this.#group.updateGroupImageUrlSquare(imageUrl);\n }\n\n get description() {\n return this.#group.groupDescription();\n }\n\n async updateDescription(description: string) {\n return this.#group.updateGroupDescription(description);\n }\n\n get pinnedFrameUrl() {\n return this.#group.groupPinnedFrameUrl();\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n return this.#group.updateGroupPinnedFrameUrl(pinnedFrameUrl);\n }\n\n get isActive() {\n return this.#group.isActive();\n }\n\n get addedByInboxId() {\n return this.#group.addedByInboxId();\n }\n\n get createdAtNs() {\n return this.#group.createdAtNs();\n }\n\n 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 addMembers(accountAddresses: string[]) {\n return this.#group.addMembers(accountAddresses);\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#group.addMembersByInboxId(inboxIds);\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#group.removeMembers(accountAddresses);\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#group.removeMembersByInboxId(inboxIds);\n }\n\n async addAdmin(inboxId: string) {\n return this.#group.addAdmin(inboxId);\n }\n\n async removeAdmin(inboxId: string) {\n return this.#group.removeAdmin(inboxId);\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#group.addSuperAdmin(inboxId);\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#group.removeSuperAdmin(inboxId);\n }\n\n async publishMessages() {\n return this.#group.publishMessages();\n }\n\n sendOptimistic(encodedContent: EncodedContent) {\n return this.#group.sendOptimistic(encodedContent);\n }\n\n async send(encodedContent: EncodedContent) {\n return this.#group.send(encodedContent);\n }\n\n 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","import type { Conversation, Conversations } from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeCreateGroupOptions,\n fromSafeListConversationsOptions,\n type HmacKeys,\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() {\n return this.#conversations.syncAllConversations();\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 Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = this.#conversations.listGroups(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n listDms(options?: Omit<SafeListConversationsOptions, \"conversation_type\">) {\n const groups = this.#conversations.listDms(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const group = await this.#conversations.createGroup(\n accountAddresses,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDm(accountAddress: string) {\n const group = await this.#conversations.createDm(accountAddress);\n return new WorkerConversation(this.#client, group);\n }\n\n getHmacKeys() {\n return this.#conversations.getHmacKeys() as HmacKeys;\n }\n}\n","import {\n verifySignedWithPublicKey,\n type Client,\n type ConsentEntityType,\n type SignatureRequestType,\n} from \"@xmtp/wasm-bindings\";\nimport type { ClientOptions } from \"@/types\";\nimport { fromSafeConsent, type SafeConsent } from \"@/utils/conversions\";\nimport { createClient } from \"@/utils/createClient\";\nimport { WorkerConversations } from \"@/WorkerConversations\";\n\nexport class WorkerClient {\n #client: Client;\n\n #conversations: WorkerConversations;\n\n #accountAddress: string;\n\n constructor(client: Client) {\n this.#client = client;\n this.#accountAddress = client.accountAddress;\n this.#conversations = new WorkerConversations(this, client.conversations());\n }\n\n static async create(\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n ) {\n const client = await createClient(accountAddress, encryptionKey, options);\n return new WorkerClient(client);\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n get inboxId() {\n return this.#client.inboxId;\n }\n\n get installationId() {\n return this.#client.installationId;\n }\n\n get installationIdBytes() {\n return this.#client.installationIdBytes;\n }\n\n get isRegistered() {\n return this.#client.isRegistered;\n }\n\n async createInboxSignatureText() {\n try {\n return await this.#client.createInboxSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async addAccountSignatureText(accountAddress: string) {\n try {\n return await this.#client.addWalletSignatureText(accountAddress);\n } catch {\n return undefined;\n }\n }\n\n async removeAccountSignatureText(accountAddress: string) {\n try {\n return await this.#client.revokeWalletSignatureText(accountAddress);\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 addSignature(type: SignatureRequestType, bytes: Uint8Array) {\n return this.#client.addSignature(type, bytes);\n }\n\n async addScwSignature(\n type: SignatureRequestType,\n bytes: Uint8Array,\n chainId: bigint,\n blockNumber?: bigint,\n ) {\n return this.#client.addScwSignature(type, bytes, chainId, blockNumber);\n }\n\n async applySignatures() {\n return this.#client.applySignatureRequests();\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.#client.canMessage(accountAddresses) as Promise<\n Map<string, boolean>\n >;\n }\n\n async registerIdentity() {\n return this.#client.registerIdentity();\n }\n\n async findInboxIdByAddress(address: string) {\n return this.#client.findInboxIdByAddress(address);\n }\n\n async inboxState(refreshFromNetwork: boolean) {\n return this.#client.inboxState(refreshFromNetwork);\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.#client.getLatestInboxState(inboxId);\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.#client.setConsentStates(records.map(fromSafeConsent));\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.#client.getConsentState(entityType, entity);\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n 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 init, {\n createClient as createWasmClient,\n generateInboxId,\n getInboxIdForAddress,\n LogOptions,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls } from \"@/constants\";\nimport type { ClientOptions } from \"@/types\";\n\nexport const createClient = async (\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n) => {\n // initialize WASM module\n await init();\n\n const host = options?.apiUrl ?? ApiUrls[options?.env ?? \"dev\"];\n // TODO: add db path validation\n // - must end with .db3\n // - must not contain invalid characters\n // - must not start with a dot\n const dbPath =\n options?.dbPath ?? `xmtp-${options?.env ?? \"dev\"}-${accountAddress}.db3`;\n\n const inboxId =\n (await getInboxIdForAddress(host, accountAddress)) ||\n generateInboxId(accountAddress);\n\n const isLogging =\n options &&\n (options.loggingLevel !== undefined ||\n options.structuredLogging ||\n options.performanceLogging);\n\n return createWasmClient(\n host,\n inboxId,\n accountAddress,\n dbPath,\n encryptionKey,\n undefined,\n isLogging\n ? new LogOptions(\n options.structuredLogging ?? false,\n options.performanceLogging ?? false,\n options.loggingLevel,\n )\n : undefined,\n );\n};\n","import type {\n ClientEventsActions,\n ClientEventsClientMessageData,\n ClientEventsErrorData,\n ClientEventsWorkerPostMessageData,\n} from \"@/types\";\nimport {\n fromEncodedContent,\n fromSafeEncodedContent,\n toSafeConversation,\n toSafeHmacKey,\n toSafeInboxState,\n toSafeMessage,\n} from \"@/utils/conversions\";\nimport { WorkerClient } from \"@/WorkerClient\";\n\nlet client: WorkerClient;\nlet enableLogging = false;\n\n/**\n * Type-safe postMessage\n */\nconst postMessage = <A extends ClientEventsActions>(\n data: ClientEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for errors\n */\nconst postMessageError = (data: ClientEventsErrorData) => {\n self.postMessage(data);\n};\n\nself.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {\n const { action, id, data } = event.data;\n\n if (enableLogging) {\n console.log(\"client worker received event data\", event.data);\n }\n\n // a client is required for all actions except init\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (action !== \"init\" && !client) {\n postMessageError({\n id,\n action,\n error: \"Client not initialized\",\n });\n return;\n }\n\n try {\n switch (action) {\n /**\n * Client actions\n */\n case \"init\":\n client = await WorkerClient.create(\n data.address,\n data.encryptionKey,\n data.options,\n );\n enableLogging =\n data.options?.loggingLevel !== undefined &&\n data.options.loggingLevel !== \"off\";\n postMessage({\n id,\n action,\n result: {\n inboxId: client.inboxId,\n installationId: client.installationId,\n installationIdBytes: client.installationIdBytes,\n },\n });\n break;\n case \"createInboxSignatureText\": {\n const result = await client.createInboxSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addAccountSignatureText\": {\n const result = await client.addAccountSignatureText(\n data.newAccountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"removeAccountSignatureText\": {\n const result = await client.removeAccountSignatureText(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"revokeAllOtherInstallationsSignatureText\": {\n const result = await client.revokeAllAOtherInstallationsSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"revokeInstallationsSignatureText\": {\n const result = await client.revokeInstallationsSignatureText(\n data.installationIds,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addSignature\":\n await client.addSignature(data.type, data.bytes);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"addScwSignature\":\n await client.addScwSignature(\n data.type,\n data.bytes,\n data.chainId,\n data.blockNumber,\n );\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"applySignatures\":\n await client.applySignatures();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"registerIdentity\":\n await client.registerIdentity();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"isRegistered\": {\n const result = client.isRegistered;\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"canMessage\": {\n const result = await client.canMessage(data.accountAddresses);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"inboxState\": {\n const result = await client.inboxState(data.refreshFromNetwork);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"getLatestInboxState\": {\n const result = await client.getLatestInboxState(data.inboxId);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"setConsentStates\": {\n await client.setConsentStates(data.records);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConsentState\": {\n const result = await client.getConsentState(\n data.entityType,\n data.entity,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"findInboxIdByAddress\": {\n const result = await client.findInboxIdByAddress(data.address);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"signWithInstallationKey\": {\n const result = client.signWithInstallationKey(data.signatureText);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"verifySignedWithInstallationKey\": {\n const result = client.verifySignedWithInstallationKey(\n data.signatureText,\n data.signatureBytes,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"verifySignedWithPublicKey\": {\n const result = client.verifySignedWithPublicKey(\n data.signatureText,\n data.signatureBytes,\n data.publicKey,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n /**\n * Conversations actions\n */\n case \"getConversations\": {\n const conversations = client.conversations.list(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"getGroups\": {\n const conversations = client.conversations.listGroups(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"getDms\": {\n const conversations = client.conversations.listDms(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"newGroup\": {\n const conversation = await client.conversations.newGroup(\n data.accountAddresses,\n data.options,\n );\n postMessage({\n id,\n action,\n result: await toSafeConversation(conversation),\n });\n break;\n }\n case \"newDm\": {\n const conversation = await client.conversations.newDm(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result: await toSafeConversation(conversation),\n });\n break;\n }\n case \"syncConversations\": {\n await client.conversations.sync();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"syncAllConversations\": {\n await client.conversations.syncAll();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConversationById\": {\n const conversation = client.conversations.getConversationById(data.id);\n postMessage({\n id,\n action,\n result: conversation\n ? await toSafeConversation(conversation)\n : undefined,\n });\n break;\n }\n case \"getMessageById\": {\n const message = client.conversations.getMessageById(data.id);\n postMessage({\n id,\n action,\n result: message ? toSafeMessage(message) : undefined,\n });\n break;\n }\n case \"getDmByInboxId\": {\n const conversation = client.conversations.getDmByInboxId(data.inboxId);\n postMessage({\n id,\n action,\n result: conversation\n ? await toSafeConversation(conversation)\n : undefined,\n });\n break;\n }\n case \"getHmacKeys\": {\n const result = client.conversations.getHmacKeys();\n postMessage({\n id,\n action,\n result: Object.fromEntries(\n Array.from(result.entries()).map(([groupId, hmacKeys]) => [\n groupId,\n hmacKeys.map(toSafeHmacKey),\n ]),\n ),\n });\n break;\n }\n /**\n * Group actions\n */\n case \"syncGroup\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.sync();\n postMessage({\n id,\n action,\n result: await toSafeConversation(group),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupName\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateName(data.name);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupDescription\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateDescription(data.description);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupImageUrlSquare\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateImageUrl(data.imageUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPinnedFrameUrl\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePinnedFrameUrl(data.pinnedFrameUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.send(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendOptimisticGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.sendOptimistic(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"publishGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.publishMessages();\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const messages = await group.messages(data.options);\n postMessage({\n id,\n action,\n result: messages.map((message) => toSafeMessage(message)),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.members();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.admins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupSuperAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.superAdmins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.consentState,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n group.updateConsentState(data.state);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getDmPeerInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.dmPeerInboxId();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPermissionPolicy\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePermission(\n data.permissionType,\n data.policy,\n data.metadataField,\n );\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupPermissions\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const safeConversation = await toSafeConversation(group);\n postMessage({\n id,\n action,\n result: safeConversation.permissions,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n }\n } catch (e) {\n postMessageError({\n id,\n action,\n error: (e as Error).message,\n });\n }\n};\n"],"names":["fromEncodedContent","content","WasmEncodedContent","contentTypeId","type","WasmContentTypeId","authorityId","typeId","versionMajor","versionMinor","Map","Object","entries","parameters","fallback","compression","toSafeEncodedContent","fromSafeEncodedContent","ContentTypeId","toSafeMessage","message","fromEntries","convoId","deliveryStatus","id","kind","senderInboxId","sentAtNs","fromSafeListConversationsOptions","options","ListConversationsOptions","allowedStates","conversationType","createdAfterNs","createdBeforeNs","limit","fromSafeCreateGroupOptions","CreateGroupOptions","permissions","name","imageUrlSquare","description","pinnedFrameUrl","customPermissionPolicySet","GroupPermissionsOptions","CustomPolicy","policySet","PermissionPolicySet","addMemberPolicy","removeMemberPolicy","addAdminPolicy","removeAdminPolicy","updateGroupNamePolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateGroupPinnedFrameUrlPolicy","updateMessageExpirationPolicy","undefined","toSafeConversation","async","conversation","imageUrl","policyType","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","bytes","clientTimestampNs","toSafeInboxState","inboxState","accountAddresses","inboxId","installations","map","recoveryAddress","fromSafeConsent","consent","Consent","entityType","state","entity","toSafeHmacKey","hmacKey","key","epoch","ApiUrls","local","dev","production","WorkerConversation","client","group","constructor","this","groupName","updateName","updateGroupName","groupImageUrlSquare","updateImageUrl","updateGroupImageUrlSquare","groupDescription","updateDescription","updateGroupDescription","groupPinnedFrameUrl","updatePinnedFrameUrl","updateGroupPinnedFrameUrl","groupMetadata","creatorInboxId","members","listMembers","member","consentState","installationIds","permissionLevel","toSafeGroupMember","adminList","superAdminList","groupPermissions","updatePermission","permissionType","policy","metadataField","updatePermissionPolicy","isAdmin","isSuperAdmin","sync","addMembers","addMembersByInboxId","inboxIds","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","encodedContent","send","messages","findMessages","ListMessagesOptions","sentBeforeNs","sentAfterNs","direction","fromSafeListMessagesOptions","updateConsentState","dmPeerInboxId","WorkerConversations","conversations","syncAll","syncAllConversations","getConversationById","findGroupById","getMessageById","findMessageById","getDmByInboxId","findDmByTargetInboxId","list","listGroups","listDms","newGroup","createGroup","newDm","accountAddress","createDm","getHmacKeys","WorkerClient","create","encryptionKey","init","host","apiUrl","env","dbPath","getInboxIdForAddress","generateInboxId","isLogging","loggingLevel","structuredLogging","performanceLogging","createWasmClient","LogOptions","createClient","installationId","installationIdBytes","isRegistered","createInboxSignatureText","addAccountSignatureText","addWalletSignatureText","removeAccountSignatureText","revokeWalletSignatureText","revokeAllAOtherInstallationsSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","addScwSignature","chainId","blockNumber","applySignatures","applySignatureRequests","canMessage","registerIdentity","findInboxIdByAddress","address","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","signWithInstallationKey","signatureText","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","enableLogging","postMessage","data","self","postMessageError","onmessage","event","action","console","log","result","newAccountAddress","Promise","all","Array","from","groupId","hmacKeys","error","safeConversation","e"],"mappings":"2YA8BO,MAyDMA,EACXC,IAEA,WAAIC,GAjDJC,EAkDoBF,EAAQG,KAhD5B,IAAIC,EACFF,EAAcG,YACdH,EAAcI,OACdJ,EAAcK,aACdL,EAAcM,eA6Cd,IAAIC,IAAIC,OAAOC,QAAQX,EAAQY,aAC/BZ,EAAQa,SACRb,EAAQc,YACRd,EAAQA,SAvDqB,IAC/BE,CAuDC,EAUUa,EACXf,IACwB,OACxBG,MAnDAD,EAmD0BF,EAAQG,KAlDX,CACvBE,YAAaH,EAAcG,YAC3BC,OAAQJ,EAAcI,OACtBC,aAAcL,EAAcK,aAC5BC,aAAcN,EAAcM,eA+C5BI,WAAYZ,EAAQY,WACpBC,SAAUb,EAAQa,SAClBC,YAAad,EAAQc,YACrBd,QAASA,EAAQA,SAxDgB,IACjCE,CAwDA,EAEWc,EACXhB,IACoB,OACpBG,MApDAD,EAoD4BF,EAAQG,KAlDpC,IAAIc,EAAc,CAChBZ,Y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mBAG3B2L,EAAiB,CACfzM,KACA4M,SACAW,MAAO,oBAGX,QAGJ,MAAOE,GACPhB,EAAiB,CACfzM,KACA4M,SACAW,MAAQE,EAAY7N,eA/0BtB6M,EAAiB,CACfzM,KACA4M,SACAW,MAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmtp/browser-sdk",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "XMTP client SDK for browsers written in TypeScript",
5
5
  "keywords": [
6
6
  "xmtp",
@@ -64,7 +64,7 @@
64
64
  "@xmtp/content-type-primitives": "^2.0.0",
65
65
  "@xmtp/content-type-text": "^2.0.0",
66
66
  "@xmtp/proto": "^3.72.3",
67
- "@xmtp/wasm-bindings": "^0.0.11",
67
+ "@xmtp/wasm-bindings": "^0.0.12",
68
68
  "uuid": "^11.0.3"
69
69
  },
70
70
  "devDependencies": {
@@ -95,4 +95,8 @@ export class Conversations {
95
95
 
96
96
  return new Conversation(this.#client, conversation.id, conversation);
97
97
  }
98
+
99
+ async getHmacKeys() {
100
+ return this.#client.sendMessage("getHmacKeys", undefined);
101
+ }
98
102
  }
@@ -2,6 +2,7 @@ import type { Conversation, Conversations } from "@xmtp/wasm-bindings";
2
2
  import {
3
3
  fromSafeCreateGroupOptions,
4
4
  fromSafeListConversationsOptions,
5
+ type HmacKeys,
5
6
  type SafeCreateGroupOptions,
6
7
  type SafeListConversationsOptions,
7
8
  } from "@/utils/conversions";
@@ -89,4 +90,8 @@ export class WorkerConversations {
89
90
  const group = await this.#conversations.createDm(accountAddress);
90
91
  return new WorkerConversation(this.#client, group);
91
92
  }
93
+
94
+ getHmacKeys() {
95
+ return this.#conversations.getHmacKeys() as HmacKeys;
96
+ }
92
97
  }
package/src/index.ts CHANGED
@@ -34,6 +34,7 @@ export {
34
34
  SortDirection,
35
35
  Consent,
36
36
  ContentTypeId,
37
+ HmacKey,
37
38
  } from "@xmtp/wasm-bindings";
38
39
  export {
39
40
  isSmartContractSigner,
@@ -22,6 +22,7 @@ import type {
22
22
  SafeCreateGroupOptions,
23
23
  SafeEncodedContent,
24
24
  SafeGroupMember,
25
+ SafeHmacKeys,
25
26
  SafeInboxState,
26
27
  SafeListConversationsOptions,
27
28
  SafeListMessagesOptions,
@@ -276,6 +277,12 @@ export type ClientEvents =
276
277
  result: undefined;
277
278
  data: undefined;
278
279
  }
280
+ | {
281
+ action: "getHmacKeys";
282
+ id: string;
283
+ result: SafeHmacKeys;
284
+ data: undefined;
285
+ }
279
286
  /**
280
287
  * Group actions
281
288
  */
@@ -18,6 +18,7 @@ import {
18
18
  type DeliveryStatus,
19
19
  type GroupMembershipState,
20
20
  type GroupMessageKind,
21
+ type HmacKey,
21
22
  type InboxState,
22
23
  type Installation,
23
24
  type Message,
@@ -210,6 +211,7 @@ export type SafePermissionPolicySet = {
210
211
  updateGroupImageUrlSquarePolicy: PermissionPolicy;
211
212
  updateGroupNamePolicy: PermissionPolicy;
212
213
  updateGroupPinnedFrameUrlPolicy: PermissionPolicy;
214
+ updateMessageExpirationPolicy: PermissionPolicy;
213
215
  };
214
216
 
215
217
  export const toSafePermissionPolicySet = (
@@ -223,6 +225,7 @@ export const toSafePermissionPolicySet = (
223
225
  updateGroupImageUrlSquarePolicy: policySet.updateGroupImageUrlSquarePolicy,
224
226
  updateGroupNamePolicy: policySet.updateGroupNamePolicy,
225
227
  updateGroupPinnedFrameUrlPolicy: policySet.updateGroupPinnedFrameUrlPolicy,
228
+ updateMessageExpirationPolicy: policySet.updateMessageExpirationPolicy,
226
229
  });
227
230
 
228
231
  export const fromSafePermissionPolicySet = (
@@ -237,6 +240,7 @@ export const fromSafePermissionPolicySet = (
237
240
  policySet.updateGroupDescriptionPolicy,
238
241
  policySet.updateGroupImageUrlSquarePolicy,
239
242
  policySet.updateGroupPinnedFrameUrlPolicy,
243
+ policySet.updateMessageExpirationPolicy,
240
244
  );
241
245
 
242
246
  export type SafeCreateGroupOptions = {
@@ -292,6 +296,7 @@ export type SafeConversation = {
292
296
  updateGroupImageUrlSquarePolicy: PermissionPolicy;
293
297
  updateGroupNamePolicy: PermissionPolicy;
294
298
  updateGroupPinnedFrameUrlPolicy: PermissionPolicy;
299
+ updateMessageExpirationPolicy: PermissionPolicy;
295
300
  };
296
301
  };
297
302
  isActive: boolean;
@@ -328,6 +333,8 @@ export const toSafeConversation = async (
328
333
  conversation.permissions.policySet.updateGroupNamePolicy,
329
334
  updateGroupPinnedFrameUrlPolicy:
330
335
  conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,
336
+ updateMessageExpirationPolicy:
337
+ conversation.permissions.policySet.updateMessageExpirationPolicy,
331
338
  },
332
339
  },
333
340
  isActive: conversation.isActive,
@@ -339,15 +346,17 @@ export const toSafeConversation = async (
339
346
  });
340
347
 
341
348
  export type SafeInstallation = {
342
- id: string;
349
+ bytes: Uint8Array;
343
350
  clientTimestampNs?: bigint;
351
+ id: string;
344
352
  };
345
353
 
346
354
  export const toSafeInstallation = (
347
355
  installation: Installation,
348
356
  ): SafeInstallation => ({
349
- id: installation.id,
357
+ bytes: installation.bytes,
350
358
  clientTimestampNs: installation.clientTimestampNs,
359
+ id: installation.id,
351
360
  });
352
361
 
353
362
  export type SafeInboxState = {
@@ -403,3 +412,16 @@ export const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>
403
412
  member.permissionLevel,
404
413
  member.consentState,
405
414
  );
415
+
416
+ export type SafeHmacKey = {
417
+ key: Uint8Array;
418
+ epoch: bigint;
419
+ };
420
+
421
+ export const toSafeHmacKey = (hmacKey: HmacKey): SafeHmacKey => ({
422
+ key: hmacKey.key,
423
+ epoch: hmacKey.epoch,
424
+ });
425
+
426
+ export type HmacKeys = Map<string, HmacKey[]>;
427
+ export type SafeHmacKeys = Record<string, SafeHmacKey[]>;
@@ -8,6 +8,7 @@ import {
8
8
  fromEncodedContent,
9
9
  fromSafeEncodedContent,
10
10
  toSafeConversation,
11
+ toSafeHmacKey,
11
12
  toSafeInboxState,
12
13
  toSafeMessage,
13
14
  } from "@/utils/conversions";
@@ -376,6 +377,20 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
376
377
  });
377
378
  break;
378
379
  }
380
+ case "getHmacKeys": {
381
+ const result = client.conversations.getHmacKeys();
382
+ postMessage({
383
+ id,
384
+ action,
385
+ result: Object.fromEntries(
386
+ Array.from(result.entries()).map(([groupId, hmacKeys]) => [
387
+ groupId,
388
+ hmacKeys.map(toSafeHmacKey),
389
+ ]),
390
+ ),
391
+ });
392
+ break;
393
+ }
379
394
  /**
380
395
  * Group actions
381
396
  */