switch to cloudflare turnstile

This commit is contained in:
jake committed 2024-07-31 14:57:19 +00:00
1 parent 00165a5871
commit 5fe420913e
7 files changed
+59 -77

No files matched your search

+6 -21
View File
@@ -1,36 +1,21 @@
import HCaptcha from "@hcaptcha/react-hcaptcha";
import Turnstile from "react-turnstile";
import useHasMounted from "../../hooks/useHasMounted";
import useTheme from "../../hooks/useTheme";
import type { ComponentPropsWithoutRef } from "react";
export type CaptchaProps = {
size?: "normal" | "compact" | "invisible";
theme?: "light" | "dark";
export type CaptchaProps = Omit<ComponentPropsWithoutRef<typeof Turnstile>, "sitekey"> & {
className?: string;
// callbacks pulled verbatim from node_modules/@hcaptcha/react-hcaptcha/types/index.d.ts
/* eslint-disable @typescript-eslint/no-explicit-any */
onExpire?: () => any;
onOpen?: () => any;
onClose?: () => any;
onChalExpired?: () => any;
onError?: (event: string) => any;
onVerify?: (token: string, ekey: string) => any;
onLoad?: () => any;
/* eslint-enable @typescript-eslint/no-explicit-any */
};
const Captcha = ({ size = "normal", theme, className, ...rest }: CaptchaProps) => {
const Captcha = ({ theme, className, ...rest }: CaptchaProps) => {
const hasMounted = useHasMounted();
const { activeTheme } = useTheme();
return (
<div className={className}>
{hasMounted && (
<HCaptcha
sitekey={process.env.NEXT_PUBLIC_HCAPTCHA_SITE_KEY || "10000000-ffff-ffff-ffff-000000000001"}
reCaptchaCompat={false}
tabIndex={0}
size={size}
<Turnstile
sitekey={process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY || "1x00000000000000000000AA"}
theme={theme || (activeTheme === "dark" ? activeTheme : "light")}
{...rest}
/>