Skip to content

Client

Defined in: sdks/js/browser-sdk/src/Client.ts:76

Client for interacting with the XMTP network

ContentTypes = ExtractCodecContentTypes

new Client<ContentTypes>(options?): Client<ContentTypes>

Defined in: sdks/js/browser-sdk/src/Client.ts:103

Creates a new XMTP client instance

This class is not intended to be initialized directly. Use Client.create or Client.build instead.

ClientOptions

Optional configuration for the client

Client<ContentTypes>

get accountIdentifier(): Identifier | undefined

Defined in: sdks/js/browser-sdk/src/Client.ts:297

Gets the account identifier for this client

Identifier | undefined


get appVersion(): string | undefined

Defined in: sdks/js/browser-sdk/src/Client.ts:346

Gets the app version used by the client

string | undefined


get conversations(): Conversations<ContentTypes>

Defined in: sdks/js/browser-sdk/src/Client.ts:318

Gets the conversations manager for this client

Conversations<ContentTypes>


get debugInformation(): DebugInformation

Defined in: sdks/js/browser-sdk/src/Client.ts:325

Gets the debug information helpers for this client

DebugInformation


get env(): string | undefined

Defined in: sdks/js/browser-sdk/src/Client.ts:353

Gets the label used for the default database file name

string | undefined


get inboxId(): string | undefined

Defined in: sdks/js/browser-sdk/src/Client.ts:290

Gets the inbox ID associated with this client

string | undefined


get installationId(): string | undefined

Defined in: sdks/js/browser-sdk/src/Client.ts:304

Gets the installation ID for this client

string | undefined


get installationIdBytes(): Uint8Array<ArrayBufferLike> | undefined

Defined in: sdks/js/browser-sdk/src/Client.ts:311

Gets the installation ID bytes for this client

Uint8Array<ArrayBufferLike> | undefined


get isReady(): boolean

Defined in: sdks/js/browser-sdk/src/Client.ts:283

Gets whether the client has been initialized

boolean


get libxmtpVersion(): string | undefined

Defined in: sdks/js/browser-sdk/src/Client.ts:339

Gets the version of libxmtp used in the bindings

string | undefined


get options(): ClientOptions | undefined

Defined in: sdks/js/browser-sdk/src/Client.ts:269

Gets the client options

ClientOptions | undefined


get preferences(): Preferences

Defined in: sdks/js/browser-sdk/src/Client.ts:332

Gets the preferences manager for this client

Preferences


get signer(): Signer | undefined

Defined in: sdks/js/browser-sdk/src/Client.ts:276

Gets the signer associated with this client

Signer | undefined

archiveMetadata(data, key): Promise<ArchiveMetadata>

Defined in: sdks/js/browser-sdk/src/Client.ts:927

Load the metadata for an archive to see what it contains

Uint8Array

The archive data as bytes

Uint8Array

Encryption key for the archive

Promise<ArchiveMetadata>

Promise that resolves with the archive metadata


canMessage(identifiers): Promise<Map<string, boolean>>

Defined in: sdks/js/browser-sdk/src/Client.ts:728

Checks if the client can message the specified identifiers

Identifier[]

The identifiers to check

Promise<Map<string, boolean>>

Whether the client can message the identifiers


changeRecoveryIdentifier(identifier): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:696

Changes the recovery identifier for the client’s inbox

Requires a signer, use Client.create to create a client with a signer.

Identifier

The new recovery identifier

Promise<void>

if no signer is available


close(): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:173

Shutdown the client

Promise<void>


createArchive(key, opts?): Promise<Uint8Array<ArrayBufferLike>>

Defined in: sdks/js/browser-sdk/src/Client.ts:894

Export archive data to bytes for later restoration

Uint8Array

Encryption key for the archive

ArchiveOptions

Archive options specifying what to include (defaults to consent and messages)

Promise<Uint8Array<ArrayBufferLike>>

Promise that resolves with the archive data as bytes


