New Captcha Package added

This commit is contained in:
2026-07-25 13:38:18 +05:30
parent d0aded0392
commit 8b728a3e5d
157 changed files with 12092 additions and 1913 deletions
+36
View File
@@ -0,0 +1,36 @@
export interface CaptchaClientProviderDefinition {
name: "turnstile" | "recaptcha" | "hcaptcha";
scriptUrl: string;
responseField: string;
globalName: string;
}
export const captchaClientProviders: Record<string, CaptchaClientProviderDefinition> = {
turnstile: {
name: "turnstile",
scriptUrl: "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",
responseField: "cf-turnstile-response",
globalName: "turnstile",
},
recaptcha: {
name: "recaptcha",
scriptUrl: "https://www.google.com/recaptcha/api.js?render=explicit",
responseField: "g-recaptcha-response",
globalName: "grecaptcha",
},
hcaptcha: {
name: "hcaptcha",
scriptUrl: "https://js.hcaptcha.com/1/api.js?render=explicit",
responseField: "h-captcha-response",
globalName: "hcaptcha",
},
};
export function getCaptchaResponse(form: HTMLFormElement, field = "wrn-captcha-response"): string {
const value = new FormData(form).get(field);
return typeof value === "string" ? value : "";
}
export function resetCaptchaElement(element: Element): void {
element.dispatchEvent(new CustomEvent("captcha-reset", { bubbles: true }));
}