mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
Use a different turnstile package
This commit is contained in:
parent
1e494f0e0d
commit
549ff4db0c
3 changed files with 24 additions and 18 deletions
|
@ -32,6 +32,7 @@
|
||||||
"@formkit/auto-animate": "^0.8.2",
|
"@formkit/auto-animate": "^0.8.2",
|
||||||
"@headlessui/react": "^1.7.19",
|
"@headlessui/react": "^1.7.19",
|
||||||
"@ladjs/country-language": "^1.0.3",
|
"@ladjs/country-language": "^1.0.3",
|
||||||
|
"@marsidev/react-turnstile": "^0.7.1",
|
||||||
"@movie-web/providers": "github:sussy-code/providers",
|
"@movie-web/providers": "github:sussy-code/providers",
|
||||||
"@noble/hashes": "^1.4.0",
|
"@noble/hashes": "^1.4.0",
|
||||||
"@plasmohq/messaging": "^0.6.2",
|
"@plasmohq/messaging": "^0.6.2",
|
||||||
|
|
|
@ -30,6 +30,9 @@ dependencies:
|
||||||
'@ladjs/country-language':
|
'@ladjs/country-language':
|
||||||
specifier: ^1.0.3
|
specifier: ^1.0.3
|
||||||
version: 1.0.3
|
version: 1.0.3
|
||||||
|
'@marsidev/react-turnstile':
|
||||||
|
specifier: ^0.7.1
|
||||||
|
version: 0.7.1(react-dom@18.3.1)(react@18.3.1)
|
||||||
'@movie-web/providers':
|
'@movie-web/providers':
|
||||||
specifier: github:sussy-code/providers
|
specifier: github:sussy-code/providers
|
||||||
version: github.com/sussy-code/providers/b04c921b5533e6f53a58c3a0406d90ad2f076c05
|
version: github.com/sussy-code/providers/b04c921b5533e6f53a58c3a0406d90ad2f076c05
|
||||||
|
@ -1957,6 +1960,16 @@ packages:
|
||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@marsidev/react-turnstile@0.7.1(react-dom@18.3.1)(react@18.3.1):
|
||||||
|
resolution: {integrity: sha512-SGa0cweJ2mP1RRi9oJJrlPpZHvlklLqu8tlXDLEbsQ/WExM8Ng9cr9439lZcnu8+tfeVpQIe8qFB1UU5uE+KlQ==}
|
||||||
|
peerDependencies:
|
||||||
|
react: '>=16.8.0'
|
||||||
|
react-dom: '>=16.8.0'
|
||||||
|
dependencies:
|
||||||
|
react: 18.3.1
|
||||||
|
react-dom: 18.3.1(react@18.3.1)
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@noble/hashes@1.4.0:
|
/@noble/hashes@1.4.0:
|
||||||
resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==}
|
resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
|
@ -7434,7 +7447,6 @@ packages:
|
||||||
resolution: {tarball: https://codeload.github.com/sussy-code/providers/tar.gz/b04c921b5533e6f53a58c3a0406d90ad2f076c05}
|
resolution: {tarball: https://codeload.github.com/sussy-code/providers/tar.gz/b04c921b5533e6f53a58c3a0406d90ad2f076c05}
|
||||||
name: '@movie-web/providers'
|
name: '@movie-web/providers'
|
||||||
version: 2.3.0
|
version: 2.3.0
|
||||||
prepare: true
|
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dependencies:
|
dependencies:
|
||||||
cheerio: 1.0.0-rc.12
|
cheerio: 1.0.0-rc.12
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import { Turnstile } from "@marsidev/react-turnstile";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import Turnstile, { BoundTurnstileObject } from "react-turnstile";
|
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { immer } from "zustand/middleware/immer";
|
import { immer } from "zustand/middleware/immer";
|
||||||
|
|
||||||
|
@ -10,16 +10,12 @@ import { conf } from "@/setup/config";
|
||||||
export interface TurnstileStore {
|
export interface TurnstileStore {
|
||||||
isInWidget: boolean;
|
isInWidget: boolean;
|
||||||
turnstiles: {
|
turnstiles: {
|
||||||
controls: BoundTurnstileObject;
|
controls: any;
|
||||||
isInPopout: boolean;
|
isInPopout: boolean;
|
||||||
id: string;
|
id: string;
|
||||||
}[];
|
}[];
|
||||||
cbs: ((token: string | null) => void)[];
|
cbs: ((token: string | null) => void)[];
|
||||||
setTurnstile(
|
setTurnstile(id: string, v: any, isInPopout: boolean): void;
|
||||||
id: string,
|
|
||||||
v: BoundTurnstileObject | null,
|
|
||||||
isInPopout: boolean,
|
|
||||||
): void;
|
|
||||||
getToken(): Promise<string>;
|
getToken(): Promise<string>;
|
||||||
processToken(token: string | null, widgetId: string): void;
|
processToken(token: string | null, widgetId: string): void;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +99,7 @@ export function TurnstileProvider(props: {
|
||||||
const setTurnstile = useTurnstileStore((s) => s.setTurnstile);
|
const setTurnstile = useTurnstileStore((s) => s.setTurnstile);
|
||||||
const processToken = useTurnstileStore((s) => s.processToken);
|
const processToken = useTurnstileStore((s) => s.processToken);
|
||||||
if (!siteKey) return null;
|
if (!siteKey) return null;
|
||||||
|
const widgetId = idRef.current || "sudo-turnstile";
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames({
|
className={classNames({
|
||||||
|
@ -110,19 +107,17 @@ export function TurnstileProvider(props: {
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Turnstile
|
<Turnstile
|
||||||
sitekey={siteKey}
|
siteKey={siteKey}
|
||||||
theme="light"
|
onLoadScript={() => {
|
||||||
onLoad={(widgetId, bound) => {
|
setTurnstile(widgetId, "sudo", !!props.isInPopout);
|
||||||
idRef.current = widgetId;
|
|
||||||
setTurnstile(widgetId, bound, !!props.isInPopout);
|
|
||||||
}}
|
}}
|
||||||
onError={() => {
|
onError={() => {
|
||||||
const id = idRef.current;
|
const id = "sudo-turnstile";
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
processToken(null, id);
|
processToken(null, id);
|
||||||
}}
|
}}
|
||||||
onVerify={(token) => {
|
onSuccess={(token) => {
|
||||||
const id = idRef.current;
|
const id = "sudo-turnstile";
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
processToken(token, id);
|
processToken(token, id);
|
||||||
props.onUpdateShow?.(false);
|
props.onUpdateShow?.(false);
|
||||||
|
@ -130,8 +125,6 @@ export function TurnstileProvider(props: {
|
||||||
onBeforeInteractive={() => {
|
onBeforeInteractive={() => {
|
||||||
props.onUpdateShow?.(true);
|
props.onUpdateShow?.(true);
|
||||||
}}
|
}}
|
||||||
refreshExpired="never"
|
|
||||||
execution="render"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue