@prosopo/procaptcha-puzzle 2.10.39 → 2.10.40
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 +13 -11
- package/.turbo/turbo-build$colon$tsc.log +19 -19
- package/.turbo/turbo-build.log +15 -12
- package/CHANGELOG.md +34 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/components/ProcaptchaPuzzle.cjs +6 -9
- package/dist/cjs/components/ProcaptchaWidget.cjs +186 -213
- package/dist/cjs/components/PuzzleCanvas.cjs +228 -270
- package/dist/cjs/index.cjs +2 -4
- package/dist/cjs/services/Manager.cjs +209 -289
- package/dist/components/ProcaptchaPuzzle.js +6 -8
- package/dist/components/ProcaptchaWidget.js +185 -212
- package/dist/components/PuzzleCanvas.js +229 -271
- package/dist/index.js +2 -4
- package/dist/services/Manager.d.ts.map +1 -1
- package/dist/services/Manager.js +205 -286
- package/dist/services/Manager.js.map +1 -1
- package/package.json +11 -11
- package/src/services/Manager.ts +4 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-puzzle@2.10.
|
|
2
|
+
> @prosopo/procaptcha-puzzle@2.10.40 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -39,15 +39,17 @@ ViteCommonJSConfig: .
|
|
|
39
39
|
'@prosopo/keyring'
|
|
40
40
|
]
|
|
41
41
|
}
|
|
42
|
-
[
|
|
42
|
+
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
43
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
43
44
|
Bundle build started
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[32m✓[39m 5 modules transformed.
|
|
45
|
+
[2K
|
|
46
|
+
✓ 6 modules transformed.
|
|
47
47
|
rendering chunks...
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
computing gzip size...
|
|
49
|
+
dist/cjs/index.cjs 0.22 kB │ gzip: 0.15 kB
|
|
50
|
+
dist/cjs/components/ProcaptchaPuzzle.cjs 0.52 kB │ gzip: 0.27 kB
|
|
51
|
+
dist/cjs/components/ProcaptchaWidget.cjs 6.82 kB │ gzip: 1.95 kB
|
|
52
|
+
dist/cjs/components/PuzzleCanvas.cjs 8.35 kB │ gzip: 2.51 kB
|
|
53
|
+
dist/cjs/services/Manager.cjs 8.99 kB │ gzip: 2.48 kB
|
|
54
|
+
|
|
55
|
+
[32m✓ built in 72ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-puzzle@2.10.
|
|
2
|
+
> @prosopo/procaptcha-puzzle@2.10.40 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
8:59:31 PM - Projects in this build:
|
|
6
6
|
* ../../dev/config/tsconfig.json
|
|
7
7
|
* ../locale/tsconfig.json
|
|
8
8
|
* ../util/tsconfig.json
|
|
@@ -20,37 +20,37 @@
|
|
|
20
20
|
* ../procaptcha-common/tsconfig.json
|
|
21
21
|
* tsconfig.json
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
8:59:31 PM - 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
24
|
|
|
25
|
-
|
|
25
|
+
8:59:31 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
8:59:31 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
8:59:31 PM - 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
30
|
|
|
31
|
-
|
|
31
|
+
8:59:31 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/provider/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
8:59:31 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
8:59:31 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
8:59:31 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/tests/utils/batches.unit.test.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
8:59:31 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/tests/providers.unit.test.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
8:59:31 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/index.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
8:59:31 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
8:59:31 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
8:59:31 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/keyring/keyring.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
8:59:31 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/tests/cryptoWorker.unit.test.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
8:59:31 PM - 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
52
|
|
|
53
|
-
|
|
53
|
+
8:59:31 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
8:59:31 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-puzzle/tsconfig.json'...
|
|
56
56
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-puzzle@2.10.
|
|
2
|
+
> @prosopo/procaptcha-puzzle@2.10.40 build
|
|
3
3
|
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @prosopo/procaptcha-puzzle@2.10.
|
|
6
|
+
> @prosopo/procaptcha-puzzle@2.10.40 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -29,6 +29,7 @@ ViteEsmConfig: .
|
|
|
29
29
|
externals: [
|
|
30
30
|
'@prosopo/api',
|
|
31
31
|
'@prosopo/types',
|
|
32
|
+
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
32
33
|
'@prosopo/locale',
|
|
33
34
|
'@prosopo/util',
|
|
34
35
|
'@prosopo/util-crypto',
|
|
@@ -43,15 +44,17 @@ ViteEsmConfig: .
|
|
|
43
44
|
'@prosopo/keyring'
|
|
44
45
|
]
|
|
45
46
|
}
|
|
46
|
-
[36mvite
|
|
47
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
47
48
|
Bundle build started
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
[32m✓[39m 5 modules transformed.
|
|
49
|
+
[2K
|
|
50
|
+
✓ 6 modules transformed.
|
|
51
51
|
rendering chunks...
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
computing gzip size...
|
|
53
|
+
dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
|
|
54
|
+
dist/index.js 0.14 kB │ gzip: 0.11 kB
|
|
55
|
+
dist/components/ProcaptchaPuzzle.js 0.38 kB │ gzip: 0.24 kB
|
|
56
|
+
dist/components/ProcaptchaWidget.js 6.32 kB │ gzip: 1.92 kB
|
|
57
|
+
dist/components/PuzzleCanvas.js 7.89 kB │ gzip: 2.48 kB
|
|
58
|
+
dist/services/Manager.js 8.47 kB │ gzip: 2.43 kB
|
|
59
|
+
|
|
60
|
+
[32m✓ built in 87ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @prosopo/procaptcha-puzzle
|
|
2
2
|
|
|
3
|
+
## 2.10.40
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- ab3499c: feat(procaptcha): block on SIMD readings at solution submit
|
|
7
|
+
|
|
8
|
+
Solution submit is the last hop the client controls, so it's the last chance to
|
|
9
|
+
attach the catcher's WASM SIMD readings for a session. The image, PoW and puzzle
|
|
10
|
+
managers now wait for the benchmark there via a shared
|
|
11
|
+
`getSimdReadingsForSubmit` helper, capped at 5s, instead of attaching only
|
|
12
|
+
whatever the prefetch happened to have resolved.
|
|
13
|
+
|
|
14
|
+
The helper passes the budget down to the detector *and* races it locally — the
|
|
15
|
+
detector ships prebuilt, so a bundle that ignores `timeoutMs` (or a benchmark
|
|
16
|
+
wedged on a busy main thread) can't hang the submission. It never rejects: a
|
|
17
|
+
missing accessor, a rejection, a synchronous throw and a timeout all resolve to
|
|
18
|
+
`undefined` and the solution is submitted without readings, so a user is never
|
|
19
|
+
failed over telemetry.
|
|
20
|
+
|
|
21
|
+
The earlier frictionless POST and challenge GET hops are unchanged and remain
|
|
22
|
+
non-blocking.
|
|
23
|
+
- e14fce6: chore(deps): bump vite to 6.4.3 and mongoose to 8.24.1, and adjust types for the mongoose 8.24 Document/ObjectId changes
|
|
24
|
+
- Updated dependencies [2c47bb7]
|
|
25
|
+
- Updated dependencies [ab3499c]
|
|
26
|
+
- Updated dependencies [0e1171c]
|
|
27
|
+
- Updated dependencies [103318c]
|
|
28
|
+
- Updated dependencies [270a8d8]
|
|
29
|
+
- Updated dependencies [e14fce6]
|
|
30
|
+
- @prosopo/util@3.3.5
|
|
31
|
+
- @prosopo/procaptcha-common@2.11.18
|
|
32
|
+
- @prosopo/locale@3.2.8
|
|
33
|
+
- @prosopo/types@4.10.0
|
|
34
|
+
- @prosopo/api@3.5.20
|
|
35
|
+
- @prosopo/common@3.1.48
|
|
36
|
+
|
|
3
37
|
## 2.10.39
|
|
4
38
|
### Patch Changes
|
|
5
39
|
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
async () => Promise.resolve().then(() => /* @__PURE__ */ _interopNamespaceDefaultOnly(require("./ProcaptchaWidget.cjs")))
|
|
8
|
-
);
|
|
9
|
-
const ProcaptchaPuzzle = (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsx(ProcaptchaWidget, { ...props }) });
|
|
1
|
+
let react = require("react");
|
|
2
|
+
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
3
|
+
//#region src/components/ProcaptchaPuzzle.tsx
|
|
4
|
+
var ProcaptchaWidget = (0, react.lazy)(async () => Promise.resolve().then(() => require("./ProcaptchaWidget.cjs")));
|
|
5
|
+
var ProcaptchaPuzzle = (props) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react.Suspense, { children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ProcaptchaWidget, { ...props }) });
|
|
6
|
+
//#endregion
|
|
10
7
|
exports.ProcaptchaPuzzle = ProcaptchaPuzzle;
|
|
@@ -1,214 +1,187 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
setLoading(true);
|
|
186
|
-
setShowRetry(false);
|
|
187
|
-
let x = 0;
|
|
188
|
-
let y = 0;
|
|
189
|
-
const mouseOrTouchEvent = event.nativeEvent;
|
|
190
|
-
if (!mouseOrTouchEvent.isTrusted) {
|
|
191
|
-
} else if ("touches" in mouseOrTouchEvent && mouseOrTouchEvent.touches.length > 0 && mouseOrTouchEvent.touches[0]) {
|
|
192
|
-
x = mouseOrTouchEvent.touches[0].clientX;
|
|
193
|
-
y = mouseOrTouchEvent.touches[0].clientY;
|
|
194
|
-
} else if ("clientX" in mouseOrTouchEvent && "clientY" in mouseOrTouchEvent) {
|
|
195
|
-
x = mouseOrTouchEvent.clientX;
|
|
196
|
-
y = mouseOrTouchEvent.clientY;
|
|
197
|
-
}
|
|
198
|
-
lastCoordsRef.current = { x, y };
|
|
199
|
-
const challenge = await manager.current.start(x, y);
|
|
200
|
-
if (challenge) {
|
|
201
|
-
setChallengeData(challenge);
|
|
202
|
-
setPuzzlePhase("dragging");
|
|
203
|
-
}
|
|
204
|
-
setLoading(false);
|
|
205
|
-
},
|
|
206
|
-
labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
|
|
207
|
-
error: state.error?.message,
|
|
208
|
-
"aria-label": "human checkbox",
|
|
209
|
-
loading: loading || puzzlePhase === "submitting"
|
|
210
|
-
}
|
|
211
|
-
)
|
|
212
|
-
] });
|
|
1
|
+
const require_Manager = require("../services/Manager.cjs");
|
|
2
|
+
const require_PuzzleCanvas = require("./PuzzleCanvas.cjs");
|
|
3
|
+
let _prosopo_locale = require("@prosopo/locale");
|
|
4
|
+
let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
|
|
5
|
+
let _prosopo_types = require("@prosopo/types");
|
|
6
|
+
let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
9
|
+
//#region src/components/ProcaptchaWidget.tsx
|
|
10
|
+
var PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
|
|
11
|
+
var Procaptcha = (props) => {
|
|
12
|
+
const { t, ready: isTranslationReady } = (0, _prosopo_locale.useTranslation)();
|
|
13
|
+
const config = props.config;
|
|
14
|
+
const i18n = props.i18n;
|
|
15
|
+
const theme = "light" === config.theme ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme;
|
|
16
|
+
const frictionlessState = props.frictionlessState;
|
|
17
|
+
const callbacks = props.callbacks || {};
|
|
18
|
+
const [state, _updateState] = (0, _prosopo_procaptcha_common.useProcaptcha)(react.useState, react.useRef);
|
|
19
|
+
const [loading, setLoading] = (0, react.useState)(false);
|
|
20
|
+
const [puzzlePhase, setPuzzlePhase] = (0, react.useState)("checkbox");
|
|
21
|
+
const [challengeData, setChallengeData] = (0, react.useState)(null);
|
|
22
|
+
const [showRetry, setShowRetry] = (0, react.useState)(false);
|
|
23
|
+
const updateState = (0, _prosopo_procaptcha_common.buildUpdateState)(state, _updateState);
|
|
24
|
+
const hpRef = (0, react.useRef)(null);
|
|
25
|
+
const manager = (0, react.useRef)(require_Manager.Manager(config, state, updateState, callbacks, frictionlessState, () => hpRef.current?.value || void 0));
|
|
26
|
+
const lastCoordsRef = (0, react.useRef)(null);
|
|
27
|
+
const sessionInvalidatedFiredRef = (0, react.useRef)(false);
|
|
28
|
+
(0, react.useEffect)(() => {
|
|
29
|
+
if (!config.language) return;
|
|
30
|
+
if (i18n) {
|
|
31
|
+
if (i18n.language !== config.language) i18n.changeLanguage(config.language);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
(0, _prosopo_locale.loadI18next)(false, config.language);
|
|
35
|
+
}, [i18n, config.language]);
|
|
36
|
+
(0, react.useEffect)(() => {
|
|
37
|
+
if (!props.autoStart) return;
|
|
38
|
+
setLoading(true);
|
|
39
|
+
setShowRetry(false);
|
|
40
|
+
const coords = props.startCoords;
|
|
41
|
+
lastCoordsRef.current = coords ?? null;
|
|
42
|
+
manager.current.start(coords?.x ?? 0, coords?.y ?? 0).then((challenge) => {
|
|
43
|
+
if (challenge) {
|
|
44
|
+
setChallengeData(challenge);
|
|
45
|
+
setPuzzlePhase("dragging");
|
|
46
|
+
}
|
|
47
|
+
setLoading(false);
|
|
48
|
+
}, () => setLoading(false));
|
|
49
|
+
}, [props.autoStart, props.startCoords]);
|
|
50
|
+
(0, react.useEffect)(() => {
|
|
51
|
+
if (!state.error) return void 0;
|
|
52
|
+
setLoading(false);
|
|
53
|
+
setPuzzlePhase("checkbox");
|
|
54
|
+
setChallengeData(null);
|
|
55
|
+
setShowRetry(false);
|
|
56
|
+
if (state.error.key !== "CAPTCHA.NO_SESSION_FOUND") return void 0;
|
|
57
|
+
if (props.onSessionInvalidated && !sessionInvalidatedFiredRef.current) {
|
|
58
|
+
sessionInvalidatedFiredRef.current = true;
|
|
59
|
+
const coords = lastCoordsRef.current;
|
|
60
|
+
props.onSessionInvalidated(coords?.x, coords?.y);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (frictionlessState) {
|
|
64
|
+
const timer = setTimeout(() => {
|
|
65
|
+
frictionlessState.restart();
|
|
66
|
+
}, 100);
|
|
67
|
+
return () => clearTimeout(timer);
|
|
68
|
+
}
|
|
69
|
+
}, [
|
|
70
|
+
state.error,
|
|
71
|
+
frictionlessState,
|
|
72
|
+
props.onSessionInvalidated
|
|
73
|
+
]);
|
|
74
|
+
(0, react.useEffect)(() => {
|
|
75
|
+
if (config.mode === _prosopo_types.ModeEnum.invisible) {
|
|
76
|
+
const handleExecuteEvent = async () => {
|
|
77
|
+
if (loading) return;
|
|
78
|
+
setLoading(true);
|
|
79
|
+
setShowRetry(false);
|
|
80
|
+
try {
|
|
81
|
+
const challenge = await manager.current.start();
|
|
82
|
+
if (challenge) {
|
|
83
|
+
setChallengeData(challenge);
|
|
84
|
+
setPuzzlePhase("dragging");
|
|
85
|
+
}
|
|
86
|
+
} catch (error) {
|
|
87
|
+
callbacks.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
88
|
+
} finally {
|
|
89
|
+
setLoading(false);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, handleExecuteEvent);
|
|
93
|
+
return () => {
|
|
94
|
+
document.removeEventListener(PROCAPTCHA_EXECUTE_EVENT, handleExecuteEvent);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return () => {};
|
|
98
|
+
}, [
|
|
99
|
+
config.mode,
|
|
100
|
+
callbacks.onError,
|
|
101
|
+
loading
|
|
102
|
+
]);
|
|
103
|
+
const handlePuzzleComplete = (0, react.useCallback)(async (finalX, finalY, puzzleEvents) => {
|
|
104
|
+
setPuzzlePhase("submitting");
|
|
105
|
+
let verified = false;
|
|
106
|
+
try {
|
|
107
|
+
verified = await manager.current.submitSolution(finalX, finalY, puzzleEvents);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
callbacks.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
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) setChallengeData(newChallenge);
|
|
123
|
+
else {
|
|
124
|
+
setPuzzlePhase("checkbox");
|
|
125
|
+
setChallengeData(null);
|
|
126
|
+
setShowRetry(false);
|
|
127
|
+
}
|
|
128
|
+
} catch {
|
|
129
|
+
setPuzzlePhase("checkbox");
|
|
130
|
+
setChallengeData(null);
|
|
131
|
+
setShowRetry(false);
|
|
132
|
+
}
|
|
133
|
+
setLoading(false);
|
|
134
|
+
}, [callbacks.onError]);
|
|
135
|
+
const isInvisible = config.mode === _prosopo_types.ModeEnum.invisible;
|
|
136
|
+
const showPuzzleOverlay = (puzzlePhase === "dragging" || puzzlePhase === "submitting") && challengeData;
|
|
137
|
+
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(_emotion_react_jsx_runtime.Fragment, { children: [
|
|
138
|
+
frictionlessState?.hp && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_prosopo_procaptcha_common.Honeypot, {
|
|
139
|
+
ref: hpRef,
|
|
140
|
+
encodedQuestion: frictionlessState.hp
|
|
141
|
+
}),
|
|
142
|
+
showPuzzleOverlay && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_PuzzleCanvas.PuzzleCanvas, {
|
|
143
|
+
originX: challengeData.originX,
|
|
144
|
+
originY: challengeData.originY,
|
|
145
|
+
targetX: challengeData.targetX,
|
|
146
|
+
targetY: challengeData.targetY,
|
|
147
|
+
onComplete: handlePuzzleComplete,
|
|
148
|
+
showRetry,
|
|
149
|
+
submitting: puzzlePhase === "submitting"
|
|
150
|
+
}),
|
|
151
|
+
!isInvisible && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_prosopo_procaptcha_common.Checkbox, {
|
|
152
|
+
checked: state.isHuman,
|
|
153
|
+
theme,
|
|
154
|
+
onChange: async (event) => {
|
|
155
|
+
if (loading) return;
|
|
156
|
+
setLoading(true);
|
|
157
|
+
setShowRetry(false);
|
|
158
|
+
let x = 0;
|
|
159
|
+
let y = 0;
|
|
160
|
+
const mouseOrTouchEvent = event.nativeEvent;
|
|
161
|
+
if (!mouseOrTouchEvent.isTrusted) {} else if ("touches" in mouseOrTouchEvent && mouseOrTouchEvent.touches.length > 0 && mouseOrTouchEvent.touches[0]) {
|
|
162
|
+
x = mouseOrTouchEvent.touches[0].clientX;
|
|
163
|
+
y = mouseOrTouchEvent.touches[0].clientY;
|
|
164
|
+
} else if ("clientX" in mouseOrTouchEvent && "clientY" in mouseOrTouchEvent) {
|
|
165
|
+
x = mouseOrTouchEvent.clientX;
|
|
166
|
+
y = mouseOrTouchEvent.clientY;
|
|
167
|
+
}
|
|
168
|
+
lastCoordsRef.current = {
|
|
169
|
+
x,
|
|
170
|
+
y
|
|
171
|
+
};
|
|
172
|
+
const challenge = await manager.current.start(x, y);
|
|
173
|
+
if (challenge) {
|
|
174
|
+
setChallengeData(challenge);
|
|
175
|
+
setPuzzlePhase("dragging");
|
|
176
|
+
}
|
|
177
|
+
setLoading(false);
|
|
178
|
+
},
|
|
179
|
+
labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
|
|
180
|
+
error: state.error?.message,
|
|
181
|
+
"aria-label": "human checkbox",
|
|
182
|
+
loading: loading || puzzlePhase === "submitting"
|
|
183
|
+
})
|
|
184
|
+
] });
|
|
213
185
|
};
|
|
214
|
-
|
|
186
|
+
//#endregion
|
|
187
|
+
exports.default = Procaptcha;
|