fetchInboxIdByIdentifier(identifier): Promise<string | undefined>

Defined in: sdks/js/browser-sdk/src/Client.ts:808

Fetches the inbox ID for a given identifier from the local database If not found, fetches from the network

Identifier

The identifier to look up

Promise<string | undefined>

The inbox ID, if found


fetchKeyPackageStatuses(installationIds): Promise<Map<string, KeyPackageStatus>>

Defined in: sdks/js/browser-sdk/src/Client.ts:868

Fetches the key package statuses from the network for the specified installation IDs

string[]

The installation IDs to check

Promise<Map<string, KeyPackageStatus>>

The key package statuses


fetchLatestInboxUpdatesCount(inboxIds): Promise<Map<string, number>>

Defined in: sdks/js/browser-sdk/src/Client.ts:738

Fetches the latest inbox updates count for the specified inbox IDs

string[]

The inbox IDs to check

Promise<Map<string, number>>

Map of inbox IDs to their updates count


fetchOwnInboxUpdatesCount(): Promise<number>

Defined in: sdks/js/browser-sdk/src/Client.ts:754

Fetches the latest inbox updates count for the client’s inbox

Promise<number>

The latest inbox updates count


importArchive(data, key): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:913

Import an archive from bytes

Uint8Array

The archive data as bytes

Uint8Array

Encryption key for the archive

Promise<void>

Promise that resolves when the archive is imported


init(identifier): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:145

Initializes the client with the provided identifier

This is not meant to be called directly. Use Client.create or Client.build instead.

Identifier

The identifier to initialize the client with

Promise<void>


isRegistered(): Promise<boolean>

Defined in: sdks/js/browser-sdk/src/Client.ts:718

Checks if the client is registered with the XMTP network

Promise<boolean>

Whether the client is registered


refreshServerConfiguration(): Promise<ServerConfiguration>

Defined in: sdks/js/browser-sdk/src/Client.ts:973

Fetches the backend configuration now and rewrites the stored copy (CFG-082)

The snapshot this client holds is unchanged; a new value takes effect at the next build.

Promise<ServerConfiguration>

The configuration that was fetched


register(): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:513

Registers the client with the XMTP network

Requires a signer, use Client.create to create a client with a signer.

Promise<void>

if no signer is available


removeAccount(identifier): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:597

Removes an account from the client’s inbox

Requires a signer, use Client.create to create a client with a signer.

Identifier

The identifier of the account to remove

Promise<void>

if no signer is available


revokeAllOtherInstallations(): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:621

Revokes all other installations of the client’s inbox

Requires a signer, use Client.create to create a client with a signer.

Promise<void>

if no signer is available


revokeInstallations(installationIds): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:651

Revokes specific installations of the client’s inbox

Requires a signer, use Client.create to create a client with a signer.

Uint8Array<ArrayBufferLike>[]

The installation IDs to revoke

Promise<void>

if no signer is available


serverConfiguration(): ServerConfiguration

Defined in: sdks/js/browser-sdk/src/Client.ts:957

Gets what the backend published about itself, as resolved when this client was built (CFG-080)

A worker action cannot be synchronous, so the snapshot is captured from the init result and answered from the main thread. A refresh rewrites the stored copy; it never changes this value.

ServerConfiguration

The configuration snapshot this client holds

if the client is not initialized


signWithInstallationKey(signatureText): Promise<Uint8Array<ArrayBufferLike>>

Defined in: sdks/js/browser-sdk/src/Client.ts:818

Signs a message with the installation key

string

The text to sign

Promise<Uint8Array<ArrayBufferLike>>

The signature


syncAllDeviceSyncGroups(): Promise<GroupSyncSummary>

Defined in: sdks/js/browser-sdk/src/Client.ts:942

Manually sync all device sync groups

Promise<GroupSyncSummary>

Promise that resolves with a summary of the sync operation


unsafe_addAccount(newAccountSigner, allowInboxReassign?): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:554

Adds a new account to the client inbox

