import { type Database } from "./database.js"; /** * Card verification gate (migration 1494, docs/signup-abuse-protection.md, * "Card verification"). While the deployment-wide switch is on, an unpaid * organization (Free or plan-less, never bought credit, no Stripe * subscription) needs a card its owner verified with a Stripe SetupIntent * before it starts a sandbox box or receives Free credit. Paid, Enterprise and * host-provisioned organizations are never gated. */ export type BillingCardVerification = { accountId: string; subjectId: string; provider: "stripe:test" | "stripe:live"; brand: string; last4: string; verifiedAt: Date; }; export type RecordCardVerificationInput = { accountId: string; subjectId: string; provider: "stripe:test" | "stripe:live"; customerId: string; paymentMethodId: string; setupIntentId: string; /** The SetupIntent's creation time: an older one never replaces a newer card. */ setupIntentCreatedAt: Date; fingerprint: string; brand: string; last4: string; }; /** Forget the cached switch (tests, and right after an operator change). */ export declare function resetCardVerificationGateCache(): void; /** Whether the gate is on. Fails open: a failed read (including a database * that predates migration 1494) leaves it off. */ export declare function readCardVerificationGate(db: Database): Promise; /** The organization's verified card, read inside its account RLS context. */ export declare function readCardVerificationInTransaction(tx: Database, accountId: string): Promise; export declare function readCardVerification(db: Database, accountId: string): Promise; /** Whether `subjectId` verified the card of this organization (read inside * its account RLS context). */ export declare function subjectVerifiedCardInTransaction(tx: Database, accountId: string, subjectId: string): Promise; /** Records (or replaces) the organization's verified card. Idempotent for the * same SetupIntent; a late webhook for an older SetupIntent leaves the newer * card in place (and returns it). */ export declare function recordCardVerification(db: Database, input: RecordCardVerificationInput): Promise;