27 lines
1.4 KiB
TypeScript
27 lines
1.4 KiB
TypeScript
/**
|
|
* Login captcha: Cloudflare Turnstile when configured, otherwise built-in math challenge.
|
|
*/
|
|
export type CaptchaProvider = 'turnstile' | 'math';
|
|
export type CaptchaChallengePayload = {
|
|
provider: CaptchaProvider;
|
|
siteKey?: string | null;
|
|
challengeToken?: string;
|
|
prompt?: string;
|
|
};
|
|
/** Turnstile is preferred when secret key is present. */
|
|
export declare function getCaptchaProvider(): CaptchaProvider;
|
|
export declare function getCaptchaSiteKey(): string | null;
|
|
/** Captcha is available whenever the admin threshold is positive (math fallback always works). */
|
|
export declare function isCaptchaAvailable(afterFailures: number): boolean;
|
|
/** @deprecated Prefer isCaptchaAvailable(afterFailures) — kept for call sites during transition. */
|
|
export declare function isCaptchaConfigured(): boolean;
|
|
export declare function createMathChallenge(): CaptchaChallengePayload;
|
|
export declare function createLoginCaptchaChallenge(): CaptchaChallengePayload;
|
|
/** Verifies login captcha using Turnstile or built-in math challenge. */
|
|
export declare function verifyCaptchaToken(token: string | undefined, remoteIp?: string): Promise<void>;
|
|
/** Attach a fresh challenge to captcha errors for the client. */
|
|
export declare function withCaptchaChallenge<T extends Error & {
|
|
code?: string;
|
|
captcha?: CaptchaChallengePayload;
|
|
}>(err: T): T;
|
|
//# sourceMappingURL=captchaService.d.ts.map
|