WARNING: This function should be used with caution. Adding a wallet already associated with an inbox ID will cause the wallet to lose access to that inbox.

The allowInboxReassign parameter must be true to reassign an inbox already associated with a different account.

Requires a signer, use Client.create to create a client with a signer.

Signer

The signer for the new account

boolean = false

Whether to allow inbox reassignment

Promise<void>

if no signer is available

if allowInboxReassign is false

if the account is already associated with an inbox ID


unsafe_addAccountSignatureText(newIdentifier, allowInboxReassign?): Promise<{ signatureRequestId: string; signatureText: string; }>

Defined in: sdks/js/browser-sdk/src/Client.ts:388

Creates signature text for adding a new account to the client’s inbox

WARNING: This function should be used with caution. It is only provided for use in special cases where the provided workflows do not meet the requirements of an application.

It is highly recommended to use the unsafe_addAccount method instead.

Identifier

The identifier of the new account

boolean = false

Whether to allow inbox reassignment

Promise<{ signatureRequestId: string; signatureText: string; }>

The signature text and signature request ID

if allowInboxReassign is false


unsafe_applySignatureRequest(signer, signatureRequestId): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:496

Applies a signature request to the client

WARNING: This function should be used with caution. It is only provided for use in special cases where the provided workflows do not meet the requirements of an application.

It is highly recommended to use the register, unsafe_addAccount, removeAccount, revokeAllOtherInstallations, revokeInstallations, or changeRecoveryIdentifier method instead.

SafeSigner

The signer to use

string

The ID of the signature request to apply

Promise<void>


unsafe_changeRecoveryIdentifierSignatureText()

Section titled “unsafe_changeRecoveryIdentifierSignatureText()”

unsafe_changeRecoveryIdentifierSignatureText(identifier): Promise<{ signatureRequestId: string; signatureText: string; }>

Defined in: sdks/js/browser-sdk/src/Client.ts:475

Creates signature text for changing the recovery identifier for this client’s inbox

WARNING: This function should be used with caution. It is only provided for use in special cases where the provided workflows do not meet the requirements of an application.

It is highly recommended to use the changeRecoveryIdentifier method instead.

Identifier

The new recovery identifier

Promise<{ signatureRequestId: string; signatureText: string; }>

The signature text and signature request ID


unsafe_createInboxSignatureText(): Promise<{ signatureRequestId?: string; signatureText?: string; }>

Defined in: sdks/js/browser-sdk/src/Client.ts:368

Creates signature text for creating a new inbox

WARNING: This function should be used with caution. It is only provided for use in special cases where the provided workflows do not meet the requirements of an application.

It is highly recommended to use the register method instead.

Promise<{ signatureRequestId?: string; signatureText?: string; }>

The signature text and signature request ID


unsafe_removeAccountSignatureText(identifier): Promise<{ signatureRequestId: string; signatureText: string; }>

Defined in: sdks/js/browser-sdk/src/Client.ts:414

Creates signature text for removing an account from the client’s inbox

WARNING: This function should be used with caution. It is only provided for use in special cases where the provided workflows do not meet the requirements of an application.

It is highly recommended to use the removeAccount method instead.

Identifier

The identifier of the account to remove

Promise<{ signatureRequestId: string; signatureText: string; }>

The signature text and signature request ID


unsafe_revokeAllOtherInstallationsSignatureText()

Section titled “unsafe_revokeAllOtherInstallationsSignatureText()”

unsafe_revokeAllOtherInstallationsSignatureText(): Promise<{ signatureRequestId: string; signatureText: string | undefined; }>

Defined in: sdks/js/browser-sdk/src/Client.ts:433

Creates signature text for revoking all other installations of the client’s inbox

WARNING: This function should be used with caution. It is only provided for use in special cases where the provided workflows do not meet the requirements of an application.

It is highly recommended to use the revokeAllOtherInstallations method instead.

Promise<{ signatureRequestId: string; signatureText: string | undefined; }>

