@idpass/data-collect-core / OtpAuthAdapter
Class: OtpAuthAdapter
Defined in: components/authentication/OtpAuthAdapter.ts:42
Authentication adapter that uses one-time passwords (OTP) sent to a phone number or email address. Designed for self-service access by beneficiaries who may not have traditional login credentials.
Flow:
- Call requestOtp(identifier) to send a 6-digit code
- Call verifyOtp(identifier, otp) to exchange the code for a JWT
- The JWT has scope "self-service" and is scoped to the beneficiary's entity
Implements
Constructors
Constructor
new OtpAuthAdapter(
storage,config):OtpAuthAdapter
Defined in: components/authentication/OtpAuthAdapter.ts:45
Parameters
storage
SingleAuthStorage | null
config
Returns
OtpAuthAdapter
Methods
requestOtp()
requestOtp(
identifier):Promise<{success:boolean;expiresIn:number; }>
Defined in: components/authentication/OtpAuthAdapter.ts:53
Request OTP to be sent to phone/email
Parameters
identifier
string
Returns
Promise<{ success: boolean; expiresIn: number; }>
verifyOtp()
verifyOtp(
identifier,otp):Promise<{username:string;token:string; }>
Defined in: components/authentication/OtpAuthAdapter.ts:69
Verify OTP and get token
Parameters
identifier
string
otp
string
Returns
Promise<{ username: string; token: string; }>
isAuthenticated()
isAuthenticated():
Promise<boolean>
Defined in: components/authentication/OtpAuthAdapter.ts:92
Check if currently authenticated
Returns
Promise<boolean>
Implementation of
validateToken()
validateToken(
token):Promise<boolean>
Defined in: components/authentication/OtpAuthAdapter.ts:104
Validate stored token
Parameters
token
string
Returns
Promise<boolean>
Implementation of
logout()
logout():
Promise<void>
Defined in: components/authentication/OtpAuthAdapter.ts:118
Returns
Promise<void>
Implementation of
initialize()
initialize():
Promise<void>
Defined in: components/authentication/OtpAuthAdapter.ts:124
Returns
Promise<void>
Implementation of
login()
login(
_credentials):Promise<{username:string;token:string; }>
Defined in: components/authentication/OtpAuthAdapter.ts:128
Parameters
_credentials
PasswordCredentials | TokenCredentials | null
Returns
Promise<{ username: string; token: string; }>
Implementation of
handleCallback()
handleCallback():
Promise<void>
Defined in: components/authentication/OtpAuthAdapter.ts:134
Returns
Promise<void>