@xmtp/browser-sdk 5.1.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,6 +21,7 @@ import type {
21
21
  import {
22
22
  fromEncodedContent,
23
23
  fromSafeEncodedContent,
24
+ fromSafeSendMessageOpts,
24
25
  toSafeApiStats,
25
26
  toSafeConsent,
26
27
  toSafeConversation,
@@ -203,10 +204,12 @@ self.onmessage = async (
203
204
  const signatureRequest =
204
205
  await client.revokeAllOtherInstallationsSignatureRequest();
205
206
  const result = {
206
- signatureText: await signatureRequest.signatureText(),
207
+ signatureText: await signatureRequest?.signatureText(),
207
208
  signatureRequestId: data.signatureRequestId,
208
209
  };
209
- signatureRequests.set(data.signatureRequestId, signatureRequest);
210
+ if (signatureRequest) {
211
+ signatureRequests.set(data.signatureRequestId, signatureRequest);
212
+ }
210
213
  postMessage({ id, action, result });
211
214
  break;
212
215
  }
@@ -350,6 +353,16 @@ self.onmessage = async (
350
353
  });
351
354
  break;
352
355
  }
356
+ case "client.libxmtpVersion": {
357
+ const result = client.libxmtpVersion;
358
+ postMessage({ id, action, result });
359
+ break;
360
+ }
361
+ case "client.appVersion": {
362
+ const result = client.appVersion;
363
+ postMessage({ id, action, result });
364
+ break;
365
+ }
353
366
  /**
354
367
  * Debug information actions
355
368
  */
@@ -597,6 +610,32 @@ self.onmessage = async (
597
610
  postMessage({ id, action, result: undefined });
598
611
  break;
599
612
  }
613
+ case "conversations.streamMessageDeletions": {
614
+ const streamCallback = (
615
+ error: Error | null,
616
+ value: string | undefined,
617
+ ) => {
618
+ if (error) {
619
+ streamClosers.delete(data.streamId);
620
+ postStreamMessageError({
621
+ action: "stream.messageDeleted",
622
+ streamId: data.streamId,
623
+ error,
624
+ });
625
+ } else {
626
+ postStreamMessage({
627
+ action: "stream.messageDeleted",
628
+ streamId: data.streamId,
629
+ result: value,
630
+ });
631
+ }
632
+ };
633
+ const streamCloser =
634
+ client.conversations.streamMessageDeletions(streamCallback);
635
+ streamClosers.set(data.streamId, streamCloser);
636
+ postMessage({ id, action, result: undefined });
637
+ break;
638
+ }
600
639
  case "conversations.list": {
601
640
  const conversations = client.conversations.list(data.options);
602
641
  const result = await Promise.all(
@@ -764,10 +803,17 @@ self.onmessage = async (
764
803
  postMessage({ id, action, result: undefined });
765
804
  break;
766
805
  }
806
+ case "group.updateAppData": {
807
+ const group = getGroup(data.id);
808
+ await group.updateAppData(data.appData);
809
+ postMessage({ id, action, result: undefined });
810
+ break;
811
+ }
767
812
  case "conversation.send": {
768
813
  const group = getGroup(data.id);
769
814
  const result = await group.send(
770
815
  fromEncodedContent(fromSafeEncodedContent(data.content)),
816
+ fromSafeSendMessageOpts(data.sendOptions),
771
817
  );
772
818
  postMessage({ id, action, result });
773
819
  break;
@@ -776,6 +822,7 @@ self.onmessage = async (
776
822
  const group = getGroup(data.id);
777
823
  const result = group.sendOptimistic(
778
824
  fromEncodedContent(fromSafeEncodedContent(data.content)),
825
+ fromSafeSendMessageOpts(data.sendOptions),
779
826
  );
780
827
  postMessage({ id, action, result });
781
828
  break;
@@ -793,6 +840,12 @@ self.onmessage = async (
793
840
  postMessage({ id, action, result });
794
841
  break;
795
842
  }
843
+ case "conversation.countMessages": {
844
+ const group = getGroup(data.id);
845
+ const result = await group.countMessages(data.options);
846
+ postMessage({ id, action, result });
847
+ break;
848
+ }
796
849
  case "conversation.members": {
797
850
  const group = getGroup(data.id);
798
851
  const result = await group.members();
@@ -894,6 +947,18 @@ self.onmessage = async (
894
947
  postMessage({ id, action, result });
895
948
  break;
896
949
  }
950
+ case "group.requestRemoval": {
951
+ const group = getGroup(data.id);
952
+ await group.requestRemoval();
953
+ postMessage({ id, action, result: undefined });
954
+ break;
955
+ }
956
+ case "group.isPendingRemoval": {
957
+ const group = getGroup(data.id);
958
+ const result = group.isPendingRemoval;
959
+ postMessage({ id, action, result });
960
+ break;
961
+ }
897
962
  case "conversation.messageDisappearingSettings": {
898
963
  const group = getGroup(data.id);
899
964
  const settings = group.messageDisappearingSettings();
@@ -39,9 +39,10 @@ const postMessageError = (data: ActionErrorData<UtilsWorkerAction>) => {
39
39
  const getInboxIdForIdentifier = async (
40
40
  identifier: Identifier,
41
41
  env?: XmtpEnv,
42
+ gatewayHost?: string,
42
43
  ) => {
43
44
  const host = env ? ApiUrls[env] : ApiUrls.dev;
44
- return get_inbox_id_for_identifier(host, identifier);
45
+ return get_inbox_id_for_identifier(host, gatewayHost ?? null, identifier);
45
46
  };
46
47
 
47
48
  let enableLogging = false;
@@ -75,14 +76,19 @@ self.onmessage = async (
75
76
  break;
76
77
  }
77
78
  case "utils.getInboxIdForIdentifier": {
78
- const result = await getInboxIdForIdentifier(data.identifier, data.env);
79
+ const result = await getInboxIdForIdentifier(
80
+ data.identifier,
81
+ data.env,
82
+ data.gatewayHost,
83
+ );
79
84
  postMessage({ id, action, result });
80
85
  break;
81
86
  }
82
87
  case "utils.revokeInstallationsSignatureText": {
83
88
  const host = ApiUrls[data.env ?? "dev"];
84
- const signatureRequest = await revokeInstallationsSignatureRequest(
89
+ const signatureRequest = revokeInstallationsSignatureRequest(
85
90
  host,
91
+ data.gatewayHost,
86
92
  data.identifier,
87
93
  data.inboxId,
88
94
  data.installationIds,
@@ -115,15 +121,24 @@ self.onmessage = async (
115
121
  );
116
122
  break;
117
123
  }
118
- await applySignatureRequest(host, signatureRequest);
124
+ await applySignatureRequest(
125
+ host,
126
+ data.gatewayHost ?? null,
127
+ signatureRequest,
128
+ );
119
129
  signatureRequests.delete(data.signatureRequestId);
120
- postMessage({ id, action, result: undefined });
130
+ postMessage({ id, action, result: [] });
121
131
  break;
122
132
  }
133
+
123
134
  case "utils.inboxStateFromInboxIds": {
124
135
  const host = ApiUrls[data.env ?? "dev"];
125
136
  try {
126
- const inboxStates = await inboxStateFromInboxIds(host, data.inboxIds);
137
+ const inboxStates = await inboxStateFromInboxIds(
138
+ host,
139
+ data.gatewayHost ?? null,
140
+ data.inboxIds,
141
+ );
127
142
  const result = inboxStates.map((inboxState) =>
128
143
  toSafeInboxState(inboxState),
129
144
  );