@prosopo/procaptcha-puzzle 2.10.24 → 2.10.26
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 +3 -3
- package/.turbo/turbo-build$colon$tsc.log +19 -19
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +25 -0
- package/dist/cjs/components/ProcaptchaWidget.cjs +28 -17
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
- package/dist/components/ProcaptchaWidget.js +28 -17
- package/dist/components/ProcaptchaWidget.js.map +1 -1
- package/package.json +4 -4
- package/src/components/ProcaptchaWidget.tsx +30 -17
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-puzzle@2.10.
|
|
2
|
+
> @prosopo/procaptcha-puzzle@2.10.26 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -47,7 +47,7 @@ Build end
|
|
|
47
47
|
rendering chunks...
|
|
48
48
|
[2mdist/cjs/[22m[36mindex.cjs [39m[1m[2m 0.27 kB[22m[1m[22m
|
|
49
49
|
[2mdist/cjs/[22m[36mcomponents/ProcaptchaPuzzle.cjs [39m[1m[2m 0.70 kB[22m[1m[22m
|
|
50
|
-
[2mdist/cjs/[22m[36mcomponents/ProcaptchaWidget.cjs [39m[1m[2m
|
|
50
|
+
[2mdist/cjs/[22m[36mcomponents/ProcaptchaWidget.cjs [39m[1m[2m 7.48 kB[22m[1m[22m
|
|
51
51
|
[2mdist/cjs/[22m[36mcomponents/PuzzleCanvas.cjs [39m[1m[2m10.09 kB[22m[1m[22m
|
|
52
52
|
[2mdist/cjs/[22m[36mservices/Manager.cjs [39m[1m[2m10.17 kB[22m[1m[22m
|
|
53
|
-
[32m✓ built in
|
|
53
|
+
[32m✓ built in 212ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-puzzle@2.10.
|
|
2
|
+
> @prosopo/procaptcha-puzzle@2.10.26 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
9:22:25 AM - 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
|
+
9:22:25 AM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/vite/vite-plugin-fix-absolute-imports.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
9:22:26 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/useTranslation.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
9:22:26 AM - 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
|
+
9:22:26 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
30
|
|
|
31
|
-
|
|
31
|
+
9:22:26 AM - 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
|
+
9:22:26 AM - 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
|
+
9:22:26 AM - 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
|
+
9:22:26 AM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
9:22:26 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
40
|
|
|
41
|
-
|
|
41
|
+
9:22:26 AM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/constants.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
9:22:26 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
44
|
|
|
45
|
-
|
|
45
|
+
9:22:26 AM - 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
|
+
9:22:26 AM - 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
|
+
9:22:26 AM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/index.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
9:22:26 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
52
|
|
|
53
|
-
|
|
53
|
+
9:22:26 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
9:22:26 AM - 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.26 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.26 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -51,7 +51,7 @@ Build end
|
|
|
51
51
|
rendering chunks...
|
|
52
52
|
[2mdist/[22m[36mindex.js [39m[1m[2m 0.14 kB[22m[1m[22m
|
|
53
53
|
[2mdist/[22m[36mcomponents/ProcaptchaPuzzle.js [39m[1m[2m 0.34 kB[22m[1m[22m
|
|
54
|
-
[2mdist/[22m[36mcomponents/ProcaptchaWidget.js [39m[1m[2m
|
|
54
|
+
[2mdist/[22m[36mcomponents/ProcaptchaWidget.js [39m[1m[2m 7.28 kB[22m[1m[22m
|
|
55
55
|
[2mdist/[22m[36mcomponents/PuzzleCanvas.js [39m[1m[2m 9.81 kB[22m[1m[22m
|
|
56
56
|
[2mdist/[22m[36mservices/Manager.js [39m[1m[2m10.01 kB[22m[1m[22m
|
|
57
|
-
[32m✓ built in
|
|
57
|
+
[32m✓ built in 229ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @prosopo/procaptcha-puzzle
|
|
2
2
|
|
|
3
|
+
## 2.10.26
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- Updated dependencies [de12b31]
|
|
7
|
+
- Updated dependencies [770954b]
|
|
8
|
+
- @prosopo/types@4.9.4
|
|
9
|
+
- @prosopo/api@3.5.11
|
|
10
|
+
- @prosopo/procaptcha-common@2.11.5
|
|
11
|
+
|
|
12
|
+
## 2.10.25
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 18d0287: fix(procaptcha-frictionless,procaptcha-pow,procaptcha-puzzle,procaptcha-react): auto-recover from `CAPTCHA.NO_SESSION_FOUND` on the inner widget without asking the user to click the checkbox a second time, and without dropping the click coordinates that would otherwise land in the solution salt as `(0, 0)`.
|
|
16
|
+
|
|
17
|
+
Motivation. The in-flight dedupe added in the previous change only collapses `/captcha/{type}` POSTs that overlap in flight. A duplicate POST that fires ~1 s after the first has already settled (observed on iPhone WKWebView, incident 2026-07-01 21:23 UTC) still lands on a consumed session and returns `NO_SESSION_FOUND`. The pre-existing recovery for that case was a `setTimeout(restart, 100)` that tore the whole widget down and lost the checkbox click position.
|
|
18
|
+
|
|
19
|
+
- `ProcaptchaProps` gains two optional props: `onSessionInvalidated(x?, y?)` and `startCoords: { x, y }`. Widgets not mounted under a recovery-aware parent still fall back to `frictionlessState.restart()`.
|
|
20
|
+
- `procaptcha-pow`, `procaptcha-puzzle`, and `procaptcha-react` widgets now track the last `manager.start(x, y)` coords in a ref (either from the checkbox click or from `startCoords`) and, on the first `CAPTCHA.NO_SESSION_FOUND`, invoke `onSessionInvalidated(x, y)` instead of calling `restart()`. A per-instance ref makes it strictly one-shot — a second failure falls back to the existing restart path so a persistently broken session doesn't loop.
|
|
21
|
+
- `ProcaptchaFrictionless` wires `onSessionInvalidated` through to each inner widget: it stashes the retry coords in a ref, re-runs its own `start()` (which re-invokes `/frictionless` and mints a fresh sessionId), then re-mounts the inner widget with `autoStart={true}` and `startCoords={x, y}`. The inner widget auto-fires `manager.start(x, y)` on mount so the eventual submit still embeds the real checkbox click position in the salt.
|
|
22
|
+
- The recovery decision (one-shot fire, coord validation — `(0, 0)` and partial pairs are discarded because they're what an `autoStart` mount or an untrusted pointer event emits rather than a real click, and the consume-and-clear pending-coords ref) is extracted into `sessionInvalidatedRecovery.ts` with dedicated unit tests.
|
|
23
|
+
- Updated dependencies [18d0287]
|
|
24
|
+
- @prosopo/types@4.9.3
|
|
25
|
+
- @prosopo/api@3.5.10
|
|
26
|
+
- @prosopo/procaptcha-common@2.11.4
|
|
27
|
+
|
|
3
28
|
## 2.10.24
|
|
4
29
|
### Patch Changes
|
|
5
30
|
|
|
@@ -32,6 +32,8 @@ const Procaptcha = (props) => {
|
|
|
32
32
|
() => hpRef.current?.value || void 0
|
|
33
33
|
)
|
|
34
34
|
);
|
|
35
|
+
const lastCoordsRef = react.useRef(null);
|
|
36
|
+
const sessionInvalidatedFiredRef = react.useRef(false);
|
|
35
37
|
react.useEffect(() => {
|
|
36
38
|
if (config.language) {
|
|
37
39
|
if (i18n) {
|
|
@@ -47,35 +49,43 @@ const Procaptcha = (props) => {
|
|
|
47
49
|
}
|
|
48
50
|
}, [i18n, config.language]);
|
|
49
51
|
react.useEffect(() => {
|
|
50
|
-
if (props.autoStart)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
if (!props.autoStart) return;
|
|
53
|
+
setLoading(true);
|
|
54
|
+
setShowRetry(false);
|
|
55
|
+
const coords = props.startCoords;
|
|
56
|
+
lastCoordsRef.current = coords ?? null;
|
|
57
|
+
manager.current.start(coords?.x ?? 0, coords?.y ?? 0).then(
|
|
58
|
+
(challenge) => {
|
|
59
|
+
if (challenge) {
|
|
60
|
+
setChallengeData(challenge);
|
|
61
|
+
setPuzzlePhase("dragging");
|
|
62
|
+
}
|
|
63
|
+
setLoading(false);
|
|
64
|
+
},
|
|
65
|
+
() => setLoading(false)
|
|
66
|
+
);
|
|
67
|
+
}, [props.autoStart, props.startCoords]);
|
|
65
68
|
react.useEffect(() => {
|
|
66
69
|
if (!state.error) return void 0;
|
|
67
70
|
setLoading(false);
|
|
68
71
|
setPuzzlePhase("checkbox");
|
|
69
72
|
setChallengeData(null);
|
|
70
73
|
setShowRetry(false);
|
|
71
|
-
if (state.error.key
|
|
74
|
+
if (state.error.key !== "CAPTCHA.NO_SESSION_FOUND") return void 0;
|
|
75
|
+
if (props.onSessionInvalidated && !sessionInvalidatedFiredRef.current) {
|
|
76
|
+
sessionInvalidatedFiredRef.current = true;
|
|
77
|
+
const coords = lastCoordsRef.current;
|
|
78
|
+
props.onSessionInvalidated(coords?.x, coords?.y);
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
if (frictionlessState) {
|
|
72
82
|
const timer = setTimeout(() => {
|
|
73
83
|
frictionlessState.restart();
|
|
74
84
|
}, 100);
|
|
75
85
|
return () => clearTimeout(timer);
|
|
76
86
|
}
|
|
77
87
|
return void 0;
|
|
78
|
-
}, [state.error, frictionlessState]);
|
|
88
|
+
}, [state.error, frictionlessState, props.onSessionInvalidated]);
|
|
79
89
|
react.useEffect(() => {
|
|
80
90
|
if (config.mode === types.ModeEnum.invisible) {
|
|
81
91
|
const handleExecuteEvent = async () => {
|
|
@@ -189,6 +199,7 @@ const Procaptcha = (props) => {
|
|
|
189
199
|
x = mouseOrTouchEvent.clientX;
|
|
190
200
|
y = mouseOrTouchEvent.clientY;
|
|
191
201
|
}
|
|
202
|
+
lastCoordsRef.current = { x, y };
|
|
192
203
|
const challenge = await manager.current.start(x, y);
|
|
193
204
|
if (challenge) {
|
|
194
205
|
setChallengeData(challenge);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAGN,KAAK,eAAe,EAEpB,MAAM,gBAAgB,CAAC;AAWxB,QAAA,MAAM,UAAU,UAAW,eAAe,
|
|
1
|
+
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAGN,KAAK,eAAe,EAEpB,MAAM,gBAAgB,CAAC;AAWxB,QAAA,MAAM,UAAU,UAAW,eAAe,qDA+PzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -31,6 +31,8 @@ const Procaptcha = (props) => {
|
|
|
31
31
|
() => hpRef.current?.value || void 0
|
|
32
32
|
)
|
|
33
33
|
);
|
|
34
|
+
const lastCoordsRef = useRef(null);
|
|
35
|
+
const sessionInvalidatedFiredRef = useRef(false);
|
|
34
36
|
useEffect(() => {
|
|
35
37
|
if (config.language) {
|
|
36
38
|
if (i18n) {
|
|
@@ -46,35 +48,43 @@ const Procaptcha = (props) => {
|
|
|
46
48
|
}
|
|
47
49
|
}, [i18n, config.language]);
|
|
48
50
|
useEffect(() => {
|
|
49
|
-
if (props.autoStart)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
if (!props.autoStart) return;
|
|
52
|
+
setLoading(true);
|
|
53
|
+
setShowRetry(false);
|
|
54
|
+
const coords = props.startCoords;
|
|
55
|
+
lastCoordsRef.current = coords ?? null;
|
|
56
|
+
manager.current.start(coords?.x ?? 0, coords?.y ?? 0).then(
|
|
57
|
+
(challenge) => {
|
|
58
|
+
if (challenge) {
|
|
59
|
+
setChallengeData(challenge);
|
|
60
|
+
setPuzzlePhase("dragging");
|
|
61
|
+
}
|
|
62
|
+
setLoading(false);
|
|
63
|
+
},
|
|
64
|
+
() => setLoading(false)
|
|
65
|
+
);
|
|
66
|
+
}, [props.autoStart, props.startCoords]);
|
|
64
67
|
useEffect(() => {
|
|
65
68
|
if (!state.error) return void 0;
|
|
66
69
|
setLoading(false);
|
|
67
70
|
setPuzzlePhase("checkbox");
|
|
68
71
|
setChallengeData(null);
|
|
69
72
|
setShowRetry(false);
|
|
70
|
-
if (state.error.key
|
|
73
|
+
if (state.error.key !== "CAPTCHA.NO_SESSION_FOUND") return void 0;
|
|
74
|
+
if (props.onSessionInvalidated && !sessionInvalidatedFiredRef.current) {
|
|
75
|
+
sessionInvalidatedFiredRef.current = true;
|
|
76
|
+
const coords = lastCoordsRef.current;
|
|
77
|
+
props.onSessionInvalidated(coords?.x, coords?.y);
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
if (frictionlessState) {
|
|
71
81
|
const timer = setTimeout(() => {
|
|
72
82
|
frictionlessState.restart();
|
|
73
83
|
}, 100);
|
|
74
84
|
return () => clearTimeout(timer);
|
|
75
85
|
}
|
|
76
86
|
return void 0;
|
|
77
|
-
}, [state.error, frictionlessState]);
|
|
87
|
+
}, [state.error, frictionlessState, props.onSessionInvalidated]);
|
|
78
88
|
useEffect(() => {
|
|
79
89
|
if (config.mode === ModeEnum.invisible) {
|
|
80
90
|
const handleExecuteEvent = async () => {
|
|
@@ -188,6 +198,7 @@ const Procaptcha = (props) => {
|
|
|
188
198
|
x = mouseOrTouchEvent.clientX;
|
|
189
199
|
y = mouseOrTouchEvent.clientY;
|
|
190
200
|
}
|
|
201
|
+
lastCoordsRef.current = { x, y };
|
|
191
202
|
const challenge = await manager.current.start(x, y);
|
|
192
203
|
if (challenge) {
|
|
193
204
|
setChallengeData(challenge);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaWidget.js","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AA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AAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;oBACjC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAEpD,IAAI,SAAS,EAAE,CAAC;wBACf,gBAAgB,CAAC,SAAS,CAAC,CAAC;wBAC5B,cAAc,CAAC,UAAU,CAAC,CAAC;oBAC5B,CAAC;oBAED,UAAU,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC,EACD,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,EAC3D,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,gBAChB,gBAAgB,EAC3B,OAAO,EAAE,OAAO,IAAI,WAAW,KAAK,YAAY,GAC/C,CACF,IACC,CACH,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-puzzle",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.26",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"browserslist": ["> 0.5%, last 2 versions, not dead"],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@polkadot/util": "13.5.7",
|
|
33
|
-
"@prosopo/api": "3.5.
|
|
33
|
+
"@prosopo/api": "3.5.11",
|
|
34
34
|
"@prosopo/common": "3.1.43",
|
|
35
35
|
"@prosopo/locale": "3.2.6",
|
|
36
|
-
"@prosopo/procaptcha-common": "2.11.
|
|
37
|
-
"@prosopo/types": "4.9.
|
|
36
|
+
"@prosopo/procaptcha-common": "2.11.5",
|
|
37
|
+
"@prosopo/types": "4.9.4",
|
|
38
38
|
"@prosopo/util": "3.3.3",
|
|
39
39
|
"@prosopo/util-crypto": "13.5.30",
|
|
40
40
|
"@prosopo/widget-skeleton": "2.8.4",
|
|
@@ -57,6 +57,10 @@ const Procaptcha = (props: ProcaptchaProps) => {
|
|
|
57
57
|
() => hpRef.current?.value || undefined,
|
|
58
58
|
),
|
|
59
59
|
);
|
|
60
|
+
// See ProcaptchaWidget (procaptcha-pow) — same session-invalidation
|
|
61
|
+
// recovery contract with coords preservation across a re-mint.
|
|
62
|
+
const lastCoordsRef = useRef<{ x: number; y: number } | null>(null);
|
|
63
|
+
const sessionInvalidatedFiredRef = useRef(false);
|
|
60
64
|
|
|
61
65
|
useEffect(() => {
|
|
62
66
|
if (config.language) {
|
|
@@ -74,21 +78,22 @@ const Procaptcha = (props: ProcaptchaProps) => {
|
|
|
74
78
|
}, [i18n, config.language]);
|
|
75
79
|
|
|
76
80
|
useEffect(() => {
|
|
77
|
-
if (props.autoStart)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
if (!props.autoStart) return;
|
|
82
|
+
setLoading(true);
|
|
83
|
+
setShowRetry(false);
|
|
84
|
+
const coords = props.startCoords;
|
|
85
|
+
lastCoordsRef.current = coords ?? null;
|
|
86
|
+
manager.current.start(coords?.x ?? 0, coords?.y ?? 0).then(
|
|
87
|
+
(challenge) => {
|
|
88
|
+
if (challenge) {
|
|
89
|
+
setChallengeData(challenge);
|
|
90
|
+
setPuzzlePhase("dragging");
|
|
91
|
+
}
|
|
92
|
+
setLoading(false);
|
|
93
|
+
},
|
|
94
|
+
() => setLoading(false),
|
|
95
|
+
);
|
|
96
|
+
}, [props.autoStart, props.startCoords]);
|
|
92
97
|
|
|
93
98
|
useEffect(() => {
|
|
94
99
|
if (!state.error) return undefined;
|
|
@@ -96,14 +101,21 @@ const Procaptcha = (props: ProcaptchaProps) => {
|
|
|
96
101
|
setPuzzlePhase("checkbox");
|
|
97
102
|
setChallengeData(null);
|
|
98
103
|
setShowRetry(false);
|
|
99
|
-
if (state.error.key
|
|
104
|
+
if (state.error.key !== "CAPTCHA.NO_SESSION_FOUND") return undefined;
|
|
105
|
+
if (props.onSessionInvalidated && !sessionInvalidatedFiredRef.current) {
|
|
106
|
+
sessionInvalidatedFiredRef.current = true;
|
|
107
|
+
const coords = lastCoordsRef.current;
|
|
108
|
+
props.onSessionInvalidated(coords?.x, coords?.y);
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
if (frictionlessState) {
|
|
100
112
|
const timer = setTimeout(() => {
|
|
101
113
|
frictionlessState.restart();
|
|
102
114
|
}, 100);
|
|
103
115
|
return () => clearTimeout(timer);
|
|
104
116
|
}
|
|
105
117
|
return undefined;
|
|
106
|
-
}, [state.error, frictionlessState]);
|
|
118
|
+
}, [state.error, frictionlessState, props.onSessionInvalidated]);
|
|
107
119
|
|
|
108
120
|
// Add event listener for the execute event (works for invisible mode)
|
|
109
121
|
useEffect(() => {
|
|
@@ -256,6 +268,7 @@ const Procaptcha = (props: ProcaptchaProps) => {
|
|
|
256
268
|
y = mouseOrTouchEvent.clientY;
|
|
257
269
|
}
|
|
258
270
|
|
|
271
|
+
lastCoordsRef.current = { x, y };
|
|
259
272
|
const challenge = await manager.current.start(x, y);
|
|
260
273
|
|
|
261
274
|
if (challenge) {
|