@prosopo/procaptcha-frictionless 2.13.23 → 2.15.0
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 +3 -3
- package/.turbo/turbo-build$colon$tsc.log +24 -24
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +89 -0
- package/dist/ProcaptchaFrictionless.d.ts.map +1 -1
- package/dist/ProcaptchaFrictionless.js +50 -6
- package/dist/ProcaptchaFrictionless.js.map +1 -1
- package/dist/cjs/ProcaptchaFrictionless.cjs +49 -5
- package/dist/tests/manualStart.test.d.ts +5 -0
- package/dist/tests/manualStart.test.d.ts.map +1 -0
- package/dist/tests/manualStart.test.js +254 -0
- package/dist/tests/manualStart.test.js.map +1 -0
- package/package.json +13 -13
- package/src/ProcaptchaFrictionless.tsx +77 -2
- package/src/tests/manualStart.test.tsx +388 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.15.0 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -62,6 +62,6 @@ dist/cjs/frictionlessResultGuard.cjs 1.55 kB │ gzip: 0.80 kB
|
|
|
62
62
|
dist/cjs/sessionInvalidatedRecovery.cjs 2.35 kB │ gzip: 1.07 kB
|
|
63
63
|
dist/cjs/detectorPrefetch.cjs 2.98 kB │ gzip: 1.35 kB
|
|
64
64
|
dist/cjs/customDetectBot.cjs 5.55 kB │ gzip: 1.70 kB
|
|
65
|
-
dist/cjs/ProcaptchaFrictionless.cjs
|
|
65
|
+
dist/cjs/ProcaptchaFrictionless.cjs 9.55 kB │ gzip: 2.59 kB
|
|
66
66
|
|
|
67
|
-
[32m✓ built in
|
|
67
|
+
[32m✓ built in 48ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.15.0 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
1:
|
|
5
|
+
1:15:48 PM - Projects in this build:
|
|
6
6
|
* ../../dev/config/tsconfig.json
|
|
7
7
|
* ../locale/tsconfig.json
|
|
8
8
|
* ../util/tsconfig.json
|
|
@@ -25,47 +25,47 @@
|
|
|
25
25
|
* ../procaptcha-react/tsconfig.json
|
|
26
26
|
* tsconfig.json
|
|
27
27
|
|
|
28
|
-
1:
|
|
28
|
+
1:15:48 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'
|
|
29
29
|
|
|
30
|
-
1:
|
|
30
|
+
1:15:48 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
31
31
|
|
|
32
|
-
1:
|
|
32
|
+
1:15:48 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
33
33
|
|
|
34
|
-
1:
|
|
34
|
+
1:15:48 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'
|
|
35
35
|
|
|
36
|
-
1:
|
|
36
|
+
1:15:48 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
37
37
|
|
|
38
|
-
1:
|
|
38
|
+
1:15:48 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/tests/apiHarness.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
39
39
|
|
|
40
|
-
1:
|
|
40
|
+
1:15:48 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
41
41
|
|
|
42
|
-
1:
|
|
42
|
+
1:15:48 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/utils/batches.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
43
43
|
|
|
44
|
-
1:
|
|
44
|
+
1:15:48 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
|
|
45
45
|
|
|
46
|
-
1:
|
|
46
|
+
1:15:48 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
|
|
47
47
|
|
|
48
|
-
1:
|
|
48
|
+
1:15:48 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'
|
|
49
49
|
|
|
50
|
-
1:
|
|
50
|
+
1:15:48 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'
|
|
51
51
|
|
|
52
|
-
1:
|
|
52
|
+
1:15:48 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/keyring/keyring.test.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
|
|
53
53
|
|
|
54
|
-
1:
|
|
54
|
+
1:15:48 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
55
55
|
|
|
56
|
-
1:
|
|
56
|
+
1:15:48 PM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/tests/challengeSurfaceRender.unit.test.tsx' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
|
|
57
57
|
|
|
58
|
-
1:
|
|
58
|
+
1:15:48 PM - Project '../procaptcha-pow/tsconfig.json' is up to date because newest input '../procaptcha-pow/src/tests/managerHarness.ts' is older than output '../procaptcha-pow/tsconfig.tsbuildinfo'
|
|
59
59
|
|
|
60
|
-
1:
|
|
60
|
+
1:15:48 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'
|
|
61
61
|
|
|
62
|
-
1:
|
|
62
|
+
1:15:48 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/tests/dataset.unit.test.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
|
|
63
63
|
|
|
64
|
-
1:
|
|
64
|
+
1:15:48 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/modules/Manager.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
|
|
65
65
|
|
|
66
|
-
1:
|
|
66
|
+
1:15:49 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'
|
|
67
67
|
|
|
68
|
-
1:
|
|
68
|
+
1:15:49 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
69
69
|
|
|
70
|
-
1:
|
|
70
|
+
1:15:49 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-frictionless/tsconfig.json'...
|
|
71
71
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.15.0 build
|
|
3
3
|
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @prosopo/procaptcha-frictionless@2.
|
|
6
|
+
> @prosopo/procaptcha-frictionless@2.15.0 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -67,6 +67,6 @@ dist/frictionlessResultGuard.js 1.48 kB │ gzip: 0.80 kB
|
|
|
67
67
|
dist/sessionInvalidatedRecovery.js 2.26 kB │ gzip: 1.05 kB
|
|
68
68
|
dist/detectorPrefetch.js 2.86 kB │ gzip: 1.32 kB
|
|
69
69
|
dist/customDetectBot.js 5.37 kB │ gzip: 1.67 kB
|
|
70
|
-
dist/ProcaptchaFrictionless.js
|
|
70
|
+
dist/ProcaptchaFrictionless.js 8.89 kB │ gzip: 2.55 kB
|
|
71
71
|
|
|
72
|
-
[32m✓ built in
|
|
72
|
+
[32m✓ built in 61ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
# @prosopo/procaptcha-frictionless
|
|
2
2
|
|
|
3
|
+
## 2.15.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
- d288371: Let a site choose where a challenge opens, and which button triggers it.
|
|
7
|
+
|
|
8
|
+
- `placement: "popup" | "float"`, also `data-placement`. `popup` is the default and unchanged. `float` opens the challenge directly above the widget and keeps it pinned there as the page scrolls, leaves the page usable behind it, and dismisses on Escape or an outside click. An invisible widget always uses popup.
|
|
9
|
+
- `bind: "#selector"`, also `data-bind`. The matching host-page button triggers that one widget, in visible or invisible mode. The click's default action is prevented so a submit button does not post the form before a token exists.
|
|
10
|
+
- `execute(widgetId?)`. Called with no argument every widget responds, as before. Called with the id `render()` returns, only that widget runs. Implicitly rendered invisible buttons now trigger only their own widget.
|
|
11
|
+
|
|
12
|
+
Behaviour changes for existing widgets:
|
|
13
|
+
|
|
14
|
+
- Escape now closes the image and puzzle challenge in both placements. For the image captcha this runs the cancel path, which fires `onClose` and restarts frictionless.
|
|
15
|
+
- Image and puzzle now present on one shared `ChallengeSurface`. Both were already portalled to `document.body`, so neither moves in the page, but the markup around them changed: the outer layer keeps `prosopo-modalOuter` for the image captcha and also carries `prosopo-challenge-surface`, and a new `prosopo-challenge-content` element sits between it and `prosopo-modalInner`. A direct-child selector such as `.prosopo-modalOuter > .prosopo-modalInner` no longer matches, and the centring transform now lives on `prosopo-challenge-content` rather than on `prosopo-modalInner`.
|
|
16
|
+
|
|
17
|
+
`createConfig` takes a named options object.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [6f57ee9]
|
|
22
|
+
- Updated dependencies [d288371]
|
|
23
|
+
- @prosopo/types@5.7.0
|
|
24
|
+
- @prosopo/procaptcha-common@2.13.0
|
|
25
|
+
- @prosopo/procaptcha-react@2.10.0
|
|
26
|
+
- @prosopo/procaptcha-puzzle@2.12.0
|
|
27
|
+
- @prosopo/procaptcha-pow@2.12.0
|
|
28
|
+
- @prosopo/api@4.1.6
|
|
29
|
+
- @prosopo/common@3.1.54
|
|
30
|
+
|
|
31
|
+
## 2.14.0
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- 80f73c1: Sites can now control when the widget starts working.
|
|
35
|
+
|
|
36
|
+
By default the widget runs bot detection, starts the behavioural collectors and calls `/frictionless` as soon as it mounts. Rendering with `data-start-mode="manual"` (or `startMode: "manual"` in the render options) keeps all of that off the page load: the checkbox still appears immediately, at its final size, so nothing shifts, but the widget does nothing else until one of two things happens.
|
|
37
|
+
|
|
38
|
+
- The site calls `window.procaptcha.start()`, optionally with a widget id, or dispatches a `procaptcha:start` event on `document`. The frictionless flow runs and the widget then waits for a click exactly as it does today.
|
|
39
|
+
- The visitor clicks the checkbox. The frictionless flow runs and whichever challenge the provider chooses opens straight away, carrying that click's position, so the visitor is never asked to click twice.
|
|
40
|
+
|
|
41
|
+
Both triggers are one-shot: whichever comes first wins and the other is ignored. `window.procaptcha.execute()` also starts a manual widget, opening its challenge immediately. Widgets in the default `auto` mode are unaffected.
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- 89dd38a: chore(deps): batch the outstanding dependabot bumps into one upgrade
|
|
46
|
+
|
|
47
|
+
Rolls up dependabot PRs #3112, #3127-#3134 and #3159. Majors: `mongoose`
|
|
48
|
+
8 -> 9, `bson` 6 -> 7, `@noble/curves` 1 -> 2, `@polkadot/util-crypto`
|
|
49
|
+
13 -> 14, `@typegoose/auto-increment` 4 -> 5, `@babel/preset-env` 7 -> 8,
|
|
50
|
+
`@types/jsdom` 21 -> 30, `@types/bcrypt` 5 -> 6, `@actions/github` 6 -> 9,
|
|
51
|
+
`testcontainers` 11 -> 12. The rest are minor/patch.
|
|
52
|
+
|
|
53
|
+
Code changes the majors forced:
|
|
54
|
+
- `@noble/curves` v2 requires `.js` specifiers and renamed the point API,
|
|
55
|
+
so `secp256k1.ProjectivePoint.fromHex(...).toRawBytes()` becomes
|
|
56
|
+
`secp256k1.Point.fromBytes(...).toBytes()`, `RistrettoPoint` becomes
|
|
57
|
+
`ristretto255.Point`, and `abstract/utils` moves to `utils.js`.
|
|
58
|
+
- mongoose 9 drops `RootFilterQuery` (now `QueryFilter`), no longer sets
|
|
59
|
+
`background: true` on schema indexes by default, and no longer declares
|
|
60
|
+
`id` on `Document`, which un-hid a mismatch between
|
|
61
|
+
`updateDappUserCommitment`'s `Hash` parameter and the `string` `id` it
|
|
62
|
+
filters on.
|
|
63
|
+
- mongoose 9 rejects an aggregation-pipeline update (an array) unless the
|
|
64
|
+
call passes `updatePipeline: true`, so the six pipeline writes in
|
|
65
|
+
`ProviderDatabase` now opt in explicitly.
|
|
66
|
+
- mongoose 9's `castUpdate` throws on a `$setOnInsert` key inside `$set`.
|
|
67
|
+
`storeUserImageCaptchaSolution` passed its record straight in as the
|
|
68
|
+
update, and mongoose's `moveImmutableProperties` mutates that object on
|
|
69
|
+
an upsert -- adding the very `$setOnInsert` key the record then carried
|
|
70
|
+
into `CentralDbStreamer.streamImageRecord`. Image records stopped
|
|
71
|
+
reaching the central DB (the streamer is fire-and-forget, so it only
|
|
72
|
+
logged) and signup verification returned 500. The update is now an
|
|
73
|
+
explicit `$set` over a shallow copy.
|
|
74
|
+
- `@prosopo/database` moves from mongodb 6.20 to 7.5 to match the driver
|
|
75
|
+
mongoose 9 pulls, so bson 7 is the only copy resolvable in the package.
|
|
76
|
+
- `vitest`/`@vitest/coverage-v8` go to 4.1.11 alongside dependabot's
|
|
77
|
+
`@vitest/spy` bump; leaving them at 4.1.10 installed a second copy of
|
|
78
|
+
`@vitest/spy` and broke type inference in the provider test utils.
|
|
79
|
+
- Updated dependencies [89dd38a]
|
|
80
|
+
- Updated dependencies [80f73c1]
|
|
81
|
+
- Updated dependencies [8a670d3]
|
|
82
|
+
- @prosopo/api@4.1.5
|
|
83
|
+
- @prosopo/common@3.1.53
|
|
84
|
+
- @prosopo/locale@3.4.1
|
|
85
|
+
- @prosopo/procaptcha-common@2.12.6
|
|
86
|
+
- @prosopo/procaptcha-pow@2.11.6
|
|
87
|
+
- @prosopo/procaptcha-puzzle@2.11.6
|
|
88
|
+
- @prosopo/procaptcha-react@2.9.122
|
|
89
|
+
- @prosopo/types@5.6.0
|
|
90
|
+
- @prosopo/widget-skeleton@2.8.7
|
|
91
|
+
|
|
3
92
|
## 2.13.23
|
|
4
93
|
### Patch Changes
|
|
5
94
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaFrictionless.d.ts","sourceRoot":"","sources":["../src/ProcaptchaFrictionless.tsx"],"names":[],"mappings":"AAsBA,OAAO,
|
|
1
|
+
{"version":3,"file":"ProcaptchaFrictionless.d.ts","sourceRoot":"","sources":["../src/ProcaptchaFrictionless.tsx"],"names":[],"mappings":"AAsBA,OAAO,EAMN,KAAK,2BAA2B,EAGhC,MAAM,gBAAgB,CAAC;AAoExB,eAAO,MAAM,sBAAsB,gEAOhC,2BAA2B,gCA2X7B,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { evaluateFrictionlessResult } from "./frictionlessResultGuard.js";
|
|
|
3
3
|
import { consumeRetryMountProps, handleSessionInvalidated, normaliseRetryCoords } from "./sessionInvalidatedRecovery.js";
|
|
4
4
|
import { loadI18next } from "@prosopo/locale";
|
|
5
5
|
import { Checkbox, TestModeBanner, getDefaultEvents, isSecureBrowserContext, providerRetry } from "@prosopo/procaptcha-common";
|
|
6
|
-
import { CaptchaType, ProcaptchaConfigSchema } from "@prosopo/types";
|
|
6
|
+
import { CaptchaType, PROCAPTCHA_START_EVENT, ProcaptchaConfigSchema, StartModeEnum } from "@prosopo/types";
|
|
7
7
|
import { darkTheme, lightTheme } from "@prosopo/widget-skeleton";
|
|
8
8
|
import { useEffect, useRef, useState } from "react";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -11,12 +11,14 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
var ProcaptchaLoader = async () => (await import("@prosopo/procaptcha-react")).Procaptcha;
|
|
12
12
|
var ProcaptchaPuzzleLoader = async () => (await import("@prosopo/procaptcha-puzzle")).ProcaptchaPuzzle;
|
|
13
13
|
var ProcaptchaPowLoader = async () => (await import("@prosopo/procaptcha-pow")).ProcaptchaPow;
|
|
14
|
-
var
|
|
14
|
+
var PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
|
|
15
|
+
var noopCheckboxHandler = async (_event) => {};
|
|
16
|
+
var renderPlaceholder = (theme, mode, errorMessage, isTranslationLoaded, translationFn, loading, onChange = noopCheckboxHandler) => {
|
|
15
17
|
const checkboxTheme = "light" === theme ? lightTheme : darkTheme;
|
|
16
18
|
if (mode === "invisible") return null;
|
|
17
19
|
return /* @__PURE__ */ jsx(Checkbox, {
|
|
18
20
|
theme: checkboxTheme,
|
|
19
|
-
onChange
|
|
21
|
+
onChange,
|
|
20
22
|
checked: false,
|
|
21
23
|
labelText: isTranslationLoaded ? translationFn("WIDGET.I_AM_HUMAN") : "",
|
|
22
24
|
error: errorMessage,
|
|
@@ -35,6 +37,9 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = cu
|
|
|
35
37
|
const sessionInvalidatedFiredRef = useRef(false);
|
|
36
38
|
const mountCountRef = useRef(0);
|
|
37
39
|
const nextMountAutoStartRef = useRef(false);
|
|
40
|
+
const manualStart = config.startMode === StartModeEnum.manual;
|
|
41
|
+
const manualStartedRef = useRef(false);
|
|
42
|
+
const manualCheckboxHandlerRef = useRef(noopCheckboxHandler);
|
|
38
43
|
useEffect(() => {
|
|
39
44
|
if (!config.language) return;
|
|
40
45
|
if (i18n) {
|
|
@@ -43,7 +48,7 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = cu
|
|
|
43
48
|
}
|
|
44
49
|
loadI18next(false, config.language);
|
|
45
50
|
}, [i18n, config.language]);
|
|
46
|
-
const [componentToRender, setComponentToRender] = useState(renderPlaceholder(config.theme, config.mode, stateRef.current.errorMessage, i18n.isInitialized, i18n.t,
|
|
51
|
+
const [componentToRender, setComponentToRender] = useState(renderPlaceholder(config.theme, config.mode, stateRef.current.errorMessage, i18n.isInitialized, i18n.t, !manualStart, manualStart ? (event) => manualCheckboxHandlerRef.current(event) : void 0));
|
|
47
52
|
const resetState = (attemptCount) => {
|
|
48
53
|
stateRef.current = defaultLoadingState(attemptCount || stateRef.current.attemptCount);
|
|
49
54
|
};
|
|
@@ -95,6 +100,7 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = cu
|
|
|
95
100
|
autoStart: resumedAutoStart,
|
|
96
101
|
startCoords,
|
|
97
102
|
onSessionInvalidated,
|
|
103
|
+
container,
|
|
98
104
|
onReload
|
|
99
105
|
}, mountKey));
|
|
100
106
|
} else if (captchaType === CaptchaType.puzzle) {
|
|
@@ -106,7 +112,8 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = cu
|
|
|
106
112
|
i18n,
|
|
107
113
|
autoStart: resumedAutoStart,
|
|
108
114
|
startCoords,
|
|
109
|
-
onSessionInvalidated
|
|
115
|
+
onSessionInvalidated,
|
|
116
|
+
container
|
|
110
117
|
}, mountKey));
|
|
111
118
|
} else {
|
|
112
119
|
const ProcaptchaPow = await ProcaptchaPowLoader();
|
|
@@ -118,7 +125,8 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = cu
|
|
|
118
125
|
onEscalate,
|
|
119
126
|
autoStart: resumedAutoStart,
|
|
120
127
|
startCoords,
|
|
121
|
-
onSessionInvalidated
|
|
128
|
+
onSessionInvalidated,
|
|
129
|
+
container
|
|
122
130
|
}, mountKey));
|
|
123
131
|
}
|
|
124
132
|
};
|
|
@@ -168,11 +176,47 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = cu
|
|
|
168
176
|
}
|
|
169
177
|
});
|
|
170
178
|
};
|
|
179
|
+
const startManually = async (autoStart, coords) => {
|
|
180
|
+
if (manualStartedRef.current) return;
|
|
181
|
+
manualStartedRef.current = true;
|
|
182
|
+
pendingRetryCoordsRef.current = coords ?? null;
|
|
183
|
+
nextMountAutoStartRef.current = autoStart;
|
|
184
|
+
setComponentToRender(renderPlaceholder(config.theme, config.mode, stateRef.current.errorMessage, i18n.isInitialized, i18n.t, true));
|
|
185
|
+
await start();
|
|
186
|
+
};
|
|
187
|
+
manualCheckboxHandlerRef.current = async (event) => {
|
|
188
|
+
let x = 0;
|
|
189
|
+
let y = 0;
|
|
190
|
+
const nativeEvent = event.nativeEvent;
|
|
191
|
+
if ("clientX" in nativeEvent && "clientY" in nativeEvent) {
|
|
192
|
+
x = nativeEvent.clientX;
|
|
193
|
+
y = nativeEvent.clientY;
|
|
194
|
+
}
|
|
195
|
+
await startManually(true, normaliseRetryCoords(x, y) ?? void 0);
|
|
196
|
+
};
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
if (!manualStart) return;
|
|
199
|
+
const onStartEvent = (event) => {
|
|
200
|
+
const detail = event.detail;
|
|
201
|
+
if (detail?.element && container && !detail.element.contains(container)) return;
|
|
202
|
+
startManually(false);
|
|
203
|
+
};
|
|
204
|
+
const onExecuteEvent = () => {
|
|
205
|
+
startManually(true);
|
|
206
|
+
};
|
|
207
|
+
document.addEventListener(PROCAPTCHA_START_EVENT, onStartEvent);
|
|
208
|
+
document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, onExecuteEvent);
|
|
209
|
+
return () => {
|
|
210
|
+
document.removeEventListener(PROCAPTCHA_START_EVENT, onStartEvent);
|
|
211
|
+
document.removeEventListener(PROCAPTCHA_EXECUTE_EVENT, onExecuteEvent);
|
|
212
|
+
};
|
|
213
|
+
}, [manualStart, container]);
|
|
171
214
|
const startedForKeyRef = useRef(null);
|
|
172
215
|
useEffect(() => {
|
|
173
216
|
const key = `${config.account?.address ?? ""}|${config.language ?? ""}|${config.mode ?? ""}`;
|
|
174
217
|
if (startedForKeyRef.current === key) return;
|
|
175
218
|
startedForKeyRef.current = key;
|
|
219
|
+
if (manualStart) return;
|
|
176
220
|
start();
|
|
177
221
|
}, [
|
|
178
222
|
config.account?.address,
|
|
@@ -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,
|
|
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,EACtB,sBAAsB,EAGtB,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA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,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC;YACnE,QAAQ,CAAC,mBAAmB,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC;QACxE,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;IAmB7B,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,IAAI,WAAW;YAAE,OAAO;QACxB,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"}
|
|
@@ -11,12 +11,14 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
11
11
|
var ProcaptchaLoader = async () => (await import("@prosopo/procaptcha-react")).Procaptcha;
|
|
12
12
|
var ProcaptchaPuzzleLoader = async () => (await import("@prosopo/procaptcha-puzzle")).ProcaptchaPuzzle;
|
|
13
13
|
var ProcaptchaPowLoader = async () => (await import("@prosopo/procaptcha-pow")).ProcaptchaPow;
|
|
14
|
-
var
|
|
14
|
+
var PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
|
|
15
|
+
var noopCheckboxHandler = async (_event) => {};
|
|
16
|
+
var renderPlaceholder = (theme, mode, errorMessage, isTranslationLoaded, translationFn, loading, onChange = noopCheckboxHandler) => {
|
|
15
17
|
const checkboxTheme = "light" === theme ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme;
|
|
16
18
|
if (mode === "invisible") return null;
|
|
17
19
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_prosopo_procaptcha_common.Checkbox, {
|
|
18
20
|
theme: checkboxTheme,
|
|
19
|
-
onChange
|
|
21
|
+
onChange,
|
|
20
22
|
checked: false,
|
|
21
23
|
labelText: isTranslationLoaded ? translationFn("WIDGET.I_AM_HUMAN") : "",
|
|
22
24
|
error: errorMessage,
|
|
@@ -35,6 +37,9 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = re
|
|
|
35
37
|
const sessionInvalidatedFiredRef = (0, react.useRef)(false);
|
|
36
38
|
const mountCountRef = (0, react.useRef)(0);
|
|
37
39
|
const nextMountAutoStartRef = (0, react.useRef)(false);
|
|
40
|
+
const manualStart = config.startMode === _prosopo_types.StartModeEnum.manual;
|
|
41
|
+
const manualStartedRef = (0, react.useRef)(false);
|
|
42
|
+
const manualCheckboxHandlerRef = (0, react.useRef)(noopCheckboxHandler);
|
|
38
43
|
(0, react.useEffect)(() => {
|
|
39
44
|
if (!config.language) return;
|
|
40
45
|
if (i18n) {
|
|
@@ -43,7 +48,7 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = re
|
|
|
43
48
|
}
|
|
44
49
|
(0, _prosopo_locale.loadI18next)(false, config.language);
|
|
45
50
|
}, [i18n, config.language]);
|
|
46
|
-
const [componentToRender, setComponentToRender] = (0, react.useState)(renderPlaceholder(config.theme, config.mode, stateRef.current.errorMessage, i18n.isInitialized, i18n.t,
|
|
51
|
+
const [componentToRender, setComponentToRender] = (0, react.useState)(renderPlaceholder(config.theme, config.mode, stateRef.current.errorMessage, i18n.isInitialized, i18n.t, !manualStart, manualStart ? (event) => manualCheckboxHandlerRef.current(event) : void 0));
|
|
47
52
|
const resetState = (attemptCount) => {
|
|
48
53
|
stateRef.current = defaultLoadingState(attemptCount || stateRef.current.attemptCount);
|
|
49
54
|
};
|
|
@@ -95,6 +100,7 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = re
|
|
|
95
100
|
autoStart: resumedAutoStart,
|
|
96
101
|
startCoords,
|
|
97
102
|
onSessionInvalidated,
|
|
103
|
+
container,
|
|
98
104
|
onReload
|
|
99
105
|
}, mountKey));
|
|
100
106
|
} else if (captchaType === _prosopo_types.CaptchaType.puzzle) {
|
|
@@ -106,7 +112,8 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = re
|
|
|
106
112
|
i18n,
|
|
107
113
|
autoStart: resumedAutoStart,
|
|
108
114
|
startCoords,
|
|
109
|
-
onSessionInvalidated
|
|
115
|
+
onSessionInvalidated,
|
|
116
|
+
container
|
|
110
117
|
}, mountKey));
|
|
111
118
|
} else {
|
|
112
119
|
const ProcaptchaPow = await ProcaptchaPowLoader();
|
|
@@ -118,7 +125,8 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = re
|
|
|
118
125
|
onEscalate,
|
|
119
126
|
autoStart: resumedAutoStart,
|
|
120
127
|
startCoords,
|
|
121
|
-
onSessionInvalidated
|
|
128
|
+
onSessionInvalidated,
|
|
129
|
+
container
|
|
122
130
|
}, mountKey));
|
|
123
131
|
}
|
|
124
132
|
};
|
|
@@ -168,11 +176,47 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = re
|
|
|
168
176
|
}
|
|
169
177
|
});
|
|
170
178
|
};
|
|
179
|
+
const startManually = async (autoStart, coords) => {
|
|
180
|
+
if (manualStartedRef.current) return;
|
|
181
|
+
manualStartedRef.current = true;
|
|
182
|
+
pendingRetryCoordsRef.current = coords ?? null;
|
|
183
|
+
nextMountAutoStartRef.current = autoStart;
|
|
184
|
+
setComponentToRender(renderPlaceholder(config.theme, config.mode, stateRef.current.errorMessage, i18n.isInitialized, i18n.t, true));
|
|
185
|
+
await start();
|
|
186
|
+
};
|
|
187
|
+
manualCheckboxHandlerRef.current = async (event) => {
|
|
188
|
+
let x = 0;
|
|
189
|
+
let y = 0;
|
|
190
|
+
const nativeEvent = event.nativeEvent;
|
|
191
|
+
if ("clientX" in nativeEvent && "clientY" in nativeEvent) {
|
|
192
|
+
x = nativeEvent.clientX;
|
|
193
|
+
y = nativeEvent.clientY;
|
|
194
|
+
}
|
|
195
|
+
await startManually(true, require_sessionInvalidatedRecovery.normaliseRetryCoords(x, y) ?? void 0);
|
|
196
|
+
};
|
|
197
|
+
(0, react.useEffect)(() => {
|
|
198
|
+
if (!manualStart) return;
|
|
199
|
+
const onStartEvent = (event) => {
|
|
200
|
+
const detail = event.detail;
|
|
201
|
+
if (detail?.element && container && !detail.element.contains(container)) return;
|
|
202
|
+
startManually(false);
|
|
203
|
+
};
|
|
204
|
+
const onExecuteEvent = () => {
|
|
205
|
+
startManually(true);
|
|
206
|
+
};
|
|
207
|
+
document.addEventListener(_prosopo_types.PROCAPTCHA_START_EVENT, onStartEvent);
|
|
208
|
+
document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, onExecuteEvent);
|
|
209
|
+
return () => {
|
|
210
|
+
document.removeEventListener(_prosopo_types.PROCAPTCHA_START_EVENT, onStartEvent);
|
|
211
|
+
document.removeEventListener(PROCAPTCHA_EXECUTE_EVENT, onExecuteEvent);
|
|
212
|
+
};
|
|
213
|
+
}, [manualStart, container]);
|
|
171
214
|
const startedForKeyRef = (0, react.useRef)(null);
|
|
172
215
|
(0, react.useEffect)(() => {
|
|
173
216
|
const key = `${config.account?.address ?? ""}|${config.language ?? ""}|${config.mode ?? ""}`;
|
|
174
217
|
if (startedForKeyRef.current === key) return;
|
|
175
218
|
startedForKeyRef.current = key;
|
|
219
|
+
if (manualStart) return;
|
|
176
220
|
start();
|
|
177
221
|
}, [
|
|
178
222
|
config.account?.address,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manualStart.test.d.ts","sourceRoot":"","sources":["../../src/tests/manualStart.test.tsx"],"names":[],"mappings":"AAgCA,OAAO,CAAC,MAAM,CAAC;IACd,IAAI,wBAAwB,EAAE,OAAO,CAAC;CACtC"}
|