@prosopo/procaptcha-frictionless 2.12.3 → 2.12.5
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 +8 -7
- package/.turbo/turbo-build$colon$tsc.log +25 -25
- package/.turbo/turbo-build.log +9 -8
- package/CHANGELOG.md +33 -0
- package/dist/ProcaptchaFrictionless.d.ts.map +1 -1
- package/dist/ProcaptchaFrictionless.js +34 -8
- package/dist/ProcaptchaFrictionless.js.map +1 -1
- package/dist/cjs/ProcaptchaFrictionless.cjs +34 -8
- package/dist/cjs/sessionInvalidatedRecovery.cjs +20 -0
- package/dist/sessionInvalidatedRecovery.d.ts +15 -0
- package/dist/sessionInvalidatedRecovery.d.ts.map +1 -0
- package/dist/sessionInvalidatedRecovery.js +20 -0
- package/dist/sessionInvalidatedRecovery.js.map +1 -0
- package/dist/tests/sessionInvalidatedRecovery.test.d.ts +2 -0
- package/dist/tests/sessionInvalidatedRecovery.test.d.ts.map +1 -0
- package/dist/tests/sessionInvalidatedRecovery.test.js +74 -0
- package/dist/tests/sessionInvalidatedRecovery.test.js.map +1 -0
- package/package.json +8 -8
- package/src/ProcaptchaFrictionless.tsx +79 -9
- package/src/sessionInvalidatedRecovery.ts +78 -0
- package/src/tests/sessionInvalidatedRecovery.test.ts +129 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.12.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.12.5 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -55,11 +55,12 @@ ViteCommonJSConfig: .
|
|
|
55
55
|
Bundle build started
|
|
56
56
|
transforming...
|
|
57
57
|
Build end
|
|
58
|
-
[32m✓[39m
|
|
58
|
+
[32m✓[39m 5 modules transformed.
|
|
59
59
|
[33mEntry module "src/customDetectBot.ts" is using named and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.[39m
|
|
60
60
|
rendering chunks...
|
|
61
|
-
[2mdist/cjs/[22m[36mindex.cjs
|
|
62
|
-
[2mdist/cjs/[22m[
|
|
63
|
-
[2mdist/cjs/[22m[
|
|
64
|
-
[2mdist/cjs/[22m[
|
|
65
|
-
[
|
|
61
|
+
[2mdist/cjs/[22m[36mindex.cjs [39m[1m[2m0.24 kB[22m[1m[22m
|
|
62
|
+
[2mdist/cjs/[22m[36msessionInvalidatedRecovery.cjs [39m[1m[2m0.85 kB[22m[1m[22m
|
|
63
|
+
[2mdist/cjs/[22m[36mdetectorLoader.cjs [39m[1m[2m1.37 kB[22m[1m[22m
|
|
64
|
+
[2mdist/cjs/[22m[36mcustomDetectBot.cjs [39m[1m[2m3.34 kB[22m[1m[22m
|
|
65
|
+
[2mdist/cjs/[22m[36mProcaptchaFrictionless.cjs [39m[1m[2m9.05 kB[22m[1m[22m
|
|
66
|
+
[32m✓ built in 195ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.12.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.12.5 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
8:44:46 AM - Projects in this build:
|
|
6
6
|
* ../../dev/config/tsconfig.json
|
|
7
7
|
* ../locale/tsconfig.json
|
|
8
8
|
* ../util/tsconfig.json
|
|
@@ -26,49 +26,49 @@
|
|
|
26
26
|
* ../procaptcha-react/tsconfig.json
|
|
27
27
|
* tsconfig.json
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
8:44:46 AM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/vite/vite.frontend.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
8:44:46 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
8:44:46 AM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
8:44:46 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'
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
8:44:46 AM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/procaptcha/utils.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
8:44:46 AM - Project '../detector/tsconfig.json' is up to date because newest input '../detector/src/index.js' is older than output '../detector/tsconfig.tsbuildinfo'
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
8:44:46 AM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
8:44:46 AM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/logger.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
8:44:46 AM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/utils/batches.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
8:44:46 AM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/sources/timezone.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
8:44:46 AM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
8:44:46 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'
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
8:44:46 AM - 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'
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
8:44:46 AM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/index.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
8:44:46 AM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/workers/index.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
8:44:46 AM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/tests/form.test.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
8:44:46 AM - Project '../procaptcha-pow/tsconfig.json' is up to date because newest input '../procaptcha-pow/src/index.ts' is older than output '../procaptcha-pow/tsconfig.tsbuildinfo'
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
8:44:46 AM - Project '../procaptcha-puzzle/tsconfig.json' is up to date because newest input '../procaptcha-puzzle/src/index.ts' is older than output '../procaptcha-puzzle/tsconfig.tsbuildinfo'
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
8:44:46 AM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/index.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
8:44:46 AM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/index.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
8:44:46 AM - Project '../procaptcha-react/tsconfig.json' is up to date because newest input '../procaptcha-react/src/index.ts' is older than output '../procaptcha-react/tsconfig.tsbuildinfo'
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
8:44:46 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
8:44:46 AM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-frictionless/tsconfig.json'...
|
|
74
74
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.12.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.12.5 build
|
|
3
3
|
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @prosopo/procaptcha-frictionless@2.12.
|
|
6
|
+
> @prosopo/procaptcha-frictionless@2.12.5 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -59,10 +59,11 @@ ViteEsmConfig: .
|
|
|
59
59
|
Bundle build started
|
|
60
60
|
transforming...
|
|
61
61
|
Build end
|
|
62
|
-
[32m✓[39m
|
|
62
|
+
[32m✓[39m 5 modules transformed.
|
|
63
63
|
rendering chunks...
|
|
64
|
-
[2mdist/[22m[36mindex.js
|
|
65
|
-
[2mdist/[22m[36mdetectorLoader.js
|
|
66
|
-
[2mdist/[22m[
|
|
67
|
-
[2mdist/[22m[
|
|
68
|
-
[
|
|
64
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m0.11 kB[22m[1m[22m
|
|
65
|
+
[2mdist/[22m[36mdetectorLoader.js [39m[1m[2m0.11 kB[22m[1m[22m
|
|
66
|
+
[2mdist/[22m[36msessionInvalidatedRecovery.js [39m[1m[2m0.71 kB[22m[1m[22m
|
|
67
|
+
[2mdist/[22m[36mcustomDetectBot.js [39m[1m[2m3.16 kB[22m[1m[22m
|
|
68
|
+
[2mdist/[22m[36mProcaptchaFrictionless.js [39m[1m[2m7.60 kB[22m[1m[22m
|
|
69
|
+
[32m✓ built in 204ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @prosopo/procaptcha-frictionless
|
|
2
2
|
|
|
3
|
+
## 2.12.5
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- 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)`.
|
|
7
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
- `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()`.
|
|
11
|
+
- `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.
|
|
12
|
+
- `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.
|
|
13
|
+
- 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.
|
|
14
|
+
- Updated dependencies [18d0287]
|
|
15
|
+
- @prosopo/types@4.9.3
|
|
16
|
+
- @prosopo/procaptcha-pow@2.10.10
|
|
17
|
+
- @prosopo/procaptcha-puzzle@2.10.25
|
|
18
|
+
- @prosopo/procaptcha-react@2.9.83
|
|
19
|
+
- @prosopo/api@3.5.10
|
|
20
|
+
- @prosopo/detector@3.5.4
|
|
21
|
+
- @prosopo/procaptcha-common@2.11.4
|
|
22
|
+
|
|
23
|
+
## 2.12.4
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 8814425: fix(api,procaptcha-frictionless): collapse the WKWebView "No session found" mount storm. Two independent client-side amplifiers were stacking to produce a cascade of `CAPTCHA.NO_SESSION_FOUND` errors during the frictionless → PoW hand-off in iPhone WKWebView.
|
|
27
|
+
|
|
28
|
+
- `ProcaptchaFrictionless`'s outer `useEffect` depended on `[config, callbacks, detectBot, config.language]`. Host pages that recreate the `callbacks` object on every render (the common React pattern) refired the effect on each parent re-render and triggered a fresh `/frictionless` call each time. Deps are now the primitive widget identity (`config.account?.address`, `config.language`, `config.mode`) plus a `startedForKeyRef` guard, so React StrictMode double-invocation and same-identity re-renders are idempotent. `callbacks` and `detectBot` are still read live via the closure captured by `start()`.
|
|
29
|
+
- `ProviderApi` had no in-flight guard on the three challenge-fetch calls, so a WKWebView duplicate POST (microseconds-apart) would race for the atomic `checkAndRemoveSession` on the same sessionId; the loser saw `NO_SESSION_FOUND`. A per-`(path, sessionId)` in-flight dedupe now attaches duplicate calls to the same Promise. Entry drops on settle, so a genuine retry after a real network error still fires a fresh POST; skipped when there's no sessionId to race on.
|
|
30
|
+
- Updated dependencies [8814425]
|
|
31
|
+
- @prosopo/api@3.5.9
|
|
32
|
+
- @prosopo/procaptcha-pow@2.10.9
|
|
33
|
+
- @prosopo/procaptcha-puzzle@2.10.24
|
|
34
|
+
- @prosopo/procaptcha-react@2.9.82
|
|
35
|
+
|
|
3
36
|
## 2.12.3
|
|
4
37
|
### Patch Changes
|
|
5
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaFrictionless.d.ts","sourceRoot":"","sources":["../src/ProcaptchaFrictionless.tsx"],"names":[],"mappings":"AAsBA,OAAO,EAKN,KAAK,2BAA2B,EAChC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProcaptchaFrictionless.d.ts","sourceRoot":"","sources":["../src/ProcaptchaFrictionless.tsx"],"names":[],"mappings":"AAsBA,OAAO,EAKN,KAAK,2BAA2B,EAChC,MAAM,gBAAgB,CAAC;AA0DxB,eAAO,MAAM,sBAAsB,gEAOhC,2BAA2B,4CA6Q7B,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { CaptchaType, ProcaptchaConfigSchema } from "@prosopo/types";
|
|
|
5
5
|
import { lightTheme, darkTheme } from "@prosopo/widget-skeleton";
|
|
6
6
|
import { useRef, useEffect, useState } from "react";
|
|
7
7
|
import customDetectBot from "./customDetectBot.js";
|
|
8
|
+
import { handleSessionInvalidated, consumeRetryMountProps } from "./sessionInvalidatedRecovery.js";
|
|
8
9
|
const ProcaptchaLoader = async () => (await import("@prosopo/procaptcha-react")).Procaptcha;
|
|
9
10
|
const ProcaptchaPuzzleLoader = async () => (await import("@prosopo/procaptcha-puzzle")).ProcaptchaPuzzle;
|
|
10
11
|
const ProcaptchaPowLoader = async () => (await import("@prosopo/procaptcha-pow")).ProcaptchaPow;
|
|
@@ -41,6 +42,8 @@ const ProcaptchaFrictionless = ({
|
|
|
41
42
|
}) => {
|
|
42
43
|
const stateRef = useRef(defaultLoadingState(0));
|
|
43
44
|
const events = getDefaultEvents(callbacks);
|
|
45
|
+
const pendingRetryCoordsRef = useRef(null);
|
|
46
|
+
const sessionInvalidatedFiredRef = useRef(false);
|
|
44
47
|
useEffect(() => {
|
|
45
48
|
if (config.language) {
|
|
46
49
|
if (i18n) {
|
|
@@ -105,6 +108,21 @@ const ProcaptchaFrictionless = ({
|
|
|
105
108
|
true
|
|
106
109
|
);
|
|
107
110
|
};
|
|
111
|
+
const onSessionInvalidated = (x, y) => {
|
|
112
|
+
const { shouldRestart } = handleSessionInvalidated(
|
|
113
|
+
x,
|
|
114
|
+
y,
|
|
115
|
+
sessionInvalidatedFiredRef,
|
|
116
|
+
pendingRetryCoordsRef
|
|
117
|
+
);
|
|
118
|
+
if (!shouldRestart) return;
|
|
119
|
+
resetState(0);
|
|
120
|
+
void start();
|
|
121
|
+
};
|
|
122
|
+
const { autoStart: resumedAutoStart, startCoords } = consumeRetryMountProps(
|
|
123
|
+
pendingRetryCoordsRef,
|
|
124
|
+
autoStart
|
|
125
|
+
);
|
|
108
126
|
if (captchaType === CaptchaType.image) {
|
|
109
127
|
const Procaptcha = await ProcaptchaLoader();
|
|
110
128
|
setComponentToRender(
|
|
@@ -115,7 +133,9 @@ const ProcaptchaFrictionless = ({
|
|
|
115
133
|
callbacks,
|
|
116
134
|
frictionlessState,
|
|
117
135
|
i18n,
|
|
118
|
-
autoStart
|
|
136
|
+
autoStart: resumedAutoStart,
|
|
137
|
+
startCoords,
|
|
138
|
+
onSessionInvalidated
|
|
119
139
|
}
|
|
120
140
|
)
|
|
121
141
|
);
|
|
@@ -129,7 +149,9 @@ const ProcaptchaFrictionless = ({
|
|
|
129
149
|
callbacks,
|
|
130
150
|
frictionlessState,
|
|
131
151
|
i18n,
|
|
132
|
-
autoStart
|
|
152
|
+
autoStart: resumedAutoStart,
|
|
153
|
+
startCoords,
|
|
154
|
+
onSessionInvalidated
|
|
133
155
|
}
|
|
134
156
|
)
|
|
135
157
|
);
|
|
@@ -143,7 +165,10 @@ const ProcaptchaFrictionless = ({
|
|
|
143
165
|
callbacks,
|
|
144
166
|
frictionlessState,
|
|
145
167
|
i18n,
|
|
146
|
-
onEscalate
|
|
168
|
+
onEscalate,
|
|
169
|
+
autoStart: resumedAutoStart,
|
|
170
|
+
startCoords,
|
|
171
|
+
onSessionInvalidated
|
|
147
172
|
}
|
|
148
173
|
)
|
|
149
174
|
);
|
|
@@ -202,12 +227,13 @@ const ProcaptchaFrictionless = ({
|
|
|
202
227
|
}
|
|
203
228
|
});
|
|
204
229
|
};
|
|
230
|
+
const startedForKeyRef = useRef(null);
|
|
205
231
|
useEffect(() => {
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}, [config,
|
|
232
|
+
const key = `${config.account?.address ?? ""}|${config.language ?? ""}|${config.mode ?? ""}`;
|
|
233
|
+
if (startedForKeyRef.current === key) return;
|
|
234
|
+
startedForKeyRef.current = key;
|
|
235
|
+
void start();
|
|
236
|
+
}, [config.account?.address, config.language, config.mode]);
|
|
211
237
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
212
238
|
/* @__PURE__ */ jsx(TestModeBanner, { siteKey: config.account?.address ?? "" }),
|
|
213
239
|
componentToRender
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaFrictionless.js","sourceRoot":"","sources":["../src/ProcaptchaFrictionless.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACN,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,WAAW,EAGX,sBAAsB,GAEtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OA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;gBACxC,iBAAiB,EAAE,CAAC;gBACpB,uBAAuB,EAAE,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAmBF,MAAM,gBAAgB,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IAErD,SAAS,CAAC,GAAG,EAAE;QACd,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,IAAI,MAAM,CAAC,QAAQ,IAAI,EAAE,IACpE,MAAM,CAAC,IAAI,IAAI,EAChB,EAAE,CAAC;QACH,IAAI,gBAAgB,CAAC,OAAO,KAAK,GAAG;YAAE,OAAO;QAC7C,gBAAgB,CAAC,OAAO,GAAG,GAAG,CAAC;QAC/B,KAAK,KAAK,EAAE,CAAC;IACd,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5D,OAAO,CACN,8BACC,KAAC,cAAc,IAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,GAAI,EACzD,iBAAiB,IAChB,CACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -29,6 +29,7 @@ const types = require("@prosopo/types");
|
|
|
29
29
|
const widgetSkeleton = require("@prosopo/widget-skeleton");
|
|
30
30
|
const react = require("react");
|
|
31
31
|
const customDetectBot = require("./customDetectBot.cjs");
|
|
32
|
+
const sessionInvalidatedRecovery = require("./sessionInvalidatedRecovery.cjs");
|
|
32
33
|
const ProcaptchaLoader = async () => (await import("@prosopo/procaptcha-react")).Procaptcha;
|
|
33
34
|
const ProcaptchaPuzzleLoader = async () => (await import("@prosopo/procaptcha-puzzle")).ProcaptchaPuzzle;
|
|
34
35
|
const ProcaptchaPowLoader = async () => (await import("@prosopo/procaptcha-pow")).ProcaptchaPow;
|
|
@@ -65,6 +66,8 @@ const ProcaptchaFrictionless = ({
|
|
|
65
66
|
}) => {
|
|
66
67
|
const stateRef = react.useRef(defaultLoadingState(0));
|
|
67
68
|
const events = procaptchaCommon.getDefaultEvents(callbacks);
|
|
69
|
+
const pendingRetryCoordsRef = react.useRef(null);
|
|
70
|
+
const sessionInvalidatedFiredRef = react.useRef(false);
|
|
68
71
|
react.useEffect(() => {
|
|
69
72
|
if (config.language) {
|
|
70
73
|
if (i18n) {
|
|
@@ -129,6 +132,21 @@ const ProcaptchaFrictionless = ({
|
|
|
129
132
|
true
|
|
130
133
|
);
|
|
131
134
|
};
|
|
135
|
+
const onSessionInvalidated = (x, y) => {
|
|
136
|
+
const { shouldRestart } = sessionInvalidatedRecovery.handleSessionInvalidated(
|
|
137
|
+
x,
|
|
138
|
+
y,
|
|
139
|
+
sessionInvalidatedFiredRef,
|
|
140
|
+
pendingRetryCoordsRef
|
|
141
|
+
);
|
|
142
|
+
if (!shouldRestart) return;
|
|
143
|
+
resetState(0);
|
|
144
|
+
void start();
|
|
145
|
+
};
|
|
146
|
+
const { autoStart: resumedAutoStart, startCoords } = sessionInvalidatedRecovery.consumeRetryMountProps(
|
|
147
|
+
pendingRetryCoordsRef,
|
|
148
|
+
autoStart
|
|
149
|
+
);
|
|
132
150
|
if (captchaType === types.CaptchaType.image) {
|
|
133
151
|
const Procaptcha = await ProcaptchaLoader();
|
|
134
152
|
setComponentToRender(
|
|
@@ -139,7 +157,9 @@ const ProcaptchaFrictionless = ({
|
|
|
139
157
|
callbacks,
|
|
140
158
|
frictionlessState,
|
|
141
159
|
i18n,
|
|
142
|
-
autoStart
|
|
160
|
+
autoStart: resumedAutoStart,
|
|
161
|
+
startCoords,
|
|
162
|
+
onSessionInvalidated
|
|
143
163
|
}
|
|
144
164
|
)
|
|
145
165
|
);
|
|
@@ -153,7 +173,9 @@ const ProcaptchaFrictionless = ({
|
|
|
153
173
|
callbacks,
|
|
154
174
|
frictionlessState,
|
|
155
175
|
i18n,
|
|
156
|
-
autoStart
|
|
176
|
+
autoStart: resumedAutoStart,
|
|
177
|
+
startCoords,
|
|
178
|
+
onSessionInvalidated
|
|
157
179
|
}
|
|
158
180
|
)
|
|
159
181
|
);
|
|
@@ -167,7 +189,10 @@ const ProcaptchaFrictionless = ({
|
|
|
167
189
|
callbacks,
|
|
168
190
|
frictionlessState,
|
|
169
191
|
i18n,
|
|
170
|
-
onEscalate
|
|
192
|
+
onEscalate,
|
|
193
|
+
autoStart: resumedAutoStart,
|
|
194
|
+
startCoords,
|
|
195
|
+
onSessionInvalidated
|
|
171
196
|
}
|
|
172
197
|
)
|
|
173
198
|
);
|
|
@@ -226,12 +251,13 @@ const ProcaptchaFrictionless = ({
|
|
|
226
251
|
}
|
|
227
252
|
});
|
|
228
253
|
};
|
|
254
|
+
const startedForKeyRef = react.useRef(null);
|
|
229
255
|
react.useEffect(() => {
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}, [config,
|
|
256
|
+
const key = `${config.account?.address ?? ""}|${config.language ?? ""}|${config.mode ?? ""}`;
|
|
257
|
+
if (startedForKeyRef.current === key) return;
|
|
258
|
+
startedForKeyRef.current = key;
|
|
259
|
+
void start();
|
|
260
|
+
}, [config.account?.address, config.language, config.mode]);
|
|
235
261
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
236
262
|
/* @__PURE__ */ jsxRuntime.jsx(procaptchaCommon.TestModeBanner, { siteKey: config.account?.address ?? "" }),
|
|
237
263
|
componentToRender
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const handleSessionInvalidated = (x, y, firedRef, pendingCoordsRef) => {
|
|
4
|
+
if (firedRef.current) return { shouldRestart: false };
|
|
5
|
+
firedRef.current = true;
|
|
6
|
+
const bothNumeric = typeof x === "number" && typeof y === "number";
|
|
7
|
+
const isRealClick = bothNumeric && (x !== 0 || y !== 0);
|
|
8
|
+
pendingCoordsRef.current = isRealClick ? { x, y } : null;
|
|
9
|
+
return { shouldRestart: true };
|
|
10
|
+
};
|
|
11
|
+
const consumeRetryMountProps = (pendingCoordsRef, escalationAutoStart) => {
|
|
12
|
+
const startCoords = pendingCoordsRef.current ?? void 0;
|
|
13
|
+
pendingCoordsRef.current = null;
|
|
14
|
+
return {
|
|
15
|
+
autoStart: escalationAutoStart || Boolean(startCoords),
|
|
16
|
+
startCoords
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.consumeRetryMountProps = consumeRetryMountProps;
|
|
20
|
+
exports.handleSessionInvalidated = handleSessionInvalidated;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type RetryCoords = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
};
|
|
5
|
+
export type MutableRef<T> = {
|
|
6
|
+
current: T;
|
|
7
|
+
};
|
|
8
|
+
export declare const handleSessionInvalidated: (x: number | undefined, y: number | undefined, firedRef: MutableRef<boolean>, pendingCoordsRef: MutableRef<RetryCoords | null>) => {
|
|
9
|
+
shouldRestart: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const consumeRetryMountProps: (pendingCoordsRef: MutableRef<RetryCoords | null>, escalationAutoStart: boolean) => {
|
|
12
|
+
autoStart: boolean;
|
|
13
|
+
startCoords: RetryCoords | undefined;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=sessionInvalidatedRecovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionInvalidatedRecovery.d.ts","sourceRoot":"","sources":["../src/sessionInvalidatedRecovery.ts"],"names":[],"mappings":"AAmBA,MAAM,MAAM,WAAW,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAMnD,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAmB3C,eAAO,MAAM,wBAAwB,MACjC,MAAM,GAAG,SAAS,KAClB,MAAM,GAAG,SAAS,YACX,UAAU,CAAC,OAAO,CAAC,oBACX,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,KAC9C;IAAE,aAAa,EAAE,OAAO,CAAA;CAO1B,CAAC;AAWF,eAAO,MAAM,sBAAsB,qBAChB,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,uBAC3B,OAAO,KAC1B;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,WAAW,GAAG,SAAS,CAAA;CAO5D,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const handleSessionInvalidated = (x, y, firedRef, pendingCoordsRef) => {
|
|
2
|
+
if (firedRef.current) return { shouldRestart: false };
|
|
3
|
+
firedRef.current = true;
|
|
4
|
+
const bothNumeric = typeof x === "number" && typeof y === "number";
|
|
5
|
+
const isRealClick = bothNumeric && (x !== 0 || y !== 0);
|
|
6
|
+
pendingCoordsRef.current = isRealClick ? { x, y } : null;
|
|
7
|
+
return { shouldRestart: true };
|
|
8
|
+
};
|
|
9
|
+
const consumeRetryMountProps = (pendingCoordsRef, escalationAutoStart) => {
|
|
10
|
+
const startCoords = pendingCoordsRef.current ?? void 0;
|
|
11
|
+
pendingCoordsRef.current = null;
|
|
12
|
+
return {
|
|
13
|
+
autoStart: escalationAutoStart || Boolean(startCoords),
|
|
14
|
+
startCoords
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
consumeRetryMountProps,
|
|
19
|
+
handleSessionInvalidated
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionInvalidatedRecovery.js","sourceRoot":"","sources":["../src/sessionInvalidatedRecovery.ts"],"names":[],"mappings":"AA4CA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACvC,CAAqB,EACrB,CAAqB,EACrB,QAA6B,EAC7B,gBAAgD,EACnB,EAAE;IAC/B,IAAI,QAAQ,CAAC,OAAO;QAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IACtD,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC;IACnE,MAAM,WAAW,GAAG,WAAW,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,gBAAgB,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AAChC,CAAC,CAAC;AAWF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACrC,gBAAgD,EAChD,mBAA4B,EACmC,EAAE;IACjE,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,IAAI,SAAS,CAAC;IAC1D,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC;IAChC,OAAO;QACN,SAAS,EAAE,mBAAmB,IAAI,OAAO,CAAC,WAAW,CAAC;QACtD,WAAW;KACX,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionInvalidatedRecovery.test.d.ts","sourceRoot":"","sources":["../../src/tests/sessionInvalidatedRecovery.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { consumeRetryMountProps, handleSessionInvalidated, } from "../sessionInvalidatedRecovery.js";
|
|
3
|
+
const ref = (initial) => ({ current: initial });
|
|
4
|
+
describe("handleSessionInvalidated", () => {
|
|
5
|
+
it("records both coords and signals a restart on the first fire", () => {
|
|
6
|
+
const firedRef = ref(false);
|
|
7
|
+
const coordsRef = ref(null);
|
|
8
|
+
const result = handleSessionInvalidated(120, 340, firedRef, coordsRef);
|
|
9
|
+
expect(result).toEqual({ shouldRestart: true });
|
|
10
|
+
expect(firedRef.current).toBe(true);
|
|
11
|
+
expect(coordsRef.current).toEqual({ x: 120, y: 340 });
|
|
12
|
+
});
|
|
13
|
+
it("treats (0, 0) as 'no coords' — that's the autoStart / untrusted-event default, not a real click", () => {
|
|
14
|
+
const firedRef = ref(false);
|
|
15
|
+
const coordsRef = ref(null);
|
|
16
|
+
const result = handleSessionInvalidated(0, 0, firedRef, coordsRef);
|
|
17
|
+
expect(result).toEqual({ shouldRestart: true });
|
|
18
|
+
expect(coordsRef.current).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
it("carries a real click even if only one axis is at the origin", () => {
|
|
21
|
+
const firedRef = ref(false);
|
|
22
|
+
const coordsRef = ref(null);
|
|
23
|
+
handleSessionInvalidated(0, 340, firedRef, coordsRef);
|
|
24
|
+
expect(coordsRef.current).toEqual({ x: 0, y: 340 });
|
|
25
|
+
});
|
|
26
|
+
it("stores no coords when x or y is undefined (autoStart / non-trusted event)", () => {
|
|
27
|
+
const firedRef = ref(false);
|
|
28
|
+
const coordsRef = ref(null);
|
|
29
|
+
const result = handleSessionInvalidated(undefined, undefined, firedRef, coordsRef);
|
|
30
|
+
expect(result).toEqual({ shouldRestart: true });
|
|
31
|
+
expect(firedRef.current).toBe(true);
|
|
32
|
+
expect(coordsRef.current).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
it("stores no coords when only one axis is present — never emit NaN into the salt", () => {
|
|
35
|
+
const firedRef = ref(false);
|
|
36
|
+
const coordsRef = ref(null);
|
|
37
|
+
handleSessionInvalidated(120, undefined, firedRef, coordsRef);
|
|
38
|
+
expect(coordsRef.current).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
it("is one-shot per outer widget lifetime — a second call is a no-op", () => {
|
|
41
|
+
const firedRef = ref(false);
|
|
42
|
+
const coordsRef = ref(null);
|
|
43
|
+
handleSessionInvalidated(100, 200, firedRef, coordsRef);
|
|
44
|
+
const second = handleSessionInvalidated(500, 600, firedRef, coordsRef);
|
|
45
|
+
expect(second).toEqual({ shouldRestart: false });
|
|
46
|
+
expect(coordsRef.current).toEqual({ x: 100, y: 200 });
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe("consumeRetryMountProps", () => {
|
|
50
|
+
it("returns pending retry coords and forces autoStart", () => {
|
|
51
|
+
const coordsRef = ref({ x: 42, y: 99 });
|
|
52
|
+
const mount = consumeRetryMountProps(coordsRef, false);
|
|
53
|
+
expect(mount).toEqual({
|
|
54
|
+
autoStart: true,
|
|
55
|
+
startCoords: { x: 42, y: 99 },
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
it("clears the coords ref so a subsequent render doesn't re-inject stale values", () => {
|
|
59
|
+
const coordsRef = ref({ x: 42, y: 99 });
|
|
60
|
+
consumeRetryMountProps(coordsRef, false);
|
|
61
|
+
expect(coordsRef.current).toBeNull();
|
|
62
|
+
});
|
|
63
|
+
it("propagates escalationAutoStart when no retry is pending (post-PoW escalation path)", () => {
|
|
64
|
+
const coordsRef = ref(null);
|
|
65
|
+
const mount = consumeRetryMountProps(coordsRef, true);
|
|
66
|
+
expect(mount).toEqual({ autoStart: true, startCoords: undefined });
|
|
67
|
+
});
|
|
68
|
+
it("returns autoStart=false, startCoords=undefined for the initial checkbox mount", () => {
|
|
69
|
+
const coordsRef = ref(null);
|
|
70
|
+
const mount = consumeRetryMountProps(coordsRef, false);
|
|
71
|
+
expect(mount).toEqual({ autoStart: false, startCoords: undefined });
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=sessionInvalidatedRecovery.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionInvalidatedRecovery.test.js","sourceRoot":"","sources":["../../src/tests/sessionInvalidatedRecovery.test.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;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EzC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oFAAoF,EAAE,GAAG,EAAE;QAC7F,MAAM,SAAS,GAAG,GAAG,CAAqB,IAAI,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAG,sBAAsB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAEtD,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+EAA+E,EAAE,GAAG,EAAE;QACxF,MAAM,SAAS,GAAG,GAAG,CAAqB,IAAI,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAG,sBAAsB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAEvD,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-frictionless",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.5",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
},
|
|
31
31
|
"browserslist": ["> 0.5%, last 2 versions, not dead"],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@prosopo/api": "3.5.
|
|
33
|
+
"@prosopo/api": "3.5.10",
|
|
34
34
|
"@prosopo/common": "3.1.43",
|
|
35
|
-
"@prosopo/detector": "3.5.
|
|
35
|
+
"@prosopo/detector": "3.5.4",
|
|
36
36
|
"@prosopo/locale": "3.2.6",
|
|
37
|
-
"@prosopo/procaptcha-common": "2.11.
|
|
38
|
-
"@prosopo/procaptcha-pow": "2.10.
|
|
39
|
-
"@prosopo/procaptcha-puzzle": "2.10.
|
|
40
|
-
"@prosopo/procaptcha-react": "2.9.
|
|
41
|
-
"@prosopo/types": "4.9.
|
|
37
|
+
"@prosopo/procaptcha-common": "2.11.4",
|
|
38
|
+
"@prosopo/procaptcha-pow": "2.10.10",
|
|
39
|
+
"@prosopo/procaptcha-puzzle": "2.10.25",
|
|
40
|
+
"@prosopo/procaptcha-react": "2.9.83",
|
|
41
|
+
"@prosopo/types": "4.9.3",
|
|
42
42
|
"@prosopo/widget-skeleton": "2.8.4",
|
|
43
43
|
"dotenv": "16.4.5",
|
|
44
44
|
"react": "18.3.1"
|