@xmtp/browser-sdk 5.2.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/index.d.ts +587 -670
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/workers/client.js +1 -1
  5. package/dist/workers/client.js.map +1 -1
  6. package/dist/workers/opfs.js +2 -0
  7. package/dist/workers/opfs.js.map +1 -0
  8. package/package.json +12 -16
  9. package/src/Client.ts +92 -219
  10. package/src/CodecRegistry.ts +27 -0
  11. package/src/Conversation.ts +275 -104
  12. package/src/Conversations.ts +188 -99
  13. package/src/DebugInformation.ts +10 -27
  14. package/src/DecodedMessage.ts +155 -58
  15. package/src/Dm.ts +25 -9
  16. package/src/Group.ts +69 -26
  17. package/src/Opfs.ts +63 -0
  18. package/src/Preferences.ts +68 -52
  19. package/src/WorkerClient.ts +5 -5
  20. package/src/WorkerConversation.ts +119 -44
  21. package/src/WorkerConversations.ts +35 -74
  22. package/src/WorkerDebugInformation.ts +1 -12
  23. package/src/WorkerPreferences.ts +6 -14
  24. package/src/index.ts +53 -24
  25. package/src/types/actions/client.ts +6 -17
  26. package/src/types/actions/conversation.ts +160 -31
  27. package/src/types/actions/conversations.ts +21 -24
  28. package/src/types/actions/debugInformation.ts +3 -11
  29. package/src/types/actions/dm.ts +1 -1
  30. package/src/types/actions/group.ts +25 -0
  31. package/src/types/actions/opfs.ts +66 -0
  32. package/src/types/actions/preferences.ts +6 -13
  33. package/src/types/actions/streams.ts +8 -8
  34. package/src/types/actions.ts +11 -9
  35. package/src/types/options.ts +47 -6
  36. package/src/{ClientWorkerClass.ts → utils/WorkerBridge.ts} +35 -45
  37. package/src/utils/contentTypes.ts +77 -0
  38. package/src/utils/conversions.ts +18 -588
  39. package/src/utils/createClient.ts +16 -11
  40. package/src/utils/errors.ts +13 -19
  41. package/src/utils/inboxId.ts +46 -0
  42. package/src/utils/inboxState.ts +23 -0
  43. package/src/utils/installations.ts +95 -0
  44. package/src/utils/metadata.ts +15 -0
  45. package/src/utils/signer.ts +4 -4
  46. package/src/utils/uuid.ts +8 -0
  47. package/src/workers/client.ts +191 -132
  48. package/src/workers/opfs.ts +127 -0
  49. package/dist/workers/utils.js +0 -2
  50. package/dist/workers/utils.js.map +0 -1
  51. package/src/Utils.ts +0 -143
  52. package/src/UtilsWorkerClass.ts +0 -121
  53. package/src/types/actions/utils.ts +0 -69
  54. package/src/workers/utils.ts +0 -155
@@ -1,72 +1,85 @@
1
- import type { ConsentEntityType, UserPreference } from "@xmtp/wasm-bindings";
2
- import { v4 } from "uuid";
3
- import type { SafeConsent } from "@/utils/conversions";
1
+ import type {
2
+ Consent,
3
+ ConsentEntityType,
4
+ ConsentState,
5
+ UserPreferenceUpdate,
6
+ } from "@xmtp/wasm-bindings";
7
+ import type { ClientWorkerAction } from "@/types/actions";
4
8
  import {
5
9
  createStream,
6
10
  type StreamCallback,
7
11
  type StreamOptions,
8
12
  } from "@/utils/streams";
9
- import type { Client } from "./Client";
13
+ import { uuid } from "@/utils/uuid";
14
+ import type { WorkerBridge } from "@/utils/WorkerBridge";
10
15
 
11
16
  /**
12
17
  * Manages user preferences and consent states
13
18
  *
14
19
  * This class is not intended to be initialized directly.
15
20
  */
