import { Result } from "@badrap/result"; import type { CodeRepository, Validation } from "./repository.js"; import type { SMS } from "./SMS.js"; export declare class PhoneValidationError extends Error { } export interface ValidationRequest { phone: string; timeLimitInMinutes?: number; message?(code: string): string; } export interface PhoneValidationConfig { /** sms provider */ sms: SMS; /** when validation will be stored */ repository: CodeRepository; /** time to wait before resending the same code */ intervalInSeconds?: number; /** amount of time the code will be valid */ validationTimeLimitInMinutes?: number; /** number of times the code can be incorrect, default is 3 */ maxAttempts?: number; /** how the code will be generated */ generateCode?(): string; /** how the sms message will be formmated */ formatMessage?(code: string): string; } export declare class PhoneValidation { private readonly config; constructor(config: PhoneValidationConfig); requestValidation({ phone, timeLimitInMinutes, message, }: ValidationRequest): Promise; private isCodeExpired; getValidation(phone: string): Promise; verify(phone: string, code: string): Promise | Result.Err>; resend(phone: string): Promise | Result.Err>; }