@xmtp/browser-sdk 0.0.1
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/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/index.d.ts +791 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/workers/client.js +2 -0
- package/dist/workers/client.js.map +1 -0
- package/dist/workers/utils.js +2 -0
- package/dist/workers/utils.js.map +1 -0
- package/package.json +101 -0
- package/src/Client.ts +181 -0
- package/src/ClientWorkerClass.ts +71 -0
- package/src/Conversation.ts +285 -0
- package/src/Conversations.ts +50 -0
- package/src/DecodedMessage.ts +71 -0
- package/src/Utils.ts +28 -0
- package/src/UtilsWorkerClass.ts +71 -0
- package/src/WorkerClient.ts +124 -0
- package/src/WorkerConversation.ts +169 -0
- package/src/WorkerConversations.ts +60 -0
- package/src/constants.ts +5 -0
- package/src/index.ts +9 -0
- package/src/types/clientEvents.ts +426 -0
- package/src/types/index.ts +4 -0
- package/src/types/options.ts +59 -0
- package/src/types/utils.ts +46 -0
- package/src/types/utilsEvents.ts +53 -0
- package/src/utils/conversions.ts +352 -0
- package/src/utils/createClient.ts +30 -0
- package/src/utils/date.ts +3 -0
- package/src/workers/client.ts +689 -0
- package/src/workers/utils.ts +72 -0
- package/tsconfig.json +11 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,791 @@
|
|
|
1
|
+
import * as _xmtp_wasm_bindings from '@xmtp/wasm-bindings';
|
|
2
|
+
import { WasmSignatureRequestType, WasmConsentState, WasmConsentEntityType, WasmConversations, WasmClient, WasmGroup, WasmGroupMember, WasmEncodedContent, WasmContentTypeId, WasmDeliveryStatus, WasmGroupMessageKind, WasmMessage, WasmListMessagesOptions, WasmListConversationsOptions, WasmGroupPermissionsOptions, WasmCreateGroupOptions, WasmPermissionPolicy, WasmInstallation, WasmInboxState, WasmConsent, WasmPermissionLevel } from '@xmtp/wasm-bindings';
|
|
3
|
+
export * from '@xmtp/wasm-bindings';
|
|
4
|
+
import { ContentCodec, ContentTypeId, EncodedContent } from '@xmtp/content-type-primitives';
|
|
5
|
+
|
|
6
|
+
declare const ApiUrls: {
|
|
7
|
+
readonly local: "http://localhost:5555";
|
|
8
|
+
readonly dev: "https://dev.xmtp.network";
|
|
9
|
+
readonly production: "https://production.xmtp.network";
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type XmtpEnv = keyof typeof ApiUrls;
|
|
13
|
+
/**
|
|
14
|
+
* Network options
|
|
15
|
+
*/
|
|
16
|
+
type NetworkOptions = {
|
|
17
|
+
/**
|
|
18
|
+
* Specify which XMTP environment to connect to. (default: `dev`)
|
|
19
|
+
*/
|
|
20
|
+
env?: XmtpEnv;
|
|
21
|
+
/**
|
|
22
|
+
* apiUrl can be used to override the `env` flag and connect to a
|
|
23
|
+
* specific endpoint
|
|
24
|
+
*/
|
|
25
|
+
apiUrl?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Encryption options
|
|
29
|
+
*/
|
|
30
|
+
type EncryptionOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* Encryption key to use for the local DB
|
|
33
|
+
*/
|
|
34
|
+
encryptionKey?: Uint8Array;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Storage options
|
|
38
|
+
*/
|
|
39
|
+
type StorageOptions = {
|
|
40
|
+
/**
|
|
41
|
+
* Path to the local DB
|
|
42
|
+
*/
|
|
43
|
+
dbPath?: string;
|
|
44
|
+
};
|
|
45
|
+
type ContentOptions = {
|
|
46
|
+
/**
|
|
47
|
+
* Allow configuring codecs for additional content types
|
|
48
|
+
*/
|
|
49
|
+
codecs?: ContentCodec[];
|
|
50
|
+
};
|
|
51
|
+
type OtherOptions = {
|
|
52
|
+
/**
|
|
53
|
+
* Enable logging of events between the client and worker
|
|
54
|
+
*/
|
|
55
|
+
enableLogging?: boolean;
|
|
56
|
+
};
|
|
57
|
+
type ClientOptions = NetworkOptions & EncryptionOptions & StorageOptions & ContentOptions & OtherOptions;
|
|
58
|
+
|
|
59
|
+
type ClientEvents =
|
|
60
|
+
/**
|
|
61
|
+
* Client actions
|
|
62
|
+
*/
|
|
63
|
+
{
|
|
64
|
+
action: "init";
|
|
65
|
+
id: string;
|
|
66
|
+
result: {
|
|
67
|
+
inboxId: string;
|
|
68
|
+
installationId: string;
|
|
69
|
+
};
|
|
70
|
+
data: {
|
|
71
|
+
address: string;
|
|
72
|
+
options?: ClientOptions;
|
|
73
|
+
};
|
|
74
|
+
} | {
|
|
75
|
+
action: "getCreateInboxSignatureText";
|
|
76
|
+
id: string;
|
|
77
|
+
result: string | undefined;
|
|
78
|
+
data: undefined;
|
|
79
|
+
} | {
|
|
80
|
+
action: "getAddWalletSignatureText";
|
|
81
|
+
id: string;
|
|
82
|
+
result: string | undefined;
|
|
83
|
+
data: {
|
|
84
|
+
accountAddress: string;
|
|
85
|
+
};
|
|
86
|
+
} | {
|
|
87
|
+
action: "getRevokeWalletSignatureText";
|
|
88
|
+
id: string;
|
|
89
|
+
result: string | undefined;
|
|
90
|
+
data: {
|
|
91
|
+
accountAddress: string;
|
|
92
|
+
};
|
|
93
|
+
} | {
|
|
94
|
+
action: "getRevokeInstallationsSignatureText";
|
|
95
|
+
id: string;
|
|
96
|
+
result: string | undefined;
|
|
97
|
+
data: undefined;
|
|
98
|
+
} | {
|
|
99
|
+
action: "addSignature";
|
|
100
|
+
id: string;
|
|
101
|
+
result: undefined;
|
|
102
|
+
data: {
|
|
103
|
+
type: WasmSignatureRequestType;
|
|
104
|
+
bytes: Uint8Array;
|
|
105
|
+
};
|
|
106
|
+
} | {
|
|
107
|
+
action: "applySignaturesRequests";
|
|
108
|
+
id: string;
|
|
109
|
+
result: undefined;
|
|
110
|
+
data: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
action: "registerIdentity";
|
|
113
|
+
id: string;
|
|
114
|
+
result: undefined;
|
|
115
|
+
data: undefined;
|
|
116
|
+
} | {
|
|
117
|
+
action: "isRegistered";
|
|
118
|
+
id: string;
|
|
119
|
+
result: boolean;
|
|
120
|
+
data: undefined;
|
|
121
|
+
} | {
|
|
122
|
+
action: "canMessage";
|
|
123
|
+
id: string;
|
|
124
|
+
result: Map<string, boolean>;
|
|
125
|
+
data: {
|
|
126
|
+
accountAddresses: string[];
|
|
127
|
+
};
|
|
128
|
+
} | {
|
|
129
|
+
action: "inboxState";
|
|
130
|
+
id: string;
|
|
131
|
+
result: SafeInboxState;
|
|
132
|
+
data: {
|
|
133
|
+
refreshFromNetwork: boolean;
|
|
134
|
+
};
|
|
135
|
+
} | {
|
|
136
|
+
action: "getLatestInboxState";
|
|
137
|
+
id: string;
|
|
138
|
+
result: SafeInboxState;
|
|
139
|
+
data: {
|
|
140
|
+
inboxId: string;
|
|
141
|
+
};
|
|
142
|
+
} | {
|
|
143
|
+
action: "setConsentStates";
|
|
144
|
+
id: string;
|
|
145
|
+
result: undefined;
|
|
146
|
+
data: {
|
|
147
|
+
records: SafeConsent[];
|
|
148
|
+
};
|
|
149
|
+
} | {
|
|
150
|
+
action: "getConsentState";
|
|
151
|
+
id: string;
|
|
152
|
+
result: WasmConsentState;
|
|
153
|
+
data: {
|
|
154
|
+
entityType: WasmConsentEntityType;
|
|
155
|
+
entity: string;
|
|
156
|
+
};
|
|
157
|
+
} | {
|
|
158
|
+
action: "findInboxIdByAddress";
|
|
159
|
+
id: string;
|
|
160
|
+
result: string | undefined;
|
|
161
|
+
data: {
|
|
162
|
+
address: string;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Conversations actions
|
|
167
|
+
*/
|
|
168
|
+
| {
|
|
169
|
+
action: "getConversationById";
|
|
170
|
+
id: string;
|
|
171
|
+
result: SafeConversation | undefined;
|
|
172
|
+
data: {
|
|
173
|
+
id: string;
|
|
174
|
+
};
|
|
175
|
+
} | {
|
|
176
|
+
action: "getMessageById";
|
|
177
|
+
id: string;
|
|
178
|
+
result: SafeMessage | undefined;
|
|
179
|
+
data: {
|
|
180
|
+
id: string;
|
|
181
|
+
};
|
|
182
|
+
} | {
|
|
183
|
+
action: "getConversations";
|
|
184
|
+
id: string;
|
|
185
|
+
result: SafeConversation[];
|
|
186
|
+
data: {
|
|
187
|
+
options?: SafeListConversationsOptions;
|
|
188
|
+
};
|
|
189
|
+
} | {
|
|
190
|
+
action: "newGroup";
|
|
191
|
+
id: string;
|
|
192
|
+
result: SafeConversation;
|
|
193
|
+
data: {
|
|
194
|
+
accountAddresses: string[];
|
|
195
|
+
options?: SafeCreateGroupOptions;
|
|
196
|
+
};
|
|
197
|
+
} | {
|
|
198
|
+
action: "syncConversations";
|
|
199
|
+
id: string;
|
|
200
|
+
result: undefined;
|
|
201
|
+
data: undefined;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Group actions
|
|
205
|
+
*/
|
|
206
|
+
| {
|
|
207
|
+
action: "syncGroup";
|
|
208
|
+
id: string;
|
|
209
|
+
result: SafeConversation;
|
|
210
|
+
data: {
|
|
211
|
+
id: string;
|
|
212
|
+
};
|
|
213
|
+
} | {
|
|
214
|
+
action: "sendGroupMessage";
|
|
215
|
+
id: string;
|
|
216
|
+
result: string;
|
|
217
|
+
data: {
|
|
218
|
+
id: string;
|
|
219
|
+
content: SafeEncodedContent;
|
|
220
|
+
};
|
|
221
|
+
} | {
|
|
222
|
+
action: "sendOptimisticGroupMessage";
|
|
223
|
+
id: string;
|
|
224
|
+
result: string;
|
|
225
|
+
data: {
|
|
226
|
+
id: string;
|
|
227
|
+
content: SafeEncodedContent;
|
|
228
|
+
};
|
|
229
|
+
} | {
|
|
230
|
+
action: "publishGroupMessages";
|
|
231
|
+
id: string;
|
|
232
|
+
result: undefined;
|
|
233
|
+
data: {
|
|
234
|
+
id: string;
|
|
235
|
+
};
|
|
236
|
+
} | {
|
|
237
|
+
action: "getGroupMessages";
|
|
238
|
+
id: string;
|
|
239
|
+
result: SafeMessage[];
|
|
240
|
+
data: {
|
|
241
|
+
id: string;
|
|
242
|
+
options?: SafeListMessagesOptions;
|
|
243
|
+
};
|
|
244
|
+
} | {
|
|
245
|
+
action: "getGroupMembers";
|
|
246
|
+
id: string;
|
|
247
|
+
result: SafeGroupMember[];
|
|
248
|
+
data: {
|
|
249
|
+
id: string;
|
|
250
|
+
};
|
|
251
|
+
} | {
|
|
252
|
+
action: "getGroupAdmins";
|
|
253
|
+
id: string;
|
|
254
|
+
result: string[];
|
|
255
|
+
data: {
|
|
256
|
+
id: string;
|
|
257
|
+
};
|
|
258
|
+
} | {
|
|
259
|
+
action: "getGroupSuperAdmins";
|
|
260
|
+
id: string;
|
|
261
|
+
result: string[];
|
|
262
|
+
data: {
|
|
263
|
+
id: string;
|
|
264
|
+
};
|
|
265
|
+
} | {
|
|
266
|
+
action: "isGroupAdmin";
|
|
267
|
+
id: string;
|
|
268
|
+
result: boolean;
|
|
269
|
+
data: {
|
|
270
|
+
id: string;
|
|
271
|
+
inboxId: string;
|
|
272
|
+
};
|
|
273
|
+
} | {
|
|
274
|
+
action: "isGroupSuperAdmin";
|
|
275
|
+
id: string;
|
|
276
|
+
result: boolean;
|
|
277
|
+
data: {
|
|
278
|
+
id: string;
|
|
279
|
+
inboxId: string;
|
|
280
|
+
};
|
|
281
|
+
} | {
|
|
282
|
+
action: "addGroupMembers";
|
|
283
|
+
id: string;
|
|
284
|
+
result: undefined;
|
|
285
|
+
data: {
|
|
286
|
+
id: string;
|
|
287
|
+
accountAddresses: string[];
|
|
288
|
+
};
|
|
289
|
+
} | {
|
|
290
|
+
action: "removeGroupMembers";
|
|
291
|
+
id: string;
|
|
292
|
+
result: undefined;
|
|
293
|
+
data: {
|
|
294
|
+
id: string;
|
|
295
|
+
accountAddresses: string[];
|
|
296
|
+
};
|
|
297
|
+
} | {
|
|
298
|
+
action: "addGroupMembersByInboxId";
|
|
299
|
+
id: string;
|
|
300
|
+
result: undefined;
|
|
301
|
+
data: {
|
|
302
|
+
id: string;
|
|
303
|
+
inboxIds: string[];
|
|
304
|
+
};
|
|
305
|
+
} | {
|
|
306
|
+
action: "removeGroupMembersByInboxId";
|
|
307
|
+
id: string;
|
|
308
|
+
result: undefined;
|
|
309
|
+
data: {
|
|
310
|
+
id: string;
|
|
311
|
+
inboxIds: string[];
|
|
312
|
+
};
|
|
313
|
+
} | {
|
|
314
|
+
action: "addGroupAdmin";
|
|
315
|
+
id: string;
|
|
316
|
+
result: undefined;
|
|
317
|
+
data: {
|
|
318
|
+
id: string;
|
|
319
|
+
inboxId: string;
|
|
320
|
+
};
|
|
321
|
+
} | {
|
|
322
|
+
action: "removeGroupAdmin";
|
|
323
|
+
id: string;
|
|
324
|
+
result: undefined;
|
|
325
|
+
data: {
|
|
326
|
+
id: string;
|
|
327
|
+
inboxId: string;
|
|
328
|
+
};
|
|
329
|
+
} | {
|
|
330
|
+
action: "addGroupSuperAdmin";
|
|
331
|
+
id: string;
|
|
332
|
+
result: undefined;
|
|
333
|
+
data: {
|
|
334
|
+
id: string;
|
|
335
|
+
inboxId: string;
|
|
336
|
+
};
|
|
337
|
+
} | {
|
|
338
|
+
action: "removeGroupSuperAdmin";
|
|
339
|
+
id: string;
|
|
340
|
+
result: undefined;
|
|
341
|
+
data: {
|
|
342
|
+
id: string;
|
|
343
|
+
inboxId: string;
|
|
344
|
+
};
|
|
345
|
+
} | {
|
|
346
|
+
action: "updateGroupName";
|
|
347
|
+
id: string;
|
|
348
|
+
result: undefined;
|
|
349
|
+
data: {
|
|
350
|
+
id: string;
|
|
351
|
+
name: string;
|
|
352
|
+
};
|
|
353
|
+
} | {
|
|
354
|
+
action: "updateGroupDescription";
|
|
355
|
+
id: string;
|
|
356
|
+
result: undefined;
|
|
357
|
+
data: {
|
|
358
|
+
id: string;
|
|
359
|
+
description: string;
|
|
360
|
+
};
|
|
361
|
+
} | {
|
|
362
|
+
action: "updateGroupImageUrlSquare";
|
|
363
|
+
id: string;
|
|
364
|
+
result: undefined;
|
|
365
|
+
data: {
|
|
366
|
+
id: string;
|
|
367
|
+
imageUrl: string;
|
|
368
|
+
};
|
|
369
|
+
} | {
|
|
370
|
+
action: "updateGroupPinnedFrameUrl";
|
|
371
|
+
id: string;
|
|
372
|
+
result: undefined;
|
|
373
|
+
data: {
|
|
374
|
+
id: string;
|
|
375
|
+
pinnedFrameUrl: string;
|
|
376
|
+
};
|
|
377
|
+
} | {
|
|
378
|
+
action: "getGroupConsentState";
|
|
379
|
+
id: string;
|
|
380
|
+
result: WasmConsentState;
|
|
381
|
+
data: {
|
|
382
|
+
id: string;
|
|
383
|
+
};
|
|
384
|
+
} | {
|
|
385
|
+
action: "updateGroupConsentState";
|
|
386
|
+
id: string;
|
|
387
|
+
result: undefined;
|
|
388
|
+
data: {
|
|
389
|
+
id: string;
|
|
390
|
+
state: WasmConsentState;
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
type ClientEventsActions = ClientEvents["action"];
|
|
394
|
+
type ClientEventsClientMessageData = EventsClientMessageData<ClientEvents>;
|
|
395
|
+
type ClientEventsWorkerMessageData = EventsWorkerMessageData<ClientEvents>;
|
|
396
|
+
type ClientEventsResult<A extends ClientEventsActions> = EventsResult<ClientEvents, A>;
|
|
397
|
+
type ClientSendMessageData<A extends ClientEventsActions> = SendMessageData<ClientEvents, A>;
|
|
398
|
+
type ClientEventsWorkerPostMessageData<A extends ClientEventsActions> = EventsWorkerPostMessageData<ClientEvents, A>;
|
|
399
|
+
type ClientEventsClientPostMessageData<A extends ClientEventsActions> = EventsClientPostMessageData<ClientEvents, A>;
|
|
400
|
+
type ClientEventsErrorData = EventsErrorData<ClientEvents>;
|
|
401
|
+
|
|
402
|
+
type UtilsEvents = {
|
|
403
|
+
action: "generateInboxId";
|
|
404
|
+
id: string;
|
|
405
|
+
result: string;
|
|
406
|
+
data: {
|
|
407
|
+
address: string;
|
|
408
|
+
enableLogging: boolean;
|
|
409
|
+
};
|
|
410
|
+
} | {
|
|
411
|
+
action: "getInboxIdForAddress";
|
|
412
|
+
id: string;
|
|
413
|
+
result: string | undefined;
|
|
414
|
+
data: {
|
|
415
|
+
address: string;
|
|
416
|
+
env?: XmtpEnv;
|
|
417
|
+
enableLogging: boolean;
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
type UtilsEventsActions = UtilsEvents["action"];
|
|
421
|
+
type UtilsEventsClientMessageData = EventsClientMessageData<UtilsEvents>;
|
|
422
|
+
type UtilsEventsWorkerMessageData = EventsWorkerMessageData<UtilsEvents>;
|
|
423
|
+
type UtilsEventsResult<A extends UtilsEventsActions> = EventsResult<UtilsEvents, A>;
|
|
424
|
+
type UtilsSendMessageData<A extends UtilsEventsActions> = SendMessageData<UtilsEvents, A>;
|
|
425
|
+
type UtilsEventsWorkerPostMessageData<A extends UtilsEventsActions> = EventsWorkerPostMessageData<UtilsEvents, A>;
|
|
426
|
+
type UtilsEventsClientPostMessageData<A extends UtilsEventsActions> = EventsClientPostMessageData<UtilsEvents, A>;
|
|
427
|
+
type UtilsEventsErrorData = EventsErrorData<UtilsEvents>;
|
|
428
|
+
|
|
429
|
+
type GenericEvent = {
|
|
430
|
+
action: string;
|
|
431
|
+
id: string;
|
|
432
|
+
result: unknown;
|
|
433
|
+
data: unknown;
|
|
434
|
+
};
|
|
435
|
+
type EventsClientMessageData<Events extends GenericEvent> = {
|
|
436
|
+
[Action in Events["action"]]: Omit<Extract<Events, {
|
|
437
|
+
action: Action;
|
|
438
|
+
}>, "result">;
|
|
439
|
+
}[Events["action"]];
|
|
440
|
+
type EventsWorkerMessageData<Events extends GenericEvent> = {
|
|
441
|
+
[Action in Events["action"]]: Omit<Extract<Events, {
|
|
442
|
+
action: Action;
|
|
443
|
+
}>, "data">;
|
|
444
|
+
}[Events["action"]];
|
|
445
|
+
type EventsResult<Events extends GenericEvent, Action extends Events["action"]> = Extract<Events, {
|
|
446
|
+
action: Action;
|
|
447
|
+
}>["result"];
|
|
448
|
+
type SendMessageData<Events extends GenericEvent, Action extends Events["action"]> = Extract<Events, {
|
|
449
|
+
action: Action;
|
|
450
|
+
}>["data"];
|
|
451
|
+
type EventsWorkerPostMessageData<Events extends GenericEvent, Action extends Events["action"]> = Omit<Extract<Events, {
|
|
452
|
+
action: Action;
|
|
453
|
+
}>, "data">;
|
|
454
|
+
type EventsClientPostMessageData<Events extends GenericEvent, Action extends Events["action"]> = Omit<Extract<Events, {
|
|
455
|
+
action: Action;
|
|
456
|
+
}>, "result">;
|
|
457
|
+
type EventsErrorData<Events extends GenericEvent> = {
|
|
458
|
+
id: string;
|
|
459
|
+
action: Events["action"];
|
|
460
|
+
error: string;
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
declare class WorkerConversations {
|
|
464
|
+
#private;
|
|
465
|
+
constructor(client: WorkerClient, conversations: WasmConversations);
|
|
466
|
+
sync(): Promise<void>;
|
|
467
|
+
getConversationById(id: string): WorkerConversation | undefined;
|
|
468
|
+
getMessageById(id: string): SafeMessage | undefined;
|
|
469
|
+
list(options?: SafeListConversationsOptions): Promise<WorkerConversation[]>;
|
|
470
|
+
newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions): Promise<WorkerConversation>;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
declare class WorkerClient {
|
|
474
|
+
#private;
|
|
475
|
+
constructor(client: WasmClient);
|
|
476
|
+
static create(accountAddress: string, options?: Omit<ClientOptions, "codecs">): Promise<WorkerClient>;
|
|
477
|
+
get accountAddress(): string;
|
|
478
|
+
get inboxId(): string;
|
|
479
|
+
get installationId(): string;
|
|
480
|
+
get isRegistered(): boolean;
|
|
481
|
+
getCreateInboxSignatureText(): Promise<string | undefined>;
|
|
482
|
+
getAddWalletSignatureText(accountAddress: string): Promise<string | undefined>;
|
|
483
|
+
getRevokeWalletSignatureText(accountAddress: string): Promise<string | undefined>;
|
|
484
|
+
getRevokeInstallationsSignatureText(): Promise<string | undefined>;
|
|
485
|
+
addSignature(type: WasmSignatureRequestType, bytes: Uint8Array): Promise<void>;
|
|
486
|
+
applySignaturesRequests(): Promise<void>;
|
|
487
|
+
canMessage(accountAddresses: string[]): Promise<Map<string, boolean>>;
|
|
488
|
+
registerIdentity(): Promise<void>;
|
|
489
|
+
findInboxIdByAddress(address: string): Promise<string | undefined>;
|
|
490
|
+
inboxState(refreshFromNetwork: boolean): Promise<_xmtp_wasm_bindings.WasmInboxState>;
|
|
491
|
+
getLatestInboxState(inboxId: string): Promise<_xmtp_wasm_bindings.WasmInboxState>;
|
|
492
|
+
setConsentStates(records: SafeConsent[]): Promise<void>;
|
|
493
|
+
getConsentState(entityType: WasmConsentEntityType, entity: string): Promise<_xmtp_wasm_bindings.WasmConsentState>;
|
|
494
|
+
get conversations(): WorkerConversations;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
declare class WorkerConversation {
|
|
498
|
+
#private;
|
|
499
|
+
constructor(client: WorkerClient, group: WasmGroup);
|
|
500
|
+
get id(): string;
|
|
501
|
+
get name(): string;
|
|
502
|
+
updateName(name: string): Promise<void>;
|
|
503
|
+
get imageUrl(): string;
|
|
504
|
+
updateImageUrl(imageUrl: string): Promise<void>;
|
|
505
|
+
get description(): string;
|
|
506
|
+
updateDescription(description: string): Promise<void>;
|
|
507
|
+
get pinnedFrameUrl(): string;
|
|
508
|
+
updatePinnedFrameUrl(pinnedFrameUrl: string): Promise<void>;
|
|
509
|
+
get isActive(): boolean;
|
|
510
|
+
get addedByInboxId(): string;
|
|
511
|
+
get createdAtNs(): bigint;
|
|
512
|
+
get metadata(): {
|
|
513
|
+
creatorInboxId: string;
|
|
514
|
+
conversationType: string;
|
|
515
|
+
};
|
|
516
|
+
members(): Promise<WasmGroupMember[]>;
|
|
517
|
+
get admins(): string[];
|
|
518
|
+
get superAdmins(): string[];
|
|
519
|
+
get permissions(): {
|
|
520
|
+
policyType: _xmtp_wasm_bindings.WasmGroupPermissionsOptions;
|
|
521
|
+
policySet: _xmtp_wasm_bindings.WasmPermissionPolicySet;
|
|
522
|
+
};
|
|
523
|
+
isAdmin(inboxId: string): boolean;
|
|
524
|
+
isSuperAdmin(inboxId: string): boolean;
|
|
525
|
+
sync(): Promise<void>;
|
|
526
|
+
addMembers(accountAddresses: string[]): Promise<void>;
|
|
527
|
+
addMembersByInboxId(inboxIds: string[]): Promise<void>;
|
|
528
|
+
removeMembers(accountAddresses: string[]): Promise<void>;
|
|
529
|
+
removeMembersByInboxId(inboxIds: string[]): Promise<void>;
|
|
530
|
+
addAdmin(inboxId: string): Promise<void>;
|
|
531
|
+
removeAdmin(inboxId: string): Promise<void>;
|
|
532
|
+
addSuperAdmin(inboxId: string): Promise<void>;
|
|
533
|
+
removeSuperAdmin(inboxId: string): Promise<void>;
|
|
534
|
+
publishMessages(): Promise<void>;
|
|
535
|
+
sendOptimistic(encodedContent: WasmEncodedContent): string;
|
|
536
|
+
send(encodedContent: WasmEncodedContent): Promise<string>;
|
|
537
|
+
messages(options?: SafeListMessagesOptions): _xmtp_wasm_bindings.WasmMessage[];
|
|
538
|
+
get consentState(): WasmConsentState;
|
|
539
|
+
updateConsentState(state: WasmConsentState): void;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
declare const toContentTypeId: (contentTypeId: WasmContentTypeId) => ContentTypeId;
|
|
543
|
+
declare const fromContentTypeId: (contentTypeId: ContentTypeId) => WasmContentTypeId;
|
|
544
|
+
type SafeContentTypeId = {
|
|
545
|
+
authorityId: string;
|
|
546
|
+
typeId: string;
|
|
547
|
+
versionMajor: number;
|
|
548
|
+
versionMinor: number;
|
|
549
|
+
};
|
|
550
|
+
declare const toSafeContentTypeId: (contentTypeId: ContentTypeId) => SafeContentTypeId;
|
|
551
|
+
declare const fromSafeContentTypeId: (contentTypeId: SafeContentTypeId) => ContentTypeId;
|
|
552
|
+
declare const toEncodedContent: (content: WasmEncodedContent) => EncodedContent;
|
|
553
|
+
declare const fromEncodedContent: (content: EncodedContent) => WasmEncodedContent;
|
|
554
|
+
type SafeEncodedContent = {
|
|
555
|
+
type: SafeContentTypeId;
|
|
556
|
+
parameters: Record<string, string>;
|
|
557
|
+
fallback?: string;
|
|
558
|
+
compression?: number;
|
|
559
|
+
content: Uint8Array;
|
|
560
|
+
};
|
|
561
|
+
declare const toSafeEncodedContent: (content: EncodedContent) => SafeEncodedContent;
|
|
562
|
+
declare const fromSafeEncodedContent: (content: SafeEncodedContent) => EncodedContent;
|
|
563
|
+
type SafeMessage = {
|
|
564
|
+
content: SafeEncodedContent;
|
|
565
|
+
convoId: string;
|
|
566
|
+
deliveryStatus: WasmDeliveryStatus;
|
|
567
|
+
id: string;
|
|
568
|
+
kind: WasmGroupMessageKind;
|
|
569
|
+
senderInboxId: string;
|
|
570
|
+
sentAtNs: bigint;
|
|
571
|
+
};
|
|
572
|
+
declare const toSafeMessage: (message: WasmMessage) => SafeMessage;
|
|
573
|
+
type SafeListMessagesOptions = {
|
|
574
|
+
delivery_status?: WasmDeliveryStatus;
|
|
575
|
+
limit?: bigint;
|
|
576
|
+
sent_after_ns?: bigint;
|
|
577
|
+
sent_before_ns?: bigint;
|
|
578
|
+
};
|
|
579
|
+
declare const toSafeListMessagesOptions: (options: WasmListMessagesOptions) => SafeListMessagesOptions;
|
|
580
|
+
declare const fromSafeListMessagesOptions: (options: SafeListMessagesOptions) => WasmListMessagesOptions;
|
|
581
|
+
type SafeListConversationsOptions = {
|
|
582
|
+
created_after_ns?: bigint;
|
|
583
|
+
created_before_ns?: bigint;
|
|
584
|
+
limit?: bigint;
|
|
585
|
+
};
|
|
586
|
+
declare const toSafeListConversationsOptions: (options: WasmListConversationsOptions) => SafeListConversationsOptions;
|
|
587
|
+
declare const fromSafeListConversationsOptions: (options: SafeListConversationsOptions) => WasmListConversationsOptions;
|
|
588
|
+
type SafeCreateGroupOptions = {
|
|
589
|
+
permissions?: WasmGroupPermissionsOptions;
|
|
590
|
+
name?: string;
|
|
591
|
+
imageUrlSquare?: string;
|
|
592
|
+
description?: string;
|
|
593
|
+
pinnedFrameUrl?: string;
|
|
594
|
+
};
|
|
595
|
+
declare const toSafeCreateGroupOptions: (options: WasmCreateGroupOptions) => SafeCreateGroupOptions;
|
|
596
|
+
declare const fromSafeCreateGroupOptions: (options: SafeCreateGroupOptions) => WasmCreateGroupOptions;
|
|
597
|
+
type SafeConversation = {
|
|
598
|
+
id: string;
|
|
599
|
+
name: string;
|
|
600
|
+
imageUrl: string;
|
|
601
|
+
description: string;
|
|
602
|
+
pinnedFrameUrl: string;
|
|
603
|
+
permissions: {
|
|
604
|
+
policyType: WasmGroupPermissionsOptions;
|
|
605
|
+
policySet: {
|
|
606
|
+
addAdminPolicy: WasmPermissionPolicy;
|
|
607
|
+
addMemberPolicy: WasmPermissionPolicy;
|
|
608
|
+
removeAdminPolicy: WasmPermissionPolicy;
|
|
609
|
+
removeMemberPolicy: WasmPermissionPolicy;
|
|
610
|
+
updateGroupDescriptionPolicy: WasmPermissionPolicy;
|
|
611
|
+
updateGroupImageUrlSquarePolicy: WasmPermissionPolicy;
|
|
612
|
+
updateGroupNamePolicy: WasmPermissionPolicy;
|
|
613
|
+
updateGroupPinnedFrameUrlPolicy: WasmPermissionPolicy;
|
|
614
|
+
};
|
|
615
|
+
};
|
|
616
|
+
isActive: boolean;
|
|
617
|
+
addedByInboxId: string;
|
|
618
|
+
metadata: {
|
|
619
|
+
creatorInboxId: string;
|
|
620
|
+
conversationType: string;
|
|
621
|
+
};
|
|
622
|
+
admins: string[];
|
|
623
|
+
superAdmins: string[];
|
|
624
|
+
createdAtNs: bigint;
|
|
625
|
+
};
|
|
626
|
+
declare const toSafeConversation: (conversation: WorkerConversation) => SafeConversation;
|
|
627
|
+
type SafeInstallation = {
|
|
628
|
+
id: string;
|
|
629
|
+
clientTimestampNs?: bigint;
|
|
630
|
+
};
|
|
631
|
+
declare const toSafeInstallation: (installation: WasmInstallation) => SafeInstallation;
|
|
632
|
+
type SafeInboxState = {
|
|
633
|
+
accountAddresses: string[];
|
|
634
|
+
inboxId: string;
|
|
635
|
+
installations: SafeInstallation[];
|
|
636
|
+
recoveryAddress: string;
|
|
637
|
+
};
|
|
638
|
+
declare const toSafeInboxState: (inboxState: WasmInboxState) => SafeInboxState;
|
|
639
|
+
type SafeConsent = {
|
|
640
|
+
entity: string;
|
|
641
|
+
entityType: WasmConsentEntityType;
|
|
642
|
+
state: WasmConsentState;
|
|
643
|
+
};
|
|
644
|
+
declare const toSafeConsent: (consent: WasmConsent) => SafeConsent;
|
|
645
|
+
declare const fromSafeConsent: (consent: SafeConsent) => WasmConsent;
|
|
646
|
+
type SafeGroupMember = {
|
|
647
|
+
accountAddresses: string[];
|
|
648
|
+
consentState: WasmConsentState;
|
|
649
|
+
inboxId: string;
|
|
650
|
+
installationIds: string[];
|
|
651
|
+
permissionLevel: WasmPermissionLevel;
|
|
652
|
+
};
|
|
653
|
+
declare const toSafeGroupMember: (member: WasmGroupMember) => SafeGroupMember;
|
|
654
|
+
declare const fromSafeGroupMember: (member: SafeGroupMember) => WasmGroupMember;
|
|
655
|
+
|
|
656
|
+
declare class ClientWorkerClass {
|
|
657
|
+
#private;
|
|
658
|
+
constructor(worker: Worker, enableLogging: boolean);
|
|
659
|
+
sendMessage<A extends ClientEventsActions>(action: A, data: ClientSendMessageData<A>): Promise<ClientEventsResult<A>>;
|
|
660
|
+
handleMessage: (event: MessageEvent<ClientEventsWorkerMessageData | ClientEventsErrorData>) => void;
|
|
661
|
+
close(): void;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
type MessageKind = "application" | "membership_change";
|
|
665
|
+
type MessageDeliveryStatus = "unpublished" | "published" | "failed";
|
|
666
|
+
declare class DecodedMessage {
|
|
667
|
+
#private;
|
|
668
|
+
content: any;
|
|
669
|
+
contentType: ContentTypeId;
|
|
670
|
+
conversationId: string;
|
|
671
|
+
deliveryStatus: MessageDeliveryStatus;
|
|
672
|
+
fallback?: string;
|
|
673
|
+
compression?: number;
|
|
674
|
+
id: string;
|
|
675
|
+
kind: MessageKind;
|
|
676
|
+
parameters: Map<string, string>;
|
|
677
|
+
senderInboxId: string;
|
|
678
|
+
sentAtNs: bigint;
|
|
679
|
+
constructor(client: Client, message: SafeMessage);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
declare class Conversation {
|
|
683
|
+
#private;
|
|
684
|
+
constructor(client: Client, id: string, data?: SafeConversation);
|
|
685
|
+
get id(): string;
|
|
686
|
+
get name(): string | undefined;
|
|
687
|
+
updateName(name: string): Promise<void>;
|
|
688
|
+
get imageUrl(): string | undefined;
|
|
689
|
+
updateImageUrl(imageUrl: string): Promise<void>;
|
|
690
|
+
get description(): string | undefined;
|
|
691
|
+
updateDescription(description: string): Promise<void>;
|
|
692
|
+
get pinnedFrameUrl(): string | undefined;
|
|
693
|
+
updatePinnedFrameUrl(pinnedFrameUrl: string): Promise<void>;
|
|
694
|
+
get isActive(): boolean | undefined;
|
|
695
|
+
get addedByInboxId(): string | undefined;
|
|
696
|
+
get createdAtNs(): bigint | undefined;
|
|
697
|
+
get createdAt(): Date | undefined;
|
|
698
|
+
get metadata(): {
|
|
699
|
+
creatorInboxId: string;
|
|
700
|
+
conversationType: string;
|
|
701
|
+
} | undefined;
|
|
702
|
+
members(): Promise<SafeGroupMember[]>;
|
|
703
|
+
admins(): Promise<string[]>;
|
|
704
|
+
superAdmins(): Promise<string[]>;
|
|
705
|
+
get permissions(): {
|
|
706
|
+
policyType: _xmtp_wasm_bindings.WasmGroupPermissionsOptions;
|
|
707
|
+
policySet: {
|
|
708
|
+
addAdminPolicy: _xmtp_wasm_bindings.WasmPermissionPolicy;
|
|
709
|
+
addMemberPolicy: _xmtp_wasm_bindings.WasmPermissionPolicy;
|
|
710
|
+
removeAdminPolicy: _xmtp_wasm_bindings.WasmPermissionPolicy;
|
|
711
|
+
removeMemberPolicy: _xmtp_wasm_bindings.WasmPermissionPolicy;
|
|
712
|
+
updateGroupDescriptionPolicy: _xmtp_wasm_bindings.WasmPermissionPolicy;
|
|
713
|
+
updateGroupImageUrlSquarePolicy: _xmtp_wasm_bindings.WasmPermissionPolicy;
|
|
714
|
+
updateGroupNamePolicy: _xmtp_wasm_bindings.WasmPermissionPolicy;
|
|
715
|
+
updateGroupPinnedFrameUrlPolicy: _xmtp_wasm_bindings.WasmPermissionPolicy;
|
|
716
|
+
};
|
|
717
|
+
} | undefined;
|
|
718
|
+
isAdmin(inboxId: string): Promise<boolean>;
|
|
719
|
+
isSuperAdmin(inboxId: string): Promise<boolean>;
|
|
720
|
+
sync(): Promise<void>;
|
|
721
|
+
addMembers(accountAddresses: string[]): Promise<undefined>;
|
|
722
|
+
addMembersByInboxId(inboxIds: string[]): Promise<undefined>;
|
|
723
|
+
removeMembers(accountAddresses: string[]): Promise<undefined>;
|
|
724
|
+
removeMembersByInboxId(inboxIds: string[]): Promise<undefined>;
|
|
725
|
+
addAdmin(inboxId: string): Promise<undefined>;
|
|
726
|
+
removeAdmin(inboxId: string): Promise<undefined>;
|
|
727
|
+
addSuperAdmin(inboxId: string): Promise<undefined>;
|
|
728
|
+
removeSuperAdmin(inboxId: string): Promise<undefined>;
|
|
729
|
+
publishMessages(): Promise<undefined>;
|
|
730
|
+
sendOptimistic(content: any, contentType?: ContentTypeId): Promise<string>;
|
|
731
|
+
send(content: any, contentType?: ContentTypeId): Promise<string>;
|
|
732
|
+
messages(options?: SafeListMessagesOptions): Promise<DecodedMessage[]>;
|
|
733
|
+
consentState(): Promise<WasmConsentState>;
|
|
734
|
+
updateConsentState(state: WasmConsentState): Promise<undefined>;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
declare class Conversations {
|
|
738
|
+
#private;
|
|
739
|
+
constructor(client: Client);
|
|
740
|
+
sync(): Promise<undefined>;
|
|
741
|
+
getConversationById(id: string): Promise<SafeConversation | undefined>;
|
|
742
|
+
getMessageById(id: string): Promise<SafeMessage | undefined>;
|
|
743
|
+
list(options?: SafeListConversationsOptions): Promise<Conversation[]>;
|
|
744
|
+
newGroup(accountAddresses: string[], options?: SafeCreateGroupOptions): Promise<Conversation>;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
declare class Client extends ClientWorkerClass {
|
|
748
|
+
#private;
|
|
749
|
+
address: string;
|
|
750
|
+
options?: ClientOptions;
|
|
751
|
+
constructor(address: string, options?: ClientOptions);
|
|
752
|
+
init(): Promise<void>;
|
|
753
|
+
static create(address: string, options?: ClientOptions): Promise<Client>;
|
|
754
|
+
get isReady(): boolean;
|
|
755
|
+
get inboxId(): string | undefined;
|
|
756
|
+
get installationId(): string | undefined;
|
|
757
|
+
getCreateInboxSignatureText(): Promise<string | undefined>;
|
|
758
|
+
getAddWalletSignatureText(accountAddress: string): Promise<string | undefined>;
|
|
759
|
+
getRevokeWalletSignatureText(accountAddress: string): Promise<string | undefined>;
|
|
760
|
+
addSignature(type: WasmSignatureRequestType, bytes: Uint8Array): Promise<undefined>;
|
|
761
|
+
applySignaturesRequests(): Promise<undefined>;
|
|
762
|
+
registerIdentity(): Promise<undefined>;
|
|
763
|
+
isRegistered(): Promise<boolean>;
|
|
764
|
+
canMessage(accountAddresses: string[]): Promise<Map<string, boolean>>;
|
|
765
|
+
findInboxIdByAddress(address: string): Promise<string | undefined>;
|
|
766
|
+
inboxState(refreshFromNetwork: boolean): Promise<SafeInboxState>;
|
|
767
|
+
getLatestInboxState(inboxId: string): Promise<SafeInboxState>;
|
|
768
|
+
setConsentStates(records: SafeConsent[]): Promise<undefined>;
|
|
769
|
+
getConsentState(entityType: WasmConsentEntityType, entity: string): Promise<_xmtp_wasm_bindings.WasmConsentState>;
|
|
770
|
+
get conversations(): Conversations;
|
|
771
|
+
codecFor(contentType: ContentTypeId): ContentCodec | undefined;
|
|
772
|
+
encodeContent(content: any, contentType: ContentTypeId): SafeEncodedContent;
|
|
773
|
+
decodeContent(message: SafeMessage, contentType: ContentTypeId): any;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
declare class UtilsWorkerClass {
|
|
777
|
+
#private;
|
|
778
|
+
constructor(worker: Worker, enableLogging: boolean);
|
|
779
|
+
sendMessage<A extends UtilsEventsActions>(action: A, data: UtilsSendMessageData<A>): Promise<UtilsEventsResult<A>>;
|
|
780
|
+
handleMessage: (event: MessageEvent<UtilsEventsWorkerMessageData | UtilsEventsErrorData>) => void;
|
|
781
|
+
close(): void;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
declare class Utils extends UtilsWorkerClass {
|
|
785
|
+
#private;
|
|
786
|
+
constructor(enableLogging?: boolean);
|
|
787
|
+
generateInboxId(address: string): Promise<string>;
|
|
788
|
+
getInboxIdForAddress(address: string, env?: XmtpEnv): Promise<string | undefined>;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
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 EncryptionOptions, type EventsClientMessageData, type EventsClientPostMessageData, type EventsErrorData, type EventsResult, type EventsWorkerMessageData, type EventsWorkerPostMessageData, type GenericEvent, type MessageDeliveryStatus, type MessageKind, type NetworkOptions, type OtherOptions, type SafeConsent, type SafeContentTypeId, type SafeConversation, type SafeCreateGroupOptions, type SafeEncodedContent, type SafeGroupMember, type SafeInboxState, type SafeInstallation, type SafeListConversationsOptions, type SafeListMessagesOptions, type SafeMessage, type SendMessageData, 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, toContentTypeId, toEncodedContent, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeInboxState, toSafeInstallation, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage };
|