16
- export class Preferences<ContentTypes = unknown> {
17
- #client: Client<ContentTypes>;
21
+ export class Preferences {
22
+ #worker: WorkerBridge<ClientWorkerAction>;
18
23
 
19
24
  /**
20
25
  * Creates a new preferences instance
21
26
  *
22
27
  * @param client - The client instance managing preferences
23
28
  */
24
- constructor(client: Client<ContentTypes>) {
25
- this.#client = client;
29
+ constructor(worker: WorkerBridge<ClientWorkerAction>) {
30
+ this.#worker = worker;
26
31
  }
27
32
 
28
33
  sync() {
29
- return this.#client.sendMessage("preferences.sync", undefined);
34
+ return this.#worker.action("preferences.sync");
30
35
  }
31
36
 
32
37
  /**
33
- * Retrieves the current inbox state
38
+ * Retrieves the current inbox state of this client from the local database
34
39
  *
35
- * @param refreshFromNetwork - Optional flag to force refresh from network
36
40
  * @returns Promise that resolves with the inbox state
37
41
  */
38
- async inboxState(refreshFromNetwork?: boolean) {
39
- return this.#client.sendMessage("preferences.inboxState", {
40
- refreshFromNetwork: refreshFromNetwork ?? false,
42
+ async inboxState() {
43
+ return this.#worker.action("preferences.inboxState", {
44
+ refreshFromNetwork: false,
41
45
  });
42
46
  }
43
47
 
44
48
  /**
45
- * Retrieves inbox state for specific inbox IDs
49
+ * Retrieves the latest inbox state of this client from the network
50
+ *
51
+ * @returns Promise that resolves with the inbox state
52
+ */
53
+ async fetchInboxState() {
54
+ return this.#worker.action("preferences.inboxState", {
55
+ refreshFromNetwork: true,
56
+ });
57
+ }
58
+
59
+ /**
60
+ * Retrieves the current inbox states for specified inbox IDs from the local
61
+ * database
46
62
  *
47
63
  * @param inboxIds - Array of inbox IDs to get state for
48
- * @param refreshFromNetwork - Optional flag to force refresh from network
49
- * @returns Promise that resolves with the inbox state for the inbox IDs
64
+ * @returns Promise that resolves with the inbox states for the inbox IDs
50
65
  */
51
- async inboxStateFromInboxIds(
52
- inboxIds: string[],
53
- refreshFromNetwork?: boolean,
54
- ) {
55
- return this.#client.sendMessage("preferences.inboxStateFromInboxIds", {
66
+ async getInboxStates(inboxIds: string[]) {
67
+ return this.#worker.action("preferences.getInboxStates", {
56
68
  inboxIds,
57
- refreshFromNetwork: refreshFromNetwork ?? false,
69
+ refreshFromNetwork: false,
58
70
  });
59
71
  }
60
72
 
61
73
  /**
62
- * Gets the latest inbox state for a specific inbox
74
+ * Retrieves the latest inbox states for specified inbox IDs from the network
63
75
  *
64
- * @param inboxId - The inbox ID to get state for
65
- * @returns Promise that resolves with the latest inbox state
76
+ * @param inboxIds - Array of inbox IDs to get state for
77
+ * @returns Promise that resolves with the inbox states for the inbox IDs
66
78
  */
67
- async getLatestInboxState(inboxId: string) {
68
- return this.#client.sendMessage("preferences.getLatestInboxState", {
69
- inboxId,
79
+ async fetchInboxStates(inboxIds: string[]) {
80
+ return this.#worker.action("preferences.getInboxStates", {
81
+ inboxIds,
82
+ refreshFromNetwork: true,
70
83
  });
71
84
  }
72
85
 
@@ -76,8 +89,8 @@ export class Preferences<ContentTypes = unknown> {
76
89
  * @param records - Array of consent records to update
77
90
  * @returns Promise that resolves when consent states are updated
78
91
  */
79
- async setConsentStates(records: SafeConsent[]) {
80
- return this.#client.sendMessage("preferences.setConsentStates", {
92
+ async setConsentStates(records: Consent[]) {
93
+ return this.#worker.action("preferences.setConsentStates", {
81
94
  records,
82
95
  });
83
96
  }
