@xmtp/browser-sdk 6.5.0 → 7.0.0
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 +17 -0
- package/dist/index.d.ts +227 -52
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/workers/client.js +1 -1
- package/dist/workers/client.js.map +1 -1
- package/package.json +11 -3
- package/src/Client.ts +255 -14
- package/src/WorkerClient.ts +55 -7
- package/src/WorkerConversation.ts +4 -4
- package/src/constants.ts +5 -0
- package/src/index.ts +7 -1
- package/src/types/actions/client.ts +71 -1
- package/src/types/options.ts +27 -13
- package/src/utils/createBackend.ts +45 -0
- package/src/utils/createClient.ts +58 -27
- package/src/utils/inboxId.ts +5 -15
- package/src/utils/inboxState.ts +5 -9
- package/src/utils/installations.ts +8 -17
- package/src/utils/signer.ts +37 -1
- package/src/workers/client.ts +37 -1
package/src/Client.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { type ContentCodec } from "@xmtp/content-type-primitives";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Backend,
|
|
4
|
+
BackupElementSelectionOption,
|
|
5
|
+
LogLevel,
|
|
6
|
+
type ArchiveMetadata,
|
|
7
|
+
type ArchiveOptions,
|
|
8
|
+
type AvailableArchiveInfo,
|
|
9
|
+
type GroupSyncSummary,
|
|
10
|
+
type Identifier,
|
|
11
|
+
type InboxState,
|
|
12
|
+
} from "@xmtp/wasm-bindings";
|
|
3
13
|
import { CodecRegistry } from "@/CodecRegistry";
|
|
14
|
+
import { HistorySyncUrls } from "@/constants";
|
|
4
15
|
import { Conversations } from "@/Conversations";
|
|
5
16
|
import { DebugInformation } from "@/DebugInformation";
|
|
6
17
|
import { Preferences } from "@/Preferences";
|
|
@@ -10,6 +21,7 @@ import type {
|
|
|
10
21
|
ExtractCodecContentTypes,
|
|
11
22
|
XmtpEnv,
|
|
12
23
|
} from "@/types/options";
|
|
24
|
+
import { createBackend } from "@/utils/createBackend";
|
|
13
25
|
import {
|
|
14
26
|
AccountAlreadyAssociatedError,
|
|
15
27
|
InboxReassignError,
|
|
@@ -22,6 +34,23 @@ import { toSafeSigner, type SafeSigner, type Signer } from "@/utils/signer";
|
|
|
22
34
|
import { uuid } from "@/utils/uuid";
|
|
23
35
|
import { WorkerBridge } from "@/utils/WorkerBridge";
|
|
24
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Resolves a `Backend` instance from either a `Backend` or an `XmtpEnv` string.
|
|
39
|
+
*
|
|
40
|
+
* @param envOrBackend - A `Backend` instance, or an `XmtpEnv` string
|
|
41
|
+
* @param gatewayHost - Optional gateway host (only used when `envOrBackend` is an `XmtpEnv`)
|
|
42
|
+
* @returns A `Backend` instance
|
|
43
|
+
*/
|
|
44
|
+
const resolveBackend = async (
|
|
45
|
+
envOrBackend?: XmtpEnv | Backend,
|
|
46
|
+
gatewayHost?: string,
|
|
47
|
+
): Promise<Backend> => {
|
|
48
|
+
if (envOrBackend instanceof Backend) {
|
|
49
|
+
return envOrBackend;
|
|
50
|
+
}
|
|
51
|
+
return createBackend({ env: envOrBackend, gatewayHost });
|
|
52
|
+
};
|
|
53
|
+
|
|
25
54
|
/**
|
|
26
55
|
* Client for interacting with the XMTP network
|
|
27
56
|
*/
|
|
@@ -30,6 +59,7 @@ export class Client<ContentTypes = ExtractCodecContentTypes> {
|
|
|
30
59
|
#codecRegistry: CodecRegistry;
|
|
31
60
|
#conversations: Conversations<ContentTypes>;
|
|
32
61
|
#debugInformation: DebugInformation;
|
|
62
|
+
#env?: XmtpEnv;
|
|
33
63
|
#identifier?: Identifier;
|
|
34
64
|
#inboxId?: string;
|
|
35
65
|
#installationId?: string;
|
|
@@ -97,6 +127,7 @@ export class Client<ContentTypes = ExtractCodecContentTypes> {
|
|
|
97
127
|
options: this.#options,
|
|
98
128
|
});
|
|
99
129
|
this.#appVersion = result.appVersion;
|
|
130
|
+
this.#env = result.env as XmtpEnv;
|
|
100
131
|
this.#identifier = identifier;
|
|
101
132
|
this.#inboxId = result.inboxId;
|
|
102
133
|
this.#installationId = result.installationId;
|
|
@@ -246,6 +277,13 @@ export class Client<ContentTypes = ExtractCodecContentTypes> {
|
|
|
246
277
|
return this.#appVersion;
|
|
247
278
|
}
|
|
248
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Gets the XMTP environment used by this client
|
|
282
|
+
*/
|
|
283
|
+
get env() {
|
|
284
|
+
return this.#env;
|
|
285
|
+
}
|
|
286
|
+
|
|
249
287
|
/**
|
|
250
288
|
* Creates signature text for creating a new inbox
|
|
251
289
|
*
|
|
@@ -559,10 +597,27 @@ export class Client<ContentTypes = ExtractCodecContentTypes> {
|
|
|
559
597
|
/**
|
|
560
598
|
* Revokes specific installations of the client's inbox without a client
|
|
561
599
|
*
|
|
562
|
-
* @param env - The environment to use
|
|
563
600
|
* @param signer - The signer to use
|
|
564
601
|
* @param inboxId - The inbox ID to revoke installations for
|
|
565
602
|
* @param installationIds - The installation IDs to revoke
|
|
603
|
+
* @param backend - Optional `Backend` instance created with `createBackend()`
|
|
604
|
+
*/
|
|
605
|
+
static async revokeInstallations(
|
|
606
|
+
signer: Signer,
|
|
607
|
+
inboxId: string,
|
|
608
|
+
installationIds: Uint8Array[],
|
|
609
|
+
backend?: Backend,
|
|
610
|
+
): Promise<void>;
|
|
611
|
+
/**
|
|
612
|
+
* Revokes specific installations of the client's inbox without a client
|
|
613
|
+
*
|
|
614
|
+
* @param signer - The signer to use
|
|
615
|
+
* @param inboxId - The inbox ID to revoke installations for
|
|
616
|
+
* @param installationIds - The installation IDs to revoke
|
|
617
|
+
* @param env - The environment to use
|
|
618
|
+
* @param gatewayHost - Optional gateway host
|
|
619
|
+
* @deprecated Pass a `Backend` instance created with `createBackend()` instead
|
|
620
|
+
* of `XmtpEnv` and `gatewayHost`.
|
|
566
621
|
*/
|
|
567
622
|
static async revokeInstallations(
|
|
568
623
|
signer: Signer,
|
|
@@ -570,30 +625,53 @@ export class Client<ContentTypes = ExtractCodecContentTypes> {
|
|
|
570
625
|
installationIds: Uint8Array[],
|
|
571
626
|
env?: XmtpEnv,
|
|
572
627
|
gatewayHost?: string,
|
|
628
|
+
): Promise<void>;
|
|
629
|
+
static async revokeInstallations(
|
|
630
|
+
signer: Signer,
|
|
631
|
+
inboxId: string,
|
|
632
|
+
installationIds: Uint8Array[],
|
|
633
|
+
envOrBackend?: XmtpEnv | Backend,
|
|
634
|
+
gatewayHost?: string,
|
|
573
635
|
) {
|
|
574
|
-
await
|
|
575
|
-
|
|
576
|
-
inboxId,
|
|
577
|
-
installationIds,
|
|
578
|
-
env,
|
|
579
|
-
gatewayHost,
|
|
580
|
-
);
|
|
636
|
+
const backend = await resolveBackend(envOrBackend, gatewayHost);
|
|
637
|
+
await utilsRevokeInstallations(backend, signer, inboxId, installationIds);
|
|
581
638
|
}
|
|
582
639
|
|
|
640
|
+
/**
|
|
641
|
+
* Fetches the inbox states for the specified inbox IDs from the network
|
|
642
|
+
* without a client
|
|
643
|
+
*
|
|
644
|
+
* @param inboxIds - The inbox IDs to get the state for
|
|
645
|
+
* @param backend - Optional `Backend` instance created with `createBackend()`
|
|
646
|
+
* @returns The inbox states for the specified inbox IDs
|
|
647
|
+
*/
|
|
648
|
+
static async fetchInboxStates(
|
|
649
|
+
inboxIds: string[],
|
|
650
|
+
backend?: Backend,
|
|
651
|
+
): Promise<InboxState[]>;
|
|
583
652
|
/**
|
|
584
653
|
* Fetches the inbox states for the specified inbox IDs from the network
|
|
585
654
|
* without a client
|
|
586
655
|
*
|
|
587
656
|
* @param inboxIds - The inbox IDs to get the state for
|
|
588
657
|
* @param env - The environment to use
|
|
658
|
+
* @param gatewayHost - Optional gateway host
|
|
589
659
|
* @returns The inbox states for the specified inbox IDs
|
|
660
|
+
* @deprecated Pass a `Backend` instance created with `createBackend()` instead
|
|
661
|
+
* of `XmtpEnv` and `gatewayHost`.
|
|
590
662
|
*/
|
|
591
663
|
static async fetchInboxStates(
|
|
592
664
|
inboxIds: string[],
|
|
593
665
|
env?: XmtpEnv,
|
|
594
666
|
gatewayHost?: string,
|
|
667
|
+
): Promise<InboxState[]>;
|
|
668
|
+
static async fetchInboxStates(
|
|
669
|
+
inboxIds: string[],
|
|
670
|
+
envOrBackend?: XmtpEnv | Backend,
|
|
671
|
+
gatewayHost?: string,
|
|
595
672
|
) {
|
|
596
|
-
|
|
673
|
+
const backend = await resolveBackend(envOrBackend, gatewayHost);
|
|
674
|
+
return utilsInboxStateFromInboxIds(backend, inboxIds);
|
|
597
675
|
}
|
|
598
676
|
|
|
599
677
|
/**
|
|
@@ -640,17 +718,40 @@ export class Client<ContentTypes = ExtractCodecContentTypes> {
|
|
|
640
718
|
return this.#worker.action("client.canMessage", { identifiers });
|
|
641
719
|
}
|
|
642
720
|
|
|
721
|
+
/**
|
|
722
|
+
* Checks if the specified identifiers can be messaged
|
|
723
|
+
*
|
|
724
|
+
* @param identifiers - The identifiers to check
|
|
725
|
+
* @param backend - Optional `Backend` instance created with `createBackend()`
|
|
726
|
+
* @returns Map of identifiers to whether they can be messaged
|
|
727
|
+
*/
|
|
728
|
+
static async canMessage(
|
|
729
|
+
identifiers: Identifier[],
|
|
730
|
+
backend?: Backend,
|
|
731
|
+
): Promise<Map<string, boolean>>;
|
|
643
732
|
/**
|
|
644
733
|
* Checks if the specified identifiers can be messaged
|
|
645
734
|
*
|
|
646
735
|
* @param identifiers - The identifiers to check
|
|
647
736
|
* @param env - Optional XMTP environment
|
|
648
737
|
* @returns Map of identifiers to whether they can be messaged
|
|
738
|
+
* @deprecated Pass a `Backend` instance created with `createBackend()` instead
|
|
739
|
+
* of `XmtpEnv`.
|
|
649
740
|
*/
|
|
650
|
-
|
|
741
|
+
/* eslint-disable @typescript-eslint/unified-signatures */
|
|
742
|
+
static async canMessage(
|
|
743
|
+
identifiers: Identifier[],
|
|
744
|
+
env?: XmtpEnv,
|
|
745
|
+
): Promise<Map<string, boolean>>;
|
|
746
|
+
/* eslint-enable @typescript-eslint/unified-signatures */
|
|
747
|
+
static async canMessage(
|
|
748
|
+
identifiers: Identifier[],
|
|
749
|
+
envOrBackend?: XmtpEnv | Backend,
|
|
750
|
+
) {
|
|
751
|
+
const backend = await resolveBackend(envOrBackend);
|
|
651
752
|
const canMessageMap = new Map<string, boolean>();
|
|
652
753
|
for (const identifier of identifiers) {
|
|
653
|
-
const inboxId = await getInboxIdForIdentifier(
|
|
754
|
+
const inboxId = await getInboxIdForIdentifier(backend, identifier);
|
|
654
755
|
canMessageMap.set(
|
|
655
756
|
identifier.identifier.toLowerCase(),
|
|
656
757
|
inboxId !== undefined,
|
|
@@ -732,12 +833,152 @@ export class Client<ContentTypes = ExtractCodecContentTypes> {
|
|
|
732
833
|
});
|
|
733
834
|
}
|
|
734
835
|
|
|
836
|
+
/**
|
|
837
|
+
* Get the default archive options (consent and messages)
|
|
838
|
+
*/
|
|
839
|
+
#getDefaultArchiveOptions(): ArchiveOptions {
|
|
840
|
+
return {
|
|
841
|
+
elements: [
|
|
842
|
+
BackupElementSelectionOption.Consent,
|
|
843
|
+
BackupElementSelectionOption.Messages,
|
|
844
|
+
],
|
|
845
|
+
excludeDisappearingMessages: false,
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Get the default server URL based on the environment
|
|
851
|
+
*/
|
|
852
|
+
#getDefaultServerUrl(): string {
|
|
853
|
+
const env = this.#env ?? "dev";
|
|
854
|
+
return HistorySyncUrls[env];
|
|
855
|
+
}
|
|
856
|
+
|
|
735
857
|
/**
|
|
736
858
|
* Send a sync request to other devices on the network
|
|
737
859
|
*
|
|
860
|
+
* @param options - Archive options specifying what to sync (defaults to consent and messages)
|
|
861
|
+
* @param serverUrl - The server URL for the sync request (defaults to environment-specific URL)
|
|
738
862
|
* @returns Promise that resolves when the sync request is sent
|
|
739
863
|
*/
|
|
740
|
-
async sendSyncRequest() {
|
|
741
|
-
|
|
864
|
+
async sendSyncRequest(options?: ArchiveOptions, serverUrl?: string) {
|
|
865
|
+
const resolvedOptions = options ?? this.#getDefaultArchiveOptions();
|
|
866
|
+
const resolvedServerUrl = serverUrl ?? this.#getDefaultServerUrl();
|
|
867
|
+
|
|
868
|
+
return this.#worker.action("client.sendSyncRequest", {
|
|
869
|
+
options: resolvedOptions,
|
|
870
|
+
serverUrl: resolvedServerUrl,
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Send a sync archive to the sync group
|
|
876
|
+
*
|
|
877
|
+
* @param pin - The pin used for reference when importing
|
|
878
|
+
* @param options - Archive options specifying what to sync (defaults to consent and messages)
|
|
879
|
+
* @param serverUrl - The server URL for the sync archive (defaults to environment-specific URL)
|
|
880
|
+
* @returns Promise that resolves when the sync archive is sent
|
|
881
|
+
*/
|
|
882
|
+
async sendSyncArchive(
|
|
883
|
+
pin: string,
|
|
884
|
+
options?: ArchiveOptions,
|
|
885
|
+
serverUrl?: string,
|
|
886
|
+
) {
|
|
887
|
+
const resolvedOptions = options ?? this.#getDefaultArchiveOptions();
|
|
888
|
+
const resolvedServerUrl = serverUrl ?? this.#getDefaultServerUrl();
|
|
889
|
+
|
|
890
|
+
return this.#worker.action("client.sendSyncArchive", {
|
|
891
|
+
options: resolvedOptions,
|
|
892
|
+
serverUrl: resolvedServerUrl,
|
|
893
|
+
pin,
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Process a sync archive that matches the pin given
|
|
899
|
+
*
|
|
900
|
+
* @param archivePin - Optional pin to match. If not provided, processes the last archive sent
|
|
901
|
+
* @returns Promise that resolves when the archive is processed
|
|
902
|
+
*/
|
|
903
|
+
async processSyncArchive(archivePin?: string | null) {
|
|
904
|
+
return this.#worker.action("client.processSyncArchive", {
|
|
905
|
+
archivePin,
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* List the archives available for import in the sync group
|
|
911
|
+
*
|
|
912
|
+
* You may need to manually sync the sync group before calling
|
|
913
|
+
* this function to see recently uploaded archives.
|
|
914
|
+
*
|
|
915
|
+
* @param daysCutoff - Number of days to look back for archives
|
|
916
|
+
* @returns Promise that resolves with array of available archive information
|
|
917
|
+
*/
|
|
918
|
+
async listAvailableArchives(
|
|
919
|
+
daysCutoff: number,
|
|
920
|
+
): Promise<AvailableArchiveInfo[]> {
|
|
921
|
+
return this.#worker.action("client.listAvailableArchives", {
|
|
922
|
+
daysCutoff,
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Export archive data to bytes for later restoration
|
|
928
|
+
*
|
|
929
|
+
* @param key - Encryption key for the archive
|
|
930
|
+
* @param opts - Archive options specifying what to include (defaults to consent and messages)
|
|
931
|
+
* @returns Promise that resolves with the archive data as bytes
|
|
932
|
+
*/
|
|
933
|
+
async createArchive(
|
|
934
|
+
key: Uint8Array,
|
|
935
|
+
opts?: ArchiveOptions,
|
|
936
|
+
): Promise<Uint8Array> {
|
|
937
|
+
const resolvedOpts = opts ?? this.#getDefaultArchiveOptions();
|
|
938
|
+
|
|
939
|
+
return this.#worker.action("client.createArchive", {
|
|
940
|
+
opts: resolvedOpts,
|
|
941
|
+
key,
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Import an archive from bytes
|
|
947
|
+
*
|
|
948
|
+
* @param data - The archive data as bytes
|
|
949
|
+
* @param key - Encryption key for the archive
|
|
950
|
+
* @returns Promise that resolves when the archive is imported
|
|
951
|
+
*/
|
|
952
|
+
async importArchive(data: Uint8Array, key: Uint8Array) {
|
|
953
|
+
return this.#worker.action("client.importArchive", {
|
|
954
|
+
data,
|
|
955
|
+
key,
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Load the metadata for an archive to see what it contains
|
|
961
|
+
*
|
|
962
|
+
* @param data - The archive data as bytes
|
|
963
|
+
* @param key - Encryption key for the archive
|
|
964
|
+
* @returns Promise that resolves with the archive metadata
|
|
965
|
+
*/
|
|
966
|
+
async archiveMetadata(
|
|
967
|
+
data: Uint8Array,
|
|
968
|
+
key: Uint8Array,
|
|
969
|
+
): Promise<ArchiveMetadata> {
|
|
970
|
+
return this.#worker.action("client.archiveMetadata", {
|
|
971
|
+
data,
|
|
972
|
+
key,
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* Manually sync all device sync groups
|
|
978
|
+
*
|
|
979
|
+
* @returns Promise that resolves with a summary of the sync operation
|
|
980
|
+
*/
|
|
981
|
+
async syncAllDeviceSyncGroups(): Promise<GroupSyncSummary> {
|
|
982
|
+
return this.#worker.action("client.syncAllDeviceSyncGroups");
|
|
742
983
|
}
|
|
743
984
|
}
|
package/src/WorkerClient.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
verifySignedWithPublicKey,
|
|
3
|
+
type ArchiveMetadata,
|
|
4
|
+
type ArchiveOptions,
|
|
5
|
+
type AvailableArchiveInfo,
|
|
3
6
|
type Client,
|
|
7
|
+
type GroupSyncSummary,
|
|
4
8
|
type Identifier,
|
|
5
9
|
type KeyPackageStatus,
|
|
6
10
|
type SignatureRequestHandle,
|
|
7
11
|
} from "@xmtp/wasm-bindings";
|
|
8
|
-
import type { ClientOptions } from "@/types/options";
|
|
12
|
+
import type { ClientOptions, XmtpEnv } from "@/types/options";
|
|
9
13
|
import { createClient } from "@/utils/createClient";
|
|
10
14
|
import type { SafeSigner } from "@/utils/signer";
|
|
11
15
|
import { WorkerConversations } from "@/WorkerConversations";
|
|
@@ -16,10 +20,12 @@ export class WorkerClient {
|
|
|
16
20
|
#client: Client;
|
|
17
21
|
#conversations: WorkerConversations;
|
|
18
22
|
#debugInformation: WorkerDebugInformation;
|
|
23
|
+
#env: XmtpEnv;
|
|
19
24
|
#preferences: WorkerPreferences;
|
|
20
25
|
|
|
21
|
-
constructor(client: Client) {
|
|
26
|
+
constructor(client: Client, env: XmtpEnv) {
|
|
22
27
|
this.#client = client;
|
|
28
|
+
this.#env = env;
|
|
23
29
|
const conversations = client.conversations();
|
|
24
30
|
this.#conversations = new WorkerConversations(this, conversations);
|
|
25
31
|
this.#debugInformation = new WorkerDebugInformation(client);
|
|
@@ -30,8 +36,8 @@ export class WorkerClient {
|
|
|
30
36
|
identifier: Identifier,
|
|
31
37
|
options?: Omit<ClientOptions, "codecs">,
|
|
32
38
|
) {
|
|
33
|
-
const client = await createClient(identifier, options);
|
|
34
|
-
return new WorkerClient(client);
|
|
39
|
+
const { client, env } = await createClient(identifier, options);
|
|
40
|
+
return new WorkerClient(client, env);
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
get libxmtpVersion() {
|
|
@@ -42,6 +48,10 @@ export class WorkerClient {
|
|
|
42
48
|
return this.#client.appVersion;
|
|
43
49
|
}
|
|
44
50
|
|
|
51
|
+
get env() {
|
|
52
|
+
return this.#env;
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
get accountIdentifier() {
|
|
46
56
|
return this.#client.accountIdentifier;
|
|
47
57
|
}
|
|
@@ -144,7 +154,7 @@ export class WorkerClient {
|
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
async getInboxIdByIdentifier(identifier: Identifier) {
|
|
147
|
-
return this.#client.
|
|
157
|
+
return this.#client.findInboxIdByIdentity(identifier);
|
|
148
158
|
}
|
|
149
159
|
|
|
150
160
|
signWithInstallationKey(signatureText: string) {
|
|
@@ -185,7 +195,45 @@ export class WorkerClient {
|
|
|
185
195
|
) as Promise<Map<string, KeyPackageStatus>>;
|
|
186
196
|
}
|
|
187
197
|
|
|
188
|
-
async sendSyncRequest() {
|
|
189
|
-
return this.#client.sendSyncRequest();
|
|
198
|
+
async sendSyncRequest(options: ArchiveOptions, serverUrl: string) {
|
|
199
|
+
return this.#client.device_sync().sendSyncRequest(options, serverUrl);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async sendSyncArchive(
|
|
203
|
+
options: ArchiveOptions,
|
|
204
|
+
serverUrl: string,
|
|
205
|
+
pin: string,
|
|
206
|
+
) {
|
|
207
|
+
return this.#client.device_sync().sendSyncArchive(options, serverUrl, pin);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async processSyncArchive(archivePin?: string | null) {
|
|
211
|
+
return this.#client.device_sync().processSyncArchive(archivePin);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
listAvailableArchives(daysCutoff: number): AvailableArchiveInfo[] {
|
|
215
|
+
return this.#client.device_sync().listAvailableArchives(BigInt(daysCutoff));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async createArchive(
|
|
219
|
+
opts: ArchiveOptions,
|
|
220
|
+
key: Uint8Array,
|
|
221
|
+
): Promise<Uint8Array> {
|
|
222
|
+
return this.#client.device_sync().createArchive(opts, key);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async importArchive(data: Uint8Array, key: Uint8Array) {
|
|
226
|
+
return this.#client.device_sync().importArchive(data, key);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async archiveMetadata(
|
|
230
|
+
data: Uint8Array,
|
|
231
|
+
key: Uint8Array,
|
|
232
|
+
): Promise<ArchiveMetadata> {
|
|
233
|
+
return this.#client.device_sync().archiveMetadata(data, key);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
async syncAllDeviceSyncGroups(): Promise<GroupSyncSummary> {
|
|
237
|
+
return this.#client.device_sync().syncAllDeviceSyncGroups();
|
|
190
238
|
}
|
|
191
239
|
}
|
|
@@ -153,19 +153,19 @@ export class WorkerConversation {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
async addMembersByIdentifiers(identifiers: Identifier[]) {
|
|
156
|
-
return this.#group.
|
|
156
|
+
return this.#group.addMembersByIdentity(identifiers);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
async addMembers(inboxIds: string[]) {
|
|
160
|
-
return this.#group.
|
|
160
|
+
return this.#group.addMembers(inboxIds);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
async removeMembersByIdentifiers(identifiers: Identifier[]) {
|
|
164
|
-
return this.#group.
|
|
164
|
+
return this.#group.removeMembersByIdentity(identifiers);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
async removeMembers(inboxIds: string[]) {
|
|
168
|
-
return this.#group.
|
|
168
|
+
return this.#group.removeMembers(inboxIds);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
async addAdmin(inboxId: string) {
|
package/src/constants.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pre-configured URLs for the XMTP network based on the environment
|
|
3
3
|
*
|
|
4
|
+
* @deprecated Use `createBackend()` instead.
|
|
4
5
|
* @constant
|
|
5
6
|
* @property {string} local - The local URL for the XMTP network
|
|
6
7
|
* @property {string} dev - The development URL for the XMTP network
|
|
@@ -24,4 +25,8 @@ export const HistorySyncUrls = {
|
|
|
24
25
|
local: "http://localhost:5558",
|
|
25
26
|
dev: "https://message-history.dev.ephemera.network",
|
|
26
27
|
production: "https://message-history.production.ephemera.network",
|
|
28
|
+
"testnet-staging": "https://message-history.dev.ephemera.network",
|
|
29
|
+
"testnet-dev": "https://message-history.dev.ephemera.network",
|
|
30
|
+
testnet: "https://message-history.dev.ephemera.network",
|
|
31
|
+
mainnet: "https://message-history.production.ephemera.network",
|
|
27
32
|
} as const;
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { Conversation } from "./Conversation";
|
|
|
5
5
|
export { Dm } from "./Dm";
|
|
6
6
|
export { Group } from "./Group";
|
|
7
7
|
export { DecodedMessage } from "./DecodedMessage";
|
|
8
|
+
export { createBackend } from "./utils/createBackend";
|
|
8
9
|
export { generateInboxId, getInboxIdForIdentifier } from "./utils/inboxId";
|
|
9
10
|
export { metadataFieldName } from "./utils/metadata";
|
|
10
11
|
export { ApiUrls, HistorySyncUrls } from "./constants";
|
|
@@ -16,7 +17,12 @@ export type {
|
|
|
16
17
|
Action,
|
|
17
18
|
Actions,
|
|
18
19
|
ApiStats,
|
|
20
|
+
ArchiveMetadata,
|
|
21
|
+
ArchiveOptions,
|
|
19
22
|
Attachment,
|
|
23
|
+
AvailableArchiveInfo,
|
|
24
|
+
Backend,
|
|
25
|
+
BackendBuilder,
|
|
20
26
|
Consent,
|
|
21
27
|
ConversationDebugInfo,
|
|
22
28
|
ConversationListItem,
|
|
@@ -50,7 +56,6 @@ export type {
|
|
|
50
56
|
Reaction,
|
|
51
57
|
ReadReceipt,
|
|
52
58
|
RemoteAttachment,
|
|
53
|
-
RemoteAttachmentInfo,
|
|
54
59
|
Reply,
|
|
55
60
|
SendMessageOpts,
|
|
56
61
|
SignatureRequestHandle,
|
|
@@ -62,6 +67,7 @@ export type {
|
|
|
62
67
|
} from "@xmtp/wasm-bindings";
|
|
63
68
|
export {
|
|
64
69
|
ActionStyle,
|
|
70
|
+
BackupElementSelectionOption,
|
|
65
71
|
ConsentEntityType,
|
|
66
72
|
ConsentState,
|
|
67
73
|
ContentType,
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ArchiveMetadata,
|
|
3
|
+
ArchiveOptions,
|
|
4
|
+
AvailableArchiveInfo,
|
|
5
|
+
GroupSyncSummary,
|
|
6
|
+
Identifier,
|
|
7
|
+
KeyPackageStatus,
|
|
8
|
+
} from "@xmtp/wasm-bindings";
|
|
2
9
|
import type { ClientOptions } from "@/types/options";
|
|
3
10
|
import type { SafeSigner } from "@/utils/signer";
|
|
4
11
|
|
|
@@ -8,6 +15,7 @@ export type ClientAction =
|
|
|
8
15
|
id: string;
|
|
9
16
|
result: {
|
|
10
17
|
appVersion: string;
|
|
18
|
+
env: string;
|
|
11
19
|
inboxId: string;
|
|
12
20
|
installationId: string;
|
|
13
21
|
installationIdBytes: Uint8Array;
|
|
@@ -216,5 +224,67 @@ export type ClientAction =
|
|
|
216
224
|
action: "client.sendSyncRequest";
|
|
217
225
|
id: string;
|
|
218
226
|
result: undefined;
|
|
227
|
+
data: {
|
|
228
|
+
options: ArchiveOptions;
|
|
229
|
+
serverUrl: string;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
| {
|
|
233
|
+
action: "client.sendSyncArchive";
|
|
234
|
+
id: string;
|
|
235
|
+
result: undefined;
|
|
236
|
+
data: {
|
|
237
|
+
options: ArchiveOptions;
|
|
238
|
+
serverUrl: string;
|
|
239
|
+
pin: string;
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
| {
|
|
243
|
+
action: "client.processSyncArchive";
|
|
244
|
+
id: string;
|
|
245
|
+
result: undefined;
|
|
246
|
+
data: {
|
|
247
|
+
archivePin?: string | null;
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
| {
|
|
251
|
+
action: "client.listAvailableArchives";
|
|
252
|
+
id: string;
|
|
253
|
+
result: AvailableArchiveInfo[];
|
|
254
|
+
data: {
|
|
255
|
+
daysCutoff: number;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
| {
|
|
259
|
+
action: "client.createArchive";
|
|
260
|
+
id: string;
|
|
261
|
+
result: Uint8Array;
|
|
262
|
+
data: {
|
|
263
|
+
opts: ArchiveOptions;
|
|
264
|
+
key: Uint8Array;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
| {
|
|
268
|
+
action: "client.importArchive";
|
|
269
|
+
id: string;
|
|
270
|
+
result: undefined;
|
|
271
|
+
data: {
|
|
272
|
+
data: Uint8Array;
|
|
273
|
+
key: Uint8Array;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
| {
|
|
277
|
+
action: "client.archiveMetadata";
|
|
278
|
+
id: string;
|
|
279
|
+
result: ArchiveMetadata;
|
|
280
|
+
data: {
|
|
281
|
+
data: Uint8Array;
|
|
282
|
+
key: Uint8Array;
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
| {
|
|
286
|
+
action: "client.syncAllDeviceSyncGroups";
|
|
287
|
+
id: string;
|
|
288
|
+
result: GroupSyncSummary;
|
|
219
289
|
data: undefined;
|
|
220
290
|
};
|