@kiryano/etherealotp
Version:
A library for two-factor authentication using Twilio and Speakeasy.
25 lines (24 loc) • 863 B
TypeScript
import * as speakeasy from 'speakeasy';
import 'twilio';
/**
* Generates a secret key for TOTP.
* @returns A generated secret key
*/
export declare function generateSecret(): speakeasy.GeneratedSecret;
/**
* Generates a TOTP token based on the secret.
* @param secret The user's TOTP secret
*/
export declare function generateToken(secret: string): string;
/**
* Verifies a TOTP token against the user's secret.
* @param token The TOTP token to verify
* @param secret The user's TOTP secret
*/
export declare function verifyToken(token: string, secret: string): boolean;
/**
* Sends an OTP via SMS using Twilio.
* @param phoneNumber The destination phone number, including country code
* @param message The message to send, typically "Your OTP is: [token]"
*/
export declare function sendSmsOTP(phoneNumber: string, message: string): Promise<void>;