Class Client<ContentTypes>

Type Parameters

  • ContentTypes extends DefaultContentTypes = DefaultContentTypes

Constructors

Properties

conversations: default<ContentTypes>
dbPath: string
debugInformation: default
environment: XMTPEnvironment
inboxId: string
installationId: InstallationId
preferences: default
publicIdentity: PublicIdentity
codecRegistry: {
    [key: string]: ContentCodec<unknown>;
}

Type declaration

Methods

  • Add this account to the current inboxId. Adding a identity already associated with an inboxId will cause the identity to lose access to that inbox.

    Parameters

    • newAccount: Signer | {}

      The signer of the new account to be added.

    • allowReassignInboxId: boolean = false

      A boolean specifying if the inboxId should be reassigned or not.

    Returns Promise<void>

  • Retrieves metadata from an existing encrypted archive.

    Parameters

    • path: string

      The file system path of the archive.

    • encryptionKey: Uint8Array<ArrayBufferLike>

      The encryption key used to decrypt the archive metadata.

    Returns Promise<ArchiveMetadata>

    A Promise that resolves to an ArchiveMetadata object.

    Throws

    Will reject if the archive is invalid or decryption fails.

  • Determines whether the current user can send messages to the specified peers.

    This method checks if the specified peers are using clients that are on the network.

    Parameters

    • identities: PublicIdentity[]

      The identities of the peers to check for messaging eligibility.

    Returns Promise<{
        [key: string]: boolean;
    }>

    A Promise resolving to a hash of identifiers and booleans if they can message on the network.

  • Creates a new archive at the specified path with encryption.

    Parameters

    • path: string

      The file system path where the archive should be created.

    • encryptionKey: Uint8Array<ArrayBufferLike>

      A binary encryption key (must match key used for decryption).

    • Optional opts: ArchiveOptions

      Optional archive configuration settings.

    Returns Promise<void>

    A Promise that resolves when the archive is successfully created.

    Throws

    Will reject if the operation fails or parameters are invalid.

  • Decrypts an encrypted local attachment.

    This asynchronous method takes an encrypted local attachment and decrypts it.

    Parameters

    Returns Promise<DecryptedLocalAttachment>

    A Promise that resolves to the decrypted local attachment.

    Throws

    Throws an error if the attachment is not a local file URI (must start with "file://").

  • Deletes the local database. This cannot be undone and these stored messages will not be refetched from the network.

    Returns Promise<any>

  • Drop the local database connection. This function is delicate and should be used with caution. App will error if database not properly reconnected. See: reconnectLocalDatabase()

    Returns Promise<any>

  • Encrypts a local attachment for secure transmission.

    This asynchronous method takes a file, checks if it's a local file URI, and encrypts the attachment for secure transmission.

    Parameters

    Returns Promise<EncryptedLocalAttachment>

    A Promise that resolves to the encrypted local attachment.

    Throws

    Throws an error if the attachment is not a local file URI (must start with "file://").

  • This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use create() instead. Adds the Ecdsa signature to the identity to be registered

    Parameters

    • signature: Uint8Array<ArrayBufferLike>

    Returns Promise<void>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the create and register flow independently otherwise use addWallet() instead. Gets the signature text for the add identity action

    Parameters

    Returns Promise<string>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use create() instead. Adds the SCW signature to the identity to be registered

    Parameters

    • signature: Uint8Array<ArrayBufferLike>
    • address: string
    • chainId: number
    • Optional blockNumber: number

    Returns Promise<void>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use addAccount(), removeAccount(), or revoke() instead. Applys the signature after adding signature

    Returns Promise<void>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use create() instead. Gets the signature text to be signed

    Returns Promise<string>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the create and register flow independently otherwise use create() instead. Registers the identity to the XMTP network

    Returns Promise<void>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use removeWallet() instead. Gets the signature text for the removed identity action

    Parameters

    Returns Promise<string>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use revokeAllOtherInstallations() instead. Gets the signature text for the revoke installations action

    Returns Promise<string>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use revokeInstallations() instead. Gets the signature text for the revoke installations action

    Parameters

    • installationIds: InstallationId[]

    Returns Promise<string>

  • Find the InboxId associated with this identity

    Parameters

    • identity: PublicIdentity

      The identity of the peer to check for inboxId.

    Returns Promise<undefined | string>

    A Promise resolving to the InboxId.

  • Imports an existing archive from disk using the provided encryption key.

    Parameters

    • path: string

      The file system path of the archive to import.

    • encryptionKey: Uint8Array<ArrayBufferLike>

      The encryption key that was used to secure the archive.

    Returns Promise<void>

    A Promise that resolves when the archive has been successfully imported.

    Throws

    Will reject if the archive cannot be found, is invalid, or the decryption fails.

  • Make a request for your inbox state.

    Parameters

    • refreshFromNetwork: boolean

      If you want to refresh the current state of in the inbox from the network or not.

    Returns Promise<InboxState>

    A Promise resolving to a InboxState.

  • Make a request for a list of inbox states.

    Parameters

    • refreshFromNetwork: boolean

      If you want to refresh the current state the inbox from the network or not.

    • inboxIds: string[]

      The inboxIds to get the associate inbox states for.

    Returns Promise<InboxState[]>

    A Promise resolving to a list of InboxState.

  • Reconnects the local database after being dropped.

    Returns Promise<any>

  • Remove this account from the current inboxId.

    Parameters

    • signer: Signer | {}

      The signer object used for authenticate the removal.

    • identityToRemove: PublicIdentity

      The identity of the signer you'd like to remove from the account.

    Returns Promise<void>

  • Revoke all other installations but the current one.

    Parameters

    • signer: null | Signer | {}

      The signer object used for authenticate the revoke.

    Returns Promise<void>

  • Revoke a list of installations.

    Parameters

    • signer: null | Signer | {}

      The signer object used for authenticate the revoke.

    • installationIds: InstallationId[]

      A list of installationIds to revoke access to the inboxId.

    Returns Promise<void>

  • Sign this message with the current installation key.

    Parameters

    • message: string

      The message to sign.

    Returns Promise<Uint8Array<ArrayBufferLike>>

    A Promise resolving to the signature bytes.

  • Verify the signature was signed with this clients installation key.

    Parameters

    • message: string

      The message that was signed.

    • signature: Uint8Array<ArrayBufferLike>

      The signature.

    Returns Promise<boolean>

    A Promise resolving to a boolean if the signature verified or not.

  • Activates persistent logging for libXMTP with specified configuration.

    Parameters

    • logLevel: LogLevel

      The minimum log level to record (e.g., debug, info, warn, error)

    • logRotation: LogRotation

      How often the log files will rotate into a new file

    • logMaxFiles: number

      Maximum number of log files to keep before rotation

    Returns void

    Promise that resolves when logging is activated

  • Builds a instance of the Client class using the provided identity and chainId if SCW.

    Type Parameters

    • ContentCodecs extends DefaultContentTypes = DefaultContentTypes

    Parameters

    • identity: PublicIdentity

      The identity of the account to build

    • options: ClientOptions & {
          codecs?: ContentCodecs;
      }
    • Optional inboxId: string

    Returns Promise<Client<ContentCodecs>>

    A Promise that resolves to a new Client instance.

    See XMTP Docs for more information.

  • Determines whether the current user can send messages to the specified peers.

    This method checks if the specified peers are using clients that are on the network.

    Parameters

    • env: XMTPEnvironment

      Environment to see if the identity is on the network for

    • identities: PublicIdentity[]

      The identities of the peers to check for messaging eligibility.

    Returns Promise<{
        [key: string]: boolean;
    }>

    A Promise resolving to a hash of identifiers and booleans if they can message on the network.

  • Clears all XMTP log files.

    Returns number

    Number of log files that were cleared

  • Creates a new instance of the Client class using the provided signer.

    Type Parameters

    • ContentCodecs extends DefaultContentTypes = DefaultContentTypes

    Parameters

    • signer: null | Signer | {}

      The signer object used for authentication and message signing.

    • options: ClientOptions & {
          codecs?: ContentCodecs;
      }

    Returns Promise<Client<ContentCodecs>>

    A Promise that resolves to a new Client instance.

    See XMTP Docs for more information.

  • Creates a new instance of the XMTP Client with a randomly generated address.

    Type Parameters

    • ContentTypes extends DefaultContentTypes

    Parameters

    Returns Promise<Client<ContentTypes>>

    A Promise that resolves to a new Client instance with a random address.

  • Deactivates the persistent log writer for libXMTP. This stops recording logs to persistent storage.

    Returns void

    Promise that resolves when logging is deactivated

  • Drop the client from memory. Use when you want to remove the client from memory and are done with it.

    Parameters

    • installationId: InstallationId

    Returns Promise<any>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use create() instead. Adds the Ecdsa signature to the identity to be registered

    Parameters

    • signatureType: "revokeInstallations"
    • signature: Uint8Array<ArrayBufferLike>

    Returns Promise<void>

  • This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use create() instead. Adds the SCW signature to the identity to be registered

    Parameters

    • signatureType: "revokeInstallations"
    • signature: Uint8Array<ArrayBufferLike>
    • address: string
    • chainId: number
    • Optional blockNumber: number

    Returns Promise<void>

  • ⚠️ This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use revokeInstallations() instead

    Applies the signature.

    Parameters

    • env: XMTPEnvironment

      Environment to apply the signature request

    • signatureType: "revokeInstallations"

    Returns Promise<void>

  • ⚠️ This function is delicate and should be used with caution. Creating an FfiClient without signing or registering will create a broken experience use create() instead

    Creates a new instance of the Client class using the provided identity.

    Type Parameters

    • ContentCodecs extends DefaultContentTypes = DefaultContentTypes

    Parameters

    Returns Promise<Client<ContentCodecs>>

    A Promise that resolves to a new Client instance.

  • ⚠️ This function is delicate and should be used with caution. Should only be used if trying to manage the signature flow independently otherwise use revokeInstallations() instead

    Revoke a list of installations. Revoking a installation will cause that installation to lose access to the inbox.

    Parameters

    Returns Promise<string>

  • Static method to determine the inboxId for the identity.

    Parameters

    Returns Promise<string>

  • Gets the file paths of all XMTP log files.

    Returns string[]

    Array of file paths to log files

  • Determines whether the current user can send messages to the specified peers.

    This method checks if the specified peers are using clients that are on the network.

    Parameters

    • env: XMTPEnvironment

      Environment to see if the identity is on the network for

    • inboxIds: string[]

      The inboxIds to get the associated inbox states for.

    Returns Promise<InboxState[]>

    A Promise resolving to a list of inbox states.

  • Checks if the persistent log writer is currently active. Note that persistent logging may be killed by OS when app is backgrounded. When app is foregrounded, logging will resume if isLogWriterActive is set to true.

    Returns any

    True if logging is active, false otherwise

  • Reads the contents of a specific XMTP log file.

    Parameters

    • filePath: string

      Path to the log file to read

    Returns Promise<string>

    Promise resolving to the contents of the log file

  • Revoke a list of installations. Revoking a installation will cause that installation to lose access to the inbox.

    Parameters

    • env: XMTPEnvironment

      Environment to revoke installation from.

    • signer: Signer | {}

      The signer of the recovery account to sign the revocation.

    • inboxId: string
    • installationIds: InstallationId[]

    Returns Promise<void>