Skip to main content

Abstract Class: BaseRegistrationRoute<U, A>

Defined in: src/routes/BaseRegistrationRoute.ts:49

Provides a simple account registration flow that verifies an e-mail or phone number using OTP authentication before creating the account.

The registration flow:

  1. Client calls POST /start with either an e-mail address of phone number to verify.
  2. Sends an OTP code to the provided email or phone number in step 1.
  3. Client calls POST /verify with the email or phone number and OTP code.
  4. If OTP code is verified, creates a new User and Alias, returns a valid JWT token.

Extended by

Type Parameters

U

U extends User

A

A extends Alias

Constructors

Constructor

new BaseRegistrationRoute<U, A>(): BaseRegistrationRoute<U, A>

Returns

BaseRegistrationRoute<U, A>

Properties

aliasClass

abstract protected aliasClass: any

Defined in: src/routes/BaseRegistrationRoute.ts:50


aliasRepo?

protected optional aliasRepo?: RepoUtils<A>

Defined in: src/routes/BaseRegistrationRoute.ts:77


defaultScopes

protected defaultScopes: string[] = []

Defined in: src/routes/BaseRegistrationRoute.ts:57


jwtConfig?

protected optional jwtConfig?: any

Defined in: src/routes/BaseRegistrationRoute.ts:60


logger

protected logger: any

Defined in: src/routes/BaseRegistrationRoute.ts:63


messagingUtils?

protected optional messagingUtils?: MessagingUtils

Defined in: src/routes/BaseRegistrationRoute.ts:66


rateLimiter?

protected optional rateLimiter?: RateLimiter

Defined in: src/routes/BaseRegistrationRoute.ts:69


tokenUtils?

protected optional tokenUtils?: TokenUtils

Defined in: src/routes/BaseRegistrationRoute.ts:72


trustedProxies

protected trustedProxies: string[] = []

Defined in: src/routes/BaseRegistrationRoute.ts:75


userClass

abstract protected userClass: any

Defined in: src/routes/BaseRegistrationRoute.ts:51


userRepo?

protected optional userRepo?: RepoUtils<U>

Defined in: src/routes/BaseRegistrationRoute.ts:78

Methods

initialize()

protected initialize(): Promise<void>

Defined in: src/routes/BaseRegistrationRoute.ts:81

Returns

Promise<void>


start()

start(body, req): Promise<Record<string, never>>

Defined in: src/routes/BaseRegistrationRoute.ts:108

Sends a one-time verification code to the provided e-mail address or phone number.

Parameters

body

StartBody

req

HttpRequest

Returns

Promise<Record<string, never>>


verify()

verify(body, req, res): Promise<AuthResult>

Defined in: src/routes/BaseRegistrationRoute.ts:194

Verifies the one-time code sent by start(). On success, creates a new User and verified Alias and returns an JWT token.

Parameters

body

VerifyBody

req

HttpRequest

res

HttpResponse

Returns

Promise<AuthResult>