Skip to main content

Class: TOTPStrategy

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

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: src/auth/TOTPStrategy.ts:56

Parameters

options?

TOTPStrategyOptions = ...

Returns

TOTPStrategy

Properties

name

readonly name: string = "totp"

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

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: src/auth/TOTPStrategy.ts:60

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

Set to true to if authentication is required to pass, otherwise set to false.

Returns

Promise<AuthResult | undefined>

Implementation of

AuthStrategy.authenticate


authenticateSync()

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

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

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

Set to true to if authentication is required to pass, otherwise set to false.

Returns

AuthResult | undefined

Implementation of

AuthStrategy.authenticateSync


verify()

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

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

Parameters

payload

any

Returns

Promise<JWTUser | undefined>