@xmtp/browser-sdk 1.1.4 → 2.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/dist/index.d.ts +776 -27
- 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 +8 -8
- package/src/AsyncStream.ts +38 -8
- package/src/Client.ts +351 -72
- package/src/Conversation.ts +104 -13
- package/src/Conversations.ts +130 -0
- package/src/DecodedMessage.ts +20 -12
- package/src/Dm.ts +17 -1
- package/src/Group.ts +124 -9
- package/src/Preferences.ts +54 -0
- package/src/Utils.ts +21 -4
- package/src/UtilsWorkerClass.ts +7 -0
- package/src/WorkerClient.ts +18 -2
- package/src/WorkerConversation.ts +5 -0
- package/src/constants.ts +16 -0
- package/src/index.ts +0 -1
- package/src/types/clientEvents.ts +26 -2
- package/src/types/options.ts +5 -1
- package/src/types/utilsEvents.ts +8 -2
- package/src/utils/conversions.ts +21 -0
- package/src/utils/createClient.ts +4 -3
- package/src/utils/errors.ts +86 -0
- package/src/workers/client.ts +40 -8
- package/src/workers/utils.ts +12 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContentCodec, ContentTypeId as ContentTypeId$1, EncodedContent as EncodedContent$1 } from '@xmtp/content-type-primitives';
|
|
2
2
|
import * as _xmtp_wasm_bindings from '@xmtp/wasm-bindings';
|
|
3
|
-
import { Identifier, SignatureRequestType, ConsentState, ConsentEntityType, ConversationType, PermissionUpdateType, PermissionPolicy, MetadataField, Conversations as Conversations$1, Message, Conversation as Conversation$1, Client as Client$1, Consent, UserPreference, EncodedContent, MessageDisappearingSettings, GroupPermissionsOptions, DeliveryStatus, GroupMessageKind, ContentType, SortDirection, PermissionLevel, ContentTypeId, ListMessagesOptions, ListConversationsOptions, PermissionPolicySet, CreateGroupOptions, CreateDMOptions,
|
|
4
|
-
export { Consent, ConsentEntityType, ConsentState, ContentType, ContentTypeId, ConversationListItem, ConversationType, CreateDMOptions, CreateGroupOptions, DeliveryStatus, EncodedContent, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, HmacKey, Identifier, IdentifierKind, InboxState, Installation, ListConversationsOptions, ListMessagesOptions, LogOptions, Message, MessageDisappearingSettings, MetadataField,
|
|
3
|
+
import { Identifier, SignatureRequestType, ConsentState, ConsentEntityType, ConversationType, PermissionUpdateType, PermissionPolicy, MetadataField, Conversations as Conversations$1, Message, Conversation as Conversation$1, Client as Client$1, Consent, UserPreference, KeyPackageStatus, EncodedContent, MessageDisappearingSettings, HmacKey, GroupPermissionsOptions, DeliveryStatus, GroupMessageKind, ContentType, SortDirection, PermissionLevel, ContentTypeId, ListMessagesOptions, ListConversationsOptions, PermissionPolicySet, CreateGroupOptions, CreateDMOptions, Installation, InboxState, GroupMember } from '@xmtp/wasm-bindings';
|
|
4
|
+
export { Consent, ConsentEntityType, ConsentState, ContentType, ContentTypeId, ConversationListItem, ConversationType, CreateDMOptions, CreateGroupOptions, DeliveryStatus, EncodedContent, GroupMember, GroupMembershipState, GroupMessageKind, GroupMetadata, GroupPermissions, GroupPermissionsOptions, HmacKey, Identifier, IdentifierKind, InboxState, Installation, ListConversationsOptions, ListMessagesOptions, LogOptions, Message, MessageDisappearingSettings, MetadataField, PermissionLevel, PermissionPolicy, PermissionPolicySet, PermissionUpdateType, SignatureRequestType, SortDirection, UserPreference } from '@xmtp/wasm-bindings';
|
|
5
5
|
|
|
6
6
|
type ResolveValue<T> = {
|
|
7
7
|
value: T | undefined;
|
|
@@ -11,7 +11,9 @@ type StreamCallback<T> = (err: Error | null, value: T | undefined) => void | Pro
|
|
|
11
11
|
declare class AsyncStream<T> {
|
|
12
12
|
#private;
|
|
13
13
|
onReturn: (() => void) | undefined;
|
|
14
|
+
onError: ((error: Error) => void) | undefined;
|
|
14
15
|
constructor();
|
|
16
|
+
get error(): Error | null;
|
|
15
17
|
get isDone(): boolean;
|
|
16
18
|
callback: StreamCallback<T>;
|
|
17
19
|
next: () => Promise<ResolveValue<T>>;
|
|
@@ -22,11 +24,27 @@ declare class AsyncStream<T> {
|
|
|
22
24
|
[Symbol.asyncIterator](): this;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Pre-configured URLs for the XMTP network based on the environment
|
|
29
|
+
*
|
|
30
|
+
* @constant
|
|
31
|
+
* @property {string} local - The local URL for the XMTP network
|
|
32
|
+
* @property {string} dev - The development URL for the XMTP network
|
|
33
|
+
* @property {string} production - The production URL for the XMTP network
|
|
34
|
+
*/
|
|
25
35
|
declare const ApiUrls: {
|
|
26
36
|
readonly local: "http://localhost:5555";
|
|
27
37
|
readonly dev: "https://dev.xmtp.network";
|
|
28
38
|
readonly production: "https://production.xmtp.network";
|
|
29
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Pre-configured URLs for the XMTP history sync service based on the environment
|
|
42
|
+
*
|
|
43
|
+
* @constant
|
|
44
|
+
* @property {string} local - The local URL for the XMTP history sync service
|
|
45
|
+
* @property {string} dev - The development URL for the XMTP history sync service
|
|
46
|
+
* @property {string} production - The production URL for the XMTP history sync service
|
|
47
|
+
*/
|
|
30
48
|
declare const HistorySyncUrls: {
|
|
31
49
|
readonly local: "http://localhost:5558";
|
|
32
50
|
readonly dev: "https://message-history.dev.ephemera.network";
|
|
@@ -66,7 +84,11 @@ type StorageOptions = {
|
|
|
66
84
|
/**
|
|
67
85
|
* Path to the local DB
|
|
68
86
|
*/
|
|
69
|
-
dbPath?: string;
|
|
87
|
+
dbPath?: string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Encryption key for the local DB
|
|
90
|
+
*/
|
|
91
|
+
dbEncryptionKey?: Uint8Array;
|
|
70
92
|
};
|
|
71
93
|
type OtherOptions = {
|
|
72
94
|
/**
|
|
@@ -113,7 +135,6 @@ type ClientEvents =
|
|
|
113
135
|
};
|
|
114
136
|
data: {
|
|
115
137
|
identifier: Identifier;
|
|
116
|
-
encryptionKey: Uint8Array;
|
|
117
138
|
options?: ClientOptions;
|
|
118
139
|
};
|
|
119
140
|
} | {
|
|
@@ -147,6 +168,13 @@ type ClientEvents =
|
|
|
147
168
|
data: {
|
|
148
169
|
installationIds: Uint8Array[];
|
|
149
170
|
};
|
|
171
|
+
} | {
|
|
172
|
+
action: "changeRecoveryIdentifierSignatureText";
|
|
173
|
+
id: string;
|
|
174
|
+
result: string | undefined;
|
|
175
|
+
data: {
|
|
176
|
+
identifier: Identifier;
|
|
177
|
+
};
|
|
150
178
|
} | {
|
|
151
179
|
action: "addEcdsaSignature";
|
|
152
180
|
id: string;
|
|
@@ -255,6 +283,13 @@ type ClientEvents =
|
|
|
255
283
|
signatureBytes: Uint8Array;
|
|
256
284
|
publicKey: Uint8Array;
|
|
257
285
|
};
|
|
286
|
+
} | {
|
|
287
|
+
action: "getKeyPackageStatusesForInstallationIds";
|
|
288
|
+
id: string;
|
|
289
|
+
result: Map<string, SafeKeyPackageStatus>;
|
|
290
|
+
data: {
|
|
291
|
+
installationIds: string[];
|
|
292
|
+
};
|
|
258
293
|
}
|
|
259
294
|
/**
|
|
260
295
|
* Conversations actions
|
|
@@ -629,6 +664,13 @@ type ClientEvents =
|
|
|
629
664
|
data: {
|
|
630
665
|
id: string;
|
|
631
666
|
};
|
|
667
|
+
} | {
|
|
668
|
+
action: "getGroupHmacKeys";
|
|
669
|
+
id: string;
|
|
670
|
+
result: SafeHmacKey[];
|
|
671
|
+
data: {
|
|
672
|
+
id: string;
|
|
673
|
+
};
|
|
632
674
|
};
|
|
633
675
|
type ClientEventsActions = ClientEvents["action"];
|
|
634
676
|
type ClientEventsClientMessageData = EventsClientMessageData<ClientEvents>;
|
|
@@ -640,12 +682,18 @@ type ClientEventsClientPostMessageData<A extends ClientEventsActions> = EventsCl
|
|
|
640
682
|
type ClientEventsErrorData = EventsErrorData<ClientEvents>;
|
|
641
683
|
|
|
642
684
|
type UtilsEvents = {
|
|
685
|
+
action: "init";
|
|
686
|
+
id: string;
|
|
687
|
+
result: undefined;
|
|
688
|
+
data: {
|
|
689
|
+
enableLogging: boolean;
|
|
690
|
+
};
|
|
691
|
+
} | {
|
|
643
692
|
action: "generateInboxId";
|
|
644
693
|
id: string;
|
|
645
694
|
result: string;
|
|
646
695
|
data: {
|
|
647
696
|
identifier: Identifier;
|
|
648
|
-
enableLogging: boolean;
|
|
649
697
|
};
|
|
650
698
|
} | {
|
|
651
699
|
action: "getInboxIdForIdentifier";
|
|
@@ -654,7 +702,6 @@ type UtilsEvents = {
|
|
|
654
702
|
data: {
|
|
655
703
|
identifier: Identifier;
|
|
656
704
|
env?: XmtpEnv;
|
|
657
|
-
enableLogging: boolean;
|
|
658
705
|
};
|
|
659
706
|
};
|
|
660
707
|
type UtilsEventsActions = UtilsEvents["action"];
|
|
@@ -758,7 +805,7 @@ declare class WorkerPreferences {
|
|
|
758
805
|
declare class WorkerClient {
|
|
759
806
|
#private;
|
|
760
807
|
constructor(client: Client$1);
|
|
761
|
-
static create(identifier: Identifier,
|
|
808
|
+
static create(identifier: Identifier, options?: Omit<ClientOptions, "codecs">): Promise<WorkerClient>;
|
|
762
809
|
get accountIdentifier(): Identifier;
|
|
763
810
|
get inboxId(): string;
|
|
764
811
|
get installationId(): string;
|
|
@@ -771,6 +818,7 @@ declare class WorkerClient {
|
|
|
771
818
|
removeAccountSignatureText(identifier: Identifier): Promise<string | undefined>;
|
|
772
819
|
revokeAllAOtherInstallationsSignatureText(): Promise<string | undefined>;
|
|
773
820
|
revokeInstallationsSignatureText(installationIds: Uint8Array[]): Promise<string | undefined>;
|
|
821
|
+
changeRecoveryIdentifierSignatureText(identifier: Identifier): Promise<string | undefined>;
|
|
774
822
|
addEcdsaSignature(type: SignatureRequestType, bytes: Uint8Array): Promise<void>;
|
|
775
823
|
addScwSignature(type: SignatureRequestType, bytes: Uint8Array, chainId: bigint, blockNumber?: bigint): Promise<void>;
|
|
776
824
|
applySignatures(): Promise<void>;
|
|
@@ -780,6 +828,7 @@ declare class WorkerClient {
|
|
|
780
828
|
signWithInstallationKey(signatureText: string): Uint8Array<ArrayBufferLike>;
|
|
781
829
|
verifySignedWithInstallationKey(signatureText: string, signatureBytes: Uint8Array): boolean;
|
|
782
830
|
verifySignedWithPublicKey(signatureText: string, signatureBytes: Uint8Array, publicKey: Uint8Array): boolean;
|
|
831
|
+
getKeyPackageStatusesForInstallationIds(installationIds: string[]): Promise<Map<string, KeyPackageStatus>>;
|
|
783
832
|
}
|
|
784
833
|
|
|
785
834
|
declare class WorkerConversation {
|
|
@@ -831,6 +880,7 @@ declare class WorkerConversation {
|
|
|
831
880
|
isMessageDisappearingEnabled(): boolean;
|
|
832
881
|
stream(callback?: StreamCallback<Message>): _xmtp_wasm_bindings.StreamCloser;
|
|
833
882
|
pausedForVersion(): string | undefined;
|
|
883
|
+
getHmacKeys(): HmacKey[];
|
|
834
884
|
}
|
|
835
885
|
|
|
836
886
|
declare const toContentTypeId: (contentTypeId: ContentTypeId) => ContentTypeId$1;
|
|
@@ -981,6 +1031,14 @@ type SafeMessageDisappearingSettings = {
|
|
|
981
1031
|
};
|
|
982
1032
|
declare const toSafeMessageDisappearingSettings: (settings: MessageDisappearingSettings) => SafeMessageDisappearingSettings;
|
|
983
1033
|
declare const fromSafeMessageDisappearingSettings: (settings: SafeMessageDisappearingSettings) => MessageDisappearingSettings;
|
|
1034
|
+
type SafeKeyPackageStatus = {
|
|
1035
|
+
lifetime?: {
|
|
1036
|
+
notBefore: bigint;
|
|
1037
|
+
notAfter: bigint;
|
|
1038
|
+
};
|
|
1039
|
+
validationError?: string;
|
|
1040
|
+
};
|
|
1041
|
+
declare const toSafeKeyPackageStatus: (status: KeyPackageStatus) => SafeKeyPackageStatus;
|
|
984
1042
|
|
|
985
1043
|
type ClientStreamEvents = {
|
|
986
1044
|
type: "message";
|
|
@@ -1011,6 +1069,26 @@ declare class ClientWorkerClass {
|
|
|
1011
1069
|
|
|
1012
1070
|
type MessageKind = "application" | "membership_change";
|
|
1013
1071
|
type MessageDeliveryStatus = "unpublished" | "published" | "failed";
|
|
1072
|
+
/**
|
|
1073
|
+
* Represents a decoded XMTP message
|
|
1074
|
+
*
|
|
1075
|
+
* This class transforms network messages into a structured format with
|
|
1076
|
+
* content decoding.
|
|
1077
|
+
*
|
|
1078
|
+
* @class
|
|
1079
|
+
* @property {any} content - The decoded content of the message
|
|
1080
|
+
* @property {ContentTypeId} contentType - The content type of the message content
|
|
1081
|
+
* @property {string} conversationId - Unique identifier for the conversation
|
|
1082
|
+
* @property {MessageDeliveryStatus} deliveryStatus - Current delivery status of the message ("unpublished" | "published" | "failed")
|
|
1083
|
+
* @property {string} [fallback] - Optional fallback text for the message
|
|
1084
|
+
* @property {number} [compression] - Optional compression level applied to the message
|
|
1085
|
+
* @property {string} id - Unique identifier for the message
|
|
1086
|
+
* @property {MessageKind} kind - Type of message ("application" | "membership_change")
|
|
1087
|
+
* @property {Map<string, string>} parameters - Additional parameters associated with the message
|
|
1088
|
+
* @property {SafeMessage["content"]} encodedContent - Raw encoded content of the message
|
|
1089
|
+
* @property {string} senderInboxId - Identifier for the sender's inbox
|
|
1090
|
+
* @property {bigint} sentAtNs - Timestamp when the message was sent (in nanoseconds)
|
|
1091
|
+
*/
|
|
1014
1092
|
declare class DecodedMessage {
|
|
1015
1093
|
#private;
|
|
1016
1094
|
content: any;
|
|
@@ -1028,8 +1106,20 @@ declare class DecodedMessage {
|
|
|
1028
1106
|
constructor(client: Client, message: SafeMessage);
|
|
1029
1107
|
}
|
|
1030
1108
|
|
|
1109
|
+
/**
|
|
1110
|
+
* Represents a conversation
|
|
1111
|
+
*
|
|
1112
|
+
* This class is not intended to be initialized directly.
|
|
1113
|
+
*/
|
|
1031
1114
|
declare class Conversation {
|
|
1032
1115
|
#private;
|
|
1116
|
+
/**
|
|
1117
|
+
* Creates a new conversation instance
|
|
1118
|
+
*
|
|
1119
|
+
* @param client - The client instance managing the conversation
|
|
1120
|
+
* @param id - The unique identifier for this conversation
|
|
1121
|
+
* @param data - Optional conversation data to initialize with
|
|
1122
|
+
*/
|
|
1033
1123
|
constructor(client: Client, id: string, data?: SafeConversation);
|
|
1034
1124
|
get id(): string;
|
|
1035
1125
|
get isActive(): boolean | undefined;
|
|
@@ -1040,42 +1130,203 @@ declare class Conversation {
|
|
|
1040
1130
|
creatorInboxId: string;
|
|
1041
1131
|
conversationType: string;
|
|
1042
1132
|
} | undefined;
|
|
1133
|
+
/**
|
|
1134
|
+
* Gets the conversation members
|
|
1135
|
+
*
|
|
1136
|
+
* @returns Promise that resolves with the conversation members
|
|
1137
|
+
*/
|
|
1043
1138
|
members(): Promise<SafeGroupMember[]>;
|
|
1139
|
+
/**
|
|
1140
|
+
* Synchronizes conversation data from the network
|
|
1141
|
+
*
|
|
1142
|
+
* @returns Promise that resolves with the updated conversation data
|
|
1143
|
+
*/
|
|
1044
1144
|
sync(): Promise<SafeConversation>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Publishes pending messages that were sent optimistically
|
|
1147
|
+
*
|
|
1148
|
+
* @returns Promise that resolves when publishing is complete
|
|
1149
|
+
*/
|
|
1045
1150
|
publishMessages(): Promise<undefined>;
|
|
1151
|
+
/**
|
|
1152
|
+
* Sends a message optimistically
|
|
1153
|
+
*
|
|
1154
|
+
* @param content - The content to send
|
|
1155
|
+
* @param contentType - Optional content type of the message content
|
|
1156
|
+
* @returns Promise that resolves with the message ID
|
|
1157
|
+
* @throws {MissingContentTypeError} When content type is required but not provided
|
|
1158
|
+
*/
|
|
1046
1159
|
sendOptimistic(content: any, contentType?: ContentTypeId$1): Promise<string>;
|
|
1160
|
+
/**
|
|
1161
|
+
* Sends a message
|
|
1162
|
+
*
|
|
1163
|
+
* @param content - The content to send
|
|
1164
|
+
* @param contentType - Optional content type of the message content
|
|
1165
|
+
* @returns Promise that resolves with the message ID after it has been sent
|
|
1166
|
+
* @throws {MissingContentTypeError} When content type is required but not provided
|
|
1167
|
+
*/
|
|
1047
1168
|
send(content: any, contentType?: ContentTypeId$1): Promise<string>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Lists messages in this conversation
|
|
1171
|
+
*
|
|
1172
|
+
* @param options - Optional filtering and pagination options
|
|
1173
|
+
* @returns Promise that resolves with an array of decoded messages
|
|
1174
|
+
*/
|
|
1048
1175
|
messages(options?: SafeListMessagesOptions): Promise<DecodedMessage[]>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Gets the consent state for this conversation
|
|
1178
|
+
*
|
|
1179
|
+
* @returns Promise that resolves with the current consent state
|
|
1180
|
+
*/
|
|
1049
1181
|
consentState(): Promise<ConsentState>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Updates the consent state for this conversation
|
|
1184
|
+
*
|
|
1185
|
+
* @param state - The new consent state to set
|
|
1186
|
+
* @returns Promise that resolves when the update is complete
|
|
1187
|
+
*/
|
|
1050
1188
|
updateConsentState(state: ConsentState): Promise<undefined>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Gets the message disappearing settings for this conversation
|
|
1191
|
+
*
|
|
1192
|
+
* @returns Promise that resolves with the current message disappearing settings
|
|
1193
|
+
*/
|
|
1051
1194
|
messageDisappearingSettings(): Promise<SafeMessageDisappearingSettings | undefined>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Updates message disappearing settings for this conversation
|
|
1197
|
+
*
|
|
1198
|
+
* @param fromNs - The timestamp from which messages should start disappearing
|
|
1199
|
+
* @param inNs - The duration after which messages should disappear
|
|
1200
|
+
* @returns Promise that resolves when the update is complete
|
|
1201
|
+
*/
|
|
1052
1202
|
updateMessageDisappearingSettings(fromNs: bigint, inNs: bigint): Promise<undefined>;
|
|
1203
|
+
/**
|
|
1204
|
+
* Removes message disappearing settings from this conversation
|
|
1205
|
+
*
|
|
1206
|
+
* @returns Promise that resolves when the settings are removed
|
|
1207
|
+
*/
|
|
1053
1208
|
removeMessageDisappearingSettings(): Promise<undefined>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Checks if message disappearing is enabled for this conversation
|
|
1211
|
+
*
|
|
1212
|
+
* @returns Promise that resolves with whether message disappearing is enabled
|
|
1213
|
+
*/
|
|
1054
1214
|
isMessageDisappearingEnabled(): Promise<boolean>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Creates a stream for new messages in this conversation
|
|
1217
|
+
*
|
|
1218
|
+
* @param callback - Optional callback function for handling new stream values
|
|
1219
|
+
* @returns AsyncStream instance for new messages
|
|
1220
|
+
*/
|
|
1055
1221
|
stream(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage>>;
|
|
1056
1222
|
pausedForVersion(): Promise<string | undefined>;
|
|
1223
|
+
/**
|
|
1224
|
+
* Retrieves HMAC keys for this conversation
|
|
1225
|
+
*
|
|
1226
|
+
* @returns Promise that resolves with the HMAC keys
|
|
1227
|
+
*/
|
|
1228
|
+
getHmacKeys(): Promise<SafeHmacKey[]>;
|
|
1057
1229
|
}
|
|
1058
1230
|
|
|
1231
|
+
/**
|
|
1232
|
+
* Represents a direct message conversation between two inboxes
|
|
1233
|
+
*
|
|
1234
|
+
* This class is not intended to be initialized directly.
|
|
1235
|
+
*/
|
|
1059
1236
|
declare class Dm extends Conversation {
|
|
1060
1237
|
#private;
|
|
1238
|
+
/**
|
|
1239
|
+
* Creates a new direct message conversation instance
|
|
1240
|
+
*
|
|
1241
|
+
* @param client - The client instance managing this direct message conversation
|
|
1242
|
+
* @param id - Identifier for the direct message conversation
|
|
1243
|
+
* @param data - Optional conversation data to initialize with
|
|
1244
|
+
*/
|
|
1061
1245
|
constructor(client: Client, id: string, data?: SafeConversation);
|
|
1246
|
+
/**
|
|
1247
|
+
* Retrieves the inbox ID of the other participant in the DM
|
|
1248
|
+
*
|
|
1249
|
+
* @returns Promise that resolves with the peer's inbox ID
|
|
1250
|
+
*/
|
|
1062
1251
|
peerInboxId(): Promise<string>;
|
|
1063
1252
|
}
|
|
1064
1253
|
|
|
1254
|
+
/**
|
|
1255
|
+
* Represents a group conversation between multiple inboxes
|
|
1256
|
+
*
|
|
1257
|
+
* This class is not intended to be initialized directly.
|
|
1258
|
+
*/
|
|
1065
1259
|
declare class Group extends Conversation {
|
|
1066
1260
|
#private;
|
|
1261
|
+
/**
|
|
1262
|
+
* Creates a new group conversation instance
|
|
1263
|
+
*
|
|
1264
|
+
* @param client - The client instance managing this group conversation
|
|
1265
|
+
* @param id - Identifier for the group conversation
|
|
1266
|
+
* @param data - Optional conversation data to initialize with
|
|
1267
|
+
*/
|
|
1067
1268
|
constructor(client: Client, id: string, data?: SafeConversation);
|
|
1269
|
+
/**
|
|
1270
|
+
* Synchronizes the group's data with the network
|
|
1271
|
+
*
|
|
1272
|
+
* @returns Updated group data
|
|
1273
|
+
*/
|
|
1068
1274
|
sync(): Promise<SafeConversation>;
|
|
1275
|
+
/**
|
|
1276
|
+
* The name of the group
|
|
1277
|
+
*/
|
|
1069
1278
|
get name(): string | undefined;
|
|
1279
|
+
/**
|
|
1280
|
+
* Updates the group's name
|
|
1281
|
+
*
|
|
1282
|
+
* @param name The new name for the group
|
|
1283
|
+
*/
|
|
1070
1284
|
updateName(name: string): Promise<void>;
|
|
1285
|
+
/**
|
|
1286
|
+
* The image URL of the group
|
|
1287
|
+
*/
|
|
1071
1288
|
get imageUrl(): string | undefined;
|
|
1289
|
+
/**
|
|
1290
|
+
* Updates the group's image URL
|
|
1291
|
+
*
|
|
1292
|
+
* @param imageUrl The new image URL for the group
|
|
1293
|
+
*/
|
|
1072
1294
|
updateImageUrl(imageUrl: string): Promise<void>;
|
|
1295
|
+
/**
|
|
1296
|
+
* The description of the group
|
|
1297
|
+
*/
|
|
1073
1298
|
get description(): string | undefined;
|
|
1299
|
+
/**
|
|
1300
|
+
* Updates the group's description
|
|
1301
|
+
*
|
|
1302
|
+
* @param description The new description for the group
|
|
1303
|
+
*/
|
|
1074
1304
|
updateDescription(description: string): Promise<void>;
|
|
1305
|
+
/**
|
|
1306
|
+
* The list of admins of the group by inbox ID
|
|
1307
|
+
*/
|
|
1075
1308
|
get admins(): string[];
|
|
1309
|
+
/**
|
|
1310
|
+
* The list of super admins of the group by inbox ID
|
|
1311
|
+
*/
|
|
1076
1312
|
get superAdmins(): string[];
|
|
1313
|
+
/**
|
|
1314
|
+
* Fetches and updates the list of group admins from the server
|
|
1315
|
+
*
|
|
1316
|
+
* @returns Array of admin inbox IDs
|
|
1317
|
+
*/
|
|
1077
1318
|
listAdmins(): Promise<string[]>;
|
|
1319
|
+
/**
|
|
1320
|
+
* Fetches and updates the list of group super admins from the server
|
|
1321
|
+
*
|
|
1322
|
+
* @returns Array of super admin inbox IDs
|
|
1323
|
+
*/
|
|
1078
1324
|
listSuperAdmins(): Promise<string[]>;
|
|
1325
|
+
/**
|
|
1326
|
+
* Retrieves the group's permissions
|
|
1327
|
+
*
|
|
1328
|
+
* @returns The group's permissions
|
|
1329
|
+
*/
|
|
1079
1330
|
permissions(): Promise<{
|
|
1080
1331
|
policyType: _xmtp_wasm_bindings.GroupPermissionsOptions;
|
|
1081
1332
|
policySet: {
|
|
@@ -1089,52 +1340,295 @@ declare class Group extends Conversation {
|
|
|
1089
1340
|
updateMessageDisappearingPolicy: PermissionPolicy;
|
|
1090
1341
|
};
|
|
1091
1342
|
}>;
|
|
1343
|
+
/**
|
|
1344
|
+
* Updates a specific permission policy for the group
|
|
1345
|
+
*
|
|
1346
|
+
* @param permissionType The type of permission to update
|
|
1347
|
+
* @param policy The new permission policy
|
|
1348
|
+
* @param metadataField Optional metadata field for the permission
|
|
1349
|
+
*/
|
|
1092
1350
|
updatePermission(permissionType: PermissionUpdateType, policy: PermissionPolicy, metadataField?: MetadataField): Promise<undefined>;
|
|
1351
|
+
/**
|
|
1352
|
+
* Checks if an inbox is an admin of the group
|
|
1353
|
+
*
|
|
1354
|
+
* @param inboxId The inbox ID to check
|
|
1355
|
+
* @returns Boolean indicating if the inbox is an admin
|
|
1356
|
+
*/
|
|
1093
1357
|
isAdmin(inboxId: string): Promise<boolean>;
|
|
1358
|
+
/**
|
|
1359
|
+
* Checks if an inbox is a super admin of the group
|
|
1360
|
+
*
|
|
1361
|
+
* @param inboxId The inbox ID to check
|
|
1362
|
+
* @returns Boolean indicating if the inbox is a super admin
|
|
1363
|
+
*/
|
|
1094
1364
|
isSuperAdmin(inboxId: string): Promise<boolean>;
|
|
1365
|
+
/**
|
|
1366
|
+
* Adds members to the group using identifiers
|
|
1367
|
+
*
|
|
1368
|
+
* @param identifiers Array of member identifiers to add
|
|
1369
|
+
*/
|
|
1095
1370
|
addMembersByIdentifiers(identifiers: Identifier[]): Promise<undefined>;
|
|
1371
|
+
/**
|
|
1372
|
+
* Adds members to the group using inbox IDs
|
|
1373
|
+
*
|
|
1374
|
+
* @param inboxIds Array of inbox IDs to add
|
|
1375
|
+
*/
|
|
1096
1376
|
addMembers(inboxIds: string[]): Promise<undefined>;
|
|
1377
|
+
/**
|
|
1378
|
+
* Removes members from the group using identifiers
|
|
1379
|
+
*
|
|
1380
|
+
* @param identifiers Array of member identifiers to remove
|
|
1381
|
+
*/
|
|
1097
1382
|
removeMembersByIdentifiers(identifiers: Identifier[]): Promise<undefined>;
|
|
1383
|
+
/**
|
|
1384
|
+
* Removes members from the group using inbox IDs
|
|
1385
|
+
*
|
|
1386
|
+
* @param inboxIds Array of inbox IDs to remove
|
|
1387
|
+
*/
|
|
1098
1388
|
removeMembers(inboxIds: string[]): Promise<undefined>;
|
|
1389
|
+
/**
|
|
1390
|
+
* Promotes a group member to admin status
|
|
1391
|
+
*
|
|
1392
|
+
* @param inboxId The inbox ID of the member to promote
|
|
1393
|
+
*/
|
|
1099
1394
|
addAdmin(inboxId: string): Promise<undefined>;
|
|
1395
|
+
/**
|
|
1396
|
+
* Removes admin status from a group member
|
|
1397
|
+
*
|
|
1398
|
+
* @param inboxId The inbox ID of the admin to demote
|
|
1399
|
+
*/
|
|
1100
1400
|
removeAdmin(inboxId: string): Promise<undefined>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Promotes a group member to super admin status
|
|
1403
|
+
*
|
|
1404
|
+
* @param inboxId The inbox ID of the member to promote
|
|
1405
|
+
*/
|
|
1101
1406
|
addSuperAdmin(inboxId: string): Promise<undefined>;
|
|
1407
|
+
/**
|
|
1408
|
+
* Removes super admin status from a group member
|
|
1409
|
+
*
|
|
1410
|
+
* @param inboxId The inbox ID of the super admin to demote
|
|
1411
|
+
*/
|
|
1102
1412
|
removeSuperAdmin(inboxId: string): Promise<undefined>;
|
|
1103
1413
|
}
|
|
1104
1414
|
|
|
1415
|
+
/**
|
|
1416
|
+
* Manages conversations
|
|
1417
|
+
*
|
|
1418
|
+
* This class is not intended to be initialized directly.
|
|
1419
|
+
*/
|
|
1105
1420
|
declare class Conversations {
|
|
1106
1421
|
#private;
|
|
1422
|
+
/**
|
|
1423
|
+
* Creates a new conversations instance
|
|
1424
|
+
*
|
|
1425
|
+
* @param client - The client instance managing the conversations
|
|
1426
|
+
*/
|
|
1107
1427
|
constructor(client: Client);
|
|
1428
|
+
/**
|
|
1429
|
+
* Synchronizes conversations for the current client from the network
|
|
1430
|
+
*
|
|
1431
|
+
* @returns Promise that resolves when sync is complete
|
|
1432
|
+
*/
|
|
1108
1433
|
sync(): Promise<undefined>;
|
|
1434
|
+
/**
|
|
1435
|
+
* Synchronizes all conversations and messages from the network with optional
|
|
1436
|
+
* consent state filtering, then uploads conversation and message history to
|
|
1437
|
+
* the history sync server
|
|
1438
|
+
*
|
|
1439
|
+
* @param consentStates - Optional array of consent states to filter by
|
|
1440
|
+
* @returns Promise that resolves when sync is complete
|
|
1441
|
+
*/
|
|
1109
1442
|
syncAll(consentStates?: ConsentState[]): Promise<undefined>;
|
|
1443
|
+
/**
|
|
1444
|
+
* Retrieves a conversation by its ID
|
|
1445
|
+
*
|
|
1446
|
+
* @param id - The conversation ID to look up
|
|
1447
|
+
* @returns Promise that resolves with the conversation, if found
|
|
1448
|
+
*/
|
|
1110
1449
|
getConversationById(id: string): Promise<Dm | Group | undefined>;
|
|
1450
|
+
/**
|
|
1451
|
+
* Retrieves a message by its ID
|
|
1452
|
+
*
|
|
1453
|
+
* @param id - The message ID to look up
|
|
1454
|
+
* @returns Promise that resolves with the decoded message, if found
|
|
1455
|
+
*/
|
|
1111
1456
|
getMessageById(id: string): Promise<DecodedMessage | undefined>;
|
|
1457
|
+
/**
|
|
1458
|
+
* Retrieves a DM by inbox ID
|
|
1459
|
+
*
|
|
1460
|
+
* @param inboxId - The inbox ID to look up
|
|
1461
|
+
* @returns Promise that resolves with the DM, if found
|
|
1462
|
+
*/
|
|
1112
1463
|
getDmByInboxId(inboxId: string): Promise<Dm | undefined>;
|
|
1464
|
+
/**
|
|
1465
|
+
* Lists all conversations with optional filtering
|
|
1466
|
+
*
|
|
1467
|
+
* @param options - Optional filtering and pagination options
|
|
1468
|
+
* @returns Promise that resolves with an array of conversations
|
|
1469
|
+
*/
|
|
1113
1470
|
list(options?: SafeListConversationsOptions): Promise<(Dm | Group)[]>;
|
|
1471
|
+
/**
|
|
1472
|
+
* Lists all group conversations with optional filtering
|
|
1473
|
+
*
|
|
1474
|
+
* @param options - Optional filtering and pagination options
|
|
1475
|
+
* @returns Promise that resolves with an array of groups
|
|
1476
|
+
*/
|
|
1114
1477
|
listGroups(options?: Omit<SafeListConversationsOptions, "conversation_type">): Promise<Group[]>;
|
|
1478
|
+
/**
|
|
1479
|
+
* Lists all DM conversations with optional filtering
|
|
1480
|
+
*
|
|
1481
|
+
* @param options - Optional filtering and pagination options
|
|
1482
|
+
* @returns Promise that resolves with an array of DMs
|
|
1483
|
+
*/
|
|
1115
1484
|
listDms(options?: Omit<SafeListConversationsOptions, "conversation_type">): Promise<Dm[]>;
|
|
1485
|
+
/**
|
|
1486
|
+
* Creates a new group conversation with the specified identifiers
|
|
1487
|
+
*
|
|
1488
|
+
* @param identifiers - Array of identifiers for group members
|
|
1489
|
+
* @param options - Optional group creation options
|
|
1490
|
+
* @returns Promise that resolves with the new group
|
|
1491
|
+
*/
|
|
1116
1492
|
newGroupWithIdentifiers(identifiers: Identifier[], options?: SafeCreateGroupOptions): Promise<Group>;
|
|
1493
|
+
/**
|
|
1494
|
+
* Creates a new group conversation with the specified inbox IDs
|
|
1495
|
+
*
|
|
1496
|
+
* @param inboxIds - Array of inbox IDs for group members
|
|
1497
|
+
* @param options - Optional group creation options
|
|
1498
|
+
* @returns Promise that resolves with the new group
|
|
1499
|
+
*/
|
|
1117
1500
|
newGroup(inboxIds: string[], options?: SafeCreateGroupOptions): Promise<Group>;
|
|
1501
|
+
/**
|
|
1502
|
+
* Creates a new DM conversation with the specified identifier
|
|
1503
|
+
*
|
|
1504
|
+
* @param identifier - Identifier for the DM recipient
|
|
1505
|
+
* @param options - Optional DM creation options
|
|
1506
|
+
* @returns Promise that resolves with the new DM
|
|
1507
|
+
*/
|
|
1118
1508
|
newDmWithIdentifier(identifier: Identifier, options?: SafeCreateDmOptions): Promise<Dm>;
|
|
1509
|
+
/**
|
|
1510
|
+
* Creates a new DM conversation with the specified inbox ID
|
|
1511
|
+
*
|
|
1512
|
+
* @param inboxId - Inbox ID for the DM recipient
|
|
1513
|
+
* @param options - Optional DM creation options
|
|
1514
|
+
* @returns Promise that resolves with the new DM
|
|
1515
|
+
*/
|
|
1119
1516
|
newDm(inboxId: string, options?: SafeCreateDmOptions): Promise<Dm>;
|
|
1517
|
+
/**
|
|
1518
|
+
* Retrieves HMAC keys for all conversations
|
|
1519
|
+
*
|
|
1520
|
+
* @returns Promise that resolves with the HMAC keys for all conversations
|
|
1521
|
+
*/
|
|
1120
1522
|
getHmacKeys(): Promise<SafeHmacKeys>;
|
|
1523
|
+
/**
|
|
1524
|
+
* Creates a stream for new conversations
|
|
1525
|
+
*
|
|
1526
|
+
* @param callback - Optional callback function for handling new stream value
|
|
1527
|
+
* @param conversationType - Optional type to filter conversations
|
|
1528
|
+
* @returns AsyncStream instance for new conversations
|
|
1529
|
+
*/
|
|
1121
1530
|
stream<T extends Group | Dm = Group | Dm>(callback?: StreamCallback<T>, conversationType?: ConversationType): Promise<AsyncStream<T>>;
|
|
1531
|
+
/**
|
|
1532
|
+
* Creates a stream for new group conversations
|
|
1533
|
+
*
|
|
1534
|
+
* @param callback - Optional callback function for handling new stream value
|
|
1535
|
+
* @returns AsyncStream instance for new group conversations
|
|
1536
|
+
*/
|
|
1122
1537
|
streamGroups(callback?: StreamCallback<Group>): Promise<AsyncStream<Group>>;
|
|
1538
|
+
/**
|
|
1539
|
+
* Creates a stream for new DM conversations
|
|
1540
|
+
*
|
|
1541
|
+
* @param callback - Optional callback function for handling new stream value
|
|
1542
|
+
* @returns AsyncStream instance for new DM conversations
|
|
1543
|
+
*/
|
|
1123
1544
|
streamDms(callback?: StreamCallback<Dm>): Promise<AsyncStream<Dm>>;
|
|
1545
|
+
/**
|
|
1546
|
+
* Creates a stream for all new messages
|
|
1547
|
+
*
|
|
1548
|
+
* @param callback - Optional callback function for handling new stream value
|
|
1549
|
+
* @param conversationType - Optional conversation type to filter messages
|
|
1550
|
+
* @returns AsyncStream instance for new messages
|
|
1551
|
+
*/
|
|
1124
1552
|
streamAllMessages(callback?: StreamCallback<DecodedMessage>, conversationType?: ConversationType): Promise<AsyncStream<DecodedMessage>>;
|
|
1553
|
+
/**
|
|
1554
|
+
* Creates a stream for all new group messages
|
|
1555
|
+
*
|
|
1556
|
+
* @param callback - Optional callback function for handling new stream value
|
|
1557
|
+
* @returns AsyncStream instance for new group messages
|
|
1558
|
+
*/
|
|
1125
1559
|
streamAllGroupMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage>>;
|
|
1560
|
+
/**
|
|
1561
|
+
* Creates a stream for all new DM messages
|
|
1562
|
+
*
|
|
1563
|
+
* @param callback - Optional callback function for handling new stream value
|
|
1564
|
+
* @returns AsyncStream instance for new DM messages
|
|
1565
|
+
*/
|
|
1126
1566
|
streamAllDmMessages(callback?: StreamCallback<DecodedMessage>): Promise<AsyncStream<DecodedMessage>>;
|
|
1127
1567
|
}
|
|
1128
1568
|
|
|
1569
|
+
/**
|
|
1570
|
+
* Manages user preferences and consent states
|
|
1571
|
+
*
|
|
1572
|
+
* This class is not intended to be initialized directly.
|
|
1573
|
+
*/
|
|
1129
1574
|
declare class Preferences {
|
|
1130
1575
|
#private;
|
|
1576
|
+
/**
|
|
1577
|
+
* Creates a new preferences instance
|
|
1578
|
+
*
|
|
1579
|
+
* @param client - The client instance managing preferences
|
|
1580
|
+
*/
|
|
1131
1581
|
constructor(client: Client);
|
|
1582
|
+
/**
|
|
1583
|
+
* Retrieves the current inbox state
|
|
1584
|
+
*
|
|
1585
|
+
* @param refreshFromNetwork - Optional flag to force refresh from network
|
|
1586
|
+
* @returns Promise that resolves with the inbox state
|
|
1587
|
+
*/
|
|
1132
1588
|
inboxState(refreshFromNetwork?: boolean): Promise<SafeInboxState>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Retrieves inbox state for specific inbox IDs
|
|
1591
|
+
*
|
|
1592
|
+
* @param inboxIds - Array of inbox IDs to get state for
|
|
1593
|
+
* @param refreshFromNetwork - Optional flag to force refresh from network
|
|
1594
|
+
* @returns Promise that resolves with the inbox state for the inbox IDs
|
|
1595
|
+
*/
|
|
1133
1596
|
inboxStateFromInboxIds(inboxIds: string[], refreshFromNetwork?: boolean): Promise<SafeInboxState[]>;
|
|
1597
|
+
/**
|
|
1598
|
+
* Gets the latest inbox state for a specific inbox
|
|
1599
|
+
*
|
|
1600
|
+
* @param inboxId - The inbox ID to get state for
|
|
1601
|
+
* @returns Promise that resolves with the latest inbox state
|
|
1602
|
+
*/
|
|
1134
1603
|
getLatestInboxState(inboxId: string): Promise<SafeInboxState>;
|
|
1604
|
+
/**
|
|
1605
|
+
* Updates consent states for multiple records
|
|
1606
|
+
*
|
|
1607
|
+
* @param records - Array of consent records to update
|
|
1608
|
+
* @returns Promise that resolves when consent states are updated
|
|
1609
|
+
*/
|
|
1135
1610
|
setConsentStates(records: SafeConsent[]): Promise<undefined>;
|
|
1611
|
+
/**
|
|
1612
|
+
* Retrieves consent state for a specific entity
|
|
1613
|
+
*
|
|
1614
|
+
* @param entityType - Type of entity to get consent for
|
|
1615
|
+
* @param entity - Entity identifier
|
|
1616
|
+
* @returns Promise that resolves with the consent state
|
|
1617
|
+
*/
|
|
1136
1618
|
getConsentState(entityType: ConsentEntityType, entity: string): Promise<_xmtp_wasm_bindings.ConsentState>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Creates a stream of consent state updates
|
|
1621
|
+
*
|
|
1622
|
+
* @param callback - Optional callback function for handling stream updates
|
|
1623
|
+
* @returns AsyncStream instance for consent updates
|
|
1624
|
+
*/
|
|
1137
1625
|
streamConsent(callback?: StreamCallback<SafeConsent[]>): Promise<AsyncStream<SafeConsent[]>>;
|
|
1626
|
+
/**
|
|
1627
|
+
* Creates a stream of user preference updates
|
|
1628
|
+
*
|
|
1629
|
+
* @param callback - Optional callback function for handling stream updates
|
|
1630
|
+
* @returns AsyncStream instance for preference updates
|
|
1631
|
+
*/
|
|
1138
1632
|
streamPreferences(callback?: StreamCallback<UserPreference[]>): Promise<AsyncStream<UserPreference[]>>;
|
|
1139
1633
|
}
|
|
1140
1634
|
|
|
@@ -1154,121 +1648,376 @@ type Signer = {
|
|
|
1154
1648
|
getChainId: GetChainId;
|
|
1155
1649
|
};
|
|
1156
1650
|
|
|
1651
|
+
/**
|
|
1652
|
+
* Client for interacting with the XMTP network
|
|
1653
|
+
*/
|
|
1157
1654
|
declare class Client extends ClientWorkerClass {
|
|
1158
1655
|
#private;
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1656
|
+
/**
|
|
1657
|
+
* Creates a new XMTP client instance
|
|
1658
|
+
*
|
|
1659
|
+
* This class is not intended to be initialized directly.
|
|
1660
|
+
* Use `Client.create` or `Client.build` instead.
|
|
1661
|
+
*
|
|
1662
|
+
* @param options - Optional configuration for the client
|
|
1663
|
+
*/
|
|
1664
|
+
constructor(options?: ClientOptions);
|
|
1665
|
+
/**
|
|
1666
|
+
* Initializes the client with the provided identifier
|
|
1667
|
+
*
|
|
1668
|
+
* This is not meant to be called directly.
|
|
1669
|
+
* Use `Client.create` or `Client.build` instead.
|
|
1670
|
+
*
|
|
1671
|
+
* @param identifier - The identifier to initialize the client with
|
|
1672
|
+
*/
|
|
1673
|
+
init(identifier: Identifier): Promise<void>;
|
|
1674
|
+
/**
|
|
1675
|
+
* Creates a new client instance with a signer
|
|
1676
|
+
*
|
|
1677
|
+
* @param signer - The signer to use for authentication
|
|
1678
|
+
* @param options - Optional configuration for the client
|
|
1679
|
+
* @returns A new client instance
|
|
1680
|
+
*/
|
|
1681
|
+
static create(signer: Signer, options?: ClientOptions): Promise<Client>;
|
|
1682
|
+
/**
|
|
1683
|
+
* Creates a new client instance with an identifier
|
|
1684
|
+
*
|
|
1685
|
+
* Clients created with this method must already be registered.
|
|
1686
|
+
* Any methods called that require a signer will throw an error.
|
|
1687
|
+
*
|
|
1688
|
+
* @param identifier - The identifier to use
|
|
1689
|
+
* @param options - Optional configuration for the client
|
|
1690
|
+
* @returns A new client instance
|
|
1691
|
+
*/
|
|
1692
|
+
static build(identifier: Identifier, options?: ClientOptions): Promise<Client>;
|
|
1693
|
+
/**
|
|
1694
|
+
* Gets the client options
|
|
1695
|
+
*/
|
|
1696
|
+
get options(): ClientOptions | undefined;
|
|
1697
|
+
/**
|
|
1698
|
+
* Gets whether the client has been initialized
|
|
1699
|
+
*/
|
|
1163
1700
|
get isReady(): boolean;
|
|
1701
|
+
/**
|
|
1702
|
+
* Gets the inbox ID associated with this client
|
|
1703
|
+
*/
|
|
1164
1704
|
get inboxId(): string | undefined;
|
|
1165
|
-
|
|
1705
|
+
/**
|
|
1706
|
+
* Gets the account identifier for this client
|
|
1707
|
+
*/
|
|
1708
|
+
get accountIdentifier(): Identifier | undefined;
|
|
1709
|
+
/**
|
|
1710
|
+
* Gets the installation ID for this client
|
|
1711
|
+
*/
|
|
1166
1712
|
get installationId(): string | undefined;
|
|
1713
|
+
/**
|
|
1714
|
+
* Gets the installation ID bytes for this client
|
|
1715
|
+
*/
|
|
1167
1716
|
get installationIdBytes(): Uint8Array<ArrayBufferLike> | undefined;
|
|
1717
|
+
/**
|
|
1718
|
+
* Gets the conversations manager for this client
|
|
1719
|
+
*/
|
|
1168
1720
|
get conversations(): Conversations;
|
|
1721
|
+
/**
|
|
1722
|
+
* Gets the preferences manager for this client
|
|
1723
|
+
*/
|
|
1169
1724
|
get preferences(): Preferences;
|
|
1170
1725
|
/**
|
|
1726
|
+
* Creates signature text for creating a new inbox
|
|
1727
|
+
*
|
|
1171
1728
|
* WARNING: This function should be used with caution. It is only provided
|
|
1172
1729
|
* for use in special cases where the provided workflows do not meet the
|
|
1173
1730
|
* requirements of an application.
|
|
1174
1731
|
*
|
|
1175
|
-
* It is highly recommended to use the `register`
|
|
1732
|
+
* It is highly recommended to use the `register` method instead.
|
|
1733
|
+
*
|
|
1734
|
+
* @returns The signature text
|
|
1176
1735
|
*/
|
|
1177
1736
|
unsafe_createInboxSignatureText(): Promise<string | undefined>;
|
|
1178
1737
|
/**
|
|
1738
|
+
* Creates signature text for adding a new account to the client's inbox
|
|
1739
|
+
*
|
|
1179
1740
|
* WARNING: This function should be used with caution. It is only provided
|
|
1180
1741
|
* for use in special cases where the provided workflows do not meet the
|
|
1181
1742
|
* requirements of an application.
|
|
1182
1743
|
*
|
|
1183
|
-
* It is highly recommended to use the `unsafe_addAccount`
|
|
1744
|
+
* It is highly recommended to use the `unsafe_addAccount` method instead.
|
|
1184
1745
|
*
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1746
|
+
* @param newIdentifier - The identifier of the new account
|
|
1747
|
+
* @param allowInboxReassign - Whether to allow inbox reassignment
|
|
1748
|
+
* @returns The signature text
|
|
1187
1749
|
*/
|
|
1188
1750
|
unsafe_addAccountSignatureText(newIdentifier: Identifier, allowInboxReassign?: boolean): Promise<string | undefined>;
|
|
1189
1751
|
/**
|
|
1752
|
+
* Creates signature text for removing an account from the client's inbox
|
|
1753
|
+
*
|
|
1190
1754
|
* WARNING: This function should be used with caution. It is only provided
|
|
1191
1755
|
* for use in special cases where the provided workflows do not meet the
|
|
1192
1756
|
* requirements of an application.
|
|
1193
1757
|
*
|
|
1194
|
-
* It is highly recommended to use the `removeAccount`
|
|
1758
|
+
* It is highly recommended to use the `removeAccount` method instead.
|
|
1759
|
+
*
|
|
1760
|
+
* @param identifier - The identifier of the account to remove
|
|
1761
|
+
* @returns The signature text
|
|
1195
1762
|
*/
|
|
1196
1763
|
unsafe_removeAccountSignatureText(identifier: Identifier): Promise<string | undefined>;
|
|
1197
1764
|
/**
|
|
1765
|
+
* Creates signature text for revoking all other installations of the
|
|
1766
|
+
* client's inbox
|
|
1767
|
+
*
|
|
1198
1768
|
* WARNING: This function should be used with caution. It is only provided
|
|
1199
1769
|
* for use in special cases where the provided workflows do not meet the
|
|
1200
1770
|
* requirements of an application.
|
|
1201
1771
|
*
|
|
1202
|
-
* It is highly recommended to use the `revokeAllOtherInstallations`
|
|
1203
|
-
*
|
|
1772
|
+
* It is highly recommended to use the `revokeAllOtherInstallations` method instead.
|
|
1773
|
+
*
|
|
1774
|
+
* @returns The signature text
|
|
1204
1775
|
*/
|
|
1205
1776
|
unsafe_revokeAllOtherInstallationsSignatureText(): Promise<string | undefined>;
|
|
1206
1777
|
/**
|
|
1778
|
+
* Creates signature text for revoking specific installations of the
|
|
1779
|
+
* client's inbox
|
|
1780
|
+
*
|
|
1207
1781
|
* WARNING: This function should be used with caution. It is only provided
|
|
1208
1782
|
* for use in special cases where the provided workflows do not meet the
|
|
1209
1783
|
* requirements of an application.
|
|
1210
1784
|
*
|
|
1211
|
-
* It is highly recommended to use the `revokeInstallations`
|
|
1785
|
+
* It is highly recommended to use the `revokeInstallations` method instead.
|
|
1786
|
+
*
|
|
1787
|
+
* @param installationIds - The installation IDs to revoke
|
|
1788
|
+
* @returns The signature text
|
|
1212
1789
|
*/
|
|
1213
1790
|
unsafe_revokeInstallationsSignatureText(installationIds: Uint8Array[]): Promise<string | undefined>;
|
|
1214
1791
|
/**
|
|
1792
|
+
* Creates signature text for changing the recovery identifier for this
|
|
1793
|
+
* client's inbox
|
|
1794
|
+
*
|
|
1215
1795
|
* WARNING: This function should be used with caution. It is only provided
|
|
1216
1796
|
* for use in special cases where the provided workflows do not meet the
|
|
1217
1797
|
* requirements of an application.
|
|
1218
1798
|
*
|
|
1219
|
-
* It is highly recommended to use the `
|
|
1799
|
+
* It is highly recommended to use the `changeRecoveryIdentifier` method instead.
|
|
1800
|
+
*
|
|
1801
|
+
* @param identifier - The new recovery identifier
|
|
1802
|
+
* @returns The signature text
|
|
1803
|
+
*/
|
|
1804
|
+
unsafe_changeRecoveryIdentifierSignatureText(identifier: Identifier): Promise<string | undefined>;
|
|
1805
|
+
/**
|
|
1806
|
+
* Adds a signature for a specific request type
|
|
1807
|
+
*
|
|
1808
|
+
* WARNING: This function should be used with caution. It is only provided
|
|
1809
|
+
* for use in special cases where the provided workflows do not meet the
|
|
1810
|
+
* requirements of an application.
|
|
1811
|
+
*
|
|
1812
|
+
* It is highly recommended to use the `register`, `unsafe_addAccount`,
|
|
1220
1813
|
* `removeAccount`, `revokeAllOtherInstallations`, or `revokeInstallations`
|
|
1221
|
-
*
|
|
1814
|
+
* methods instead.
|
|
1815
|
+
*
|
|
1816
|
+
* @param signatureType - The type of signature request
|
|
1817
|
+
* @param signatureText - The text to sign
|
|
1818
|
+
* @param signer - The signer to use
|
|
1819
|
+
* @warning This is an unsafe operation and should be used with caution
|
|
1222
1820
|
*/
|
|
1223
1821
|
unsafe_addSignature(signatureType: SignatureRequestType, signatureText: string, signer: Signer): Promise<void>;
|
|
1224
1822
|
/**
|
|
1823
|
+
* Applies all pending signatures
|
|
1824
|
+
*
|
|
1225
1825
|
* WARNING: This function should be used with caution. It is only provided
|
|
1226
1826
|
* for use in special cases where the provided workflows do not meet the
|
|
1227
1827
|
* requirements of an application.
|
|
1228
1828
|
*
|
|
1229
|
-
* It is highly recommended to use the `register`, `
|
|
1829
|
+
* It is highly recommended to use the `register`, `unsafe_addAccount`,
|
|
1230
1830
|
* `removeAccount`, `revokeAllOtherInstallations`, or `revokeInstallations`
|
|
1231
|
-
*
|
|
1831
|
+
* methods instead.
|
|
1232
1832
|
*/
|
|
1233
1833
|
unsafe_applySignatures(): Promise<undefined>;
|
|
1834
|
+
/**
|
|
1835
|
+
* Registers the client with the XMTP network
|
|
1836
|
+
*
|
|
1837
|
+
* Requires a signer, use `Client.create` to create a client with a signer.
|
|
1838
|
+
*
|
|
1839
|
+
* @throws {SignerUnavailableError} if no signer is available
|
|
1840
|
+
*/
|
|
1234
1841
|
register(): Promise<undefined>;
|
|
1235
1842
|
/**
|
|
1843
|
+
* Adds a new account to the client inbox
|
|
1844
|
+
*
|
|
1236
1845
|
* WARNING: This function should be used with caution. Adding a wallet already
|
|
1237
|
-
* associated with an
|
|
1846
|
+
* associated with an inbox ID will cause the wallet to lose access to
|
|
1238
1847
|
* that inbox.
|
|
1239
1848
|
*
|
|
1240
1849
|
* The `allowInboxReassign` parameter must be true to reassign an inbox
|
|
1241
1850
|
* already associated with a different account.
|
|
1851
|
+
*
|
|
1852
|
+
* Requires a signer, use `Client.create` to create a client with a signer.
|
|
1853
|
+
*
|
|
1854
|
+
* @param newAccountSigner - The signer for the new account
|
|
1855
|
+
* @param allowInboxReassign - Whether to allow inbox reassignment
|
|
1856
|
+
* @throws {AccountAlreadyAssociatedError} if the account is already associated with an inbox ID
|
|
1857
|
+
* @throws {GenerateSignatureError} if the signature cannot be generated
|
|
1858
|
+
* @throws {SignerUnavailableError} if no signer is available
|
|
1242
1859
|
*/
|
|
1243
1860
|
unsafe_addAccount(newAccountSigner: Signer, allowInboxReassign?: boolean): Promise<void>;
|
|
1861
|
+
/**
|
|
1862
|
+
* Removes an account from the client's inbox
|
|
1863
|
+
*
|
|
1864
|
+
* Requires a signer, use `Client.create` to create a client with a signer.
|
|
1865
|
+
*
|
|
1866
|
+
* @param accountIdentifier - The identifier of the account to remove
|
|
1867
|
+
* @throws {GenerateSignatureError} if the signature cannot be generated
|
|
1868
|
+
* @throws {SignerUnavailableError} if no signer is available
|
|
1869
|
+
*/
|
|
1244
1870
|
removeAccount(accountIdentifier: Identifier): Promise<void>;
|
|
1871
|
+
/**
|
|
1872
|
+
* Revokes all other installations of the client's inbox
|
|
1873
|
+
*
|
|
1874
|
+
* Requires a signer, use `Client.create` to create a client with a signer.
|
|
1875
|
+
*
|
|
1876
|
+
* @throws {GenerateSignatureError} if the signature cannot be generated
|
|
1877
|
+
* @throws {SignerUnavailableError} if no signer is available
|
|
1878
|
+
*/
|
|
1245
1879
|
revokeAllOtherInstallations(): Promise<void>;
|
|
1880
|
+
/**
|
|
1881
|
+
* Revokes specific installations of the client's inbox
|
|
1882
|
+
*
|
|
1883
|
+
* Requires a signer, use `Client.create` to create a client with a signer.
|
|
1884
|
+
*
|
|
1885
|
+
* @param installationIds - The installation IDs to revoke
|
|
1886
|
+
* @throws {GenerateSignatureError} if the signature cannot be generated
|
|
1887
|
+
* @throws {SignerUnavailableError} if no signer is available
|
|
1888
|
+
*/
|
|
1246
1889
|
revokeInstallations(installationIds: Uint8Array[]): Promise<void>;
|
|
1890
|
+
/**
|
|
1891
|
+
* Changes the recovery identifier for the client's inbox
|
|
1892
|
+
*
|
|
1893
|
+
* Requires a signer, use `Client.create` to create a client with a signer.
|
|
1894
|
+
*
|
|
1895
|
+
* @param identifier - The new recovery identifier
|
|
1896
|
+
* @throws {GenerateSignatureError} if the signature cannot be generated
|
|
1897
|
+
* @throws {SignerUnavailableError} if no signer is available
|
|
1898
|
+
*/
|
|
1899
|
+
changeRecoveryIdentifier(identifier: Identifier): Promise<void>;
|
|
1900
|
+
/**
|
|
1901
|
+
* Checks if the client is registered with the XMTP network
|
|
1902
|
+
*
|
|
1903
|
+
* @returns Whether the client is registered
|
|
1904
|
+
*/
|
|
1247
1905
|
isRegistered(): Promise<boolean>;
|
|
1906
|
+
/**
|
|
1907
|
+
* Checks if the client can message the specified identifiers
|
|
1908
|
+
*
|
|
1909
|
+
* @param identifiers - The identifiers to check
|
|
1910
|
+
* @returns Whether the client can message the identifiers
|
|
1911
|
+
*/
|
|
1248
1912
|
canMessage(identifiers: Identifier[]): Promise<Map<string, boolean>>;
|
|
1913
|
+
/**
|
|
1914
|
+
* Checks if the specified identifiers can be messaged
|
|
1915
|
+
*
|
|
1916
|
+
* @param identifiers - The identifiers to check
|
|
1917
|
+
* @param env - Optional XMTP environment
|
|
1918
|
+
* @returns Map of identifiers to whether they can be messaged
|
|
1919
|
+
*/
|
|
1249
1920
|
static canMessage(identifiers: Identifier[], env?: XmtpEnv): Promise<Map<string, boolean>>;
|
|
1921
|
+
/**
|
|
1922
|
+
* Finds the inbox ID for a given identifier
|
|
1923
|
+
*
|
|
1924
|
+
* @param identifier - The identifier to look up
|
|
1925
|
+
* @returns The inbox ID, if found
|
|
1926
|
+
*/
|
|
1250
1927
|
findInboxIdByIdentifier(identifier: Identifier): Promise<string | undefined>;
|
|
1928
|
+
/**
|
|
1929
|
+
* Gets the codec for a given content type
|
|
1930
|
+
*
|
|
1931
|
+
* @param contentType - The content type to get the codec for
|
|
1932
|
+
* @returns The codec, if found
|
|
1933
|
+
*/
|
|
1251
1934
|
codecFor(contentType: ContentTypeId$1): ContentCodec | undefined;
|
|
1935
|
+
/**
|
|
1936
|
+
* Encodes content for a given content type
|
|
1937
|
+
*
|
|
1938
|
+
* @param content - The content to encode
|
|
1939
|
+
* @param contentType - The content type to encode for
|
|
1940
|
+
* @returns The encoded content
|
|
1941
|
+
* @throws {CodecNotFoundError} if no codec is found for the content type
|
|
1942
|
+
*/
|
|
1252
1943
|
encodeContent(content: any, contentType: ContentTypeId$1): SafeEncodedContent;
|
|
1944
|
+
/**
|
|
1945
|
+
* Decodes a message for a given content type
|
|
1946
|
+
*
|
|
1947
|
+
* @param message - The message to decode
|
|
1948
|
+
* @param contentType - The content type to decode for
|
|
1949
|
+
* @returns The decoded content
|
|
1950
|
+
* @throws {CodecNotFoundError} if no codec is found for the content type
|
|
1951
|
+
* @throws {InvalidGroupMembershipChangeError} if the message is an invalid group membership change
|
|
1952
|
+
*/
|
|
1253
1953
|
decodeContent(message: SafeMessage, contentType: ContentTypeId$1): any;
|
|
1954
|
+
/**
|
|
1955
|
+
* Signs a message with the installation key
|
|
1956
|
+
*
|
|
1957
|
+
* @param signatureText - The text to sign
|
|
1958
|
+
* @returns The signature
|
|
1959
|
+
*/
|
|
1254
1960
|
signWithInstallationKey(signatureText: string): Promise<Uint8Array<ArrayBufferLike>>;
|
|
1961
|
+
/**
|
|
1962
|
+
* Verifies a signature was made with the installation key
|
|
1963
|
+
*
|
|
1964
|
+
* @param signatureText - The text that was signed
|
|
1965
|
+
* @param signatureBytes - The signature bytes to verify
|
|
1966
|
+
* @returns Whether the signature is valid
|
|
1967
|
+
*/
|
|
1255
1968
|
verifySignedWithInstallationKey(signatureText: string, signatureBytes: Uint8Array): Promise<boolean>;
|
|
1969
|
+
/**
|
|
1970
|
+
* Verifies a signature was made with a public key
|
|
1971
|
+
*
|
|
1972
|
+
* @param signatureText - The text that was signed
|
|
1973
|
+
* @param signatureBytes - The signature bytes to verify
|
|
1974
|
+
* @param publicKey - The public key to verify against
|
|
1975
|
+
* @returns Whether the signature is valid
|
|
1976
|
+
*/
|
|
1256
1977
|
verifySignedWithPublicKey(signatureText: string, signatureBytes: Uint8Array, publicKey: Uint8Array): Promise<boolean>;
|
|
1978
|
+
/**
|
|
1979
|
+
* Gets the key package statuses for the specified installation IDs
|
|
1980
|
+
*
|
|
1981
|
+
* @param installationIds - The installation IDs to check
|
|
1982
|
+
* @returns The key package statuses
|
|
1983
|
+
*/
|
|
1984
|
+
getKeyPackageStatusesForInstallationIds(installationIds: string[]): Promise<Map<string, SafeKeyPackageStatus>>;
|
|
1257
1985
|
}
|
|
1258
1986
|
|
|
1259
1987
|
declare class UtilsWorkerClass {
|
|
1260
1988
|
#private;
|
|
1261
1989
|
constructor(worker: Worker, enableLogging: boolean);
|
|
1990
|
+
init(enableLogging: boolean): Promise<undefined>;
|
|
1262
1991
|
sendMessage<A extends UtilsEventsActions>(action: A, data: UtilsSendMessageData<A>): Promise<UtilsEventsResult<A>>;
|
|
1263
1992
|
handleMessage: (event: MessageEvent<UtilsEventsWorkerMessageData | UtilsEventsErrorData>) => void;
|
|
1264
1993
|
close(): void;
|
|
1265
1994
|
}
|
|
1266
1995
|
|
|
1996
|
+
/**
|
|
1997
|
+
* Utility class that provides helper functions for XMTP inbox IDs
|
|
1998
|
+
*/
|
|
1267
1999
|
declare class Utils extends UtilsWorkerClass {
|
|
1268
|
-
|
|
2000
|
+
/**
|
|
2001
|
+
* Creates a new Utils instance
|
|
2002
|
+
*
|
|
2003
|
+
* @param enableLogging - Optional flag to enable logging
|
|
2004
|
+
*/
|
|
1269
2005
|
constructor(enableLogging?: boolean);
|
|
2006
|
+
/**
|
|
2007
|
+
* Generates an inbox ID for a given identifier
|
|
2008
|
+
*
|
|
2009
|
+
* @param identifier - The identifier to generate an inbox ID for
|
|
2010
|
+
* @returns Promise that resolves with the generated inbox ID
|
|
2011
|
+
*/
|
|
1270
2012
|
generateInboxId(identifier: Identifier): Promise<string>;
|
|
2013
|
+
/**
|
|
2014
|
+
* Gets the inbox ID for a specific identifier and optional environment
|
|
2015
|
+
*
|
|
2016
|
+
* @param identifier - The identifier to get the inbox ID for
|
|
2017
|
+
* @param env - Optional XMTP environment configuration (default: "dev")
|
|
2018
|
+
* @returns Promise that resolves with the inbox ID for the identifier
|
|
2019
|
+
*/
|
|
1271
2020
|
getInboxIdForIdentifier(identifier: Identifier, env?: XmtpEnv): Promise<string | undefined>;
|
|
1272
2021
|
}
|
|
1273
2022
|
|
|
1274
|
-
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, Dm, type EventsClientMessageData, type EventsClientPostMessageData, type EventsErrorData, type EventsResult, type EventsWorkerMessageData, type EventsWorkerPostMessageData, type GenericEvent, type GenericStreamEvent, Group, HistorySyncUrls, type HmacKeys, type MessageDeliveryStatus, type MessageKind, type NetworkOptions, type OtherOptions, type SafeConsent, type SafeContentTypeId, type SafeConversation, type SafeCreateDmOptions, type SafeCreateGroupOptions, type SafeEncodedContent, type SafeGroupMember, type SafeHmacKey, type SafeHmacKeys, type SafeInboxState, type SafeInstallation, type SafeListConversationsOptions, type SafeListMessagesOptions, type SafeMessage, type SafeMessageDisappearingSettings, type SafePermissionPolicySet, type SendMessageData, type Signer, type StorageOptions, type StreamEventsClientMessageData, type StreamEventsClientPostMessageData, type StreamEventsErrorData, type StreamEventsResult, 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, fromSafeCreateDmOptions, fromSafeCreateGroupOptions, fromSafeEncodedContent, fromSafeGroupMember, fromSafeListConversationsOptions, fromSafeListMessagesOptions, fromSafeMessageDisappearingSettings, fromSafePermissionPolicySet, toContentTypeId, toEncodedContent, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeCreateDmOptions, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeHmacKey, toSafeInboxState, toSafeInstallation, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage, toSafeMessageDisappearingSettings, toSafePermissionPolicySet };
|
|
2023
|
+
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, Dm, type EventsClientMessageData, type EventsClientPostMessageData, type EventsErrorData, type EventsResult, type EventsWorkerMessageData, type EventsWorkerPostMessageData, type GenericEvent, type GenericStreamEvent, Group, HistorySyncUrls, type HmacKeys, type MessageDeliveryStatus, type MessageKind, type NetworkOptions, type OtherOptions, type SafeConsent, type SafeContentTypeId, type SafeConversation, type SafeCreateDmOptions, type SafeCreateGroupOptions, type SafeEncodedContent, type SafeGroupMember, type SafeHmacKey, type SafeHmacKeys, type SafeInboxState, type SafeInstallation, type SafeKeyPackageStatus, type SafeListConversationsOptions, type SafeListMessagesOptions, type SafeMessage, type SafeMessageDisappearingSettings, type SafePermissionPolicySet, type SendMessageData, type Signer, type StorageOptions, type StreamEventsClientMessageData, type StreamEventsClientPostMessageData, type StreamEventsErrorData, type StreamEventsResult, 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, fromSafeCreateDmOptions, fromSafeCreateGroupOptions, fromSafeEncodedContent, fromSafeGroupMember, fromSafeListConversationsOptions, fromSafeListMessagesOptions, fromSafeMessageDisappearingSettings, fromSafePermissionPolicySet, toContentTypeId, toEncodedContent, toSafeConsent, toSafeContentTypeId, toSafeConversation, toSafeCreateDmOptions, toSafeCreateGroupOptions, toSafeEncodedContent, toSafeGroupMember, toSafeHmacKey, toSafeInboxState, toSafeInstallation, toSafeKeyPackageStatus, toSafeListConversationsOptions, toSafeListMessagesOptions, toSafeMessage, toSafeMessageDisappearingSettings, toSafePermissionPolicySet };
|