@xmtp/browser-sdk 0.0.11 → 0.0.12

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
@@ -96,10 +96,17 @@ type ClientEvents =
96
96
  accountAddress: string;
97
97
  };
98
98
  } | {
99
- action: "revokeInstallationsSignatureText";
99
+ action: "revokeAllOtherInstallationsSignatureText";
100
100
  id: string;
101
101
  result: string | undefined;
102
102
  data: undefined;
103
+ } | {
104
+ action: "revokeInstallationsSignatureText";
105
+ id: string;
106
+ result: string | undefined;
107
+ data: {
108
+ installationIds: Uint8Array[];
109
+ };
103
110
  } | {
104
111
  action: "addSignature";
105
112
  id: string;
@@ -564,9 +571,9 @@ declare class WorkerConversations {
564
571
  getConversationById(id: string): WorkerConversation | undefined;
565
572
  getMessageById(id: string): _xmtp_wasm_bindings.Message | undefined;
566
573
  getDmByInboxId(inboxId: string): WorkerConversation | undefined;
567
- list(options?: SafeListConversationsOptions): Promise<WorkerConversation[]>;
568
- listGroups(options?: Omit<SafeListConversationsOptions, "conversation_type">): Promise<WorkerConversation[]>;
569
- listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">): Promise<WorkerConversation[]>;
574
+ list(options?: SafeListConversationsOptions): WorkerConversation[];
575
+ listGroups(options?: Omit<SafeListConversationsOptions, "conversation_type">): WorkerConversation[];
576
+ listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">): WorkerConversation[];
570
577
  newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions): Promise<WorkerConversation>;
571
578
  newDm(accountAddress: string): Promise<WorkerConversation>;
572
579
  }