@@ -89,8 +102,11 @@ export class Preferences<ContentTypes = unknown> {
89
102
  * @param entity - Entity identifier
90
103
  * @returns Promise that resolves with the consent state
91
104
  */
92
- async getConsentState(entityType: ConsentEntityType, entity: string) {
93
- return this.#client.sendMessage("preferences.getConsentState", {
105
+ async getConsentState(
106
+ entityType: ConsentEntityType,
107
+ entity: string,
108
+ ): Promise<ConsentState> {
109
+ return this.#worker.action("preferences.getConsentState", {
94
110
  entityType,
95
111
  entity,
96
112
  });
@@ -102,27 +118,25 @@ export class Preferences<ContentTypes = unknown> {
102
118
  * @param options - Optional stream options
103
119
  * @returns Stream instance for consent updates
104
120
  */
105
- async streamConsent(options?: StreamOptions<SafeConsent[]>) {
121
+ async streamConsent(options?: StreamOptions<Consent[]>) {
106
122
  const stream = async (
107
- callback: StreamCallback<SafeConsent[]>,
123
+ callback: StreamCallback<Consent[]>,
108
124
  onFail: () => void,
109
125
  ) => {
110
- const streamId = v4();
126
+ const streamId = uuid();
111
127
  // sync the conversation
112
- await this.sync();
128
+ if (!options?.disableSync) {
129
+ await this.sync();
130
+ }
113
131
  // start the stream
114
- await this.#client.sendMessage("preferences.streamConsent", {
132
+ await this.#worker.action("preferences.streamConsent", {
115
133
  streamId,
116
134
  });
117
135
  // handle stream messages
118
- return this.#client.handleStreamMessage<SafeConsent[]>(
119
- streamId,
120
- callback,
121
- {
122
- ...options,
123
- onFail,
124
- },
125
- );
136
+ return this.#worker.handleStreamMessage<Consent[]>(streamId, callback, {
137
+ ...options,
138
+ onFail,
139
+ });
126
140
  };
127
141
 
128
142
  return createStream(stream, undefined, options);
