@xmtp/browser-sdk 0.0.1 → 0.0.2
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 +144 -87
- 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/package.json +2 -2
- package/src/Client.ts +16 -10
- package/src/Conversation.ts +8 -2
- package/src/Conversations.ts +30 -0
- package/src/DecodedMessage.ts +6 -6
- package/src/WorkerClient.ts +8 -8
- package/src/WorkerConversation.ts +48 -42
- package/src/WorkerConversations.ts +39 -7
- package/src/types/clientEvents.ts +49 -9
- package/src/utils/conversions.ts +124 -93
- package/src/utils/createClient.ts +6 -1
- package/src/workers/client.ts +75 -5
package/src/utils/conversions.ts
CHANGED
|
@@ -3,23 +3,26 @@ import {
|
|
|
3
3
|
type EncodedContent,
|
|
4
4
|
} from "@xmtp/content-type-primitives";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
type
|
|
17
|
-
type
|
|
18
|
-
type
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
type
|
|
22
|
-
type
|
|
6
|
+
Consent,
|
|
7
|
+
CreateGroupOptions,
|
|
8
|
+
GroupMember,
|
|
9
|
+
ListConversationsOptions,
|
|
10
|
+
ListMessagesOptions,
|
|
11
|
+
ContentTypeId as WasmContentTypeId,
|
|
12
|
+
EncodedContent as WasmEncodedContent,
|
|
13
|
+
type ConsentEntityType,
|
|
14
|
+
type ConsentState,
|
|
15
|
+
type ConversationType,
|
|
16
|
+
type DeliveryStatus,
|
|
17
|
+
type GroupMembershipState,
|
|
18
|
+
type GroupMessageKind,
|
|
19
|
+
type GroupPermissionsOptions,
|
|
20
|
+
type InboxState,
|
|
21
|
+
type Installation,
|
|
22
|
+
type Message,
|
|
23
|
+
type PermissionLevel,
|
|
24
|
+
type PermissionPolicy,
|
|
25
|
+
type SortDirection,
|
|
23
26
|
} from "@xmtp/wasm-bindings";
|
|
24
27
|
import type { WorkerConversation } from "@/WorkerConversation";
|
|
25
28
|
|
|
@@ -27,10 +30,10 @@ export const toContentTypeId = (
|
|
|
27
30
|
contentTypeId: WasmContentTypeId,
|
|
28
31
|
): ContentTypeId =>
|
|
29
32
|
new ContentTypeId({
|
|
30
|
-
authorityId: contentTypeId.
|
|
31
|
-
typeId: contentTypeId.
|
|
32
|
-
versionMajor: contentTypeId.
|
|
33
|
-
versionMinor: contentTypeId.
|
|
33
|
+
authorityId: contentTypeId.authorityId,
|
|
34
|
+
typeId: contentTypeId.typeId,
|
|
35
|
+
versionMajor: contentTypeId.versionMajor,
|
|
36
|
+
versionMinor: contentTypeId.versionMinor,
|
|
34
37
|
});
|
|
35
38
|
|
|
36
39
|
export const fromContentTypeId = (
|
|
@@ -122,74 +125,83 @@ export const fromSafeEncodedContent = (
|
|
|
122
125
|
export type SafeMessage = {
|
|
123
126
|
content: SafeEncodedContent;
|
|
124
127
|
convoId: string;
|
|
125
|
-
deliveryStatus:
|
|
128
|
+
deliveryStatus: DeliveryStatus;
|
|
126
129
|
id: string;
|
|
127
|
-
kind:
|
|
130
|
+
kind: GroupMessageKind;
|
|
128
131
|
senderInboxId: string;
|
|
129
132
|
sentAtNs: bigint;
|
|
130
133
|
};
|
|
131
134
|
|
|
132
|
-
export const toSafeMessage = (message:
|
|
135
|
+
export const toSafeMessage = (message: Message): SafeMessage => ({
|
|
133
136
|
content: toSafeEncodedContent(toEncodedContent(message.content)),
|
|
134
|
-
convoId: message.
|
|
135
|
-
deliveryStatus: message.
|
|
137
|
+
convoId: message.convoId,
|
|
138
|
+
deliveryStatus: message.deliveryStatus,
|
|
136
139
|
id: message.id,
|
|
137
140
|
kind: message.kind,
|
|
138
|
-
senderInboxId: message.
|
|
139
|
-
sentAtNs: message.
|
|
141
|
+
senderInboxId: message.senderInboxId,
|
|
142
|
+
sentAtNs: message.sentAtNs,
|
|
140
143
|
});
|
|
141
144
|
|
|
142
145
|
export type SafeListMessagesOptions = {
|
|
143
|
-
|
|
146
|
+
deliveryStatus?: DeliveryStatus;
|
|
147
|
+
direction?: SortDirection;
|
|
144
148
|
limit?: bigint;
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
sentAfterNs?: bigint;
|
|
150
|
+
sentBeforeNs?: bigint;
|
|
147
151
|
};
|
|
148
152
|
|
|
149
153
|
export const toSafeListMessagesOptions = (
|
|
150
|
-
options:
|
|
154
|
+
options: ListMessagesOptions,
|
|
151
155
|
): SafeListMessagesOptions => ({
|
|
152
|
-
|
|
156
|
+
deliveryStatus: options.deliveryStatus,
|
|
157
|
+
direction: options.direction,
|
|
153
158
|
limit: options.limit,
|
|
154
|
-
|
|
155
|
-
|
|
159
|
+
sentAfterNs: options.sentAfterNs,
|
|
160
|
+
sentBeforeNs: options.sentBeforeNs,
|
|
156
161
|
});
|
|
157
162
|
|
|
158
163
|
export const fromSafeListMessagesOptions = (
|
|
159
164
|
options: SafeListMessagesOptions,
|
|
160
|
-
):
|
|
161
|
-
new
|
|
162
|
-
options.
|
|
163
|
-
options.
|
|
165
|
+
): ListMessagesOptions =>
|
|
166
|
+
new ListMessagesOptions(
|
|
167
|
+
options.sentBeforeNs,
|
|
168
|
+
options.sentAfterNs,
|
|
164
169
|
options.limit,
|
|
165
|
-
options.
|
|
170
|
+
options.deliveryStatus,
|
|
171
|
+
options.direction,
|
|
166
172
|
);
|
|
167
173
|
|
|
168
174
|
export type SafeListConversationsOptions = {
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
allowedStates?: GroupMembershipState[];
|
|
176
|
+
conversationType?: ConversationType;
|
|
177
|
+
createdAfterNs?: bigint;
|
|
178
|
+
createdBeforeNs?: bigint;
|
|
171
179
|
limit?: bigint;
|
|
172
180
|
};
|
|
173
181
|
|
|
174
182
|
export const toSafeListConversationsOptions = (
|
|
175
|
-
options:
|
|
183
|
+
options: ListConversationsOptions,
|
|
176
184
|
): SafeListConversationsOptions => ({
|
|
177
|
-
|
|
178
|
-
|
|
185
|
+
allowedStates: options.allowedStates,
|
|
186
|
+
conversationType: options.conversationType,
|
|
187
|
+
createdAfterNs: options.createdAfterNs,
|
|
188
|
+
createdBeforeNs: options.createdBeforeNs,
|
|
179
189
|
limit: options.limit,
|
|
180
190
|
});
|
|
181
191
|
|
|
182
192
|
export const fromSafeListConversationsOptions = (
|
|
183
193
|
options: SafeListConversationsOptions,
|
|
184
|
-
):
|
|
185
|
-
new
|
|
186
|
-
options.
|
|
187
|
-
options.
|
|
194
|
+
): ListConversationsOptions =>
|
|
195
|
+
new ListConversationsOptions(
|
|
196
|
+
options.allowedStates,
|
|
197
|
+
options.conversationType,
|
|
198
|
+
options.createdAfterNs,
|
|
199
|
+
options.createdBeforeNs,
|
|
188
200
|
options.limit,
|
|
189
201
|
);
|
|
190
202
|
|
|
191
203
|
export type SafeCreateGroupOptions = {
|
|
192
|
-
permissions?:
|
|
204
|
+
permissions?: GroupPermissionsOptions;
|
|
193
205
|
name?: string;
|
|
194
206
|
imageUrlSquare?: string;
|
|
195
207
|
description?: string;
|
|
@@ -197,19 +209,19 @@ export type SafeCreateGroupOptions = {
|
|
|
197
209
|
};
|
|
198
210
|
|
|
199
211
|
export const toSafeCreateGroupOptions = (
|
|
200
|
-
options:
|
|
212
|
+
options: CreateGroupOptions,
|
|
201
213
|
): SafeCreateGroupOptions => ({
|
|
202
214
|
permissions: options.permissions,
|
|
203
|
-
name: options.
|
|
204
|
-
imageUrlSquare: options.
|
|
205
|
-
description: options.
|
|
206
|
-
pinnedFrameUrl: options.
|
|
215
|
+
name: options.groupName,
|
|
216
|
+
imageUrlSquare: options.groupImageUrlSquare,
|
|
217
|
+
description: options.groupDescription,
|
|
218
|
+
pinnedFrameUrl: options.groupPinnedFrameUrl,
|
|
207
219
|
});
|
|
208
220
|
|
|
209
221
|
export const fromSafeCreateGroupOptions = (
|
|
210
222
|
options: SafeCreateGroupOptions,
|
|
211
|
-
):
|
|
212
|
-
new
|
|
223
|
+
): CreateGroupOptions =>
|
|
224
|
+
new CreateGroupOptions(
|
|
213
225
|
options.permissions,
|
|
214
226
|
options.name,
|
|
215
227
|
options.imageUrlSquare,
|
|
@@ -224,16 +236,16 @@ export type SafeConversation = {
|
|
|
224
236
|
description: string;
|
|
225
237
|
pinnedFrameUrl: string;
|
|
226
238
|
permissions: {
|
|
227
|
-
policyType:
|
|
239
|
+
policyType: GroupPermissionsOptions;
|
|
228
240
|
policySet: {
|
|
229
|
-
addAdminPolicy:
|
|
230
|
-
addMemberPolicy:
|
|
231
|
-
removeAdminPolicy:
|
|
232
|
-
removeMemberPolicy:
|
|
233
|
-
updateGroupDescriptionPolicy:
|
|
234
|
-
updateGroupImageUrlSquarePolicy:
|
|
235
|
-
updateGroupNamePolicy:
|
|
236
|
-
updateGroupPinnedFrameUrlPolicy:
|
|
241
|
+
addAdminPolicy: PermissionPolicy;
|
|
242
|
+
addMemberPolicy: PermissionPolicy;
|
|
243
|
+
removeAdminPolicy: PermissionPolicy;
|
|
244
|
+
removeMemberPolicy: PermissionPolicy;
|
|
245
|
+
updateGroupDescriptionPolicy: PermissionPolicy;
|
|
246
|
+
updateGroupImageUrlSquarePolicy: PermissionPolicy;
|
|
247
|
+
updateGroupNamePolicy: PermissionPolicy;
|
|
248
|
+
updateGroupPinnedFrameUrlPolicy: PermissionPolicy;
|
|
237
249
|
};
|
|
238
250
|
};
|
|
239
251
|
isActive: boolean;
|
|
@@ -258,19 +270,18 @@ export const toSafeConversation = (
|
|
|
258
270
|
permissions: {
|
|
259
271
|
policyType: conversation.permissions.policyType,
|
|
260
272
|
policySet: {
|
|
261
|
-
addAdminPolicy: conversation.permissions.policySet.
|
|
262
|
-
addMemberPolicy: conversation.permissions.policySet.
|
|
263
|
-
removeAdminPolicy: conversation.permissions.policySet.
|
|
264
|
-
removeMemberPolicy:
|
|
265
|
-
conversation.permissions.policySet.remove_member_policy,
|
|
273
|
+
addAdminPolicy: conversation.permissions.policySet.addAdminPolicy,
|
|
274
|
+
addMemberPolicy: conversation.permissions.policySet.addMemberPolicy,
|
|
275
|
+
removeAdminPolicy: conversation.permissions.policySet.removeAdminPolicy,
|
|
276
|
+
removeMemberPolicy: conversation.permissions.policySet.removeMemberPolicy,
|
|
266
277
|
updateGroupDescriptionPolicy:
|
|
267
|
-
conversation.permissions.policySet.
|
|
278
|
+
conversation.permissions.policySet.updateGroupDescriptionPolicy,
|
|
268
279
|
updateGroupImageUrlSquarePolicy:
|
|
269
|
-
conversation.permissions.policySet.
|
|
280
|
+
conversation.permissions.policySet.updateGroupImageUrlSquarePolicy,
|
|
270
281
|
updateGroupNamePolicy:
|
|
271
|
-
conversation.permissions.policySet.
|
|
282
|
+
conversation.permissions.policySet.updateGroupNamePolicy,
|
|
272
283
|
updateGroupPinnedFrameUrlPolicy:
|
|
273
|
-
conversation.permissions.policySet.
|
|
284
|
+
conversation.permissions.policySet.updateGroupPinnedFrameUrlPolicy,
|
|
274
285
|
},
|
|
275
286
|
},
|
|
276
287
|
isActive: conversation.isActive,
|
|
@@ -287,10 +298,10 @@ export type SafeInstallation = {
|
|
|
287
298
|
};
|
|
288
299
|
|
|
289
300
|
export const toSafeInstallation = (
|
|
290
|
-
installation:
|
|
301
|
+
installation: Installation,
|
|
291
302
|
): SafeInstallation => ({
|
|
292
303
|
id: installation.id,
|
|
293
|
-
clientTimestampNs: installation.
|
|
304
|
+
clientTimestampNs: installation.clientTimestampNs,
|
|
294
305
|
});
|
|
295
306
|
|
|
296
307
|
export type SafeInboxState = {
|
|
@@ -300,38 +311,58 @@ export type SafeInboxState = {
|
|
|
300
311
|
recoveryAddress: string;
|
|
301
312
|
};
|
|
302
313
|
|
|
303
|
-
export const toSafeInboxState = (
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
accountAddresses: inboxState.account_addresses,
|
|
307
|
-
inboxId: inboxState.inbox_id,
|
|
314
|
+
export const toSafeInboxState = (inboxState: InboxState): SafeInboxState => ({
|
|
315
|
+
accountAddresses: inboxState.accountAddresses,
|
|
316
|
+
inboxId: inboxState.inboxId,
|
|
308
317
|
installations: inboxState.installations.map(toSafeInstallation),
|
|
309
|
-
recoveryAddress: inboxState.
|
|
318
|
+
recoveryAddress: inboxState.recoveryAddress,
|
|
310
319
|
});
|
|
311
320
|
|
|
312
321
|
export type SafeConsent = {
|
|
313
322
|
entity: string;
|
|
314
|
-
entityType:
|
|
315
|
-
state:
|
|
323
|
+
entityType: ConsentEntityType;
|
|
324
|
+
state: ConsentState;
|
|
316
325
|
};
|
|
317
326
|
|
|
318
|
-
export const toSafeConsent = (consent:
|
|
327
|
+
export const toSafeConsent = (consent: Consent): SafeConsent => ({
|
|
319
328
|
entity: consent.entity,
|
|
320
|
-
entityType: consent.
|
|
329
|
+
entityType: consent.entityType,
|
|
321
330
|
state: consent.state,
|
|
322
331
|
});
|
|
323
332
|
|
|
324
|
-
export const fromSafeConsent = (consent: SafeConsent):
|
|
325
|
-
new
|
|
333
|
+
export const fromSafeConsent = (consent: SafeConsent): Consent =>
|
|
334
|
+
new Consent(consent.entityType, consent.state, consent.entity);
|
|
326
335
|
|
|
327
336
|
export type SafeGroupMember = {
|
|
328
337
|
accountAddresses: string[];
|
|
329
|
-
consentState:
|
|
338
|
+
consentState: ConsentState;
|
|
330
339
|
inboxId: string;
|
|
331
340
|
installationIds: string[];
|
|
332
|
-
permissionLevel:
|
|
341
|
+
permissionLevel: PermissionLevel;
|
|
333
342
|
};
|
|
334
343
|
|
|
344
|
+
export class WasmGroupMember {
|
|
345
|
+
account_addresses: string[];
|
|
346
|
+
consent_state: ConsentState;
|
|
347
|
+
inbox_id: string;
|
|
348
|
+
installation_ids: string[];
|
|
349
|
+
permission_level: PermissionLevel;
|
|
350
|
+
|
|
351
|
+
constructor(
|
|
352
|
+
inbox_id: string,
|
|
353
|
+
account_addresses: string[],
|
|
354
|
+
installation_ids: string[],
|
|
355
|
+
permission_level: PermissionLevel,
|
|
356
|
+
consent_state: ConsentState,
|
|
357
|
+
) {
|
|
358
|
+
this.inbox_id = inbox_id;
|
|
359
|
+
this.account_addresses = account_addresses;
|
|
360
|
+
this.installation_ids = installation_ids;
|
|
361
|
+
this.permission_level = permission_level;
|
|
362
|
+
this.consent_state = consent_state;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
335
366
|
export const toSafeGroupMember = (
|
|
336
367
|
member: WasmGroupMember,
|
|
337
368
|
): SafeGroupMember => ({
|
|
@@ -342,8 +373,8 @@ export const toSafeGroupMember = (
|
|
|
342
373
|
permissionLevel: member.permission_level,
|
|
343
374
|
});
|
|
344
375
|
|
|
345
|
-
export const fromSafeGroupMember = (member: SafeGroupMember):
|
|
346
|
-
new
|
|
376
|
+
export const fromSafeGroupMember = (member: SafeGroupMember): GroupMember =>
|
|
377
|
+
new GroupMember(
|
|
347
378
|
member.inboxId,
|
|
348
379
|
member.accountAddresses,
|
|
349
380
|
member.installationIds,
|
|
@@ -14,7 +14,12 @@ export const createClient = async (
|
|
|
14
14
|
await init();
|
|
15
15
|
|
|
16
16
|
const host = options?.apiUrl ?? ApiUrls[options?.env ?? "dev"];
|
|
17
|
-
|
|
17
|
+
// TODO: add db path validation
|
|
18
|
+
// - must end with .db3
|
|
19
|
+
// - must not contain invalid characters
|
|
20
|
+
// - must not start with a dot
|
|
21
|
+
const dbPath =
|
|
22
|
+
options?.dbPath ?? `xmtp-${options?.env ?? "dev"}-${accountAddress}.db3`;
|
|
18
23
|
|
|
19
24
|
const inboxId =
|
|
20
25
|
(await getInboxIdForAddress(host, accountAddress)) ||
|
package/src/workers/client.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
fromEncodedContent,
|
|
9
9
|
fromSafeEncodedContent,
|
|
10
10
|
toSafeConversation,
|
|
11
|
-
toSafeGroupMember,
|
|
12
11
|
toSafeInboxState,
|
|
13
12
|
toSafeMessage,
|
|
14
13
|
} from "@/utils/conversions";
|
|
@@ -99,6 +98,15 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
99
98
|
});
|
|
100
99
|
break;
|
|
101
100
|
}
|
|
101
|
+
case "getRevokeInstallationsSignatureText": {
|
|
102
|
+
const result = await client.getRevokeInstallationsSignatureText();
|
|
103
|
+
postMessage({
|
|
104
|
+
id,
|
|
105
|
+
action,
|
|
106
|
+
result,
|
|
107
|
+
});
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
102
110
|
case "addSignature":
|
|
103
111
|
await client.addSignature(data.type, data.bytes);
|
|
104
112
|
postMessage({
|
|
@@ -107,8 +115,8 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
107
115
|
result: undefined,
|
|
108
116
|
});
|
|
109
117
|
break;
|
|
110
|
-
case "
|
|
111
|
-
await client.
|
|
118
|
+
case "applySignatures":
|
|
119
|
+
await client.applySignatures();
|
|
112
120
|
postMessage({
|
|
113
121
|
id,
|
|
114
122
|
action,
|
|
@@ -203,6 +211,30 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
203
211
|
});
|
|
204
212
|
break;
|
|
205
213
|
}
|
|
214
|
+
case "getGroups": {
|
|
215
|
+
const conversations = await client.conversations.listGroups(
|
|
216
|
+
data.options,
|
|
217
|
+
);
|
|
218
|
+
postMessage({
|
|
219
|
+
id,
|
|
220
|
+
action,
|
|
221
|
+
result: conversations.map((conversation) =>
|
|
222
|
+
toSafeConversation(conversation),
|
|
223
|
+
),
|
|
224
|
+
});
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case "getDms": {
|
|
228
|
+
const conversations = await client.conversations.listDms(data.options);
|
|
229
|
+
postMessage({
|
|
230
|
+
id,
|
|
231
|
+
action,
|
|
232
|
+
result: conversations.map((conversation) =>
|
|
233
|
+
toSafeConversation(conversation),
|
|
234
|
+
),
|
|
235
|
+
});
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
206
238
|
case "newGroup": {
|
|
207
239
|
const conversation = await client.conversations.newGroup(
|
|
208
240
|
data.accountAddresses,
|
|
@@ -215,6 +247,17 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
215
247
|
});
|
|
216
248
|
break;
|
|
217
249
|
}
|
|
250
|
+
case "newDm": {
|
|
251
|
+
const conversation = await client.conversations.newDm(
|
|
252
|
+
data.accountAddress,
|
|
253
|
+
);
|
|
254
|
+
postMessage({
|
|
255
|
+
id,
|
|
256
|
+
action,
|
|
257
|
+
result: toSafeConversation(conversation),
|
|
258
|
+
});
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
218
261
|
case "syncConversations": {
|
|
219
262
|
await client.conversations.sync();
|
|
220
263
|
postMessage({
|
|
@@ -242,6 +285,15 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
242
285
|
});
|
|
243
286
|
break;
|
|
244
287
|
}
|
|
288
|
+
case "getDmByInboxId": {
|
|
289
|
+
const conversation = client.conversations.getDmByInboxId(data.inboxId);
|
|
290
|
+
postMessage({
|
|
291
|
+
id,
|
|
292
|
+
action,
|
|
293
|
+
result: conversation ? toSafeConversation(conversation) : undefined,
|
|
294
|
+
});
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
245
297
|
/**
|
|
246
298
|
* Group actions
|
|
247
299
|
*/
|
|
@@ -414,11 +466,11 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
414
466
|
case "getGroupMembers": {
|
|
415
467
|
const group = client.conversations.getConversationById(data.id);
|
|
416
468
|
if (group) {
|
|
417
|
-
const
|
|
469
|
+
const result = await group.members();
|
|
418
470
|
postMessage({
|
|
419
471
|
id,
|
|
420
472
|
action,
|
|
421
|
-
result
|
|
473
|
+
result,
|
|
422
474
|
});
|
|
423
475
|
} else {
|
|
424
476
|
postMessageError({
|
|
@@ -678,6 +730,24 @@ self.onmessage = async (event: MessageEvent<ClientEventsClientMessageData>) => {
|
|
|
678
730
|
}
|
|
679
731
|
break;
|
|
680
732
|
}
|
|
733
|
+
case "getDmPeerInboxId": {
|
|
734
|
+
const group = client.conversations.getConversationById(data.id);
|
|
735
|
+
if (group) {
|
|
736
|
+
const result = group.dmPeerInboxId();
|
|
737
|
+
postMessage({
|
|
738
|
+
id,
|
|
739
|
+
action,
|
|
740
|
+
result,
|
|
741
|
+
});
|
|
742
|
+
} else {
|
|
743
|
+
postMessageError({
|
|
744
|
+
id,
|
|
745
|
+
action,
|
|
746
|
+
error: "Group not found",
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
break;
|
|
750
|
+
}
|
|
681
751
|
}
|
|
682
752
|
} catch (e) {
|
|
683
753
|
postMessageError({
|