Skip to content

InteractiveAuth

Defined in: src/interactive-auth.ts:261

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.

opts

options object

T

the return type of the request when it is successful

new InteractiveAuth<T>(opts): InteractiveAuth<T>

Defined in: src/interactive-auth.ts:285

IOpts<T>

InteractiveAuth<T>

attemptAuth(): Promise<T>

Defined in: src/interactive-auth.ts:308

begin the authentication process.

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


getChosenFlow(): UIAFlow | null

Defined in: src/interactive-auth.ts:395

UIAFlow | null


getClientSecret(): string

Defined in: src/interactive-auth.ts:381

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

string

client secret


getEmailSid(): string | undefined

Defined in: src/interactive-auth.ts:463

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

string | undefined

The sid of the email auth session


getSessionId(): string | undefined

Defined in: src/interactive-auth.ts:371

get the auth session ID

string | undefined

session id


getStageParams(loginType): Record<string, any> | undefined

Defined in: src/interactive-auth.ts:391

get the server params for a given stage

string

login type for the stage

Record<string, any> | undefined

any parameters from the server for this stage


poll(): Promise<void>

Defined in: src/interactive-auth.ts:335

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

Promise<void>


requestEmailToken(): Promise<void>

Defined in: src/interactive-auth.ts:482

Requests a new email token and sets the email sid for the validation session

Promise<void>


setEmailSid(sid): void

Defined in: src/interactive-auth.ts:475

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

string

The sid for the email validation session

void


submitAuthDict(authData, background?): Promise<void>

Defined in: src/interactive-auth.ts:411

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.

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.

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.

Promise<void>