Skip to main content

Abstract Class: BaseAuthOTPRoute<U, A, S>

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:33

Extended by​

Type Parameters​

U​

U extends User

A​

A extends Alias

S​

S extends Secret

Constructors​

Constructor​

new BaseAuthOTPRoute<U, A, S>(): BaseAuthOTPRoute<U, A, S>

Returns​

BaseAuthOTPRoute<U, A, S>

Properties​

aliasClass​

abstract protected aliasClass: any

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:34


aliasRepo?​

protected optional aliasRepo?: RepoUtils<A>

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:41


authMiddleware?​

protected optional authMiddleware?: AuthMiddleware

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:44


defaultScopes​

protected defaultScopes: string[] = []

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:50


jwtConfig?​

protected optional jwtConfig?: any

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:53


logger​

protected logger: any

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:47


messagingUtils?​

protected optional messagingUtils?: MessagingUtils

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:56


rateLimiter?​

protected optional rateLimiter?: RateLimiter

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:59


secretClass​

abstract protected secretClass: any

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:35


secretRepo?​

protected optional secretRepo?: RepoUtils<S>

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:61


template​

protected template: string = "login-otp"

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:64

The name of the messaging template to use for sending notifications.


tokenUtils?​

protected optional tokenUtils?: TokenUtils

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:67


userClass​

abstract protected userClass: any

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:36


userRepo?​

protected optional userRepo?: RepoUtils<U>

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:69


userUtils?​

protected optional userUtils?: UserUtils<U, A>

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:71

Methods​

authenticate()​

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

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:138

Authenticates the user using OTP and returns a JSON Web Token access token to be used with future API requests.

Parameters​

user​

JWTUser

req​

HttpRequest

res​

HttpResponse

Returns​

Promise<AuthResult | undefined>


convertAliasType()​

protected convertAliasType(type): OTPContactType

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:146

Parameters​

type​

AliasType

Returns​

OTPContactType


getContact()​

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

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:166

Retrieves the alias with the given unique id.

Parameters​

id​

string

The unique id of the alias to retrieve.

channel?​

string

The delivery channel the client asked for, if any. Only "whatsapp" is meaningful - it selects WhatsApp delivery, and is honored only for a verified phone alias while WhatsApp is configured (see isWhatsAppConfigured()), otherwise undefined is returned so nothing is sent. Any other value (or none) leaves the alias on its default channel (e-mail or SMS), exactly as before.

Returns​

Promise<OTPContact | undefined>

The alias if found, otherwise undefined.


getContacts()​

protected getContacts(id): Promise<OTPContact[]>

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:202

Retrieves all aliases for the user with the given id.

Parameters​

id​

string

The unique id of the user to lookup.

Returns​

Promise<OTPContact[]>


getUser()​

protected getUser(uid): Promise<JWTUser | undefined>

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:255

Retrieves the user with the given unique id.

Parameters​

uid​

string

The unique id of the user to retrieve.

Returns​

Promise<JWTUser | undefined>

The user if found, otherwise undefined.


initialize()​

protected initialize(): Promise<void>

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:77

Called on server startup to initialize the route with any defaults.

Returns​

Promise<void>


notifyContact()​

protected notifyContact(contact, totp): Promise<void>

Defined in: auth/src/routes/BaseAuthOTPRoute.ts:262

Parameters​

contact​

OTPContact

totp​

string

Returns​

Promise<void>