@prosopo/procaptcha-frictionless 2.12.7 → 2.12.10
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 +4 -4
- package/.turbo/turbo-build$colon$tsc.log +25 -25
- package/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +50 -0
- package/dist/ProcaptchaFrictionless.d.ts.map +1 -1
- package/dist/ProcaptchaFrictionless.js +3 -1
- package/dist/ProcaptchaFrictionless.js.map +1 -1
- package/dist/cjs/ProcaptchaFrictionless.cjs +3 -1
- package/dist/cjs/customDetectBot.cjs +28 -6
- package/dist/customDetectBot.d.ts.map +1 -1
- package/dist/customDetectBot.js +28 -6
- package/dist/customDetectBot.js.map +1 -1
- package/package.json +8 -8
- package/src/ProcaptchaFrictionless.tsx +6 -1
- package/src/customDetectBot.ts +54 -8
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.12.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.12.10 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -61,6 +61,6 @@ rendering chunks...
|
|
|
61
61
|
[2mdist/cjs/[22m[36mindex.cjs [39m[1m[2m0.24 kB[22m[1m[22m
|
|
62
62
|
[2mdist/cjs/[22m[36msessionInvalidatedRecovery.cjs [39m[1m[2m0.85 kB[22m[1m[22m
|
|
63
63
|
[2mdist/cjs/[22m[36mdetectorLoader.cjs [39m[1m[2m1.37 kB[22m[1m[22m
|
|
64
|
-
[2mdist/cjs/[22m[36mcustomDetectBot.cjs [39m[1m[
|
|
65
|
-
[2mdist/cjs/[22m[36mProcaptchaFrictionless.cjs [39m[1m[2m9.
|
|
66
|
-
[32m✓ built in
|
|
64
|
+
[2mdist/cjs/[22m[36mcustomDetectBot.cjs [39m[1m[2m4.01 kB[22m[1m[22m
|
|
65
|
+
[2mdist/cjs/[22m[36mProcaptchaFrictionless.cjs [39m[1m[2m9.11 kB[22m[1m[22m
|
|
66
|
+
[32m✓ built in 135ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.12.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.12.10 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
8:57:20 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:57:20 AM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
8:57:20 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:57:20 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:57:20 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:57:20 AM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/provider/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
8:57:20 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:57:20 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:57:20 AM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
8:57:20 AM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
8:57:20 AM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
8:57:20 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:57:20 AM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/index.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
8:57:20 AM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/webComponent/createWidget.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
8:57:20 AM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/keyring/keyring.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
8:57:20 AM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
8:57:20 AM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/extensionLoader.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
8:57:20 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:57:20 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:57:20 AM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/tests/mocks/data/captchas.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
8:57:20 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:57:20 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:57:20 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
8:57:20 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.10 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.10 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -64,6 +64,6 @@ rendering chunks...
|
|
|
64
64
|
[2mdist/[22m[36mindex.js [39m[1m[2m0.11 kB[22m[1m[22m
|
|
65
65
|
[2mdist/[22m[36mdetectorLoader.js [39m[1m[2m0.11 kB[22m[1m[22m
|
|
66
66
|
[2mdist/[22m[36msessionInvalidatedRecovery.js [39m[1m[2m0.71 kB[22m[1m[22m
|
|
67
|
-
[2mdist/[22m[36mcustomDetectBot.js [39m[1m[2m3.
|
|
68
|
-
[2mdist/[22m[36mProcaptchaFrictionless.js [39m[1m[2m7.
|
|
69
|
-
[32m✓ built in
|
|
67
|
+
[2mdist/[22m[36mcustomDetectBot.js [39m[1m[2m3.83 kB[22m[1m[22m
|
|
68
|
+
[2mdist/[22m[36mProcaptchaFrictionless.js [39m[1m[2m7.67 kB[22m[1m[22m
|
|
69
|
+
[32m✓ built in 196ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# @prosopo/procaptcha-frictionless
|
|
2
2
|
|
|
3
|
+
## 2.12.10
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- Updated dependencies [8bde5df]
|
|
7
|
+
- @prosopo/types@4.9.7
|
|
8
|
+
- @prosopo/api@3.5.14
|
|
9
|
+
- @prosopo/detector@3.5.8
|
|
10
|
+
- @prosopo/procaptcha-common@2.11.8
|
|
11
|
+
- @prosopo/procaptcha-pow@2.10.14
|
|
12
|
+
- @prosopo/procaptcha-puzzle@2.10.29
|
|
13
|
+
- @prosopo/procaptcha-react@2.9.87
|
|
14
|
+
|
|
15
|
+
## 2.12.9
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 35d2784: Report the top-frame URL as `currentUrl` when the widget runs inside an iframe.
|
|
19
|
+
|
|
20
|
+
Previously the frictionless client always sent `window.location.origin + pathname`, which is the iframe's own URL — so every session loaded through Protect's site-wide iframe (`protect.<tenant>.live/...`) reported the same widget endpoint regardless of which page the user was actually on. Downstream detectors (HEAD_HASH_OUTLIER's proxy-pool signal in particular) then saw diverse-geography traffic on one URL+UA fingerprint and treated our own iframe as a bot cluster.
|
|
21
|
+
|
|
22
|
+
Resolution order for `currentUrl`:
|
|
23
|
+
1. Top window → local `location.href` (widget is the top frame).
|
|
24
|
+
2. Same-origin iframe → `window.top.location.href`.
|
|
25
|
+
3. Cross-origin iframe → `document.referrer` (browser fills it subject to Referrer-Policy).
|
|
26
|
+
4. Fallback → the iframe's own `location.href` so the field is never empty.
|
|
27
|
+
|
|
28
|
+
Origin+path sanitisation is preserved across all paths — the query string, fragment and any embedded credentials are still stripped before the URL leaves the browser.
|
|
29
|
+
|
|
30
|
+
## 2.12.8
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- b3f351b: fix(procaptcha): random provider re-selection + backoff on error fallback
|
|
34
|
+
|
|
35
|
+
When a provider errored, the widget retried the same DNS-routed endpoint immediately and in a tight loop. A fleet of widgets whose provider was unhealthy could therefore accidentally DDoS the provider fleet — retrying the same (possibly-down) endpoint as fast as the event loop allowed.
|
|
36
|
+
|
|
37
|
+
The error-fallback path now:
|
|
38
|
+
|
|
39
|
+
- **Re-selects a different provider on retry.** The first attempt still hits the DNS-routed endpoint (unchanged happy path, preserves session stickiness). On a retry the widget picks a random provider straight from the provider list (`getRandomProviderFromList`), weighted by provider capacity and excluding the URL that just failed. In development the list holds only the single local provider, so a retry simply re-targets that provider.
|
|
40
|
+
- **Backs off between retries.** `providerRetry` now waits an exponential-backoff-with-full-jitter delay (0.5s → 1s → 2s → 4s …, capped at 10s) before retrying, so a down provider is no longer hammered and a fleet of clients that all errored at once don't reconverge into a thundering herd.
|
|
41
|
+
|
|
42
|
+
Applies to the image, PoW and puzzle managers and the frictionless detection flow. New shared `ProviderSelectRetryContext` type; `BotDetectionFunction` gains an optional retry-context argument.
|
|
43
|
+
- Updated dependencies [b3f351b]
|
|
44
|
+
- Updated dependencies [17bc76e]
|
|
45
|
+
- @prosopo/procaptcha-common@2.11.7
|
|
46
|
+
- @prosopo/procaptcha-puzzle@2.10.28
|
|
47
|
+
- @prosopo/procaptcha-pow@2.10.13
|
|
48
|
+
- @prosopo/types@4.9.6
|
|
49
|
+
- @prosopo/procaptcha-react@2.9.86
|
|
50
|
+
- @prosopo/api@3.5.13
|
|
51
|
+
- @prosopo/detector@3.5.7
|
|
52
|
+
|
|
3
53
|
## 2.12.7
|
|
4
54
|
### Patch Changes
|
|
5
55
|
|
|
@@ -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;AA0DxB,eAAO,MAAM,sBAAsB,gEAOhC,2BAA2B,
|
|
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,4CAkR7B,CAAC"}
|
|
@@ -185,7 +185,9 @@ const ProcaptchaFrictionless = ({
|
|
|
185
185
|
async () => {
|
|
186
186
|
stateRef.current.attemptCount += 1;
|
|
187
187
|
const configOutput = ProcaptchaConfigSchema.parse(config);
|
|
188
|
-
const result = await detectBot(configOutput, container, restart
|
|
188
|
+
const result = await detectBot(configOutput, container, restart, {
|
|
189
|
+
attempt: stateRef.current.attemptCount
|
|
190
|
+
});
|
|
189
191
|
if (result.error?.message) {
|
|
190
192
|
stateRef.current = {
|
|
191
193
|
...stateRef.current,
|
|
@@ -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,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAEN,sBAAsB,EACtB,wBAAwB,GACxB,MAAM,iCAAiC,CAAC;AAGzC,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE,CACnC,CAAC,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC,CAAC,UAAU,CAAC;AACxD,MAAM,sBAAsB,GAAG,KAAK,IAAI,EAAE,CACzC,CAAC,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC,CAAC,gBAAgB,CAAC;AAC/D,MAAM,mBAAmB,GAAG,KAAK,IAAI,EAAE,CACtC,CAAC,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,aAAa,CAAC;AAEzD,MAAM,iBAAiB,GAAG,CACzB,KAAyB,EACzB,IAAc,EACd,YAAgC,EAChC,mBAA4B,EAC5B,aAAsC,EACtC,OAAgB,EACf,EAAE;IACH,MAAM,aAAa,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAEjE,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;I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AAC;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"}
|
|
@@ -209,7 +209,9 @@ const ProcaptchaFrictionless = ({
|
|
|
209
209
|
async () => {
|
|
210
210
|
stateRef.current.attemptCount += 1;
|
|
211
211
|
const configOutput = types.ProcaptchaConfigSchema.parse(config);
|
|
212
|
-
const result = await detectBot(configOutput, container, restart
|
|
212
|
+
const result = await detectBot(configOutput, container, restart, {
|
|
213
|
+
attempt: stateRef.current.attemptCount
|
|
214
|
+
});
|
|
213
215
|
if (result.error?.message) {
|
|
214
216
|
stateRef.current = {
|
|
215
217
|
...stateRef.current,
|
|
@@ -4,15 +4,36 @@ const api = require("@prosopo/api");
|
|
|
4
4
|
const common = require("@prosopo/common");
|
|
5
5
|
const procaptchaCommon = require("@prosopo/procaptcha-common");
|
|
6
6
|
const detectorLoader = require("./detectorLoader.cjs");
|
|
7
|
+
const sanitiseHref = (href) => {
|
|
8
|
+
try {
|
|
9
|
+
const u = new URL(href);
|
|
10
|
+
if (!u.origin || u.origin === "null") return void 0;
|
|
11
|
+
return `${u.origin}${u.pathname || ""}`;
|
|
12
|
+
} catch {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
7
16
|
const getCurrentPageUrl = () => {
|
|
8
17
|
if (typeof window === "undefined" || !window.location) {
|
|
9
18
|
return void 0;
|
|
10
19
|
}
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
return void 0;
|
|
20
|
+
const local = (() => {
|
|
21
|
+
const { origin, pathname } = window.location;
|
|
22
|
+
if (!origin || origin === "null") return void 0;
|
|
23
|
+
return `${origin}${pathname || ""}`;
|
|
24
|
+
})();
|
|
25
|
+
if (window === window.top) return local;
|
|
26
|
+
try {
|
|
27
|
+
const topHref = window.top?.location?.href;
|
|
28
|
+
const sanitised = topHref ? sanitiseHref(topHref) : void 0;
|
|
29
|
+
if (sanitised) return sanitised;
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
if (typeof document !== "undefined" && document.referrer) {
|
|
33
|
+
const fromReferrer = sanitiseHref(document.referrer);
|
|
34
|
+
if (fromReferrer) return fromReferrer;
|
|
14
35
|
}
|
|
15
|
-
return
|
|
36
|
+
return local;
|
|
16
37
|
};
|
|
17
38
|
const withTimeout = async (promise, ms) => {
|
|
18
39
|
let timeoutId;
|
|
@@ -34,7 +55,7 @@ const withTimeout = async (promise, ms) => {
|
|
|
34
55
|
throw error;
|
|
35
56
|
}
|
|
36
57
|
};
|
|
37
|
-
const customDetectBot = async (config, container, restartFn) => {
|
|
58
|
+
const customDetectBot = async (config, container, restartFn, retryContext) => {
|
|
38
59
|
const [ExtClass, detect] = await Promise.all([
|
|
39
60
|
procaptchaCommon.ExtensionLoader(config.web2),
|
|
40
61
|
detectorLoader.DetectorLoader()
|
|
@@ -53,7 +74,8 @@ const customDetectBot = async (config, container, restartFn) => {
|
|
|
53
74
|
}
|
|
54
75
|
const provider = await procaptchaCommon.getProcaptchaRandomActiveProvider(
|
|
55
76
|
config.defaultEnvironment,
|
|
56
|
-
procaptchaCommon.pickIpMode(config)
|
|
77
|
+
procaptchaCommon.pickIpMode(config),
|
|
78
|
+
retryContext
|
|
57
79
|
);
|
|
58
80
|
const providerApi = new api.ProviderApi(
|
|
59
81
|
provider.provider.url,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customDetectBot.d.ts","sourceRoot":"","sources":["../src/customDetectBot.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACX,oBAAoB,
|
|
1
|
+
{"version":3,"file":"customDetectBot.d.ts","sourceRoot":"","sources":["../src/customDetectBot.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACX,oBAAoB,EAGpB,MAAM,gBAAgB,CAAC;AA8DxB,eAAO,MAAM,WAAW,GAAU,CAAC,WACzB,OAAO,CAAC,CAAC,CAAC,MACf,MAAM,KACR,OAAO,CAAC,CAAC,CAoBX,CAAC;AAEF,QAAA,MAAM,eAAe,EAAE,oBAwGtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/dist/customDetectBot.js
CHANGED
|
@@ -2,15 +2,36 @@ import { ProviderApi } from "@prosopo/api";
|
|
|
2
2
|
import { ProsopoEnvError } from "@prosopo/common";
|
|
3
3
|
import { ExtensionLoader, getProcaptchaRandomActiveProvider, pickIpMode } from "@prosopo/procaptcha-common";
|
|
4
4
|
import { DetectorLoader } from "./detectorLoader.js";
|
|
5
|
+
const sanitiseHref = (href) => {
|
|
6
|
+
try {
|
|
7
|
+
const u = new URL(href);
|
|
8
|
+
if (!u.origin || u.origin === "null") return void 0;
|
|
9
|
+
return `${u.origin}${u.pathname || ""}`;
|
|
10
|
+
} catch {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
5
14
|
const getCurrentPageUrl = () => {
|
|
6
15
|
if (typeof window === "undefined" || !window.location) {
|
|
7
16
|
return void 0;
|
|
8
17
|
}
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
return void 0;
|
|
18
|
+
const local = (() => {
|
|
19
|
+
const { origin, pathname } = window.location;
|
|
20
|
+
if (!origin || origin === "null") return void 0;
|
|
21
|
+
return `${origin}${pathname || ""}`;
|
|
22
|
+
})();
|
|
23
|
+
if (window === window.top) return local;
|
|
24
|
+
try {
|
|
25
|
+
const topHref = window.top?.location?.href;
|
|
26
|
+
const sanitised = topHref ? sanitiseHref(topHref) : void 0;
|
|
27
|
+
if (sanitised) return sanitised;
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
if (typeof document !== "undefined" && document.referrer) {
|
|
31
|
+
const fromReferrer = sanitiseHref(document.referrer);
|
|
32
|
+
if (fromReferrer) return fromReferrer;
|
|
12
33
|
}
|
|
13
|
-
return
|
|
34
|
+
return local;
|
|
14
35
|
};
|
|
15
36
|
const withTimeout = async (promise, ms) => {
|
|
16
37
|
let timeoutId;
|
|
@@ -32,7 +53,7 @@ const withTimeout = async (promise, ms) => {
|
|
|
32
53
|
throw error;
|
|
33
54
|
}
|
|
34
55
|
};
|
|
35
|
-
const customDetectBot = async (config, container, restartFn) => {
|
|
56
|
+
const customDetectBot = async (config, container, restartFn, retryContext) => {
|
|
36
57
|
const [ExtClass, detect] = await Promise.all([
|
|
37
58
|
ExtensionLoader(config.web2),
|
|
38
59
|
DetectorLoader()
|
|
@@ -51,7 +72,8 @@ const customDetectBot = async (config, container, restartFn) => {
|
|
|
51
72
|
}
|
|
52
73
|
const provider = await getProcaptchaRandomActiveProvider(
|
|
53
74
|
config.defaultEnvironment,
|
|
54
|
-
pickIpMode(config)
|
|
75
|
+
pickIpMode(config),
|
|
76
|
+
retryContext
|
|
55
77
|
);
|
|
56
78
|
const providerApi = new ProviderApi(
|
|
57
79
|
provider.provider.url,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customDetectBot.js","sourceRoot":"","sources":["../src/customDetectBot.ts"],"names":[],"mappings":"A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;AAEF,eAAe,eAAe,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.10",
|
|
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.14",
|
|
34
34
|
"@prosopo/common": "3.1.43",
|
|
35
|
-
"@prosopo/detector": "3.5.
|
|
35
|
+
"@prosopo/detector": "3.5.8",
|
|
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.8",
|
|
38
|
+
"@prosopo/procaptcha-pow": "2.10.14",
|
|
39
|
+
"@prosopo/procaptcha-puzzle": "2.10.29",
|
|
40
|
+
"@prosopo/procaptcha-react": "2.9.87",
|
|
41
|
+
"@prosopo/types": "4.9.7",
|
|
42
42
|
"@prosopo/widget-skeleton": "2.8.4",
|
|
43
43
|
"dotenv": "16.4.5",
|
|
44
44
|
"react": "18.3.1"
|
|
@@ -280,7 +280,12 @@ export const ProcaptchaFrictionless = ({
|
|
|
280
280
|
stateRef.current.attemptCount += 1;
|
|
281
281
|
|
|
282
282
|
const configOutput = ProcaptchaConfigSchema.parse(config);
|
|
283
|
-
|
|
283
|
+
// After the first attempt, tell detection this is a retry so it
|
|
284
|
+
// re-selects a random provider from the list rather than re-using
|
|
285
|
+
// the DNS-routed pronode that just failed.
|
|
286
|
+
const result = await detectBot(configOutput, container, restart, {
|
|
287
|
+
attempt: stateRef.current.attemptCount,
|
|
288
|
+
});
|
|
284
289
|
|
|
285
290
|
if (result.error?.message) {
|
|
286
291
|
stateRef.current = {
|
package/src/customDetectBot.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import type {
|
|
23
23
|
BotDetectionFunction,
|
|
24
24
|
ProcaptchaClientConfigOutput,
|
|
25
|
+
ProviderSelectRetryContext,
|
|
25
26
|
} from "@prosopo/types";
|
|
26
27
|
import type { BotDetectionFunctionResult } from "@prosopo/types";
|
|
27
28
|
import { DetectorLoader } from "./detectorLoader.js";
|
|
@@ -33,15 +34,55 @@ import { DetectorLoader } from "./detectorLoader.js";
|
|
|
33
34
|
// Returns undefined in non-browser contexts (SSR / tests) or for opaque
|
|
34
35
|
// origins; the provider then treats the session as having no page URL and
|
|
35
36
|
// forces an image captcha.
|
|
37
|
+
//
|
|
38
|
+
// When we're loaded inside an iframe (Protect's site-wide embed) the local
|
|
39
|
+
// `window.location` is the iframe URL, which conveys nothing about the page
|
|
40
|
+
// the user is actually on — every session across the tenant ends up
|
|
41
|
+
// reporting the same widget endpoint. Same-origin iframes let us read the
|
|
42
|
+
// top frame directly; cross-origin iframes fall through to `document.referrer`,
|
|
43
|
+
// which the browser fills with the embedding page URL subject to
|
|
44
|
+
// Referrer-Policy. Only when both are unavailable do we fall back to the
|
|
45
|
+
// iframe's own URL, matching the previous behaviour.
|
|
46
|
+
const sanitiseHref = (href: string): string | undefined => {
|
|
47
|
+
try {
|
|
48
|
+
const u = new URL(href);
|
|
49
|
+
if (!u.origin || u.origin === "null") return undefined;
|
|
50
|
+
return `${u.origin}${u.pathname || ""}`;
|
|
51
|
+
} catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
36
56
|
const getCurrentPageUrl = (): string | undefined => {
|
|
37
57
|
if (typeof window === "undefined" || !window.location) {
|
|
38
58
|
return undefined;
|
|
39
59
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
return undefined;
|
|
60
|
+
const local = (() => {
|
|
61
|
+
const { origin, pathname } = window.location;
|
|
62
|
+
if (!origin || origin === "null") return undefined;
|
|
63
|
+
return `${origin}${pathname || ""}`;
|
|
64
|
+
})();
|
|
65
|
+
|
|
66
|
+
// Top window — the iframe path doesn't apply.
|
|
67
|
+
if (window === window.top) return local;
|
|
68
|
+
|
|
69
|
+
// Same-origin iframe — read the top URL directly.
|
|
70
|
+
try {
|
|
71
|
+
const topHref = window.top?.location?.href;
|
|
72
|
+
const sanitised = topHref ? sanitiseHref(topHref) : undefined;
|
|
73
|
+
if (sanitised) return sanitised;
|
|
74
|
+
} catch {
|
|
75
|
+
/* cross-origin — fall through */
|
|
43
76
|
}
|
|
44
|
-
|
|
77
|
+
|
|
78
|
+
// Cross-origin iframe — the embedding page URL comes via referrer,
|
|
79
|
+
// subject to the parent's Referrer-Policy header.
|
|
80
|
+
if (typeof document !== "undefined" && document.referrer) {
|
|
81
|
+
const fromReferrer = sanitiseHref(document.referrer);
|
|
82
|
+
if (fromReferrer) return fromReferrer;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return local;
|
|
45
86
|
};
|
|
46
87
|
|
|
47
88
|
export const withTimeout = async <T>(
|
|
@@ -73,6 +114,7 @@ const customDetectBot: BotDetectionFunction = async (
|
|
|
73
114
|
config: ProcaptchaClientConfigOutput,
|
|
74
115
|
container: HTMLElement | undefined,
|
|
75
116
|
restartFn: () => void,
|
|
117
|
+
retryContext?: ProviderSelectRetryContext,
|
|
76
118
|
): Promise<BotDetectionFunctionResult> => {
|
|
77
119
|
const [ExtClass, detect] = await Promise.all([
|
|
78
120
|
ExtensionLoader(config.web2),
|
|
@@ -99,13 +141,17 @@ const customDetectBot: BotDetectionFunction = async (
|
|
|
99
141
|
throw new ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
|
|
100
142
|
}
|
|
101
143
|
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
//
|
|
144
|
+
// On the first attempt this resolves the static DNS endpoint for this env —
|
|
145
|
+
// the DNS layer load-balances across the pronode fleet. On a retry
|
|
146
|
+
// (`retryContext.attempt > 1`) the previously used pronode errored, so we
|
|
147
|
+
// pick a random provider straight from the list instead of re-pinning the
|
|
148
|
+
// same one. `pickIpMode(config)` honours the dapp's data-ipv4 / data-ipv6
|
|
149
|
+
// preference so frictionless and the subsequent captcha hops stay on the
|
|
150
|
+
// same stack.
|
|
106
151
|
const provider = await getProcaptchaRandomActiveProvider(
|
|
107
152
|
config.defaultEnvironment,
|
|
108
153
|
pickIpMode(config),
|
|
154
|
+
retryContext,
|
|
109
155
|
);
|
|
110
156
|
|
|
111
157
|
const providerApi = new ProviderApi(
|