@prosopo/procaptcha-puzzle 2.10.8 → 2.10.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.
@@ -0,0 +1,53 @@
1
+
2
+ > @prosopo/procaptcha-puzzle@2.10.10 build:cjs
3
+ > NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
4
+
5
+ ViteCommonJSConfig: .
6
+ {
7
+ tsConfigPaths: [
8
+ '/home/runner/work/captcha/captcha/packages/api/tsconfig.json',
9
+ '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
10
+ '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
11
+ '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
12
+ '/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
13
+ '/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
14
+ '/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
15
+ '/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json',
16
+ '/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json',
17
+ '/home/runner/work/captcha/captcha/packages/widget-skeleton/tsconfig.json',
18
+ '/home/runner/work/captcha/captcha/packages/account/tsconfig.json',
19
+ '/home/runner/work/captcha/captcha/packages/fingerprint/tsconfig.json',
20
+ '/home/runner/work/captcha/captcha/packages/fingerprintjs/tsconfig.json',
21
+ '/home/runner/work/captcha/captcha/packages/keyring/tsconfig.json'
22
+ ]
23
+ }
24
+ {
25
+ externals: [
26
+ '@prosopo/api',
27
+ '@prosopo/types',
28
+ '@prosopo/locale',
29
+ '@prosopo/util',
30
+ '@prosopo/util-crypto',
31
+ '@prosopo/common',
32
+ '@prosopo/logger',
33
+ '@prosopo/procaptcha-common',
34
+ '@prosopo/load-balancer',
35
+ '@prosopo/widget-skeleton',
36
+ '@prosopo/account',
37
+ '@prosopo/fingerprint',
38
+ '@prosopo/fingerprintjs',
39
+ '@prosopo/keyring'
40
+ ]
41
+ }
42
+ vite v6.4.1 building SSR bundle for production...
43
+ Bundle build started
44
+ transforming...
45
+ Build end
46
+ ✓ 5 modules transformed.
47
+ rendering chunks...
48
+ dist/cjs/index.cjs  0.27 kB
49
+ dist/cjs/components/ProcaptchaPuzzle.cjs  0.83 kB
50
+ dist/cjs/components/ProcaptchaWidget.cjs  6.52 kB
51
+ dist/cjs/components/PuzzleCanvas.cjs 10.09 kB
52
+ dist/cjs/services/Manager.cjs 10.11 kB
53
+ ✓ built in 234ms
@@ -0,0 +1,56 @@
1
+
2
+ > @prosopo/procaptcha-puzzle@2.10.10 build:tsc
3
+ > tsc --build --verbose
4
+
5
+ 5:56:19 PM - Projects in this build:
6
+ * ../../dev/config/tsconfig.json
7
+ * ../locale/tsconfig.json
8
+ * ../util/tsconfig.json
9
+ * ../util-crypto/tsconfig.json
10
+ * ../types/tsconfig.json
11
+ * ../api/tsconfig.json
12
+ * ../logger/tsconfig.json
13
+ * ../common/tsconfig.json
14
+ * ../load-balancer/tsconfig.json
15
+ * ../widget-skeleton/tsconfig.json
16
+ * ../fingerprintjs/tsconfig.json
17
+ * ../fingerprint/tsconfig.json
18
+ * ../keyring/tsconfig.json
19
+ * ../account/tsconfig.json
20
+ * ../procaptcha-common/tsconfig.json
21
+ * tsconfig.json
22
+
23
+ 5:56:19 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'
24
+
25
+ 5:56:19 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
26
+
27
+ 5:56:19 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
28
+
29
+ 5:56:19 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
+
31
+ 5:56:19 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
+
33
+ 5:56:19 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
34
+
35
+ 5:56:19 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
36
+
37
+ 5:56:19 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
38
+
39
+ 5:56:19 PM - 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'
40
+
41
+ 5:56:19 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'
42
+
43
+ 5:56:19 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
44
+
45
+ 5:56:19 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
46
+
47
+ 5:56:19 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/pair/decode.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
48
+
49
+ 5:56:19 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
+
51
+ 5:56:19 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'
52
+
53
+ 5:56:19 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
54
+
55
+ 5:56:19 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-puzzle/tsconfig.json'...
56
+
@@ -1,57 +1,57 @@
1
-
2
-
3
- > @prosopo/procaptcha-puzzle@2.10.4 build
4
- > npm run build:cross-env -- --mode ${NODE_ENV:-development}
5
-
6
-
7
- > @prosopo/procaptcha-puzzle@2.10.4 build:cross-env
8
- > vite build --config vite.esm.config.ts --mode production
9
-
10
- ViteEsmConfig: .
11
- {
12
- tsConfigPaths: [
13
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/api/tsconfig.json',
14
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/types/tsconfig.json',
15
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/locale/tsconfig.json',
16
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/util/tsconfig.json',
17
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/util-crypto/tsconfig.json',
18
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/common/tsconfig.json',
19
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/logger/tsconfig.json',
20
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/procaptcha-common/tsconfig.json',
21
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/load-balancer/tsconfig.json',
22
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/widget-skeleton/tsconfig.json',
23
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/account/tsconfig.json',
24
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/fingerprint/tsconfig.json',
25
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/fingerprintjs/tsconfig.json',
26
- '/home/chris/dev/prosopo/captcha-private2/captcha/packages/keyring/tsconfig.json'
27
- ]
28
- }
29
- {
30
- externals: [
31
- '@prosopo/api',
32
- '@prosopo/types',
33
- '@prosopo/locale',
34
- '@prosopo/util',
35
- '@prosopo/util-crypto',
36
- '@prosopo/common',
37
- '@prosopo/logger',
38
- '@prosopo/procaptcha-common',
39
- '@prosopo/load-balancer',
40
- '@prosopo/widget-skeleton',
41
- '@prosopo/account',
42
- '@prosopo/fingerprint',
43
- '@prosopo/fingerprintjs',
44
- '@prosopo/keyring'
45
- ]
46
- }
47
- vite v6.4.1 building SSR bundle for production...
48
- Bundle build started
49
- transforming (1) src/index.tsBuild end
50
- ✓ 5 modules transformed.
51
- rendering chunks (1)...rendering chunks (2)...rendering chunks (3)...rendering chunks (4)...rendering chunks (5)...dist/index.js 0.14 kB
52
- dist/components/ProcaptchaPuzzle.js 0.46 kB
53
- dist/components/ProcaptchaWidget.js 6.11 kB
54
- dist/services/Manager.js 9.80 kB
55
- dist/components/PuzzleCanvas.js 9.81 kB
56
- ✓ built in 69ms
57
- ⠙⠙
1
+
2
+ > @prosopo/procaptcha-puzzle@2.10.10 build
3
+ > npm run build:cross-env -- --mode ${NODE_ENV:-development}
4
+
5
+
6
+ > @prosopo/procaptcha-puzzle@2.10.10 build:cross-env
7
+ > vite build --config vite.esm.config.ts --mode production
8
+
9
+ ViteEsmConfig: .
10
+ {
11
+ tsConfigPaths: [
12
+ '/home/runner/work/captcha/captcha/packages/api/tsconfig.json',
13
+ '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
14
+ '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
15
+ '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
16
+ '/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
17
+ '/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
18
+ '/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
19
+ '/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json',
20
+ '/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json',
21
+ '/home/runner/work/captcha/captcha/packages/widget-skeleton/tsconfig.json',
22
+ '/home/runner/work/captcha/captcha/packages/account/tsconfig.json',
23
+ '/home/runner/work/captcha/captcha/packages/fingerprint/tsconfig.json',
24
+ '/home/runner/work/captcha/captcha/packages/fingerprintjs/tsconfig.json',
25
+ '/home/runner/work/captcha/captcha/packages/keyring/tsconfig.json'
26
+ ]
27
+ }
28
+ {
29
+ externals: [
30
+ '@prosopo/api',
31
+ '@prosopo/types',
32
+ '@prosopo/locale',
33
+ '@prosopo/util',
34
+ '@prosopo/util-crypto',
35
+ '@prosopo/common',
36
+ '@prosopo/logger',
37
+ '@prosopo/procaptcha-common',
38
+ '@prosopo/load-balancer',
39
+ '@prosopo/widget-skeleton',
40
+ '@prosopo/account',
41
+ '@prosopo/fingerprint',
42
+ '@prosopo/fingerprintjs',
43
+ '@prosopo/keyring'
44
+ ]
45
+ }
46
+ vite v6.4.1 building SSR bundle for production...
47
+ Bundle build started
48
+ transforming...
49
+ Build end
50
+ ✓ 5 modules transformed.
51
+ rendering chunks...
52
+ dist/index.js 0.14 kB
53
+ dist/components/ProcaptchaPuzzle.js 0.46 kB
54
+ dist/components/ProcaptchaWidget.js 6.34 kB
55
+ dist/components/PuzzleCanvas.js 9.81 kB
56
+ dist/services/Manager.js 9.96 kB
57
+ ✓ built in 228ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @prosopo/procaptcha-puzzle
2
2
 
