@prosopo/procaptcha-frictionless 2.13.22 → 2.14.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 +5 -5
- package/CHANGELOG.md +74 -0
- package/dist/ProcaptchaFrictionless.d.ts.map +1 -1
- package/dist/ProcaptchaFrictionless.js +45 -4
- package/dist/ProcaptchaFrictionless.js.map +1 -1
- package/dist/cjs/ProcaptchaFrictionless.cjs +44 -3
- 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 +74 -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.14.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.51 kB │ gzip: 2.59 kB
|
|
66
66
|
|
|
67
|
-
[32m✓ built in
|
|
67
|
+
[32m✓ built in 62ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-frictionless@2.
|
|
2
|
+
> @prosopo/procaptcha-frictionless@2.14.0 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
10:02
|
|
5
|
+
10:40:02 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
|
-
10:02
|
|
28
|
+
10:40:02 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/vite/NodejsPolarsNativeFilePlugin.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
29
29
|
|
|
30
|
-
10:02
|
|
30
|
+
10:40:02 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
|
-
10:02
|
|
32
|
+
10:40:02 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
|
-
10:02
|
|
34
|
+
10:40:02 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
|
-
10:02
|
|
36
|
+
10:40:02 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
|
-
10:02
|
|
38
|
+
10:40:02 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
|
-
10:02
|
|
40
|
+
10:40:02 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/logger.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
41
41
|
|
|
42
|
-
10:02
|
|
42
|
+
10:40:02 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'
|
|
43
43
|
|
|
44
|
-
10:02
|
|
44
|
+
10:40:02 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
|
-
10:02
|
|
46
|
+
10:40:02 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
|
-
10:02
|
|
48
|
+
10:40:02 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/index.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
|
|
49
49
|
|
|
50
|
-
10:02
|
|
50
|
+
10:40:02 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'
|
|
51
51
|
|
|
52
|
-
10:02
|
|
52
|
+
10:40:02 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/pair/decode.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
|
|
53
53
|
|
|
54
|
-
10:02
|
|
54
|
+
10:40:02 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
|
-
10:02
|
|
56
|
+
10:40:02 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'
|
|
57
57
|
|
|
58
|
-
10:02
|
|
58
|
+
10:40:02 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
|
-
10:02
|
|
60
|
+
10:40:02 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
|
-
10:02
|
|
62
|
+
10:40:02 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/index.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
|
|
63
63
|
|
|
64
|
-
10:02
|
|
64
|
+
10:40:02 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/index.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
|
|
65
65
|
|
|
66
|
-
10:02
|
|
66
|
+
10:40:02 PM - Project '../procaptcha-react/tsconfig.json' is up to date because newest input '../procaptcha-react/src/tests/captchaComponent.unit.test.tsx' is older than output '../procaptcha-react/tsconfig.tsbuildinfo'
|
|
67
67
|
|
|
68
|
-
10:02
|
|
68
|
+
10:40:02 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
69
69
|
|
|
70
|
-
10:02
|
|
70
|
+
10:40:02 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.14.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.14.0 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -32,6 +32,7 @@ ViteEsmConfig: .
|
|
|
32
32
|
}
|
|
33
33
|
{
|
|
34
34
|
externals: [
|
|
35
|
+
[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
|
|
35
36
|
'@prosopo/locale',
|
|
36
37
|
'@prosopo/procaptcha-pow',
|
|
37
38
|
'@prosopo/api',
|
|
@@ -53,7 +54,6 @@ ViteEsmConfig: .
|
|
|
53
54
|
'@prosopo/datasets'
|
|
54
55
|
]
|
|
55
56
|
}
|
|
56
|
-
[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
|
|
57
57
|
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
58
58
|
Bundle build started
|
|
59
59
|
[2K
|
|
@@ -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.85 kB │ gzip: 2.55 kB
|
|
71
71
|
|
|
72
|
-
[32m✓ built in
|
|
72
|
+
[32m✓ built in 49ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# @prosopo/procaptcha-frictionless
|
|
2
2
|
|
|
3
|
+
## 2.14.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
- 80f73c1: Sites can now control when the widget starts working.
|
|
7
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
- 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.
|
|
11
|
+
- 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.
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 89dd38a: chore(deps): batch the outstanding dependabot bumps into one upgrade
|
|
18
|
+
|
|
19
|
+
Rolls up dependabot PRs #3112, #3127-#3134 and #3159. Majors: `mongoose`
|
|
20
|
+
8 -> 9, `bson` 6 -> 7, `@noble/curves` 1 -> 2, `@polkadot/util-crypto`
|
|
21
|
+
13 -> 14, `@typegoose/auto-increment` 4 -> 5, `@babel/preset-env` 7 -> 8,
|
|
22
|
+
`@types/jsdom` 21 -> 30, `@types/bcrypt` 5 -> 6, `@actions/github` 6 -> 9,
|
|
23
|
+
`testcontainers` 11 -> 12. The rest are minor/patch.
|
|
24
|
+
|
|
25
|
+
Code changes the majors forced:
|
|
26
|
+
- `@noble/curves` v2 requires `.js` specifiers and renamed the point API,
|
|
27
|
+
so `secp256k1.ProjectivePoint.fromHex(...).toRawBytes()` becomes
|
|
28
|
+
`secp256k1.Point.fromBytes(...).toBytes()`, `RistrettoPoint` becomes
|
|
29
|
+
`ristretto255.Point`, and `abstract/utils` moves to `utils.js`.
|
|
30
|
+
- mongoose 9 drops `RootFilterQuery` (now `QueryFilter`), no longer sets
|
|
31
|
+
`background: true` on schema indexes by default, and no longer declares
|
|
32
|
+
`id` on `Document`, which un-hid a mismatch between
|
|
33
|
+
`updateDappUserCommitment`'s `Hash` parameter and the `string` `id` it
|
|
34
|
+
filters on.
|
|
35
|
+
- mongoose 9 rejects an aggregation-pipeline update (an array) unless the
|
|
36
|
+
call passes `updatePipeline: true`, so the six pipeline writes in
|
|
37
|
+
`ProviderDatabase` now opt in explicitly.
|
|
38
|
+
- mongoose 9's `castUpdate` throws on a `$setOnInsert` key inside `$set`.
|
|
39
|
+
`storeUserImageCaptchaSolution` passed its record straight in as the
|
|
40
|
+
update, and mongoose's `moveImmutableProperties` mutates that object on
|
|
41
|
+
an upsert -- adding the very `$setOnInsert` key the record then carried
|
|
42
|
+
into `CentralDbStreamer.streamImageRecord`. Image records stopped
|
|
43
|
+
reaching the central DB (the streamer is fire-and-forget, so it only
|
|
44
|
+
logged) and signup verification returned 500. The update is now an
|
|
45
|
+
explicit `$set` over a shallow copy.
|
|
46
|
+
- `@prosopo/database` moves from mongodb 6.20 to 7.5 to match the driver
|
|
47
|
+
mongoose 9 pulls, so bson 7 is the only copy resolvable in the package.
|
|
48
|
+
- `vitest`/`@vitest/coverage-v8` go to 4.1.11 alongside dependabot's
|
|
49
|
+
`@vitest/spy` bump; leaving them at 4.1.10 installed a second copy of
|
|
50
|
+
`@vitest/spy` and broke type inference in the provider test utils.
|
|
51
|
+
- Updated dependencies [89dd38a]
|
|
52
|
+
- Updated dependencies [80f73c1]
|
|
53
|
+
- Updated dependencies [8a670d3]
|
|
54
|
+
- @prosopo/api@4.1.5
|
|
55
|
+
- @prosopo/common@3.1.53
|
|
56
|
+
- @prosopo/locale@3.4.1
|
|
57
|
+
- @prosopo/procaptcha-common@2.12.6
|
|
58
|
+
- @prosopo/procaptcha-pow@2.11.6
|
|
59
|
+
- @prosopo/procaptcha-puzzle@2.11.6
|
|
60
|
+
- @prosopo/procaptcha-react@2.9.122
|
|
61
|
+
- @prosopo/types@5.6.0
|
|
62
|
+
- @prosopo/widget-skeleton@2.8.7
|
|
63
|
+
|
|
64
|
+
## 2.13.23
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [a62b994]
|
|
68
|
+
- Updated dependencies [a447afa]
|
|
69
|
+
- Updated dependencies [37ab95c]
|
|
70
|
+
- @prosopo/types@5.5.3
|
|
71
|
+
- @prosopo/procaptcha-puzzle@2.11.5
|
|
72
|
+
- @prosopo/api@4.1.4
|
|
73
|
+
- @prosopo/procaptcha-common@2.12.5
|
|
74
|
+
- @prosopo/procaptcha-pow@2.11.5
|
|
75
|
+
- @prosopo/procaptcha-react@2.9.121
|
|
76
|
+
|
|
3
77
|
## 2.13.22
|
|
4
78
|
### Patch Changes
|
|
5
79
|
|
|
@@ -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,gCAwX7B,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
|
};
|
|
@@ -168,11 +173,47 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = cu
|
|
|
168
173
|
}
|
|
169
174
|
});
|
|
170
175
|
};
|
|
176
|
+
const startManually = async (autoStart, coords) => {
|
|
177
|
+
if (manualStartedRef.current) return;
|
|
178
|
+
manualStartedRef.current = true;
|
|
179
|
+
pendingRetryCoordsRef.current = coords ?? null;
|
|
180
|
+
nextMountAutoStartRef.current = autoStart;
|
|
181
|
+
setComponentToRender(renderPlaceholder(config.theme, config.mode, stateRef.current.errorMessage, i18n.isInitialized, i18n.t, true));
|
|
182
|
+
await start();
|
|
183
|
+
};
|
|
184
|
+
manualCheckboxHandlerRef.current = async (event) => {
|
|
185
|
+
let x = 0;
|
|
186
|
+
let y = 0;
|
|
187
|
+
const nativeEvent = event.nativeEvent;
|
|
188
|
+
if ("clientX" in nativeEvent && "clientY" in nativeEvent) {
|
|
189
|
+
x = nativeEvent.clientX;
|
|
190
|
+
y = nativeEvent.clientY;
|
|
191
|
+
}
|
|
192
|
+
await startManually(true, normaliseRetryCoords(x, y) ?? void 0);
|
|
193
|
+
};
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (!manualStart) return;
|
|
196
|
+
const onStartEvent = (event) => {
|
|
197
|
+
const detail = event.detail;
|
|
198
|
+
if (detail?.element && container && !detail.element.contains(container)) return;
|
|
199
|
+
startManually(false);
|
|
200
|
+
};
|
|
201
|
+
const onExecuteEvent = () => {
|
|
202
|
+
startManually(true);
|
|
203
|
+
};
|
|
204
|
+
document.addEventListener(PROCAPTCHA_START_EVENT, onStartEvent);
|
|
205
|
+
document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, onExecuteEvent);
|
|
206
|
+
return () => {
|
|
207
|
+
document.removeEventListener(PROCAPTCHA_START_EVENT, onStartEvent);
|
|
208
|
+
document.removeEventListener(PROCAPTCHA_EXECUTE_EVENT, onExecuteEvent);
|
|
209
|
+
};
|
|
210
|
+
}, [manualStart, container]);
|
|
171
211
|
const startedForKeyRef = useRef(null);
|
|
172
212
|
useEffect(() => {
|
|
173
213
|
const key = `${config.account?.address ?? ""}|${config.language ?? ""}|${config.mode ?? ""}`;
|
|
174
214
|
if (startedForKeyRef.current === key) return;
|
|
175
215
|
startedForKeyRef.current = key;
|
|
216
|
+
if (manualStart) return;
|
|
176
217
|
start();
|
|
177
218
|
}, [
|
|
178
219
|
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,EAA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AAC;QACF,QAAQ,CAAC,gBAAgB,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC;QAChE,QAAQ,CAAC,gBAAgB,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC;QACpE,OAAO,GAAG,EAAE;YACX,QAAQ,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
|
};
|
|
@@ -168,11 +173,47 @@ var ProcaptchaFrictionless = ({ config, callbacks, restart, i18n, detectBot = re
|
|
|
168
173
|
}
|
|
169
174
|
});
|
|
170
175
|
};
|
|
176
|
+
const startManually = async (autoStart, coords) => {
|
|
177
|
+
if (manualStartedRef.current) return;
|
|
178
|
+
manualStartedRef.current = true;
|
|
179
|
+
pendingRetryCoordsRef.current = coords ?? null;
|
|
180
|
+
nextMountAutoStartRef.current = autoStart;
|
|
181
|
+
setComponentToRender(renderPlaceholder(config.theme, config.mode, stateRef.current.errorMessage, i18n.isInitialized, i18n.t, true));
|
|
182
|
+
await start();
|
|
183
|
+
};
|
|
184
|
+
manualCheckboxHandlerRef.current = async (event) => {
|
|
185
|
+
let x = 0;
|
|
186
|
+
let y = 0;
|
|
187
|
+
const nativeEvent = event.nativeEvent;
|
|
188
|
+
if ("clientX" in nativeEvent && "clientY" in nativeEvent) {
|
|
189
|
+
x = nativeEvent.clientX;
|
|
190
|
+
y = nativeEvent.clientY;
|
|
191
|
+
}
|
|
192
|
+
await startManually(true, require_sessionInvalidatedRecovery.normaliseRetryCoords(x, y) ?? void 0);
|
|
193
|
+
};
|
|
194
|
+
(0, react.useEffect)(() => {
|
|
195
|
+
if (!manualStart) return;
|
|
196
|
+
const onStartEvent = (event) => {
|
|
197
|
+
const detail = event.detail;
|
|
198
|
+
if (detail?.element && container && !detail.element.contains(container)) return;
|
|
199
|
+
startManually(false);
|
|
200
|
+
};
|
|
201
|
+
const onExecuteEvent = () => {
|
|
202
|
+
startManually(true);
|
|
203
|
+
};
|
|
204
|
+
document.addEventListener(_prosopo_types.PROCAPTCHA_START_EVENT, onStartEvent);
|
|
205
|
+
document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, onExecuteEvent);
|
|
206
|
+
return () => {
|
|
207
|
+
document.removeEventListener(_prosopo_types.PROCAPTCHA_START_EVENT, onStartEvent);
|
|
208
|
+
document.removeEventListener(PROCAPTCHA_EXECUTE_EVENT, onExecuteEvent);
|
|
209
|
+
};
|
|
210
|
+
}, [manualStart, container]);
|
|
171
211
|
const startedForKeyRef = (0, react.useRef)(null);
|
|
172
212
|
(0, react.useEffect)(() => {
|
|
173
213
|
const key = `${config.account?.address ?? ""}|${config.language ?? ""}|${config.mode ?? ""}`;
|
|
174
214
|
if (startedForKeyRef.current === key) return;
|
|
175
215
|
startedForKeyRef.current = key;
|
|
216
|
+
if (manualStart) return;
|
|
176
217
|
start();
|
|
177
218
|
}, [
|
|
178
219
|
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"}
|