@prosopo/procaptcha-puzzle 2.10.8 → 2.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build$colon$cjs.log +53 -0
- package/.turbo/turbo-build$colon$tsc.log +56 -0
- package/.turbo/turbo-build.log +57 -57
- package/CHANGELOG.md +8 -0
- package/dist/cjs/components/ProcaptchaPuzzle.cjs +18 -0
- package/dist/cjs/components/ProcaptchaWidget.cjs +191 -0
- package/dist/cjs/components/PuzzleCanvas.cjs +275 -0
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/services/Manager.cjs +286 -0
- package/dist/components/ProcaptchaPuzzle.js +17 -5
- package/dist/components/ProcaptchaWidget.js +181 -144
- package/dist/components/PuzzleCanvas.js +258 -189
- package/dist/index.js +5 -3
- package/dist/services/Manager.js +270 -253
- package/package.json +4 -4
- package/src/components/ProcaptchaPuzzle.tsx +38 -0
- package/src/components/ProcaptchaWidget.tsx +261 -0
- package/src/components/PuzzleCanvas.tsx +336 -0
- package/src/index.ts +15 -0
- package/src/services/Manager.ts +454 -0
- package/tsconfig.cjs.json +44 -0
- package/tsconfig.json +45 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsconfig.types.json +9 -0
- package/.turbo/turbo-typecheck.log +0 -4
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
> @prosopo/procaptcha-puzzle@2.10.9 build:cjs
|
|
3
|
+
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
|
+
|
|
5
|
+
ViteCommonJSConfig: .
|
|
6
|
+
{
|
|
7
|
+
tsConfigPaths: [
|
|
8
|
+
'/home/runner/work/captcha/captcha/packages/api/tsconfig.json',
|
|
9
|
+
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
10
|
+
'/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
|
|
11
|
+
'/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
|
|
12
|
+
'/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
|
|
13
|
+
'/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
|
|
14
|
+
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
15
|
+
'/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json',
|
|
16
|
+
'/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json',
|
|
17
|
+
'/home/runner/work/captcha/captcha/packages/widget-skeleton/tsconfig.json',
|
|
18
|
+
'/home/runner/work/captcha/captcha/packages/account/tsconfig.json',
|
|
19
|
+
'/home/runner/work/captcha/captcha/packages/fingerprint/tsconfig.json',
|
|
20
|
+
'/home/runner/work/captcha/captcha/packages/fingerprintjs/tsconfig.json',
|
|
21
|
+
'/home/runner/work/captcha/captcha/packages/keyring/tsconfig.json'
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
{
|
|
25
|
+
externals: [
|
|
26
|
+
'@prosopo/api',
|
|
27
|
+
'@prosopo/types',
|
|
28
|
+
'@prosopo/locale',
|
|
29
|
+
'@prosopo/util',
|
|
30
|
+
'@prosopo/util-crypto',
|
|
31
|
+
'@prosopo/common',
|
|
32
|
+
'@prosopo/logger',
|
|
33
|
+
'@prosopo/procaptcha-common',
|
|
34
|
+
'@prosopo/load-balancer',
|
|
35
|
+
'@prosopo/widget-skeleton',
|
|
36
|
+
'@prosopo/account',
|
|
37
|
+
'@prosopo/fingerprint',
|
|
38
|
+
'@prosopo/fingerprintjs',
|
|
39
|
+
'@prosopo/keyring'
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
[36mvite v6.4.1 [32mbuilding SSR bundle for production...[36m[39m
|
|
43
|
+
Bundle build started
|
|
44
|
+
transforming...
|
|
45
|
+
Build end
|
|
46
|
+
[32m✓[39m 5 modules transformed.
|
|
47
|
+
rendering chunks...
|
|
48
|
+
[2mdist/cjs/[22m[36mindex.cjs [39m[1m[2m 0.27 kB[22m[1m[22m
|
|
49
|
+
[2mdist/cjs/[22m[36mcomponents/ProcaptchaPuzzle.cjs [39m[1m[2m 0.83 kB[22m[1m[22m
|
|
50
|
+
[2mdist/cjs/[22m[36mcomponents/ProcaptchaWidget.cjs [39m[1m[2m 6.52 kB[22m[1m[22m
|
|
51
|
+
[2mdist/cjs/[22m[36mcomponents/PuzzleCanvas.cjs [39m[1m[2m10.09 kB[22m[1m[22m
|
|
52
|
+
[2mdist/cjs/[22m[36mservices/Manager.cjs [39m[1m[2m10.11 kB[22m[1m[22m
|
|
53
|
+
[32m✓ built in 182ms[39m
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
> @prosopo/procaptcha-puzzle@2.10.9 build:tsc
|
|
3
|
+
> tsc --build --verbose
|
|
4
|
+
|
|
5
|
+
10:13:40 AM - Projects in this build:
|
|
6
|
+
* ../../dev/config/tsconfig.json
|
|
7
|
+
* ../locale/tsconfig.json
|
|
8
|
+
* ../util/tsconfig.json
|
|
9
|
+
* ../util-crypto/tsconfig.json
|
|
10
|
+
* ../types/tsconfig.json
|
|
11
|
+
* ../api/tsconfig.json
|
|
12
|
+
* ../logger/tsconfig.json
|
|
13
|
+
* ../common/tsconfig.json
|
|
14
|
+
* ../load-balancer/tsconfig.json
|
|
15
|
+
* ../widget-skeleton/tsconfig.json
|
|
16
|
+
* ../fingerprintjs/tsconfig.json
|
|
17
|
+
* ../fingerprint/tsconfig.json
|
|
18
|
+
* ../keyring/tsconfig.json
|
|
19
|
+
* ../account/tsconfig.json
|
|
20
|
+
* ../procaptcha-common/tsconfig.json
|
|
21
|
+
* tsconfig.json
|
|
22
|
+
|
|
23
|
+
10:13:40 AM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
24
|
+
|
|
25
|
+
10:13:40 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/util.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
26
|
+
|
|
27
|
+
10:13:40 AM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
28
|
+
|
|
29
|
+
10:13:40 AM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
|
|
30
|
+
|
|
31
|
+
10:13:40 AM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/procaptcha/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
32
|
+
|
|
33
|
+
10:13:40 AM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
34
|
+
|
|
35
|
+
10:13:40 AM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
36
|
+
|
|
37
|
+
10:13:40 AM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
38
|
+
|
|
39
|
+
10:13:40 AM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/balancer.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
|
|
40
|
+
|
|
41
|
+
10:13:40 AM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/webComponent/createWidget.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
|
|
42
|
+
|
|
43
|
+
10:13:40 AM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
|
|
44
|
+
|
|
45
|
+
10:13:40 AM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
|
|
46
|
+
|
|
47
|
+
10:13:40 AM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/index.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
|
|
48
|
+
|
|
49
|
+
10:13:40 AM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
50
|
+
|
|
51
|
+
10:13:40 AM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/tests/defaultEvents.test.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
|
|
52
|
+
|
|
53
|
+
10:13:40 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
54
|
+
|
|
55
|
+
10:13:40 AM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-puzzle/tsconfig.json'...
|
|
56
|
+
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
[
|
|
51
|
-
|
|
52
|
-
[2mdist/[22m[
|
|
53
|
-
[2mdist/[22m[36mcomponents/
|
|
54
|
-
[2mdist/[22m[
|
|
55
|
-
[2mdist/[22m[36mcomponents/PuzzleCanvas.js [39m[1m[2m9.81 kB[22m[1m[22m
|
|
56
|
-
[
|
|
57
|
-
|
|
1
|
+
|
|
2
|
+
> @prosopo/procaptcha-puzzle@2.10.9 build
|
|
3
|
+
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> @prosopo/procaptcha-puzzle@2.10.9 build:cross-env
|
|
7
|
+
> vite build --config vite.esm.config.ts --mode production
|
|
8
|
+
|
|
9
|
+
ViteEsmConfig: .
|
|
10
|
+
{
|
|
11
|
+
tsConfigPaths: [
|
|
12
|
+
'/home/runner/work/captcha/captcha/packages/api/tsconfig.json',
|
|
13
|
+
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
14
|
+
'/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
|
|
15
|
+
'/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
|
|
16
|
+
'/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
|
|
17
|
+
'/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
|
|
18
|
+
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
19
|
+
'/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json',
|
|
20
|
+
'/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json',
|
|
21
|
+
'/home/runner/work/captcha/captcha/packages/widget-skeleton/tsconfig.json',
|
|
22
|
+
'/home/runner/work/captcha/captcha/packages/account/tsconfig.json',
|
|
23
|
+
'/home/runner/work/captcha/captcha/packages/fingerprint/tsconfig.json',
|
|
24
|
+
'/home/runner/work/captcha/captcha/packages/fingerprintjs/tsconfig.json',
|
|
25
|
+
'/home/runner/work/captcha/captcha/packages/keyring/tsconfig.json'
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
{
|
|
29
|
+
externals: [
|
|
30
|
+
'@prosopo/api',
|
|
31
|
+
'@prosopo/types',
|
|
32
|
+
'@prosopo/locale',
|
|
33
|
+
'@prosopo/util',
|
|
34
|
+
'@prosopo/util-crypto',
|
|
35
|
+
'@prosopo/common',
|
|
36
|
+
'@prosopo/logger',
|
|
37
|
+
'@prosopo/procaptcha-common',
|
|
38
|
+
'@prosopo/load-balancer',
|
|
39
|
+
'@prosopo/widget-skeleton',
|
|
40
|
+
'@prosopo/account',
|
|
41
|
+
'@prosopo/fingerprint',
|
|
42
|
+
'@prosopo/fingerprintjs',
|
|
43
|
+
'@prosopo/keyring'
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
[36mvite v6.4.1 [32mbuilding SSR bundle for production...[36m[39m
|
|
47
|
+
Bundle build started
|
|
48
|
+
transforming...
|
|
49
|
+
Build end
|
|
50
|
+
[32m✓[39m 5 modules transformed.
|
|
51
|
+
rendering chunks...
|
|
52
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m0.14 kB[22m[1m[22m
|
|
53
|
+
[2mdist/[22m[36mcomponents/ProcaptchaPuzzle.js [39m[1m[2m0.46 kB[22m[1m[22m
|
|
54
|
+
[2mdist/[22m[36mcomponents/ProcaptchaWidget.js [39m[1m[2m6.34 kB[22m[1m[22m
|
|
55
|
+
[2mdist/[22m[36mcomponents/PuzzleCanvas.js [39m[1m[2m9.81 kB[22m[1m[22m
|
|
56
|
+
[2mdist/[22m[36mservices/Manager.js [39m[1m[2m9.96 kB[22m[1m[22m
|
|
57
|
+
[32m✓ built in 250ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const _interopNamespaceDefaultOnly = (e) => Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: "Module" }));
|
|
6
|
+
const ProcaptchaWidget = react.lazy(
|
|
7
|
+
async () => Promise.resolve().then(() => /* @__PURE__ */ _interopNamespaceDefaultOnly(require("./ProcaptchaWidget.cjs")))
|
|
8
|
+
);
|
|
9
|
+
const ProcaptchaPuzzle = (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10
|
+
ProcaptchaWidget,
|
|
11
|
+
{
|
|
12
|
+
config: props.config,
|
|
13
|
+
callbacks: props.callbacks,
|
|
14
|
+
frictionlessState: props.frictionlessState,
|
|
15
|
+
i18n: props.i18n
|
|
16
|
+
}
|
|
17
|
+
) });
|
|
18
|
+
exports.ProcaptchaPuzzle = ProcaptchaPuzzle;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
3
|
+
const locale = require("@prosopo/locale");
|
|
4
|
+
const procaptchaCommon = require("@prosopo/procaptcha-common");
|
|
5
|
+
const types = require("@prosopo/types");
|
|
6
|
+
const widgetSkeleton = require("@prosopo/widget-skeleton");
|
|
7
|
+
const react = require("react");
|
|
8
|
+
const Manager = require("../services/Manager.cjs");
|
|
9
|
+
const PuzzleCanvas = require("./PuzzleCanvas.cjs");
|
|
10
|
+
const PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
|
|
11
|
+
const Procaptcha = (props) => {
|
|
12
|
+
const { t, ready: isTranslationReady } = locale.useTranslation();
|
|
13
|
+
const config = props.config;
|
|
14
|
+
const i18n = props.i18n;
|
|
15
|
+
const theme = "light" === config.theme ? widgetSkeleton.lightTheme : widgetSkeleton.darkTheme;
|
|
16
|
+
const frictionlessState = props.frictionlessState;
|
|
17
|
+
const callbacks = props.callbacks || {};
|
|
18
|
+
const [state, _updateState] = procaptchaCommon.useProcaptcha(react.useState, react.useRef);
|
|
19
|
+
const [loading, setLoading] = react.useState(false);
|
|
20
|
+
const [puzzlePhase, setPuzzlePhase] = react.useState("checkbox");
|
|
21
|
+
const [challengeData, setChallengeData] = react.useState(null);
|
|
22
|
+
const [showRetry, setShowRetry] = react.useState(false);
|
|
23
|
+
const updateState = procaptchaCommon.buildUpdateState(state, _updateState);
|
|
24
|
+
const hpRef = react.useRef(null);
|
|
25
|
+
const manager = react.useRef(
|
|
26
|
+
Manager.Manager(
|
|
27
|
+
config,
|
|
28
|
+
state,
|
|
29
|
+
updateState,
|
|
30
|
+
callbacks,
|
|
31
|
+
frictionlessState,
|
|
32
|
+
() => hpRef.current?.value || void 0
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
react.useEffect(() => {
|
|
36
|
+
if (config.language) {
|
|
37
|
+
if (i18n) {
|
|
38
|
+
if (i18n.language !== config.language) {
|
|
39
|
+
i18n.changeLanguage(config.language).then((r) => r);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
locale.loadI18next(false).then((i18n2) => {
|
|
43
|
+
if (i18n2.language !== config.language)
|
|
44
|
+
i18n2.changeLanguage(config.language).then((r) => r);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, [i18n, config.language]);
|
|
49
|
+
react.useEffect(() => {
|
|
50
|
+
if (!state.error) return void 0;
|
|
51
|
+
setLoading(false);
|
|
52
|
+
setPuzzlePhase("checkbox");
|
|
53
|
+
setChallengeData(null);
|
|
54
|
+
setShowRetry(false);
|
|
55
|
+
if (state.error.key === "CAPTCHA.NO_SESSION_FOUND" && frictionlessState) {
|
|
56
|
+
const timer = setTimeout(() => {
|
|
57
|
+
frictionlessState.restart();
|
|
58
|
+
}, 100);
|
|
59
|
+
return () => clearTimeout(timer);
|
|
60
|
+
}
|
|
61
|
+
return void 0;
|
|
62
|
+
}, [state.error, frictionlessState]);
|
|
63
|
+
react.useEffect(() => {
|
|
64
|
+
if (config.mode === types.ModeEnum.invisible) {
|
|
65
|
+
const handleExecuteEvent = async () => {
|
|
66
|
+
if (loading) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setLoading(true);
|
|
70
|
+
setShowRetry(false);
|
|
71
|
+
try {
|
|
72
|
+
const challenge = await manager.current.start();
|
|
73
|
+
if (challenge) {
|
|
74
|
+
setChallengeData(challenge);
|
|
75
|
+
setPuzzlePhase("dragging");
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
callbacks.onError?.(
|
|
79
|
+
error instanceof Error ? error : new Error(String(error))
|
|
80
|
+
);
|
|
81
|
+
} finally {
|
|
82
|
+
setLoading(false);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, handleExecuteEvent);
|
|
86
|
+
return () => {
|
|
87
|
+
document.removeEventListener(
|
|
88
|
+
PROCAPTCHA_EXECUTE_EVENT,
|
|
89
|
+
handleExecuteEvent
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return () => {
|
|
94
|
+
};
|
|
95
|
+
}, [config.mode, callbacks.onError, loading]);
|
|
96
|
+
const handlePuzzleComplete = react.useCallback(
|
|
97
|
+
async (finalX, finalY, puzzleEvents) => {
|
|
98
|
+
setPuzzlePhase("submitting");
|
|
99
|
+
let verified = false;
|
|
100
|
+
try {
|
|
101
|
+
verified = await manager.current.submitSolution(
|
|
102
|
+
finalX,
|
|
103
|
+
finalY,
|
|
104
|
+
puzzleEvents
|
|
105
|
+
);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
callbacks.onError?.(
|
|
108
|
+
error instanceof Error ? error : new Error(String(error))
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (verified) {
|
|
112
|
+
setPuzzlePhase("checkbox");
|
|
113
|
+
setChallengeData(null);
|
|
114
|
+
setShowRetry(false);
|
|
115
|
+
setLoading(false);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
setShowRetry(true);
|
|
119
|
+
setPuzzlePhase("dragging");
|
|
120
|
+
try {
|
|
121
|
+
const newChallenge = await manager.current.start();
|
|
122
|
+
if (newChallenge) {
|
|
123
|
+
setChallengeData(newChallenge);
|
|
124
|
+
} else {
|
|
125
|
+
setPuzzlePhase("checkbox");
|
|
126
|
+
setChallengeData(null);
|
|
127
|
+
setShowRetry(false);
|
|
128
|
+
}
|
|
129
|
+
} catch {
|
|
130
|
+
setPuzzlePhase("checkbox");
|
|
131
|
+
setChallengeData(null);
|
|
132
|
+
setShowRetry(false);
|
|
133
|
+
}
|
|
134
|
+
setLoading(false);
|
|
135
|
+
},
|
|
136
|
+
[callbacks.onError]
|
|
137
|
+
);
|
|
138
|
+
const isInvisible = config.mode === types.ModeEnum.invisible;
|
|
139
|
+
const showPuzzleOverlay = (puzzlePhase === "dragging" || puzzlePhase === "submitting") && challengeData;
|
|
140
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
141
|
+
frictionlessState?.hp && /* @__PURE__ */ jsxRuntime.jsx(procaptchaCommon.Honeypot, { ref: hpRef, encodedQuestion: frictionlessState.hp }),
|
|
142
|
+
showPuzzleOverlay && /* @__PURE__ */ jsxRuntime.jsx(
|
|
143
|
+
PuzzleCanvas.PuzzleCanvas,
|
|
144
|
+
{
|
|
145
|
+
originX: challengeData.originX,
|
|
146
|
+
originY: challengeData.originY,
|
|
147
|
+
targetX: challengeData.targetX,
|
|
148
|
+
targetY: challengeData.targetY,
|
|
149
|
+
onComplete: handlePuzzleComplete,
|
|
150
|
+
showRetry,
|
|
151
|
+
submitting: puzzlePhase === "submitting"
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
!isInvisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
155
|
+
procaptchaCommon.Checkbox,
|
|
156
|
+
{
|
|
157
|
+
checked: state.isHuman,
|
|
158
|
+
theme,
|
|
159
|
+
onChange: async (event) => {
|
|
160
|
+
if (loading) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
setLoading(true);
|
|
164
|
+
setShowRetry(false);
|
|
165
|
+
let x = 0;
|
|
166
|
+
let y = 0;
|
|
167
|
+
const mouseOrTouchEvent = event.nativeEvent;
|
|
168
|
+
if (!mouseOrTouchEvent.isTrusted) {
|
|
169
|
+
} else if ("touches" in mouseOrTouchEvent && mouseOrTouchEvent.touches.length > 0 && mouseOrTouchEvent.touches[0]) {
|
|
170
|
+
x = mouseOrTouchEvent.touches[0].clientX;
|
|
171
|
+
y = mouseOrTouchEvent.touches[0].clientY;
|
|
172
|
+
} else if ("clientX" in mouseOrTouchEvent && "clientY" in mouseOrTouchEvent) {
|
|
173
|
+
x = mouseOrTouchEvent.clientX;
|
|
174
|
+
y = mouseOrTouchEvent.clientY;
|
|
175
|
+
}
|
|
176
|
+
const challenge = await manager.current.start(x, y);
|
|
177
|
+
if (challenge) {
|
|
178
|
+
setChallengeData(challenge);
|
|
179
|
+
setPuzzlePhase("dragging");
|
|
180
|
+
}
|
|
181
|
+
setLoading(false);
|
|
182
|
+
},
|
|
183
|
+
labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
|
|
184
|
+
error: state.error?.message,
|
|
185
|
+
"aria-label": "human checkbox",
|
|
186
|
+
loading: loading || puzzlePhase === "submitting"
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
] });
|
|
190
|
+
};
|
|
191
|
+
module.exports = Procaptcha;
|