Class InteractiveAuth<T>

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.

options object

Type Parameters

  • T

    the return type of the request when it is successful

Constructors

Methods

  • begin the authentication process.

    Returns Promise<T>

    which resolves to the response on success, or rejects with the error on failure. Rejects with NoAuthFlowFoundError if no suitable authentication flow can be found

  • get the client secret used for validation sessions with the identity server.

    Returns string

    client secret

  • Gets the sid for the email validation session Specific to m.login.email.identity

    Returns undefined | string

    The sid of the email auth session

  • get the server params for a given stage

    Parameters

    • loginType: string

      login type for the stage

    Returns undefined | Record<string, any>

    any parameters from the server for this stage

  • Poll to check if the auth session or current stage has been completed out-of-band. If so, the attemptAuth promise will be resolved.

    Returns Promise<void>

  • Sets the sid for the email validation session This must be set in order to successfully poll for completion of the email validation. Specific to m.login.email.identity

    Parameters

    • sid: string

      The sid for the email validation session

    Returns void

  • 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

    • authData: AuthDict

      new auth dict to send to the server. Should include a type property denoting the login type, as well as any other params for that stage.

    • background: boolean = false

      If true, this request failing will not result in the attemptAuth promise being rejected. This can be set to true for requests that just poll to see if auth has been completed elsewhere.

    Returns Promise<void>