The signature text and signature request ID


unsafe_revokeInstallationsSignatureText(installationIds): Promise<{ signatureRequestId: string; signatureText: string; }>

Defined in: sdks/js/browser-sdk/src/Client.ts:455

Creates signature text for revoking specific installations of the client’s inbox

WARNING: This function should be used with caution. It is only provided for use in special cases where the provided workflows do not meet the requirements of an application.

It is highly recommended to use the revokeInstallations method instead.

Uint8Array<ArrayBufferLike>[]

The installation IDs to revoke

Promise<{ signatureRequestId: string; signatureText: string; }>

The signature text and signature request ID


verifySignedWithInstallationKey(signatureText, signatureBytes): Promise<boolean>

Defined in: sdks/js/browser-sdk/src/Client.ts:831

Verifies a signature was made with the installation key

string

The text that was signed

Uint8Array

The signature bytes to verify

Promise<boolean>

Whether the signature is valid


verifySignedWithPublicKey(signatureText, signatureBytes, publicKey): Promise<boolean>

Defined in: sdks/js/browser-sdk/src/Client.ts:849

Verifies a signature was made with a public key

string

The text that was signed

Uint8Array

The signature bytes to verify

Uint8Array

The public key to verify against

Promise<boolean>

Whether the signature is valid


static build<ContentCodecs>(identifier, options): Promise<Client<ExtractCodecContentTypes<ContentCodecs>>>

Defined in: sdks/js/browser-sdk/src/Client.ts:243

Creates a new client instance with an identifier

Clients created with this method must already be registered. Any methods called that require a signer will throw an error.

ContentCodecs extends ContentCodec[] = []

Identifier

The identifier to use

DistributiveOmit<ClientOptions, "codecs"> & object

Optional configuration for the client

Promise<Client<ExtractCodecContentTypes<ContentCodecs>>>

A new client instance


static canMessage(identifiers, optionsOrBackend): Promise<Map<string, boolean>>

Defined in: sdks/js/browser-sdk/src/Client.ts:759

Check identifiers with an explicit backend or network options.

Identifier[]

NetworkOptions | Backend

Promise<Map<string, boolean>>


static create<ContentCodecs>(signer, options): Promise<Client<ExtractCodecContentTypes<ContentCodecs>>>

Defined in: sdks/js/browser-sdk/src/Client.ts:208

Creates a new client instance with a signer

ContentCodecs extends ContentCodec[] = []

Signer

The signer to use for authentication

DistributiveOmit<ClientOptions, "codecs"> & object

Optional configuration for the client

Promise<Client<ExtractCodecContentTypes<ContentCodecs>>>

A new client instance


static fetchInboxStates(inboxIds, optionsOrBackend): Promise<InboxState[]>

Defined in: sdks/js/browser-sdk/src/Client.ts:680

Fetch inbox states with an explicit backend or network options.

string[]

NetworkOptions | Backend

Promise<InboxState[]>


static fetchLatestInboxUpdatesCount(inboxIds, optionsOrBackend): Promise<Map<string, number>>

Defined in: sdks/js/browser-sdk/src/Client.ts:776

Fetch inbox update counts with an explicit backend or network options.

string[]

NetworkOptions | Backend

Promise<Map<string, number>>


static fetchServerConfiguration(optionsOrUrl): Promise<ServerConfiguration>

Defined in: sdks/js/browser-sdk/src/Client.ts:990

Reads a backend’s configuration with no database, no client, and no credential (CFG-081)

string | NetworkOptions

The backend URL, or network options carrying it

Promise<ServerConfiguration>

The configuration the backend publishes


static revokeInstallations(signer, inboxId, installationIds, optionsOrBackend): Promise<void>

Defined in: sdks/js/browser-sdk/src/Client.ts:669

Revoke installations with an explicit backend or network options.

Signer

string

Uint8Array<ArrayBufferLike>[]

NetworkOptions | Backend

Promise<void>