/** * OTP (One-Time Password) Authentication Provider * * Handles OTP-based authentication including: * - SMS OTP: One-time passwords sent via SMS * - Email OTP: One-time passwords sent via email * - Magic Links: Login links sent via email * * P1 Feature: OTP-based authentication is widely used for 2FA and passwordless flows */ import type { AuthProvider, AuthResult } from './index.js'; import { type OTPAuthConfig } from './index.js'; /** * OTP delivery method */ export type OTPDeliveryMethod = 'sms' | 'email' | 'magic_link'; /** * Generates a random OTP code * @param digits Number of digits (default 6) */ export declare function generateOTP(digits?: number): string; /** * Validates OTP format * @param code OTP code to validate * @param digits Expected number of digits */ export declare function validateOTPFormat(code: string, digits?: number): boolean; /** * Generates a magic link URL * @param baseUrl Base URL of the application * @param token Authentication token * @param email User email */ export declare function generateMagicLink(baseUrl: string, token: string, email: string): string; /** * Extracts token from magic link URL * @param url Magic link URL */ export declare function extractTokenFromMagicLink(url: string): string | null; /** * OTP Authentication Provider */ export declare class OTPProvider implements AuthProvider { readonly type: "otp"; private otpStates; private maxAttempts; authenticate(config: OTPAuthConfig): Promise; /** * Requests a new OTP to be sent */ requestOTP(config: OTPAuthConfig): Promise; /** * Verifies an OTP code */ verifyOTP(config: OTPAuthConfig): Promise; /** * Verifies a magic link */ verifyMagicLink(config: OTPAuthConfig): Promise; /** * Generates a session token */ private generateSessionToken; /** * Validates OTP configuration */ validate(config: OTPAuthConfig): Promise; /** * Clears cached OTP state */ clear(config: OTPAuthConfig): Promise; /** * Gets remaining time for OTP expiration */ getOTPTimeRemaining(destination: string): number | null; /** * Gets remaining attempts for OTP verification */ getRemainingAttempts(destination: string): number; /** * Sets maximum verification attempts */ setMaxAttempts(max: number): void; /** * Clears all OTP states */ clearAllStates(): void; private getCacheKey; } /** * Creates an OTP auth provider instance */ export declare function createOTPProvider(): OTPProvider;