Class

MatrixAuth

MatrixAuth(homeserverUrl)

Functions for interacting with Matrix prior to having an access token. Intended to be used for logging in/registering to get a MatrixClient instance. By design, this limits the options used to create the MatrixClient. To specify custom elements to the client, get the access token from the returned client and create a new MatrixClient instance. Due to the nature of Matrix, it is also recommended to use the homeserverUrl from the generated MatrixClient as it may be different from that given to the MatrixAuth class.
Constructor

# new MatrixAuth(homeserverUrl)

Creates a new MatrixAuth class for creating a MatrixClient
Parameters:
Name Type Description
homeserverUrl string The homeserver URL to authenticate against.

View Source MatrixAuth.ts, line 13

Classes

MatrixAuth
MatrixAuth

Methods

# createTemplateClient()

Generate a client with no access token so we can reuse the doRequest logic already written.

View Source MatrixAuth.ts, line 27

# async passwordLogin(username, password, deviceName) → {Promise.<MatrixClient>}

Performs simple password login with the homeserver. The caller is expected to confirm if the homeserver supports this login flow prior to invocation.
Parameters:
Name Type Description
username string The username (localpart or user ID) to log in with
password string The password for the account
deviceName string The name of the newly created device. Optional.

View Source MatrixAuth.ts, line 168

Resolves to a logged-in MatrixClient
Promise.<MatrixClient>

# async passwordRegister(localpart, password, deviceName) → {Promise.<MatrixClient>}

Performs simple registration using a password for the account. This will assume the server supports the m.login.password flow for registration, and will attempt to complete only that stage. The caller is expected to determine if the homeserver supports registration prior to invocation.
Parameters:
Name Type Description
localpart string The localpart (username) to register
password string The password to register with
deviceName string The name of the newly created device. Optional.

View Source MatrixAuth.ts, line 155

Resolves to a logged-in MatrixClient
Promise.<MatrixClient>