Class: module:interactive-auth

module:interactive-auth

new module:interactive-auth(opts)

Abstracts the logic used to drive the interactive auth process.

Components implementing an interactive auth flow should instantiate one of these, passing in the necessary callbacks to the constructor. They should then call attemptAuth, which will return a promise which will resolve or reject when the interactive-auth process completes.

Meanwhile, calls will be made to the startAuthStage and doRequest callbacks, and information gathered from the user can be submitted with submitAuthDict.

Parameters:
Name Type Description
opts object options object
Properties
Name Type Attributes Description
authData object <nullable>
error response from the last request. If null, a request will be made with no auth before starting.
doRequest function called with the new auth dict to submit the request. Should return a promise which resolves to the successful response or rejects with a MatrixError.
startAuthStage function called to ask the UI to start a particular auth stage. The arguments are: the login type (eg m.login.password); and (if the last request returned an error), an error object, with fields 'errcode' and 'error'.
Source:

Methods

attemptAuth() → {module:client.Promise}

begin the authentication process.
Source:
Returns:
which resolves to the response on success, or rejects with the error on failure.
Type
module:client.Promise

getSessionId() → {string}

get the auth session ID
Source:
Returns:
session id
Type
string

getStageParams(login) → (nullable) {object}

get the server params for a given stage
Parameters:
Name Type Description
login string type for the stage
Source:
Returns:
any parameters from the server for this stage
Type
object

submitAuthDict(authData)

submit a new auth dict and fire off the request. This will either make attemptAuth resolve/reject, or cause the startAuthStage callback to be called for a new stage.
Parameters:
Name Type Description
authData object new auth dict to send to the server. Should include a `type` propterty denoting the login type, as well as any other params for that stage.
Source: