import { MailAdapter } from '@platform-modules/mail';

type OtpRecord = {
    codeHash: string;
    expiresAt: number;
    attempts: number;
};
type OtpStore = {
    get(key: string): Promise<OtpRecord | null>;
    set(key: string, record: OtpRecord): Promise<void>;
    delete(key: string): Promise<void>;
};
type OtpEmailConfig = {
    mail: MailAdapter;
    store: OtpStore;
    from: string;
    ttlMs?: number;
    maxAttempts?: number;
    rateLimit?: (email: string) => Promise<boolean>;
};
declare class OtpError extends Error {
}
declare class OtpExpiredError extends OtpError {
    readonly name = "OtpExpiredError";
}
declare class OtpAttemptsExceededError extends OtpError {
    readonly name = "OtpAttemptsExceededError";
}
declare function createOtpEmail(config: OtpEmailConfig): {
    issueAndSend(email: string, message: {
        subject: string;
        text: string;
    }): Promise<{
        expiresAt: number;
    }>;
    verify(email: string, code: string): Promise<boolean>;
};

export { OtpAttemptsExceededError, type OtpEmailConfig, OtpError, OtpExpiredError, type OtpRecord, type OtpStore, createOtpEmail };
