Skip to main content

Class: OTPStrategyOptions

Defined in: auth/src/auth/OTPStrategy.ts:15

Describes the configuration options that can be used to initialize OTPStrategy.

Constructors​

Constructor​

new OTPStrategyOptions(): OTPStrategyOptions

Returns​

OTPStrategyOptions

Properties​

allowDiscovery?​

optional allowDiscovery?: boolean

Defined in: auth/src/auth/OTPStrategy.ts:21

Set to true to enable discovery of a user's aliases. Default is false.

Be careful enabling this as it can be used as a way for an attacker to discover sensitive information.


headerKey​

headerKey: string = "authorization"

Defined in: auth/src/auth/OTPStrategy.ts:23

The name of the header to look for when performing header based authentication. Default value is Authorization.


headerScheme​

headerScheme: string = "otp"

Defined in: auth/src/auth/OTPStrategy.ts:25

The authorization scheme type when using header based authentication. Default value is otp.

Methods​

checkRateLimit()?​

optional checkRateLimit(identifier, req): Promise<void>

Defined in: auth/src/auth/OTPStrategy.ts:32

Optional hook invoked with the claimed identifier before a new OTP is generated/sent (phase 2), and again before the submitted token is verified (phase 3). Implementations should throw to reject the request once a caller-defined attempt threshold has been exceeded (see RateLimiter). A no-op when not provided.

Parameters​

identifier​

string

req​

HttpRequest

Returns​

Promise<void>


getContact()​

getContact(id, channel?): Promise<OTPContact | undefined>

Defined in: auth/src/auth/OTPStrategy.ts:42

Retrieves the user's contact information for a given id. NOTE: You must override this function when using this strategy.

Parameters​

id​

string

The unique id of the contact to retrieve.

channel?​

string

The delivery channel the client asked for in the challenge request's optional channel field (e.g. "whatsapp"), if any. An implementation must only honor a channel that is actually available for the contact, and return undefined (which sends nothing) or the contact's default channel otherwise - never a channel/contact other than the one requested for id.

Returns​

Promise<OTPContact | undefined>


getContacts()​

getContacts(id): Promise<OTPContact[]>

Defined in: auth/src/auth/OTPStrategy.ts:50

Retrieves the list of available contacts for the user with the given id. NOTE: You must override this function when using this strategy.

Parameters​

id​

string

The unique id of the user.

Returns​

Promise<OTPContact[]>


getUser()​

getUser(uid): Promise<JWTUser | undefined>

Defined in: auth/src/auth/OTPStrategy.ts:58

Retrieves the user data for the given unique identifier after authentication has completed successfully. NOTE: You must override this function when using this strategy.

Parameters​

uid​

string

Returns​

Promise<JWTUser | undefined>


notifyContact()​

notifyContact(contact, token): Promise<void>

Defined in: auth/src/auth/OTPStrategy.ts:67

Sends a notification to the specified contact with the provided OTP token. NOTE: You must override this function when using this strategy.

Parameters​

contact​

OTPContact

The contact to send the OTP token to.

token​

string

The OTP token to send to the user.

Returns​

Promise<void>