@prosopo/procaptcha-frictionless 2.12.20 → 2.12.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build$colon$cjs.log +13 -12
- package/.turbo/turbo-build$colon$tsc.log +25 -25
- package/.turbo/turbo-build.log +15 -12
- package/CHANGELOG.md +31 -0
- package/dist/ProcaptchaFrictionless.js +165 -236
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/ProcaptchaFrictionless.cjs +166 -259
- package/dist/cjs/customDetectBot.cjs +102 -137
- package/dist/cjs/detectorLoader.cjs +3 -25
- package/dist/cjs/index.cjs +2 -3
- package/dist/cjs/sessionInvalidatedRecovery.cjs +43 -16
- package/dist/customDetectBot.js +101 -137
- package/dist/detectorLoader.js +4 -4
- package/dist/index.js +2 -3
- package/dist/sessionInvalidatedRecovery.js +44 -18
- package/dist/tests/customDetectBotSimd.test.js +5 -3
- package/dist/tests/customDetectBotSimd.test.js.map +1 -1
- package/package.json +14 -14
- package/src/tests/customDetectBotSimd.test.ts +8 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.12.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.12.22 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -51,16 +51,17 @@ ViteCommonJSConfig: .
|
|
|
51
51
|
'@prosopo/datasets'
|
|
52
52
|
]
|
|
53
53
|
}
|
|
54
|
-
[
|
|
54
|
+
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
55
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
55
56
|
Bundle build started
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[32m✓[39m 5 modules transformed.
|
|
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
|
|
57
|
+
[2K
|
|
58
|
+
✓ 6 modules transformed.
|
|
60
59
|
rendering chunks...
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
computing gzip size...
|
|
61
|
+
dist/cjs/detectorLoader.cjs 0.16 kB │ gzip: 0.12 kB
|
|
62
|
+
dist/cjs/index.cjs 0.24 kB │ gzip: 0.15 kB
|
|
63
|
+
dist/cjs/sessionInvalidatedRecovery.cjs 2.07 kB │ gzip: 0.99 kB
|
|
64
|
+
dist/cjs/customDetectBot.cjs 4.22 kB │ gzip: 1.36 kB
|
|
65
|
+
dist/cjs/ProcaptchaFrictionless.cjs 7.00 kB │ gzip: 2.02 kB
|
|
66
|
+
|
|
67
|
+
[32m✓ built in 45ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.12.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.12.22 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
8:59:45 PM - 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:59:45 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
8:59:45 PM - 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:59:45 PM - 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:59:45 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
8:59:45 PM - 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:59:45 PM - 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:59:45 PM - 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:59:45 PM - 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:59:45 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/tests/utils/batches.unit.test.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
8:59:45 PM - 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:59:45 PM - 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:59:45 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/tests/providers.unit.test.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
8:59:45 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/index.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
8:59:45 PM - 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:59:45 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/tests/cryptoWorker.unit.test.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
8:59:45 PM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/tests/defaultEvents.test.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
8:59:45 PM - 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:59:45 PM - 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:59:45 PM - 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:59:46 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/modules/Manager.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
8:59:46 PM - 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:59:46 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
8:59:46 PM - 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.22 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.22 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -55,15 +55,18 @@ ViteEsmConfig: .
|
|
|
55
55
|
'@prosopo/datasets'
|
|
56
56
|
]
|
|
57
57
|
}
|
|
58
|
-
[
|
|
58
|
+
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
59
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
59
60
|
Bundle build started
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
[32m✓[39m 5 modules transformed.
|
|
61
|
+
[2K
|
|
62
|
+
✓ 6 modules transformed.
|
|
63
63
|
rendering chunks...
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
computing gzip size...
|
|
65
|
+
dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
|
|
66
|
+
dist/index.js 0.14 kB │ gzip: 0.10 kB
|
|
67
|
+
dist/detectorLoader.js 0.15 kB │ gzip: 0.13 kB
|
|
68
|
+
dist/sessionInvalidatedRecovery.js 2.01 kB │ gzip: 0.98 kB
|
|
69
|
+
dist/customDetectBot.js 3.97 kB │ gzip: 1.33 kB
|
|
70
|
+
dist/ProcaptchaFrictionless.js 6.49 kB │ gzip: 1.97 kB
|
|
71
|
+
|
|
72
|
+
[32m✓ built in 52ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @prosopo/procaptcha-frictionless
|
|
2
2
|
|
|
3
|
+
## 2.12.22
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- e14fce6: chore(deps): bump vite to 6.4.3 and mongoose to 8.24.1, and adjust types for the mongoose 8.24 Document/ObjectId changes
|
|
7
|
+
- Updated dependencies [ab3499c]
|
|
8
|
+
- Updated dependencies [0e1171c]
|
|
9
|
+
- Updated dependencies [103318c]
|
|
10
|
+
- Updated dependencies [270a8d8]
|
|
11
|
+
- Updated dependencies [e14fce6]
|
|
12
|
+
- @prosopo/procaptcha-common@2.11.18
|
|
13
|
+
- @prosopo/procaptcha-pow@2.10.24
|
|
14
|
+
- @prosopo/procaptcha-puzzle@2.10.40
|
|
15
|
+
- @prosopo/locale@3.2.8
|
|
16
|
+
- @prosopo/types@4.10.0
|
|
17
|
+
- @prosopo/api@3.5.20
|
|
18
|
+
- @prosopo/common@3.1.48
|
|
19
|
+
- @prosopo/detector@3.5.14
|
|
20
|
+
- @prosopo/procaptcha-react@2.9.97
|
|
21
|
+
|
|
22
|
+
## 2.12.21
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [a0cb39e]
|
|
26
|
+
- @prosopo/types@4.9.12
|
|
27
|
+
- @prosopo/api@3.5.19
|
|
28
|
+
- @prosopo/detector@3.5.13
|
|
29
|
+
- @prosopo/procaptcha-common@2.11.17
|
|
30
|
+
- @prosopo/procaptcha-pow@2.10.23
|
|
31
|
+
- @prosopo/procaptcha-puzzle@2.10.39
|
|
32
|
+
- @prosopo/procaptcha-react@2.9.96
|
|
33
|
+
|
|
3
34
|
## 2.12.20
|
|
4
35
|
### Patch Changes
|
|
5
36
|
|
|
@@ -1,241 +1,170 @@
|
|
|
1
|
-
import
|
|
1
|
+
import customDetectBot from "./customDetectBot.js";
|
|
2
|
+
import { consumeRetryMountProps, handleSessionInvalidated } from "./sessionInvalidatedRecovery.js";
|
|
2
3
|
import { loadI18next } from "@prosopo/locale";
|
|
3
|
-
import { Checkbox, getDefaultEvents, isSecureBrowserContext, providerRetry
|
|
4
|
+
import { Checkbox, TestModeBanner, getDefaultEvents, isSecureBrowserContext, providerRetry } from "@prosopo/procaptcha-common";
|
|
4
5
|
import { CaptchaType, ProcaptchaConfigSchema } from "@prosopo/types";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
labelText: isTranslationLoaded ? translationFn("WIDGET.I_AM_HUMAN") : "",
|
|
25
|
-
error: errorMessage,
|
|
26
|
-
"aria-label": "human checkbox",
|
|
27
|
-
loading
|
|
28
|
-
}
|
|
29
|
-
);
|
|
6
|
+
import { darkTheme, lightTheme } from "@prosopo/widget-skeleton";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/ProcaptchaFrictionless.tsx
|
|
10
|
+
var ProcaptchaLoader = async () => (await import("@prosopo/procaptcha-react")).Procaptcha;
|
|
11
|
+
var ProcaptchaPuzzleLoader = async () => (await import("@prosopo/procaptcha-puzzle")).ProcaptchaPuzzle;
|
|
12
|
+
var ProcaptchaPowLoader = async () => (await import("@prosopo/procaptcha-pow")).ProcaptchaPow;
|
|
13
|
+
var renderPlaceholder = (theme, mode, errorMessage, isTranslationLoaded, translationFn, loading) => {
|
|
14
|
+
const checkboxTheme = "light" === theme ? lightTheme : darkTheme;
|
|
15
|
+
if (mode === "invisible") return null;
|
|
16
|
+
return /* @__PURE__ */ jsx(Checkbox, {
|
|
17
|
+
theme: checkboxTheme,
|
|
18
|
+
onChange: async () => {},
|
|
19
|
+
checked: false,
|
|
20
|
+
labelText: isTranslationLoaded ? translationFn("WIDGET.I_AM_HUMAN") : "",
|
|
21
|
+
error: errorMessage,
|
|
22
|
+
"aria-label": "human checkbox",
|
|
23
|
+
loading
|
|
24
|
+
});
|
|
30
25
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
var defaultLoadingState = (attemptCount) => ({
|
|
27
|
+
loading: false,
|
|
28
|
+
attemptCount: attemptCount || 0
|
|
34
29
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (!isSecureBrowserContext()) {
|
|
174
|
-
const errorMessage = i18n.isInitialized ? i18n.t("WIDGET.INSECURE_CONTEXT") : "Procaptcha requires a secure (HTTPS) connection";
|
|
175
|
-
events.onError(new Error(errorMessage));
|
|
176
|
-
fallOverWithStyle(errorMessage, "WIDGET.INSECURE_CONTEXT");
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
await providerRetry(
|
|
180
|
-
async () => {
|
|
181
|
-
stateRef.current.attemptCount += 1;
|
|
182
|
-
const configOutput = ProcaptchaConfigSchema.parse(config);
|
|
183
|
-
const result = await detectBot(configOutput, container, restart, {
|
|
184
|
-
attempt: stateRef.current.attemptCount
|
|
185
|
-
});
|
|
186
|
-
if (result.error?.message) {
|
|
187
|
-
stateRef.current = {
|
|
188
|
-
...stateRef.current,
|
|
189
|
-
loading: false,
|
|
190
|
-
errorMessage: result.error?.message
|
|
191
|
-
};
|
|
192
|
-
events.onError(new Error(result.error?.message));
|
|
193
|
-
fallOverWithStyle(result.error?.message, result.error?.key);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const frictionlessState = {
|
|
197
|
-
provider: result.provider,
|
|
198
|
-
sessionId: result.sessionId,
|
|
199
|
-
userAccount: result.userAccount,
|
|
200
|
-
restart,
|
|
201
|
-
// Pass restart function
|
|
202
|
-
behaviorCollector1: result.behaviorCollector1,
|
|
203
|
-
behaviorCollector2: result.behaviorCollector2,
|
|
204
|
-
behaviorCollector3: result.behaviorCollector3,
|
|
205
|
-
deviceCapability: result.deviceCapability,
|
|
206
|
-
encryptBehavioralData: result.encryptBehavioralData,
|
|
207
|
-
getSimdReadings: result.getSimdReadings,
|
|
208
|
-
hp: result.hp
|
|
209
|
-
};
|
|
210
|
-
await renderForCaptchaType(result.captchaType, frictionlessState);
|
|
211
|
-
stateRef.current = {
|
|
212
|
-
...stateRef.current,
|
|
213
|
-
loading: false
|
|
214
|
-
};
|
|
215
|
-
},
|
|
216
|
-
start,
|
|
217
|
-
resetState,
|
|
218
|
-
stateRef.current.attemptCount,
|
|
219
|
-
5
|
|
220
|
-
).finally(() => {
|
|
221
|
-
if (stateRef.current.attemptCount >= 5) {
|
|
222
|
-
fallOverWithStyle();
|
|
223
|
-
restartComponentTimeout();
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
|
-
const startedForKeyRef = useRef(null);
|
|
228
|
-
useEffect(() => {
|
|
229
|
-
const key = `${config.account?.address ?? ""}|${config.language ?? ""}|${config.mode ?? ""}`;
|
|
230
|
-
if (startedForKeyRef.current === key) return;
|
|
231
|
-
startedForKeyRef.current = key;
|
|
232
|
-
void start();
|
|
233
|
-
}, [config.account?.address, config.language, config.mode]);
|
|
234
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
235
|
-
/* @__PURE__ */ jsx(TestModeBanner, { siteKey: config.account?.address ?? "" }),
|
|
236
|
-
componentToRender
|
|
237
|
-
] });
|
|
238
|
-
};
|
|
239
|
-
export {
|
|
240
|
-
ProcaptchaFrictionless
|
|
30
|
+
var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = customDetectBot, container }) => {
|
|
31
|
+
const stateRef = useRef(defaultLoadingState(0));
|
|
32
|
+
const events = getDefaultEvents(callbacks);
|
|
33
|
+
const pendingRetryCoordsRef = useRef(null);
|
|
34
|
+
const sessionInvalidatedFiredRef = useRef(false);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!config.language) return;
|
|
37
|
+
if (i18n) {
|
|
38
|
+
if (i18n.language !== config.language) i18n.changeLanguage(config.language);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
loadI18next(false, config.language);
|
|
42
|
+
}, [i18n, config.language]);
|
|
43
|
+
const [componentToRender, setComponentToRender] = useState(renderPlaceholder(config.theme, config.mode, stateRef.current.errorMessage, i18n.isInitialized, i18n.t, true));
|
|
44
|
+
const resetState = (attemptCount) => {
|
|
45
|
+
stateRef.current = defaultLoadingState(attemptCount || stateRef.current.attemptCount);
|
|
46
|
+
};
|
|
47
|
+
const fallOverWithStyle = (errorMessage, errorKey) => {
|
|
48
|
+
if (errorKey === "CAPTCHA.NO_SESSION_FOUND") setTimeout(() => {
|
|
49
|
+
restartComponentTimeout();
|
|
50
|
+
}, 0);
|
|
51
|
+
setComponentToRender(renderPlaceholder(config.theme, config.mode, errorMessage || "Cannot load CAPTCHA", i18n.isInitialized, i18n.t, false));
|
|
52
|
+
};
|
|
53
|
+
const restartComponentTimeout = () => {
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
resetState(0);
|
|
56
|
+
events.onReset();
|
|
57
|
+
restart();
|
|
58
|
+
}, 1e4);
|
|
59
|
+
};
|
|
60
|
+
const renderForCaptchaType = async (captchaType, frictionlessState, autoStart = false, escalationCoords) => {
|
|
61
|
+
const onEscalate = (next, newSessionId, coords) => {
|
|
62
|
+
renderForCaptchaType(next, {
|
|
63
|
+
...frictionlessState,
|
|
64
|
+
sessionId: newSessionId
|
|
65
|
+
}, true, coords);
|
|
66
|
+
};
|
|
67
|
+
const onSessionInvalidated = (x, y) => {
|
|
68
|
+
const { shouldRestart } = handleSessionInvalidated(x, y, sessionInvalidatedFiredRef, pendingRetryCoordsRef);
|
|
69
|
+
if (!shouldRestart) return;
|
|
70
|
+
resetState(0);
|
|
71
|
+
start();
|
|
72
|
+
};
|
|
73
|
+
const { autoStart: resumedAutoStart, startCoords: retryStartCoords } = consumeRetryMountProps(pendingRetryCoordsRef, autoStart);
|
|
74
|
+
const startCoords = escalationCoords ?? retryStartCoords;
|
|
75
|
+
if (captchaType === CaptchaType.image) {
|
|
76
|
+
const Procaptcha = await ProcaptchaLoader();
|
|
77
|
+
setComponentToRender(/* @__PURE__ */ jsx(Procaptcha, {
|
|
78
|
+
config,
|
|
79
|
+
callbacks,
|
|
80
|
+
frictionlessState,
|
|
81
|
+
i18n,
|
|
82
|
+
autoStart: resumedAutoStart,
|
|
83
|
+
startCoords,
|
|
84
|
+
onSessionInvalidated
|
|
85
|
+
}));
|
|
86
|
+
} else if (captchaType === CaptchaType.puzzle) {
|
|
87
|
+
const ProcaptchaPuzzle = await ProcaptchaPuzzleLoader();
|
|
88
|
+
setComponentToRender(/* @__PURE__ */ jsx(ProcaptchaPuzzle, {
|
|
89
|
+
config,
|
|
90
|
+
callbacks,
|
|
91
|
+
frictionlessState,
|
|
92
|
+
i18n,
|
|
93
|
+
autoStart: resumedAutoStart,
|
|
94
|
+
startCoords,
|
|
95
|
+
onSessionInvalidated
|
|
96
|
+
}));
|
|
97
|
+
} else {
|
|
98
|
+
const ProcaptchaPow = await ProcaptchaPowLoader();
|
|
99
|
+
setComponentToRender(/* @__PURE__ */ jsx(ProcaptchaPow, {
|
|
100
|
+
config,
|
|
101
|
+
callbacks,
|
|
102
|
+
frictionlessState,
|
|
103
|
+
i18n,
|
|
104
|
+
onEscalate,
|
|
105
|
+
autoStart: resumedAutoStart,
|
|
106
|
+
startCoords,
|
|
107
|
+
onSessionInvalidated
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const start = async () => {
|
|
112
|
+
if (!isSecureBrowserContext()) {
|
|
113
|
+
const errorMessage = i18n.isInitialized ? i18n.t("WIDGET.INSECURE_CONTEXT") : "Procaptcha requires a secure (HTTPS) connection";
|
|
114
|
+
events.onError(new Error(errorMessage));
|
|
115
|
+
fallOverWithStyle(errorMessage, "WIDGET.INSECURE_CONTEXT");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
await providerRetry(async () => {
|
|
119
|
+
stateRef.current.attemptCount += 1;
|
|
120
|
+
const result = await detectBot(ProcaptchaConfigSchema.parse(config), container, restart, { attempt: stateRef.current.attemptCount });
|
|
121
|
+
if (result.error?.message) {
|
|
122
|
+
stateRef.current = {
|
|
123
|
+
...stateRef.current,
|
|
124
|
+
loading: false,
|
|
125
|
+
errorMessage: result.error?.message
|
|
126
|
+
};
|
|
127
|
+
events.onError(new Error(result.error?.message));
|
|
128
|
+
fallOverWithStyle(result.error?.message, result.error?.key);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const frictionlessState = {
|
|
132
|
+
provider: result.provider,
|
|
133
|
+
sessionId: result.sessionId,
|
|
134
|
+
userAccount: result.userAccount,
|
|
135
|
+
restart,
|
|
136
|
+
behaviorCollector1: result.behaviorCollector1,
|
|
137
|
+
behaviorCollector2: result.behaviorCollector2,
|
|
138
|
+
behaviorCollector3: result.behaviorCollector3,
|
|
139
|
+
deviceCapability: result.deviceCapability,
|
|
140
|
+
encryptBehavioralData: result.encryptBehavioralData,
|
|
141
|
+
getSimdReadings: result.getSimdReadings,
|
|
142
|
+
hp: result.hp
|
|
143
|
+
};
|
|
144
|
+
await renderForCaptchaType(result.captchaType, frictionlessState);
|
|
145
|
+
stateRef.current = {
|
|
146
|
+
...stateRef.current,
|
|
147
|
+
loading: false
|
|
148
|
+
};
|
|
149
|
+
}, start, resetState, stateRef.current.attemptCount, 5).finally(() => {
|
|
150
|
+
if (stateRef.current.attemptCount >= 5) {
|
|
151
|
+
fallOverWithStyle();
|
|
152
|
+
restartComponentTimeout();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
const startedForKeyRef = useRef(null);
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
const key = `${config.account?.address ?? ""}|${config.language ?? ""}|${config.mode ?? ""}`;
|
|
159
|
+
if (startedForKeyRef.current === key) return;
|
|
160
|
+
startedForKeyRef.current = key;
|
|
161
|
+
start();
|
|
162
|
+
}, [
|
|
163
|
+
config.account?.address,
|
|
164
|
+
config.language,
|
|
165
|
+
config.mode
|
|
166
|
+
]);
|
|
167
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(TestModeBanner, { siteKey: config.account?.address ?? "" }), componentToRender] });
|
|
241
168
|
};
|
|
169
|
+
//#endregion
|
|
170
|
+
export { ProcaptchaFrictionless };
|