@xmtp/node-sdk 3.2.1-dev.cb2628c → 3.2.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/README.md +1 -1
- package/dist/index.d.ts +127 -70
- package/dist/index.js +268 -264
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GroupUpdatedCodec, ContentTypeGroupUpdated } from '@xmtp/content-type-group-updated';
|
|
2
2
|
import { ContentTypeText, TextCodec } from '@xmtp/content-type-text';
|
|
3
|
-
import { generateInboxId as generateInboxId$1, getInboxIdForIdentifier as getInboxIdForIdentifier$1, createClient as createClient$1, verifySignedWithPublicKey, isAddressAuthorized, isInstallationAuthorized } from '@xmtp/node-bindings';
|
|
4
|
-
export { ConsentEntityType, ConsentState, ConversationType, DeliveryStatus, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, IdentifierKind, LogLevel, MetadataField, PermissionLevel, PermissionPolicy, PermissionUpdateType,
|
|
3
|
+
import { generateInboxId as generateInboxId$1, getInboxIdForIdentifier as getInboxIdForIdentifier$1, createClient as createClient$1, revokeInstallationsSignatureRequest, applySignatureRequest, inboxStateFromInboxIds, verifySignedWithPublicKey, isAddressAuthorized, isInstallationAuthorized } from '@xmtp/node-bindings';
|
|
4
|
+
export { ConsentEntityType, ConsentState, ConversationType, DeliveryStatus, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, IdentifierKind, LogLevel, MetadataField, PermissionLevel, PermissionPolicy, PermissionUpdateType, SignatureRequestHandle, SortDirection } from '@xmtp/node-bindings';
|
|
5
5
|
import { ContentTypeId } from '@xmtp/content-type-primitives';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import process from 'node:process';
|
|
@@ -35,83 +35,99 @@ const HistorySyncUrls = {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
class AsyncStream {
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#rejectNext;
|
|
38
|
+
#isDone = false;
|
|
39
|
+
#pendingPromises = [];
|
|
41
40
|
#queue;
|
|
42
41
|
#error;
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
#onDone;
|
|
43
|
+
#onReturn;
|
|
44
|
+
#onError;
|
|
45
45
|
constructor() {
|
|
46
46
|
this.#queue = [];
|
|
47
|
-
this.#
|
|
48
|
-
this.#rejectNext = null;
|
|
49
|
-
this.#error = null;
|
|
50
|
-
this.#done = false;
|
|
47
|
+
this.#isDone = false;
|
|
51
48
|
}
|
|
52
|
-
#
|
|
49
|
+
#flush(value) {
|
|
50
|
+
while (this.#pendingPromises.length > 0) {
|
|
51
|
+
const nextPendingPromise = this.#pendingPromises.shift();
|
|
52
|
+
if (nextPendingPromise) {
|
|
53
|
+
nextPendingPromise.resolve({ done: true, value });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
#done(value) {
|
|
58
|
+
this.#flush(value);
|
|
53
59
|
this.#queue = [];
|
|
54
|
-
this.#
|
|
55
|
-
this.#
|
|
56
|
-
this.#
|
|
60
|
+
this.#pendingPromises = [];
|
|
61
|
+
this.#isDone = true;
|
|
62
|
+
this.#onDone?.();
|
|
63
|
+
if (this.#error) {
|
|
64
|
+
this.#onError?.(this.#error);
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
67
|
get error() {
|
|
59
68
|
return this.#error;
|
|
60
69
|
}
|
|
61
70
|
get isDone() {
|
|
62
|
-
return this.#
|
|
71
|
+
return this.#isDone;
|
|
72
|
+
}
|
|
73
|
+
set onReturn(callback) {
|
|
74
|
+
this.#onReturn = callback;
|
|
75
|
+
}
|
|
76
|
+
set onError(callback) {
|
|
77
|
+
this.#onError = callback;
|
|
78
|
+
}
|
|
79
|
+
set onDone(callback) {
|
|
80
|
+
this.#onDone = callback;
|
|
63
81
|
}
|
|
64
82
|
callback = (error, value) => {
|
|
65
|
-
if (
|
|
66
|
-
this.#error = error;
|
|
67
|
-
if (this.#rejectNext) {
|
|
68
|
-
this.#rejectNext(error);
|
|
69
|
-
this.#endStream();
|
|
70
|
-
this.onError?.(error);
|
|
71
|
-
}
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (this.#done) {
|
|
83
|
+
if (this.#isDone) {
|
|
75
84
|
return;
|
|
76
85
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
const nextPendingPromise = this.#pendingPromises.shift();
|
|
87
|
+
if (nextPendingPromise) {
|
|
88
|
+
const { resolve, reject } = nextPendingPromise;
|
|
89
|
+
if (error) {
|
|
90
|
+
this.#error = error;
|
|
91
|
+
reject(error);
|
|
92
|
+
this.#done();
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
resolve({
|
|
96
|
+
done: false,
|
|
97
|
+
value,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
84
100
|
}
|
|
85
101
|
else {
|
|
86
|
-
this.#queue.push(value);
|
|
102
|
+
this.#queue.push(error ?? value);
|
|
87
103
|
}
|
|
88
104
|
};
|
|
89
105
|
next = () => {
|
|
90
|
-
if (this.#
|
|
91
|
-
this.#endStream();
|
|
92
|
-
this.onError?.(this.#error);
|
|
93
|
-
return Promise.reject(this.#error);
|
|
94
|
-
}
|
|
95
|
-
if (this.#queue.length > 0) {
|
|
106
|
+
if (this.#isDone) {
|
|
96
107
|
return Promise.resolve({
|
|
97
|
-
done:
|
|
98
|
-
value:
|
|
108
|
+
done: true,
|
|
109
|
+
value: undefined,
|
|
99
110
|
});
|
|
100
111
|
}
|
|
101
|
-
if (this.#
|
|
112
|
+
if (this.#queue.length > 0) {
|
|
113
|
+
const value = this.#queue.shift();
|
|
114
|
+
if (value instanceof Error) {
|
|
115
|
+
this.#error = value;
|
|
116
|
+
this.#done();
|
|
117
|
+
return Promise.reject(value);
|
|
118
|
+
}
|
|
102
119
|
return Promise.resolve({
|
|
103
|
-
done:
|
|
104
|
-
value
|
|
120
|
+
done: false,
|
|
121
|
+
value,
|
|
105
122
|
});
|
|
106
123
|
}
|
|
107
124
|
return new Promise((resolve, reject) => {
|
|
108
|
-
this.#
|
|
109
|
-
this.#rejectNext = reject;
|
|
125
|
+
this.#pendingPromises.push({ resolve, reject });
|
|
110
126
|
});
|
|
111
127
|
};
|
|
112
128
|
return = (value) => {
|
|
113
|
-
this.#
|
|
114
|
-
this
|
|
129
|
+
this.#onReturn?.();
|
|
130
|
+
this.#done(value);
|
|
115
131
|
return Promise.resolve({
|
|
116
132
|
done: true,
|
|
117
133
|
value,
|
|
@@ -222,29 +238,6 @@ class AccountAlreadyAssociatedError extends Error {
|
|
|
222
238
|
super(`Account already associated with inbox ${inboxId}`);
|
|
223
239
|
}
|
|
224
240
|
}
|
|
225
|
-
class GenerateSignatureError extends Error {
|
|
226
|
-
constructor(signatureType) {
|
|
227
|
-
let type = "";
|
|
228
|
-
switch (signatureType) {
|
|
229
|
-
case 0 /* SignatureRequestType.AddWallet */:
|
|
230
|
-
type = "add account";
|
|
231
|
-
break;
|
|
232
|
-
case 1 /* SignatureRequestType.CreateInbox */:
|
|
233
|
-
type = "create inbox";
|
|
234
|
-
break;
|
|
235
|
-
case 2 /* SignatureRequestType.RevokeWallet */:
|
|
236
|
-
type = "remove account";
|
|
237
|
-
break;
|
|
238
|
-
case 3 /* SignatureRequestType.RevokeInstallations */:
|
|
239
|
-
type = "revoke installations";
|
|
240
|
-
break;
|
|
241
|
-
case 4 /* SignatureRequestType.ChangeRecoveryIdentifier */:
|
|
242
|
-
type = "change recovery identifier";
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
super(`Failed to generate ${type} signature text`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
241
|
class InvalidGroupMembershipChangeError extends Error {
|
|
249
242
|
constructor(messageId) {
|
|
250
243
|
super(`Invalid group membership change for message ${messageId}`);
|
|
@@ -353,7 +346,7 @@ class Conversation {
|
|
|
353
346
|
* @param callback - Optional callback function for handling new stream values
|
|
354
347
|
* @returns Stream instance for new messages
|
|
355
348
|
*/
|
|
356
|
-
stream(callback) {
|
|
349
|
+
stream(callback, onFail) {
|
|
357
350
|
const asyncStream = new AsyncStream();
|
|
358
351
|
const stream = this.#conversation.stream((error, value) => {
|
|
359
352
|
let err = error;
|
|
@@ -368,8 +361,10 @@ class Conversation {
|
|
|
368
361
|
}
|
|
369
362
|
asyncStream.callback(err, message);
|
|
370
363
|
callback?.(err, message);
|
|
371
|
-
});
|
|
372
|
-
asyncStream.
|
|
364
|
+
}, onFail ?? (() => { }));
|
|
365
|
+
asyncStream.onDone = () => {
|
|
366
|
+
stream.end();
|
|
367
|
+
};
|
|
373
368
|
return asyncStream;
|
|
374
369
|
}
|
|
375
370
|
/**
|
|
@@ -921,7 +916,7 @@ class Conversations {
|
|
|
921
916
|
* @param callback - Optional callback function for handling new stream value
|
|
922
917
|
* @returns Stream instance for new conversations
|
|
923
918
|
*/
|
|
924
|
-
stream(callback) {
|
|
919
|
+
stream(callback, onFail) {
|
|
925
920
|
const asyncStream = new AsyncStream();
|
|
926
921
|
const stream = this.#conversations.stream((err, value) => {
|
|
927
922
|
if (err) {
|
|
@@ -951,8 +946,10 @@ class Conversations {
|
|
|
951
946
|
asyncStream.callback(error, undefined);
|
|
952
947
|
callback?.(error, undefined);
|
|
953
948
|
});
|
|
954
|
-
});
|
|
955
|
-
asyncStream.
|
|
949
|
+
}, onFail ?? (() => { }));
|
|
950
|
+
asyncStream.onDone = () => {
|
|
951
|
+
stream.end();
|
|
952
|
+
};
|
|
956
953
|
return asyncStream;
|
|
957
954
|
}
|
|
958
955
|
/**
|
|
@@ -961,7 +958,7 @@ class Conversations {
|
|
|
961
958
|
* @param callback - Optional callback function for handling new stream value
|
|
962
959
|
* @returns Stream instance for new group conversations
|
|
963
960
|
*/
|
|
964
|
-
streamGroups(callback) {
|
|
961
|
+
streamGroups(callback, onFail) {
|
|
965
962
|
const asyncStream = new AsyncStream();
|
|
966
963
|
const stream = this.#conversations.stream((error, value) => {
|
|
967
964
|
let err = error;
|
|
@@ -976,8 +973,10 @@ class Conversations {
|
|
|
976
973
|
}
|
|
977
974
|
asyncStream.callback(err, group);
|
|
978
975
|
callback?.(err, group);
|
|
979
|
-
}, 1 /* ConversationType.Group */);
|
|
980
|
-
asyncStream.
|
|
976
|
+
}, onFail ?? (() => { }), 1 /* ConversationType.Group */);
|
|
977
|
+
asyncStream.onDone = () => {
|
|
978
|
+
stream.end();
|
|
979
|
+
};
|
|
981
980
|
return asyncStream;
|
|
982
981
|
}
|
|
983
982
|
/**
|
|
@@ -986,7 +985,7 @@ class Conversations {
|
|
|
986
985
|
* @param callback - Optional callback function for handling new stream value
|
|
987
986
|
* @returns Stream instance for new DM conversations
|
|
988
987
|
*/
|
|
989
|
-
streamDms(callback) {
|
|
988
|
+
streamDms(callback, onFail) {
|
|
990
989
|
const asyncStream = new AsyncStream();
|
|
991
990
|
const stream = this.#conversations.stream((error, value) => {
|
|
992
991
|
let err = error;
|
|
@@ -1001,8 +1000,10 @@ class Conversations {
|
|
|
1001
1000
|
}
|
|
1002
1001
|
asyncStream.callback(err, dm);
|
|
1003
1002
|
callback?.(err, dm);
|
|
1004
|
-
}, 0 /* ConversationType.Dm */);
|
|
1005
|
-
asyncStream.
|
|
1003
|
+
}, onFail ?? (() => { }), 0 /* ConversationType.Dm */);
|
|
1004
|
+
asyncStream.onDone = () => {
|
|
1005
|
+
stream.end();
|
|
1006
|
+
};
|
|
1006
1007
|
return asyncStream;
|
|
1007
1008
|
}
|
|
1008
1009
|
/**
|
|
@@ -1011,7 +1012,7 @@ class Conversations {
|
|
|
1011
1012
|
* @param callback - Optional callback function for handling new stream value
|
|
1012
1013
|
* @returns Stream instance for new messages
|
|
1013
1014
|
*/
|
|
1014
|
-
async streamAllMessages(callback, conversationType, consentStates) {
|
|
1015
|
+
async streamAllMessages(callback, conversationType, consentStates, onFail) {
|
|
1015
1016
|
// sync conversations first
|
|
1016
1017
|
await this.sync();
|
|
1017
1018
|
const asyncStream = new AsyncStream();
|
|
@@ -1028,8 +1029,10 @@ class Conversations {
|
|
|
1028
1029
|
}
|
|
1029
1030
|
asyncStream.callback(err, message);
|
|
1030
1031
|
callback?.(err, message);
|
|
1031
|
-
}, conversationType, consentStates);
|
|
1032
|
-
asyncStream.
|
|
1032
|
+
}, onFail ?? (() => { }), conversationType, consentStates);
|
|
1033
|
+
asyncStream.onDone = () => {
|
|
1034
|
+
stream.end();
|
|
1035
|
+
};
|
|
1033
1036
|
return asyncStream;
|
|
1034
1037
|
}
|
|
1035
1038
|
/**
|
|
@@ -1038,8 +1041,8 @@ class Conversations {
|
|
|
1038
1041
|
* @param callback - Optional callback function for handling new stream value
|
|
1039
1042
|
* @returns Stream instance for new group messages
|
|
1040
1043
|
*/
|
|
1041
|
-
async streamAllGroupMessages(callback, consentStates) {
|
|
1042
|
-
return this.streamAllMessages(callback, 1 /* ConversationType.Group */, consentStates);
|
|
1044
|
+
async streamAllGroupMessages(callback, consentStates, onFail) {
|
|
1045
|
+
return this.streamAllMessages(callback, 1 /* ConversationType.Group */, consentStates, onFail);
|
|
1043
1046
|
}
|
|
1044
1047
|
/**
|
|
1045
1048
|
* Creates a stream for all new DM messages
|
|
@@ -1047,8 +1050,8 @@ class Conversations {
|
|
|
1047
1050
|
* @param callback - Optional callback function for handling new stream value
|
|
1048
1051
|
* @returns Stream instance for new DM messages
|
|
1049
1052
|
*/
|
|
1050
|
-
async streamAllDmMessages(callback, consentStates) {
|
|
1051
|
-
return this.streamAllMessages(callback, 0 /* ConversationType.Dm */, consentStates);
|
|
1053
|
+
async streamAllDmMessages(callback, consentStates, onFail) {
|
|
1054
|
+
return this.streamAllMessages(callback, 0 /* ConversationType.Dm */, consentStates, onFail);
|
|
1052
1055
|
}
|
|
1053
1056
|
/**
|
|
1054
1057
|
* Retrieves HMAC keys for all conversations
|
|
@@ -1060,6 +1063,37 @@ class Conversations {
|
|
|
1060
1063
|
}
|
|
1061
1064
|
}
|
|
1062
1065
|
|
|
1066
|
+
/**
|
|
1067
|
+
* Debug information helpers for the client
|
|
1068
|
+
*
|
|
1069
|
+
* This class is not intended to be initialized directly.
|
|
1070
|
+
*/
|
|
1071
|
+
class DebugInformation {
|
|
1072
|
+
#client;
|
|
1073
|
+
#options;
|
|
1074
|
+
constructor(client, options) {
|
|
1075
|
+
this.#client = client;
|
|
1076
|
+
this.#options = options;
|
|
1077
|
+
}
|
|
1078
|
+
apiStatistics() {
|
|
1079
|
+
return this.#client.apiStatistics();
|
|
1080
|
+
}
|
|
1081
|
+
apiIdentityStatistics() {
|
|
1082
|
+
return this.#client.apiIdentityStatistics();
|
|
1083
|
+
}
|
|
1084
|
+
apiAggregateStatistics() {
|
|
1085
|
+
return this.#client.apiAggregateStatistics();
|
|
1086
|
+
}
|
|
1087
|
+
clearAllStatistics() {
|
|
1088
|
+
this.#client.clearAllStatistics();
|
|
1089
|
+
}
|
|
1090
|
+
uploadDebugArchive(serverUrl) {
|
|
1091
|
+
const env = this.#options?.env || "dev";
|
|
1092
|
+
const historySyncUrl = this.#options?.historySyncUrl || HistorySyncUrls[env];
|
|
1093
|
+
return this.#client.uploadDebugArchive(serverUrl || historySyncUrl);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1063
1097
|
/**
|
|
1064
1098
|
* Manages user preferences and consent states
|
|
1065
1099
|
*
|
|
@@ -1134,7 +1168,7 @@ class Preferences {
|
|
|
1134
1168
|
* @param callback - Optional callback function for handling stream updates
|
|
1135
1169
|
* @returns Stream instance for consent updates
|
|
1136
1170
|
*/
|
|
1137
|
-
streamConsent(callback) {
|
|
1171
|
+
streamConsent(callback, onFail) {
|
|
1138
1172
|
const asyncStream = new AsyncStream();
|
|
1139
1173
|
const stream = this.#conversations.streamConsent((err, value) => {
|
|
1140
1174
|
if (err) {
|
|
@@ -1144,8 +1178,10 @@ class Preferences {
|
|
|
1144
1178
|
}
|
|
1145
1179
|
asyncStream.callback(null, value);
|
|
1146
1180
|
callback?.(null, value);
|
|
1147
|
-
});
|
|
1148
|
-
asyncStream.
|
|
1181
|
+
}, onFail ?? (() => { }));
|
|
1182
|
+
asyncStream.onDone = () => {
|
|
1183
|
+
stream.end();
|
|
1184
|
+
};
|
|
1149
1185
|
return asyncStream;
|
|
1150
1186
|
}
|
|
1151
1187
|
/**
|
|
@@ -1154,7 +1190,7 @@ class Preferences {
|
|
|
1154
1190
|
* @param callback - Optional callback function for handling stream updates
|
|
1155
1191
|
* @returns Stream instance for preference updates
|
|
1156
1192
|
*/
|
|
1157
|
-
streamPreferences(callback) {
|
|
1193
|
+
streamPreferences(callback, onFail) {
|
|
1158
1194
|
const asyncStream = new AsyncStream();
|
|
1159
1195
|
const stream = this.#conversations.streamPreferences((err, value) => {
|
|
1160
1196
|
if (err) {
|
|
@@ -1165,8 +1201,10 @@ class Preferences {
|
|
|
1165
1201
|
// TODO: remove this once the node bindings type is updated
|
|
1166
1202
|
asyncStream.callback(null, value);
|
|
1167
1203
|
callback?.(null, value);
|
|
1168
|
-
});
|
|
1169
|
-
asyncStream.
|
|
1204
|
+
}, onFail ?? (() => { }));
|
|
1205
|
+
asyncStream.onDone = () => {
|
|
1206
|
+
stream.end();
|
|
1207
|
+
};
|
|
1170
1208
|
return asyncStream;
|
|
1171
1209
|
}
|
|
1172
1210
|
}
|
|
@@ -1210,6 +1248,7 @@ const version = `${bindingsVersion.branch}@${bindingsVersion.version} (${binding
|
|
|
1210
1248
|
class Client {
|
|
1211
1249
|
#client;
|
|
1212
1250
|
#conversations;
|
|
1251
|
+
#debugInformation;
|
|
1213
1252
|
#preferences;
|
|
1214
1253
|
#signer;
|
|
1215
1254
|
#codecs;
|
|
@@ -1248,6 +1287,7 @@ class Client {
|
|
|
1248
1287
|
this.#client = await createClient(identifier, this.#options);
|
|
1249
1288
|
const conversations = this.#client.conversations();
|
|
1250
1289
|
this.#conversations = new Conversations(this, conversations);
|
|
1290
|
+
this.#debugInformation = new DebugInformation(this.#client, this.#options);
|
|
1251
1291
|
this.#preferences = new Preferences(this.#client, conversations);
|
|
1252
1292
|
}
|
|
1253
1293
|
/**
|
|
@@ -1352,6 +1392,17 @@ class Client {
|
|
|
1352
1392
|
}
|
|
1353
1393
|
return this.#conversations;
|
|
1354
1394
|
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Gets the debug information helpersfor this client
|
|
1397
|
+
*
|
|
1398
|
+
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1399
|
+
*/
|
|
1400
|
+
get debugInformation() {
|
|
1401
|
+
if (!this.#debugInformation) {
|
|
1402
|
+
throw new ClientNotInitializedError();
|
|
1403
|
+
}
|
|
1404
|
+
return this.#debugInformation;
|
|
1405
|
+
}
|
|
1355
1406
|
/**
|
|
1356
1407
|
* Gets the preferences manager for this client
|
|
1357
1408
|
*
|
|
@@ -1364,31 +1415,61 @@ class Client {
|
|
|
1364
1415
|
return this.#preferences;
|
|
1365
1416
|
}
|
|
1366
1417
|
/**
|
|
1367
|
-
*
|
|
1418
|
+
* Adds a signature to a signature request using the client's signer (or the
|
|
1419
|
+
* provided signer)
|
|
1368
1420
|
*
|
|
1369
1421
|
* WARNING: This function should be used with caution. It is only provided
|
|
1370
1422
|
* for use in special cases where the provided workflows do not meet the
|
|
1371
1423
|
* requirements of an application.
|
|
1372
1424
|
*
|
|
1373
|
-
* It is highly recommended to use the `register`
|
|
1425
|
+
* It is highly recommended to use the `register`, `unsafe_addAccount`,
|
|
1426
|
+
* `removeAccount`, `revokeAllOtherInstallations`, or `revokeInstallations`
|
|
1427
|
+
* methods instead.
|
|
1374
1428
|
*
|
|
1375
|
-
* @
|
|
1429
|
+
* @param signatureRequest - The signature request to add the signature to
|
|
1376
1430
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1431
|
+
* @throws {SignerUnavailableError} if no signer is available
|
|
1377
1432
|
*/
|
|
1378
|
-
async
|
|
1433
|
+
async unsafe_addSignature(signatureRequest, signer) {
|
|
1379
1434
|
if (!this.#client) {
|
|
1380
1435
|
throw new ClientNotInitializedError();
|
|
1381
1436
|
}
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
return signatureText;
|
|
1437
|
+
if (!this.#signer) {
|
|
1438
|
+
throw new SignerUnavailableError();
|
|
1385
1439
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1440
|
+
const finalSigner = signer ?? this.#signer;
|
|
1441
|
+
const signature = await finalSigner.signMessage(await signatureRequest.signatureText());
|
|
1442
|
+
const identifier = await finalSigner.getIdentifier();
|
|
1443
|
+
switch (finalSigner.type) {
|
|
1444
|
+
case "SCW":
|
|
1445
|
+
await signatureRequest.addScwSignature(identifier, signature, finalSigner.getChainId(), finalSigner.getBlockNumber?.());
|
|
1446
|
+
break;
|
|
1447
|
+
case "EOA":
|
|
1448
|
+
await signatureRequest.addEcdsaSignature(signature);
|
|
1449
|
+
break;
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Returns a signature request handler for creating a new inbox
|
|
1454
|
+
*
|
|
1455
|
+
* WARNING: This function should be used with caution. It is only provided
|
|
1456
|
+
* for use in special cases where the provided workflows do not meet the
|
|
1457
|
+
* requirements of an application.
|
|
1458
|
+
*
|
|
1459
|
+
* It is highly recommended to use the `register` method instead.
|
|
1460
|
+
*
|
|
1461
|
+
* @returns The signature text
|
|
1462
|
+
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1463
|
+
*/
|
|
1464
|
+
async unsafe_createInboxSignatureRequest() {
|
|
1465
|
+
if (!this.#client) {
|
|
1466
|
+
throw new ClientNotInitializedError();
|
|
1388
1467
|
}
|
|
1468
|
+
return this.#client.createInboxSignatureRequest();
|
|
1389
1469
|
}
|
|
1390
1470
|
/**
|
|
1391
|
-
*
|
|
1471
|
+
* Returns a signature request handler for adding a new account to the
|
|
1472
|
+
* client's inbox
|
|
1392
1473
|
*
|
|
1393
1474
|
* WARNING: This function should be used with caution. It is only provided
|
|
1394
1475
|
* for use in special cases where the provided workflows do not meet the
|
|
@@ -1404,23 +1485,18 @@ class Client {
|
|
|
1404
1485
|
* @returns The signature text
|
|
1405
1486
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1406
1487
|
*/
|
|
1407
|
-
async
|
|
1488
|
+
async unsafe_addAccountSignatureRequest(newAccountIdentifier, allowInboxReassign = false) {
|
|
1408
1489
|
if (!this.#client) {
|
|
1409
1490
|
throw new ClientNotInitializedError();
|
|
1410
1491
|
}
|
|
1411
1492
|
if (!allowInboxReassign) {
|
|
1412
1493
|
throw new InboxReassignError();
|
|
1413
1494
|
}
|
|
1414
|
-
|
|
1415
|
-
const signatureText = await this.#client.addIdentifierSignatureText(newAccountIdentifier);
|
|
1416
|
-
return signatureText;
|
|
1417
|
-
}
|
|
1418
|
-
catch {
|
|
1419
|
-
return undefined;
|
|
1420
|
-
}
|
|
1495
|
+
return this.#client.addIdentifierSignatureRequest(newAccountIdentifier);
|
|
1421
1496
|
}
|
|
1422
1497
|
/**
|
|
1423
|
-
*
|
|
1498
|
+
* Returns a signature request handler for removing an account from the
|
|
1499
|
+
* client's inbox
|
|
1424
1500
|
*
|
|
1425
1501
|
* WARNING: This function should be used with caution. It is only provided
|
|
1426
1502
|
* for use in special cases where the provided workflows do not meet the
|
|
@@ -1432,21 +1508,15 @@ class Client {
|
|
|
1432
1508
|
* @returns The signature text
|
|
1433
1509
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1434
1510
|
*/
|
|
1435
|
-
async
|
|
1511
|
+
async unsafe_removeAccountSignatureRequest(identifier) {
|
|
1436
1512
|
if (!this.#client) {
|
|
1437
1513
|
throw new ClientNotInitializedError();
|
|
1438
1514
|
}
|
|
1439
|
-
|
|
1440
|
-
const signatureText = await this.#client.revokeIdentifierSignatureText(identifier);
|
|
1441
|
-
return signatureText;
|
|
1442
|
-
}
|
|
1443
|
-
catch {
|
|
1444
|
-
return undefined;
|
|
1445
|
-
}
|
|
1515
|
+
return this.#client.revokeIdentifierSignatureRequest(identifier);
|
|
1446
1516
|
}
|
|
1447
1517
|
/**
|
|
1448
|
-
*
|
|
1449
|
-
* client's inbox
|
|
1518
|
+
* Returns a signature request handler for revoking all other installations
|
|
1519
|
+
* of the client's inbox
|
|
1450
1520
|
*
|
|
1451
1521
|
* WARNING: This function should be used with caution. It is only provided
|
|
1452
1522
|
* for use in special cases where the provided workflows do not meet the
|
|
@@ -1457,21 +1527,15 @@ class Client {
|
|
|
1457
1527
|
* @returns The signature text
|
|
1458
1528
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1459
1529
|
*/
|
|
1460
|
-
async
|
|
1530
|
+
async unsafe_revokeAllOtherInstallationsSignatureRequest() {
|
|
1461
1531
|
if (!this.#client) {
|
|
1462
1532
|
throw new ClientNotInitializedError();
|
|
1463
1533
|
}
|
|
1464
|
-
|
|
1465
|
-
const signatureText = await this.#client.revokeAllOtherInstallationsSignatureText();
|
|
1466
|
-
return signatureText;
|
|
1467
|
-
}
|
|
1468
|
-
catch {
|
|
1469
|
-
return undefined;
|
|
1470
|
-
}
|
|
1534
|
+
return this.#client.revokeAllOtherInstallationsSignatureRequest();
|
|
1471
1535
|
}
|
|
1472
1536
|
/**
|
|
1473
|
-
*
|
|
1474
|
-
* client's inbox
|
|
1537
|
+
* Returns a signature request handler for revoking specific installations
|
|
1538
|
+
* of the client's inbox
|
|
1475
1539
|
*
|
|
1476
1540
|
* WARNING: This function should be used with caution. It is only provided
|
|
1477
1541
|
* for use in special cases where the provided workflows do not meet the
|
|
@@ -1483,21 +1547,15 @@ class Client {
|
|
|
1483
1547
|
* @returns The signature text
|
|
1484
1548
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1485
1549
|
*/
|
|
1486
|
-
async
|
|
1550
|
+
async unsafe_revokeInstallationsSignatureRequest(installationIds) {
|
|
1487
1551
|
if (!this.#client) {
|
|
1488
1552
|
throw new ClientNotInitializedError();
|
|
1489
1553
|
}
|
|
1490
|
-
|
|
1491
|
-
const signatureText = await this.#client.revokeInstallationsSignatureText(installationIds);
|
|
1492
|
-
return signatureText;
|
|
1493
|
-
}
|
|
1494
|
-
catch {
|
|
1495
|
-
return undefined;
|
|
1496
|
-
}
|
|
1554
|
+
return this.#client.revokeInstallationsSignatureRequest(installationIds);
|
|
1497
1555
|
}
|
|
1498
1556
|
/**
|
|
1499
|
-
*
|
|
1500
|
-
* client's inbox
|
|
1557
|
+
* Returns a signature request handler for changing the recovery identifier
|
|
1558
|
+
* for this client's inbox
|
|
1501
1559
|
*
|
|
1502
1560
|
* WARNING: This function should be used with caution. It is only provided
|
|
1503
1561
|
* for use in special cases where the provided workflows do not meet the
|
|
@@ -1509,49 +1567,14 @@ class Client {
|
|
|
1509
1567
|
* @returns The signature text
|
|
1510
1568
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1511
1569
|
*/
|
|
1512
|
-
async
|
|
1513
|
-
if (!this.#client) {
|
|
1514
|
-
throw new ClientNotInitializedError();
|
|
1515
|
-
}
|
|
1516
|
-
try {
|
|
1517
|
-
const signatureText = await this.#client.changeRecoveryIdentifierSignatureText(identifier);
|
|
1518
|
-
return signatureText;
|
|
1519
|
-
}
|
|
1520
|
-
catch {
|
|
1521
|
-
return undefined;
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
/**
|
|
1525
|
-
* Adds a signature for a specific request type
|
|
1526
|
-
*
|
|
1527
|
-
* WARNING: This function should be used with caution. It is only provided
|
|
1528
|
-
* for use in special cases where the provided workflows do not meet the
|
|
1529
|
-
* requirements of an application.
|
|
1530
|
-
*
|
|
1531
|
-
* It is highly recommended to use the `register`, `unsafe_addAccount`,
|
|
1532
|
-
* `removeAccount`, `revokeAllOtherInstallations`, or `revokeInstallations`
|
|
1533
|
-
* methods instead.
|
|
1534
|
-
*
|
|
1535
|
-
* @param signatureType - The type of signature request
|
|
1536
|
-
* @param signatureText - The text to sign
|
|
1537
|
-
* @param signer - The signer to use
|
|
1538
|
-
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1539
|
-
*/
|
|
1540
|
-
async unsafe_addSignature(signatureType, signatureText, signer) {
|
|
1570
|
+
async unsafe_changeRecoveryIdentifierSignatureRequest(identifier) {
|
|
1541
1571
|
if (!this.#client) {
|
|
1542
1572
|
throw new ClientNotInitializedError();
|
|
1543
1573
|
}
|
|
1544
|
-
|
|
1545
|
-
case "SCW":
|
|
1546
|
-
await this.#client.addScwSignature(signatureType, await signer.signMessage(signatureText), signer.getChainId(), signer.getBlockNumber?.());
|
|
1547
|
-
break;
|
|
1548
|
-
case "EOA":
|
|
1549
|
-
await this.#client.addEcdsaSignature(signatureType, await signer.signMessage(signatureText));
|
|
1550
|
-
break;
|
|
1551
|
-
}
|
|
1574
|
+
return this.#client.changeRecoveryIdentifierSignatureRequest(identifier);
|
|
1552
1575
|
}
|
|
1553
1576
|
/**
|
|
1554
|
-
* Applies
|
|
1577
|
+
* Applies a signature request to the client
|
|
1555
1578
|
*
|
|
1556
1579
|
* WARNING: This function should be used with caution. It is only provided
|
|
1557
1580
|
* for use in special cases where the provided workflows do not meet the
|
|
@@ -1563,11 +1586,11 @@ class Client {
|
|
|
1563
1586
|
*
|
|
1564
1587
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1565
1588
|
*/
|
|
1566
|
-
async
|
|
1589
|
+
async unsafe_applySignatureRequest(signatureRequest) {
|
|
1567
1590
|
if (!this.#client) {
|
|
1568
1591
|
throw new ClientNotInitializedError();
|
|
1569
1592
|
}
|
|
1570
|
-
return this.#client.
|
|
1593
|
+
return this.#client.applySignatureRequest(signatureRequest);
|
|
1571
1594
|
}
|
|
1572
1595
|
/**
|
|
1573
1596
|
* Registers the client with the XMTP network
|
|
@@ -1578,19 +1601,12 @@ class Client {
|
|
|
1578
1601
|
* @throws {SignerUnavailableError} if no signer is available
|
|
1579
1602
|
*/
|
|
1580
1603
|
async register() {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
}
|
|
1584
|
-
if (!this.#signer) {
|
|
1585
|
-
throw new SignerUnavailableError();
|
|
1586
|
-
}
|
|
1587
|
-
const signatureText = await this.unsafe_createInboxSignatureText();
|
|
1588
|
-
// if the signature text is not available, the client is already registered
|
|
1589
|
-
if (!signatureText) {
|
|
1604
|
+
const signatureRequest = await this.unsafe_createInboxSignatureRequest();
|
|
1605
|
+
if (!signatureRequest) {
|
|
1590
1606
|
return;
|
|
1591
1607
|
}
|
|
1592
|
-
await this.unsafe_addSignature(
|
|
1593
|
-
|
|
1608
|
+
await this.unsafe_addSignature(signatureRequest);
|
|
1609
|
+
await this.#client?.registerIdentity(signatureRequest);
|
|
1594
1610
|
}
|
|
1595
1611
|
/**
|
|
1596
1612
|
* Adds a new account to the client inbox
|
|
@@ -1606,27 +1622,20 @@ class Client {
|
|
|
1606
1622
|
*
|
|
1607
1623
|
* @param newAccountSigner - The signer for the new account
|
|
1608
1624
|
* @param allowInboxReassign - Whether to allow inbox reassignment
|
|
1609
|
-
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1610
1625
|
* @throws {AccountAlreadyAssociatedError} if the account is already associated with an inbox ID
|
|
1611
|
-
* @throws {
|
|
1626
|
+
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1612
1627
|
* @throws {SignerUnavailableError} if no signer is available
|
|
1613
1628
|
*/
|
|
1614
1629
|
async unsafe_addAccount(newAccountSigner, allowInboxReassign = false) {
|
|
1615
|
-
if (!this.#client) {
|
|
1616
|
-
throw new ClientNotInitializedError();
|
|
1617
|
-
}
|
|
1618
1630
|
// check for existing inbox id
|
|
1619
1631
|
const identifier = await newAccountSigner.getIdentifier();
|
|
1620
1632
|
const existingInboxId = await this.getInboxIdByIdentifier(identifier);
|
|
1621
1633
|
if (existingInboxId && !allowInboxReassign) {
|
|
1622
1634
|
throw new AccountAlreadyAssociatedError(existingInboxId);
|
|
1623
1635
|
}
|
|
1624
|
-
const
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
}
|
|
1628
|
-
await this.unsafe_addSignature(0 /* SignatureRequestType.AddWallet */, signatureText, newAccountSigner);
|
|
1629
|
-
await this.unsafe_applySignatures();
|
|
1636
|
+
const signatureRequest = await this.unsafe_addAccountSignatureRequest(identifier, allowInboxReassign);
|
|
1637
|
+
await this.unsafe_addSignature(signatureRequest, newAccountSigner);
|
|
1638
|
+
await this.unsafe_applySignatureRequest(signatureRequest);
|
|
1630
1639
|
}
|
|
1631
1640
|
/**
|
|
1632
1641
|
* Removes an account from the client's inbox
|
|
@@ -1635,22 +1644,12 @@ class Client {
|
|
|
1635
1644
|
*
|
|
1636
1645
|
* @param identifier - The identifier of the account to remove
|
|
1637
1646
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1638
|
-
* @throws {GenerateSignatureError} if the signature cannot be generated
|
|
1639
1647
|
* @throws {SignerUnavailableError} if no signer is available
|
|
1640
1648
|
*/
|
|
1641
1649
|
async removeAccount(identifier) {
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
if (!this.#signer) {
|
|
1646
|
-
throw new SignerUnavailableError();
|
|
1647
|
-
}
|
|
1648
|
-
const signatureText = await this.unsafe_removeAccountSignatureText(identifier);
|
|
1649
|
-
if (!signatureText) {
|
|
1650
|
-
throw new GenerateSignatureError(2 /* SignatureRequestType.RevokeWallet */);
|
|
1651
|
-
}
|
|
1652
|
-
await this.unsafe_addSignature(2 /* SignatureRequestType.RevokeWallet */, signatureText, this.#signer);
|
|
1653
|
-
await this.unsafe_applySignatures();
|
|
1650
|
+
const signatureRequest = await this.unsafe_removeAccountSignatureRequest(identifier);
|
|
1651
|
+
await this.unsafe_addSignature(signatureRequest);
|
|
1652
|
+
await this.unsafe_applySignatureRequest(signatureRequest);
|
|
1654
1653
|
}
|
|
1655
1654
|
/**
|
|
1656
1655
|
* Revokes all other installations of the client's inbox
|
|
@@ -1658,22 +1657,12 @@ class Client {
|
|
|
1658
1657
|
* Requires a signer, use `Client.create` to create a client with a signer.
|
|
1659
1658
|
*
|
|
1660
1659
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1661
|
-
* @throws {GenerateSignatureError} if the signature cannot be generated
|
|
1662
1660
|
* @throws {SignerUnavailableError} if no signer is available
|
|
1663
1661
|
*/
|
|
1664
1662
|
async revokeAllOtherInstallations() {
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
if (!this.#signer) {
|
|
1669
|
-
throw new SignerUnavailableError();
|
|
1670
|
-
}
|
|
1671
|
-
const signatureText = await this.unsafe_revokeAllOtherInstallationsSignatureText();
|
|
1672
|
-
if (!signatureText) {
|
|
1673
|
-
throw new GenerateSignatureError(3 /* SignatureRequestType.RevokeInstallations */);
|
|
1674
|
-
}
|
|
1675
|
-
await this.unsafe_addSignature(3 /* SignatureRequestType.RevokeInstallations */, signatureText, this.#signer);
|
|
1676
|
-
await this.unsafe_applySignatures();
|
|
1663
|
+
const signatureRequest = await this.unsafe_revokeAllOtherInstallationsSignatureRequest();
|
|
1664
|
+
await this.unsafe_addSignature(signatureRequest);
|
|
1665
|
+
await this.unsafe_applySignatureRequest(signatureRequest);
|
|
1677
1666
|
}
|
|
1678
1667
|
/**
|
|
1679
1668
|
* Revokes specific installations of the client's inbox
|
|
@@ -1683,21 +1672,46 @@ class Client {
|
|
|
1683
1672
|
* @param installationIds - The installation IDs to revoke
|
|
1684
1673
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1685
1674
|
* @throws {SignerUnavailableError} if no signer is available
|
|
1686
|
-
* @throws {GenerateSignatureError} if the signature cannot be generated
|
|
1687
1675
|
*/
|
|
1688
1676
|
async revokeInstallations(installationIds) {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1677
|
+
const signatureRequest = await this.unsafe_revokeInstallationsSignatureRequest(installationIds);
|
|
1678
|
+
await this.unsafe_addSignature(signatureRequest);
|
|
1679
|
+
await this.unsafe_applySignatureRequest(signatureRequest);
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* Revokes specific installations of the client's inbox without a client
|
|
1683
|
+
*
|
|
1684
|
+
* @param env - The environment to use
|
|
1685
|
+
* @param signer - The signer to use
|
|
1686
|
+
* @param inboxId - The inbox ID to revoke installations for
|
|
1687
|
+
* @param installationIds - The installation IDs to revoke
|
|
1688
|
+
*/
|
|
1689
|
+
static async revokeInstallations(signer, inboxId, installationIds, env) {
|
|
1690
|
+
const host = ApiUrls[env ?? "dev"];
|
|
1691
|
+
const identifier = await signer.getIdentifier();
|
|
1692
|
+
const signatureRequest = await revokeInstallationsSignatureRequest(host, identifier, inboxId, installationIds);
|
|
1693
|
+
const signatureText = await signatureRequest.signatureText();
|
|
1694
|
+
const signature = await signer.signMessage(signatureText);
|
|
1695
|
+
switch (signer.type) {
|
|
1696
|
+
case "SCW":
|
|
1697
|
+
await signatureRequest.addScwSignature(identifier, signature, signer.getChainId(), signer.getBlockNumber?.());
|
|
1698
|
+
break;
|
|
1699
|
+
case "EOA":
|
|
1700
|
+
await signatureRequest.addEcdsaSignature(signature);
|
|
1701
|
+
break;
|
|
1698
1702
|
}
|
|
1699
|
-
await
|
|
1700
|
-
|
|
1703
|
+
await applySignatureRequest(host, signatureRequest);
|
|
1704
|
+
}
|
|
1705
|
+
/**
|
|
1706
|
+
* Gets the inbox state for the specified inbox IDs without a client
|
|
1707
|
+
*
|
|
1708
|
+
* @param env - The environment to use
|
|
1709
|
+
* @param inboxIds - The inbox IDs to get the state for
|
|
1710
|
+
* @returns The inbox state for the specified inbox IDs
|
|
1711
|
+
*/
|
|
1712
|
+
static async inboxStateFromInboxIds(inboxIds, env) {
|
|
1713
|
+
const host = ApiUrls[env ?? "dev"];
|
|
1714
|
+
return inboxStateFromInboxIds(host, inboxIds);
|
|
1701
1715
|
}
|
|
1702
1716
|
/**
|
|
1703
1717
|
* Changes the recovery identifier for the client's inbox
|
|
@@ -1707,21 +1721,11 @@ class Client {
|
|
|
1707
1721
|
* @param identifier - The new recovery identifier
|
|
1708
1722
|
* @throws {ClientNotInitializedError} if the client is not initialized
|
|
1709
1723
|
* @throws {SignerUnavailableError} if no signer is available
|
|
1710
|
-
* @throws {GenerateSignatureError} if the signature cannot be generated
|
|
1711
1724
|
*/
|
|
1712
1725
|
async changeRecoveryIdentifier(identifier) {
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
if (!this.#signer) {
|
|
1717
|
-
throw new SignerUnavailableError();
|
|
1718
|
-
}
|
|
1719
|
-
const signatureText = await this.unsafe_changeRecoveryIdentifierSignatureText(identifier);
|
|
1720
|
-
if (!signatureText) {
|
|
1721
|
-
throw new GenerateSignatureError(4 /* SignatureRequestType.ChangeRecoveryIdentifier */);
|
|
1722
|
-
}
|
|
1723
|
-
await this.unsafe_addSignature(4 /* SignatureRequestType.ChangeRecoveryIdentifier */, signatureText, this.#signer);
|
|
1724
|
-
await this.unsafe_applySignatures();
|
|
1726
|
+
const signatureRequest = await this.unsafe_changeRecoveryIdentifierSignatureRequest(identifier);
|
|
1727
|
+
await this.unsafe_addSignature(signatureRequest);
|
|
1728
|
+
await this.unsafe_applySignatureRequest(signatureRequest);
|
|
1725
1729
|
}
|
|
1726
1730
|
/**
|
|
1727
1731
|
* Checks if the client can message the specified identifiers
|
|
@@ -1886,8 +1890,8 @@ class Client {
|
|
|
1886
1890
|
* @param options - Optional network options
|
|
1887
1891
|
* @returns Whether the address is authorized
|
|
1888
1892
|
*/
|
|
1889
|
-
static async isAddressAuthorized(inboxId, address,
|
|
1890
|
-
const host =
|
|
1893
|
+
static async isAddressAuthorized(inboxId, address, env) {
|
|
1894
|
+
const host = ApiUrls[env ?? "dev"];
|
|
1891
1895
|
return await isAddressAuthorized(host, inboxId, address);
|
|
1892
1896
|
}
|
|
1893
1897
|
/**
|
|
@@ -1898,8 +1902,8 @@ class Client {
|
|
|
1898
1902
|
* @param options - Optional network options
|
|
1899
1903
|
* @returns Whether the installation is authorized
|
|
1900
1904
|
*/
|
|
1901
|
-
static async isInstallationAuthorized(inboxId, installation,
|
|
1902
|
-
const host =
|
|
1905
|
+
static async isInstallationAuthorized(inboxId, installation, env) {
|
|
1906
|
+
const host = ApiUrls[env ?? "dev"];
|
|
1903
1907
|
return await isInstallationAuthorized(host, inboxId, installation);
|
|
1904
1908
|
}
|
|
1905
1909
|
/**
|
|
@@ -1910,5 +1914,5 @@ class Client {
|
|
|
1910
1914
|
}
|
|
1911
1915
|
}
|
|
1912
1916
|
|
|
1913
|
-
export { ApiUrls, Client, Conversation, Conversations, DecodedMessage, Dm, Group, HistorySyncUrls, generateInboxId, getInboxIdForIdentifier };
|
|
1917
|
+
export { AccountAlreadyAssociatedError, ApiUrls, Client, ClientNotInitializedError, CodecNotFoundError, Conversation, Conversations, DecodedMessage, Dm, Group, HistorySyncUrls, InboxReassignError, InvalidGroupMembershipChangeError, MissingContentTypeError, SignerUnavailableError, generateInboxId, getInboxIdForIdentifier };
|
|
1914
1918
|
//# sourceMappingURL=index.js.map
|