UNPKG

@kiryano/etherealotp

Version:

A library for two-factor authentication using Twilio and Speakeasy.

33 lines (32 loc) 1.27 kB
import { TwilioConfig } from './config/TwilioConfig'; import { generateSecret } from './utils/TokenUtils'; export declare class TwoFactorAuth { private client; private fromNumber; constructor(config: TwilioConfig); /** * Generates a new TOTP secret. * @returns The generated secret. */ generateSecret(): ReturnType<typeof generateSecret>; /** * Generates a TOTP token based on a user's secret. * @param secret The user's TOTP secret. * @returns The generated token. */ generateToken(secret: string): string; /** * Verifies a user-provided TOTP token against their secret. * @param token The TOTP token to verify. * @param secret The user's TOTP secret. * @returns True if the token is valid, otherwise false. */ verifyToken(token: string, secret: string): boolean; /** * Sends an SMS message containing the TOTP token to a user's phone number. * @param phoneNumber The destination phone number, including country code. * @param message The message to send, typically containing the TOTP token. * @returns A promise resolved with the message sid if sending succeeds. */ sendSmsOTP(phoneNumber: string, message: string): Promise<string>; }