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
Type Parameters
Section titled “Type Parameters”T
the return type of the request when it is successful
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new InteractiveAuth<
T>(opts):InteractiveAuth<T>
Defined in: src/interactive-auth.ts:285
Parameters
Section titled “Parameters”IOpts<T>
Returns
Section titled “Returns”InteractiveAuth<T>
Methods
Section titled “Methods”attemptAuth()
Section titled “attemptAuth()”attemptAuth():
Promise<T>
Defined in: src/interactive-auth.ts:308
begin the authentication process.
Returns
Section titled “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
getChosenFlow()
Section titled “getChosenFlow()”getChosenFlow():
UIAFlow|null
Defined in: src/interactive-auth.ts:395
Returns
Section titled “Returns”UIAFlow | null
getClientSecret()
Section titled “getClientSecret()”getClientSecret():
string
Defined in: src/interactive-auth.ts:381
get the client secret used for validation sessions with the identity server.
Returns
Section titled “Returns”string
client secret
getEmailSid()
Section titled “getEmailSid()”getEmailSid():
string|undefined
Defined in: src/interactive-auth.ts:463
Gets the sid for the email validation session Specific to m.login.email.identity
Returns
Section titled “Returns”string | undefined
The sid of the email auth session
getSessionId()
Section titled “getSessionId()”getSessionId():
string|undefined
Defined in: src/interactive-auth.ts:371
get the auth session ID
Returns
Section titled “Returns”string | undefined
session id
getStageParams()
Section titled “getStageParams()”getStageParams(
loginType):Record<string,any> |undefined
Defined in: src/interactive-auth.ts:391
get the server params for a given stage
Parameters
Section titled “Parameters”loginType
Section titled “loginType”string
login type for the stage
Returns
Section titled “Returns”Record<string, any> | undefined
any parameters from the server for this stage
poll()
Section titled “poll()”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.
Returns
Section titled “Returns”Promise<void>
requestEmailToken()
Section titled “requestEmailToken()”requestEmailToken():
Promise<void>
Defined in: src/interactive-auth.ts:482
Requests a new email token and sets the email sid for the validation session
Returns
Section titled “Returns”Promise<void>
setEmailSid()
Section titled “setEmailSid()”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
Parameters
Section titled “Parameters”string
The sid for the email validation session
Returns
Section titled “Returns”void
submitAuthDict()
Section titled “submitAuthDict()”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.
Parameters
Section titled “Parameters”authData
Section titled “authData”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?
Section titled “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
Section titled “Returns”Promise<void>