import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"; import type { ConfirmEmailVerificationChallengeInput, ConfirmSmsVerificationChallengeInput, StartEmailVerificationChallengeInput, StartSmsVerificationChallengeInput } from "./validation.js"; export interface StorefrontVerificationServiceOptions { codeLength?: number; expiresInSeconds?: number; maxAttempts?: number; now?: () => Date; } export interface StorefrontVerificationDeliveryResult { id?: string; provider?: string; } export type StorefrontVerificationNotificationChannel = "email" | "sms" | (string & {}); export interface StorefrontVerificationNotificationPayload { to: string; channel: StorefrontVerificationNotificationChannel; provider?: string; template: string; data?: unknown; subject?: string; text?: string; } export interface StorefrontVerificationNotificationResult { id?: string; provider: string; } export interface StorefrontVerificationNotificationProvider { readonly name: string; readonly channels: ReadonlyArray; send(payload: StorefrontVerificationNotificationPayload): Promise; } export interface StorefrontVerificationEmailSendInput { email: string; code: string; purpose: string; locale?: string | null; expiresAt: Date; metadata?: Record | null; } export interface StorefrontVerificationSmsSendInput { phone: string; code: string; purpose: string; locale?: string | null; expiresAt: Date; metadata?: Record | null; } export interface StorefrontVerificationSenders { sendEmailChallenge?: (input: StorefrontVerificationEmailSendInput) => Promise; sendSmsChallenge?: (input: StorefrontVerificationSmsSendInput) => Promise; } export interface StorefrontVerificationProviderOptions { email?: { provider?: string; template?: string; subject?: string | ((input: StorefrontVerificationEmailSendInput) => string); }; sms?: { provider?: string; template?: string; }; } export declare class StorefrontVerificationError extends Error { readonly code: "sender_not_configured" | "challenge_not_found" | "challenge_expired" | "challenge_invalid" | "challenge_failed"; constructor(message: string, code: "sender_not_configured" | "challenge_not_found" | "challenge_expired" | "challenge_invalid" | "challenge_failed"); } export declare function createStorefrontVerificationSendersFromProviders(providers: ReadonlyArray, options?: StorefrontVerificationProviderOptions): StorefrontVerificationSenders; export declare function createStorefrontVerificationService(options?: StorefrontVerificationServiceOptions): { startEmailChallenge(db: PostgresJsDatabase, input: StartEmailVerificationChallengeInput, senders: StorefrontVerificationSenders): Promise<{ id: string; channel: "email" | "sms"; destination: string; purpose: string; status: "pending" | "expired" | "cancelled" | "failed" | "verified"; expiresAt: Date; verifiedAt: Date | null; createdAt: Date; updatedAt: Date; }>; startSmsChallenge(db: PostgresJsDatabase, input: StartSmsVerificationChallengeInput, senders: StorefrontVerificationSenders): Promise<{ id: string; channel: "email" | "sms"; destination: string; purpose: string; status: "pending" | "expired" | "cancelled" | "failed" | "verified"; expiresAt: Date; verifiedAt: Date | null; createdAt: Date; updatedAt: Date; }>; confirmEmailChallenge(db: PostgresJsDatabase, input: ConfirmEmailVerificationChallengeInput): Promise<{ id: string; channel: "email" | "sms"; destination: string; purpose: string; status: "pending" | "expired" | "cancelled" | "failed" | "verified"; expiresAt: Date; verifiedAt: Date | null; createdAt: Date; updatedAt: Date; }>; confirmSmsChallenge(db: PostgresJsDatabase, input: ConfirmSmsVerificationChallengeInput): Promise<{ id: string; channel: "email" | "sms"; destination: string; purpose: string; status: "pending" | "expired" | "cancelled" | "failed" | "verified"; expiresAt: Date; verifiedAt: Date | null; createdAt: Date; updatedAt: Date; }>; };