@@ -583,7 +590,8 @@ declare class WorkerClient {
583
590
  createInboxSignatureText(): Promise<string | undefined>;
584
591
  addAccountSignatureText(accountAddress: string): Promise<string | undefined>;
585
592
  removeAccountSignatureText(accountAddress: string): Promise<string | undefined>;
586
- revokeInstallationsSignatureText(): Promise<string | undefined>;
593
+ revokeAllAOtherInstallationsSignatureText(): Promise<string | undefined>;
594
+ revokeInstallationsSignatureText(installationIds: Uint8Array[]): Promise<string | undefined>;
587
595
  addSignature(type: SignatureRequestType, bytes: Uint8Array): Promise<void>;
588
596
  addScwSignature(type: SignatureRequestType, bytes: Uint8Array, chainId: bigint, blockNumber?: bigint): Promise<void>;
589
597
  applySignatures(): Promise<void>;
@@ -905,7 +913,8 @@ declare class Client extends ClientWorkerClass {
905
913
  register(): Promise<undefined>;
906
914
  addAccount(newAccountSigner: Signer): Promise<void>;
907
915
  removeAccount(accountAddress: string): Promise<void>;
908
- revokeInstallations(): Promise<void>;
916
+ revokeAllOtherInstallations(): Promise<void>;
917
+ revokeInstallations(installationIds: Uint8Array[]): Promise<void>;
909
918
  isRegistered(): Promise<boolean>;
910
919
  canMessage(accountAddresses: string[]): Promise<Map<string, boolean>>;
911
920
  static canMessage(accountAddresses: string[], env?: XmtpEnv): Promise<Map<string, boolean>>;
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 b{#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 w=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:w(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),f=e=>({type:A(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),k=e=>({type:S(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),G=e=>({content:f(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}),j=e=>({id:e.id,clientTimestampNs:e.clientTimestampNs}),R=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(j),recoveryAddress:e.recoveryAddress}),q=e=>({entity:e.entity,entityType:e.entityType,state:e.state}),K=e=>new p(e.entityType,e.state,e.entity),W=e=>({accountAddresses:e.accountAddresses,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}),O=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 b{#y;#I;#v;#b;#w;#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.#b=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.#b,options:this.options});this.#w=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.#w}get installationId(){return this.#M}get installationIdBytes(){return this.#A}async#P(){return this.sendMessage("createInboxSignatureText",void 0)}async#f(e){return this.sendMessage("addAccountSignatureText",{newAccountAddress:e})}async#k(e){return this.sendMessage("removeAccountSignatureText",{accountAddress:e})}async#G(){return this.sendMessage("revokeInstallationsSignatureText",void 0)}async#U(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#N(){return this.sendMessage("applySignatures",void 0)}async register(){const e=await this.#P();if(e)return await this.#U(h.CreateInbox,e,this.#x),this.sendMessage("registerIdentity",void 0)}async addAccount(e){const t=await this.#f(await e.getAddress());if(!t)throw new Error("Unable to generate add account signature text");await this.#U(h.AddWallet,t,e),await this.#N()}async removeAccount(e){const t=await this.#k(e);if(!t)throw new Error("Unable to generate remove account signature text");await this.#U(h.RevokeWallet,t,this.#x),await this.#N()}async revokeInstallations(){const e=await this.#G();if(!e)throw new Error("Unable to generate revoke installations signature text");await this.#U(h.RevokeInstallations,e,this.#x),await this.#N()}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),f(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=k(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,K as fromSafeConsent,S as fromSafeContentTypeId,E as fromSafeCreateGroupOptions,k as fromSafeEncodedContent,O as fromSafeGroupMember,T as fromSafeListConversationsOptions,N as fromSafeListMessagesOptions,L as fromSafePermissionPolicySet,z as isSmartContractSigner,w as toContentTypeId,x as toEncodedContent,q as toSafeConsent,A as toSafeContentTypeId,D as toSafeConversation,F as toSafeCreateGroupOptions,f as toSafeEncodedContent,W as toSafeGroupMember,R as toSafeInboxState,j 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,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};
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 #revokeInstallationsSignatureText() {\n return this.sendMessage(\"revokeInstallationsSignatureText\", undefined);\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 revokeInstallations() {\n const signatureText = await this.#revokeInstallationsSignatureText();\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","revokeInstallationsSignatureText","addSignature","signatureType","signatureText","signature","signMessage","bytes","chainId","getChainId","blockNumber","getBlockNumber","applySignatures","SignatureRequestType","CreateInbox","addAccount","newAccountSigner","AddWallet","removeAccount","RevokeWallet","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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iB,EAGzC,qBAAMkR,CAAgBxD,GACpB,OAAOtN,KAAKG,YAAY,kBAAmB,CACzCmN,UACA1N,cAAeI,MAAKJ,IAIxB,0BAAMmR,CAAqBzD,EAAiBgC,GAC1C,OAAOtP,KAAKG,YAAY,uBAAwB,CAC9CmN,UACAgC,MACA1P,cAAeI,MAAKJ,KCxBb,MAAAoR,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 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,KAAAC,GACErB,MAAKL,EAAQ2B,oBAAoB,UAAWtB,KAAKE,eACjDF,MAAKL,EAAQ2B,oBAAoB,QAASnC,GAC1Ca,MAAKL,EAAQ4B,aCvCJ,MAAAC,EACXC,GAEA,IAAIC,EAAc,CAChBC,YAAaF,EAAcE,YAC3BC,OAAQH,EAAcG,OACtBC,aAAcJ,EAAcI,aAC5BC,aAAcL,EAAcK,eAGnBC,EACXN,GAEA,IAAIO,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
1
- import{ContentTypeId as e}from"@xmtp/content-type-primitives";import t,{EncodedContent as n,ContentTypeId as i,Consent as r,ListConversationsOptions as o,CreateGroupOptions as s,GroupPermissionsOptions as a,ListMessagesOptions as d,PermissionPolicySet as c,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 o(e.allowedStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.limit),w=e=>{return new s(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},S=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}),x=e=>({id:e.id,clientTimestampNs:e.clientTimestampNs}),A=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(x),recoveryAddress:e.recoveryAddress}),G=e=>new r(e.entityType,e.state,e.entity),k={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}}async list(e){return(await this.#n.list(e?h(e):void 0)).map((e=>new f(this.#e,e)))}async listGroups(e){return(await this.#n.listGroups(e?h(e):void 0)).map((e=>new f(this.#e,e)))}async listDms(e){return(await 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?w(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??k[i?.env??"dev"],o=i?.dbPath??`xmtp-${i?.env??"dev"}-${e}.db3`,s=await u(r,e)||p(e),a=i&&(void 0!==i.loggingLevel||i.structuredLogging||i.performanceLogging);return l(r,s,e,o,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 revokeInstallationsSignatureText(){try{return await this.#e.revokeInstallationsSignatureText()}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(G))}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"revokeInstallationsSignatureText":{const e=await P.revokeInstallationsSignatureText();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:A(e)});break}case"getLatestInboxState":{const e=await P.getLatestInboxState(i.inboxId);T({id:n,action:t,result:A(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=await P.conversations.list(i.options);T({id:n,action:t,result:await Promise.all(e.map((e=>S(e))))});break}case"getGroups":{const e=await P.conversations.listGroups(i.options);T({id:n,action:t,result:await Promise.all(e.map((e=>S(e))))});break}case"getDms":{const e=await P.conversations.listDms(i.options);T({id:n,action:t,result:await Promise.all(e.map((e=>S(e))))});break}case"newGroup":{const e=await P.conversations.newGroup(i.accountAddresses,i.options);T({id:n,action:t,result:await S(e)});break}case"newDm":{const e=await P.conversations.newDm(i.accountAddress);T({id:n,action:t,result:await S(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 S(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 S(e):void 0});break}case"syncGroup":{const e=P.conversations.getConversationById(i.id);e?(await e.sync(),T({id:n,action:t,result:await S(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 S(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 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"})};
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 async list(options?: SafeListConversationsOptions) {\n const groups = (await this.#conversations.list(\n options ? fromSafeListConversationsOptions(options) : undefined,\n )) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = (await this.#conversations.listGroups(\n options ? fromSafeListConversationsOptions(options) : undefined,\n )) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async listDms(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = (await this.#conversations.listDms(\n options ? fromSafeListConversationsOptions(options) : undefined,\n )) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const group = await this.#conversations.createGroup(\n accountAddresses,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDm(accountAddress: string) {\n const group = await this.#conversations.createDm(accountAddress);\n return new WorkerConversation(this.#client, group);\n }\n}\n","import {\n 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 revokeInstallationsSignatureText() {\n try {\n return await this.#client.revokeInstallationsSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async addSignature(type: SignatureRequestType, bytes: Uint8Array) {\n return this.#client.addSignature(type, bytes);\n }\n\n async addScwSignature(\n type: SignatureRequestType,\n bytes: Uint8Array,\n chainId: bigint,\n blockNumber?: bigint,\n ) {\n return this.#client.addScwSignature(type, bytes, chainId, blockNumber);\n }\n\n async applySignatures() {\n return this.#client.applySignatureRequests();\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.#client.canMessage(accountAddresses) as Promise<\n Map<string, boolean>\n >;\n }\n\n async registerIdentity() {\n return this.#client.registerIdentity();\n }\n\n async findInboxIdByAddress(address: string) {\n return this.#client.findInboxIdByAddress(address);\n }\n\n async inboxState(refreshFromNetwork: boolean) {\n return this.#client.inboxState(refreshFromNetwork);\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.#client.getLatestInboxState(inboxId);\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.#client.setConsentStates(records.map(fromSafeConsent));\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.#client.getConsentState(entityType, entity);\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n 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 \"revokeInstallationsSignatureText\": {\n const result = await client.revokeInstallationsSignatureText();\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 = await 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 = await client.conversations.listGroups(\n data.options,\n );\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 = await 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 // console.log(\n // \"newGroup\",\n // fromSafeCreateGroupOptions(data.options!),\n // data.options,\n // );\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","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,aAC/BZ,EAAQa,SACRb,EAAQc,YACRd,EAAQA,SAvDqB,IAC/BE,CAuDC,EAUUa,EACXf,IACwB,OACxBG,MAnDAD,EAmD0BF,EAAQG,KAl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AAqB,CACxB,MAAMzI,EAAQD,EAAO2D,cAAcG,oBAAoBgE,EAAK/L,IAC5D,GAAIkE,EAAO,CACT,MAAMqI,EAASrI,EAAMiC,aAAa4F,EAAK7I,SACvC4I,EAAY,CACV9L,KACAoM,SACAG,gBAGFN,EAAiB,CACfjM,KACAoM,SACAO,MAAO,oBAGX,MAEF,IAAK,mBAAoB,CACvB,MAAMzI,EAAQD,EAAO2D,cAAcG,oBAAoBgE,EAAK/L,IAC5D,GAAIkE,EAAO,CACT,MAAMqI,EAASrI,EAAMwD,gBACrBoE,EAAY,CACV9L,KACAoM,SACAG,gBAGFN,EAAiB,CACfjM,KACAoM,SACAO,MAAO,oBAGX,MAEF,IAAK,8BAA+B,CAClC,MAAMzI,EAAQD,EAAO2D,cAAcG,oBAAoBgE,EAAK/L,IACxDkE,SACIA,EAAM2B,iBACVkG,EAAKjG,eACLiG,EAAKhG,OACLgG,EAAK/F,eAEP8F,EAAY,CACV9L,KACAoM,SACAG,YAAQvK,KAGViK,EAAiB,CACfjM,KACAoM,SACAO,MAAO,oBAGX,MAEF,IAAK,sBAAuB,CAC1B,MAAMzI,EAAQD,EAAO2D,cAAcG,oBAAoBgE,EAAK/L,IAC5D,GAAIkE,EAAO,CACT,MAAM0I,QAAyB3K,EAAmBiC,GAClD4H,EAAY,CACV9L,KACAoM,SACAG,OAAQK,EAAiB9L,mBAG3BmL,EAAiB,CACfjM,KACAoM,SACAO,MAAO,oBAGX,QAGJ,MAAOE,GACPZ,EAAiB,CACfjM,KACAoM,SACAO,MAAQE,EAAYjN,eA7zBtBqM,EAAiB,CACfjM,KACAoM,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 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,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,EAAQ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,KACAsM,SACAG,gBAGFN,EAAiB,CACfnM,KACAsM,SACAO,MAAO,oBAGX,MAEF,IAAK,oBAAqB,CACxB,MAAM3I,EAAQD,EAAO2D,cAAcG,oBAAoBkE,EAAKjM,IAC5D,GAAIkE,EAAO,CACT,MAAMuI,EAASvI,EAAMiC,aAAa8F,EAAK/I,SACvC8I,EAAY,CACVhM,KACAsM,SACAG,gBAGFN,EAAiB,CACfnM,KACAsM,SACAO,MAAO,oBAGX,MAEF,IAAK,mBAAoB,CACvB,MAAM3I,EAAQD,EAAO2D,cAAcG,oBAAoBkE,EAAKjM,IAC5D,GAAIkE,EAAO,CACT,MAAMuI,EAASvI,EAAMwD,gBACrBsE,EAAY,CACVhM,KACAsM,SACAG,gBAGFN,EAAiB,CACfnM,KACAsM,SACAO,MAAO,oBAGX,MAEF,IAAK,8BAA+B,CAClC,MAAM3I,EAAQD,EAAO2D,cAAcG,oBAAoBkE,EAAKjM,IACxDkE,SACIA,EAAM2B,iBACVoG,EAAKnG,eACLmG,EAAKlG,OACLkG,EAAKjG,eAEPgG,EAAY,CACVhM,KACAsM,SACAG,YAAQzK,KAGVmK,EAAiB,CACfnM,KACAsM,SACAO,MAAO,oBAGX,MAEF,IAAK,sBAAuB,CAC1B,MAAM3I,EAAQD,EAAO2D,cAAcG,oBAAoBkE,EAAKjM,IAC5D,GAAIkE,EAAO,CACT,MAAM4I,QAAyB7K,EAAmBiC,GAClD8H,EAAY,CACVhM,KACAsM,SACAG,OAAQK,EAAiBhM,mBAG3BqL,EAAiB,CACfnM,KACAsM,SACAO,MAAO,oBAGX,QAGJ,MAAOE,GACPZ,EAAiB,CACfnM,KACAsM,SACAO,MAAQE,EAAYnN,eAj0BtBuM,EAAiB,CACfnM,KACAsM,SACAO,MAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmtp/browser-sdk",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
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.9",
67
+ "@xmtp/wasm-bindings": "^0.0.11",
68
68
  "uuid": "^11.0.3"
69
69
  },
70
70
  "devDependencies": {
package/src/Client.ts CHANGED
@@ -126,8 +126,17 @@ export class Client extends ClientWorkerClass {
126
126
  return this.sendMessage("removeAccountSignatureText", { accountAddress });
127
127
  }
128
128
 
129
- async #revokeInstallationsSignatureText() {
130
- return this.sendMessage("revokeInstallationsSignatureText", undefined);
129
+ async #revokeAllOtherInstallationsSignatureText() {
130
+ return this.sendMessage(
131
+ "revokeAllOtherInstallationsSignatureText",
132
+ undefined,
133
+ );
134
+ }
135
+
136
+ async #revokeInstallationsSignatureText(installationIds: Uint8Array[]) {
137
+ return this.sendMessage("revokeInstallationsSignatureText", {
138
+ installationIds,
139
+ });
131
140
  }
132
141
 
133
142
  async #addSignature(
@@ -208,8 +217,28 @@ export class Client extends ClientWorkerClass {
208
217
  await this.#applySignatures();
209
218
  }
210
219
 
211
- async revokeInstallations() {
212
- const signatureText = await this.#revokeInstallationsSignatureText();
220
+ async revokeAllOtherInstallations() {
221
+ const signatureText =
222
+ await this.#revokeAllOtherInstallationsSignatureText();
223
+
224
+ if (!signatureText) {
225
+ throw new Error(
226
+ "Unable to generate revoke all other installations signature text",
227
+ );
228
+ }
229
+
230
+ await this.#addSignature(
231
+ SignatureRequestType.RevokeInstallations,
232
+ signatureText,
233
+ this.#signer,
234
+ );
235
+
236
+ await this.#applySignatures();
237
+ }
238
+
239
+ async revokeInstallations(installationIds: Uint8Array[]) {
240
+ const signatureText =
241
+ await this.#revokeInstallationsSignatureText(installationIds);
213
242
 
214
243
  if (!signatureText) {
215
244
  throw new Error("Unable to generate revoke installations signature text");
@@ -75,9 +75,19 @@ export class WorkerClient {
75
75
  }
76
76
  }
77
77
 
78
- async revokeInstallationsSignatureText() {
78
+ async revokeAllAOtherInstallationsSignatureText() {
79
79
  try {
80
- return await this.#client.revokeInstallationsSignatureText();
80
+ return await this.#client.revokeAllOtherInstallationsSignatureText();
81
+ } catch {
82
+ return undefined;
83
+ }
84
+ }
85
+
86
+ async revokeInstallationsSignatureText(installationIds: Uint8Array[]) {
87
+ try {
88
+ return await this.#client.revokeInstallationsSignatureText(
89
+ installationIds,
90
+ );
81
91
  } catch {
82
92
  return undefined;
83
93
  }
@@ -54,28 +54,26 @@ export class WorkerConversations {
54
54
  }
55
55
  }
56
56
 
57
- async list(options?: SafeListConversationsOptions) {
58
- const groups = (await this.#conversations.list(
57
+ list(options?: SafeListConversationsOptions) {
58
+ const groups = this.#conversations.list(
59
59
  options ? fromSafeListConversationsOptions(options) : undefined,
60
- )) as Conversation[];
60
+ ) as Conversation[];
61
61
  return groups.map((group) => new WorkerConversation(this.#client, group));
62
62
  }
63
63
 
64
- async listGroups(
64
+ listGroups(
65
65
  options?: Omit<SafeListConversationsOptions, "conversation_type">,
66
66
  ) {
67
- const groups = (await this.#conversations.listGroups(
67
+ const groups = this.#conversations.listGroups(
68
68
  options ? fromSafeListConversationsOptions(options) : undefined,
69
- )) as Conversation[];
69
+ ) as Conversation[];
70
70
  return groups.map((group) => new WorkerConversation(this.#client, group));
71
71
  }
72
72
 
73
- async listDms(
74
- options?: Omit<SafeListConversationsOptions, "conversation_type">,
75
- ) {
76
- const groups = (await this.#conversations.listDms(
73
+ listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">) {
74
+ const groups = this.#conversations.listDms(
77
75
  options ? fromSafeListConversationsOptions(options) : undefined,
78
- )) as Conversation[];
76
+ ) as Conversation[];
79
77
  return groups.map((group) => new WorkerConversation(this.#client, group));
80
78
  }
81
79
 
@@ -69,11 +69,19 @@ export type ClientEvents =
69
69
  };
70
70
  }
71
71
  | {
72
- action: "revokeInstallationsSignatureText";
72
+ action: "revokeAllOtherInstallationsSignatureText";
73
73
  id: string;
74
74
  result: string | undefined;
75
75
  data: undefined;
76
76
  }
77
+ | {
78
+ action: "revokeInstallationsSignatureText";
79
+ id: string;
80
+ result: string | undefined;
81
+ data: {
82
+ installationIds: Uint8Array[];
83
+ };
84
+ }
77
85
  | {
78
86
  action: "addSignature";
79
87
  id: string;
@@ -105,8 +105,19 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
105
105
  });
106
106
  break;
107
107
  }
108
+ case "revokeAllOtherInstallationsSignatureText": {
109
+ const result = await client.revokeAllAOtherInstallationsSignatureText();
110
+ postMessage({
111
+ id,
112
+ action,
113
+ result,
114
+ });
115
+ break;
116
+ }
108
117
  case "revokeInstallationsSignatureText": {
109
- const result = await client.revokeInstallationsSignatureText();
118
+ const result = await client.revokeInstallationsSignatureText(
119
+ data.installationIds,
120
+ );
110
121
  postMessage({
111
122
  id,
112
123
  action,
@@ -255,7 +266,7 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
255
266
  * Conversations actions
256
267
  */
257
268
  case "getConversations": {
258
- const conversations = await client.conversations.list(data.options);
269
+ const conversations = client.conversations.list(data.options);
259
270
  postMessage({
260
271
  id,
261
272
  action,
@@ -268,9 +279,7 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
268
279
  break;
269
280
  }
270
281
  case "getGroups": {
271
- const conversations = await client.conversations.listGroups(
272
- data.options,
273
- );
282
+ const conversations = client.conversations.listGroups(data.options);
274
283
  postMessage({
275
284
  id,
276
285
  action,
@@ -283,7 +292,7 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
283
292
  break;
284
293
  }
285
294
  case "getDms": {
286
- const conversations = await client.conversations.listDms(data.options);
295
+ const conversations = client.conversations.listDms(data.options);
287
296
  postMessage({
288
297
  id,
289
298
  action,
@@ -296,11 +305,6 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
296
305
  break;
297
306
  }
298
307
  case "newGroup": {
299
- // console.log(
300
- // "newGroup",
301
- // fromSafeCreateGroupOptions(data.options!),
302
- // data.options,
303
- // );
304
308
  const conversation = await client.conversations.newGroup(
305
309
  data.accountAddresses,
306
310
  data.options,