@prosopo/procaptcha-pow 2.10.23 → 2.10.25
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 +12 -10
- package/.turbo/turbo-build$colon$tsc.log +19 -19
- package/.turbo/turbo-build.log +14 -11
- package/CHANGELOG.md +46 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/components/ProcaptchaPoW.cjs +6 -9
- package/dist/cjs/components/ProcaptchaWidget.cjs +117 -127
- package/dist/cjs/index.cjs +2 -4
- package/dist/cjs/services/Manager.cjs +193 -277
- package/dist/components/ProcaptchaPoW.js +6 -8
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
- package/dist/components/ProcaptchaWidget.js +117 -127
- package/dist/components/ProcaptchaWidget.js.map +1 -1
- package/dist/index.js +2 -4
- package/dist/services/Manager.d.ts.map +1 -1
- package/dist/services/Manager.js +189 -274
- package/dist/services/Manager.js.map +1 -1
- package/dist/tests/manager.unit.test.d.ts +2 -0
- package/dist/tests/manager.unit.test.d.ts.map +1 -0
- package/dist/tests/manager.unit.test.js +752 -0
- package/dist/tests/manager.unit.test.js.map +1 -0
- package/dist/tests/managerHarness.d.ts +17 -0
- package/dist/tests/managerHarness.d.ts.map +1 -0
- package/dist/tests/managerHarness.js +70 -0
- package/dist/tests/managerHarness.js.map +1 -0
- package/dist/tests/procaptchaPoW.unit.test.d.ts +2 -0
- package/dist/tests/procaptchaPoW.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptchaPoW.unit.test.js +79 -0
- package/dist/tests/procaptchaPoW.unit.test.js.map +1 -0
- package/dist/tests/procaptchaPow.test-d.d.ts +2 -0
- package/dist/tests/procaptchaPow.test-d.d.ts.map +1 -0
- package/dist/tests/procaptchaPow.test-d.js +62 -0
- package/dist/tests/procaptchaPow.test-d.js.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts +2 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.js +410 -0
- package/dist/tests/procaptchaWidget.unit.test.js.map +1 -0
- package/package.json +18 -13
- package/src/components/ProcaptchaWidget.tsx +22 -5
- package/src/services/Manager.ts +9 -5
- package/src/tests/manager.unit.test.ts +1105 -0
- package/src/tests/managerHarness.ts +135 -0
- package/src/tests/procaptchaPoW.unit.test.ts +120 -0
- package/src/tests/procaptchaPow.test-d.ts +122 -0
- package/src/tests/procaptchaWidget.unit.test.ts +571 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.test.config.ts +25 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-pow@2.10.
|
|
2
|
+
> @prosopo/procaptcha-pow@2.10.25 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -39,14 +39,16 @@ ViteCommonJSConfig: .
|
|
|
39
39
|
'@prosopo/keyring'
|
|
40
40
|
]
|
|
41
41
|
}
|
|
42
|
-
[
|
|
42
|
+
[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
|
|
43
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
43
44
|
Bundle build started
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[32m✓[39m 4 modules transformed.
|
|
45
|
+
[2K
|
|
46
|
+
✓ 5 modules transformed.
|
|
47
47
|
rendering chunks...
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
computing gzip size...
|
|
49
|
+
dist/cjs/index.cjs 0.20 kB │ gzip: 0.15 kB
|
|
50
|
+
dist/cjs/components/ProcaptchaPoW.cjs 0.51 kB │ gzip: 0.27 kB
|
|
51
|
+
dist/cjs/components/ProcaptchaWidget.cjs 4.70 kB │ gzip: 1.50 kB
|
|
52
|
+
dist/cjs/services/Manager.cjs 9.19 kB │ gzip: 2.61 kB
|
|
53
|
+
|
|
54
|
+
[32m✓ built in 87ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-pow@2.10.
|
|
2
|
+
> @prosopo/procaptcha-pow@2.10.25 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
12:36:38 PM - 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
|
+
12:36:38 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/index.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
12:36:38 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
12:36:38 PM - 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
|
+
12:36:38 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'
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
12:36:38 PM - 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
|
+
12:36:38 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/tests/apiHarness.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
12:36:38 PM - 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
|
+
12:36:38 PM - 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
|
+
12:36:38 PM - 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
|
+
12:36:38 PM - 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
|
+
12:36:39 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'
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
12:36:39 PM - 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'
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
12:36:39 PM - 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
|
+
12:36:39 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
12:36:39 PM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/simdReadings.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
12:36:39 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
12:36:39 PM - 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.25 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.25 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -27,6 +27,7 @@ ViteEsmConfig: .
|
|
|
27
27
|
}
|
|
28
28
|
{
|
|
29
29
|
externals: [
|
|
30
|
+
[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
|
|
30
31
|
'@prosopo/api',
|
|
31
32
|
'@prosopo/types',
|
|
32
33
|
'@prosopo/locale',
|
|
@@ -43,14 +44,16 @@ ViteEsmConfig: .
|
|
|
43
44
|
'@prosopo/keyring'
|
|
44
45
|
]
|
|
45
46
|
}
|
|
46
|
-
[36mvite
|
|
47
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
47
48
|
Bundle build started
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
[32m✓[39m 4 modules transformed.
|
|
49
|
+
[2K
|
|
50
|
+
✓ 5 modules transformed.
|
|
51
51
|
rendering chunks...
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
computing gzip size...
|
|
53
|
+
dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
|
|
54
|
+
dist/index.js 0.13 kB │ gzip: 0.11 kB
|
|
55
|
+
dist/components/ProcaptchaPoW.js 0.37 kB │ gzip: 0.23 kB
|
|
56
|
+
dist/components/ProcaptchaWidget.js 4.30 kB │ gzip: 1.48 kB
|
|
57
|
+
dist/services/Manager.js 8.54 kB │ gzip: 2.57 kB
|
|
58
|
+
|
|
59
|
+
[32m✓ built in 83ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @prosopo/procaptcha-pow
|
|
2
2
|
|
|
3
|
+
## 2.10.25
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- 34f902a: Remove the undeclared `@prosopo/load-balancer` import from the manager unit test, deriving `IpMode` from `procaptcha-common`'s `pickIpMode` instead so `lint:refs` passes.
|
|
7
|
+
- 9c55bcb: Add unit and type tests for the PoW widget and Manager, and fix the defects they exposed:
|
|
8
|
+
|
|
9
|
+
- a retried solve restarted at coordinates (0, 0), losing the real click telemetry an escalated widget depends on
|
|
10
|
+
- three paths in `ProcaptchaWidget` (checkbox change, autoStart effect, `procaptcha:execute` handler) let a rejected `manager.start()` escape as an unhandled rejection, leaving the spinner running
|
|
11
|
+
- Updated dependencies [1e0cf14]
|
|
12
|
+
- @prosopo/api@3.5.21
|
|
13
|
+
|
|
14
|
+
## 2.10.24
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- ab3499c: feat(procaptcha): block on SIMD readings at solution submit
|
|
18
|
+
|
|
19
|
+
Solution submit is the last hop the client controls, so it's the last chance to
|
|
20
|
+
attach the catcher's WASM SIMD readings for a session. The image, PoW and puzzle
|
|
21
|
+
managers now wait for the benchmark there via a shared
|
|
22
|
+
`getSimdReadingsForSubmit` helper, capped at 5s, instead of attaching only
|
|
23
|
+
whatever the prefetch happened to have resolved.
|
|
24
|
+
|
|
25
|
+
The helper passes the budget down to the detector *and* races it locally — the
|
|
26
|
+
detector ships prebuilt, so a bundle that ignores `timeoutMs` (or a benchmark
|
|
27
|
+
wedged on a busy main thread) can't hang the submission. It never rejects: a
|
|
28
|
+
missing accessor, a rejection, a synchronous throw and a timeout all resolve to
|
|
29
|
+
`undefined` and the solution is submitted without readings, so a user is never
|
|
30
|
+
failed over telemetry.
|
|
31
|
+
|
|
32
|
+
The earlier frictionless POST and challenge GET hops are unchanged and remain
|
|
33
|
+
non-blocking.
|
|
34
|
+
- 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
|
|
35
|
+
- Updated dependencies [2c47bb7]
|
|
36
|
+
- Updated dependencies [ab3499c]
|
|
37
|
+
- Updated dependencies [0e1171c]
|
|
38
|
+
- Updated dependencies [103318c]
|
|
39
|
+
- Updated dependencies [270a8d8]
|
|
40
|
+
- Updated dependencies [e14fce6]
|
|
41
|
+
- @prosopo/util@3.3.5
|
|
42
|
+
- @prosopo/procaptcha-common@2.11.18
|
|
43
|
+
- @prosopo/locale@3.2.8
|
|
44
|
+
- @prosopo/types@4.10.0
|
|
45
|
+
- @prosopo/api@3.5.20
|
|
46
|
+
- @prosopo/common@3.1.48
|
|
47
|
+
- @prosopo/fingerprint@2.7.19
|
|
48
|
+
|
|
3
49
|
## 2.10.23
|
|
4
50
|
### Patch Changes
|
|
5
51
|
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
async () => Promise.resolve().then(() => /* @__PURE__ */ _interopNamespaceDefaultOnly(require("./ProcaptchaWidget.cjs")))
|
|
8
|
-
);
|
|
9
|
-
const ProcaptchaPow = (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsx(ProcaptchaWidget, { ...props }) });
|
|
1
|
+
let react = require("react");
|
|
2
|
+
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
3
|
+
//#region src/components/ProcaptchaPoW.tsx
|
|
4
|
+
var ProcaptchaWidget = (0, react.lazy)(async () => Promise.resolve().then(() => require("./ProcaptchaWidget.cjs")));
|
|
5
|
+
var ProcaptchaPow = (props) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react.Suspense, { children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ProcaptchaWidget, { ...props }) });
|
|
6
|
+
//#endregion
|
|
10
7
|
exports.ProcaptchaPow = ProcaptchaPow;
|
|
@@ -1,128 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
lastCoordsRef.current = { x, y };
|
|
117
|
-
await manager.current.start(x, y);
|
|
118
|
-
setLoading(false);
|
|
119
|
-
},
|
|
120
|
-
labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
|
|
121
|
-
error: state.error?.message,
|
|
122
|
-
"aria-label": "human checkbox",
|
|
123
|
-
loading
|
|
124
|
-
}
|
|
125
|
-
)
|
|
126
|
-
] });
|
|
1
|
+
const require_Manager = require("../services/Manager.cjs");
|
|
2
|
+
let _prosopo_locale = require("@prosopo/locale");
|
|
3
|
+
let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
|
|
4
|
+
let _prosopo_types = require("@prosopo/types");
|
|
5
|
+
let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
8
|
+
//#region src/components/ProcaptchaWidget.tsx
|
|
9
|
+
var PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
|
|
10
|
+
var Procaptcha = (props) => {
|
|
11
|
+
const { t, ready: isTranslationReady } = (0, _prosopo_locale.useTranslation)();
|
|
12
|
+
const config = props.config;
|
|
13
|
+
const i18n = props.i18n;
|
|
14
|
+
const theme = "light" === config.theme ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme;
|
|
15
|
+
const frictionlessState = props.frictionlessState;
|
|
16
|
+
const callbacks = props.callbacks || {};
|
|
17
|
+
const [state, _updateState] = (0, _prosopo_procaptcha_common.useProcaptcha)(react.useState, react.useRef);
|
|
18
|
+
const [loading, setLoading] = (0, react.useState)(false);
|
|
19
|
+
const updateState = (0, _prosopo_procaptcha_common.buildUpdateState)(state, _updateState);
|
|
20
|
+
const hpRef = (0, react.useRef)(null);
|
|
21
|
+
const manager = (0, react.useRef)(require_Manager.Manager(config, state, updateState, callbacks, frictionlessState, props.onEscalate, () => hpRef.current?.value || void 0));
|
|
22
|
+
const lastCoordsRef = (0, react.useRef)(null);
|
|
23
|
+
const sessionInvalidatedFiredRef = (0, react.useRef)(false);
|
|
24
|
+
(0, react.useEffect)(() => {
|
|
25
|
+
if (!config.language) return;
|
|
26
|
+
if (i18n) {
|
|
27
|
+
if (i18n.language !== config.language) i18n.changeLanguage(config.language);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
(0, _prosopo_locale.loadI18next)(false, config.language);
|
|
31
|
+
}, [i18n, config.language]);
|
|
32
|
+
(0, react.useEffect)(() => {
|
|
33
|
+
if (!props.autoStart) return;
|
|
34
|
+
setLoading(true);
|
|
35
|
+
const coords = props.startCoords;
|
|
36
|
+
lastCoordsRef.current = coords ?? null;
|
|
37
|
+
manager.current.start(coords?.x ?? 0, coords?.y ?? 0).catch((error) => {
|
|
38
|
+
console.error("Error starting PoW verification:", error);
|
|
39
|
+
}).finally(() => {
|
|
40
|
+
setLoading(false);
|
|
41
|
+
});
|
|
42
|
+
}, [props.autoStart, props.startCoords]);
|
|
43
|
+
(0, react.useEffect)(() => {
|
|
44
|
+
if (!state.error) return;
|
|
45
|
+
setLoading(false);
|
|
46
|
+
if (state.error.key !== "CAPTCHA.NO_SESSION_FOUND") return;
|
|
47
|
+
if (props.onSessionInvalidated && !sessionInvalidatedFiredRef.current) {
|
|
48
|
+
sessionInvalidatedFiredRef.current = true;
|
|
49
|
+
const coords = lastCoordsRef.current;
|
|
50
|
+
props.onSessionInvalidated(coords?.x, coords?.y);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (frictionlessState) setTimeout(() => {
|
|
54
|
+
frictionlessState.restart();
|
|
55
|
+
}, 100);
|
|
56
|
+
}, [
|
|
57
|
+
state.error,
|
|
58
|
+
frictionlessState,
|
|
59
|
+
props.onSessionInvalidated
|
|
60
|
+
]);
|
|
61
|
+
(0, react.useEffect)(() => {
|
|
62
|
+
if (config.mode === _prosopo_types.ModeEnum.invisible) {
|
|
63
|
+
const handleExecuteEvent = (event) => {
|
|
64
|
+
try {
|
|
65
|
+
manager.current.start().catch((error) => {
|
|
66
|
+
console.error("Error starting PoW verification:", error);
|
|
67
|
+
});
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error("Error starting PoW verification:", error);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, handleExecuteEvent);
|
|
73
|
+
return () => {
|
|
74
|
+
document.removeEventListener(PROCAPTCHA_EXECUTE_EVENT, handleExecuteEvent);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return () => {};
|
|
78
|
+
}, [config.mode]);
|
|
79
|
+
const honeypot = frictionlessState?.hp ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_prosopo_procaptcha_common.Honeypot, {
|
|
80
|
+
ref: hpRef,
|
|
81
|
+
encodedQuestion: frictionlessState.hp
|
|
82
|
+
}) : null;
|
|
83
|
+
if (config.mode === _prosopo_types.ModeEnum.invisible) return honeypot;
|
|
84
|
+
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(_emotion_react_jsx_runtime.Fragment, { children: [honeypot, /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_prosopo_procaptcha_common.Checkbox, {
|
|
85
|
+
checked: state.isHuman,
|
|
86
|
+
theme,
|
|
87
|
+
onChange: async (event) => {
|
|
88
|
+
if (loading) return;
|
|
89
|
+
setLoading(true);
|
|
90
|
+
let x = 0;
|
|
91
|
+
let y = 0;
|
|
92
|
+
const mouseOrTouchEvent = event.nativeEvent;
|
|
93
|
+
if (!mouseOrTouchEvent.isTrusted) {} else if ("touches" in mouseOrTouchEvent && mouseOrTouchEvent.touches.length > 0 && mouseOrTouchEvent.touches[0]) {
|
|
94
|
+
x = mouseOrTouchEvent.touches[0].clientX;
|
|
95
|
+
y = mouseOrTouchEvent.touches[0].clientY;
|
|
96
|
+
} else if ("clientX" in mouseOrTouchEvent && "clientY" in mouseOrTouchEvent) {
|
|
97
|
+
x = mouseOrTouchEvent.clientX;
|
|
98
|
+
y = mouseOrTouchEvent.clientY;
|
|
99
|
+
}
|
|
100
|
+
lastCoordsRef.current = {
|
|
101
|
+
x,
|
|
102
|
+
y
|
|
103
|
+
};
|
|
104
|
+
try {
|
|
105
|
+
await manager.current.start(x, y);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error("Error starting PoW verification:", error);
|
|
108
|
+
}
|
|
109
|
+
setLoading(false);
|
|
110
|
+
},
|
|
111
|
+
labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
|
|
112
|
+
error: state.error?.message,
|
|
113
|
+
"aria-label": "human checkbox",
|
|
114
|
+
loading
|
|
115
|
+
})] });
|
|
127
116
|
};
|
|
128
|
-
|
|
117
|
+
//#endregion
|
|
118
|
+
exports.default = Procaptcha;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("./components/
|
|
4
|
-
|
|
5
|
-
exports.ProcaptchaPow = ProcaptchaPoW.ProcaptchaPow;
|
|
2
|
+
const require_ProcaptchaPoW = require("./components/ProcaptchaPoW.cjs");
|
|
3
|
+
exports.ProcaptchaPow = require_ProcaptchaPoW.ProcaptchaPow;
|