3
+ ## 2.10.10
4
+ ### Patch Changes
5
+
6
+ - Updated dependencies [bc3813d]
7
+ - Updated dependencies [4d05e3f]
8
+ - @prosopo/types@4.4.0
9
+ - @prosopo/api@3.4.10
10
+ - @prosopo/procaptcha-common@2.10.19
11
+
12
+ ## 2.10.9
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [b03dad1]
16
+ - @prosopo/types@4.3.1
17
+ - @prosopo/api@3.4.9
18
+ - @prosopo/procaptcha-common@2.10.18
19
+
3
20
  ## 2.10.8
4
21
  ### Patch Changes
5
22
 
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@emotion/react/jsx-runtime");
4
+ const react = require("react");
5
+ const _interopNamespaceDefaultOnly = (e) => Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: "Module" }));
6
+ const ProcaptchaWidget = react.lazy(
7
+ async () => Promise.resolve().then(() => /* @__PURE__ */ _interopNamespaceDefaultOnly(require("./ProcaptchaWidget.cjs")))
8
+ );
9
+ const ProcaptchaPuzzle = (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsx(
10
+ ProcaptchaWidget,
11
+ {
12
+ config: props.config,
13
+ callbacks: props.callbacks,
14
+ frictionlessState: props.frictionlessState,
15
+ i18n: props.i18n
16
+ }
17
+ ) });
18
+ exports.ProcaptchaPuzzle = ProcaptchaPuzzle;
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ const jsxRuntime = require("@emotion/react/jsx-runtime");
3
+ const locale = require("@prosopo/locale");
4
+ const procaptchaCommon = require("@prosopo/procaptcha-common");
5
+ const types = require("@prosopo/types");
6
+ const widgetSkeleton = require("@prosopo/widget-skeleton");
7
+ const react = require("react");
8
+ const Manager = require("../services/Manager.cjs");
9
+ const PuzzleCanvas = require("./PuzzleCanvas.cjs");
10
+ const PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
11
+ const Procaptcha = (props) => {
12
+ const { t, ready: isTranslationReady } = locale.useTranslation();
13
+ const config = props.config;
14
+ const i18n = props.i18n;
15
+ const theme = "light" === config.theme ? widgetSkeleton.lightTheme : widgetSkeleton.darkTheme;
16
+ const frictionlessState = props.frictionlessState;
17
+ const callbacks = props.callbacks || {};
18
+ const [state, _updateState] = procaptchaCommon.useProcaptcha(react.useState, react.useRef);
19
+ const [loading, setLoading] = react.useState(false);
20
+ const [puzzlePhase, setPuzzlePhase] = react.useState("checkbox");
21
+ const [challengeData, setChallengeData] = react.useState(null);
22
+ const [showRetry, setShowRetry] = react.useState(false);
23
+ const updateState = procaptchaCommon.buildUpdateState(state, _updateState);
24
+ const hpRef = react.useRef(null);
25
+ const manager = react.useRef(
26
+ Manager.Manager(
27
+ config,
28
+ state,
29
+ updateState,
30
+ callbacks,
31
+ frictionlessState,
32
+ () => hpRef.current?.value || void 0
33
+ )
34
+ );
35
+ react.useEffect(() => {
36
+ if (config.language) {
37
+ if (i18n) {
38
+ if (i18n.language !== config.language) {
39
+ i18n.changeLanguage(config.language).then((r) => r);
40
+ }
41
+ } else {
42
+ locale.loadI18next(false).then((i18n2) => {
43
+ if (i18n2.language !== config.language)
44
+ i18n2.changeLanguage(config.language).then((r) => r);
45
+ });
46
+ }
47
+ }
48
+ }, [i18n, config.language]);
49
+ react.useEffect(() => {
50
+ if (!state.error) return void 0;
51
+ setLoading(false);
52
+ setPuzzlePhase("checkbox");
53
+ setChallengeData(null);
54
+ setShowRetry(false);
55
+ if (state.error.key === "CAPTCHA.NO_SESSION_FOUND" && frictionlessState) {
56
+ const timer = setTimeout(() => {
57
+ frictionlessState.restart();
58
+ }, 100);
59
+ return () => clearTimeout(timer);
60
+ }
61
+ return void 0;
62
+ }, [state.error, frictionlessState]);
63
+ react.useEffect(() => {
64
+ if (config.mode === types.ModeEnum.invisible) {
65
+ const handleExecuteEvent = async () => {
66
+ if (loading) {
67
+ return;
68
+ }
69
+ setLoading(true);
70
+ setShowRetry(false);
71
+ try {
72
+ const challenge = await manager.current.start();
73
+ if (challenge) {
74
+ setChallengeData(challenge);
75
+ setPuzzlePhase("dragging");
76
+ }
77
+ } catch (error) {
78
+ callbacks.onError?.(
79
+ error instanceof Error ? error : new Error(String(error))
80
+ );
81
+ } finally {
82
+ setLoading(false);
83
+ }
84
+ };
85
+ document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, handleExecuteEvent);
86
+ return () => {
87
+ document.removeEventListener(
88
+ PROCAPTCHA_EXECUTE_EVENT,
89
+ handleExecuteEvent
90
+ );
91
+ };
92
+ }
93
+ return () => {
94
+ };
95
+ }, [config.mode, callbacks.onError, loading]);
96
+ const handlePuzzleComplete = react.useCallback(
97
+ async (finalX, finalY, puzzleEvents) => {
98
+ setPuzzlePhase("submitting");
99
+ let verified = false;
100
+ try {
101
+ verified = await manager.current.submitSolution(
102
+ finalX,
103
+ finalY,
104
+ puzzleEvents
105
+ );
106
+ } catch (error) {
107
+ callbacks.onError?.(
108
+ error instanceof Error ? error : new Error(String(error))
109
+ );
110
+ }
111
+ if (verified) {
112
+ setPuzzlePhase("checkbox");
113
+ setChallengeData(null);
114
+ setShowRetry(false);
115
+ setLoading(false);
116
+ return;
117
+ }
118
+ setShowRetry(true);
119
+ setPuzzlePhase("dragging");
120
+ try {
121
+ const newChallenge = await manager.current.start();
122
+ if (newChallenge) {
123
+ setChallengeData(newChallenge);
124
+ } else {
125
+ setPuzzlePhase("checkbox");
126
+ setChallengeData(null);
127
+ setShowRetry(false);
128
+ }
129
+ } catch {
130
+ setPuzzlePhase("checkbox");
131
+ setChallengeData(null);
132
+ setShowRetry(false);
133
+ }
134
+ setLoading(false);
135
+ },
136
+ [callbacks.onError]
137
+ );
138
+ const isInvisible = config.mode === types.ModeEnum.invisible;
139
+ const showPuzzleOverlay = (puzzlePhase === "dragging" || puzzlePhase === "submitting") && challengeData;
140
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
141
+ frictionlessState?.hp && /* @__PURE__ */ jsxRuntime.jsx(procaptchaCommon.Honeypot, { ref: hpRef, encodedQuestion: frictionlessState.hp }),
142
+ showPuzzleOverlay && /* @__PURE__ */ jsxRuntime.jsx(
143
+ PuzzleCanvas.PuzzleCanvas,
144
+ {
145
+ originX: challengeData.originX,
146
+ originY: challengeData.originY,
147
+ targetX: challengeData.targetX,
148
+ targetY: challengeData.targetY,
149
+ onComplete: handlePuzzleComplete,
150
+ showRetry,
151
+ submitting: puzzlePhase === "submitting"
152
+ }
153
+ ),
154
+ !isInvisible && /* @__PURE__ */ jsxRuntime.jsx(
155
+ procaptchaCommon.Checkbox,
156
+ {
157
+ checked: state.isHuman,
158
+ theme,
159
+ onChange: async (event) => {
160
+ if (loading) {
161
+ return;
162
+ }
163
+ setLoading(true);
164
+ setShowRetry(false);
165
+ let x = 0;
166
+ let y = 0;
167
+ const mouseOrTouchEvent = event.nativeEvent;
168
+ if (!mouseOrTouchEvent.isTrusted) {
169
+ } else if ("touches" in mouseOrTouchEvent && mouseOrTouchEvent.touches.length > 0 && mouseOrTouchEvent.touches[0]) {
170
+ x = mouseOrTouchEvent.touches[0].clientX;
171
+ y = mouseOrTouchEvent.touches[0].clientY;
172
+ } else if ("clientX" in mouseOrTouchEvent && "clientY" in mouseOrTouchEvent) {
173
+ x = mouseOrTouchEvent.clientX;
174
+ y = mouseOrTouchEvent.clientY;
175
+ }
176
+ const challenge = await manager.current.start(x, y);
177
+ if (challenge) {
178
+ setChallengeData(challenge);
179
+ setPuzzlePhase("dragging");
180
+ }
181
+ setLoading(false);
182
+ },
183
+ labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
184
+ error: state.error?.message,
185
+ "aria-label": "human checkbox",
186
+ loading: loading || puzzlePhase === "submitting"
187
+ }
188
+ )
189
+ ] });
190
+ };
191
+ module.exports = Procaptcha;