Skip to main content

Class: TOTPStrategy

Defined in: auth/src/auth/TOTPStrategy.ts:74

Implements an authentication strategy that performs Time-Based One Time Password authentication. This strategy requires an existing user account to have already registered a TOTP secret that will be validated. The strategy does not implement how that secret is to be stored.

Implements​

  • AuthStrategy

Constructors​

Constructor​

new TOTPStrategy(options?): TOTPStrategy

Defined in: auth/src/auth/TOTPStrategy.ts:78

Parameters​

options?​

TOTPStrategyOptions = ...

Returns​

TOTPStrategy

Properties​

name​

readonly name: string = "totp"

Defined in: auth/src/auth/TOTPStrategy.ts:75

The unique name of the strategy used to register with the AuthMiddleware.

Implementation of​

AuthStrategy.name

Methods​

authenticate()​

authenticate(req, res, required?): Promise<AuthResult | undefined>

Defined in: auth/src/auth/TOTPStrategy.ts:82

Attempts to perform authentication with the given request data. If authentication was successful, returns an AuthResult containing the authentication details. If authentication fails and required is set to true throws an error, otherwise returns undefined.

Parameters​

req​

HttpRequest

The request containing data to attempt authentication with.

res​

HttpResponse

The response to use when writing back directly to the client.

required?​

boolean

Returns​

Promise<AuthResult | undefined>

Implementation of​

AuthStrategy.authenticate


authenticateSync()​

authenticateSync(req, res, required?): AuthResult | undefined

Defined in: auth/src/auth/TOTPStrategy.ts:110

Attempts to perform authentication with the given request data. If authentication was successful, returns an AuthResult containing the authentication details. If authentication fails and required is set to true throws an error, otherwise returns undefined.

This is the synchronous version of authenticate that performs blocking based authentication.

Parameters​

req​

HttpRequest

The request containing data to attempt authentication with.

res​

HttpResponse

The response to use when writing back directly to the client.

required?​

boolean

Returns​

AuthResult | undefined

Implementation of​

AuthStrategy.authenticateSync


verify()​

protected verify(payload, req?): Promise<JWTUser | undefined>

Defined in: auth/src/auth/TOTPStrategy.ts:114

Parameters​

payload​

any

req?​

HttpRequest

Returns​

Promise<JWTUser | undefined>