userClient

The Client class is the main entry point for interacting with the Cryptalk network. It provides methods for creating and managing connections, registering identities, and performing actions.

Constructor

constructor(options?: ClientOptions): Initializes a new Cryptalk client instance. It is recommended to use the static methods Client.create or Client.build instead of calling the constructor directly.

Static Methods

  • static async create(signer: Signer, options?: ClientOptions): Promise<Client>: Creates a new client instance with a signer. Use this method to create a client for a user that has a wallet.

  • static async build(identifier: Identifier, options?: ClientOptions): Promise<Client>: Creates a new client instance with an identifier. Use this method for clients that do not have a signer.

Properties

  • options: ClientOptions: Gets the client options used to initialize the client.

  • signer: Signer | undefined: Gets the signer associated with this client, if any.

  • isReady: boolean: Gets whether the client has been initialized.

  • inboxId: string | undefined: Gets the inbox ID associated with this client.

  • accountIdentifier: Identifier: Gets the identifier for this client.

  • installationId: string: Gets the installation ID for this client.

  • installationIdBytes: Uint8Array: Gets the installation ID as a byte array.

  • conversations: Conversations: Gets the Conversations instance associated with this client.

  • preferences: Preferences: Gets the Preferences instance associated with this client.

Instance Methods

  • async init(identifier: Identifier): Promise<void>: Initializes the client with the provided identifier. This method is not intended to be called directly.

  • async unsafe_createInboxSignatureText(): Promise<string | undefined>: Creates signature text for creating a new inbox. This method should be used with caution, register is the preferred method.

  • async unsafe_addAccountSignatureText(newIdentifier: Identifier, allowInboxReassign?: boolean): Promise<string | undefined>: Creates signature text for adding a new account to the client's inbox. This method should be used with caution, unsafe_addAccount is the preferred method.

  • async unsafe_removeAccountSignatureText(identifier: Identifier): Promise<string | undefined>: Creates signature text for removing an account from the client's inbox. This method should be used with caution, removeAccount is the preferred method.

  • async unsafe_revokeAllOtherInstallationsSignatureText(): Promise<string | undefined>: Creates signature text for revoking all other installations of the client's inbox. This method should be used with caution, revokeAllOtherInstallations is the preferred method.

  • async unsafe_revokeInstallationsSignatureText(installationIds: Uint8Array[]): Promise<string | undefined>: Creates signature text for revoking specific installations of the client's inbox. This method should be used with caution, revokeInstallations is the preferred method.

  • async unsafe_changeRecoveryIdentifierSignatureText(identifier: Identifier): Promise<string | undefined>: Creates signature text for changing the recovery identifier. This method should be used with caution, changeRecoveryIdentifier is the preferred method.

  • async unsafe_addSignature(signatureType: SignatureRequestType, signatureText: string, signer: Signer): Promise<void>: Adds a signature for a specific request type. This method should be used with caution.

  • async unsafe_applySignatures(): Promise<void>: Applies all pending signatures. This method should be used with caution.

  • async register(): Promise<void>: Registers the client with the XMTP network.

  • async unsafe_addAccount(newAccountSigner: Signer, allowInboxReassign?: boolean): Promise<void>: Adds a new account to the client's inbox.

  • async removeAccount(accountIdentifier: Identifier): Promise<void>: Removes an account from the client's inbox.

  • async revokeAllOtherInstallations(): Promise<void>: Revokes all other installations of the client's inbox.

  • async revokeInstallations(installationIds: Uint8Array[]): Promise<void>: Revokes specific installations of the client's inbox.

  • async changeRecoveryIdentifier(identifier: Identifier): Promise<void>: Changes the recovery identifier for the client's inbox.

  • async isRegistered(): Promise<boolean>: Checks if the client is registered with the XMTP network.

  • async canMessage(identifiers: Identifier[]): Promise<Map<string, boolean>>: Checks if the client can message the specified identifiers.

  • static async canMessage(identifiers: Identifier[], env?: XmtpEnv): Promise<Map<string, boolean>>: Checks if the specified identifiers can be messaged without a client instance.

  • async findInboxIdByIdentifier(identifier: Identifier): Promise<string | undefined>: Finds the inbox ID for a given identifier.

  • codecFor<T = unknown>(contentType: ContentTypeId): ContentCodec<T> | undefined: Gets the codec for a given content type.

  • encodeContent(content: unknown, contentType: ContentTypeId): SafeEncodedContent: Encodes content for a given content type.

  • decodeContent<T = unknown>(message: SafeMessage, contentType: ContentTypeId): T | undefined: Decodes a message for a given content type.

  • close(): Terminates the underlying worker.

Last updated