@xmtp/browser-sdk 0.0.23 → 1.0.0-rc1
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/README.md +2 -1
- package/dist/index.d.ts +70 -61
- 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 +1 -1
- package/dist/workers/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/Client.ts +44 -40
- package/src/Conversation.ts +6 -0
- package/src/Conversations.ts +28 -18
- package/src/Group.ts +7 -6
- package/src/Utils.ts +6 -5
- package/src/WorkerClient.ts +15 -17
- package/src/WorkerConversation.ts +11 -6
- package/src/WorkerConversations.ts +13 -9
- package/src/index.ts +5 -1
- package/src/types/clientEvents.ts +24 -15
- package/src/types/utilsEvents.ts +4 -3
- package/src/utils/conversions.ts +8 -7
- package/src/utils/createClient.ts +9 -13
- package/src/utils/signer.ts +10 -5
- package/src/workers/client.ts +37 -32
- package/src/workers/utils.ts +14 -13
package/src/Client.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
GroupMessageKind,
|
|
12
12
|
SignatureRequestType,
|
|
13
13
|
type ConsentEntityType,
|
|
14
|
+
type Identifier,
|
|
14
15
|
} from "@xmtp/wasm-bindings";
|
|
15
16
|
import { ClientWorkerClass } from "@/ClientWorkerClass";
|
|
16
17
|
import { Conversations } from "@/Conversations";
|
|
@@ -24,7 +25,6 @@ import {
|
|
|
24
25
|
import { type Signer } from "@/utils/signer";
|
|
25
26
|
|
|
26
27
|
export class Client extends ClientWorkerClass {
|
|
27
|
-
#accountAddress: string;
|
|
28
28
|
#codecs: Map<string, ContentCodec>;
|
|
29
29
|
#conversations: Conversations;
|
|
30
30
|
#encryptionKey: Uint8Array;
|
|
@@ -37,7 +37,6 @@ export class Client extends ClientWorkerClass {
|
|
|
37
37
|
|
|
38
38
|
constructor(
|
|
39
39
|
signer: Signer,
|
|
40
|
-
accountAddress: string,
|
|
41
40
|
encryptionKey: Uint8Array,
|
|
42
41
|
options?: ClientOptions,
|
|
43
42
|
) {
|
|
@@ -48,7 +47,6 @@ export class Client extends ClientWorkerClass {
|
|
|
48
47
|
worker,
|
|
49
48
|
options?.loggingLevel !== undefined && options.loggingLevel !== "off",
|
|
50
49
|
);
|
|
51
|
-
this.#accountAddress = accountAddress;
|
|
52
50
|
this.options = options;
|
|
53
51
|
this.#encryptionKey = encryptionKey;
|
|
54
52
|
this.#signer = signer;
|
|
@@ -63,13 +61,9 @@ export class Client extends ClientWorkerClass {
|
|
|
63
61
|
);
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
get accountAddress() {
|
|
67
|
-
return this.#accountAddress;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
64
|
async init() {
|
|
71
65
|
const result = await this.sendMessage("init", {
|
|
72
|
-
|
|
66
|
+
identifier: await this.#signer.getIdentifier(),
|
|
73
67
|
encryptionKey: this.#encryptionKey,
|
|
74
68
|
options: this.options,
|
|
75
69
|
});
|
|
@@ -84,8 +78,7 @@ export class Client extends ClientWorkerClass {
|
|
|
84
78
|
encryptionKey: Uint8Array,
|
|
85
79
|
options?: ClientOptions,
|
|
86
80
|
) {
|
|
87
|
-
const
|
|
88
|
-
const client = new Client(signer, address, encryptionKey, options);
|
|
81
|
+
const client = new Client(signer, encryptionKey, options);
|
|
89
82
|
|
|
90
83
|
await client.init();
|
|
91
84
|
|
|
@@ -104,6 +97,10 @@ export class Client extends ClientWorkerClass {
|
|
|
104
97
|
return this.#inboxId;
|
|
105
98
|
}
|
|
106
99
|
|
|
100
|
+
async accountIdentifier() {
|
|
101
|
+
return this.#signer.getIdentifier();
|
|
102
|
+
}
|
|
103
|
+
|
|
107
104
|
get installationId() {
|
|
108
105
|
return this.#installationId;
|
|
109
106
|
}
|
|
@@ -134,7 +131,7 @@ export class Client extends ClientWorkerClass {
|
|
|
134
131
|
* throw an error.
|
|
135
132
|
*/
|
|
136
133
|
async unsafe_addAccountSignatureText(
|
|
137
|
-
|
|
134
|
+
newIdentifier: Identifier,
|
|
138
135
|
allowInboxReassign: boolean = false,
|
|
139
136
|
) {
|
|
140
137
|
if (!allowInboxReassign) {
|
|
@@ -144,7 +141,7 @@ export class Client extends ClientWorkerClass {
|
|
|
144
141
|
}
|
|
145
142
|
|
|
146
143
|
return this.sendMessage("addAccountSignatureText", {
|
|
147
|
-
|
|
144
|
+
newIdentifier,
|
|
148
145
|
});
|
|
149
146
|
}
|
|
150
147
|
|
|
@@ -155,8 +152,10 @@ export class Client extends ClientWorkerClass {
|
|
|
155
152
|
*
|
|
156
153
|
* It is highly recommended to use the `removeAccount` function instead.
|
|
157
154
|
*/
|
|
158
|
-
async unsafe_removeAccountSignatureText(
|
|
159
|
-
return this.sendMessage("removeAccountSignatureText", {
|
|
155
|
+
async unsafe_removeAccountSignatureText(identifier: Identifier) {
|
|
156
|
+
return this.sendMessage("removeAccountSignatureText", {
|
|
157
|
+
identifier,
|
|
158
|
+
});
|
|
160
159
|
}
|
|
161
160
|
|
|
162
161
|
/**
|
|
@@ -203,18 +202,21 @@ export class Client extends ClientWorkerClass {
|
|
|
203
202
|
) {
|
|
204
203
|
const signature = await signer.signMessage(signatureText);
|
|
205
204
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
205
|
+
switch (signer.type) {
|
|
206
|
+
case "SCW":
|
|
207
|
+
await this.sendMessage("addScwSignature", {
|
|
208
|
+
type: signatureType,
|
|
209
|
+
bytes: signature,
|
|
210
|
+
chainId: signer.getChainId(),
|
|
211
|
+
blockNumber: signer.getBlockNumber?.(),
|
|
212
|
+
});
|
|
213
|
+
break;
|
|
214
|
+
case "EOA":
|
|
215
|
+
await this.sendMessage("addEcdsaSignature", {
|
|
216
|
+
type: signatureType,
|
|
217
|
+
bytes: signature,
|
|
218
|
+
});
|
|
219
|
+
break;
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
222
|
|
|
@@ -261,8 +263,8 @@ export class Client extends ClientWorkerClass {
|
|
|
261
263
|
allowInboxReassign: boolean = false,
|
|
262
264
|
) {
|
|
263
265
|
// check for existing inbox id
|
|
264
|
-
const existingInboxId = await this.
|
|
265
|
-
await newAccountSigner.
|
|
266
|
+
const existingInboxId = await this.findInboxIdByIdentifier(
|
|
267
|
+
await newAccountSigner.getIdentifier(),
|
|
266
268
|
);
|
|
267
269
|
|
|
268
270
|
if (existingInboxId && !allowInboxReassign) {
|
|
@@ -272,7 +274,7 @@ export class Client extends ClientWorkerClass {
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
const signatureText = await this.unsafe_addAccountSignatureText(
|
|
275
|
-
await newAccountSigner.
|
|
277
|
+
await newAccountSigner.getIdentifier(),
|
|
276
278
|
true,
|
|
277
279
|
);
|
|
278
280
|
|
|
@@ -289,9 +291,9 @@ export class Client extends ClientWorkerClass {
|
|
|
289
291
|
await this.unsafe_applySignatures();
|
|
290
292
|
}
|
|
291
293
|
|
|
292
|
-
async removeAccount(
|
|
294
|
+
async removeAccount(accountIdentifier: Identifier) {
|
|
293
295
|
const signatureText =
|
|
294
|
-
await this.unsafe_removeAccountSignatureText(
|
|
296
|
+
await this.unsafe_removeAccountSignatureText(accountIdentifier);
|
|
295
297
|
|
|
296
298
|
if (!signatureText) {
|
|
297
299
|
throw new Error("Unable to generate remove account signature text");
|
|
@@ -346,15 +348,17 @@ export class Client extends ClientWorkerClass {
|
|
|
346
348
|
return this.sendMessage("isRegistered", undefined);
|
|
347
349
|
}
|
|
348
350
|
|
|
349
|
-
async canMessage(
|
|
350
|
-
return this.sendMessage("canMessage", {
|
|
351
|
+
async canMessage(identifiers: Identifier[]) {
|
|
352
|
+
return this.sendMessage("canMessage", { identifiers });
|
|
351
353
|
}
|
|
352
354
|
|
|
353
|
-
static async canMessage(
|
|
354
|
-
const accountAddress = "0x0000000000000000000000000000000000000000";
|
|
355
|
+
static async canMessage(identifiers: Identifier[], env?: XmtpEnv) {
|
|
355
356
|
const signer: Signer = {
|
|
356
|
-
|
|
357
|
-
|
|
357
|
+
type: "EOA",
|
|
358
|
+
getIdentifier: () => ({
|
|
359
|
+
identifier: "0x0000000000000000000000000000000000000000",
|
|
360
|
+
identifierKind: "Ethereum",
|
|
361
|
+
}),
|
|
358
362
|
signMessage: () => new Uint8Array(),
|
|
359
363
|
};
|
|
360
364
|
const client = await Client.create(
|
|
@@ -365,11 +369,11 @@ export class Client extends ClientWorkerClass {
|
|
|
365
369
|
env,
|
|
366
370
|
},
|
|
367
371
|
);
|
|
368
|
-
return client.canMessage(
|
|
372
|
+
return client.canMessage(identifiers);
|
|
369
373
|
}
|
|
370
374
|
|
|
371
|
-
async
|
|
372
|
-
return this.sendMessage("
|
|
375
|
+
async findInboxIdByIdentifier(identifier: Identifier) {
|
|
376
|
+
return this.sendMessage("findInboxIdByIdentifier", { identifier });
|
|
373
377
|
}
|
|
374
378
|
|
|
375
379
|
async inboxState(refreshFromNetwork?: boolean) {
|
package/src/Conversation.ts
CHANGED
package/src/Conversations.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConversationType,
|
|
3
3
|
type ConsentState,
|
|
4
|
+
type Identifier,
|
|
4
5
|
type UserPreference,
|
|
5
6
|
} from "@xmtp/wasm-bindings";
|
|
6
7
|
import { v4 } from "uuid";
|
|
@@ -97,38 +98,47 @@ export class Conversations {
|
|
|
97
98
|
);
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
async
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
async newGroupWithIdentifiers(
|
|
102
|
+
identifiers: Identifier[],
|
|
103
|
+
options?: SafeCreateGroupOptions,
|
|
104
|
+
) {
|
|
105
|
+
const conversation = await this.#client.sendMessage(
|
|
106
|
+
"newGroupWithIdentifiers",
|
|
107
|
+
{
|
|
108
|
+
identifiers,
|
|
109
|
+
options,
|
|
110
|
+
},
|
|
111
|
+
);
|
|
105
112
|
|
|
106
113
|
return new Group(this.#client, conversation.id, conversation);
|
|
107
114
|
}
|
|
108
115
|
|
|
109
|
-
async
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
async newGroup(inboxIds: string[], options?: SafeCreateGroupOptions) {
|
|
117
|
+
const conversation = await this.#client.sendMessage(
|
|
118
|
+
"newGroupWithInboxIds",
|
|
119
|
+
{
|
|
120
|
+
inboxIds,
|
|
121
|
+
options,
|
|
122
|
+
},
|
|
123
|
+
);
|
|
117
124
|
|
|
118
125
|
return new Group(this.#client, conversation.id, conversation);
|
|
119
126
|
}
|
|
120
127
|
|
|
121
|
-
async
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
async newDmWithIdentifier(
|
|
129
|
+
identifier: Identifier,
|
|
130
|
+
options?: SafeCreateDmOptions,
|
|
131
|
+
) {
|
|
132
|
+
const conversation = await this.#client.sendMessage("newDmWithIdentifier", {
|
|
133
|
+
identifier,
|
|
124
134
|
options,
|
|
125
135
|
});
|
|
126
136
|
|
|
127
137
|
return new Dm(this.#client, conversation.id, conversation);
|
|
128
138
|
}
|
|
129
139
|
|
|
130
|
-
async
|
|
131
|
-
const conversation = await this.#client.sendMessage("
|
|
140
|
+
async newDm(inboxId: string, options?: SafeCreateDmOptions) {
|
|
141
|
+
const conversation = await this.#client.sendMessage("newDmWithInboxId", {
|
|
132
142
|
inboxId,
|
|
133
143
|
options,
|
|
134
144
|
});
|
package/src/Group.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Identifier,
|
|
2
3
|
MetadataField,
|
|
3
4
|
PermissionPolicy,
|
|
4
5
|
PermissionUpdateType,
|
|
@@ -132,28 +133,28 @@ export class Group extends Conversation {
|
|
|
132
133
|
return superAdmins.includes(inboxId);
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
async
|
|
136
|
+
async addMembersByIdentifiers(identifiers: Identifier[]) {
|
|
136
137
|
return this.#client.sendMessage("addGroupMembers", {
|
|
137
138
|
id: this.#id,
|
|
138
|
-
|
|
139
|
+
identifiers,
|
|
139
140
|
});
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
async
|
|
143
|
+
async addMembers(inboxIds: string[]) {
|
|
143
144
|
return this.#client.sendMessage("addGroupMembersByInboxId", {
|
|
144
145
|
id: this.#id,
|
|
145
146
|
inboxIds,
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
async
|
|
150
|
+
async removeMembersByIdentifiers(identifiers: Identifier[]) {
|
|
150
151
|
return this.#client.sendMessage("removeGroupMembers", {
|
|
151
152
|
id: this.#id,
|
|
152
|
-
|
|
153
|
+
identifiers,
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
async
|
|
157
|
+
async removeMembers(inboxIds: string[]) {
|
|
157
158
|
return this.#client.sendMessage("removeGroupMembersByInboxId", {
|
|
158
159
|
id: this.#id,
|
|
159
160
|
inboxIds,
|
package/src/Utils.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Identifier } from "@xmtp/wasm-bindings";
|
|
1
2
|
import type { XmtpEnv } from "@/types/options";
|
|
2
3
|
import { UtilsWorkerClass } from "@/UtilsWorkerClass";
|
|
3
4
|
|
|
@@ -11,16 +12,16 @@ export class Utils extends UtilsWorkerClass {
|
|
|
11
12
|
this.#enableLogging = enableLogging ?? false;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
async generateInboxId(
|
|
15
|
+
async generateInboxId(identifier: Identifier) {
|
|
15
16
|
return this.sendMessage("generateInboxId", {
|
|
16
|
-
|
|
17
|
+
identifier,
|
|
17
18
|
enableLogging: this.#enableLogging,
|
|
18
19
|
});
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
async
|
|
22
|
-
return this.sendMessage("
|
|
23
|
-
|
|
22
|
+
async getInboxIdForIdentifier(identifier: Identifier, env?: XmtpEnv) {
|
|
23
|
+
return this.sendMessage("getInboxIdForIdentifier", {
|
|
24
|
+
identifier,
|
|
24
25
|
env,
|
|
25
26
|
enableLogging: this.#enableLogging,
|
|
26
27
|
});
|
package/src/WorkerClient.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
verifySignedWithPublicKey,
|
|
3
3
|
type Client,
|
|
4
4
|
type ConsentEntityType,
|
|
5
|
+
type Identifier,
|
|
5
6
|
type SignatureRequestType,
|
|
6
7
|
} from "@xmtp/wasm-bindings";
|
|
7
8
|
import type { ClientOptions } from "@/types";
|
|
@@ -14,25 +15,22 @@ export class WorkerClient {
|
|
|
14
15
|
|
|
15
16
|
#conversations: WorkerConversations;
|
|
16
17
|
|
|
17
|
-
#accountAddress: string;
|
|
18
|
-
|
|
19
18
|
constructor(client: Client) {
|
|
20
19
|
this.#client = client;
|
|
21
|
-
this.#accountAddress = client.accountAddress;
|
|
22
20
|
this.#conversations = new WorkerConversations(this, client.conversations());
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
static async create(
|
|
26
|
-
|
|
24
|
+
identifier: Identifier,
|
|
27
25
|
encryptionKey: Uint8Array,
|
|
28
26
|
options?: Omit<ClientOptions, "codecs">,
|
|
29
27
|
) {
|
|
30
|
-
const client = await createClient(
|
|
28
|
+
const client = await createClient(identifier, encryptionKey, options);
|
|
31
29
|
return new WorkerClient(client);
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
get
|
|
35
|
-
return this.#
|
|
32
|
+
get accountIdentifier() {
|
|
33
|
+
return this.#client.accountIdentifier;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
get inboxId() {
|
|
@@ -59,17 +57,17 @@ export class WorkerClient {
|
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
async addAccountSignatureText(
|
|
60
|
+
async addAccountSignatureText(identifier: Identifier) {
|
|
63
61
|
try {
|
|
64
|
-
return await this.#client.addWalletSignatureText(
|
|
62
|
+
return await this.#client.addWalletSignatureText(identifier);
|
|
65
63
|
} catch {
|
|
66
64
|
return undefined;
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
async removeAccountSignatureText(
|
|
68
|
+
async removeAccountSignatureText(identifier: Identifier) {
|
|
71
69
|
try {
|
|
72
|
-
return await this.#client.revokeWalletSignatureText(
|
|
70
|
+
return await this.#client.revokeWalletSignatureText(identifier);
|
|
73
71
|
} catch {
|
|
74
72
|
return undefined;
|
|
75
73
|
}
|
|
@@ -93,8 +91,8 @@ export class WorkerClient {
|
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
|
|
96
|
-
async
|
|
97
|
-
return this.#client.
|
|
94
|
+
async addEcdsaSignature(type: SignatureRequestType, bytes: Uint8Array) {
|
|
95
|
+
return this.#client.addEcdsaSignature(type, bytes);
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
async addScwSignature(
|
|
@@ -110,8 +108,8 @@ export class WorkerClient {
|
|
|
110
108
|
return this.#client.applySignatureRequests();
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
async canMessage(
|
|
114
|
-
return this.#client.canMessage(
|
|
111
|
+
async canMessage(identifiers: Identifier[]) {
|
|
112
|
+
return this.#client.canMessage(identifiers) as Promise<
|
|
115
113
|
Map<string, boolean>
|
|
116
114
|
>;
|
|
117
115
|
}
|
|
@@ -120,8 +118,8 @@ export class WorkerClient {
|
|
|
120
118
|
return this.#client.registerIdentity();
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
async
|
|
124
|
-
return this.#client.
|
|
121
|
+
async findInboxIdByIdentifier(identifier: Identifier) {
|
|
122
|
+
return this.#client.findInboxIdByIdentifier(identifier);
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
async inboxState(refreshFromNetwork: boolean) {
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type Conversation,
|
|
5
5
|
type EncodedContent,
|
|
6
6
|
type GroupMember,
|
|
7
|
+
type Identifier,
|
|
7
8
|
type Message,
|
|
8
9
|
type MetadataField,
|
|
9
10
|
type PermissionPolicy,
|
|
@@ -121,19 +122,19 @@ export class WorkerConversation {
|
|
|
121
122
|
return this.#group.sync();
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
async
|
|
125
|
-
return this.#group.addMembers(
|
|
125
|
+
async addMembersByIdentifiers(identifiers: Identifier[]) {
|
|
126
|
+
return this.#group.addMembers(identifiers);
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
async
|
|
129
|
+
async addMembers(inboxIds: string[]) {
|
|
129
130
|
return this.#group.addMembersByInboxId(inboxIds);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
async
|
|
133
|
-
return this.#group.removeMembers(
|
|
133
|
+
async removeMembersByIdentifiers(identifiers: Identifier[]) {
|
|
134
|
+
return this.#group.removeMembers(identifiers);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
async
|
|
137
|
+
async removeMembers(inboxIds: string[]) {
|
|
137
138
|
return this.#group.removeMembersByInboxId(inboxIds);
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -209,4 +210,8 @@ export class WorkerConversation {
|
|
|
209
210
|
};
|
|
210
211
|
return this.#group.stream({ on_message, on_error });
|
|
211
212
|
}
|
|
213
|
+
|
|
214
|
+
pausedForVersion() {
|
|
215
|
+
return this.#group.pausedForVersion();
|
|
216
|
+
}
|
|
212
217
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type Conversation,
|
|
6
6
|
type ConversationListItem,
|
|
7
7
|
type Conversations,
|
|
8
|
+
type Identifier,
|
|
8
9
|
type Message,
|
|
9
10
|
type UserPreference,
|
|
10
11
|
} from "@xmtp/wasm-bindings";
|
|
@@ -96,18 +97,18 @@ export class WorkerConversations {
|
|
|
96
97
|
);
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
async
|
|
100
|
+
async newGroupWithIdentifiers(
|
|
101
|
+
identifiers: Identifier[],
|
|
102
|
+
options?: SafeCreateGroupOptions,
|
|
103
|
+
) {
|
|
100
104
|
const group = await this.#conversations.createGroup(
|
|
101
|
-
|
|
105
|
+
identifiers,
|
|
102
106
|
options ? fromSafeCreateGroupOptions(options) : undefined,
|
|
103
107
|
);
|
|
104
108
|
return new WorkerConversation(this.#client, group);
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
async
|
|
108
|
-
inboxIds: string[],
|
|
109
|
-
options?: SafeCreateGroupOptions,
|
|
110
|
-
) {
|
|
111
|
+
async newGroup(inboxIds: string[], options?: SafeCreateGroupOptions) {
|
|
111
112
|
const group = await this.#conversations.createGroupByInboxIds(
|
|
112
113
|
inboxIds,
|
|
113
114
|
options ? fromSafeCreateGroupOptions(options) : undefined,
|
|
@@ -115,15 +116,18 @@ export class WorkerConversations {
|
|
|
115
116
|
return new WorkerConversation(this.#client, group);
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
async
|
|
119
|
+
async newDmWithIdentifier(
|
|
120
|
+
identifier: Identifier,
|
|
121
|
+
options?: SafeCreateDmOptions,
|
|
122
|
+
) {
|
|
119
123
|
const group = await this.#conversations.createDm(
|
|
120
|
-
|
|
124
|
+
identifier,
|
|
121
125
|
options ? fromSafeCreateDmOptions(options) : undefined,
|
|
122
126
|
);
|
|
123
127
|
return new WorkerConversation(this.#client, group);
|
|
124
128
|
}
|
|
125
129
|
|
|
126
|
-
async
|
|
130
|
+
async newDm(inboxId: string, options?: SafeCreateDmOptions) {
|
|
127
131
|
const group = await this.#conversations.createDmByInboxId(
|
|
128
132
|
inboxId,
|
|
129
133
|
options ? fromSafeCreateDmOptions(options) : undefined,
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,11 @@ export { Utils } from "./Utils";
|
|
|
9
9
|
export { ApiUrls, HistorySyncUrls } from "./constants";
|
|
10
10
|
export type * from "./types";
|
|
11
11
|
export * from "./utils/conversions";
|
|
12
|
-
export type {
|
|
12
|
+
export type {
|
|
13
|
+
Identifier,
|
|
14
|
+
IdentifierKind,
|
|
15
|
+
UserPreference,
|
|
16
|
+
} from "@xmtp/wasm-bindings";
|
|
13
17
|
export {
|
|
14
18
|
Consent,
|
|
15
19
|
ConsentEntityType,
|