@xmtp/browser-sdk 0.0.14 → 0.0.15
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 +18 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/workers/client.js +1 -1
- package/dist/workers/client.js.map +1 -1
- package/dist/workers/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +6 -0
- package/src/index.ts +1 -1
- package/src/types/options.ts +13 -8
- package/src/utils/createClient.ts +5 -6
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ declare const ApiUrls: {
|
|
|
8
8
|
readonly dev: "https://dev.xmtp.network";
|
|
9
9
|
readonly production: "https://production.xmtp.network";
|
|
10
10
|
};
|
|
11
|
+
declare const HistorySyncUrls: {
|
|
12
|
+
readonly local: "http://localhost:5558";
|
|
13
|
+
readonly dev: "https://message-history.dev.ephemera.network";
|
|
14
|
+
readonly production: "https://message-history.production.ephemera.network";
|
|
15
|
+
};
|
|
11
16
|
|
|
12
17
|
type XmtpEnv = keyof typeof ApiUrls;
|
|
13
18
|
/**
|
|
@@ -23,6 +28,17 @@ type NetworkOptions = {
|
|
|
23
28
|
* specific endpoint
|
|
24
29
|
*/
|
|
25
30
|
apiUrl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* historySyncUrl can be used to override the `env` flag and connect to a
|
|
33
|
+
* specific endpoint for syncing history
|
|
34
|
+
*/
|
|
35
|
+
historySyncUrl?: string;
|
|
36
|
+
};
|
|
37
|
+
type ContentOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* Allow configuring codecs for additional content types
|
|
40
|
+
*/
|
|
41
|
+
codecs?: ContentCodec[];
|
|
26
42
|
};
|
|
27
43
|
/**
|
|
28
44
|
* Storage options
|
|
@@ -33,12 +49,6 @@ type StorageOptions = {
|
|
|
33
49
|
*/
|
|
34
50
|
dbPath?: string;
|
|
35
51
|
};
|
|
36
|
-
type ContentOptions = {
|
|
37
|
-
/**
|
|
38
|
-
* Allow configuring codecs for additional content types
|
|
39
|
-
*/
|
|
40
|
-
codecs?: ContentCodec[];
|
|
41
|
-
};
|
|
42
52
|
type OtherOptions = {
|
|
43
53
|
/**
|
|
44
54
|
* Enable structured JSON logging
|
|
@@ -57,7 +67,7 @@ type OtherOptions = {
|
|
|
57
67
|
*/
|
|
58
68
|
disableAutoRegister?: boolean;
|
|
59
69
|
};
|
|
60
|
-
type ClientOptions = NetworkOptions &
|
|
70
|
+
type ClientOptions = NetworkOptions & ContentOptions & StorageOptions & OtherOptions;
|
|
61
71
|
|
|
62
72
|
type ClientEvents =
|
|
63
73
|
/**
|
|
@@ -965,4 +975,4 @@ declare class Utils extends UtilsWorkerClass {
|
|
|
965
975
|
getInboxIdForAddress(address: string, env?: XmtpEnv): Promise<string | undefined>;
|
|
966
976
|
}
|
|
967
977
|
|
|
968
|
-
export { ApiUrls, Client, type ClientEvents, type ClientEventsActions, type ClientEventsClientMessageData, type ClientEventsClientPostMessageData, type ClientEventsErrorData, type ClientEventsResult, type ClientEventsWorkerMessageData, type ClientEventsWorkerPostMessageData, type ClientOptions, type ClientSendMessageData, type ContentOptions, Conversation, Conversations, DecodedMessage, type EventsClientMessageData, type EventsClientPostMessageData, type EventsErrorData, type EventsResult, type EventsWorkerMessageData, type EventsWorkerPostMessageData, type GenericEvent, type HmacKeys, type MessageDeliveryStatus, type MessageKind, type NetworkOptions, type OtherOptions, type SafeConsent, type SafeContentTypeId, type SafeConversation, type SafeCreateGroupOptions, type SafeEncodedContent, type SafeGroupMember, type SafeHmacKey, type SafeHmacKeys, type SafeInboxState, type SafeInstallation, type SafeListConversationsOptions, type SafeListMessagesOptions, type SafeMessage, type SafePermissionPolicySet, type SendMessageData, type Signer, type SmartContractSigner, type StorageOptions, Utils, type UtilsEvents, type UtilsEventsActions, type UtilsEventsClientMessageData, type UtilsEventsClientPostMessageData, type UtilsEventsErrorData, type UtilsEventsResult, type UtilsEventsWorkerMessageData, type UtilsEventsWorkerPostMessageData, type UtilsSendMessageData, type XmtpEnv, fromContentTypeId, fromEncodedContent, fromSafeConsent, fromSafeContentTypeId, fromSafeCreateGroupOptions, fromSafeEncodedContent, fromSafeGroupMember, fromSafeListConversationsOptions, fromSafeListMessagesOptions, fromSafePermissionPolicySet, isSmartContractSigner, toContentTypeId, toEncodedContent, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeHmacKey, toSafeInboxState, toSafeInstallation, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage, toSafePermissionPolicySet };
|
|
978
|
+
export { ApiUrls, Client, type ClientEvents, type ClientEventsActions, type ClientEventsClientMessageData, type ClientEventsClientPostMessageData, type ClientEventsErrorData, type ClientEventsResult, type ClientEventsWorkerMessageData, type ClientEventsWorkerPostMessageData, type ClientOptions, type ClientSendMessageData, type ContentOptions, Conversation, Conversations, DecodedMessage, type EventsClientMessageData, type EventsClientPostMessageData, type EventsErrorData, type EventsResult, type EventsWorkerMessageData, type EventsWorkerPostMessageData, type GenericEvent, HistorySyncUrls, type HmacKeys, type MessageDeliveryStatus, type MessageKind, type NetworkOptions, type OtherOptions, type SafeConsent, type SafeContentTypeId, type SafeConversation, type SafeCreateGroupOptions, type SafeEncodedContent, type SafeGroupMember, type SafeHmacKey, type SafeHmacKeys, type SafeInboxState, type SafeInstallation, type SafeListConversationsOptions, type SafeListMessagesOptions, type SafeMessage, type SafePermissionPolicySet, type SendMessageData, type Signer, type SmartContractSigner, type StorageOptions, Utils, type UtilsEvents, type UtilsEventsActions, type UtilsEventsClientMessageData, type UtilsEventsClientPostMessageData, type UtilsEventsErrorData, type UtilsEventsResult, type UtilsEventsWorkerMessageData, type UtilsEventsWorkerPostMessageData, type UtilsSendMessageData, type XmtpEnv, fromContentTypeId, fromEncodedContent, fromSafeConsent, fromSafeContentTypeId, fromSafeCreateGroupOptions, fromSafeEncodedContent, fromSafeGroupMember, fromSafeListConversationsOptions, fromSafeListMessagesOptions, fromSafePermissionPolicySet, isSmartContractSigner, toContentTypeId, toEncodedContent, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeHmacKey, toSafeInboxState, toSafeInstallation, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage, toSafePermissionPolicySet };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{GroupUpdatedCodec as e,ContentTypeGroupUpdated as t}from"@xmtp/content-type-group-updated";import{ContentTypeText as s,TextCodec as n}from"@xmtp/content-type-text";import{ContentTypeId as i,EncodedContent as r,ListMessagesOptions as a,ListConversationsOptions as o,PermissionPolicySet as d,CreateGroupOptions as c,GroupPermissionsOptions as l,Consent as p,GroupMember as u,GroupMessageKind as m,DeliveryStatus as g,SignatureRequestType as h}from"@xmtp/wasm-bindings";export{Consent,ConsentEntityType,ConsentState,ContentTypeId,ConversationType,CreateGroupOptions,DeliveryStatus,EncodedContent,GroupMember,GroupMembershipState,GroupMessageKind,GroupMetadata,GroupPermissions,GroupPermissionsOptions,HmacKey,InboxState,Installation,ListConversationsOptions,ListMessagesOptions,Message,MetadataField,PermissionLevel,PermissionPolicy,PermissionPolicySet,PermissionUpdateType,SignatureRequestType,SortDirection}from"@xmtp/wasm-bindings";import{v4 as y}from"uuid";import{ContentTypeId as I}from"@xmtp/content-type-primitives";const v=e=>{console.error(`Worker error on line ${e.lineno} in "${e.filename}"`),console.error(e.message)};class w{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),this.#e.addEventListener("error",v),this.#t=t}sendMessage(e,t){const s=y();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("client received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(new Error(t.error)):s.resolve(t.result))};close(){this.#e.removeEventListener("message",this.handleMessage),this.#e.removeEventListener("error",v),this.#e.terminate()}}const b=e=>new I({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),M=e=>new i(e.authorityId,e.typeId,e.versionMajor,e.versionMinor),A=e=>({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),S=e=>new I({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),x=e=>({type:b(e.type),parameters:Object.fromEntries(e.parameters),fallback:e.fallback,compression:e.compression,content:e.content}),P=e=>new r(M(e.type),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content),k=e=>({type:A(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),f=e=>({type:S(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),G=e=>({content:k(x(e.content)),convoId:e.convoId,deliveryStatus:e.deliveryStatus,id:e.id,kind:e.kind,senderInboxId:e.senderInboxId,sentAtNs:e.sentAtNs}),U=e=>({deliveryStatus:e.deliveryStatus,direction:e.direction,limit:e.limit,sentAfterNs:e.sentAfterNs,sentBeforeNs:e.sentBeforeNs}),N=e=>new a(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction),C=e=>({allowedStates:e.allowedStates,conversationType:e.conversationType,createdAfterNs:e.createdAfterNs,createdBeforeNs:e.createdBeforeNs,limit:e.limit}),T=e=>new o(e.allowedStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.limit),B=e=>({addAdminPolicy:e.addAdminPolicy,addMemberPolicy:e.addMemberPolicy,removeAdminPolicy:e.removeAdminPolicy,removeMemberPolicy:e.removeMemberPolicy,updateGroupDescriptionPolicy:e.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.updateGroupPinnedFrameUrlPolicy,updateMessageExpirationPolicy:e.updateMessageExpirationPolicy}),L=e=>new d(e.addMemberPolicy,e.removeMemberPolicy,e.addAdminPolicy,e.removeAdminPolicy,e.updateGroupNamePolicy,e.updateGroupDescriptionPolicy,e.updateGroupImageUrlSquarePolicy,e.updateGroupPinnedFrameUrlPolicy,e.updateMessageExpirationPolicy),E=e=>({description:e.groupDescription,imageUrlSquare:e.groupImageUrlSquare,name:e.groupName,pinnedFrameUrl:e.groupPinnedFrameUrl,permissions:e.permissions,customPermissionPolicySet:e.customPermissionPolicySet}),F=e=>new c(e.permissions,e.name,e.imageUrlSquare,e.description,e.pinnedFrameUrl,e.customPermissionPolicySet&&e.permissions===l.CustomPolicy?L(e.customPermissionPolicySet):void 0),D=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,pinnedFrameUrl:e.pinnedFrameUrl,permissions:{policyType:e.permissions.policyType,policySet:{addAdminPolicy:e.permissions.policySet.addAdminPolicy,addMemberPolicy:e.permissions.policySet.addMemberPolicy,removeAdminPolicy:e.permissions.policySet.removeAdminPolicy,removeMemberPolicy:e.permissions.policySet.removeMemberPolicy,updateGroupDescriptionPolicy:e.permissions.policySet.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.permissions.policySet.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.permissions.policySet.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.permissions.policySet.updateGroupPinnedFrameUrlPolicy,updateMessageExpirationPolicy:e.permissions.policySet.updateMessageExpirationPolicy}},isActive:e.isActive,addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.admins,superAdmins:e.superAdmins,createdAtNs:e.createdAtNs}),K=e=>({bytes:e.bytes,clientTimestampNs:e.clientTimestampNs,id:e.id}),R=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(K),recoveryAddress:e.recoveryAddress}),j=e=>({entity:e.entity,entityType:e.entityType,state:e.state}),O=e=>new p(e.entityType,e.state,e.entity),q=e=>({accountAddresses:e.accountAddresses,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}),W=e=>new u(e.inboxId,e.accountAddresses,e.installationIds,e.permissionLevel,e.consentState),$=e=>({key:e.key,epoch:e.epoch});class H{#n;content;contentType;conversationId;deliveryStatus;fallback;compression;id;kind;parameters;encodedContent;senderInboxId;sentAtNs;constructor(e,t){switch(this.#n=e,this.id=t.id,this.sentAtNs=t.sentAtNs,this.conversationId=t.convoId,this.senderInboxId=t.senderInboxId,this.encodedContent=t.content,t.kind){case m.Application:this.kind="application";break;case m.MembershipChange:this.kind="membership_change"}switch(t.deliveryStatus){case g.Unpublished:this.deliveryStatus="unpublished";break;case g.Published:this.deliveryStatus="published";break;case g.Failed:this.deliveryStatus="failed"}this.contentType=S(t.content.type),this.parameters=new Map(Object.entries(t.content.parameters)),this.fallback=t.content.fallback,this.compression=t.content.compression,this.content=this.#n.decodeContent(t,this.contentType)}}class V{#n;#i;#r;#a;#o;#d;#c;#l;#p;#u;#m=[];#g=[];constructor(e,t,s){this.#n=e,this.#i=t,this.#h(s)}#h(e){this.#r=e?.name??"",this.#a=e?.imageUrl??"",this.#o=e?.description??"",this.#d=e?.pinnedFrameUrl??"",this.#c=e?.isActive??void 0,this.#l=e?.addedByInboxId??"",this.#p=e?.metadata??void 0,this.#u=e?.createdAtNs??void 0,this.#m=e?.admins??[],this.#g=e?.superAdmins??[]}get id(){return this.#i}get name(){return this.#r}async updateName(e){await this.#n.sendMessage("updateGroupName",{id:this.#i,name:e}),this.#r=e}get imageUrl(){return this.#a}async updateImageUrl(e){await this.#n.sendMessage("updateGroupImageUrlSquare",{id:this.#i,imageUrl:e}),this.#a=e}get description(){return this.#o}async updateDescription(e){await this.#n.sendMessage("updateGroupDescription",{id:this.#i,description:e}),this.#o=e}get pinnedFrameUrl(){return this.#d}async updatePinnedFrameUrl(e){await this.#n.sendMessage("updateGroupPinnedFrameUrl",{id:this.#i,pinnedFrameUrl:e}),this.#d=e}get isActive(){return this.#c}get addedByInboxId(){return this.#l}get createdAtNs(){return this.#u}get createdAt(){return this.#u?(e=this.#u,new Date(Number(e/1000000n))):void 0;var e}get metadata(){return this.#p}async members(){return this.#n.sendMessage("getGroupMembers",{id:this.#i})}get admins(){return this.#m}get superAdmins(){return this.#g}async syncAdmins(){const e=await this.#n.sendMessage("getGroupAdmins",{id:this.#i});this.#m=e}async syncSuperAdmins(){const e=await this.#n.sendMessage("getGroupSuperAdmins",{id:this.#i});this.#g=e}async permissions(){return this.#n.sendMessage("getGroupPermissions",{id:this.#i})}async updatePermission(e,t,s){return this.#n.sendMessage("updateGroupPermissionPolicy",{id:this.#i,permissionType:e,policy:t,metadataField:s})}async isAdmin(e){return await this.syncAdmins(),this.#m.includes(e)}async isSuperAdmin(e){return await this.syncSuperAdmins(),this.#g.includes(e)}async sync(){const e=await this.#n.sendMessage("syncGroup",{id:this.#i});this.#h(e)}async addMembers(e){return this.#n.sendMessage("addGroupMembers",{id:this.#i,accountAddresses:e})}async addMembersByInboxId(e){return this.#n.sendMessage("addGroupMembersByInboxId",{id:this.#i,inboxIds:e})}async removeMembers(e){return this.#n.sendMessage("removeGroupMembers",{id:this.#i,accountAddresses:e})}async removeMembersByInboxId(e){return this.#n.sendMessage("removeGroupMembersByInboxId",{id:this.#i,inboxIds:e})}async addAdmin(e){return this.#n.sendMessage("addGroupAdmin",{id:this.#i,inboxId:e})}async removeAdmin(e){return this.#n.sendMessage("removeGroupAdmin",{id:this.#i,inboxId:e})}async addSuperAdmin(e){return this.#n.sendMessage("addGroupSuperAdmin",{id:this.#i,inboxId:e})}async removeSuperAdmin(e){return this.#n.sendMessage("removeGroupSuperAdmin",{id:this.#i,inboxId:e})}async publishMessages(){return this.#n.sendMessage("publishGroupMessages",{id:this.#i})}async sendOptimistic(e,t){if("string"!=typeof e&&!t)throw new Error("Content type is required when sending content other than text");const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("sendOptimisticGroupMessage",{id:this.#i,content:n})}async send(e,t){if("string"!=typeof e&&!t)throw new Error("Content type is required when sending content other than text");const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("sendGroupMessage",{id:this.#i,content:n})}async messages(e){return(await this.#n.sendMessage("getGroupMessages",{id:this.#i,options:e})).map((e=>new H(this.#n,e)))}async consentState(){return this.#n.sendMessage("getGroupConsentState",{id:this.#i})}async updateConsentState(e){return this.#n.sendMessage("updateGroupConsentState",{id:this.#i,state:e})}async dmPeerInboxId(){return this.#n.sendMessage("getDmPeerInboxId",{id:this.#i})}}class _{#n;constructor(e){this.#n=e}async sync(){return this.#n.sendMessage("syncConversations",void 0)}async syncAll(){return this.#n.sendMessage("syncAllConversations",void 0)}async getConversationById(e){const t=await this.#n.sendMessage("getConversationById",{id:e});return t?new V(this.#n,e,t):void 0}async getMessageById(e){const t=await this.#n.sendMessage("getMessageById",{id:e});return t?new H(this.#n,t):void 0}async getDmByInboxId(e){const t=await this.#n.sendMessage("getDmByInboxId",{inboxId:e});return t?new V(this.#n,t.id,t):void 0}async list(e){return(await this.#n.sendMessage("getConversations",{options:e})).map((e=>new V(this.#n,e.id,e)))}async listGroups(e){return(await this.#n.sendMessage("getGroups",{options:e})).map((e=>new V(this.#n,e.id,e)))}async listDms(e){return(await this.#n.sendMessage("getDms",{options:e})).map((e=>new V(this.#n,e.id,e)))}async newGroup(e,t){const s=await this.#n.sendMessage("newGroup",{accountAddresses:e,options:t});return new V(this.#n,s.id,s)}async newDm(e){const t=await this.#n.sendMessage("newDm",{accountAddress:e});return new V(this.#n,t.id,t)}async getHmacKeys(){return this.#n.sendMessage("getHmacKeys",void 0)}}const z=e=>"getBlockNumber"in e&&"getChainId"in e;class J extends w{#y;#I;#v;#w;#b;#M;#A;#S=!1;#x;options;constructor(t,s,i,r){super(new Worker(new URL("./workers/client",import.meta.url),{type:"module"}),void 0!==r?.loggingLevel&&"off"!==r.loggingLevel),this.#y=s,this.options=r,this.#w=i,this.#x=t,this.#v=new _(this);const a=[new e,new n,...r?.codecs??[]];this.#I=new Map(a.map((e=>[e.contentType.toString(),e])))}get accountAddress(){return this.#y}async init(){const e=await this.sendMessage("init",{address:this.accountAddress,encryptionKey:this.#w,options:this.options});this.#b=e.inboxId,this.#M=e.installationId,this.#A=e.installationIdBytes,this.#S=!0}static async create(e,t,s){const n=await e.getAddress(),i=new J(e,n,t,s);return await i.init(),s?.disableAutoRegister||await i.register(),i}get isReady(){return this.#S}get inboxId(){return this.#b}get installationId(){return this.#M}get installationIdBytes(){return this.#A}async#P(){return this.sendMessage("createInboxSignatureText",void 0)}async#k(e){return this.sendMessage("addAccountSignatureText",{newAccountAddress:e})}async#f(e){return this.sendMessage("removeAccountSignatureText",{accountAddress:e})}async#G(){return this.sendMessage("revokeAllOtherInstallationsSignatureText",void 0)}async#U(e){return this.sendMessage("revokeInstallationsSignatureText",{installationIds:e})}async#N(e,t,s){const n=await s.signMessage(t);z(s)?await this.sendMessage("addScwSignature",{type:e,bytes:n,chainId:s.getChainId(),blockNumber:s.getBlockNumber()}):await this.sendMessage("addSignature",{type:e,bytes:n})}async#C(){return this.sendMessage("applySignatures",void 0)}async register(){const e=await this.#P();if(e)return await this.#N(h.CreateInbox,e,this.#x),this.sendMessage("registerIdentity",void 0)}async addAccount(e){const t=await this.#k(await e.getAddress());if(!t)throw new Error("Unable to generate add account signature text");await this.#N(h.AddWallet,t,e),await this.#C()}async removeAccount(e){const t=await this.#f(e);if(!t)throw new Error("Unable to generate remove account signature text");await this.#N(h.RevokeWallet,t,this.#x),await this.#C()}async revokeAllOtherInstallations(){const e=await this.#G();if(!e)throw new Error("Unable to generate revoke all other installations signature text");await this.#N(h.RevokeInstallations,e,this.#x),await this.#C()}async revokeInstallations(e){const t=await this.#U(e);if(!t)throw new Error("Unable to generate revoke installations signature text");await this.#N(h.RevokeInstallations,t,this.#x),await this.#C()}async isRegistered(){return this.sendMessage("isRegistered",void 0)}async canMessage(e){return this.sendMessage("canMessage",{accountAddresses:e})}static async canMessage(e,t){const s={getAddress:()=>"0x0000000000000000000000000000000000000000",signMessage:()=>new Uint8Array};return(await J.create(s,window.crypto.getRandomValues(new Uint8Array(32)),{disableAutoRegister:!0,env:t})).canMessage(e)}async findInboxIdByAddress(e){return this.sendMessage("findInboxIdByAddress",{address:e})}async inboxState(e){return this.sendMessage("inboxState",{refreshFromNetwork:e??!1})}async getLatestInboxState(e){return this.sendMessage("getLatestInboxState",{inboxId:e})}async setConsentStates(e){return this.sendMessage("setConsentStates",{records:e})}async getConsentState(e,t){return this.sendMessage("getConsentState",{entityType:e,entity:t})}get conversations(){return this.#v}codecFor(e){return this.#I.get(e.toString())}encodeContent(e,t){const s=this.codecFor(t);if(!s)throw new Error(`Codec not found for "${t.toString()}" content type`);const n=s.encode(e,this),i=s.fallback(e);return i&&(n.fallback=i),k(n)}decodeContent(e,s){const n=this.codecFor(s);if(!n)throw new Error(`Codec not found for "${s.toString()}" content type`);if(s.sameAs(t)&&e.kind!==m.MembershipChange)throw new Error("Error decoding group membership change");const i=f(e.content);return n.decode(i,this)}signWithInstallationKey(e){return this.sendMessage("signWithInstallationKey",{signatureText:e})}verifySignedWithInstallationKey(e,t){return this.sendMessage("verifySignedWithInstallationKey",{signatureText:e,signatureBytes:t})}verifySignedWithPublicKey(e,t,s){return this.sendMessage("verifySignedWithPublicKey",{signatureText:e,signatureBytes:t,publicKey:s})}}const Q=e=>{console.error(`Worker error on line ${e.lineno} in "${e.filename}"`),console.error(e.message)};class X{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),this.#e.addEventListener("error",Q),this.#t=t}sendMessage(e,t){const s=y();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("utils received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(new Error(t.error)):s.resolve(t.result))};close(){this.#e.removeEventListener("message",this.handleMessage),this.#e.removeEventListener("error",Q),this.#e.terminate()}}class Y extends X{#t;constructor(e){super(new Worker(new URL("./workers/utils",import.meta.url),{type:"module"}),e??!1),this.#t=e??!1}async generateInboxId(e){return this.sendMessage("generateInboxId",{address:e,enableLogging:this.#t})}async getInboxIdForAddress(e,t){return this.sendMessage("getInboxIdForAddress",{address:e,env:t,enableLogging:this.#t})}}const Z={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"};export{Z as ApiUrls,J as Client,V as Conversation,_ as Conversations,H as DecodedMessage,Y as Utils,M as fromContentTypeId,P as fromEncodedContent,O as fromSafeConsent,S as fromSafeContentTypeId,F as fromSafeCreateGroupOptions,f as fromSafeEncodedContent,W as fromSafeGroupMember,T as fromSafeListConversationsOptions,N as fromSafeListMessagesOptions,L as fromSafePermissionPolicySet,z as isSmartContractSigner,b as toContentTypeId,x as toEncodedContent,j as toSafeConsent,A as toSafeContentTypeId,D as toSafeConversation,E as toSafeCreateGroupOptions,k as toSafeEncodedContent,q as toSafeGroupMember,$ as toSafeHmacKey,R as toSafeInboxState,K as toSafeInstallation,C as toSafeListConversationsOptions,U as toSafeListMessagesOptions,G as toSafeMessage,B as toSafePermissionPolicySet};
|
|
1
|
+
import{GroupUpdatedCodec as e,ContentTypeGroupUpdated as t}from"@xmtp/content-type-group-updated";import{ContentTypeText as s,TextCodec as n}from"@xmtp/content-type-text";import{ContentTypeId as i,EncodedContent as r,ListMessagesOptions as a,ListConversationsOptions as o,PermissionPolicySet as d,CreateGroupOptions as c,GroupPermissionsOptions as l,Consent as p,GroupMember as u,GroupMessageKind as m,DeliveryStatus as g,SignatureRequestType as h}from"@xmtp/wasm-bindings";export{Consent,ConsentEntityType,ConsentState,ContentTypeId,ConversationType,CreateGroupOptions,DeliveryStatus,EncodedContent,GroupMember,GroupMembershipState,GroupMessageKind,GroupMetadata,GroupPermissions,GroupPermissionsOptions,HmacKey,InboxState,Installation,ListConversationsOptions,ListMessagesOptions,Message,MetadataField,PermissionLevel,PermissionPolicy,PermissionPolicySet,PermissionUpdateType,SignatureRequestType,SortDirection}from"@xmtp/wasm-bindings";import{v4 as y}from"uuid";import{ContentTypeId as v}from"@xmtp/content-type-primitives";const I=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",I),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",I),this.#e.terminate()}}const b=e=>new v({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 v({authorityId:e.authorityId,typeId:e.typeId,versionMajor:e.versionMajor,versionMinor:e.versionMinor}),x=e=>({type:b(e.type),parameters:Object.fromEntries(e.parameters),fallback:e.fallback,compression:e.compression,content:e.content}),P=e=>new r(M(e.type),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content),k=e=>({type:A(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),f=e=>({type:S(e.type),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content}),G=e=>({content:k(x(e.content)),convoId:e.convoId,deliveryStatus:e.deliveryStatus,id:e.id,kind:e.kind,senderInboxId:e.senderInboxId,sentAtNs:e.sentAtNs}),U=e=>({deliveryStatus:e.deliveryStatus,direction:e.direction,limit:e.limit,sentAfterNs:e.sentAfterNs,sentBeforeNs:e.sentBeforeNs}),N=e=>new a(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction),C=e=>({allowedStates:e.allowedStates,conversationType:e.conversationType,createdAfterNs:e.createdAfterNs,createdBeforeNs:e.createdBeforeNs,limit:e.limit}),T=e=>new o(e.allowedStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.limit),B=e=>({addAdminPolicy:e.addAdminPolicy,addMemberPolicy:e.addMemberPolicy,removeAdminPolicy:e.removeAdminPolicy,removeMemberPolicy:e.removeMemberPolicy,updateGroupDescriptionPolicy:e.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.updateGroupPinnedFrameUrlPolicy,updateMessageExpirationPolicy:e.updateMessageExpirationPolicy}),L=e=>new d(e.addMemberPolicy,e.removeMemberPolicy,e.addAdminPolicy,e.removeAdminPolicy,e.updateGroupNamePolicy,e.updateGroupDescriptionPolicy,e.updateGroupImageUrlSquarePolicy,e.updateGroupPinnedFrameUrlPolicy,e.updateMessageExpirationPolicy),E=e=>({description:e.groupDescription,imageUrlSquare:e.groupImageUrlSquare,name:e.groupName,pinnedFrameUrl:e.groupPinnedFrameUrl,permissions:e.permissions,customPermissionPolicySet:e.customPermissionPolicySet}),F=e=>new c(e.permissions,e.name,e.imageUrlSquare,e.description,e.pinnedFrameUrl,e.customPermissionPolicySet&&e.permissions===l.CustomPolicy?L(e.customPermissionPolicySet):void 0),D=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,pinnedFrameUrl:e.pinnedFrameUrl,permissions:{policyType:e.permissions.policyType,policySet:{addAdminPolicy:e.permissions.policySet.addAdminPolicy,addMemberPolicy:e.permissions.policySet.addMemberPolicy,removeAdminPolicy:e.permissions.policySet.removeAdminPolicy,removeMemberPolicy:e.permissions.policySet.removeMemberPolicy,updateGroupDescriptionPolicy:e.permissions.policySet.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.permissions.policySet.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.permissions.policySet.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.permissions.policySet.updateGroupPinnedFrameUrlPolicy,updateMessageExpirationPolicy:e.permissions.policySet.updateMessageExpirationPolicy}},isActive:e.isActive,addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.admins,superAdmins:e.superAdmins,createdAtNs:e.createdAtNs}),K=e=>({bytes:e.bytes,clientTimestampNs:e.clientTimestampNs,id:e.id}),R=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(K),recoveryAddress:e.recoveryAddress}),j=e=>({entity:e.entity,entityType:e.entityType,state:e.state}),O=e=>new p(e.entityType,e.state,e.entity),q=e=>({accountAddresses:e.accountAddresses,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}),W=e=>new u(e.inboxId,e.accountAddresses,e.installationIds,e.permissionLevel,e.consentState),$=e=>({key:e.key,epoch:e.epoch});class H{#n;content;contentType;conversationId;deliveryStatus;fallback;compression;id;kind;parameters;encodedContent;senderInboxId;sentAtNs;constructor(e,t){switch(this.#n=e,this.id=t.id,this.sentAtNs=t.sentAtNs,this.conversationId=t.convoId,this.senderInboxId=t.senderInboxId,this.encodedContent=t.content,t.kind){case m.Application:this.kind="application";break;case m.MembershipChange:this.kind="membership_change"}switch(t.deliveryStatus){case g.Unpublished:this.deliveryStatus="unpublished";break;case g.Published:this.deliveryStatus="published";break;case g.Failed:this.deliveryStatus="failed"}this.contentType=S(t.content.type),this.parameters=new Map(Object.entries(t.content.parameters)),this.fallback=t.content.fallback,this.compression=t.content.compression,this.content=this.#n.decodeContent(t,this.contentType)}}class V{#n;#i;#r;#a;#o;#d;#c;#l;#p;#u;#m=[];#g=[];constructor(e,t,s){this.#n=e,this.#i=t,this.#h(s)}#h(e){this.#r=e?.name??"",this.#a=e?.imageUrl??"",this.#o=e?.description??"",this.#d=e?.pinnedFrameUrl??"",this.#c=e?.isActive??void 0,this.#l=e?.addedByInboxId??"",this.#p=e?.metadata??void 0,this.#u=e?.createdAtNs??void 0,this.#m=e?.admins??[],this.#g=e?.superAdmins??[]}get id(){return this.#i}get name(){return this.#r}async updateName(e){await this.#n.sendMessage("updateGroupName",{id:this.#i,name:e}),this.#r=e}get imageUrl(){return this.#a}async updateImageUrl(e){await this.#n.sendMessage("updateGroupImageUrlSquare",{id:this.#i,imageUrl:e}),this.#a=e}get description(){return this.#o}async updateDescription(e){await this.#n.sendMessage("updateGroupDescription",{id:this.#i,description:e}),this.#o=e}get pinnedFrameUrl(){return this.#d}async updatePinnedFrameUrl(e){await this.#n.sendMessage("updateGroupPinnedFrameUrl",{id:this.#i,pinnedFrameUrl:e}),this.#d=e}get isActive(){return this.#c}get addedByInboxId(){return this.#l}get createdAtNs(){return this.#u}get createdAt(){return this.#u?(e=this.#u,new Date(Number(e/1000000n))):void 0;var e}get metadata(){return this.#p}async members(){return this.#n.sendMessage("getGroupMembers",{id:this.#i})}get admins(){return this.#m}get superAdmins(){return this.#g}async syncAdmins(){const e=await this.#n.sendMessage("getGroupAdmins",{id:this.#i});this.#m=e}async syncSuperAdmins(){const e=await this.#n.sendMessage("getGroupSuperAdmins",{id:this.#i});this.#g=e}async permissions(){return this.#n.sendMessage("getGroupPermissions",{id:this.#i})}async updatePermission(e,t,s){return this.#n.sendMessage("updateGroupPermissionPolicy",{id:this.#i,permissionType:e,policy:t,metadataField:s})}async isAdmin(e){return await this.syncAdmins(),this.#m.includes(e)}async isSuperAdmin(e){return await this.syncSuperAdmins(),this.#g.includes(e)}async sync(){const e=await this.#n.sendMessage("syncGroup",{id:this.#i});this.#h(e)}async addMembers(e){return this.#n.sendMessage("addGroupMembers",{id:this.#i,accountAddresses:e})}async addMembersByInboxId(e){return this.#n.sendMessage("addGroupMembersByInboxId",{id:this.#i,inboxIds:e})}async removeMembers(e){return this.#n.sendMessage("removeGroupMembers",{id:this.#i,accountAddresses:e})}async removeMembersByInboxId(e){return this.#n.sendMessage("removeGroupMembersByInboxId",{id:this.#i,inboxIds:e})}async addAdmin(e){return this.#n.sendMessage("addGroupAdmin",{id:this.#i,inboxId:e})}async removeAdmin(e){return this.#n.sendMessage("removeGroupAdmin",{id:this.#i,inboxId:e})}async addSuperAdmin(e){return this.#n.sendMessage("addGroupSuperAdmin",{id:this.#i,inboxId:e})}async removeSuperAdmin(e){return this.#n.sendMessage("removeGroupSuperAdmin",{id:this.#i,inboxId:e})}async publishMessages(){return this.#n.sendMessage("publishGroupMessages",{id:this.#i})}async sendOptimistic(e,t){if("string"!=typeof e&&!t)throw new Error("Content type is required when sending content other than text");const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("sendOptimisticGroupMessage",{id:this.#i,content:n})}async send(e,t){if("string"!=typeof e&&!t)throw new Error("Content type is required when sending content other than text");const n="string"==typeof e?this.#n.encodeContent(e,t??s):this.#n.encodeContent(e,t);return this.#n.sendMessage("sendGroupMessage",{id:this.#i,content:n})}async messages(e){return(await this.#n.sendMessage("getGroupMessages",{id:this.#i,options:e})).map((e=>new H(this.#n,e)))}async consentState(){return this.#n.sendMessage("getGroupConsentState",{id:this.#i})}async updateConsentState(e){return this.#n.sendMessage("updateGroupConsentState",{id:this.#i,state:e})}async dmPeerInboxId(){return this.#n.sendMessage("getDmPeerInboxId",{id:this.#i})}}class _{#n;constructor(e){this.#n=e}async sync(){return this.#n.sendMessage("syncConversations",void 0)}async syncAll(){return this.#n.sendMessage("syncAllConversations",void 0)}async getConversationById(e){const t=await this.#n.sendMessage("getConversationById",{id:e});return t?new V(this.#n,e,t):void 0}async getMessageById(e){const t=await this.#n.sendMessage("getMessageById",{id:e});return t?new H(this.#n,t):void 0}async getDmByInboxId(e){const t=await this.#n.sendMessage("getDmByInboxId",{inboxId:e});return t?new V(this.#n,t.id,t):void 0}async list(e){return(await this.#n.sendMessage("getConversations",{options:e})).map((e=>new V(this.#n,e.id,e)))}async listGroups(e){return(await this.#n.sendMessage("getGroups",{options:e})).map((e=>new V(this.#n,e.id,e)))}async listDms(e){return(await this.#n.sendMessage("getDms",{options:e})).map((e=>new V(this.#n,e.id,e)))}async newGroup(e,t){const s=await this.#n.sendMessage("newGroup",{accountAddresses:e,options:t});return new V(this.#n,s.id,s)}async newDm(e){const t=await this.#n.sendMessage("newDm",{accountAddress:e});return new V(this.#n,t.id,t)}async getHmacKeys(){return this.#n.sendMessage("getHmacKeys",void 0)}}const z=e=>"getBlockNumber"in e&&"getChainId"in e;class J extends w{#y;#v;#I;#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.#I=new _(this);const a=[new e,new n,...r?.codecs??[]];this.#v=new Map(a.map((e=>[e.contentType.toString(),e])))}get accountAddress(){return this.#y}async init(){const e=await this.sendMessage("init",{address:this.accountAddress,encryptionKey:this.#w,options:this.options});this.#b=e.inboxId,this.#M=e.installationId,this.#A=e.installationIdBytes,this.#S=!0}static async create(e,t,s){const n=await e.getAddress(),i=new J(e,n,t,s);return await i.init(),s?.disableAutoRegister||await i.register(),i}get isReady(){return this.#S}get inboxId(){return this.#b}get installationId(){return this.#M}get installationIdBytes(){return this.#A}async#P(){return this.sendMessage("createInboxSignatureText",void 0)}async#k(e){return this.sendMessage("addAccountSignatureText",{newAccountAddress:e})}async#f(e){return this.sendMessage("removeAccountSignatureText",{accountAddress:e})}async#G(){return this.sendMessage("revokeAllOtherInstallationsSignatureText",void 0)}async#U(e){return this.sendMessage("revokeInstallationsSignatureText",{installationIds:e})}async#N(e,t,s){const n=await s.signMessage(t);z(s)?await this.sendMessage("addScwSignature",{type:e,bytes:n,chainId:s.getChainId(),blockNumber:s.getBlockNumber()}):await this.sendMessage("addSignature",{type:e,bytes:n})}async#C(){return this.sendMessage("applySignatures",void 0)}async register(){const e=await this.#P();if(e)return await this.#N(h.CreateInbox,e,this.#x),this.sendMessage("registerIdentity",void 0)}async addAccount(e){const t=await this.#k(await e.getAddress());if(!t)throw new Error("Unable to generate add account signature text");await this.#N(h.AddWallet,t,e),await this.#C()}async removeAccount(e){const t=await this.#f(e);if(!t)throw new Error("Unable to generate remove account signature text");await this.#N(h.RevokeWallet,t,this.#x),await this.#C()}async revokeAllOtherInstallations(){const e=await this.#G();if(!e)throw new Error("Unable to generate revoke all other installations signature text");await this.#N(h.RevokeInstallations,e,this.#x),await this.#C()}async revokeInstallations(e){const t=await this.#U(e);if(!t)throw new Error("Unable to generate revoke installations signature text");await this.#N(h.RevokeInstallations,t,this.#x),await this.#C()}async isRegistered(){return this.sendMessage("isRegistered",void 0)}async canMessage(e){return this.sendMessage("canMessage",{accountAddresses:e})}static async canMessage(e,t){const s={getAddress:()=>"0x0000000000000000000000000000000000000000",signMessage:()=>new Uint8Array};return(await J.create(s,window.crypto.getRandomValues(new Uint8Array(32)),{disableAutoRegister:!0,env:t})).canMessage(e)}async findInboxIdByAddress(e){return this.sendMessage("findInboxIdByAddress",{address:e})}async inboxState(e){return this.sendMessage("inboxState",{refreshFromNetwork:e??!1})}async getLatestInboxState(e){return this.sendMessage("getLatestInboxState",{inboxId:e})}async setConsentStates(e){return this.sendMessage("setConsentStates",{records:e})}async getConsentState(e,t){return this.sendMessage("getConsentState",{entityType:e,entity:t})}get conversations(){return this.#I}codecFor(e){return this.#v.get(e.toString())}encodeContent(e,t){const s=this.codecFor(t);if(!s)throw new Error(`Codec not found for "${t.toString()}" content type`);const n=s.encode(e,this),i=s.fallback(e);return i&&(n.fallback=i),k(n)}decodeContent(e,s){const n=this.codecFor(s);if(!n)throw new Error(`Codec not found for "${s.toString()}" content type`);if(s.sameAs(t)&&e.kind!==m.MembershipChange)throw new Error("Error decoding group membership change");const i=f(e.content);return n.decode(i,this)}signWithInstallationKey(e){return this.sendMessage("signWithInstallationKey",{signatureText:e})}verifySignedWithInstallationKey(e,t){return this.sendMessage("verifySignedWithInstallationKey",{signatureText:e,signatureBytes:t})}verifySignedWithPublicKey(e,t,s){return this.sendMessage("verifySignedWithPublicKey",{signatureText:e,signatureBytes:t,publicKey:s})}}const Q=e=>{console.error(`Worker error on line ${e.lineno} in "${e.filename}"`),console.error(e.message)};class X{#e;#t;#s=new Map;constructor(e,t){this.#e=e,this.#e.addEventListener("message",this.handleMessage),this.#e.addEventListener("error",Q),this.#t=t}sendMessage(e,t){const s=y();this.#e.postMessage({action:e,id:s,data:t});return new Promise(((e,t)=>{this.#s.set(s,{resolve:e,reject:t})}))}handleMessage=e=>{const t=e.data;this.#t&&console.log("utils received event data",t);const s=this.#s.get(t.id);s&&(this.#s.delete(t.id),"error"in t?s.reject(new Error(t.error)):s.resolve(t.result))};close(){this.#e.removeEventListener("message",this.handleMessage),this.#e.removeEventListener("error",Q),this.#e.terminate()}}class Y extends X{#t;constructor(e){super(new Worker(new URL("./workers/utils",import.meta.url),{type:"module"}),e??!1),this.#t=e??!1}async generateInboxId(e){return this.sendMessage("generateInboxId",{address:e,enableLogging:this.#t})}async getInboxIdForAddress(e,t){return this.sendMessage("getInboxIdForAddress",{address:e,env:t,enableLogging:this.#t})}}const Z={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"},ee={local:"http://localhost:5558",dev:"https://message-history.dev.ephemera.network",production:"https://message-history.production.ephemera.network"};export{Z as ApiUrls,J as Client,V as Conversation,_ as Conversations,H as DecodedMessage,ee as HistorySyncUrls,Y as Utils,M as fromContentTypeId,P as fromEncodedContent,O as fromSafeConsent,S as fromSafeContentTypeId,F as fromSafeCreateGroupOptions,f as fromSafeEncodedContent,W as fromSafeGroupMember,T as fromSafeListConversationsOptions,N as fromSafeListMessagesOptions,L as fromSafePermissionPolicySet,z as isSmartContractSigner,b as toContentTypeId,x as toEncodedContent,j as toSafeConsent,A as toSafeContentTypeId,D as toSafeConversation,E as toSafeCreateGroupOptions,k as toSafeEncodedContent,q as toSafeGroupMember,$ as toSafeHmacKey,R as toSafeInboxState,K as toSafeInstallation,C as toSafeListConversationsOptions,U as toSafeListMessagesOptions,G as toSafeMessage,B as toSafePermissionPolicySet};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/ClientWorkerClass.ts","../src/utils/conversions.ts","../src/DecodedMessage.ts","../src/Conversation.ts","../src/utils/date.ts","../src/Conversations.ts","../src/utils/signer.ts","../src/Client.ts","../src/UtilsWorkerClass.ts","../src/Utils.ts","../src/constants.ts"],"sourcesContent":["import { v4 } from \"uuid\";\nimport type {\n ClientEventsActions,\n ClientEventsErrorData,\n ClientEventsResult,\n ClientEventsWorkerMessageData,\n ClientSendMessageData,\n} from \"@/types\";\n\nconst handleError = (event: ErrorEvent) => {\n console.error(`Worker error on line ${event.lineno} in \"${event.filename}\"`);\n console.error(event.message);\n};\n\nexport class ClientWorkerClass {\n #worker: Worker;\n\n #enableLogging: boolean;\n\n #promises = new Map<\n string,\n { resolve: (value: any) => void; reject: (reason?: any) => void }\n >();\n\n constructor(worker: Worker, enableLogging: boolean) {\n this.#worker = worker;\n this.#worker.addEventListener(\"message\", this.handleMessage);\n this.#worker.addEventListener(\"error\", handleError);\n this.#enableLogging = enableLogging;\n }\n\n sendMessage<A extends ClientEventsActions>(\n action: A,\n data: ClientSendMessageData<A>,\n ) {\n const promiseId = v4();\n this.#worker.postMessage({\n action,\n id: promiseId,\n data,\n });\n const promise = new Promise<ClientEventsResult<A>>((resolve, reject) => {\n this.#promises.set(promiseId, { resolve, reject });\n });\n return promise;\n }\n\n handleMessage = (\n event: MessageEvent<ClientEventsWorkerMessageData | ClientEventsErrorData>,\n ) => {\n const eventData = event.data;\n if (this.#enableLogging) {\n console.log(\"client received event data\", eventData);\n }\n const promise = this.#promises.get(eventData.id);\n if (promise) {\n this.#promises.delete(eventData.id);\n if (\"error\" in eventData) {\n promise.reject(new Error(eventData.error));\n } else {\n promise.resolve(eventData.result);\n }\n }\n };\n\n close() {\n this.#worker.removeEventListener(\"message\", this.handleMessage);\n this.#worker.removeEventListener(\"error\", handleError);\n this.#worker.terminate();\n }\n}\n","import {\n ContentTypeId,\n type EncodedContent,\n} from \"@xmtp/content-type-primitives\";\nimport {\n Consent,\n CreateGroupOptions,\n GroupMember,\n GroupPermissionsOptions,\n ListConversationsOptions,\n ListMessagesOptions,\n PermissionPolicySet,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ConversationType,\n type DeliveryStatus,\n type GroupMembershipState,\n type GroupMessageKind,\n type HmacKey,\n type InboxState,\n type Installation,\n type Message,\n type PermissionLevel,\n type PermissionPolicy,\n type SortDirection,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: DeliveryStatus;\n id: string;\n kind: GroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: Message): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convoId,\n deliveryStatus: message.deliveryStatus,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.senderInboxId,\n sentAtNs: message.sentAtNs,\n});\n\nexport type SafeListMessagesOptions = {\n deliveryStatus?: DeliveryStatus;\n direction?: SortDirection;\n limit?: bigint;\n sentAfterNs?: bigint;\n sentBeforeNs?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: ListMessagesOptions,\n): SafeListMessagesOptions => ({\n deliveryStatus: options.deliveryStatus,\n direction: options.direction,\n limit: options.limit,\n sentAfterNs: options.sentAfterNs,\n sentBeforeNs: options.sentBeforeNs,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): ListMessagesOptions =>\n new ListMessagesOptions(\n options.sentBeforeNs,\n options.sentAfterNs,\n options.limit,\n options.deliveryStatus,\n options.direction,\n );\n\nexport type SafeListConversationsOptions = {\n allowedStates?: GroupMembershipState[];\n conversationType?: ConversationType;\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n allowedStates: options.allowedStates,\n conversationType: options.conversationType,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.allowedStates,\n options.conversationType,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: PermissionPolicy;\n};\n\nexport const toSafePermissionPolicySet = (\n policySet: PermissionPolicySet,\n): SafePermissionPolicySet => ({\n addAdminPolicy: policySet.addAdminPolicy,\n addMemberPolicy: policySet.addMemberPolicy,\n removeAdminPolicy: policySet.removeAdminPolicy,\n removeMemberPolicy: policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy: policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy: policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy: policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy: policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy: policySet.updateMessageExpirationPolicy,\n});\n\nexport const fromSafePermissionPolicySet = (\n policySet: SafePermissionPolicySet,\n): PermissionPolicySet =>\n new PermissionPolicySet(\n policySet.addMemberPolicy,\n policySet.removeMemberPolicy,\n policySet.addAdminPolicy,\n policySet.removeAdminPolicy,\n policySet.updateGroupNamePolicy,\n policySet.updateGroupDescriptionPolicy,\n policySet.updateGroupImageUrlSquarePolicy,\n policySet.updateGroupPinnedFrameUrlPolicy,\n policySet.updateMessageExpirationPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n name?: string;\n permissions?: GroupPermissionsOptions;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n name: options.groupName,\n pinnedFrameUrl: options.groupPinnedFrameUrl,\n permissions: options.permissions,\n customPermissionPolicySet: options.customPermissionPolicySet,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): CreateGroupOptions =>\n new CreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n // only include custom policy set if permissions are set to CustomPolicy\n options.customPermissionPolicySet &&\n options.permissions === GroupPermissionsOptions.CustomPolicy\n ? fromSafePermissionPolicySet(options.customPermissionPolicySet)\n : undefined,\n );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: GroupPermissionsOptions;\n policySet: {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: PermissionPolicy;\n };\n };\n isActive: boolean;\n addedByInboxId: string;\n metadata: {\n creatorInboxId: string;\n conversationType: string;\n };\n admins: string[];\n superAdmins: string[];\n createdAtNs: bigint;\n};\n\nexport const toSafeConversation = async (\n conversation: WorkerConversation,\n): Promise<SafeConversation> => ({\n id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,\n addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,\n removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,\n removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy:\n conversation.permissions.policySet.updateMessageExpirationPolicy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: await conversation.metadata(),\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\n});\n\nexport type SafeInstallation = {\n bytes: Uint8Array;\n clientTimestampNs?: bigint;\n id: string;\n};\n\nexport const toSafeInstallation = (\n installation: Installation,\n): SafeInstallation => ({\n bytes: installation.bytes,\n clientTimestampNs: installation.clientTimestampNs,\n id: installation.id,\n});\n\nexport type SafeInboxState = {\n accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountAddresses: inboxState.accountAddresses,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recoveryAddress,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: ConsentEntityType;\n state: ConsentState;\n};\n\nexport const toSafeConsent = (consent: Consent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entityType,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): Consent =>\n new Consent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountAddresses: member.accountAddresses,\n consentState: member.consentState,\n inboxId: member.inboxId,\n installationIds: member.installationIds,\n permissionLevel: member.permissionLevel,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>\n new GroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n\nexport type SafeHmacKey = {\n key: Uint8Array;\n epoch: bigint;\n};\n\nexport const toSafeHmacKey = (hmacKey: HmacKey): SafeHmacKey => ({\n key: hmacKey.key,\n epoch: hmacKey.epoch,\n});\n\nexport type HmacKeys = Map<string, HmacKey[]>;\nexport type SafeHmacKeys = Record<string, SafeHmacKey[]>;\n","import type { ContentTypeId } from \"@xmtp/content-type-primitives\";\nimport { DeliveryStatus, GroupMessageKind } from \"@xmtp/wasm-bindings\";\nimport type { Client } from \"@/Client\";\nimport { fromSafeContentTypeId, type SafeMessage } from \"@/utils/conversions\";\n\nexport type MessageKind = \"application\" | \"membership_change\";\nexport type MessageDeliveryStatus = \"unpublished\" | \"published\" | \"failed\";\n\nexport class DecodedMessage {\n #client: Client;\n\n content: any;\n\n contentType: ContentTypeId;\n\n conversationId: string;\n\n deliveryStatus: MessageDeliveryStatus;\n\n fallback?: string;\n\n compression?: number;\n\n id: string;\n\n kind: MessageKind;\n\n parameters: Map<string, string>;\n\n encodedContent: SafeMessage[\"content\"];\n\n senderInboxId: string;\n\n sentAtNs: bigint;\n\n constructor(client: Client, message: SafeMessage) {\n this.#client = client;\n this.id = message.id;\n this.sentAtNs = message.sentAtNs;\n this.conversationId = message.convoId;\n this.senderInboxId = message.senderInboxId;\n this.encodedContent = message.content;\n\n switch (message.kind) {\n case GroupMessageKind.Application:\n this.kind = \"application\";\n break;\n case GroupMessageKind.MembershipChange:\n this.kind = \"membership_change\";\n break;\n // no default\n }\n\n switch (message.deliveryStatus) {\n case DeliveryStatus.Unpublished:\n this.deliveryStatus = \"unpublished\";\n break;\n case DeliveryStatus.Published:\n this.deliveryStatus = \"published\";\n break;\n case DeliveryStatus.Failed:\n this.deliveryStatus = \"failed\";\n break;\n // no default\n }\n\n this.contentType = fromSafeContentTypeId(message.content.type);\n this.parameters = new Map(Object.entries(message.content.parameters));\n this.fallback = message.content.fallback;\n this.compression = message.content.compression;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this.content = this.#client.decodeContent(message, this.contentType);\n }\n}\n","import type { ContentTypeId } from \"@xmtp/content-type-primitives\";\nimport { ContentTypeText } from \"@xmtp/content-type-text\";\nimport type {\n ConsentState,\n MetadataField,\n PermissionPolicy,\n PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport type { Client } from \"@/Client\";\nimport { DecodedMessage } from \"@/DecodedMessage\";\nimport type {\n SafeConversation,\n SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport { nsToDate } from \"@/utils/date\";\n\nexport class Conversation {\n #client: Client;\n\n #id: string;\n\n #name?: SafeConversation[\"name\"];\n\n #imageUrl?: SafeConversation[\"imageUrl\"];\n\n #description?: SafeConversation[\"description\"];\n\n #pinnedFrameUrl?: SafeConversation[\"pinnedFrameUrl\"];\n\n #isActive?: SafeConversation[\"isActive\"];\n\n #addedByInboxId?: SafeConversation[\"addedByInboxId\"];\n\n #metadata?: SafeConversation[\"metadata\"];\n\n #createdAtNs?: SafeConversation[\"createdAtNs\"];\n\n #admins: SafeConversation[\"admins\"] = [];\n\n #superAdmins: SafeConversation[\"superAdmins\"] = [];\n\n constructor(client: Client, id: string, data?: SafeConversation) {\n this.#client = client;\n this.#id = id;\n this.#syncData(data);\n }\n\n #syncData(data?: SafeConversation) {\n this.#name = data?.name ?? \"\";\n this.#imageUrl = data?.imageUrl ?? \"\";\n this.#description = data?.description ?? \"\";\n this.#pinnedFrameUrl = data?.pinnedFrameUrl ?? \"\";\n this.#isActive = data?.isActive ?? undefined;\n this.#addedByInboxId = data?.addedByInboxId ?? \"\";\n this.#metadata = data?.metadata ?? undefined;\n this.#createdAtNs = data?.createdAtNs ?? undefined;\n this.#admins = data?.admins ?? [];\n this.#superAdmins = data?.superAdmins ?? [];\n }\n\n get id() {\n return this.#id;\n }\n\n get name() {\n return this.#name;\n }\n\n async updateName(name: string) {\n await this.#client.sendMessage(\"updateGroupName\", {\n id: this.#id,\n name,\n });\n this.#name = name;\n }\n\n get imageUrl() {\n return this.#imageUrl;\n }\n\n async updateImageUrl(imageUrl: string) {\n await this.#client.sendMessage(\"updateGroupImageUrlSquare\", {\n id: this.#id,\n imageUrl,\n });\n this.#imageUrl = imageUrl;\n }\n\n get description() {\n return this.#description;\n }\n\n async updateDescription(description: string) {\n await this.#client.sendMessage(\"updateGroupDescription\", {\n id: this.#id,\n description,\n });\n this.#description = description;\n }\n\n get pinnedFrameUrl() {\n return this.#pinnedFrameUrl;\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n await this.#client.sendMessage(\"updateGroupPinnedFrameUrl\", {\n id: this.#id,\n pinnedFrameUrl,\n });\n this.#pinnedFrameUrl = pinnedFrameUrl;\n }\n\n get isActive() {\n return this.#isActive;\n }\n\n get addedByInboxId() {\n return this.#addedByInboxId;\n }\n\n get createdAtNs() {\n return this.#createdAtNs;\n }\n\n get createdAt() {\n return this.#createdAtNs ? nsToDate(this.#createdAtNs) : undefined;\n }\n\n get metadata() {\n return this.#metadata;\n }\n\n async members() {\n return this.#client.sendMessage(\"getGroupMembers\", {\n id: this.#id,\n });\n }\n\n get admins() {\n return this.#admins;\n }\n\n get superAdmins() {\n return this.#superAdmins;\n }\n\n async syncAdmins() {\n const admins = await this.#client.sendMessage(\"getGroupAdmins\", {\n id: this.#id,\n });\n this.#admins = admins;\n }\n\n async syncSuperAdmins() {\n const superAdmins = await this.#client.sendMessage(\"getGroupSuperAdmins\", {\n id: this.#id,\n });\n this.#superAdmins = superAdmins;\n }\n\n async permissions() {\n return this.#client.sendMessage(\"getGroupPermissions\", {\n id: this.#id,\n });\n }\n\n async updatePermission(\n permissionType: PermissionUpdateType,\n policy: PermissionPolicy,\n metadataField?: MetadataField,\n ) {\n return this.#client.sendMessage(\"updateGroupPermissionPolicy\", {\n id: this.#id,\n permissionType,\n policy,\n metadataField,\n });\n }\n\n async isAdmin(inboxId: string) {\n await this.syncAdmins();\n return this.#admins.includes(inboxId);\n }\n\n async isSuperAdmin(inboxId: string) {\n await this.syncSuperAdmins();\n return this.#superAdmins.includes(inboxId);\n }\n\n async sync() {\n const data = await this.#client.sendMessage(\"syncGroup\", {\n id: this.#id,\n });\n this.#syncData(data);\n }\n\n async addMembers(accountAddresses: string[]) {\n return this.#client.sendMessage(\"addGroupMembers\", {\n id: this.#id,\n accountAddresses,\n });\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#client.sendMessage(\"addGroupMembersByInboxId\", {\n id: this.#id,\n inboxIds,\n });\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#client.sendMessage(\"removeGroupMembers\", {\n id: this.#id,\n accountAddresses,\n });\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#client.sendMessage(\"removeGroupMembersByInboxId\", {\n id: this.#id,\n inboxIds,\n });\n }\n\n async addAdmin(inboxId: string) {\n return this.#client.sendMessage(\"addGroupAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async removeAdmin(inboxId: string) {\n return this.#client.sendMessage(\"removeGroupAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#client.sendMessage(\"addGroupSuperAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#client.sendMessage(\"removeGroupSuperAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async publishMessages() {\n return this.#client.sendMessage(\"publishGroupMessages\", {\n id: this.#id,\n });\n }\n\n async sendOptimistic(content: any, contentType?: ContentTypeId) {\n if (typeof content !== \"string\" && !contentType) {\n throw new Error(\n \"Content type is required when sending content other than text\",\n );\n }\n\n const safeEncodedContent =\n typeof content === \"string\"\n ? this.#client.encodeContent(content, contentType ?? ContentTypeText)\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.#client.encodeContent(content, contentType!);\n\n return this.#client.sendMessage(\"sendOptimisticGroupMessage\", {\n id: this.#id,\n content: safeEncodedContent,\n });\n }\n\n async send(content: any, contentType?: ContentTypeId) {\n if (typeof content !== \"string\" && !contentType) {\n throw new Error(\n \"Content type is required when sending content other than text\",\n );\n }\n\n const safeEncodedContent =\n typeof content === \"string\"\n ? this.#client.encodeContent(content, contentType ?? ContentTypeText)\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.#client.encodeContent(content, contentType!);\n\n return this.#client.sendMessage(\"sendGroupMessage\", {\n id: this.#id,\n content: safeEncodedContent,\n });\n }\n\n async messages(options?: SafeListMessagesOptions) {\n const messages = await this.#client.sendMessage(\"getGroupMessages\", {\n id: this.#id,\n options,\n });\n\n return messages.map((message) => new DecodedMessage(this.#client, message));\n }\n\n async consentState() {\n return this.#client.sendMessage(\"getGroupConsentState\", {\n id: this.#id,\n });\n }\n\n async updateConsentState(state: ConsentState) {\n return this.#client.sendMessage(\"updateGroupConsentState\", {\n id: this.#id,\n state,\n });\n }\n\n async dmPeerInboxId() {\n return this.#client.sendMessage(\"getDmPeerInboxId\", {\n id: this.#id,\n });\n }\n}\n","export function nsToDate(ns: bigint): Date {\n return new Date(Number(ns / 1_000_000n));\n}\n","import type { Client } from \"@/Client\";\nimport { Conversation } from \"@/Conversation\";\nimport { DecodedMessage } from \"@/DecodedMessage\";\nimport type {\n SafeCreateGroupOptions,\n SafeListConversationsOptions,\n} from \"@/utils/conversions\";\n\nexport class Conversations {\n #client: Client;\n\n constructor(client: Client) {\n this.#client = client;\n }\n\n async sync() {\n return this.#client.sendMessage(\"syncConversations\", undefined);\n }\n\n async syncAll() {\n return this.#client.sendMessage(\"syncAllConversations\", undefined);\n }\n\n async getConversationById(id: string) {\n const data = await this.#client.sendMessage(\"getConversationById\", {\n id,\n });\n return data ? new Conversation(this.#client, id, data) : undefined;\n }\n\n async getMessageById(id: string) {\n const data = await this.#client.sendMessage(\"getMessageById\", {\n id,\n });\n return data ? new DecodedMessage(this.#client, data) : undefined;\n }\n\n async getDmByInboxId(inboxId: string) {\n const data = await this.#client.sendMessage(\"getDmByInboxId\", {\n inboxId,\n });\n return data ? new Conversation(this.#client, data.id, data) : undefined;\n }\n\n async list(options?: SafeListConversationsOptions) {\n const conversations = await this.#client.sendMessage(\"getConversations\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const conversations = await this.#client.sendMessage(\"getGroups\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async listDms(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const conversations = await this.#client.sendMessage(\"getDms\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const conversation = await this.#client.sendMessage(\"newGroup\", {\n accountAddresses,\n options,\n });\n\n return new Conversation(this.#client, conversation.id, conversation);\n }\n\n async newDm(accountAddress: string) {\n const conversation = await this.#client.sendMessage(\"newDm\", {\n accountAddress,\n });\n\n return new Conversation(this.#client, conversation.id, conversation);\n }\n\n async getHmacKeys() {\n return this.#client.sendMessage(\"getHmacKeys\", undefined);\n }\n}\n","export type SignMessage = (message: string) => Promise<Uint8Array> | Uint8Array;\nexport type GetAddress = () => Promise<string> | string;\nexport type GetChainId = () => bigint;\nexport type GetBlockNumber = () => bigint;\n\nexport type Signer = {\n getAddress: GetAddress;\n signMessage: SignMessage;\n // these fields indicate that the signer is a smart contract wallet\n getBlockNumber?: GetBlockNumber;\n getChainId?: GetChainId;\n};\n\nexport type SmartContractSigner = Required<Signer>;\n\nexport const isSmartContractSigner = (\n signer: Signer,\n): signer is SmartContractSigner =>\n \"getBlockNumber\" in signer && \"getChainId\" in signer;\n","import {\n ContentTypeGroupUpdated,\n GroupUpdatedCodec,\n} from \"@xmtp/content-type-group-updated\";\nimport type {\n ContentCodec,\n ContentTypeId,\n} from \"@xmtp/content-type-primitives\";\nimport { TextCodec } from \"@xmtp/content-type-text\";\nimport {\n GroupMessageKind,\n SignatureRequestType,\n type ConsentEntityType,\n} from \"@xmtp/wasm-bindings\";\nimport { ClientWorkerClass } from \"@/ClientWorkerClass\";\nimport { Conversations } from \"@/Conversations\";\nimport type { ClientOptions, XmtpEnv } from \"@/types\";\nimport {\n fromSafeEncodedContent,\n toSafeEncodedContent,\n type SafeConsent,\n type SafeMessage,\n} from \"@/utils/conversions\";\nimport { isSmartContractSigner, type Signer } from \"@/utils/signer\";\n\nexport class Client extends ClientWorkerClass {\n #accountAddress: string;\n #codecs: Map<string, ContentCodec>;\n #conversations: Conversations;\n #encryptionKey: Uint8Array;\n #inboxId: string | undefined;\n #installationId: string | undefined;\n #installationIdBytes: Uint8Array | undefined;\n #isReady = false;\n #signer: Signer;\n options?: ClientOptions;\n\n constructor(\n signer: Signer,\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: ClientOptions,\n ) {\n const worker = new Worker(new URL(\"./workers/client\", import.meta.url), {\n type: \"module\",\n });\n super(\n worker,\n options?.loggingLevel !== undefined && options.loggingLevel !== \"off\",\n );\n this.#accountAddress = accountAddress;\n this.options = options;\n this.#encryptionKey = encryptionKey;\n this.#signer = signer;\n this.#conversations = new Conversations(this);\n const codecs = [\n new GroupUpdatedCodec(),\n new TextCodec(),\n ...(options?.codecs ?? []),\n ];\n this.#codecs = new Map(\n codecs.map((codec) => [codec.contentType.toString(), codec]),\n );\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n async init() {\n const result = await this.sendMessage(\"init\", {\n address: this.accountAddress,\n encryptionKey: this.#encryptionKey,\n options: this.options,\n });\n this.#inboxId = result.inboxId;\n this.#installationId = result.installationId;\n this.#installationIdBytes = result.installationIdBytes;\n this.#isReady = true;\n }\n\n static async create(\n signer: Signer,\n encryptionKey: Uint8Array,\n options?: ClientOptions,\n ) {\n const address = await signer.getAddress();\n const client = new Client(signer, address, encryptionKey, options);\n\n await client.init();\n\n if (!options?.disableAutoRegister) {\n await client.register();\n }\n\n return client;\n }\n\n get isReady() {\n return this.#isReady;\n }\n\n get inboxId() {\n return this.#inboxId;\n }\n\n get installationId() {\n return this.#installationId;\n }\n\n get installationIdBytes() {\n return this.#installationIdBytes;\n }\n\n async #createInboxSignatureText() {\n return this.sendMessage(\"createInboxSignatureText\", undefined);\n }\n\n async #addAccountSignatureText(newAccountAddress: string) {\n return this.sendMessage(\"addAccountSignatureText\", {\n newAccountAddress,\n });\n }\n\n async #removeAccountSignatureText(accountAddress: string) {\n return this.sendMessage(\"removeAccountSignatureText\", { accountAddress });\n }\n\n async #revokeAllOtherInstallationsSignatureText() {\n return this.sendMessage(\n \"revokeAllOtherInstallationsSignatureText\",\n undefined,\n );\n }\n\n async #revokeInstallationsSignatureText(installationIds: Uint8Array[]) {\n return this.sendMessage(\"revokeInstallationsSignatureText\", {\n installationIds,\n });\n }\n\n async #addSignature(\n signatureType: SignatureRequestType,\n signatureText: string,\n signer: Signer,\n ) {\n const signature = await signer.signMessage(signatureText);\n\n if (isSmartContractSigner(signer)) {\n await this.sendMessage(\"addScwSignature\", {\n type: signatureType,\n bytes: signature,\n chainId: signer.getChainId(),\n blockNumber: signer.getBlockNumber(),\n });\n } else {\n await this.sendMessage(\"addSignature\", {\n type: signatureType,\n bytes: signature,\n });\n }\n }\n\n async #applySignatures() {\n return this.sendMessage(\"applySignatures\", undefined);\n }\n\n async register() {\n const signatureText = await this.#createInboxSignatureText();\n\n // if the signature text is not available, the client is already registered\n if (!signatureText) {\n return;\n }\n\n await this.#addSignature(\n SignatureRequestType.CreateInbox,\n signatureText,\n this.#signer,\n );\n\n return this.sendMessage(\"registerIdentity\", undefined);\n }\n\n async addAccount(newAccountSigner: Signer) {\n const signatureText = await this.#addAccountSignatureText(\n await newAccountSigner.getAddress(),\n );\n\n if (!signatureText) {\n throw new Error(\"Unable to generate add account signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.AddWallet,\n signatureText,\n newAccountSigner,\n );\n\n await this.#applySignatures();\n }\n\n async removeAccount(accountAddress: string) {\n const signatureText =\n await this.#removeAccountSignatureText(accountAddress);\n\n if (!signatureText) {\n throw new Error(\"Unable to generate remove account signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeWallet,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async revokeAllOtherInstallations() {\n const signatureText =\n await this.#revokeAllOtherInstallationsSignatureText();\n\n if (!signatureText) {\n throw new Error(\n \"Unable to generate revoke all other installations signature text\",\n );\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeInstallations,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async revokeInstallations(installationIds: Uint8Array[]) {\n const signatureText =\n await this.#revokeInstallationsSignatureText(installationIds);\n\n if (!signatureText) {\n throw new Error(\"Unable to generate revoke installations signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeInstallations,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async isRegistered() {\n return this.sendMessage(\"isRegistered\", undefined);\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.sendMessage(\"canMessage\", { accountAddresses });\n }\n\n static async canMessage(accountAddresses: string[], env?: XmtpEnv) {\n const accountAddress = \"0x0000000000000000000000000000000000000000\";\n const signer: Signer = {\n getAddress: () => accountAddress,\n signMessage: () => new Uint8Array(),\n };\n const client = await Client.create(\n signer,\n window.crypto.getRandomValues(new Uint8Array(32)),\n {\n disableAutoRegister: true,\n env,\n },\n );\n return client.canMessage(accountAddresses);\n }\n\n async findInboxIdByAddress(address: string) {\n return this.sendMessage(\"findInboxIdByAddress\", { address });\n }\n\n async inboxState(refreshFromNetwork?: boolean) {\n return this.sendMessage(\"inboxState\", {\n refreshFromNetwork: refreshFromNetwork ?? false,\n });\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.sendMessage(\"getLatestInboxState\", { inboxId });\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.sendMessage(\"setConsentStates\", { records });\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.sendMessage(\"getConsentState\", { entityType, entity });\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n codecFor(contentType: ContentTypeId) {\n return this.#codecs.get(contentType.toString());\n }\n\n encodeContent(content: any, contentType: ContentTypeId) {\n const codec = this.codecFor(contentType);\n if (!codec) {\n throw new Error(\n `Codec not found for \"${contentType.toString()}\" content type`,\n );\n }\n const encoded = codec.encode(content, this);\n const fallback = codec.fallback(content);\n if (fallback) {\n encoded.fallback = fallback;\n }\n return toSafeEncodedContent(encoded);\n }\n\n decodeContent(message: SafeMessage, contentType: ContentTypeId) {\n const codec = this.codecFor(contentType);\n if (!codec) {\n throw new Error(\n `Codec not found for \"${contentType.toString()}\" content type`,\n );\n }\n\n // throw an error if there's an invalid group membership change message\n if (\n contentType.sameAs(ContentTypeGroupUpdated) &&\n message.kind !== GroupMessageKind.MembershipChange\n ) {\n throw new Error(\"Error decoding group membership change\");\n }\n\n const encodedContent = fromSafeEncodedContent(message.content);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return codec.decode(encodedContent, this);\n }\n\n signWithInstallationKey(signatureText: string) {\n return this.sendMessage(\"signWithInstallationKey\", { signatureText });\n }\n\n verifySignedWithInstallationKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n ) {\n return this.sendMessage(\"verifySignedWithInstallationKey\", {\n signatureText,\n signatureBytes,\n });\n }\n\n verifySignedWithPublicKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n publicKey: Uint8Array,\n ) {\n return this.sendMessage(\"verifySignedWithPublicKey\", {\n signatureText,\n signatureBytes,\n publicKey,\n });\n }\n}\n","import { v4 } from \"uuid\";\nimport type {\n UtilsEventsActions,\n UtilsEventsErrorData,\n UtilsEventsResult,\n UtilsEventsWorkerMessageData,\n UtilsSendMessageData,\n} from \"@/types\";\n\nconst handleError = (event: ErrorEvent) => {\n console.error(`Worker error on line ${event.lineno} in \"${event.filename}\"`);\n console.error(event.message);\n};\n\nexport class UtilsWorkerClass {\n #worker: Worker;\n\n #enableLogging: boolean;\n\n #promises = new Map<\n string,\n { resolve: (value: any) => void; reject: (reason?: any) => void }\n >();\n\n constructor(worker: Worker, enableLogging: boolean) {\n this.#worker = worker;\n this.#worker.addEventListener(\"message\", this.handleMessage);\n this.#worker.addEventListener(\"error\", handleError);\n this.#enableLogging = enableLogging;\n }\n\n sendMessage<A extends UtilsEventsActions>(\n action: A,\n data: UtilsSendMessageData<A>,\n ) {\n const promiseId = v4();\n this.#worker.postMessage({\n action,\n id: promiseId,\n data,\n });\n const promise = new Promise<UtilsEventsResult<A>>((resolve, reject) => {\n this.#promises.set(promiseId, { resolve, reject });\n });\n return promise;\n }\n\n handleMessage = (\n event: MessageEvent<UtilsEventsWorkerMessageData | UtilsEventsErrorData>,\n ) => {\n const eventData = event.data;\n if (this.#enableLogging) {\n console.log(\"utils received event data\", eventData);\n }\n const promise = this.#promises.get(eventData.id);\n if (promise) {\n this.#promises.delete(eventData.id);\n if (\"error\" in eventData) {\n promise.reject(new Error(eventData.error));\n } else {\n promise.resolve(eventData.result);\n }\n }\n };\n\n close() {\n this.#worker.removeEventListener(\"message\", this.handleMessage);\n this.#worker.removeEventListener(\"error\", handleError);\n this.#worker.terminate();\n }\n}\n","import type { XmtpEnv } from \"@/types/options\";\nimport { UtilsWorkerClass } from \"@/UtilsWorkerClass\";\n\nexport class Utils extends UtilsWorkerClass {\n #enableLogging: boolean;\n constructor(enableLogging?: boolean) {\n const worker = new Worker(new URL(\"./workers/utils\", import.meta.url), {\n type: \"module\",\n });\n super(worker, enableLogging ?? false);\n this.#enableLogging = enableLogging ?? false;\n }\n\n async generateInboxId(address: string) {\n return this.sendMessage(\"generateInboxId\", {\n address,\n enableLogging: this.#enableLogging,\n });\n }\n\n async getInboxIdForAddress(address: string, env?: XmtpEnv) {\n return this.sendMessage(\"getInboxIdForAddress\", {\n address,\n env,\n enableLogging: this.#enableLogging,\n });\n }\n}\n","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n"],"names":["handleError","event","console","error","lineno","filename","message","ClientWorkerClass","worker","enableLogging","promises","Map","constructor","this","addEventListener","handleMessage","sendMessage","action","data","promiseId","v4","postMessage","id","Promise","resolve","reject","set","eventData","log","promise","get","delete","Error","result","close","removeEventListener","terminate","toContentTypeId","contentTypeId","ContentTypeId","authorityId","typeId","versionMajor","versionMinor","fromContentTypeId","WasmContentTypeId","toSafeContentTypeId","fromSafeContentTypeId","toEncodedContent","content","type","parameters","Object","fromEntries","fallback","compression","fromEncodedContent","WasmEncodedContent","entries","toSafeEncodedContent","fromSafeEncodedContent","toSafeMessage","convoId","deliveryStatus","kind","senderInboxId","sentAtNs","toSafeListMessagesOptions","options","direction","limit","sentAfterNs","sentBeforeNs","fromSafeListMessagesOptions","ListMessagesOptions","toSafeListConversationsOptions","allowedStates","conversationType","createdAfterNs","createdBeforeNs","fromSafeListConversationsOptions","ListConversationsOptions","toSafePermissionPolicySet","policySet","addAdminPolicy","addMemberPolicy","removeAdminPolicy","removeMemberPolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateGroupNamePolicy","updateGroupPinnedFrameUrlPolicy","updateMessageExpirationPolicy","fromSafePermissionPolicySet","PermissionPolicySet","toSafeCreateGroupOptions","description","groupDescription","imageUrlSquare","groupImageUrlSquare","name","groupName","pinnedFrameUrl","groupPinnedFrameUrl","permissions","customPermissionPolicySet","fromSafeCreateGroupOptions","CreateGroupOptions","GroupPermissionsOptions","CustomPolicy","undefined","toSafeConversation","async","conversation","imageUrl","policyType","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","bytes","clientTimestampNs","toSafeInboxState","inboxState","accountAddresses","inboxId","installations","map","recoveryAddress","toSafeConsent","consent","entity","entityType","state","fromSafeConsent","Consent","toSafeGroupMember","member","consentState","installationIds","permissionLevel","fromSafeGroupMember","GroupMember","toSafeHmacKey","hmacKey","key","epoch","DecodedMessage","client","contentType","conversationId","encodedContent","GroupMessageKind","Application","MembershipChange","DeliveryStatus","Unpublished","Published","Failed","decodeContent","Conversation","syncData","updateName","updateImageUrl","updateDescription","updatePinnedFrameUrl","createdAt","ns","Date","Number","members","syncAdmins","syncSuperAdmins","updatePermission","permissionType","policy","metadataField","isAdmin","includes","isSuperAdmin","sync","addMembers","addMembersByInboxId","inboxIds","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","safeEncodedContent","encodeContent","ContentTypeText","send","messages","updateConsentState","dmPeerInboxId","Conversations","syncAll","getConversationById","getMessageById","getDmByInboxId","list","listGroups","listDms","newGroup","newDm","accountAddress","getHmacKeys","isSmartContractSigner","signer","Client","codecs","conversations","encryptionKey","installationId","installationIdBytes","isReady","super","Worker","URL","url","loggingLevel","GroupUpdatedCodec","TextCodec","codec","toString","init","address","create","getAddress","disableAutoRegister","register","createInboxSignatureText","addAccountSignatureText","newAccountAddress","removeAccountSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","signatureType","signatureText","signature","signMessage","chainId","getChainId","blockNumber","getBlockNumber","applySignatures","SignatureRequestType","CreateInbox","addAccount","newAccountSigner","AddWallet","removeAccount","RevokeWallet","revokeAllOtherInstallations","RevokeInstallations","revokeInstallations","isRegistered","canMessage","env","Uint8Array","window","crypto","getRandomValues","findInboxIdByAddress","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","codecFor","encoded","encode","sameAs","ContentTypeGroupUpdated","decode","signWithInstallationKey","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","UtilsWorkerClass","Utils","generateInboxId","getInboxIdForAddress","ApiUrls","local","dev","production"],"mappings":"mgCASA,MAAMA,EAAeC,IACnBC,QAAQC,MAAM,wBAAwBF,EAAMG,cAAcH,EAAMI,aAChEH,QAAQC,MAAMF,EAAMK,QAAQ,QAGjBC,EACXC,GAEAC,GAEAC,GAAY,IAAIC,IAKhB,WAAAC,CAAYJ,EAAgBC,GAC1BI,MAAKL,EAAUA,EACfK,MAAKL,EAAQM,iBAAiB,UAAWD,KAAKE,eAC9CF,MAAKL,EAAQM,iBAAiB,QAASd,GACvCa,MAAKJ,EAAiBA,EAGxB,WAAAO,CACEC,EACAC,GAEA,MAAMC,EAAYC,IAClBP,MAAKL,EAAQa,YAAY,CACvBJ,SACAK,GAAIH,EACJD,SAKF,OAHgB,IAAIK,SAA+B,CAACC,EAASC,KAC3DZ,MAAKH,EAAUgB,IAAIP,E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,cACEd,IAEA,MAAM0B,EAAY1B,EAAMiB,KACpBL,MAAKJ,GACPP,QAAQ0B,IAAI,4BAA6BD,GAE3C,MAAME,EAAUhB,MAAKH,EAAUoB,IAAIH,EAAUL,IACzCO,IACFhB,MAAKH,EAAUqB,OAAOJ,EAAUL,IAC5B,UAAWK,EACbE,EAAQJ,OAAO,IAAIO,MAAML,EAAUxB,QAEnC0B,EAAQL,QAAQG,EAAUM,UAKhC,KAAAC,GACErB,MAAKL,EAAQ2B,oBAAoB,UAAWtB,KAAKE,eACjDF,MAAKL,EAAQ2B,oBAAoB,QAASnC,GAC1Ca,MAAKL,EAAQ4B,aCjEX,MAAO8P,UAAcD,EACzBxR,GACA,WAAAG,CAAYH,GAIVuN,MAHe,IAAIC,OAAO,IAAIC,IAAI,8BAA+BC,KAAM,CACrEjL,KAAM,WAEMzC,IAAiB,GAC/BI,MAAKJ,EAAiBA,IAAiB,EAGzC,qBAAM0R,CAAgBzD,GACpB,OAAO7N,KAAKG,YAAY,kBAAmB,CACzC0N,UACAjO,cAAeI,MAAKJ,IAIxB,0BAAM2R,CAAqB1D,EAAiBiC,GAC1C,OAAO9P,KAAKG,YAAY,uBAAwB,CAC9C0N,UACAiC,MACAlQ,cAAeI,MAAKJ,KCxBb,MAAA4R,EAAU,CACrBC,MAAO,wBACPC,IAAK,2BACLC,WAAY"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/ClientWorkerClass.ts","../src/utils/conversions.ts","../src/DecodedMessage.ts","../src/Conversation.ts","../src/utils/date.ts","../src/Conversations.ts","../src/utils/signer.ts","../src/Client.ts","../src/UtilsWorkerClass.ts","../src/Utils.ts","../src/constants.ts"],"sourcesContent":["import { v4 } from \"uuid\";\nimport type {\n ClientEventsActions,\n ClientEventsErrorData,\n ClientEventsResult,\n ClientEventsWorkerMessageData,\n ClientSendMessageData,\n} from \"@/types\";\n\nconst handleError = (event: ErrorEvent) => {\n console.error(`Worker error on line ${event.lineno} in \"${event.filename}\"`);\n console.error(event.message);\n};\n\nexport class ClientWorkerClass {\n #worker: Worker;\n\n #enableLogging: boolean;\n\n #promises = new Map<\n string,\n { resolve: (value: any) => void; reject: (reason?: any) => void }\n >();\n\n constructor(worker: Worker, enableLogging: boolean) {\n this.#worker = worker;\n this.#worker.addEventListener(\"message\", this.handleMessage);\n this.#worker.addEventListener(\"error\", handleError);\n this.#enableLogging = enableLogging;\n }\n\n sendMessage<A extends ClientEventsActions>(\n action: A,\n data: ClientSendMessageData<A>,\n ) {\n const promiseId = v4();\n this.#worker.postMessage({\n action,\n id: promiseId,\n data,\n });\n const promise = new Promise<ClientEventsResult<A>>((resolve, reject) => {\n this.#promises.set(promiseId, { resolve, reject });\n });\n return promise;\n }\n\n handleMessage = (\n event: MessageEvent<ClientEventsWorkerMessageData | ClientEventsErrorData>,\n ) => {\n const eventData = event.data;\n if (this.#enableLogging) {\n console.log(\"client received event data\", eventData);\n }\n const promise = this.#promises.get(eventData.id);\n if (promise) {\n this.#promises.delete(eventData.id);\n if (\"error\" in eventData) {\n promise.reject(new Error(eventData.error));\n } else {\n promise.resolve(eventData.result);\n }\n }\n };\n\n close() {\n this.#worker.removeEventListener(\"message\", this.handleMessage);\n this.#worker.removeEventListener(\"error\", handleError);\n this.#worker.terminate();\n }\n}\n","import {\n ContentTypeId,\n type EncodedContent,\n} from \"@xmtp/content-type-primitives\";\nimport {\n Consent,\n CreateGroupOptions,\n GroupMember,\n GroupPermissionsOptions,\n ListConversationsOptions,\n ListMessagesOptions,\n PermissionPolicySet,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ConversationType,\n type DeliveryStatus,\n type GroupMembershipState,\n type GroupMessageKind,\n type HmacKey,\n type InboxState,\n type Installation,\n type Message,\n type PermissionLevel,\n type PermissionPolicy,\n type SortDirection,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: DeliveryStatus;\n id: string;\n kind: GroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: Message): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convoId,\n deliveryStatus: message.deliveryStatus,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.senderInboxId,\n sentAtNs: message.sentAtNs,\n});\n\nexport type SafeListMessagesOptions = {\n deliveryStatus?: DeliveryStatus;\n direction?: SortDirection;\n limit?: bigint;\n sentAfterNs?: bigint;\n sentBeforeNs?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: ListMessagesOptions,\n): SafeListMessagesOptions => ({\n deliveryStatus: options.deliveryStatus,\n direction: options.direction,\n limit: options.limit,\n sentAfterNs: options.sentAfterNs,\n sentBeforeNs: options.sentBeforeNs,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): ListMessagesOptions =>\n new ListMessagesOptions(\n options.sentBeforeNs,\n options.sentAfterNs,\n options.limit,\n options.deliveryStatus,\n options.direction,\n );\n\nexport type SafeListConversationsOptions = {\n allowedStates?: GroupMembershipState[];\n conversationType?: ConversationType;\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n allowedStates: options.allowedStates,\n conversationType: options.conversationType,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.allowedStates,\n options.conversationType,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: PermissionPolicy;\n};\n\nexport const toSafePermissionPolicySet = (\n policySet: PermissionPolicySet,\n): SafePermissionPolicySet => ({\n addAdminPolicy: policySet.addAdminPolicy,\n addMemberPolicy: policySet.addMemberPolicy,\n removeAdminPolicy: policySet.removeAdminPolicy,\n removeMemberPolicy: policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy: policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy: policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy: policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy: policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy: policySet.updateMessageExpirationPolicy,\n});\n\nexport const fromSafePermissionPolicySet = (\n policySet: SafePermissionPolicySet,\n): PermissionPolicySet =>\n new PermissionPolicySet(\n policySet.addMemberPolicy,\n policySet.removeMemberPolicy,\n policySet.addAdminPolicy,\n policySet.removeAdminPolicy,\n policySet.updateGroupNamePolicy,\n policySet.updateGroupDescriptionPolicy,\n policySet.updateGroupImageUrlSquarePolicy,\n policySet.updateGroupPinnedFrameUrlPolicy,\n policySet.updateMessageExpirationPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n name?: string;\n permissions?: GroupPermissionsOptions;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n name: options.groupName,\n pinnedFrameUrl: options.groupPinnedFrameUrl,\n permissions: options.permissions,\n customPermissionPolicySet: options.customPermissionPolicySet,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): CreateGroupOptions =>\n new CreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n // only include custom policy set if permissions are set to CustomPolicy\n options.customPermissionPolicySet &&\n options.permissions === GroupPermissionsOptions.CustomPolicy\n ? fromSafePermissionPolicySet(options.customPermissionPolicySet)\n : undefined,\n );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: GroupPermissionsOptions;\n policySet: {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: PermissionPolicy;\n };\n };\n isActive: boolean;\n addedByInboxId: string;\n metadata: {\n creatorInboxId: string;\n conversationType: string;\n };\n admins: string[];\n superAdmins: string[];\n createdAtNs: bigint;\n};\n\nexport const toSafeConversation = async (\n conversation: WorkerConversation,\n): Promise<SafeConversation> => ({\n id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,\n addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,\n removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,\n removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy:\n conversation.permissions.policySet.updateMessageExpirationPolicy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: await conversation.metadata(),\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\n});\n\nexport type SafeInstallation = {\n bytes: Uint8Array;\n clientTimestampNs?: bigint;\n id: string;\n};\n\nexport const toSafeInstallation = (\n installation: Installation,\n): SafeInstallation => ({\n bytes: installation.bytes,\n clientTimestampNs: installation.clientTimestampNs,\n id: installation.id,\n});\n\nexport type SafeInboxState = {\n accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountAddresses: inboxState.accountAddresses,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recoveryAddress,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: ConsentEntityType;\n state: ConsentState;\n};\n\nexport const toSafeConsent = (consent: Consent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entityType,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): Consent =>\n new Consent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountAddresses: member.accountAddresses,\n consentState: member.consentState,\n inboxId: member.inboxId,\n installationIds: member.installationIds,\n permissionLevel: member.permissionLevel,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>\n new GroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n\nexport type SafeHmacKey = {\n key: Uint8Array;\n epoch: bigint;\n};\n\nexport const toSafeHmacKey = (hmacKey: HmacKey): SafeHmacKey => ({\n key: hmacKey.key,\n epoch: hmacKey.epoch,\n});\n\nexport type HmacKeys = Map<string, HmacKey[]>;\nexport type SafeHmacKeys = Record<string, SafeHmacKey[]>;\n","import type { ContentTypeId } from \"@xmtp/content-type-primitives\";\nimport { DeliveryStatus, GroupMessageKind } from \"@xmtp/wasm-bindings\";\nimport type { Client } from \"@/Client\";\nimport { fromSafeContentTypeId, type SafeMessage } from \"@/utils/conversions\";\n\nexport type MessageKind = \"application\" | \"membership_change\";\nexport type MessageDeliveryStatus = \"unpublished\" | \"published\" | \"failed\";\n\nexport class DecodedMessage {\n #client: Client;\n\n content: any;\n\n contentType: ContentTypeId;\n\n conversationId: string;\n\n deliveryStatus: MessageDeliveryStatus;\n\n fallback?: string;\n\n compression?: number;\n\n id: string;\n\n kind: MessageKind;\n\n parameters: Map<string, string>;\n\n encodedContent: SafeMessage[\"content\"];\n\n senderInboxId: string;\n\n sentAtNs: bigint;\n\n constructor(client: Client, message: SafeMessage) {\n this.#client = client;\n this.id = message.id;\n this.sentAtNs = message.sentAtNs;\n this.conversationId = message.convoId;\n this.senderInboxId = message.senderInboxId;\n this.encodedContent = message.content;\n\n switch (message.kind) {\n case GroupMessageKind.Application:\n this.kind = \"application\";\n break;\n case GroupMessageKind.MembershipChange:\n this.kind = \"membership_change\";\n break;\n // no default\n }\n\n switch (message.deliveryStatus) {\n case DeliveryStatus.Unpublished:\n this.deliveryStatus = \"unpublished\";\n break;\n case DeliveryStatus.Published:\n this.deliveryStatus = \"published\";\n break;\n case DeliveryStatus.Failed:\n this.deliveryStatus = \"failed\";\n break;\n // no default\n }\n\n this.contentType = fromSafeContentTypeId(message.content.type);\n this.parameters = new Map(Object.entries(message.content.parameters));\n this.fallback = message.content.fallback;\n this.compression = message.content.compression;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this.content = this.#client.decodeContent(message, this.contentType);\n }\n}\n","import type { ContentTypeId } from \"@xmtp/content-type-primitives\";\nimport { ContentTypeText } from \"@xmtp/content-type-text\";\nimport type {\n ConsentState,\n MetadataField,\n PermissionPolicy,\n PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport type { Client } from \"@/Client\";\nimport { DecodedMessage } from \"@/DecodedMessage\";\nimport type {\n SafeConversation,\n SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport { nsToDate } from \"@/utils/date\";\n\nexport class Conversation {\n #client: Client;\n\n #id: string;\n\n #name?: SafeConversation[\"name\"];\n\n #imageUrl?: SafeConversation[\"imageUrl\"];\n\n #description?: SafeConversation[\"description\"];\n\n #pinnedFrameUrl?: SafeConversation[\"pinnedFrameUrl\"];\n\n #isActive?: SafeConversation[\"isActive\"];\n\n #addedByInboxId?: SafeConversation[\"addedByInboxId\"];\n\n #metadata?: SafeConversation[\"metadata\"];\n\n #createdAtNs?: SafeConversation[\"createdAtNs\"];\n\n #admins: SafeConversation[\"admins\"] = [];\n\n #superAdmins: SafeConversation[\"superAdmins\"] = [];\n\n constructor(client: Client, id: string, data?: SafeConversation) {\n this.#client = client;\n this.#id = id;\n this.#syncData(data);\n }\n\n #syncData(data?: SafeConversation) {\n this.#name = data?.name ?? \"\";\n this.#imageUrl = data?.imageUrl ?? \"\";\n this.#description = data?.description ?? \"\";\n this.#pinnedFrameUrl = data?.pinnedFrameUrl ?? \"\";\n this.#isActive = data?.isActive ?? undefined;\n this.#addedByInboxId = data?.addedByInboxId ?? \"\";\n this.#metadata = data?.metadata ?? undefined;\n this.#createdAtNs = data?.createdAtNs ?? undefined;\n this.#admins = data?.admins ?? [];\n this.#superAdmins = data?.superAdmins ?? [];\n }\n\n get id() {\n return this.#id;\n }\n\n get name() {\n return this.#name;\n }\n\n async updateName(name: string) {\n await this.#client.sendMessage(\"updateGroupName\", {\n id: this.#id,\n name,\n });\n this.#name = name;\n }\n\n get imageUrl() {\n return this.#imageUrl;\n }\n\n async updateImageUrl(imageUrl: string) {\n await this.#client.sendMessage(\"updateGroupImageUrlSquare\", {\n id: this.#id,\n imageUrl,\n });\n this.#imageUrl = imageUrl;\n }\n\n get description() {\n return this.#description;\n }\n\n async updateDescription(description: string) {\n await this.#client.sendMessage(\"updateGroupDescription\", {\n id: this.#id,\n description,\n });\n this.#description = description;\n }\n\n get pinnedFrameUrl() {\n return this.#pinnedFrameUrl;\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n await this.#client.sendMessage(\"updateGroupPinnedFrameUrl\", {\n id: this.#id,\n pinnedFrameUrl,\n });\n this.#pinnedFrameUrl = pinnedFrameUrl;\n }\n\n get isActive() {\n return this.#isActive;\n }\n\n get addedByInboxId() {\n return this.#addedByInboxId;\n }\n\n get createdAtNs() {\n return this.#createdAtNs;\n }\n\n get createdAt() {\n return this.#createdAtNs ? nsToDate(this.#createdAtNs) : undefined;\n }\n\n get metadata() {\n return this.#metadata;\n }\n\n async members() {\n return this.#client.sendMessage(\"getGroupMembers\", {\n id: this.#id,\n });\n }\n\n get admins() {\n return this.#admins;\n }\n\n get superAdmins() {\n return this.#superAdmins;\n }\n\n async syncAdmins() {\n const admins = await this.#client.sendMessage(\"getGroupAdmins\", {\n id: this.#id,\n });\n this.#admins = admins;\n }\n\n async syncSuperAdmins() {\n const superAdmins = await this.#client.sendMessage(\"getGroupSuperAdmins\", {\n id: this.#id,\n });\n this.#superAdmins = superAdmins;\n }\n\n async permissions() {\n return this.#client.sendMessage(\"getGroupPermissions\", {\n id: this.#id,\n });\n }\n\n async updatePermission(\n permissionType: PermissionUpdateType,\n policy: PermissionPolicy,\n metadataField?: MetadataField,\n ) {\n return this.#client.sendMessage(\"updateGroupPermissionPolicy\", {\n id: this.#id,\n permissionType,\n policy,\n metadataField,\n });\n }\n\n async isAdmin(inboxId: string) {\n await this.syncAdmins();\n return this.#admins.includes(inboxId);\n }\n\n async isSuperAdmin(inboxId: string) {\n await this.syncSuperAdmins();\n return this.#superAdmins.includes(inboxId);\n }\n\n async sync() {\n const data = await this.#client.sendMessage(\"syncGroup\", {\n id: this.#id,\n });\n this.#syncData(data);\n }\n\n async addMembers(accountAddresses: string[]) {\n return this.#client.sendMessage(\"addGroupMembers\", {\n id: this.#id,\n accountAddresses,\n });\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#client.sendMessage(\"addGroupMembersByInboxId\", {\n id: this.#id,\n inboxIds,\n });\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#client.sendMessage(\"removeGroupMembers\", {\n id: this.#id,\n accountAddresses,\n });\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#client.sendMessage(\"removeGroupMembersByInboxId\", {\n id: this.#id,\n inboxIds,\n });\n }\n\n async addAdmin(inboxId: string) {\n return this.#client.sendMessage(\"addGroupAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async removeAdmin(inboxId: string) {\n return this.#client.sendMessage(\"removeGroupAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#client.sendMessage(\"addGroupSuperAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#client.sendMessage(\"removeGroupSuperAdmin\", {\n id: this.#id,\n inboxId,\n });\n }\n\n async publishMessages() {\n return this.#client.sendMessage(\"publishGroupMessages\", {\n id: this.#id,\n });\n }\n\n async sendOptimistic(content: any, contentType?: ContentTypeId) {\n if (typeof content !== \"string\" && !contentType) {\n throw new Error(\n \"Content type is required when sending content other than text\",\n );\n }\n\n const safeEncodedContent =\n typeof content === \"string\"\n ? this.#client.encodeContent(content, contentType ?? ContentTypeText)\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.#client.encodeContent(content, contentType!);\n\n return this.#client.sendMessage(\"sendOptimisticGroupMessage\", {\n id: this.#id,\n content: safeEncodedContent,\n });\n }\n\n async send(content: any, contentType?: ContentTypeId) {\n if (typeof content !== \"string\" && !contentType) {\n throw new Error(\n \"Content type is required when sending content other than text\",\n );\n }\n\n const safeEncodedContent =\n typeof content === \"string\"\n ? this.#client.encodeContent(content, contentType ?? ContentTypeText)\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.#client.encodeContent(content, contentType!);\n\n return this.#client.sendMessage(\"sendGroupMessage\", {\n id: this.#id,\n content: safeEncodedContent,\n });\n }\n\n async messages(options?: SafeListMessagesOptions) {\n const messages = await this.#client.sendMessage(\"getGroupMessages\", {\n id: this.#id,\n options,\n });\n\n return messages.map((message) => new DecodedMessage(this.#client, message));\n }\n\n async consentState() {\n return this.#client.sendMessage(\"getGroupConsentState\", {\n id: this.#id,\n });\n }\n\n async updateConsentState(state: ConsentState) {\n return this.#client.sendMessage(\"updateGroupConsentState\", {\n id: this.#id,\n state,\n });\n }\n\n async dmPeerInboxId() {\n return this.#client.sendMessage(\"getDmPeerInboxId\", {\n id: this.#id,\n });\n }\n}\n","export function nsToDate(ns: bigint): Date {\n return new Date(Number(ns / 1_000_000n));\n}\n","import type { Client } from \"@/Client\";\nimport { Conversation } from \"@/Conversation\";\nimport { DecodedMessage } from \"@/DecodedMessage\";\nimport type {\n SafeCreateGroupOptions,\n SafeListConversationsOptions,\n} from \"@/utils/conversions\";\n\nexport class Conversations {\n #client: Client;\n\n constructor(client: Client) {\n this.#client = client;\n }\n\n async sync() {\n return this.#client.sendMessage(\"syncConversations\", undefined);\n }\n\n async syncAll() {\n return this.#client.sendMessage(\"syncAllConversations\", undefined);\n }\n\n async getConversationById(id: string) {\n const data = await this.#client.sendMessage(\"getConversationById\", {\n id,\n });\n return data ? new Conversation(this.#client, id, data) : undefined;\n }\n\n async getMessageById(id: string) {\n const data = await this.#client.sendMessage(\"getMessageById\", {\n id,\n });\n return data ? new DecodedMessage(this.#client, data) : undefined;\n }\n\n async getDmByInboxId(inboxId: string) {\n const data = await this.#client.sendMessage(\"getDmByInboxId\", {\n inboxId,\n });\n return data ? new Conversation(this.#client, data.id, data) : undefined;\n }\n\n async list(options?: SafeListConversationsOptions) {\n const conversations = await this.#client.sendMessage(\"getConversations\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const conversations = await this.#client.sendMessage(\"getGroups\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async listDms(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const conversations = await this.#client.sendMessage(\"getDms\", {\n options,\n });\n\n return conversations.map(\n (conversation) =>\n new Conversation(this.#client, conversation.id, conversation),\n );\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const conversation = await this.#client.sendMessage(\"newGroup\", {\n accountAddresses,\n options,\n });\n\n return new Conversation(this.#client, conversation.id, conversation);\n }\n\n async newDm(accountAddress: string) {\n const conversation = await this.#client.sendMessage(\"newDm\", {\n accountAddress,\n });\n\n return new Conversation(this.#client, conversation.id, conversation);\n }\n\n async getHmacKeys() {\n return this.#client.sendMessage(\"getHmacKeys\", undefined);\n }\n}\n","export type SignMessage = (message: string) => Promise<Uint8Array> | Uint8Array;\nexport type GetAddress = () => Promise<string> | string;\nexport type GetChainId = () => bigint;\nexport type GetBlockNumber = () => bigint;\n\nexport type Signer = {\n getAddress: GetAddress;\n signMessage: SignMessage;\n // these fields indicate that the signer is a smart contract wallet\n getBlockNumber?: GetBlockNumber;\n getChainId?: GetChainId;\n};\n\nexport type SmartContractSigner = Required<Signer>;\n\nexport const isSmartContractSigner = (\n signer: Signer,\n): signer is SmartContractSigner =>\n \"getBlockNumber\" in signer && \"getChainId\" in signer;\n","import {\n ContentTypeGroupUpdated,\n GroupUpdatedCodec,\n} from \"@xmtp/content-type-group-updated\";\nimport type {\n ContentCodec,\n ContentTypeId,\n} from \"@xmtp/content-type-primitives\";\nimport { TextCodec } from \"@xmtp/content-type-text\";\nimport {\n GroupMessageKind,\n SignatureRequestType,\n type ConsentEntityType,\n} from \"@xmtp/wasm-bindings\";\nimport { ClientWorkerClass } from \"@/ClientWorkerClass\";\nimport { Conversations } from \"@/Conversations\";\nimport type { ClientOptions, XmtpEnv } from \"@/types\";\nimport {\n fromSafeEncodedContent,\n toSafeEncodedContent,\n type SafeConsent,\n type SafeMessage,\n} from \"@/utils/conversions\";\nimport { isSmartContractSigner, type Signer } from \"@/utils/signer\";\n\nexport class Client extends ClientWorkerClass {\n #accountAddress: string;\n #codecs: Map<string, ContentCodec>;\n #conversations: Conversations;\n #encryptionKey: Uint8Array;\n #inboxId: string | undefined;\n #installationId: string | undefined;\n #installationIdBytes: Uint8Array | undefined;\n #isReady = false;\n #signer: Signer;\n options?: ClientOptions;\n\n constructor(\n signer: Signer,\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: ClientOptions,\n ) {\n const worker = new Worker(new URL(\"./workers/client\", import.meta.url), {\n type: \"module\",\n });\n super(\n worker,\n options?.loggingLevel !== undefined && options.loggingLevel !== \"off\",\n );\n this.#accountAddress = accountAddress;\n this.options = options;\n this.#encryptionKey = encryptionKey;\n this.#signer = signer;\n this.#conversations = new Conversations(this);\n const codecs = [\n new GroupUpdatedCodec(),\n new TextCodec(),\n ...(options?.codecs ?? []),\n ];\n this.#codecs = new Map(\n codecs.map((codec) => [codec.contentType.toString(), codec]),\n );\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n async init() {\n const result = await this.sendMessage(\"init\", {\n address: this.accountAddress,\n encryptionKey: this.#encryptionKey,\n options: this.options,\n });\n this.#inboxId = result.inboxId;\n this.#installationId = result.installationId;\n this.#installationIdBytes = result.installationIdBytes;\n this.#isReady = true;\n }\n\n static async create(\n signer: Signer,\n encryptionKey: Uint8Array,\n options?: ClientOptions,\n ) {\n const address = await signer.getAddress();\n const client = new Client(signer, address, encryptionKey, options);\n\n await client.init();\n\n if (!options?.disableAutoRegister) {\n await client.register();\n }\n\n return client;\n }\n\n get isReady() {\n return this.#isReady;\n }\n\n get inboxId() {\n return this.#inboxId;\n }\n\n get installationId() {\n return this.#installationId;\n }\n\n get installationIdBytes() {\n return this.#installationIdBytes;\n }\n\n async #createInboxSignatureText() {\n return this.sendMessage(\"createInboxSignatureText\", undefined);\n }\n\n async #addAccountSignatureText(newAccountAddress: string) {\n return this.sendMessage(\"addAccountSignatureText\", {\n newAccountAddress,\n });\n }\n\n async #removeAccountSignatureText(accountAddress: string) {\n return this.sendMessage(\"removeAccountSignatureText\", { accountAddress });\n }\n\n async #revokeAllOtherInstallationsSignatureText() {\n return this.sendMessage(\n \"revokeAllOtherInstallationsSignatureText\",\n undefined,\n );\n }\n\n async #revokeInstallationsSignatureText(installationIds: Uint8Array[]) {\n return this.sendMessage(\"revokeInstallationsSignatureText\", {\n installationIds,\n });\n }\n\n async #addSignature(\n signatureType: SignatureRequestType,\n signatureText: string,\n signer: Signer,\n ) {\n const signature = await signer.signMessage(signatureText);\n\n if (isSmartContractSigner(signer)) {\n await this.sendMessage(\"addScwSignature\", {\n type: signatureType,\n bytes: signature,\n chainId: signer.getChainId(),\n blockNumber: signer.getBlockNumber(),\n });\n } else {\n await this.sendMessage(\"addSignature\", {\n type: signatureType,\n bytes: signature,\n });\n }\n }\n\n async #applySignatures() {\n return this.sendMessage(\"applySignatures\", undefined);\n }\n\n async register() {\n const signatureText = await this.#createInboxSignatureText();\n\n // if the signature text is not available, the client is already registered\n if (!signatureText) {\n return;\n }\n\n await this.#addSignature(\n SignatureRequestType.CreateInbox,\n signatureText,\n this.#signer,\n );\n\n return this.sendMessage(\"registerIdentity\", undefined);\n }\n\n async addAccount(newAccountSigner: Signer) {\n const signatureText = await this.#addAccountSignatureText(\n await newAccountSigner.getAddress(),\n );\n\n if (!signatureText) {\n throw new Error(\"Unable to generate add account signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.AddWallet,\n signatureText,\n newAccountSigner,\n );\n\n await this.#applySignatures();\n }\n\n async removeAccount(accountAddress: string) {\n const signatureText =\n await this.#removeAccountSignatureText(accountAddress);\n\n if (!signatureText) {\n throw new Error(\"Unable to generate remove account signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeWallet,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async revokeAllOtherInstallations() {\n const signatureText =\n await this.#revokeAllOtherInstallationsSignatureText();\n\n if (!signatureText) {\n throw new Error(\n \"Unable to generate revoke all other installations signature text\",\n );\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeInstallations,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async revokeInstallations(installationIds: Uint8Array[]) {\n const signatureText =\n await this.#revokeInstallationsSignatureText(installationIds);\n\n if (!signatureText) {\n throw new Error(\"Unable to generate revoke installations signature text\");\n }\n\n await this.#addSignature(\n SignatureRequestType.RevokeInstallations,\n signatureText,\n this.#signer,\n );\n\n await this.#applySignatures();\n }\n\n async isRegistered() {\n return this.sendMessage(\"isRegistered\", undefined);\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.sendMessage(\"canMessage\", { accountAddresses });\n }\n\n static async canMessage(accountAddresses: string[], env?: XmtpEnv) {\n const accountAddress = \"0x0000000000000000000000000000000000000000\";\n const signer: Signer = {\n getAddress: () => accountAddress,\n signMessage: () => new Uint8Array(),\n };\n const client = await Client.create(\n signer,\n window.crypto.getRandomValues(new Uint8Array(32)),\n {\n disableAutoRegister: true,\n env,\n },\n );\n return client.canMessage(accountAddresses);\n }\n\n async findInboxIdByAddress(address: string) {\n return this.sendMessage(\"findInboxIdByAddress\", { address });\n }\n\n async inboxState(refreshFromNetwork?: boolean) {\n return this.sendMessage(\"inboxState\", {\n refreshFromNetwork: refreshFromNetwork ?? false,\n });\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.sendMessage(\"getLatestInboxState\", { inboxId });\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.sendMessage(\"setConsentStates\", { records });\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.sendMessage(\"getConsentState\", { entityType, entity });\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n codecFor(contentType: ContentTypeId) {\n return this.#codecs.get(contentType.toString());\n }\n\n encodeContent(content: any, contentType: ContentTypeId) {\n const codec = this.codecFor(contentType);\n if (!codec) {\n throw new Error(\n `Codec not found for \"${contentType.toString()}\" content type`,\n );\n }\n const encoded = codec.encode(content, this);\n const fallback = codec.fallback(content);\n if (fallback) {\n encoded.fallback = fallback;\n }\n return toSafeEncodedContent(encoded);\n }\n\n decodeContent(message: SafeMessage, contentType: ContentTypeId) {\n const codec = this.codecFor(contentType);\n if (!codec) {\n throw new Error(\n `Codec not found for \"${contentType.toString()}\" content type`,\n );\n }\n\n // throw an error if there's an invalid group membership change message\n if (\n contentType.sameAs(ContentTypeGroupUpdated) &&\n message.kind !== GroupMessageKind.MembershipChange\n ) {\n throw new Error(\"Error decoding group membership change\");\n }\n\n const encodedContent = fromSafeEncodedContent(message.content);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return codec.decode(encodedContent, this);\n }\n\n signWithInstallationKey(signatureText: string) {\n return this.sendMessage(\"signWithInstallationKey\", { signatureText });\n }\n\n verifySignedWithInstallationKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n ) {\n return this.sendMessage(\"verifySignedWithInstallationKey\", {\n signatureText,\n signatureBytes,\n });\n }\n\n verifySignedWithPublicKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n publicKey: Uint8Array,\n ) {\n return this.sendMessage(\"verifySignedWithPublicKey\", {\n signatureText,\n signatureBytes,\n publicKey,\n });\n }\n}\n","import { v4 } from \"uuid\";\nimport type {\n UtilsEventsActions,\n UtilsEventsErrorData,\n UtilsEventsResult,\n UtilsEventsWorkerMessageData,\n UtilsSendMessageData,\n} from \"@/types\";\n\nconst handleError = (event: ErrorEvent) => {\n console.error(`Worker error on line ${event.lineno} in \"${event.filename}\"`);\n console.error(event.message);\n};\n\nexport class UtilsWorkerClass {\n #worker: Worker;\n\n #enableLogging: boolean;\n\n #promises = new Map<\n string,\n { resolve: (value: any) => void; reject: (reason?: any) => void }\n >();\n\n constructor(worker: Worker, enableLogging: boolean) {\n this.#worker = worker;\n this.#worker.addEventListener(\"message\", this.handleMessage);\n this.#worker.addEventListener(\"error\", handleError);\n this.#enableLogging = enableLogging;\n }\n\n sendMessage<A extends UtilsEventsActions>(\n action: A,\n data: UtilsSendMessageData<A>,\n ) {\n const promiseId = v4();\n this.#worker.postMessage({\n action,\n id: promiseId,\n data,\n });\n const promise = new Promise<UtilsEventsResult<A>>((resolve, reject) => {\n this.#promises.set(promiseId, { resolve, reject });\n });\n return promise;\n }\n\n handleMessage = (\n event: MessageEvent<UtilsEventsWorkerMessageData | UtilsEventsErrorData>,\n ) => {\n const eventData = event.data;\n if (this.#enableLogging) {\n console.log(\"utils received event data\", eventData);\n }\n const promise = this.#promises.get(eventData.id);\n if (promise) {\n this.#promises.delete(eventData.id);\n if (\"error\" in eventData) {\n promise.reject(new Error(eventData.error));\n } else {\n promise.resolve(eventData.result);\n }\n }\n };\n\n close() {\n this.#worker.removeEventListener(\"message\", this.handleMessage);\n this.#worker.removeEventListener(\"error\", handleError);\n this.#worker.terminate();\n }\n}\n","import type { XmtpEnv } from \"@/types/options\";\nimport { UtilsWorkerClass } from \"@/UtilsWorkerClass\";\n\nexport class Utils extends UtilsWorkerClass {\n #enableLogging: boolean;\n constructor(enableLogging?: boolean) {\n const worker = new Worker(new URL(\"./workers/utils\", import.meta.url), {\n type: \"module\",\n });\n super(worker, enableLogging ?? false);\n this.#enableLogging = enableLogging ?? false;\n }\n\n async generateInboxId(address: string) {\n return this.sendMessage(\"generateInboxId\", {\n address,\n enableLogging: this.#enableLogging,\n });\n }\n\n async getInboxIdForAddress(address: string, env?: XmtpEnv) {\n return this.sendMessage(\"getInboxIdForAddress\", {\n address,\n env,\n enableLogging: this.#enableLogging,\n });\n }\n}\n","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n\nexport const HistorySyncUrls = {\n local: \"http://localhost:5558\",\n dev: \"https://message-history.dev.ephemera.network\",\n production: \"https://message-history.production.ephemera.network\",\n} as const;\n"],"names":["handleError","event","console","error","lineno","filename","message","ClientWorkerClass","worker","enableLogging","promises","Map","constructor","this","addEventListener","handleMessage","sendMessage","action","data","promiseId","v4","postMessage","id","Promise","resolve","reject","set","eventData","log","promise","get","delete","Error","result","close","removeEventListener","terminate","toContentTypeId","contentTypeId","ContentTypeId","authorityId","typeId","versionMajor","versionMinor","fromContentTypeId","WasmContentTypeId","toSafeContentTypeId","fromSafeContentTypeId","toEncodedContent","content","type","parameters","Object","fromEntries","fallback","compression","fromEncodedContent","WasmEncodedContent","entries","toSafeEncodedContent","fromSafeEncodedContent","toSafeMessage","convoId","deliveryStatus","kind","senderInboxId","sentAtNs","toSafeListMessagesOptions","options","direction","limit","sentAfterNs","sentBeforeNs","fromSafeListMessagesOptions","ListMessagesOptions","toSafeListConversationsOptions","allowedStates","conversationType","createdAfterNs","createdBeforeNs","fromSafeListConversationsOptions","ListConversationsOptions","toSafePermissionPolicySet","policySet","addAdminPolicy","addMemberPolicy","removeAdminPolicy","removeMemberPolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateGroupNamePolicy","updateGroupPinnedFrameUrlPolicy","updateMessageExpirationPolicy","fromSafePermissionPolicySet","PermissionPolicySet","toSafeCreateGroupOptions","description","groupDescription","imageUrlSquare","groupImageUrlSquare","name","groupName","pinnedFrameUrl","groupPinnedFrameUrl","permissions","customPermissionPolicySet","fromSafeCreateGroupOptions","CreateGroupOptions","GroupPermissionsOptions","CustomPolicy","undefined","toSafeConversation","async","conversation","imageUrl","policyType","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","bytes","clientTimestampNs","toSafeInboxState","inboxState","accountAddresses","inboxId","installations","map","recoveryAddress","toSafeConsent","consent","entity","entityType","state","fromSafeConsent","Consent","toSafeGroupMember","member","consentState","installationIds","permissionLevel","fromSafeGroupMember","GroupMember","toSafeHmacKey","hmacKey","key","epoch","DecodedMessage","client","contentType","conversationId","encodedContent","GroupMessageKind","Application","MembershipChange","DeliveryStatus","Unpublished","Published","Failed","decodeContent","Conversation","syncData","updateName","updateImageUrl","updateDescription","updatePinnedFrameUrl","createdAt","ns","Date","Number","members","syncAdmins","syncSuperAdmins","updatePermission","permissionType","policy","metadataField","isAdmin","includes","isSuperAdmin","sync","addMembers","addMembersByInboxId","inboxIds","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","safeEncodedContent","encodeContent","ContentTypeText","send","messages","updateConsentState","dmPeerInboxId","Conversations","syncAll","getConversationById","getMessageById","getDmByInboxId","list","listGroups","listDms","newGroup","newDm","accountAddress","getHmacKeys","isSmartContractSigner","signer","Client","codecs","conversations","encryptionKey","installationId","installationIdBytes","isReady","super","Worker","URL","url","loggingLevel","GroupUpdatedCodec","TextCodec","codec","toString","init","address","create","getAddress","disableAutoRegister","register","createInboxSignatureText","addAccountSignatureText","newAccountAddress","removeAccountSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","signatureType","signatureText","signature","signMessage","chainId","getChainId","blockNumber","getBlockNumber","applySignatures","SignatureRequestType","CreateInbox","addAccount","newAccountSigner","AddWallet","removeAccount","RevokeWallet","revokeAllOtherInstallations","RevokeInstallations","revokeInstallations","isRegistered","canMessage","env","Uint8Array","window","crypto","getRandomValues","findInboxIdByAddress","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","codecFor","encoded","encode","sameAs","ContentTypeGroupUpdated","decode","signWithInstallationKey","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","UtilsWorkerClass","Utils","generateInboxId","getInboxIdForAddress","ApiUrls","local","dev","production","HistorySyncUrls"],"mappings":"mgCASA,MAAMA,EAAeC,IACnBC,QAAQC,MAAM,wBAAwBF,EAAMG,cAAcH,EAAMI,aAChEH,QAAQC,MAAMF,EAAMK,QAAQ,QAGjBC,EACXC,GAEAC,GAEAC,GAAY,IAAIC,IAKhB,WAAAC,CAAYJ,EAAgBC,GAC1BI,MAAKL,EAAUA,EACfK,MAAKL,EAAQM,iBAAiB,UAAWD,KAAKE,eAC9CF,MAAKL,EAAQM,iBAAiB,QAASd,GACvCa,MAAKJ,EAAiBA,EAGxB,WAAAO,CACEC,EACAC,GAEA,MAAMC,EAAYC,IAClBP,MAAKL,EAAQa,YAAY,CACvBJ,SACAK,GAAIH,EACJD,SAKF,OAHgB,IAAIK,SAA+B,CAACC,EAASC,KAC3DZ,MAAKH,EAAUgB,IAAIP,EAAW,CAAEK,UAASC,UAAS,IAKtDV,cACEd,IAEA,MAAM0B,EAAY1B,EAAMiB,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,aCtCJ,MAAAC,EACXC,GAEA,IAAIC,EAAc,CAChBC,YAAaF,EAAcE,YAC3BC,OAAQH,EAAcG,OACtBC,aAAcJ,EAAcI,aAC5BC,aAAcL,EAAcK,eAGnBC,EACXN,GAEA,IAAIO,EACFP,E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ACpB,OAAO7N,KAAKG,YAAY,kBAAmB,CACzC0N,UACAjO,cAAeI,MAAKJ,IAIxB,0BAAM2R,CAAqB1D,EAAiBiC,GAC1C,OAAO9P,KAAKG,YAAY,uBAAwB,CAC9C0N,UACAiC,MACAlQ,cAAeI,MAAKJ,KCxBb,MAAA4R,EAAU,CACrBC,MAAO,wBACPC,IAAK,2BACLC,WAAY,mCAGDC,GAAkB,CAC7BH,MAAO,wBACPC,IAAK,+CACLC,WAAY"}
|
package/dist/workers/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ContentTypeId as e}from"@xmtp/content-type-primitives";import t,{EncodedContent as n,ContentTypeId as i,Consent as r,ListConversationsOptions as s,CreateGroupOptions as o,GroupPermissionsOptions as a,ListMessagesOptions as c,PermissionPolicySet as d,getInboxIdForAddress as u,generateInboxId as p,createClient as l,LogOptions as y,verifySignedWithPublicKey as m}from"@xmtp/wasm-bindings";const g=e=>{return new n((t=e.type,new i(t.authorityId,t.typeId,t.versionMajor,t.versionMinor)),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content);var t},v=e=>{return{type:(t=e.type,{authorityId:t.authorityId,typeId:t.typeId,versionMajor:t.versionMajor,versionMinor:t.versionMinor}),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content};var t},I=t=>{return{type:(n=t.type,new e({authorityId:n.authorityId,typeId:n.typeId,versionMajor:n.versionMajor,versionMinor:n.versionMinor})),parameters:t.parameters,fallback:t.fallback,compression:t.compression,content:t.content};var n},b=t=>{return{content:v((n=t.content,{type:(i=n.type,new e({authorityId:i.authorityId,typeId:i.typeId,versionMajor:i.versionMajor,versionMinor:i.versionMinor})),parameters:Object.fromEntries(n.parameters),fallback:n.fallback,compression:n.compression,content:n.content})),convoId:t.convoId,deliveryStatus:t.deliveryStatus,id:t.id,kind:t.kind,senderInboxId:t.senderInboxId,sentAtNs:t.sentAtNs};var n,i},h=e=>new s(e.allowedStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.limit),S=e=>{return new o(e.permissions,e.name,e.imageUrlSquare,e.description,e.pinnedFrameUrl,e.customPermissionPolicySet&&e.permissions===a.CustomPolicy?(t=e.customPermissionPolicySet,new d(t.addMemberPolicy,t.removeMemberPolicy,t.addAdminPolicy,t.removeAdminPolicy,t.updateGroupNamePolicy,t.updateGroupDescriptionPolicy,t.updateGroupImageUrlSquarePolicy,t.updateGroupPinnedFrameUrlPolicy,t.updateMessageExpirationPolicy)):void 0);var t},w=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,pinnedFrameUrl:e.pinnedFrameUrl,permissions:{policyType:e.permissions.policyType,policySet:{addAdminPolicy:e.permissions.policySet.addAdminPolicy,addMemberPolicy:e.permissions.policySet.addMemberPolicy,removeAdminPolicy:e.permissions.policySet.removeAdminPolicy,removeMemberPolicy:e.permissions.policySet.removeMemberPolicy,updateGroupDescriptionPolicy:e.permissions.policySet.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.permissions.policySet.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.permissions.policySet.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.permissions.policySet.updateGroupPinnedFrameUrlPolicy,updateMessageExpirationPolicy:e.permissions.policySet.updateMessageExpirationPolicy}},isActive:e.isActive,addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.admins,superAdmins:e.superAdmins,createdAtNs:e.createdAtNs}),x=e=>({bytes:e.bytes,clientTimestampNs:e.clientTimestampNs,id:e.id}),A=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(x),recoveryAddress:e.recoveryAddress}),k=e=>new r(e.entityType,e.state,e.entity),G=e=>({key:e.key,epoch:e.epoch}),f={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"};class B{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get id(){return this.#t.id()}get name(){return this.#t.groupName()}async updateName(e){return this.#t.updateGroupName(e)}get imageUrl(){return this.#t.groupImageUrlSquare()}async updateImageUrl(e){return this.#t.updateGroupImageUrlSquare(e)}get description(){return this.#t.groupDescription()}async updateDescription(e){return this.#t.updateGroupDescription(e)}get pinnedFrameUrl(){return this.#t.groupPinnedFrameUrl()}async updatePinnedFrameUrl(e){return this.#t.updateGroupPinnedFrameUrl(e)}get isActive(){return this.#t.isActive()}get addedByInboxId(){return this.#t.addedByInboxId()}get createdAtNs(){return this.#t.createdAtNs()}async metadata(){const e=await this.#t.groupMetadata();return{creatorInboxId:e.creatorInboxId(),conversationType:e.conversationType()}}async members(){return(await this.#t.listMembers()).map((e=>(e=>({accountAddresses:e.accountAddresses,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}))(e)))}get admins(){return this.#t.adminList()}get superAdmins(){return this.#t.superAdminList()}get permissions(){const e=this.#t.groupPermissions();return{policyType:e.policyType(),policySet:e.policySet()}}async updatePermission(e,t,n){return this.#t.updatePermissionPolicy(e,t,n)}isAdmin(e){return this.#t.isAdmin(e)}isSuperAdmin(e){return this.#t.isSuperAdmin(e)}async sync(){return this.#t.sync()}async addMembers(e){return this.#t.addMembers(e)}async addMembersByInboxId(e){return this.#t.addMembersByInboxId(e)}async removeMembers(e){return this.#t.removeMembers(e)}async removeMembersByInboxId(e){return this.#t.removeMembersByInboxId(e)}async addAdmin(e){return this.#t.addAdmin(e)}async removeAdmin(e){return this.#t.removeAdmin(e)}async addSuperAdmin(e){return this.#t.addSuperAdmin(e)}async removeSuperAdmin(e){return this.#t.removeSuperAdmin(e)}async publishMessages(){return this.#t.publishMessages()}sendOptimistic(e){return this.#t.sendOptimistic(e)}async send(e){return this.#t.send(e)}async messages(e){return this.#t.findMessages(e?(e=>new c(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction))(e):void 0)}get consentState(){return this.#t.consentState()}updateConsentState(e){this.#t.updateConsentState(e)}dmPeerInboxId(){return this.#t.dmPeerInboxId()}}class M{#e;#n;constructor(e,t){this.#e=e,this.#n=t}async sync(){return this.#n.sync()}async syncAll(){return this.#n.syncAllConversations()}getConversationById(e){try{const t=this.#n.findGroupById(e);return new B(this.#e,t)}catch{return}}getMessageById(e){try{return this.#n.findMessageById(e)}catch{return}}getDmByInboxId(e){try{const t=this.#n.findDmByTargetInboxId(e);return new B(this.#e,t)}catch{return}}list(e){return this.#n.list(e?h(e):void 0).map((e=>new B(this.#e,e)))}listGroups(e){return this.#n.listGroups(e?h(e):void 0).map((e=>new B(this.#e,e)))}listDms(e){return this.#n.listDms(e?h(e):void 0).map((e=>new B(this.#e,e)))}async newGroup(e,t){const n=await this.#n.createGroup(e,t?S(t):void 0);return new B(this.#e,n)}async newDm(e){const t=await this.#n.createDm(e);return new B(this.#e,t)}getHmacKeys(){return this.#n.getHmacKeys()}}class P{#e;#n;#i;constructor(e){this.#e=e,this.#i=e.accountAddress,this.#n=new M(this,e.conversations())}static async create(e,n,i){const r=await(async(e,n,i)=>{await t();const r=i?.apiUrl??f[i?.env??"dev"],s=i?.dbPath??`xmtp-${i?.env??"dev"}-${e}.db3`,o=await u(r,e)||p(e),a=i&&(void 0!==i.loggingLevel||i.structuredLogging||i.performanceLogging);return l(r,o,e,s,n,void 0,a?new y(i.structuredLogging??!1,i.performanceLogging??!1,i.loggingLevel):void 0)})(e,n,i);return new P(r)}get accountAddress(){return this.#i}get inboxId(){return this.#e.inboxId}get installationId(){return this.#e.installationId}get installationIdBytes(){return this.#e.installationIdBytes}get isRegistered(){return this.#e.isRegistered}async createInboxSignatureText(){try{return await this.#e.createInboxSignatureText()}catch{return}}async addAccountSignatureText(e){try{return await this.#e.addWalletSignatureText(e)}catch{return}}async removeAccountSignatureText(e){try{return await this.#e.revokeWalletSignatureText(e)}catch{return}}async revokeAllAOtherInstallationsSignatureText(){try{return await this.#e.revokeAllOtherInstallationsSignatureText()}catch{return}}async revokeInstallationsSignatureText(e){try{return await this.#e.revokeInstallationsSignatureText(e)}catch{return}}async addSignature(e,t){return this.#e.addSignature(e,t)}async addScwSignature(e,t,n,i){return this.#e.addScwSignature(e,t,n,i)}async applySignatures(){return this.#e.applySignatureRequests()}async canMessage(e){return this.#e.canMessage(e)}async registerIdentity(){return this.#e.registerIdentity()}async findInboxIdByAddress(e){return this.#e.findInboxIdByAddress(e)}async inboxState(e){return this.#e.inboxState(e)}async getLatestInboxState(e){return this.#e.getLatestInboxState(e)}async setConsentStates(e){return this.#e.setConsentStates(e.map(k))}async getConsentState(e,t){return this.#e.getConsentState(e,t)}get conversations(){return this.#n}signWithInstallationKey(e){return this.#e.signWithInstallationKey(e)}verifySignedWithInstallationKey(e,t){try{return this.#e.verifySignedWithInstallationKey(e,t),!0}catch{return!1}}verifySignedWithPublicKey(e,t,n){try{return m(e,t,n),!0}catch{return!1}}}let C,T=!1;const U=e=>{self.postMessage(e)},N=e=>{self.postMessage(e)};self.onmessage=async e=>{const{action:t,id:n,data:i}=e.data;if(T&&console.log("client worker received event data",e.data),"init"===t||C)try{switch(t){case"init":C=await P.create(i.address,i.encryptionKey,i.options),T=void 0!==i.options?.loggingLevel&&"off"!==i.options.loggingLevel,U({id:n,action:t,result:{inboxId:C.inboxId,installationId:C.installationId,installationIdBytes:C.installationIdBytes}});break;case"createInboxSignatureText":{const e=await C.createInboxSignatureText();U({id:n,action:t,result:e});break}case"addAccountSignatureText":{const e=await C.addAccountSignatureText(i.newAccountAddress);U({id:n,action:t,result:e});break}case"removeAccountSignatureText":{const e=await C.removeAccountSignatureText(i.accountAddress);U({id:n,action:t,result:e});break}case"revokeAllOtherInstallationsSignatureText":{const e=await C.revokeAllAOtherInstallationsSignatureText();U({id:n,action:t,result:e});break}case"revokeInstallationsSignatureText":{const e=await C.revokeInstallationsSignatureText(i.installationIds);U({id:n,action:t,result:e});break}case"addSignature":await C.addSignature(i.type,i.bytes),U({id:n,action:t,result:void 0});break;case"addScwSignature":await C.addScwSignature(i.type,i.bytes,i.chainId,i.blockNumber),U({id:n,action:t,result:void 0});break;case"applySignatures":await C.applySignatures(),U({id:n,action:t,result:void 0});break;case"registerIdentity":await C.registerIdentity(),U({id:n,action:t,result:void 0});break;case"isRegistered":{const e=C.isRegistered;U({id:n,action:t,result:e});break}case"canMessage":{const e=await C.canMessage(i.accountAddresses);U({id:n,action:t,result:e});break}case"inboxState":{const e=await C.inboxState(i.refreshFromNetwork);U({id:n,action:t,result:A(e)});break}case"getLatestInboxState":{const e=await C.getLatestInboxState(i.inboxId);U({id:n,action:t,result:A(e)});break}case"setConsentStates":await C.setConsentStates(i.records),U({id:n,action:t,result:void 0});break;case"getConsentState":{const e=await C.getConsentState(i.entityType,i.entity);U({id:n,action:t,result:e});break}case"findInboxIdByAddress":{const e=await C.findInboxIdByAddress(i.address);U({id:n,action:t,result:e});break}case"signWithInstallationKey":{const e=C.signWithInstallationKey(i.signatureText);U({id:n,action:t,result:e});break}case"verifySignedWithInstallationKey":{const e=C.verifySignedWithInstallationKey(i.signatureText,i.signatureBytes);U({id:n,action:t,result:e});break}case"verifySignedWithPublicKey":{const e=C.verifySignedWithPublicKey(i.signatureText,i.signatureBytes,i.publicKey);U({id:n,action:t,result:e});break}case"getConversations":{const e=C.conversations.list(i.options);U({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"getGroups":{const e=C.conversations.listGroups(i.options);U({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"getDms":{const e=C.conversations.listDms(i.options);U({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"newGroup":{const e=await C.conversations.newGroup(i.accountAddresses,i.options);U({id:n,action:t,result:await w(e)});break}case"newDm":{const e=await C.conversations.newDm(i.accountAddress);U({id:n,action:t,result:await w(e)});break}case"syncConversations":await C.conversations.sync(),U({id:n,action:t,result:void 0});break;case"syncAllConversations":await C.conversations.syncAll(),U({id:n,action:t,result:void 0});break;case"getConversationById":{const e=C.conversations.getConversationById(i.id);U({id:n,action:t,result:e?await w(e):void 0});break}case"getMessageById":{const e=C.conversations.getMessageById(i.id);U({id:n,action:t,result:e?b(e):void 0});break}case"getDmByInboxId":{const e=C.conversations.getDmByInboxId(i.inboxId);U({id:n,action:t,result:e?await w(e):void 0});break}case"getHmacKeys":{const e=C.conversations.getHmacKeys();U({id:n,action:t,result:Object.fromEntries(Array.from(e.entries()).map((([e,t])=>[e,t.map(G)])))});break}case"syncGroup":{const e=C.conversations.getConversationById(i.id);e?(await e.sync(),U({id:n,action:t,result:await w(e)})):N({id:n,action:t,error:"Group not found"});break}case"updateGroupName":{const e=C.conversations.getConversationById(i.id);e?(await e.updateName(i.name),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"updateGroupDescription":{const e=C.conversations.getConversationById(i.id);e?(await e.updateDescription(i.description),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"updateGroupImageUrlSquare":{const e=C.conversations.getConversationById(i.id);e?(await e.updateImageUrl(i.imageUrl),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"updateGroupPinnedFrameUrl":{const e=C.conversations.getConversationById(i.id);e?(await e.updatePinnedFrameUrl(i.pinnedFrameUrl),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"sendGroupMessage":{const e=C.conversations.getConversationById(i.id);if(e){const r=await e.send(g(I(i.content)));U({id:n,action:t,result:r})}else N({id:n,action:t,error:"Group not found"});break}case"sendOptimisticGroupMessage":{const e=C.conversations.getConversationById(i.id);if(e){const r=e.sendOptimistic(g(I(i.content)));U({id:n,action:t,result:r})}else N({id:n,action:t,error:"Group not found"});break}case"publishGroupMessages":{const e=C.conversations.getConversationById(i.id);e?(await e.publishMessages(),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"getGroupMessages":{const e=C.conversations.getConversationById(i.id);if(e){const r=await e.messages(i.options);U({id:n,action:t,result:r.map((e=>b(e)))})}else N({id:n,action:t,error:"Group not found"});break}case"getGroupMembers":{const e=C.conversations.getConversationById(i.id);if(e){const i=await e.members();U({id:n,action:t,result:i})}else N({id:n,action:t,error:"Group not found"});break}case"getGroupAdmins":{const e=C.conversations.getConversationById(i.id);e?U({id:n,action:t,result:e.admins}):N({id:n,action:t,error:"Group not found"});break}case"getGroupSuperAdmins":{const e=C.conversations.getConversationById(i.id);e?U({id:n,action:t,result:e.superAdmins}):N({id:n,action:t,error:"Group not found"});break}case"getGroupConsentState":{const e=C.conversations.getConversationById(i.id);e?U({id:n,action:t,result:e.consentState}):N({id:n,action:t,error:"Group not found"});break}case"updateGroupConsentState":{const e=C.conversations.getConversationById(i.id);e?(e.updateConsentState(i.state),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"addGroupAdmin":{const e=C.conversations.getConversationById(i.id);e?(await e.addAdmin(i.inboxId),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"removeGroupAdmin":{const e=C.conversations.getConversationById(i.id);e?(await e.removeAdmin(i.inboxId),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"addGroupSuperAdmin":{const e=C.conversations.getConversationById(i.id);e?(await e.addSuperAdmin(i.inboxId),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"removeGroupSuperAdmin":{const e=C.conversations.getConversationById(i.id);e?(await e.removeSuperAdmin(i.inboxId),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"addGroupMembers":{const e=C.conversations.getConversationById(i.id);e?(await e.addMembers(i.accountAddresses),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"removeGroupMembers":{const e=C.conversations.getConversationById(i.id);e?(await e.removeMembers(i.accountAddresses),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"addGroupMembersByInboxId":{const e=C.conversations.getConversationById(i.id);e?(await e.addMembersByInboxId(i.inboxIds),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"removeGroupMembersByInboxId":{const e=C.conversations.getConversationById(i.id);e?(await e.removeMembersByInboxId(i.inboxIds),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"isGroupAdmin":{const e=C.conversations.getConversationById(i.id);if(e){const r=e.isAdmin(i.inboxId);U({id:n,action:t,result:r})}else N({id:n,action:t,error:"Group not found"});break}case"isGroupSuperAdmin":{const e=C.conversations.getConversationById(i.id);if(e){const r=e.isSuperAdmin(i.inboxId);U({id:n,action:t,result:r})}else N({id:n,action:t,error:"Group not found"});break}case"getDmPeerInboxId":{const e=C.conversations.getConversationById(i.id);if(e){const i=e.dmPeerInboxId();U({id:n,action:t,result:i})}else N({id:n,action:t,error:"Group not found"});break}case"updateGroupPermissionPolicy":{const e=C.conversations.getConversationById(i.id);e?(await e.updatePermission(i.permissionType,i.policy,i.metadataField),U({id:n,action:t,result:void 0})):N({id:n,action:t,error:"Group not found"});break}case"getGroupPermissions":{const e=C.conversations.getConversationById(i.id);if(e){const i=await w(e);U({id:n,action:t,result:i.permissions})}else N({id:n,action:t,error:"Group not found"});break}}}catch(e){N({id:n,action:t,error:e.message})}else N({id:n,action:t,error:"Client not initialized"})};
|
|
1
|
+
import{ContentTypeId as e}from"@xmtp/content-type-primitives";import t,{EncodedContent as n,ContentTypeId as i,Consent as r,ListConversationsOptions as s,CreateGroupOptions as o,GroupPermissionsOptions as a,ListMessagesOptions as c,PermissionPolicySet as d,getInboxIdForAddress as u,generateInboxId as p,createClient as l,LogOptions as y,verifySignedWithPublicKey as m}from"@xmtp/wasm-bindings";const g=e=>{return new n((t=e.type,new i(t.authorityId,t.typeId,t.versionMajor,t.versionMinor)),new Map(Object.entries(e.parameters)),e.fallback,e.compression,e.content);var t},v=e=>{return{type:(t=e.type,{authorityId:t.authorityId,typeId:t.typeId,versionMajor:t.versionMajor,versionMinor:t.versionMinor}),parameters:e.parameters,fallback:e.fallback,compression:e.compression,content:e.content};var t},I=t=>{return{type:(n=t.type,new e({authorityId:n.authorityId,typeId:n.typeId,versionMajor:n.versionMajor,versionMinor:n.versionMinor})),parameters:t.parameters,fallback:t.fallback,compression:t.compression,content:t.content};var n},b=t=>{return{content:v((n=t.content,{type:(i=n.type,new e({authorityId:i.authorityId,typeId:i.typeId,versionMajor:i.versionMajor,versionMinor:i.versionMinor})),parameters:Object.fromEntries(n.parameters),fallback:n.fallback,compression:n.compression,content:n.content})),convoId:t.convoId,deliveryStatus:t.deliveryStatus,id:t.id,kind:t.kind,senderInboxId:t.senderInboxId,sentAtNs:t.sentAtNs};var n,i},h=e=>new s(e.allowedStates,e.conversationType,e.createdAfterNs,e.createdBeforeNs,e.limit),S=e=>{return new o(e.permissions,e.name,e.imageUrlSquare,e.description,e.pinnedFrameUrl,e.customPermissionPolicySet&&e.permissions===a.CustomPolicy?(t=e.customPermissionPolicySet,new d(t.addMemberPolicy,t.removeMemberPolicy,t.addAdminPolicy,t.removeAdminPolicy,t.updateGroupNamePolicy,t.updateGroupDescriptionPolicy,t.updateGroupImageUrlSquarePolicy,t.updateGroupPinnedFrameUrlPolicy,t.updateMessageExpirationPolicy)):void 0);var t},w=async e=>({id:e.id,name:e.name,imageUrl:e.imageUrl,description:e.description,pinnedFrameUrl:e.pinnedFrameUrl,permissions:{policyType:e.permissions.policyType,policySet:{addAdminPolicy:e.permissions.policySet.addAdminPolicy,addMemberPolicy:e.permissions.policySet.addMemberPolicy,removeAdminPolicy:e.permissions.policySet.removeAdminPolicy,removeMemberPolicy:e.permissions.policySet.removeMemberPolicy,updateGroupDescriptionPolicy:e.permissions.policySet.updateGroupDescriptionPolicy,updateGroupImageUrlSquarePolicy:e.permissions.policySet.updateGroupImageUrlSquarePolicy,updateGroupNamePolicy:e.permissions.policySet.updateGroupNamePolicy,updateGroupPinnedFrameUrlPolicy:e.permissions.policySet.updateGroupPinnedFrameUrlPolicy,updateMessageExpirationPolicy:e.permissions.policySet.updateMessageExpirationPolicy}},isActive:e.isActive,addedByInboxId:e.addedByInboxId,metadata:await e.metadata(),admins:e.admins,superAdmins:e.superAdmins,createdAtNs:e.createdAtNs}),x=e=>({bytes:e.bytes,clientTimestampNs:e.clientTimestampNs,id:e.id}),A=e=>({accountAddresses:e.accountAddresses,inboxId:e.inboxId,installations:e.installations.map(x),recoveryAddress:e.recoveryAddress}),k=e=>new r(e.entityType,e.state,e.entity),G=e=>({key:e.key,epoch:e.epoch}),f={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"},B={local:"http://localhost:5558",dev:"https://message-history.dev.ephemera.network",production:"https://message-history.production.ephemera.network"};class M{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get id(){return this.#t.id()}get name(){return this.#t.groupName()}async updateName(e){return this.#t.updateGroupName(e)}get imageUrl(){return this.#t.groupImageUrlSquare()}async updateImageUrl(e){return this.#t.updateGroupImageUrlSquare(e)}get description(){return this.#t.groupDescription()}async updateDescription(e){return this.#t.updateGroupDescription(e)}get pinnedFrameUrl(){return this.#t.groupPinnedFrameUrl()}async updatePinnedFrameUrl(e){return this.#t.updateGroupPinnedFrameUrl(e)}get isActive(){return this.#t.isActive()}get addedByInboxId(){return this.#t.addedByInboxId()}get createdAtNs(){return this.#t.createdAtNs()}async metadata(){const e=await this.#t.groupMetadata();return{creatorInboxId:e.creatorInboxId(),conversationType:e.conversationType()}}async members(){return(await this.#t.listMembers()).map((e=>(e=>({accountAddresses:e.accountAddresses,consentState:e.consentState,inboxId:e.inboxId,installationIds:e.installationIds,permissionLevel:e.permissionLevel}))(e)))}get admins(){return this.#t.adminList()}get superAdmins(){return this.#t.superAdminList()}get permissions(){const e=this.#t.groupPermissions();return{policyType:e.policyType(),policySet:e.policySet()}}async updatePermission(e,t,n){return this.#t.updatePermissionPolicy(e,t,n)}isAdmin(e){return this.#t.isAdmin(e)}isSuperAdmin(e){return this.#t.isSuperAdmin(e)}async sync(){return this.#t.sync()}async addMembers(e){return this.#t.addMembers(e)}async addMembersByInboxId(e){return this.#t.addMembersByInboxId(e)}async removeMembers(e){return this.#t.removeMembers(e)}async removeMembersByInboxId(e){return this.#t.removeMembersByInboxId(e)}async addAdmin(e){return this.#t.addAdmin(e)}async removeAdmin(e){return this.#t.removeAdmin(e)}async addSuperAdmin(e){return this.#t.addSuperAdmin(e)}async removeSuperAdmin(e){return this.#t.removeSuperAdmin(e)}async publishMessages(){return this.#t.publishMessages()}sendOptimistic(e){return this.#t.sendOptimistic(e)}async send(e){return this.#t.send(e)}async messages(e){return this.#t.findMessages(e?(e=>new c(e.sentBeforeNs,e.sentAfterNs,e.limit,e.deliveryStatus,e.direction))(e):void 0)}get consentState(){return this.#t.consentState()}updateConsentState(e){this.#t.updateConsentState(e)}dmPeerInboxId(){return this.#t.dmPeerInboxId()}}class P{#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 M(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 M(this.#e,t)}catch{return}}list(e){return this.#n.list(e?h(e):void 0).map((e=>new M(this.#e,e)))}listGroups(e){return this.#n.listGroups(e?h(e):void 0).map((e=>new M(this.#e,e)))}listDms(e){return this.#n.listDms(e?h(e):void 0).map((e=>new M(this.#e,e)))}async newGroup(e,t){const n=await this.#n.createGroup(e,t?S(t):void 0);return new M(this.#e,n)}async newDm(e){const t=await this.#n.createDm(e);return new M(this.#e,t)}getHmacKeys(){return this.#n.getHmacKeys()}}class C{#e;#n;#i;constructor(e){this.#e=e,this.#i=e.accountAddress,this.#n=new P(this,e.conversations())}static async create(e,n,i){const r=await(async(e,n,i)=>{await t();const r=i?.apiUrl??f[i?.env??"dev"],s=i?.dbPath??`xmtp-${i?.env??"dev"}-${e}.db3`,o=await u(r,e)||p(e),a=i&&(void 0!==i.loggingLevel||i.structuredLogging||i.performanceLogging);return l(r,o,e,s,n,i?.historySyncUrl??B[i?.env??"dev"],a?new y(i.structuredLogging??!1,i.performanceLogging??!1,i.loggingLevel):void 0)})(e,n,i);return new C(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 T,U=!1;const N=e=>{self.postMessage(e)},D=e=>{self.postMessage(e)};self.onmessage=async e=>{const{action:t,id:n,data:i}=e.data;if(U&&console.log("client worker received event data",e.data),"init"===t||T)try{switch(t){case"init":T=await C.create(i.address,i.encryptionKey,i.options),U=void 0!==i.options?.loggingLevel&&"off"!==i.options.loggingLevel,N({id:n,action:t,result:{inboxId:T.inboxId,installationId:T.installationId,installationIdBytes:T.installationIdBytes}});break;case"createInboxSignatureText":{const e=await T.createInboxSignatureText();N({id:n,action:t,result:e});break}case"addAccountSignatureText":{const e=await T.addAccountSignatureText(i.newAccountAddress);N({id:n,action:t,result:e});break}case"removeAccountSignatureText":{const e=await T.removeAccountSignatureText(i.accountAddress);N({id:n,action:t,result:e});break}case"revokeAllOtherInstallationsSignatureText":{const e=await T.revokeAllAOtherInstallationsSignatureText();N({id:n,action:t,result:e});break}case"revokeInstallationsSignatureText":{const e=await T.revokeInstallationsSignatureText(i.installationIds);N({id:n,action:t,result:e});break}case"addSignature":await T.addSignature(i.type,i.bytes),N({id:n,action:t,result:void 0});break;case"addScwSignature":await T.addScwSignature(i.type,i.bytes,i.chainId,i.blockNumber),N({id:n,action:t,result:void 0});break;case"applySignatures":await T.applySignatures(),N({id:n,action:t,result:void 0});break;case"registerIdentity":await T.registerIdentity(),N({id:n,action:t,result:void 0});break;case"isRegistered":{const e=T.isRegistered;N({id:n,action:t,result:e});break}case"canMessage":{const e=await T.canMessage(i.accountAddresses);N({id:n,action:t,result:e});break}case"inboxState":{const e=await T.inboxState(i.refreshFromNetwork);N({id:n,action:t,result:A(e)});break}case"getLatestInboxState":{const e=await T.getLatestInboxState(i.inboxId);N({id:n,action:t,result:A(e)});break}case"setConsentStates":await T.setConsentStates(i.records),N({id:n,action:t,result:void 0});break;case"getConsentState":{const e=await T.getConsentState(i.entityType,i.entity);N({id:n,action:t,result:e});break}case"findInboxIdByAddress":{const e=await T.findInboxIdByAddress(i.address);N({id:n,action:t,result:e});break}case"signWithInstallationKey":{const e=T.signWithInstallationKey(i.signatureText);N({id:n,action:t,result:e});break}case"verifySignedWithInstallationKey":{const e=T.verifySignedWithInstallationKey(i.signatureText,i.signatureBytes);N({id:n,action:t,result:e});break}case"verifySignedWithPublicKey":{const e=T.verifySignedWithPublicKey(i.signatureText,i.signatureBytes,i.publicKey);N({id:n,action:t,result:e});break}case"getConversations":{const e=T.conversations.list(i.options);N({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"getGroups":{const e=T.conversations.listGroups(i.options);N({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"getDms":{const e=T.conversations.listDms(i.options);N({id:n,action:t,result:await Promise.all(e.map((e=>w(e))))});break}case"newGroup":{const e=await T.conversations.newGroup(i.accountAddresses,i.options);N({id:n,action:t,result:await w(e)});break}case"newDm":{const e=await T.conversations.newDm(i.accountAddress);N({id:n,action:t,result:await w(e)});break}case"syncConversations":await T.conversations.sync(),N({id:n,action:t,result:void 0});break;case"syncAllConversations":await T.conversations.syncAll(),N({id:n,action:t,result:void 0});break;case"getConversationById":{const e=T.conversations.getConversationById(i.id);N({id:n,action:t,result:e?await w(e):void 0});break}case"getMessageById":{const e=T.conversations.getMessageById(i.id);N({id:n,action:t,result:e?b(e):void 0});break}case"getDmByInboxId":{const e=T.conversations.getDmByInboxId(i.inboxId);N({id:n,action:t,result:e?await w(e):void 0});break}case"getHmacKeys":{const e=T.conversations.getHmacKeys();N({id:n,action:t,result:Object.fromEntries(Array.from(e.entries()).map((([e,t])=>[e,t.map(G)])))});break}case"syncGroup":{const e=T.conversations.getConversationById(i.id);e?(await e.sync(),N({id:n,action:t,result:await w(e)})):D({id:n,action:t,error:"Group not found"});break}case"updateGroupName":{const e=T.conversations.getConversationById(i.id);e?(await e.updateName(i.name),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"updateGroupDescription":{const e=T.conversations.getConversationById(i.id);e?(await e.updateDescription(i.description),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"updateGroupImageUrlSquare":{const e=T.conversations.getConversationById(i.id);e?(await e.updateImageUrl(i.imageUrl),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"updateGroupPinnedFrameUrl":{const e=T.conversations.getConversationById(i.id);e?(await e.updatePinnedFrameUrl(i.pinnedFrameUrl),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"sendGroupMessage":{const e=T.conversations.getConversationById(i.id);if(e){const r=await e.send(g(I(i.content)));N({id:n,action:t,result:r})}else D({id:n,action:t,error:"Group not found"});break}case"sendOptimisticGroupMessage":{const e=T.conversations.getConversationById(i.id);if(e){const r=e.sendOptimistic(g(I(i.content)));N({id:n,action:t,result:r})}else D({id:n,action:t,error:"Group not found"});break}case"publishGroupMessages":{const e=T.conversations.getConversationById(i.id);e?(await e.publishMessages(),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"getGroupMessages":{const e=T.conversations.getConversationById(i.id);if(e){const r=await e.messages(i.options);N({id:n,action:t,result:r.map((e=>b(e)))})}else D({id:n,action:t,error:"Group not found"});break}case"getGroupMembers":{const e=T.conversations.getConversationById(i.id);if(e){const i=await e.members();N({id:n,action:t,result:i})}else D({id:n,action:t,error:"Group not found"});break}case"getGroupAdmins":{const e=T.conversations.getConversationById(i.id);e?N({id:n,action:t,result:e.admins}):D({id:n,action:t,error:"Group not found"});break}case"getGroupSuperAdmins":{const e=T.conversations.getConversationById(i.id);e?N({id:n,action:t,result:e.superAdmins}):D({id:n,action:t,error:"Group not found"});break}case"getGroupConsentState":{const e=T.conversations.getConversationById(i.id);e?N({id:n,action:t,result:e.consentState}):D({id:n,action:t,error:"Group not found"});break}case"updateGroupConsentState":{const e=T.conversations.getConversationById(i.id);e?(e.updateConsentState(i.state),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"addGroupAdmin":{const e=T.conversations.getConversationById(i.id);e?(await e.addAdmin(i.inboxId),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"removeGroupAdmin":{const e=T.conversations.getConversationById(i.id);e?(await e.removeAdmin(i.inboxId),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"addGroupSuperAdmin":{const e=T.conversations.getConversationById(i.id);e?(await e.addSuperAdmin(i.inboxId),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"removeGroupSuperAdmin":{const e=T.conversations.getConversationById(i.id);e?(await e.removeSuperAdmin(i.inboxId),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"addGroupMembers":{const e=T.conversations.getConversationById(i.id);e?(await e.addMembers(i.accountAddresses),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"removeGroupMembers":{const e=T.conversations.getConversationById(i.id);e?(await e.removeMembers(i.accountAddresses),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"addGroupMembersByInboxId":{const e=T.conversations.getConversationById(i.id);e?(await e.addMembersByInboxId(i.inboxIds),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"removeGroupMembersByInboxId":{const e=T.conversations.getConversationById(i.id);e?(await e.removeMembersByInboxId(i.inboxIds),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"isGroupAdmin":{const e=T.conversations.getConversationById(i.id);if(e){const r=e.isAdmin(i.inboxId);N({id:n,action:t,result:r})}else D({id:n,action:t,error:"Group not found"});break}case"isGroupSuperAdmin":{const e=T.conversations.getConversationById(i.id);if(e){const r=e.isSuperAdmin(i.inboxId);N({id:n,action:t,result:r})}else D({id:n,action:t,error:"Group not found"});break}case"getDmPeerInboxId":{const e=T.conversations.getConversationById(i.id);if(e){const i=e.dmPeerInboxId();N({id:n,action:t,result:i})}else D({id:n,action:t,error:"Group not found"});break}case"updateGroupPermissionPolicy":{const e=T.conversations.getConversationById(i.id);e?(await e.updatePermission(i.permissionType,i.policy,i.metadataField),N({id:n,action:t,result:void 0})):D({id:n,action:t,error:"Group not found"});break}case"getGroupPermissions":{const e=T.conversations.getConversationById(i.id);if(e){const i=await w(e);N({id:n,action:t,result:i.permissions})}else D({id:n,action:t,error:"Group not found"});break}}}catch(e){D({id:n,action:t,error:e.message})}else D({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 HmacKey,\n type InboxState,\n type Installation,\n type Message,\n type PermissionLevel,\n type PermissionPolicy,\n type SortDirection,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: DeliveryStatus;\n id: string;\n kind: GroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: Message): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convoId,\n deliveryStatus: message.deliveryStatus,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.senderInboxId,\n sentAtNs: message.sentAtNs,\n});\n\nexport type SafeListMessagesOptions = {\n deliveryStatus?: DeliveryStatus;\n direction?: SortDirection;\n limit?: bigint;\n sentAfterNs?: bigint;\n sentBeforeNs?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: ListMessagesOptions,\n): SafeListMessagesOptions => ({\n deliveryStatus: options.deliveryStatus,\n direction: options.direction,\n limit: options.limit,\n sentAfterNs: options.sentAfterNs,\n sentBeforeNs: options.sentBeforeNs,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): ListMessagesOptions =>\n new ListMessagesOptions(\n options.sentBeforeNs,\n options.sentAfterNs,\n options.limit,\n options.deliveryStatus,\n options.direction,\n );\n\nexport type SafeListConversationsOptions = {\n allowedStates?: GroupMembershipState[];\n conversationType?: ConversationType;\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n allowedStates: options.allowedStates,\n conversationType: options.conversationType,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.allowedStates,\n options.conversationType,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: PermissionPolicy;\n};\n\nexport const toSafePermissionPolicySet = (\n policySet: PermissionPolicySet,\n): SafePermissionPolicySet => ({\n addAdminPolicy: policySet.addAdminPolicy,\n addMemberPolicy: policySet.addMemberPolicy,\n removeAdminPolicy: policySet.removeAdminPolicy,\n removeMemberPolicy: policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy: policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy: policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy: policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy: policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy: policySet.updateMessageExpirationPolicy,\n});\n\nexport const fromSafePermissionPolicySet = (\n policySet: SafePermissionPolicySet,\n): PermissionPolicySet =>\n new PermissionPolicySet(\n policySet.addMemberPolicy,\n policySet.removeMemberPolicy,\n policySet.addAdminPolicy,\n policySet.removeAdminPolicy,\n policySet.updateGroupNamePolicy,\n policySet.updateGroupDescriptionPolicy,\n policySet.updateGroupImageUrlSquarePolicy,\n policySet.updateGroupPinnedFrameUrlPolicy,\n policySet.updateMessageExpirationPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n name?: string;\n permissions?: GroupPermissionsOptions;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n name: options.groupName,\n pinnedFrameUrl: options.groupPinnedFrameUrl,\n permissions: options.permissions,\n customPermissionPolicySet: options.customPermissionPolicySet,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): CreateGroupOptions =>\n new CreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n // only include custom policy set if permissions are set to CustomPolicy\n options.customPermissionPolicySet &&\n options.permissions === GroupPermissionsOptions.CustomPolicy\n ? fromSafePermissionPolicySet(options.customPermissionPolicySet)\n : undefined,\n );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: GroupPermissionsOptions;\n policySet: {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: PermissionPolicy;\n };\n };\n isActive: boolean;\n addedByInboxId: string;\n metadata: {\n creatorInboxId: string;\n conversationType: string;\n };\n admins: string[];\n superAdmins: string[];\n createdAtNs: bigint;\n};\n\nexport const toSafeConversation = async (\n conversation: WorkerConversation,\n): Promise<SafeConversation> => ({\n id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,\n addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,\n removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,\n removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy:\n conversation.permissions.policySet.updateMessageExpirationPolicy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: await conversation.metadata(),\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\n});\n\nexport type SafeInstallation = {\n bytes: Uint8Array;\n clientTimestampNs?: bigint;\n id: string;\n};\n\nexport const toSafeInstallation = (\n installation: Installation,\n): SafeInstallation => ({\n bytes: installation.bytes,\n clientTimestampNs: installation.clientTimestampNs,\n id: installation.id,\n});\n\nexport type SafeInboxState = {\n accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountAddresses: inboxState.accountAddresses,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recoveryAddress,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: ConsentEntityType;\n state: ConsentState;\n};\n\nexport const toSafeConsent = (consent: Consent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entityType,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): Consent =>\n new Consent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountAddresses: member.accountAddresses,\n consentState: member.consentState,\n inboxId: member.inboxId,\n installationIds: member.installationIds,\n permissionLevel: member.permissionLevel,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>\n new GroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n\nexport type SafeHmacKey = {\n key: Uint8Array;\n epoch: bigint;\n};\n\nexport const toSafeHmacKey = (hmacKey: HmacKey): SafeHmacKey => ({\n key: hmacKey.key,\n epoch: hmacKey.epoch,\n});\n\nexport type HmacKeys = Map<string, HmacKey[]>;\nexport type SafeHmacKeys = Record<string, SafeHmacKey[]>;\n","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n","import type {\n ConsentState,\n Conversation,\n EncodedContent,\n GroupMember,\n MetadataField,\n PermissionPolicy,\n PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeListMessagesOptions,\n toSafeGroupMember,\n type SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\n\nexport class WorkerConversation {\n // eslint-disable-next-line no-unused-private-class-members\n #client: WorkerClient;\n\n #group: Conversation;\n\n constructor(client: WorkerClient, group: Conversation) {\n this.#client = client;\n this.#group = group;\n }\n\n get id() {\n return this.#group.id();\n }\n\n get name() {\n return this.#group.groupName();\n }\n\n async updateName(name: string) {\n return this.#group.updateGroupName(name);\n }\n\n get imageUrl() {\n return this.#group.groupImageUrlSquare();\n }\n\n async updateImageUrl(imageUrl: string) {\n return this.#group.updateGroupImageUrlSquare(imageUrl);\n }\n\n get description() {\n return this.#group.groupDescription();\n }\n\n async updateDescription(description: string) {\n return this.#group.updateGroupDescription(description);\n }\n\n get pinnedFrameUrl() {\n return this.#group.groupPinnedFrameUrl();\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n return this.#group.updateGroupPinnedFrameUrl(pinnedFrameUrl);\n }\n\n get isActive() {\n return this.#group.isActive();\n }\n\n get addedByInboxId() {\n return this.#group.addedByInboxId();\n }\n\n get createdAtNs() {\n return this.#group.createdAtNs();\n }\n\n async metadata() {\n const metadata = await this.#group.groupMetadata();\n return {\n creatorInboxId: metadata.creatorInboxId(),\n conversationType: metadata.conversationType(),\n };\n }\n\n async members() {\n const members = (await this.#group.listMembers()) as GroupMember[];\n return members.map((member) => toSafeGroupMember(member));\n }\n\n get admins() {\n return this.#group.adminList();\n }\n\n get superAdmins() {\n return this.#group.superAdminList();\n }\n\n get permissions() {\n const permissions = this.#group.groupPermissions();\n return {\n policyType: permissions.policyType(),\n policySet: permissions.policySet(),\n };\n }\n\n async updatePermission(\n permissionType: PermissionUpdateType,\n policy: PermissionPolicy,\n metadataField?: MetadataField,\n ) {\n return this.#group.updatePermissionPolicy(\n permissionType,\n policy,\n metadataField,\n );\n }\n\n isAdmin(inboxId: string) {\n return this.#group.isAdmin(inboxId);\n }\n\n isSuperAdmin(inboxId: string) {\n return this.#group.isSuperAdmin(inboxId);\n }\n\n async sync() {\n return this.#group.sync();\n }\n\n async addMembers(accountAddresses: string[]) {\n return this.#group.addMembers(accountAddresses);\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#group.addMembersByInboxId(inboxIds);\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#group.removeMembers(accountAddresses);\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#group.removeMembersByInboxId(inboxIds);\n }\n\n async addAdmin(inboxId: string) {\n return this.#group.addAdmin(inboxId);\n }\n\n async removeAdmin(inboxId: string) {\n return this.#group.removeAdmin(inboxId);\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#group.addSuperAdmin(inboxId);\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#group.removeSuperAdmin(inboxId);\n }\n\n async publishMessages() {\n return this.#group.publishMessages();\n }\n\n sendOptimistic(encodedContent: EncodedContent) {\n return this.#group.sendOptimistic(encodedContent);\n }\n\n async send(encodedContent: EncodedContent) {\n return this.#group.send(encodedContent);\n }\n\n async messages(options?: SafeListMessagesOptions) {\n return this.#group.findMessages(\n options ? fromSafeListMessagesOptions(options) : undefined,\n );\n }\n\n get consentState() {\n return this.#group.consentState();\n }\n\n updateConsentState(state: ConsentState) {\n this.#group.updateConsentState(state);\n }\n\n dmPeerInboxId() {\n return this.#group.dmPeerInboxId();\n }\n}\n","import type { Conversation, Conversations } from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeCreateGroupOptions,\n fromSafeListConversationsOptions,\n type HmacKeys,\n type SafeCreateGroupOptions,\n type SafeListConversationsOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\nimport { WorkerConversation } from \"@/WorkerConversation\";\n\nexport class WorkerConversations {\n #client: WorkerClient;\n\n #conversations: Conversations;\n\n constructor(client: WorkerClient, conversations: Conversations) {\n this.#client = client;\n this.#conversations = conversations;\n }\n\n async sync() {\n return this.#conversations.sync();\n }\n\n async syncAll() {\n return this.#conversations.syncAllConversations();\n }\n\n getConversationById(id: string) {\n try {\n const group = this.#conversations.findGroupById(id);\n // findGroupById will throw if group is not found\n return new WorkerConversation(this.#client, group);\n } catch {\n return undefined;\n }\n }\n\n getMessageById(id: string) {\n try {\n // findMessageById will throw if message is not found\n return this.#conversations.findMessageById(id);\n } catch {\n return undefined;\n }\n }\n\n getDmByInboxId(inboxId: string) {\n try {\n const group = this.#conversations.findDmByTargetInboxId(inboxId);\n return new WorkerConversation(this.#client, group);\n } catch {\n return undefined;\n }\n }\n\n list(options?: SafeListConversationsOptions) {\n const groups = this.#conversations.list(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = this.#conversations.listGroups(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n listDms(options?: Omit<SafeListConversationsOptions, \"conversation_type\">) {\n const groups = this.#conversations.listDms(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const group = await this.#conversations.createGroup(\n accountAddresses,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDm(accountAddress: string) {\n const group = await this.#conversations.createDm(accountAddress);\n return new WorkerConversation(this.#client, group);\n }\n\n getHmacKeys() {\n return this.#conversations.getHmacKeys() as HmacKeys;\n }\n}\n","import {\n verifySignedWithPublicKey,\n type Client,\n type ConsentEntityType,\n type SignatureRequestType,\n} from \"@xmtp/wasm-bindings\";\nimport type { ClientOptions } from \"@/types\";\nimport { fromSafeConsent, type SafeConsent } from \"@/utils/conversions\";\nimport { createClient } from \"@/utils/createClient\";\nimport { WorkerConversations } from \"@/WorkerConversations\";\n\nexport class WorkerClient {\n #client: Client;\n\n #conversations: WorkerConversations;\n\n #accountAddress: string;\n\n constructor(client: Client) {\n this.#client = client;\n this.#accountAddress = client.accountAddress;\n this.#conversations = new WorkerConversations(this, client.conversations());\n }\n\n static async create(\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n ) {\n const client = await createClient(accountAddress, encryptionKey, options);\n return new WorkerClient(client);\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n get inboxId() {\n return this.#client.inboxId;\n }\n\n get installationId() {\n return this.#client.installationId;\n }\n\n get installationIdBytes() {\n return this.#client.installationIdBytes;\n }\n\n get isRegistered() {\n return this.#client.isRegistered;\n }\n\n async createInboxSignatureText() {\n try {\n return await this.#client.createInboxSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async addAccountSignatureText(accountAddress: string) {\n try {\n return await this.#client.addWalletSignatureText(accountAddress);\n } catch {\n return undefined;\n }\n }\n\n async removeAccountSignatureText(accountAddress: string) {\n try {\n return await this.#client.revokeWalletSignatureText(accountAddress);\n } catch {\n return undefined;\n }\n }\n\n async revokeAllAOtherInstallationsSignatureText() {\n try {\n return await this.#client.revokeAllOtherInstallationsSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async revokeInstallationsSignatureText(installationIds: Uint8Array[]) {\n try {\n return await this.#client.revokeInstallationsSignatureText(\n installationIds,\n );\n } catch {\n return undefined;\n }\n }\n\n async addSignature(type: SignatureRequestType, bytes: Uint8Array) {\n return this.#client.addSignature(type, bytes);\n }\n\n async addScwSignature(\n type: SignatureRequestType,\n bytes: Uint8Array,\n chainId: bigint,\n blockNumber?: bigint,\n ) {\n return this.#client.addScwSignature(type, bytes, chainId, blockNumber);\n }\n\n async applySignatures() {\n return this.#client.applySignatureRequests();\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.#client.canMessage(accountAddresses) as Promise<\n Map<string, boolean>\n >;\n }\n\n async registerIdentity() {\n return this.#client.registerIdentity();\n }\n\n async findInboxIdByAddress(address: string) {\n return this.#client.findInboxIdByAddress(address);\n }\n\n async inboxState(refreshFromNetwork: boolean) {\n return this.#client.inboxState(refreshFromNetwork);\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.#client.getLatestInboxState(inboxId);\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.#client.setConsentStates(records.map(fromSafeConsent));\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.#client.getConsentState(entityType, entity);\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n signWithInstallationKey(signatureText: string) {\n return this.#client.signWithInstallationKey(signatureText);\n }\n\n verifySignedWithInstallationKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n ) {\n try {\n this.#client.verifySignedWithInstallationKey(\n signatureText,\n signatureBytes,\n );\n return true;\n } catch {\n return false;\n }\n }\n\n verifySignedWithPublicKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n publicKey: Uint8Array,\n ) {\n try {\n verifySignedWithPublicKey(signatureText, signatureBytes, publicKey);\n return true;\n } catch {\n return false;\n }\n }\n}\n","import init, {\n createClient as createWasmClient,\n generateInboxId,\n getInboxIdForAddress,\n LogOptions,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls } from \"@/constants\";\nimport type { ClientOptions } from \"@/types\";\n\nexport const createClient = async (\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n) => {\n // initialize WASM module\n await init();\n\n const host = options?.apiUrl ?? ApiUrls[options?.env ?? \"dev\"];\n // TODO: add db path validation\n // - must end with .db3\n // - must not contain invalid characters\n // - must not start with a dot\n const dbPath =\n options?.dbPath ?? `xmtp-${options?.env ?? \"dev\"}-${accountAddress}.db3`;\n\n const inboxId =\n (await getInboxIdForAddress(host, accountAddress)) ||\n generateInboxId(accountAddress);\n\n const isLogging =\n options &&\n (options.loggingLevel !== undefined ||\n options.structuredLogging ||\n options.performanceLogging);\n\n return createWasmClient(\n host,\n inboxId,\n accountAddress,\n dbPath,\n encryptionKey,\n undefined,\n isLogging\n ? new LogOptions(\n options.structuredLogging ?? false,\n options.performanceLogging ?? false,\n options.loggingLevel,\n )\n : undefined,\n );\n};\n","import type {\n ClientEventsActions,\n ClientEventsClientMessageData,\n ClientEventsErrorData,\n ClientEventsWorkerPostMessageData,\n} from \"@/types\";\nimport {\n fromEncodedContent,\n fromSafeEncodedContent,\n toSafeConversation,\n toSafeHmacKey,\n toSafeInboxState,\n toSafeMessage,\n} from \"@/utils/conversions\";\nimport { WorkerClient } from \"@/WorkerClient\";\n\nlet client: WorkerClient;\nlet enableLogging = false;\n\n/**\n * Type-safe postMessage\n */\nconst postMessage = <A extends ClientEventsActions>(\n data: ClientEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for errors\n */\nconst postMessageError = (data: ClientEventsErrorData) => {\n self.postMessage(data);\n};\n\nself.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {\n const { action, id, data } = event.data;\n\n if (enableLogging) {\n console.log(\"client worker received event data\", event.data);\n }\n\n // a client is required for all actions except init\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (action !== \"init\" && !client) {\n postMessageError({\n id,\n action,\n error: \"Client not initialized\",\n });\n return;\n }\n\n try {\n switch (action) {\n /**\n * Client actions\n */\n case \"init\":\n client = await WorkerClient.create(\n data.address,\n data.encryptionKey,\n data.options,\n );\n enableLogging =\n data.options?.loggingLevel !== undefined &&\n data.options.loggingLevel !== \"off\";\n postMessage({\n id,\n action,\n result: {\n inboxId: client.inboxId,\n installationId: client.installationId,\n installationIdBytes: client.installationIdBytes,\n },\n });\n break;\n case \"createInboxSignatureText\": {\n const result = await client.createInboxSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addAccountSignatureText\": {\n const result = await client.addAccountSignatureText(\n data.newAccountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"removeAccountSignatureText\": {\n const result = await client.removeAccountSignatureText(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"revokeAllOtherInstallationsSignatureText\": {\n const result = await client.revokeAllAOtherInstallationsSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"revokeInstallationsSignatureText\": {\n const result = await client.revokeInstallationsSignatureText(\n data.installationIds,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addSignature\":\n await client.addSignature(data.type, data.bytes);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"addScwSignature\":\n await client.addScwSignature(\n data.type,\n data.bytes,\n data.chainId,\n data.blockNumber,\n );\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"applySignatures\":\n await client.applySignatures();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"registerIdentity\":\n await client.registerIdentity();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"isRegistered\": {\n const result = client.isRegistered;\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"canMessage\": {\n const result = await client.canMessage(data.accountAddresses);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"inboxState\": {\n const result = await client.inboxState(data.refreshFromNetwork);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"getLatestInboxState\": {\n const result = await client.getLatestInboxState(data.inboxId);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"setConsentStates\": {\n await client.setConsentStates(data.records);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConsentState\": {\n const result = await client.getConsentState(\n data.entityType,\n data.entity,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"findInboxIdByAddress\": {\n const result = await client.findInboxIdByAddress(data.address);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"signWithInstallationKey\": {\n const result = client.signWithInstallationKey(data.signatureText);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"verifySignedWithInstallationKey\": {\n const result = client.verifySignedWithInstallationKey(\n data.signatureText,\n data.signatureBytes,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"verifySignedWithPublicKey\": {\n const result = client.verifySignedWithPublicKey(\n data.signatureText,\n data.signatureBytes,\n data.publicKey,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n /**\n * Conversations actions\n */\n case \"getConversations\": {\n const conversations = client.conversations.list(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"getGroups\": {\n const conversations = client.conversations.listGroups(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"getDms\": {\n const conversations = client.conversations.listDms(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"newGroup\": {\n const conversation = await client.conversations.newGroup(\n data.accountAddresses,\n data.options,\n );\n postMessage({\n id,\n action,\n result: await toSafeConversation(conversation),\n });\n break;\n }\n case \"newDm\": {\n const conversation = await client.conversations.newDm(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result: await toSafeConversation(conversation),\n });\n break;\n }\n case \"syncConversations\": {\n await client.conversations.sync();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"syncAllConversations\": {\n await client.conversations.syncAll();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConversationById\": {\n const conversation = client.conversations.getConversationById(data.id);\n postMessage({\n id,\n action,\n result: conversation\n ? await toSafeConversation(conversation)\n : undefined,\n });\n break;\n }\n case \"getMessageById\": {\n const message = client.conversations.getMessageById(data.id);\n postMessage({\n id,\n action,\n result: message ? toSafeMessage(message) : undefined,\n });\n break;\n }\n case \"getDmByInboxId\": {\n const conversation = client.conversations.getDmByInboxId(data.inboxId);\n postMessage({\n id,\n action,\n result: conversation\n ? await toSafeConversation(conversation)\n : undefined,\n });\n break;\n }\n case \"getHmacKeys\": {\n const result = client.conversations.getHmacKeys();\n postMessage({\n id,\n action,\n result: Object.fromEntries(\n Array.from(result.entries()).map(([groupId, hmacKeys]) => [\n groupId,\n hmacKeys.map(toSafeHmacKey),\n ]),\n ),\n });\n break;\n }\n /**\n * Group actions\n */\n case \"syncGroup\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.sync();\n postMessage({\n id,\n action,\n result: await toSafeConversation(group),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupName\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateName(data.name);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupDescription\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateDescription(data.description);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupImageUrlSquare\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateImageUrl(data.imageUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPinnedFrameUrl\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePinnedFrameUrl(data.pinnedFrameUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.send(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendOptimisticGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.sendOptimistic(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"publishGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.publishMessages();\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const messages = await group.messages(data.options);\n postMessage({\n id,\n action,\n result: messages.map((message) => toSafeMessage(message)),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.members();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.admins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupSuperAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.superAdmins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.consentState,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n group.updateConsentState(data.state);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getDmPeerInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.dmPeerInboxId();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPermissionPolicy\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePermission(\n data.permissionType,\n data.policy,\n data.metadataField,\n );\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupPermissions\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const safeConversation = await toSafeConversation(group);\n postMessage({\n id,\n action,\n result: safeConversation.permissions,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n }\n } catch (e) {\n postMessageError({\n id,\n action,\n error: (e as Error).message,\n });\n }\n};\n"],"names":["fromEncodedContent","content","WasmEncodedContent","contentTypeId","type","WasmContentTypeId","authorityId","typeId","versionMajor","versionMinor","Map","Object","entries","parameters","fallback","compression","toSafeEncodedContent","fromSafeEncodedContent","ContentTypeId","toSafeMessage","message","fromEntries","convoId","deliveryStatus","id","kind","senderInboxId","sentAtNs","fromSafeListConversationsOptions","options","ListConversationsOptions","allowedStates","conversationType","createdAfterNs","createdBeforeNs","limit","fromSafeCreateGroupOptions","CreateGroupOptions","permissions","name","imageUrlSquare","description","pinnedFrameUrl","customPermissionPolicySet","GroupPermissionsOptions","CustomPolicy","policySet","PermissionPolicySet","addMemberPolicy","removeMemberPolicy","addAdminPolicy","removeAdminPolicy","updateGroupNamePolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateGroupPinnedFrameUrlPolicy","updateMessageExpirationPolicy","undefined","toSafeConversation","async","conversation","imageUrl","policyType","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","bytes","clientTimestampNs","toSafeInboxState","inboxState","accountAddresses","inboxId","installations","map","recoveryAddress","fromSafeConsent","consent","Consent","entityType","state","entity","toSafeHmacKey","hmacKey","key","epoch","ApiUrls","local","dev","production","WorkerConversation","client","group","constructor","this","groupName","updateName","updateGroupName","groupImageUrlSquare","updateImageUrl","updateGroupImageUrlSquare","groupDescription","updateDescription","updateGroupDescription","groupPinnedFrameUrl","updatePinnedFrameUrl","updateGroupPinnedFrameUrl","groupMetadata","creatorInboxId","members","listMembers","member","consentState","installationIds","permissionLevel","toSafeGroupMember","adminList","superAdminList","groupPermissions","updatePermission","permissionType","policy","metadataField","updatePermissionPolicy","isAdmin","isSuperAdmin","sync","addMembers","addMembersByInboxId","inboxIds","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","encodedContent","send","messages","findMessages","ListMessagesOptions","sentBeforeNs","sentAfterNs","direction","fromSafeListMessagesOptions","updateConsentState","dmPeerInboxId","WorkerConversations","conversations","syncAll","syncAllConversations","getConversationById","findGroupById","getMessageById","findMessageById","getDmByInboxId","findDmByTargetInboxId","list","listGroups","listDms","newGroup","createGroup","newDm","accountAddress","createDm","getHmacKeys","WorkerClient","create","encryptionKey","init","host","apiUrl","env","dbPath","getInboxIdForAddress","generateInboxId","isLogging","loggingLevel","structuredLogging","performanceLogging","createWasmClient","LogOptions","createClient","installationId","installationIdBytes","isRegistered","createInboxSignatureText","addAccountSignatureText","addWalletSignatureText","removeAccountSignatureText","revokeWalletSignatureText","revokeAllAOtherInstallationsSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","addScwSignature","chainId","blockNumber","applySignatures","applySignatureRequests","canMessage","registerIdentity","findInboxIdByAddress","address","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","signWithInstallationKey","signatureText","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","enableLogging","postMessage","data","self","postMessageError","onmessage","event","action","console","log","result","newAccountAddress","Promise","all","Array","from","groupId","hmacKeys","error","safeConversation","e"],"mappings":"2YA8BO,MAyDMA,EACXC,IAEA,WAAIC,GAjDJC,EAkDoBF,EAAQG,KAhD5B,IAAIC,EACFF,EAAcG,YACdH,EAAcI,OACdJ,EAAcK,aACdL,EAAcM,eA6Cd,IAAIC,IAAIC,OAAOC,QAAQX,EAAQY,aAC/BZ,EAAQa,SACRb,EAAQc,YACRd,EAAQA,SAvDqB,IAC/BE,CAuDC,EAUUa,EACXf,IACwB,OACxBG,MAnDAD,EAmD0BF,EAAQG,KAlDX,CACvBE,YAAaH,EAAcG,YAC3BC,OAAQJ,EAAcI,OACtBC,aAAcL,EAAcK,aAC5BC,aAAcN,EAAcM,eA+C5BI,WAAYZ,EAAQY,WACpBC,SAAUb,EAAQa,SAClBC,YAAad,EAAQc,YACrBd,QAASA,EAAQA,SAxDgB,IACjCE,CAwDA,EAEWc,EACXhB,IACoB,OACpBG,MApDAD,EAoD4BF,EAAQG,KAlDpC,IAAIc,EAAc,CAChBZ,YAAaH,EAAcG,YAC3BC,OAAQJ,EAAcI,OACtBC,aAAcL,EAAcK,aAC5BC,aAAcN,EAAcM,gBA+C9BI,WAAYZ,EAAQY,WACpBC,SAAUb,EAAQa,SAClBC,YAAad,EAAQc,YACrBd,QAASA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}
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../src/utils/conversions.ts","../../src/constants.ts","../../src/WorkerConversation.ts","../../src/WorkerConversations.ts","../../src/WorkerClient.ts","../../src/utils/createClient.ts","../../src/workers/client.ts"],"sourcesContent":["import {\n ContentTypeId,\n type EncodedContent,\n} from \"@xmtp/content-type-primitives\";\nimport {\n Consent,\n CreateGroupOptions,\n GroupMember,\n GroupPermissionsOptions,\n ListConversationsOptions,\n ListMessagesOptions,\n PermissionPolicySet,\n ContentTypeId as WasmContentTypeId,\n EncodedContent as WasmEncodedContent,\n type ConsentEntityType,\n type ConsentState,\n type ConversationType,\n type DeliveryStatus,\n type GroupMembershipState,\n type GroupMessageKind,\n type HmacKey,\n type InboxState,\n type Installation,\n type Message,\n type PermissionLevel,\n type PermissionPolicy,\n type SortDirection,\n} from \"@xmtp/wasm-bindings\";\nimport type { WorkerConversation } from \"@/WorkerConversation\";\n\nexport const toContentTypeId = (\n contentTypeId: WasmContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const fromContentTypeId = (\n contentTypeId: ContentTypeId,\n): WasmContentTypeId =>\n new WasmContentTypeId(\n contentTypeId.authorityId,\n contentTypeId.typeId,\n contentTypeId.versionMajor,\n contentTypeId.versionMinor,\n );\n\nexport type SafeContentTypeId = {\n authorityId: string;\n typeId: string;\n versionMajor: number;\n versionMinor: number;\n};\n\nexport const toSafeContentTypeId = (\n contentTypeId: ContentTypeId,\n): SafeContentTypeId => ({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n});\n\nexport const fromSafeContentTypeId = (\n contentTypeId: SafeContentTypeId,\n): ContentTypeId =>\n new ContentTypeId({\n authorityId: contentTypeId.authorityId,\n typeId: contentTypeId.typeId,\n versionMajor: contentTypeId.versionMajor,\n versionMinor: contentTypeId.versionMinor,\n });\n\nexport const toEncodedContent = (\n content: WasmEncodedContent,\n): EncodedContent => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n type: toContentTypeId(content.type!),\n parameters: Object.fromEntries(content.parameters as Map<string, string>),\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromEncodedContent = (\n content: EncodedContent,\n): WasmEncodedContent =>\n new WasmEncodedContent(\n fromContentTypeId(content.type),\n new Map(Object.entries(content.parameters)),\n content.fallback,\n content.compression,\n content.content,\n );\n\nexport type SafeEncodedContent = {\n type: SafeContentTypeId;\n parameters: Record<string, string>;\n fallback?: string;\n compression?: number;\n content: Uint8Array;\n};\n\nexport const toSafeEncodedContent = (\n content: EncodedContent,\n): SafeEncodedContent => ({\n type: toSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport const fromSafeEncodedContent = (\n content: SafeEncodedContent,\n): EncodedContent => ({\n type: fromSafeContentTypeId(content.type),\n parameters: content.parameters,\n fallback: content.fallback,\n compression: content.compression,\n content: content.content,\n});\n\nexport type SafeMessage = {\n content: SafeEncodedContent;\n convoId: string;\n deliveryStatus: DeliveryStatus;\n id: string;\n kind: GroupMessageKind;\n senderInboxId: string;\n sentAtNs: bigint;\n};\n\nexport const toSafeMessage = (message: Message): SafeMessage => ({\n content: toSafeEncodedContent(toEncodedContent(message.content)),\n convoId: message.convoId,\n deliveryStatus: message.deliveryStatus,\n id: message.id,\n kind: message.kind,\n senderInboxId: message.senderInboxId,\n sentAtNs: message.sentAtNs,\n});\n\nexport type SafeListMessagesOptions = {\n deliveryStatus?: DeliveryStatus;\n direction?: SortDirection;\n limit?: bigint;\n sentAfterNs?: bigint;\n sentBeforeNs?: bigint;\n};\n\nexport const toSafeListMessagesOptions = (\n options: ListMessagesOptions,\n): SafeListMessagesOptions => ({\n deliveryStatus: options.deliveryStatus,\n direction: options.direction,\n limit: options.limit,\n sentAfterNs: options.sentAfterNs,\n sentBeforeNs: options.sentBeforeNs,\n});\n\nexport const fromSafeListMessagesOptions = (\n options: SafeListMessagesOptions,\n): ListMessagesOptions =>\n new ListMessagesOptions(\n options.sentBeforeNs,\n options.sentAfterNs,\n options.limit,\n options.deliveryStatus,\n options.direction,\n );\n\nexport type SafeListConversationsOptions = {\n allowedStates?: GroupMembershipState[];\n conversationType?: ConversationType;\n createdAfterNs?: bigint;\n createdBeforeNs?: bigint;\n limit?: bigint;\n};\n\nexport const toSafeListConversationsOptions = (\n options: ListConversationsOptions,\n): SafeListConversationsOptions => ({\n allowedStates: options.allowedStates,\n conversationType: options.conversationType,\n createdAfterNs: options.createdAfterNs,\n createdBeforeNs: options.createdBeforeNs,\n limit: options.limit,\n});\n\nexport const fromSafeListConversationsOptions = (\n options: SafeListConversationsOptions,\n): ListConversationsOptions =>\n new ListConversationsOptions(\n options.allowedStates,\n options.conversationType,\n options.createdAfterNs,\n options.createdBeforeNs,\n options.limit,\n );\n\nexport type SafePermissionPolicySet = {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: PermissionPolicy;\n};\n\nexport const toSafePermissionPolicySet = (\n policySet: PermissionPolicySet,\n): SafePermissionPolicySet => ({\n addAdminPolicy: policySet.addAdminPolicy,\n addMemberPolicy: policySet.addMemberPolicy,\n removeAdminPolicy: policySet.removeAdminPolicy,\n removeMemberPolicy: policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy: policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy: policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy: policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy: policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy: policySet.updateMessageExpirationPolicy,\n});\n\nexport const fromSafePermissionPolicySet = (\n policySet: SafePermissionPolicySet,\n): PermissionPolicySet =>\n new PermissionPolicySet(\n policySet.addMemberPolicy,\n policySet.removeMemberPolicy,\n policySet.addAdminPolicy,\n policySet.removeAdminPolicy,\n policySet.updateGroupNamePolicy,\n policySet.updateGroupDescriptionPolicy,\n policySet.updateGroupImageUrlSquarePolicy,\n policySet.updateGroupPinnedFrameUrlPolicy,\n policySet.updateMessageExpirationPolicy,\n );\n\nexport type SafeCreateGroupOptions = {\n customPermissionPolicySet?: SafePermissionPolicySet;\n description?: string;\n imageUrlSquare?: string;\n name?: string;\n permissions?: GroupPermissionsOptions;\n pinnedFrameUrl?: string;\n};\n\nexport const toSafeCreateGroupOptions = (\n options: CreateGroupOptions,\n): SafeCreateGroupOptions => ({\n description: options.groupDescription,\n imageUrlSquare: options.groupImageUrlSquare,\n name: options.groupName,\n pinnedFrameUrl: options.groupPinnedFrameUrl,\n permissions: options.permissions,\n customPermissionPolicySet: options.customPermissionPolicySet,\n});\n\nexport const fromSafeCreateGroupOptions = (\n options: SafeCreateGroupOptions,\n): CreateGroupOptions =>\n new CreateGroupOptions(\n options.permissions,\n options.name,\n options.imageUrlSquare,\n options.description,\n options.pinnedFrameUrl,\n // only include custom policy set if permissions are set to CustomPolicy\n options.customPermissionPolicySet &&\n options.permissions === GroupPermissionsOptions.CustomPolicy\n ? fromSafePermissionPolicySet(options.customPermissionPolicySet)\n : undefined,\n );\n\nexport type SafeConversation = {\n id: string;\n name: string;\n imageUrl: string;\n description: string;\n pinnedFrameUrl: string;\n permissions: {\n policyType: GroupPermissionsOptions;\n policySet: {\n addAdminPolicy: PermissionPolicy;\n addMemberPolicy: PermissionPolicy;\n removeAdminPolicy: PermissionPolicy;\n removeMemberPolicy: PermissionPolicy;\n updateGroupDescriptionPolicy: PermissionPolicy;\n updateGroupImageUrlSquarePolicy: PermissionPolicy;\n updateGroupNamePolicy: PermissionPolicy;\n updateGroupPinnedFrameUrlPolicy: PermissionPolicy;\n updateMessageExpirationPolicy: PermissionPolicy;\n };\n };\n isActive: boolean;\n addedByInboxId: string;\n metadata: {\n creatorInboxId: string;\n conversationType: string;\n };\n admins: string[];\n superAdmins: string[];\n createdAtNs: bigint;\n};\n\nexport const toSafeConversation = async (\n conversation: WorkerConversation,\n): Promise<SafeConversation> => ({\n id: conversation.id,\n name: conversation.name,\n imageUrl: conversation.imageUrl,\n description: conversation.description,\n pinnedFrameUrl: conversation.pinnedFrameUrl,\n permissions: {\n policyType: conversation.permissions.policyType,\n policySet: {\n addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,\n addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,\n removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,\n removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,\n updateGroupDescriptionPolicy:\n conversation.permissions.policySet.updateGroupDescriptionPolicy,\n updateGroupImageUrlSquarePolicy:\n conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,\n updateGroupNamePolicy:\n conversation.permissions.policySet.updateGroupNamePolicy,\n updateGroupPinnedFrameUrlPolicy:\n conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,\n updateMessageExpirationPolicy:\n conversation.permissions.policySet.updateMessageExpirationPolicy,\n },\n },\n isActive: conversation.isActive,\n addedByInboxId: conversation.addedByInboxId,\n metadata: await conversation.metadata(),\n admins: conversation.admins,\n superAdmins: conversation.superAdmins,\n createdAtNs: conversation.createdAtNs,\n});\n\nexport type SafeInstallation = {\n bytes: Uint8Array;\n clientTimestampNs?: bigint;\n id: string;\n};\n\nexport const toSafeInstallation = (\n installation: Installation,\n): SafeInstallation => ({\n bytes: installation.bytes,\n clientTimestampNs: installation.clientTimestampNs,\n id: installation.id,\n});\n\nexport type SafeInboxState = {\n accountAddresses: string[];\n inboxId: string;\n installations: SafeInstallation[];\n recoveryAddress: string;\n};\n\nexport const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({\n accountAddresses: inboxState.accountAddresses,\n inboxId: inboxState.inboxId,\n installations: inboxState.installations.map(toSafeInstallation),\n recoveryAddress: inboxState.recoveryAddress,\n});\n\nexport type SafeConsent = {\n entity: string;\n entityType: ConsentEntityType;\n state: ConsentState;\n};\n\nexport const toSafeConsent = (consent: Consent): SafeConsent => ({\n entity: consent.entity,\n entityType: consent.entityType,\n state: consent.state,\n});\n\nexport const fromSafeConsent = (consent: SafeConsent): Consent =>\n new Consent(consent.entityType, consent.state, consent.entity);\n\nexport type SafeGroupMember = {\n accountAddresses: string[];\n consentState: ConsentState;\n inboxId: string;\n installationIds: string[];\n permissionLevel: PermissionLevel;\n};\n\nexport const toSafeGroupMember = (member: GroupMember): SafeGroupMember => ({\n accountAddresses: member.accountAddresses,\n consentState: member.consentState,\n inboxId: member.inboxId,\n installationIds: member.installationIds,\n permissionLevel: member.permissionLevel,\n});\n\nexport const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>\n new GroupMember(\n member.inboxId,\n member.accountAddresses,\n member.installationIds,\n member.permissionLevel,\n member.consentState,\n );\n\nexport type SafeHmacKey = {\n key: Uint8Array;\n epoch: bigint;\n};\n\nexport const toSafeHmacKey = (hmacKey: HmacKey): SafeHmacKey => ({\n key: hmacKey.key,\n epoch: hmacKey.epoch,\n});\n\nexport type HmacKeys = Map<string, HmacKey[]>;\nexport type SafeHmacKeys = Record<string, SafeHmacKey[]>;\n","export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n\nexport const HistorySyncUrls = {\n local: \"http://localhost:5558\",\n dev: \"https://message-history.dev.ephemera.network\",\n production: \"https://message-history.production.ephemera.network\",\n} as const;\n","import type {\n ConsentState,\n Conversation,\n EncodedContent,\n GroupMember,\n MetadataField,\n PermissionPolicy,\n PermissionUpdateType,\n} from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeListMessagesOptions,\n toSafeGroupMember,\n type SafeListMessagesOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\n\nexport class WorkerConversation {\n // eslint-disable-next-line no-unused-private-class-members\n #client: WorkerClient;\n\n #group: Conversation;\n\n constructor(client: WorkerClient, group: Conversation) {\n this.#client = client;\n this.#group = group;\n }\n\n get id() {\n return this.#group.id();\n }\n\n get name() {\n return this.#group.groupName();\n }\n\n async updateName(name: string) {\n return this.#group.updateGroupName(name);\n }\n\n get imageUrl() {\n return this.#group.groupImageUrlSquare();\n }\n\n async updateImageUrl(imageUrl: string) {\n return this.#group.updateGroupImageUrlSquare(imageUrl);\n }\n\n get description() {\n return this.#group.groupDescription();\n }\n\n async updateDescription(description: string) {\n return this.#group.updateGroupDescription(description);\n }\n\n get pinnedFrameUrl() {\n return this.#group.groupPinnedFrameUrl();\n }\n\n async updatePinnedFrameUrl(pinnedFrameUrl: string) {\n return this.#group.updateGroupPinnedFrameUrl(pinnedFrameUrl);\n }\n\n get isActive() {\n return this.#group.isActive();\n }\n\n get addedByInboxId() {\n return this.#group.addedByInboxId();\n }\n\n get createdAtNs() {\n return this.#group.createdAtNs();\n }\n\n async metadata() {\n const metadata = await this.#group.groupMetadata();\n return {\n creatorInboxId: metadata.creatorInboxId(),\n conversationType: metadata.conversationType(),\n };\n }\n\n async members() {\n const members = (await this.#group.listMembers()) as GroupMember[];\n return members.map((member) => toSafeGroupMember(member));\n }\n\n get admins() {\n return this.#group.adminList();\n }\n\n get superAdmins() {\n return this.#group.superAdminList();\n }\n\n get permissions() {\n const permissions = this.#group.groupPermissions();\n return {\n policyType: permissions.policyType(),\n policySet: permissions.policySet(),\n };\n }\n\n async updatePermission(\n permissionType: PermissionUpdateType,\n policy: PermissionPolicy,\n metadataField?: MetadataField,\n ) {\n return this.#group.updatePermissionPolicy(\n permissionType,\n policy,\n metadataField,\n );\n }\n\n isAdmin(inboxId: string) {\n return this.#group.isAdmin(inboxId);\n }\n\n isSuperAdmin(inboxId: string) {\n return this.#group.isSuperAdmin(inboxId);\n }\n\n async sync() {\n return this.#group.sync();\n }\n\n async addMembers(accountAddresses: string[]) {\n return this.#group.addMembers(accountAddresses);\n }\n\n async addMembersByInboxId(inboxIds: string[]) {\n return this.#group.addMembersByInboxId(inboxIds);\n }\n\n async removeMembers(accountAddresses: string[]) {\n return this.#group.removeMembers(accountAddresses);\n }\n\n async removeMembersByInboxId(inboxIds: string[]) {\n return this.#group.removeMembersByInboxId(inboxIds);\n }\n\n async addAdmin(inboxId: string) {\n return this.#group.addAdmin(inboxId);\n }\n\n async removeAdmin(inboxId: string) {\n return this.#group.removeAdmin(inboxId);\n }\n\n async addSuperAdmin(inboxId: string) {\n return this.#group.addSuperAdmin(inboxId);\n }\n\n async removeSuperAdmin(inboxId: string) {\n return this.#group.removeSuperAdmin(inboxId);\n }\n\n async publishMessages() {\n return this.#group.publishMessages();\n }\n\n sendOptimistic(encodedContent: EncodedContent) {\n return this.#group.sendOptimistic(encodedContent);\n }\n\n async send(encodedContent: EncodedContent) {\n return this.#group.send(encodedContent);\n }\n\n async messages(options?: SafeListMessagesOptions) {\n return this.#group.findMessages(\n options ? fromSafeListMessagesOptions(options) : undefined,\n );\n }\n\n get consentState() {\n return this.#group.consentState();\n }\n\n updateConsentState(state: ConsentState) {\n this.#group.updateConsentState(state);\n }\n\n dmPeerInboxId() {\n return this.#group.dmPeerInboxId();\n }\n}\n","import type { Conversation, Conversations } from \"@xmtp/wasm-bindings\";\nimport {\n fromSafeCreateGroupOptions,\n fromSafeListConversationsOptions,\n type HmacKeys,\n type SafeCreateGroupOptions,\n type SafeListConversationsOptions,\n} from \"@/utils/conversions\";\nimport type { WorkerClient } from \"@/WorkerClient\";\nimport { WorkerConversation } from \"@/WorkerConversation\";\n\nexport class WorkerConversations {\n #client: WorkerClient;\n\n #conversations: Conversations;\n\n constructor(client: WorkerClient, conversations: Conversations) {\n this.#client = client;\n this.#conversations = conversations;\n }\n\n async sync() {\n return this.#conversations.sync();\n }\n\n async syncAll() {\n return this.#conversations.syncAllConversations();\n }\n\n getConversationById(id: string) {\n try {\n const group = this.#conversations.findGroupById(id);\n // findGroupById will throw if group is not found\n return new WorkerConversation(this.#client, group);\n } catch {\n return undefined;\n }\n }\n\n getMessageById(id: string) {\n try {\n // findMessageById will throw if message is not found\n return this.#conversations.findMessageById(id);\n } catch {\n return undefined;\n }\n }\n\n getDmByInboxId(inboxId: string) {\n try {\n const group = this.#conversations.findDmByTargetInboxId(inboxId);\n return new WorkerConversation(this.#client, group);\n } catch {\n return undefined;\n }\n }\n\n list(options?: SafeListConversationsOptions) {\n const groups = this.#conversations.list(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n listGroups(\n options?: Omit<SafeListConversationsOptions, \"conversation_type\">,\n ) {\n const groups = this.#conversations.listGroups(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n listDms(options?: Omit<SafeListConversationsOptions, \"conversation_type\">) {\n const groups = this.#conversations.listDms(\n options ? fromSafeListConversationsOptions(options) : undefined,\n ) as Conversation[];\n return groups.map((group) => new WorkerConversation(this.#client, group));\n }\n\n async newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions) {\n const group = await this.#conversations.createGroup(\n accountAddresses,\n options ? fromSafeCreateGroupOptions(options) : undefined,\n );\n return new WorkerConversation(this.#client, group);\n }\n\n async newDm(accountAddress: string) {\n const group = await this.#conversations.createDm(accountAddress);\n return new WorkerConversation(this.#client, group);\n }\n\n getHmacKeys() {\n return this.#conversations.getHmacKeys() as HmacKeys;\n }\n}\n","import {\n verifySignedWithPublicKey,\n type Client,\n type ConsentEntityType,\n type SignatureRequestType,\n} from \"@xmtp/wasm-bindings\";\nimport type { ClientOptions } from \"@/types\";\nimport { fromSafeConsent, type SafeConsent } from \"@/utils/conversions\";\nimport { createClient } from \"@/utils/createClient\";\nimport { WorkerConversations } from \"@/WorkerConversations\";\n\nexport class WorkerClient {\n #client: Client;\n\n #conversations: WorkerConversations;\n\n #accountAddress: string;\n\n constructor(client: Client) {\n this.#client = client;\n this.#accountAddress = client.accountAddress;\n this.#conversations = new WorkerConversations(this, client.conversations());\n }\n\n static async create(\n accountAddress: string,\n encryptionKey: Uint8Array,\n options?: Omit<ClientOptions, \"codecs\">,\n ) {\n const client = await createClient(accountAddress, encryptionKey, options);\n return new WorkerClient(client);\n }\n\n get accountAddress() {\n return this.#accountAddress;\n }\n\n get inboxId() {\n return this.#client.inboxId;\n }\n\n get installationId() {\n return this.#client.installationId;\n }\n\n get installationIdBytes() {\n return this.#client.installationIdBytes;\n }\n\n get isRegistered() {\n return this.#client.isRegistered;\n }\n\n async createInboxSignatureText() {\n try {\n return await this.#client.createInboxSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async addAccountSignatureText(accountAddress: string) {\n try {\n return await this.#client.addWalletSignatureText(accountAddress);\n } catch {\n return undefined;\n }\n }\n\n async removeAccountSignatureText(accountAddress: string) {\n try {\n return await this.#client.revokeWalletSignatureText(accountAddress);\n } catch {\n return undefined;\n }\n }\n\n async revokeAllAOtherInstallationsSignatureText() {\n try {\n return await this.#client.revokeAllOtherInstallationsSignatureText();\n } catch {\n return undefined;\n }\n }\n\n async revokeInstallationsSignatureText(installationIds: Uint8Array[]) {\n try {\n return await this.#client.revokeInstallationsSignatureText(\n installationIds,\n );\n } catch {\n return undefined;\n }\n }\n\n async addSignature(type: SignatureRequestType, bytes: Uint8Array) {\n return this.#client.addSignature(type, bytes);\n }\n\n async addScwSignature(\n type: SignatureRequestType,\n bytes: Uint8Array,\n chainId: bigint,\n blockNumber?: bigint,\n ) {\n return this.#client.addScwSignature(type, bytes, chainId, blockNumber);\n }\n\n async applySignatures() {\n return this.#client.applySignatureRequests();\n }\n\n async canMessage(accountAddresses: string[]) {\n return this.#client.canMessage(accountAddresses) as Promise<\n Map<string, boolean>\n >;\n }\n\n async registerIdentity() {\n return this.#client.registerIdentity();\n }\n\n async findInboxIdByAddress(address: string) {\n return this.#client.findInboxIdByAddress(address);\n }\n\n async inboxState(refreshFromNetwork: boolean) {\n return this.#client.inboxState(refreshFromNetwork);\n }\n\n async getLatestInboxState(inboxId: string) {\n return this.#client.getLatestInboxState(inboxId);\n }\n\n async setConsentStates(records: SafeConsent[]) {\n return this.#client.setConsentStates(records.map(fromSafeConsent));\n }\n\n async getConsentState(entityType: ConsentEntityType, entity: string) {\n return this.#client.getConsentState(entityType, entity);\n }\n\n get conversations() {\n return this.#conversations;\n }\n\n signWithInstallationKey(signatureText: string) {\n return this.#client.signWithInstallationKey(signatureText);\n }\n\n verifySignedWithInstallationKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n ) {\n try {\n this.#client.verifySignedWithInstallationKey(\n signatureText,\n signatureBytes,\n );\n return true;\n } catch {\n return false;\n }\n }\n\n verifySignedWithPublicKey(\n signatureText: string,\n signatureBytes: Uint8Array,\n publicKey: Uint8Array,\n ) {\n try {\n verifySignedWithPublicKey(signatureText, signatureBytes, publicKey);\n return true;\n } catch {\n return false;\n }\n }\n}\n","import init, {\n createClient as createWasmClient,\n generateInboxId,\n getInboxIdForAddress,\n LogOptions,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls, HistorySyncUrls } 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 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 const historySyncUrl =\n options?.historySyncUrl ?? HistorySyncUrls[options?.env ?? \"dev\"];\n\n return createWasmClient(\n host,\n inboxId,\n accountAddress,\n dbPath,\n encryptionKey,\n historySyncUrl,\n isLogging\n ? new LogOptions(\n options.structuredLogging ?? false,\n options.performanceLogging ?? false,\n options.loggingLevel,\n )\n : undefined,\n );\n};\n","import type {\n ClientEventsActions,\n ClientEventsClientMessageData,\n ClientEventsErrorData,\n ClientEventsWorkerPostMessageData,\n} from \"@/types\";\nimport {\n fromEncodedContent,\n fromSafeEncodedContent,\n toSafeConversation,\n toSafeHmacKey,\n toSafeInboxState,\n toSafeMessage,\n} from \"@/utils/conversions\";\nimport { WorkerClient } from \"@/WorkerClient\";\n\nlet client: WorkerClient;\nlet enableLogging = false;\n\n/**\n * Type-safe postMessage\n */\nconst postMessage = <A extends ClientEventsActions>(\n data: ClientEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for errors\n */\nconst postMessageError = (data: ClientEventsErrorData) => {\n self.postMessage(data);\n};\n\nself.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {\n const { action, id, data } = event.data;\n\n if (enableLogging) {\n console.log(\"client worker received event data\", event.data);\n }\n\n // a client is required for all actions except init\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (action !== \"init\" && !client) {\n postMessageError({\n id,\n action,\n error: \"Client not initialized\",\n });\n return;\n }\n\n try {\n switch (action) {\n /**\n * Client actions\n */\n case \"init\":\n client = await WorkerClient.create(\n data.address,\n data.encryptionKey,\n data.options,\n );\n enableLogging =\n data.options?.loggingLevel !== undefined &&\n data.options.loggingLevel !== \"off\";\n postMessage({\n id,\n action,\n result: {\n inboxId: client.inboxId,\n installationId: client.installationId,\n installationIdBytes: client.installationIdBytes,\n },\n });\n break;\n case \"createInboxSignatureText\": {\n const result = await client.createInboxSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addAccountSignatureText\": {\n const result = await client.addAccountSignatureText(\n data.newAccountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"removeAccountSignatureText\": {\n const result = await client.removeAccountSignatureText(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"revokeAllOtherInstallationsSignatureText\": {\n const result = await client.revokeAllAOtherInstallationsSignatureText();\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"revokeInstallationsSignatureText\": {\n const result = await client.revokeInstallationsSignatureText(\n data.installationIds,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"addSignature\":\n await client.addSignature(data.type, data.bytes);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"addScwSignature\":\n await client.addScwSignature(\n data.type,\n data.bytes,\n data.chainId,\n data.blockNumber,\n );\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"applySignatures\":\n await client.applySignatures();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"registerIdentity\":\n await client.registerIdentity();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n case \"isRegistered\": {\n const result = client.isRegistered;\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"canMessage\": {\n const result = await client.canMessage(data.accountAddresses);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"inboxState\": {\n const result = await client.inboxState(data.refreshFromNetwork);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"getLatestInboxState\": {\n const result = await client.getLatestInboxState(data.inboxId);\n postMessage({\n id,\n action,\n result: toSafeInboxState(result),\n });\n break;\n }\n case \"setConsentStates\": {\n await client.setConsentStates(data.records);\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConsentState\": {\n const result = await client.getConsentState(\n data.entityType,\n data.entity,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"findInboxIdByAddress\": {\n const result = await client.findInboxIdByAddress(data.address);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"signWithInstallationKey\": {\n const result = client.signWithInstallationKey(data.signatureText);\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"verifySignedWithInstallationKey\": {\n const result = client.verifySignedWithInstallationKey(\n data.signatureText,\n data.signatureBytes,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n case \"verifySignedWithPublicKey\": {\n const result = client.verifySignedWithPublicKey(\n data.signatureText,\n data.signatureBytes,\n data.publicKey,\n );\n postMessage({\n id,\n action,\n result,\n });\n break;\n }\n /**\n * Conversations actions\n */\n case \"getConversations\": {\n const conversations = client.conversations.list(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"getGroups\": {\n const conversations = client.conversations.listGroups(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"getDms\": {\n const conversations = client.conversations.listDms(data.options);\n postMessage({\n id,\n action,\n result: await Promise.all(\n conversations.map((conversation) =>\n toSafeConversation(conversation),\n ),\n ),\n });\n break;\n }\n case \"newGroup\": {\n const conversation = await client.conversations.newGroup(\n data.accountAddresses,\n data.options,\n );\n postMessage({\n id,\n action,\n result: await toSafeConversation(conversation),\n });\n break;\n }\n case \"newDm\": {\n const conversation = await client.conversations.newDm(\n data.accountAddress,\n );\n postMessage({\n id,\n action,\n result: await toSafeConversation(conversation),\n });\n break;\n }\n case \"syncConversations\": {\n await client.conversations.sync();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"syncAllConversations\": {\n await client.conversations.syncAll();\n postMessage({\n id,\n action,\n result: undefined,\n });\n break;\n }\n case \"getConversationById\": {\n const conversation = client.conversations.getConversationById(data.id);\n postMessage({\n id,\n action,\n result: conversation\n ? await toSafeConversation(conversation)\n : undefined,\n });\n break;\n }\n case \"getMessageById\": {\n const message = client.conversations.getMessageById(data.id);\n postMessage({\n id,\n action,\n result: message ? toSafeMessage(message) : undefined,\n });\n break;\n }\n case \"getDmByInboxId\": {\n const conversation = client.conversations.getDmByInboxId(data.inboxId);\n postMessage({\n id,\n action,\n result: conversation\n ? await toSafeConversation(conversation)\n : undefined,\n });\n break;\n }\n case \"getHmacKeys\": {\n const result = client.conversations.getHmacKeys();\n postMessage({\n id,\n action,\n result: Object.fromEntries(\n Array.from(result.entries()).map(([groupId, hmacKeys]) => [\n groupId,\n hmacKeys.map(toSafeHmacKey),\n ]),\n ),\n });\n break;\n }\n /**\n * Group actions\n */\n case \"syncGroup\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.sync();\n postMessage({\n id,\n action,\n result: await toSafeConversation(group),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupName\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateName(data.name);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupDescription\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateDescription(data.description);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupImageUrlSquare\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updateImageUrl(data.imageUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPinnedFrameUrl\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePinnedFrameUrl(data.pinnedFrameUrl);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.send(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"sendOptimisticGroupMessage\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.sendOptimistic(\n fromEncodedContent(fromSafeEncodedContent(data.content)),\n );\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"publishGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.publishMessages();\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMessages\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const messages = await group.messages(data.options);\n postMessage({\n id,\n action,\n result: messages.map((message) => toSafeMessage(message)),\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = await group.members();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.admins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupSuperAdmins\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.superAdmins,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n postMessage({\n id,\n action,\n result: group.consentState,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupConsentState\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n group.updateConsentState(data.state);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembers\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembers(data.accountAddresses);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"addGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.addMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"removeGroupMembersByInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.removeMembersByInboxId(data.inboxIds);\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"isGroupSuperAdmin\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.isSuperAdmin(data.inboxId);\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getDmPeerInboxId\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const result = group.dmPeerInboxId();\n postMessage({\n id,\n action,\n result,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"updateGroupPermissionPolicy\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n await group.updatePermission(\n data.permissionType,\n data.policy,\n data.metadataField,\n );\n postMessage({\n id,\n action,\n result: undefined,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n case \"getGroupPermissions\": {\n const group = client.conversations.getConversationById(data.id);\n if (group) {\n const safeConversation = await toSafeConversation(group);\n postMessage({\n id,\n action,\n result: safeConversation.permissions,\n });\n } else {\n postMessageError({\n id,\n action,\n error: \"Group not found\",\n });\n }\n break;\n }\n }\n } catch (e) {\n postMessageError({\n id,\n action,\n error: (e as Error).message,\n });\n }\n};\n"],"names":["fromEncodedContent","content","WasmEncodedContent","contentTypeId","type","WasmContentTypeId","authorityId","typeId","versionMajor","versionMinor","Map","Object","entries","parameters","fallback","compression","toSafeEncodedContent","fromSafeEncodedContent","ContentTypeId","toSafeMessage","message","fromEntries","convoId","deliveryStatus","id","kind","senderInboxId","sentAtNs","fromSafeListConversationsOptions","options","ListConversationsOptions","allowedStates","conversationType","createdAfterNs","createdBeforeNs","limit","fromSafeCreateGroupOptions","CreateGroupOptions","permissions","name","imageUrlSquare","description","pinnedFrameUrl","customPermissionPolicySet","GroupPermissionsOptions","CustomPolicy","policySet","PermissionPolicySet","addMemberPolicy","removeMemberPolicy","addAdminPolicy","removeAdminPolicy","updateGroupNamePolicy","updateGroupDescriptionPolicy","updateGroupImageUrlSquarePolicy","updateGroupPinnedFrameUrlPolicy","updateMessageExpirationPolicy","undefined","toSafeConversation","async","conversation","imageUrl","policyType","isActive","addedByInboxId","metadata","admins","superAdmins","createdAtNs","toSafeInstallation","installation","bytes","clientTimestampNs","toSafeInboxState","inboxState","accountAddresses","inboxId","installations","map","recoveryAddress","fromSafeConsent","consent","Consent","entityType","state","entity","toSafeHmacKey","hmacKey","key","epoch","ApiUrls","local","dev","production","HistorySyncUrls","WorkerConversation","client","group","constructor","this","groupName","updateName","updateGroupName","groupImageUrlSquare","updateImageUrl","updateGroupImageUrlSquare","groupDescription","updateDescription","updateGroupDescription","groupPinnedFrameUrl","updatePinnedFrameUrl","updateGroupPinnedFrameUrl","groupMetadata","creatorInboxId","members","listMembers","member","consentState","installationIds","permissionLevel","toSafeGroupMember","adminList","superAdminList","groupPermissions","updatePermission","permissionType","policy","metadataField","updatePermissionPolicy","isAdmin","isSuperAdmin","sync","addMembers","addMembersByInboxId","inboxIds","removeMembers","removeMembersByInboxId","addAdmin","removeAdmin","addSuperAdmin","removeSuperAdmin","publishMessages","sendOptimistic","encodedContent","send","messages","findMessages","ListMessagesOptions","sentBeforeNs","sentAfterNs","direction","fromSafeListMessagesOptions","updateConsentState","dmPeerInboxId","WorkerConversations","conversations","syncAll","syncAllConversations","getConversationById","findGroupById","getMessageById","findMessageById","getDmByInboxId","findDmByTargetInboxId","list","listGroups","listDms","newGroup","createGroup","newDm","accountAddress","createDm","getHmacKeys","WorkerClient","create","encryptionKey","init","host","apiUrl","env","dbPath","getInboxIdForAddress","generateInboxId","isLogging","loggingLevel","structuredLogging","performanceLogging","createWasmClient","historySyncUrl","LogOptions","createClient","installationId","installationIdBytes","isRegistered","createInboxSignatureText","addAccountSignatureText","addWalletSignatureText","removeAccountSignatureText","revokeWalletSignatureText","revokeAllAOtherInstallationsSignatureText","revokeAllOtherInstallationsSignatureText","revokeInstallationsSignatureText","addSignature","addScwSignature","chainId","blockNumber","applySignatures","applySignatureRequests","canMessage","registerIdentity","findInboxIdByAddress","address","refreshFromNetwork","getLatestInboxState","setConsentStates","records","getConsentState","signWithInstallationKey","signatureText","verifySignedWithInstallationKey","signatureBytes","verifySignedWithPublicKey","publicKey","enableLogging","postMessage","data","self","postMessageError","onmessage","event","action","console","log","result","newAccountAddress","Promise","all","Array","from","groupId","hmacKeys","error","safeConversation","e"],"mappings":"2YA8BO,MAyDMA,EACXC,IAEA,WAAIC,GAjDJC,EAkDoBF,EAAQG,KAhD5B,IAAIC,EACFF,EAAcG,YACdH,EAAcI,OACdJ,EAAcK,aACdL,EAAcM,eA6Cd,IAAIC,IAAIC,OAAOC,QAAQX,EAAQY,aAC/BZ,EAAQa,SACRb,EAAQc,YACRd,EAAQA,SAvDqB,IAC/BE,CAuDC,EAUUa,EACXf,IACwB,OACxBG,MAnDAD,EAmD0BF,EAAQG,KAlDX,CACvBE,YAAaH,EAAcG,YAC3BC,OAAQJ,EAAcI,OACtBC,aAAcL,EAAcK,aAC5BC,aAAcN,EAAcM,eA+C5BI,WAAYZ,EAAQY,WACpBC,SAAUb,EAAQa,SAClBC,YAAad,EAAQc,YACrBd,QAASA,EAAQA,SAxDgB,IACjCE,CAwDA,EAEWc,EACXhB,IACoB,OACpBG,MApDAD,EAoD4BF,EA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,cAAcG,oBAAoBmE,EAAKzM,IAC5D,GAAIyE,EAAO,CACT,MAAMiJ,QAAyBxL,EAAmBuC,GAClD+H,EAAY,CACVxM,KACA8M,SACAG,OAAQS,EAAiB5M,mBAG3B6L,EAAiB,CACf3M,KACA8M,SACAW,MAAO,oBAGX,QAGJ,MAAOE,GACPhB,EAAiB,CACf3M,KACA8M,SACAW,MAAQE,EAAY/N,eA/0BtB+M,EAAiB,CACf3M,KACA8M,SACAW,MAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/constants.ts","../../src/workers/utils.ts"],"sourcesContent":["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 init, {\n generateInboxId as generate_inbox_id,\n getInboxIdForAddress as get_inbox_id_for_address,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls } from \"@/constants\";\nimport type {\n UtilsEventsActions,\n UtilsEventsClientMessageData,\n UtilsEventsErrorData,\n UtilsEventsWorkerPostMessageData,\n XmtpEnv,\n} from \"@/types\";\n\n/**\n * Type-safe postMessage\n */\nconst postMessage = <A extends UtilsEventsActions>(\n data: UtilsEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for errors\n */\nconst postMessageError = (data: UtilsEventsErrorData) => {\n self.postMessage(data);\n};\n\nexport const generateInboxId = async (address: string) => {\n await init();\n return generate_inbox_id(address);\n};\n\nexport const getInboxIdForAddress = async (address: string, env?: XmtpEnv) => {\n await init();\n const host = env ? ApiUrls[env] : ApiUrls.dev;\n return get_inbox_id_for_address(host, address);\n};\n\nself.onmessage = async (event: MessageEvent<UtilsEventsClientMessageData>) => {\n const { action, id, data } = event.data;\n if (data.enableLogging) {\n console.log(\"utils worker received event data\", event.data);\n }\n\n try {\n switch (action) {\n case \"generateInboxId\":\n postMessage({\n id,\n action,\n result: await generateInboxId(data.address),\n });\n break;\n case \"getInboxIdForAddress\":\n postMessage({\n id,\n action,\n result: await getInboxIdForAddress(data.address, data.env),\n });\n break;\n // no default\n }\n } catch (e) {\n postMessageError({\n id,\n action,\n error: (e as Error).message,\n });\n }\n};\n"],"names":["ApiUrls","local","dev","production","postMessage","data","self","generateInboxId","async","address","init","generate_inbox_id","getInboxIdForAddress","env","get_inbox_id_for_address","onmessage","event","action","id","enableLogging","console","log","result","e","postMessageError","error","message"],"mappings":"mFAAO,MAAMA,EAAU,CACrBC,MAAO,wBACPC,IAAK,2BACLC,WAAY,mCCaRC,EACJC,IAEAC,KAAKF,YAAYC,EAAK,EAUXE,EAAkBC,MAAOC,UAC9BC,IACCC,EAAkBF,IAGdG,EAAuBJ,MAAOC,EAAiBI,WACpDH,IAEN,OAAOI,EADMD,EAAMb,EAAQa,GAAOb,EAAQE,IACJO,EAAQ,EAGhDH,KAAKS,UAAYP,MAAOQ,IACtB,MAAMC,OAAEA,EAAMC,GAAEA,EAAEb,KAAEA,GAASW,EAAMX,KAC/BA,EAAKc,eACPC,QAAQC,IAAI,mCAAoCL,EAAMX,MAGxD,IACE,OAAQY,GACN,IAAK,kBACHb,EAAY,CACVc,KACAD,SACAK,aAAcf,EAAgBF,EAAKI,WAErC,MACF,IAAK,uBACHL,EAAY,CACVc,KACAD,SACAK,aAAcV,EAAqBP,EAAKI,QAASJ,EAAKQ,QAK5D,MAAOU,GAvCc,CAAClB,IACxBC,KAAKF,YAAYC,EAAK,EAuCpBmB,CAAiB,CACfN,KACAD,SACAQ,MAAQF,EAAYG"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/constants.ts","../../src/workers/utils.ts"],"sourcesContent":["export const ApiUrls = {\n local: \"http://localhost:5555\",\n dev: \"https://dev.xmtp.network\",\n production: \"https://production.xmtp.network\",\n} as const;\n\nexport const HistorySyncUrls = {\n local: \"http://localhost:5558\",\n dev: \"https://message-history.dev.ephemera.network\",\n production: \"https://message-history.production.ephemera.network\",\n} as const;\n","import init, {\n generateInboxId as generate_inbox_id,\n getInboxIdForAddress as get_inbox_id_for_address,\n} from \"@xmtp/wasm-bindings\";\nimport { ApiUrls } from \"@/constants\";\nimport type {\n UtilsEventsActions,\n UtilsEventsClientMessageData,\n UtilsEventsErrorData,\n UtilsEventsWorkerPostMessageData,\n XmtpEnv,\n} from \"@/types\";\n\n/**\n * Type-safe postMessage\n */\nconst postMessage = <A extends UtilsEventsActions>(\n data: UtilsEventsWorkerPostMessageData<A>,\n) => {\n self.postMessage(data);\n};\n\n/**\n * Type-safe postMessage for errors\n */\nconst postMessageError = (data: UtilsEventsErrorData) => {\n self.postMessage(data);\n};\n\nexport const generateInboxId = async (address: string) => {\n await init();\n return generate_inbox_id(address);\n};\n\nexport const getInboxIdForAddress = async (address: string, env?: XmtpEnv) => {\n await init();\n const host = env ? ApiUrls[env] : ApiUrls.dev;\n return get_inbox_id_for_address(host, address);\n};\n\nself.onmessage = async (event: MessageEvent<UtilsEventsClientMessageData>) => {\n const { action, id, data } = event.data;\n if (data.enableLogging) {\n console.log(\"utils worker received event data\", event.data);\n }\n\n try {\n switch (action) {\n case \"generateInboxId\":\n postMessage({\n id,\n action,\n result: await generateInboxId(data.address),\n });\n break;\n case \"getInboxIdForAddress\":\n postMessage({\n id,\n action,\n result: await getInboxIdForAddress(data.address, data.env),\n });\n break;\n // no default\n }\n } catch (e) {\n postMessageError({\n id,\n action,\n error: (e as Error).message,\n });\n }\n};\n"],"names":["ApiUrls","local","dev","production","postMessage","data","self","generateInboxId","async","address","init","generate_inbox_id","getInboxIdForAddress","env","get_inbox_id_for_address","onmessage","event","action","id","enableLogging","console","log","result","e","postMessageError","error","message"],"mappings":"mFAAO,MAAMA,EAAU,CACrBC,MAAO,wBACPC,IAAK,2BACLC,WAAY,mCCaRC,EACJC,IAEAC,KAAKF,YAAYC,EAAK,EAUXE,EAAkBC,MAAOC,UAC9BC,IACCC,EAAkBF,IAGdG,EAAuBJ,MAAOC,EAAiBI,WACpDH,IAEN,OAAOI,EADMD,EAAMb,EAAQa,GAAOb,EAAQE,IACJO,EAAQ,EAGhDH,KAAKS,UAAYP,MAAOQ,IACtB,MAAMC,OAAEA,EAAMC,GAAEA,EAAEb,KAAEA,GAASW,EAAMX,KAC/BA,EAAKc,eACPC,QAAQC,IAAI,mCAAoCL,EAAMX,MAGxD,IACE,OAAQY,GACN,IAAK,kBACHb,EAAY,CACVc,KACAD,SACAK,aAAcf,EAAgBF,EAAKI,WAErC,MACF,IAAK,uBACHL,EAAY,CACVc,KACAD,SACAK,aAAcV,EAAqBP,EAAKI,QAASJ,EAAKQ,QAK5D,MAAOU,GAvCc,CAAClB,IACxBC,KAAKF,YAAYC,EAAK,EAuCpBmB,CAAiB,CACfN,KACAD,SACAQ,MAAQF,EAAYG"}
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -3,3 +3,9 @@ export const ApiUrls = {
|
|
|
3
3
|
dev: "https://dev.xmtp.network",
|
|
4
4
|
production: "https://production.xmtp.network",
|
|
5
5
|
} as const;
|
|
6
|
+
|
|
7
|
+
export const HistorySyncUrls = {
|
|
8
|
+
local: "http://localhost:5558",
|
|
9
|
+
dev: "https://message-history.dev.ephemera.network",
|
|
10
|
+
production: "https://message-history.production.ephemera.network",
|
|
11
|
+
} as const;
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { Conversation } from "./Conversation";
|
|
|
4
4
|
export type { MessageDeliveryStatus, MessageKind } from "./DecodedMessage";
|
|
5
5
|
export { DecodedMessage } from "./DecodedMessage";
|
|
6
6
|
export { Utils } from "./Utils";
|
|
7
|
-
export { ApiUrls } from "./constants";
|
|
7
|
+
export { ApiUrls, HistorySyncUrls } from "./constants";
|
|
8
8
|
export type * from "./types";
|
|
9
9
|
export * from "./utils/conversions";
|
|
10
10
|
export {
|
package/src/types/options.ts
CHANGED
|
@@ -16,6 +16,18 @@ export type NetworkOptions = {
|
|
|
16
16
|
* specific endpoint
|
|
17
17
|
*/
|
|
18
18
|
apiUrl?: string;
|
|
19
|
+
/**
|
|
20
|
+
* historySyncUrl can be used to override the `env` flag and connect to a
|
|
21
|
+
* specific endpoint for syncing history
|
|
22
|
+
*/
|
|
23
|
+
historySyncUrl?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type ContentOptions = {
|
|
27
|
+
/**
|
|
28
|
+
* Allow configuring codecs for additional content types
|
|
29
|
+
*/
|
|
30
|
+
codecs?: ContentCodec[];
|
|
19
31
|
};
|
|
20
32
|
|
|
21
33
|
/**
|
|
@@ -28,13 +40,6 @@ export type StorageOptions = {
|
|
|
28
40
|
dbPath?: string;
|
|
29
41
|
};
|
|
30
42
|
|
|
31
|
-
export type ContentOptions = {
|
|
32
|
-
/**
|
|
33
|
-
* Allow configuring codecs for additional content types
|
|
34
|
-
*/
|
|
35
|
-
codecs?: ContentCodec[];
|
|
36
|
-
};
|
|
37
|
-
|
|
38
43
|
export type OtherOptions = {
|
|
39
44
|
/**
|
|
40
45
|
* Enable structured JSON logging
|
|
@@ -55,6 +60,6 @@ export type OtherOptions = {
|
|
|
55
60
|
};
|
|
56
61
|
|
|
57
62
|
export type ClientOptions = NetworkOptions &
|
|
58
|
-
StorageOptions &
|
|
59
63
|
ContentOptions &
|
|
64
|
+
StorageOptions &
|
|
60
65
|
OtherOptions;
|
|
@@ -4,7 +4,7 @@ import init, {
|
|
|
4
4
|
getInboxIdForAddress,
|
|
5
5
|
LogOptions,
|
|
6
6
|
} from "@xmtp/wasm-bindings";
|
|
7
|
-
import { ApiUrls } from "@/constants";
|
|
7
|
+
import { ApiUrls, HistorySyncUrls } from "@/constants";
|
|
8
8
|
import type { ClientOptions } from "@/types";
|
|
9
9
|
|
|
10
10
|
export const createClient = async (
|
|
@@ -16,10 +16,6 @@ export const createClient = async (
|
|
|
16
16
|
await init();
|
|
17
17
|
|
|
18
18
|
const host = options?.apiUrl ?? ApiUrls[options?.env ?? "dev"];
|
|
19
|
-
// TODO: add db path validation
|
|
20
|
-
// - must end with .db3
|
|
21
|
-
// - must not contain invalid characters
|
|
22
|
-
// - must not start with a dot
|
|
23
19
|
const dbPath =
|
|
24
20
|
options?.dbPath ?? `xmtp-${options?.env ?? "dev"}-${accountAddress}.db3`;
|
|
25
21
|
|
|
@@ -33,13 +29,16 @@ export const createClient = async (
|
|
|
33
29
|
options.structuredLogging ||
|
|
34
30
|
options.performanceLogging);
|
|
35
31
|
|
|
32
|
+
const historySyncUrl =
|
|
33
|
+
options?.historySyncUrl ?? HistorySyncUrls[options?.env ?? "dev"];
|
|
34
|
+
|
|
36
35
|
return createWasmClient(
|
|
37
36
|
host,
|
|
38
37
|
inboxId,
|
|
39
38
|
accountAddress,
|
|
40
39
|
dbPath,
|
|
41
40
|
encryptionKey,
|
|
42
|
-
|
|
41
|
+
historySyncUrl,
|
|
43
42
|
isLogging
|
|
44
43
|
? new LogOptions(
|
|
45
44
|
options.structuredLogging ?? false,
|