@prosopo/procaptcha-pow 2.10.9 → 2.10.11
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 +27 -0
- package/dist/cjs/components/ProcaptchaWidget.cjs +25 -7
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
- package/dist/components/ProcaptchaWidget.js +25 -7
- package/dist/components/ProcaptchaWidget.js.map +1 -1
- package/package.json +5 -5
- package/src/components/ProcaptchaWidget.tsx +39 -7
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-pow@2.10.
|
|
2
|
+
> @prosopo/procaptcha-pow@2.10.11 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,6 +47,6 @@ Build end
|
|
|
47
47
|
rendering chunks...
|
|
48
48
|
[2mdist/cjs/[22m[36mindex.cjs [39m[1m[2m 0.25 kB[22m[1m[22m
|
|
49
49
|
[2mdist/cjs/[22m[36mcomponents/ProcaptchaPoW.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 4.72 kB[22m[1m[22m
|
|
51
51
|
[2mdist/cjs/[22m[36mservices/Manager.cjs [39m[1m[2m10.31 kB[22m[1m[22m
|
|
52
|
-
[32m✓ built in
|
|
52
|
+
[32m✓ built in 241ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-pow@2.10.
|
|
2
|
+
> @prosopo/procaptcha-pow@2.10.11 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
9:22:26 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:27 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:27 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:27 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:27 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:27 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:27 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:27 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:27 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:27 AM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
9:22:27 AM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
9:22:27 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'
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
9:22:27 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'
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
9:22:27 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:27 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:27 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:27 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
9:22:27 AM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-pow/tsconfig.json'...
|
|
56
56
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-pow@2.10.
|
|
2
|
+
> @prosopo/procaptcha-pow@2.10.11 build
|
|
3
3
|
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @prosopo/procaptcha-pow@2.10.
|
|
6
|
+
> @prosopo/procaptcha-pow@2.10.11 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -51,6 +51,6 @@ Build end
|
|
|
51
51
|
rendering chunks...
|
|
52
52
|
[2mdist/[22m[36mindex.js [39m[1m[2m 0.13 kB[22m[1m[22m
|
|
53
53
|
[2mdist/[22m[36mcomponents/ProcaptchaPoW.js [39m[1m[2m 0.33 kB[22m[1m[22m
|
|
54
|
-
[2mdist/[22m[36mcomponents/ProcaptchaWidget.js [39m[1m[2m
|
|
54
|
+
[2mdist/[22m[36mcomponents/ProcaptchaWidget.js [39m[1m[2m 4.56 kB[22m[1m[22m
|
|
55
55
|
[2mdist/[22m[36mservices/Manager.js [39m[1m[2m10.15 kB[22m[1m[22m
|
|
56
|
-
[32m✓ built in
|
|
56
|
+
[32m✓ built in 201ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @prosopo/procaptcha-pow
|
|
2
2
|
|
|
3
|
+
## 2.10.11
|
|
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/fingerprint@2.7.10
|
|
11
|
+
- @prosopo/procaptcha-common@2.11.5
|
|
12
|
+
|
|
13
|
+
## 2.10.10
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 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)`.
|
|
17
|
+
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
- `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()`.
|
|
21
|
+
- `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.
|
|
22
|
+
- `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.
|
|
23
|
+
- 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.
|
|
24
|
+
- Updated dependencies [18d0287]
|
|
25
|
+
- @prosopo/types@4.9.3
|
|
26
|
+
- @prosopo/api@3.5.10
|
|
27
|
+
- @prosopo/fingerprint@2.7.9
|
|
28
|
+
- @prosopo/procaptcha-common@2.11.4
|
|
29
|
+
|
|
3
30
|
## 2.10.9
|
|
4
31
|
### Patch Changes
|
|
5
32
|
|
|
@@ -29,6 +29,8 @@ const Procaptcha = (props) => {
|
|
|
29
29
|
() => hpRef.current?.value || void 0
|
|
30
30
|
)
|
|
31
31
|
);
|
|
32
|
+
const lastCoordsRef = react.useRef(null);
|
|
33
|
+
const sessionInvalidatedFiredRef = react.useRef(false);
|
|
32
34
|
react.useEffect(() => {
|
|
33
35
|
if (config.language) {
|
|
34
36
|
if (i18n) {
|
|
@@ -44,15 +46,30 @@ const Procaptcha = (props) => {
|
|
|
44
46
|
}
|
|
45
47
|
}, [i18n, config.language]);
|
|
46
48
|
react.useEffect(() => {
|
|
47
|
-
if (
|
|
49
|
+
if (!props.autoStart) return;
|
|
50
|
+
setLoading(true);
|
|
51
|
+
const coords = props.startCoords;
|
|
52
|
+
lastCoordsRef.current = coords ?? null;
|
|
53
|
+
manager.current.start(coords?.x ?? 0, coords?.y ?? 0).finally(() => {
|
|
48
54
|
setLoading(false);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
});
|
|
56
|
+
}, [props.autoStart, props.startCoords]);
|
|
57
|
+
react.useEffect(() => {
|
|
58
|
+
if (!state.error) return;
|
|
59
|
+
setLoading(false);
|
|
60
|
+
if (state.error.key !== "CAPTCHA.NO_SESSION_FOUND") return;
|
|
61
|
+
if (props.onSessionInvalidated && !sessionInvalidatedFiredRef.current) {
|
|
62
|
+
sessionInvalidatedFiredRef.current = true;
|
|
63
|
+
const coords = lastCoordsRef.current;
|
|
64
|
+
props.onSessionInvalidated(coords?.x, coords?.y);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (frictionlessState) {
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
frictionlessState.restart();
|
|
70
|
+
}, 100);
|
|
54
71
|
}
|
|
55
|
-
}, [state.error, frictionlessState]);
|
|
72
|
+
}, [state.error, frictionlessState, props.onSessionInvalidated]);
|
|
56
73
|
react.useEffect(() => {
|
|
57
74
|
if (config.mode === types.ModeEnum.invisible) {
|
|
58
75
|
const handleExecuteEvent = (event) => {
|
|
@@ -100,6 +117,7 @@ const Procaptcha = (props) => {
|
|
|
100
117
|
x = mouseOrTouchEvent.clientX;
|
|
101
118
|
y = mouseOrTouchEvent.clientY;
|
|
102
119
|
}
|
|
120
|
+
lastCoordsRef.current = { x, y };
|
|
103
121
|
await manager.current.start(x, y);
|
|
104
122
|
setLoading(false);
|
|
105
123
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQhE,QAAA,MAAM,UAAU,UAAW,eAAe,
|
|
1
|
+
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQhE,QAAA,MAAM,UAAU,UAAW,eAAe,4DAwKzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -28,6 +28,8 @@ const Procaptcha = (props) => {
|
|
|
28
28
|
() => hpRef.current?.value || void 0
|
|
29
29
|
)
|
|
30
30
|
);
|
|
31
|
+
const lastCoordsRef = useRef(null);
|
|
32
|
+
const sessionInvalidatedFiredRef = useRef(false);
|
|
31
33
|
useEffect(() => {
|
|
32
34
|
if (config.language) {
|
|
33
35
|
if (i18n) {
|
|
@@ -43,15 +45,30 @@ const Procaptcha = (props) => {
|
|
|
43
45
|
}
|
|
44
46
|
}, [i18n, config.language]);
|
|
45
47
|
useEffect(() => {
|
|
46
|
-
if (
|
|
48
|
+
if (!props.autoStart) return;
|
|
49
|
+
setLoading(true);
|
|
50
|
+
const coords = props.startCoords;
|
|
51
|
+
lastCoordsRef.current = coords ?? null;
|
|
52
|
+
manager.current.start(coords?.x ?? 0, coords?.y ?? 0).finally(() => {
|
|
47
53
|
setLoading(false);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
});
|
|
55
|
+
}, [props.autoStart, props.startCoords]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!state.error) return;
|
|
58
|
+
setLoading(false);
|
|
59
|
+
if (state.error.key !== "CAPTCHA.NO_SESSION_FOUND") return;
|
|
60
|
+
if (props.onSessionInvalidated && !sessionInvalidatedFiredRef.current) {
|
|
61
|
+
sessionInvalidatedFiredRef.current = true;
|
|
62
|
+
const coords = lastCoordsRef.current;
|
|
63
|
+
props.onSessionInvalidated(coords?.x, coords?.y);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (frictionlessState) {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
frictionlessState.restart();
|
|
69
|
+
}, 100);
|
|
53
70
|
}
|
|
54
|
-
}, [state.error, frictionlessState]);
|
|
71
|
+
}, [state.error, frictionlessState, props.onSessionInvalidated]);
|
|
55
72
|
useEffect(() => {
|
|
56
73
|
if (config.mode === ModeEnum.invisible) {
|
|
57
74
|
const handleExecuteEvent = (event) => {
|
|
@@ -99,6 +116,7 @@ const Procaptcha = (props) => {
|
|
|
99
116
|
x = mouseOrTouchEvent.clientX;
|
|
100
117
|
y = mouseOrTouchEvent.clientY;
|
|
101
118
|
}
|
|
119
|
+
lastCoordsRef.current = { x, y };
|
|
102
120
|
await manager.current.start(x, y);
|
|
103
121
|
setLoading(false);
|
|
104
122
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaWidget.js","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,WAAW,EAAE,cAAc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
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.11",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,12 +30,12 @@
|
|
|
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
|
-
"@prosopo/fingerprint": "2.7.
|
|
35
|
+
"@prosopo/fingerprint": "2.7.10",
|
|
36
36
|
"@prosopo/locale": "3.2.6",
|
|
37
|
-
"@prosopo/procaptcha-common": "2.11.
|
|
38
|
-
"@prosopo/types": "4.9.
|
|
37
|
+
"@prosopo/procaptcha-common": "2.11.5",
|
|
38
|
+
"@prosopo/types": "4.9.4",
|
|
39
39
|
"@prosopo/util": "3.3.3",
|
|
40
40
|
"@prosopo/util-crypto": "13.5.30",
|
|
41
41
|
"@prosopo/widget-skeleton": "2.8.4",
|
|
@@ -46,6 +46,15 @@ const Procaptcha = (props: ProcaptchaProps) => {
|
|
|
46
46
|
() => hpRef.current?.value || undefined,
|
|
47
47
|
),
|
|
48
48
|
);
|
|
49
|
+
// Coordinates of the last `manager.start(x, y)` invocation from this widget
|
|
50
|
+
// instance — either the checkbox click, or a `startCoords` handoff from a
|
|
51
|
+
// prior `onSessionInvalidated` cycle. Held in a ref so the current values
|
|
52
|
+
// survive re-renders and are readable from the `state.error` effect.
|
|
53
|
+
const lastCoordsRef = useRef<{ x: number; y: number } | null>(null);
|
|
54
|
+
// One-shot guard: a widget instance only escalates a single NO_SESSION_FOUND
|
|
55
|
+
// to `onSessionInvalidated`. If the retry also fails, we fall through to
|
|
56
|
+
// the pre-existing `frictionlessState.restart()` path instead of looping.
|
|
57
|
+
const sessionInvalidatedFiredRef = useRef(false);
|
|
49
58
|
|
|
50
59
|
useEffect(() => {
|
|
51
60
|
if (config.language) {
|
|
@@ -63,15 +72,37 @@ const Procaptcha = (props: ProcaptchaProps) => {
|
|
|
63
72
|
}, [i18n, config.language]);
|
|
64
73
|
|
|
65
74
|
useEffect(() => {
|
|
66
|
-
if (
|
|
75
|
+
if (!props.autoStart) return;
|
|
76
|
+
setLoading(true);
|
|
77
|
+
const coords = props.startCoords;
|
|
78
|
+
lastCoordsRef.current = coords ?? null;
|
|
79
|
+
manager.current.start(coords?.x ?? 0, coords?.y ?? 0).finally(() => {
|
|
67
80
|
setLoading(false);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
});
|
|
82
|
+
}, [props.autoStart, props.startCoords]);
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (!state.error) return;
|
|
86
|
+
setLoading(false);
|
|
87
|
+
if (state.error.key !== "CAPTCHA.NO_SESSION_FOUND") return;
|
|
88
|
+
if (props.onSessionInvalidated && !sessionInvalidatedFiredRef.current) {
|
|
89
|
+
// Preserve the checkbox coords across the retry so the resumed
|
|
90
|
+
// submit still carries the real entry-point telemetry. The
|
|
91
|
+
// frictionless wrapper mints a fresh session and re-mounts this
|
|
92
|
+
// widget with matching `autoStart` + `startCoords`.
|
|
93
|
+
sessionInvalidatedFiredRef.current = true;
|
|
94
|
+
const coords = lastCoordsRef.current;
|
|
95
|
+
props.onSessionInvalidated(coords?.x, coords?.y);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (frictionlessState) {
|
|
99
|
+
// Fallback for widgets not mounted under a recovery-aware parent,
|
|
100
|
+
// or a second NO_SESSION_FOUND after we've already retried once.
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
frictionlessState.restart();
|
|
103
|
+
}, 100);
|
|
73
104
|
}
|
|
74
|
-
}, [state.error, frictionlessState]);
|
|
105
|
+
}, [state.error, frictionlessState, props.onSessionInvalidated]);
|
|
75
106
|
|
|
76
107
|
// Add event listener for the execute event (works for invisible mode)
|
|
77
108
|
useEffect(() => {
|
|
@@ -149,6 +180,7 @@ const Procaptcha = (props: ProcaptchaProps) => {
|
|
|
149
180
|
y = mouseOrTouchEvent.clientY;
|
|
150
181
|
}
|
|
151
182
|
|
|
183
|
+
lastCoordsRef.current = { x, y };
|
|
152
184
|
await manager.current.start(x, y);
|
|
153
185
|
setLoading(false);
|
|
154
186
|
}}
|