src/interactive-auth.js
function InteractiveAuth(opts) {
    this._matrixClient = opts.matrixClient;
    this._data = opts.authData || {};
    this._requestCallback = opts.doRequest;
    // startAuthStage included for backwards compat
    this._stateUpdatedCallback = opts.stateUpdated || opts.startAuthStage;
    this._completionDeferred = null;
    this._inputs = opts.inputs || {};

    if (opts.sessionId) this._data.session = opts.sessionId;
    this._clientSecret = opts.clientSecret || this._matrixClient.generateClientSecret();
    this._emailSid = opts.emailSid;
    if (this._emailSid === undefined) this._emailSid = null;

    this._currentStage = null;
}
function InteractiveAuth(opts) {
    this._matrixClient = opts.matrixClient;
    this._data = opts.authData || {};
    this._requestCallback = opts.doRequest;
    // startAuthStage included for backwards compat
    this._stateUpdatedCallback = opts.stateUpdated || opts.startAuthStage;
    this._completionDeferred = null;
    this._inputs = opts.inputs || {};

    if (opts.sessionId) this._data.session = opts.sessionId;
    this._clientSecret = opts.clientSecret || this._matrixClient.generateClientSecret();
    this._emailSid = opts.emailSid;
    if (this._emailSid === undefined) this._emailSid = null;

    this._currentStage = null;
}
function InteractiveAuth ( opts ) { this . _matrixClient = opts . matrixClient ; this . _data = opts . authData || { } ; this . _requestCallback = opts . doRequest ; // startAuthStage included for backwards compat this . _stateUpdatedCallback = opts . stateUpdated || opts . startAuthStage ; this . _completionDeferred = null ; this . _inputs = opts . inputs || { } ; if ( opts . sessionId ) this . _data . session = opts . sessionId ; this . _clientSecret = opts . clientSecret || this . _matrixClient . generateClientSecret ( ) ; this . _emailSid = opts . emailSid ; if ( this . _emailSid === undefined ) this . _emailSid = null ; this . _currentStage = null ; }
Abstracts the logic used to drive the interactive auth process.

<p>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.

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

@constructor
@alias module:interactive-auth

@param {object} opts  options object

@param {object} opts.matrixClient A matrix client to use for the auth process

@param {object?} opts.authData error response from the last request. If
null, a request will be made with no auth before starting.

@param {function(object?, bool?): module:client.Promise} opts.doRequest
called with the new auth dict to submit the request and a flag set
to true if this request is a background request. Should return a
promise which resolves to the successful response or rejects with a
MatrixError.

@param {function(string, object?)} opts.stateUpdated
called when the status of the UI auth changes, ie. when the state of
an auth stage changes of when the auth flow moves to a new stage.
The arguments are: the login type (eg m.login.password); and an object
which is either an error or an informational object specific to the
login type. If the 'errcode' key is defined, the object is an error,
and has keys:
errcode: string, the textual error code, eg. M_UNKNOWN
error: string, human readable string describing the error

The login type specific objects are as follows:
m.login.email.identity:
* emailSid: string, the sid of the active email auth session

@param {object?} opts.inputs Inputs provided by the user and used by different
stages of the auto process. The inputs provided will affect what flow is chosen.

@param {string?} opts.inputs.emailAddress An email address. If supplied, a flow
using email verification will be chosen.

@param {string?} opts.inputs.phoneCountry An ISO two letter country code. Gives
the country that opts.phoneNumber should be resolved relative to.

@param {string?} opts.inputs.phoneNumber A phone number. If supplied, a flow
using phone number validation will be chosen.

@param {string?} opts.sessionId If resuming an existing interactive auth session,
the sessionId of that session.

@param {string?} opts.clientSecret If resuming an existing interactive auth session,
the client secret for that session

@param {string?} opts.emailSid If returning from having completed m.login.email.identity
auth, the sid for the email verification session.
Abstracts the logic used to drive the interactive auth process .