@@ -134,20 +148,22 @@ export class Preferences<ContentTypes = unknown> {
134
148
  * @param options - Optional stream options
135
149
  * @returns Stream instance for preference updates
136
150
  */
137
- async streamPreferences(options?: StreamOptions<UserPreference[]>) {
151
+ async streamPreferences(options?: StreamOptions<UserPreferenceUpdate[]>) {
138
152
  const stream = async (
139
- callback: StreamCallback<UserPreference[]>,
153
+ callback: StreamCallback<UserPreferenceUpdate[]>,
140
154
  onFail: () => void,
141
155
  ) => {
142
- const streamId = v4();
156
+ const streamId = uuid();
143
157
  // sync the conversation
144
- await this.sync();
158
+ if (!options?.disableSync) {
159
+ await this.sync();
160
+ }
145
161
  // start the stream
146
- await this.#client.sendMessage("preferences.streamPreferences", {
162
+ await this.#worker.action("preferences.streamPreferences", {
147
163
  streamId,
148
164
  });
149
165
  // handle stream messages
150
- return this.#client.handleStreamMessage<UserPreference[]>(
166
+ return this.#worker.handleStreamMessage<UserPreferenceUpdate[]>(
151
167
  streamId,
152
168
  callback,
153
169
  {
@@ -18,11 +18,11 @@ export class WorkerClient {
18
18
  #debugInformation: WorkerDebugInformation;
19
19
  #preferences: WorkerPreferences;
20
20
 
21
- constructor(client: Client, options?: ClientOptions) {
21
+ constructor(client: Client) {
22
22
  this.#client = client;
23
23
  const conversations = client.conversations();
24
24
  this.#conversations = new WorkerConversations(this, conversations);
25
- this.#debugInformation = new WorkerDebugInformation(client, options);
25
+ this.#debugInformation = new WorkerDebugInformation(client);
26
26
  this.#preferences = new WorkerPreferences(client, conversations);
27
27
  }
28
28
 
@@ -31,7 +31,7 @@ export class WorkerClient {
31
31
  options?: Omit<ClientOptions, "codecs">,
32
32
  ) {
33
33
  const client = await createClient(identifier, options);
34
- return new WorkerClient(client, options);
34
+ return new WorkerClient(client);
35
35
  }
36
36
 
37
37
  get libxmtpVersion() {
@@ -143,7 +143,7 @@ export class WorkerClient {
143
143
  await this.#client.registerIdentity(signatureRequest);
144
144
  }
145
145
 
146
- async findInboxIdByIdentifier(identifier: Identifier) {
146
+ async getInboxIdByIdentifier(identifier: Identifier) {
147
147
  return this.#client.findInboxIdByIdentifier(identifier);
148
148
  }
149
149
 
@@ -179,7 +179,7 @@ export class WorkerClient {
179
179
  }
180
180
  }
181
181
 
182
- async getKeyPackageStatusesForInstallationIds(installationIds: string[]) {
182
+ async fetchKeyPackageStatuses(installationIds: string[]) {
183
183
  return this.#client.getKeyPackageStatusesForInstallationIds(
184
184
  installationIds,
185
185
  ) as Promise<Map<string, KeyPackageStatus>>;
@@ -1,40 +1,42 @@
1
1
  import {
2
- MessageDisappearingSettings,
2
+ GroupMembershipState,
3
3
  SortDirection,
4
+ type Actions,
5
+ type Attachment,
4
6
  type ConsentState,
5
7
  type Conversation,
6
8
  type ConversationDebugInfo,
9
+ type DecodedMessage,
7
10
  type EncodedContent,
8
11
  type GroupMember,
9
12
  type HmacKey,
10
13
  type Identifier,
14
+ type Intent,
15
+ type ListMessagesOptions,
11
16
  type Message,
17
+ type MessageDisappearingSettings,
12
18
  type MetadataField,
19
+ type MultiRemoteAttachment,
13
20
  type PermissionPolicy,
14
21
  type PermissionUpdateType,
22
+ type Reaction,
23
+ type RemoteAttachment,
24
+ type Reply,
15
25
  type SendMessageOpts,
26
+ type TransactionReference,
27
+ type WalletSendCalls,
16
28
  } from "@xmtp/wasm-bindings";
17
- import {
18
- fromSafeListMessagesOptions,
19
- toSafeGroupMember,
20
- type SafeListMessagesOptions,
21
- } from "@/utils/conversions";
29
+ import type { LastReadTimes } from "@/utils/conversions";
22
30
  import type { StreamCallback } from "@/utils/streams";
23
31
  import type { WorkerClient } from "@/WorkerClient";
24
32
 
25
33
  export class WorkerConversation {
26
34
  #client: WorkerClient;
27
35
  #group: Conversation;
28
- #isCommitLogForked?: boolean;
29
36
 
30
- constructor(
31
- client: WorkerClient,
32
- group: Conversation,
33
- isCommitLogForked?: boolean,
34
- ) {
37
+ constructor(client: WorkerClient, group: Conversation) {
35
38
  this.#client = client;
36
39
  this.#group = group;
37
- this.#isCommitLogForked = isCommitLogForked;
38
40
  }
39
41
 
40
42
  get id() {
@@ -65,12 +67,21 @@ export class WorkerConversation {
65
67
  return this.#group.updateGroupDescription(description);
66
68
  }
67
69
 
68
- get isActive() {
69
- return this.#group.isActive();
70
+ get appData() {
71
+ try {
72
+ return this.#group.appData();
73
+ } catch {
74
+ // DM groups don't support appData
75
+ return "";
76
+ }
70
77
  }
71
78
 
72
- get isCommitLogForked() {
73
- return this.#isCommitLogForked;
79
+ async updateAppData(appData: string) {
80
+ return this.#group.updateAppData(appData);
81
+ }
82
+
83
+ get isActive() {
84
+ return this.#group.isActive();
74
85
  }
75
86
 
76
87
  get addedByInboxId() {
@@ -93,31 +104,27 @@ export class WorkerConversation {
93
104
  }
94
105
 
95
106
  async metadata() {
96
- const metadata = await this.#group.groupMetadata();
97
- return {
98
- creatorInboxId: metadata.creatorInboxId(),
99
- conversationType: metadata.conversationType(),
100
- };
107
+ return this.#group.groupMetadata();
101
108
  }
102
109
 
103
110
  async members() {
104
111
  const members = (await this.#group.listMembers()) as GroupMember[];
105
- return members.map((member) => toSafeGroupMember(member));
112
+ return members;
106
113
  }
107
114
 
108
- get admins() {
115
+ listAdmins() {
109
116
  return this.#group.adminList();
110
117
  }
111
118
 
112
- get superAdmins() {
119
+ listSuperAdmins() {
113
120
  return this.#group.superAdminList();
114
121
  }
115
122
 
116
- get permissions() {
123
+ permissions() {
117
124
  const permissions = this.#group.groupPermissions();
118
125
  return {
119
- policyType: permissions.policyType(),
120
- policySet: permissions.policySet(),
126
+ policyType: permissions.policyType,
127
+ policySet: permissions.policySet,
121
128
  };
122
129
  }
123
130
 
@@ -181,29 +188,85 @@ export class WorkerConversation {
181
188
  return this.#group.publishMessages();
182
189
  }
183
190
 
184
- sendOptimistic(encodedContent: EncodedContent, opts: SendMessageOpts) {
185
- // Pass through to underlying implementation - it will handle undefined opts
186
- return this.#group.sendOptimistic(encodedContent, opts);
191
+ async send(encodedContent: EncodedContent, opts?: SendMessageOpts) {
192
+ return this.#group.send(encodedContent, opts ?? { shouldPush: true });
187
193
  }
188
194
 
189
- async send(encodedContent: EncodedContent, opts: SendMessageOpts) {
190
- // Pass through to underlying implementation - it will handle undefined opts
191
- return this.#group.send(encodedContent, opts);
195
+ async sendText(text: string, isOptimistic?: boolean) {
196
+ return this.#group.sendText(text, isOptimistic);
192
197
  }
193
198
 
194
- async messages(options?: SafeListMessagesOptions) {
195
- return this.#group.findMessages(
196
- options ? fromSafeListMessagesOptions(options) : undefined,
199
+ async sendMarkdown(markdown: string, isOptimistic?: boolean) {
200
+ return this.#group.sendMarkdown(markdown, isOptimistic);
201
+ }
202
+
203
+ async sendReaction(reaction: Reaction, isOptimistic?: boolean) {
204
+ return this.#group.sendReaction(reaction, isOptimistic);
205
+ }
206
+
207
+ async sendReadReceipt(isOptimistic?: boolean) {
208
+ return this.#group.sendReadReceipt(isOptimistic);
209
+ }
210
+
211
+ async sendReply(reply: Reply, isOptimistic?: boolean) {
212
+ return this.#group.sendReply(reply, isOptimistic);
213
+ }
214
+
215
+ async sendTransactionReference(
216
+ transactionReference: TransactionReference,
217
+ isOptimistic?: boolean,
218
+ ) {
219
+ return this.#group.sendTransactionReference(
220
+ transactionReference,
221
+ isOptimistic,
197
222
  );
198
223
  }
199
224
 
200
- async countMessages(options?: SafeListMessagesOptions) {
201
- return this.#group.countMessages(
202
- options ? fromSafeListMessagesOptions(options) : undefined,
225
+ async sendWalletSendCalls(
226
+ walletSendCalls: WalletSendCalls,
227
+ isOptimistic?: boolean,
228
+ ) {
229
+ return this.#group.sendWalletSendCalls(walletSendCalls, isOptimistic);
230
+ }
231
+
232
+ async sendActions(actions: Actions, isOptimistic?: boolean) {
233
+ return this.#group.sendActions(actions, isOptimistic);
234
+ }
235
+
236
+ async sendIntent(intent: Intent, isOptimistic?: boolean) {
237
+ return this.#group.sendIntent(intent, isOptimistic);
238
+ }
239
+
240
+ async sendAttachment(attachment: Attachment, isOptimistic?: boolean) {
241
+ return this.#group.sendAttachment(attachment, isOptimistic);
242
+ }
243
+
244
+ async sendMultiRemoteAttachment(
245
+ multiRemoteAttachment: MultiRemoteAttachment,
246
+ isOptimistic?: boolean,
247
+ ) {
248
+ return this.#group.sendMultiRemoteAttachment(
249
+ multiRemoteAttachment,
250
+ isOptimistic,
203
251
  );
204
252
  }
205
253
 
206
- get consentState() {
254
+ async sendRemoteAttachment(
255
+ remoteAttachment: RemoteAttachment,
256
+ isOptimistic?: boolean,
257
+ ) {
258
+ return this.#group.sendRemoteAttachment(remoteAttachment, isOptimistic);
259
+ }
260
+
261
+ async messages(options?: ListMessagesOptions): Promise<DecodedMessage[]> {
262
+ return this.#group.findEnrichedMessages(options);
263
+ }
264
+
265
+ async countMessages(options?: ListMessagesOptions) {
266
+ return this.#group.countMessages(options);
267
+ }
268
+
269
+ consentState() {
207
270
  return this.#group.consentState();
208
271
  }
209
272
 
@@ -220,7 +283,7 @@ export class WorkerConversation {
220
283
  }
221
284
 
222
285
  async updateMessageDisappearingSettings(fromNs: bigint, inNs: bigint) {
223
- const settings = new MessageDisappearingSettings(fromNs, inNs);
286
+ const settings: MessageDisappearingSettings = { fromNs, inNs };
224
287
  return this.#group.updateMessageDisappearingSettings(settings);
225
288
  }
226
289
 
@@ -249,7 +312,7 @@ export class WorkerConversation {
249
312
  return this.#group.pausedForVersion();
250
313
  }
251
314
 
252
- getHmacKeys() {
315
+ hmacKeys() {
253
316
  return this.#group.getHmacKeys() as Map<string, HmacKey[]>;
254
317
  }
255
318
 
@@ -257,8 +320,20 @@ export class WorkerConversation {
257
320
  return (await this.#group.getDebugInfo()) as ConversationDebugInfo;
258
321
  }
259
322
 
260
- async getDuplicateDms() {
323
+ async duplicateDms() {
261
324
  const dms = await this.#group.findDuplicateDms();
262
325
  return dms.map((dm) => new WorkerConversation(this.#client, dm));
263
326
  }
327
+
328
+ async requestRemoval() {
329
+ return this.#group.leaveGroup();
330
+ }
331
+
332
+ isPendingRemoval() {
333
+ return this.#group.membershipState() === GroupMembershipState.PendingRemove;
334
+ }
335
+
336
+ async lastReadTimes() {
337
+ return this.#group.getLastReadTimes() as Promise<LastReadTimes>;
338
+ }
264
339
  }
@@ -4,18 +4,14 @@ import {
4
4
  type Conversation,
5
5
  type ConversationListItem,
6
6
  type Conversations,
7
+ type CreateDmOptions,
8
+ type CreateGroupOptions,
9
+ type DecodedMessage,
7
10
  type Identifier,
11
+ type ListConversationsOptions,
8
12
  type Message,
9
13
  } from "@xmtp/wasm-bindings";
10
- import {
11
- fromSafeCreateDmOptions,
12
- fromSafeCreateGroupOptions,
13
- fromSafeListConversationsOptions,
14
- type HmacKeys,
15
- type SafeCreateDmOptions,
16
- type SafeCreateGroupOptions,
17
- type SafeListConversationsOptions,
18
- } from "@/utils/conversions";
14
+ import { type HmacKeys } from "@/utils/conversions";
19
15
  import type { StreamCallback } from "@/utils/streams";
20
16
  import type { WorkerClient } from "@/WorkerClient";
21
17
  import { WorkerConversation } from "@/WorkerConversation";
@@ -48,10 +44,9 @@ export class WorkerConversations {
48
44
  }
49
45
  }
50
46
 
51
- getMessageById(id: string) {
47
+ async getMessageById(id: string): Promise<DecodedMessage | undefined> {
52
48
  try {
53
- // findMessageById will throw if message is not found
54
- return this.#conversations.findMessageById(id);
49
+ return await this.#conversations.findEnrichedMessageById(id);
55
50
  } catch {
56
51
  return undefined;
57
52
  }
@@ -66,102 +61,68 @@ export class WorkerConversations {
66
61
  }
67
62
  }
68
63
 
69
- list(options?: SafeListConversationsOptions) {
70
- const groups = this.#conversations.list(
71
- options ? fromSafeListConversationsOptions(options) : undefined,
72
- ) as ConversationListItem[];
64
+ list(options?: ListConversationsOptions) {
65
+ const groups = this.#conversations.list(options) as ConversationListItem[];
73
66
  return groups.map(
74
- (item) =>
75
- new WorkerConversation(
76
- this.#client,
77
- item.conversation,
78
- item.isCommitLogForked,
79
- ),
67
+ (item) => new WorkerConversation(this.#client, item.conversation),
80
68
  );
81
69
  }
82
70
 
83
- listGroups(
84
- options?: Omit<SafeListConversationsOptions, "conversation_type">,
85
- ) {
86
- const groups = this.#conversations.list(
87
- fromSafeListConversationsOptions({
88
- ...(options ?? {}),
89
- conversationType: ConversationType.Group,
90
- }),
91
- ) as ConversationListItem[];
71
+ listGroups(options?: Omit<ListConversationsOptions, "conversationType">) {
72
+ const groups = this.#conversations.list({
73
+ ...(options ?? {}),
74
+ conversationType: ConversationType.Group,
75
+ }) as ConversationListItem[];
92
76
  return groups.map(
93
- (item) =>
94
- new WorkerConversation(
95
- this.#client,
96
- item.conversation,
97
- item.isCommitLogForked,
98
- ),
77
+ (item) => new WorkerConversation(this.#client, item.conversation),
99
78
  );
100
79
  }
101
80
 
102
- listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">) {
103
- const groups = this.#conversations.list(
104
- fromSafeListConversationsOptions({
105
- ...(options ?? {}),
106
- conversationType: ConversationType.Dm,
107
- }),
108
- ) as ConversationListItem[];
81
+ listDms(options?: Omit<ListConversationsOptions, "conversationType">) {
82
+ const groups = this.#conversations.list({
83
+ ...(options ?? {}),
84
+ conversationType: ConversationType.Dm,
85
+ }) as ConversationListItem[];
109
86
  return groups.map(
110
- (item) =>
111
- new WorkerConversation(
112
- this.#client,
113
- item.conversation,
114
- item.isCommitLogForked,
115
- ),
87
+ (item) => new WorkerConversation(this.#client, item.conversation),
116
88
  );
117
89
  }
118
90
 
119
- newGroupOptimistic(options?: SafeCreateGroupOptions) {
120
- const group = this.#conversations.createGroupOptimistic(
121
- options ? fromSafeCreateGroupOptions(options) : undefined,
122
- );
91
+ createGroupOptimistic(options?: CreateGroupOptions) {
92
+ const group = this.#conversations.createGroupOptimistic(options);
123
93
  return new WorkerConversation(this.#client, group);
124
94
  }
125
95
 
126
- async newGroupWithIdentifiers(
96
+ async createGroupWithIdentifiers(
127
97
  identifiers: Identifier[],
128
- options?: SafeCreateGroupOptions,
98
+ options?: CreateGroupOptions,
129
99
  ) {
130
- const group = await this.#conversations.createGroup(
131
- identifiers,
132
- options ? fromSafeCreateGroupOptions(options) : undefined,
133
- );
100
+ const group = await this.#conversations.createGroup(identifiers, options);
134
101
  return new WorkerConversation(this.#client, group);
135
102
  }
136
103
 
137
- async newGroup(inboxIds: string[], options?: SafeCreateGroupOptions) {
104
+ async createGroup(inboxIds: string[], options?: CreateGroupOptions) {
138
105
  const group = await this.#conversations.createGroupByInboxIds(
139
106
  inboxIds,
140
- options ? fromSafeCreateGroupOptions(options) : undefined,
107
+ options,
141
108
  );
142
109
  return new WorkerConversation(this.#client, group);
143
110
  }
144
111
 
145
- async newDmWithIdentifier(
112
+ async createDmWithIdentifier(
146
113
  identifier: Identifier,
147
- options?: SafeCreateDmOptions,
114
+ options?: CreateDmOptions,
148
115
  ) {
149
- const group = await this.#conversations.createDm(
150
- identifier,
151
- options ? fromSafeCreateDmOptions(options) : undefined,
152
- );
116
+ const group = await this.#conversations.createDm(identifier, options);
153
117
  return new WorkerConversation(this.#client, group);
154
118
  }
155
119
 
156
- async newDm(inboxId: string, options?: SafeCreateDmOptions) {
157
- const group = await this.#conversations.createDmByInboxId(
158
- inboxId,
159
- options ? fromSafeCreateDmOptions(options) : undefined,
160
- );
120
+ async createDm(inboxId: string, options?: CreateDmOptions) {
121
+ const group = await this.#conversations.createDmByInboxId(inboxId, options);
161
122
  return new WorkerConversation(this.#client, group);
162
123
  }
163
124
 
164
- getHmacKeys() {
125
+ hmacKeys() {
165
126
  return this.#conversations.getHmacKeys() as HmacKeys;
166
127
  }
167
128