@prosopo/procaptcha-bundle 4.2.4 → 4.3.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.
Files changed (36) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +16 -15
  2. package/.turbo/turbo-build$colon$tsc.log +26 -26
  3. package/.turbo/turbo-build.log +7 -6
  4. package/CHANGELOG.md +68 -0
  5. package/dist/cjs/index.cjs +45 -10
  6. package/dist/cjs/util/captcha/captchaRenderer.cjs +2 -0
  7. package/dist/cjs/util/startMode.cjs +20 -0
  8. package/dist/index.d.ts +3 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +45 -11
  11. package/dist/index.js.map +1 -1
  12. package/dist/tests/procaptchaReady.unit.test.js +1 -0
  13. package/dist/tests/procaptchaReady.unit.test.js.map +1 -1
  14. package/dist/tests/start.unit.test.d.ts +2 -0
  15. package/dist/tests/start.unit.test.d.ts.map +1 -0
  16. package/dist/tests/start.unit.test.js +100 -0
  17. package/dist/tests/start.unit.test.js.map +1 -0
  18. package/dist/tests/util/startMode.test.d.ts +2 -0
  19. package/dist/tests/util/startMode.test.d.ts.map +1 -0
  20. package/dist/tests/util/startMode.test.js +48 -0
  21. package/dist/tests/util/startMode.test.js.map +1 -0
  22. package/dist/util/captcha/captchaRenderer.d.ts.map +1 -1
  23. package/dist/util/captcha/captchaRenderer.js +2 -0
  24. package/dist/util/captcha/captchaRenderer.js.map +1 -1
  25. package/dist/util/startMode.d.ts +5 -0
  26. package/dist/util/startMode.d.ts.map +1 -0
  27. package/dist/util/startMode.js +18 -0
  28. package/dist/util/startMode.js.map +1 -0
  29. package/package.json +12 -12
  30. package/src/index.ts +53 -10
  31. package/src/tests/procaptchaReady.unit.test.ts +1 -0
  32. package/src/tests/start.unit.test.ts +152 -0
  33. package/src/tests/util/startMode.test.ts +113 -0
  34. package/src/util/captcha/captchaRenderer.tsx +2 -0
  35. package/src/util/startMode.ts +53 -0
  36. package/tsconfig.tsbuildinfo +1 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > @prosopo/procaptcha-bundle@4.2.4 build:cjs
2
+ > @prosopo/procaptcha-bundle@4.3.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: .
@@ -57,21 +57,22 @@ ViteCommonJSConfig: .
57
57
  vite v8.1.5 building ssr environment for production...
58
58
  Bundle build started
59
59
  
60
- 11 modules transformed.
60
+ 12 modules transformed.
61
61
  rendering chunks...
62
62
  computing gzip size...
63
- dist/cjs/util/widgetThemeResolver.cjs 0.57 kB │ gzip: 0.29 kB
64
- dist/cjs/util/timeout.cjs 0.63 kB │ gzip: 0.29 kB
65
- dist/cjs/util/config.cjs 0.66 kB │ gzip: 0.33 kB
66
- dist/cjs/util/captcha/components/bundleCaptcha.cjs 0.82 kB │ gzip: 0.39 kB
67
- dist/cjs/util/configCreator.cjs 0.88 kB │ gzip: 0.46 kB
68
- dist/cjs/_virtual/_rolldown/runtime.cjs 1.00 kB │ gzip: 0.50 kB
69
- dist/cjs/util/clientSession.cjs 1.08 kB │ gzip: 0.56 kB
70
- dist/cjs/util/language.cjs 1.08 kB │ gzip: 0.45 kB
71
- dist/cjs/util/captcha/captchaRenderer.cjs 2.40 kB │ gzip: 0.80 kB
72
- dist/cjs/util/widgetFactory.cjs 2.73 kB │ gzip: 0.89 kB
73
- dist/cjs/index.cjs 9.20 kB │ gzip: 3.22 kB
63
+ dist/cjs/util/widgetThemeResolver.cjs 0.57 kB │ gzip: 0.29 kB
64
+ dist/cjs/util/timeout.cjs 0.63 kB │ gzip: 0.29 kB
65
+ dist/cjs/util/config.cjs 0.66 kB │ gzip: 0.33 kB
66
+ dist/cjs/util/captcha/components/bundleCaptcha.cjs 0.82 kB │ gzip: 0.39 kB
67
+ dist/cjs/util/configCreator.cjs 0.88 kB │ gzip: 0.46 kB
68
+ dist/cjs/util/startMode.cjs 0.89 kB │ gzip: 0.40 kB
69
+ dist/cjs/_virtual/_rolldown/runtime.cjs 1.00 kB │ gzip: 0.50 kB
70
+ dist/cjs/util/clientSession.cjs 1.08 kB │ gzip: 0.56 kB
71
+ dist/cjs/util/language.cjs 1.08 kB │ gzip: 0.45 kB
72
+ dist/cjs/util/captcha/captchaRenderer.cjs 2.52 kB │ gzip: 0.82 kB
73
+ dist/cjs/util/widgetFactory.cjs 2.73 kB │ gzip: 0.89 kB
74
+ dist/cjs/index.cjs 10.34 kB │ gzip: 3.46 kB
74
75
 
75
- [MIXED_EXPORTS] Entry module "src/index.ts" is using named (including "default", "execute", "remove", "render", "reset") and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
76
+ [MIXED_EXPORTS] Entry module "src/index.ts" is using named (including "default", "execute", "remove", "render", "reset", "start") and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
76
77
  
77
- ✓ built in 55ms
78
+ ✓ built in 68ms
@@ -1,8 +1,8 @@
1
1
 
2
- > @prosopo/procaptcha-bundle@4.2.4 build:tsc
2
+ > @prosopo/procaptcha-bundle@4.3.0 build:tsc
3
3
  > tsc --build --verbose
4
4
 
5
- 10:02:45 PM - Projects in this build:
5
+ 10:40:06 PM - Projects in this build:
6
6
  * ../../dev/config/tsconfig.json
7
7
  * ../util/tsconfig.json
8
8
  * ../logger/tsconfig.json
@@ -27,51 +27,51 @@
27
27
  * ../procaptcha-frictionless/tsconfig.json
28
28
  * tsconfig.json
29
29
 
30
- 10:02:45 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
30
+ 10:40:06 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'
31
31
 
32
- 10:02:45 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
32
+ 10:40:06 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:45 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/logger.ts' is older than output '../logger/tsconfig.tsbuildinfo'
34
+ 10:40:06 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/logger.ts' is older than output '../logger/tsconfig.tsbuildinfo'
35
35
 
36
- 10:02:45 PM - Project '../dotenv/tsconfig.json' is up to date because newest input '../dotenv/src/env.ts' is older than output '../dotenv/tsconfig.tsbuildinfo'
36
+ 10:40:06 PM - Project '../dotenv/tsconfig.json' is up to date because newest input '../dotenv/src/env.ts' is older than output '../dotenv/tsconfig.tsbuildinfo'
37
37
 
38
- 10:02:45 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
38
+ 10:40:06 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
39
39
 
40
- 10:02:45 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
40
+ 10:40:06 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'
41
41
 
42
- 10:02:45 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'
42
+ 10:40:06 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'
43
43
 
44
- 10:02:45 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/tests/apiHarness.ts' is older than output '../api/tsconfig.tsbuildinfo'
44
+ 10:40:06 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/tests/apiHarness.ts' is older than output '../api/tsconfig.tsbuildinfo'
45
45
 
46
- 10:02:45 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
46
+ 10:40:06 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'
47
47
 
48
- 10:02:45 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
48
+ 10:40:06 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
49
49
 
50
- 10:02:45 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
50
+ 10:40:06 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
51
51
 
52
- 10:02:45 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'
52
+ 10:40:06 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'
53
53
 
54
- 10:02:45 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'
54
+ 10:40:06 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'
55
55
 
56
- 10:02:45 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/index.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
56
+ 10:40:06 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/pair/decode.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
57
57
 
58
- 10:02:45 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/tests/cryptoWorker.unit.test.ts' is older than output '../account/tsconfig.tsbuildinfo'
58
+ 10:40:06 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
59
59
 
60
- 10:02:45 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'
60
+ 10:40:06 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'
61
61
 
62
- 10:02:45 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'
62
+ 10:40:06 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'
63
63
 
64
- 10:02:45 PM - Project '../procaptcha-puzzle/tsconfig.json' is up to date because newest input '../procaptcha-puzzle/src/index.ts' is older than output '../procaptcha-puzzle/tsconfig.tsbuildinfo'
64
+ 10:40:06 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'
65
65
 
66
- 10:02:45 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'
66
+ 10:40:06 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/index.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
67
67
 
68
- 10:02:45 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/index.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
68
+ 10:40:06 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/index.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
69
69
 
70
- 10:02:45 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'
70
+ 10:40:06 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'
71
71
 
72
- 10:02:45 PM - Project '../procaptcha-frictionless/tsconfig.json' is up to date because newest input '../procaptcha-frictionless/src/ProcaptchaFrictionless.tsx' is older than output '../procaptcha-frictionless/tsconfig.tsbuildinfo'
72
+ 10:40:06 PM - Project '../procaptcha-frictionless/tsconfig.json' is up to date because newest input '../procaptcha-frictionless/src/ProcaptchaFrictionless.tsx' is older than output '../procaptcha-frictionless/tsconfig.tsbuildinfo'
73
73
 
74
- 10:02:45 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
74
+ 10:40:06 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
75
75
 
76
- 10:02:45 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-bundle/tsconfig.json'...
76
+ 10:40:06 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-bundle/tsconfig.json'...
77
77
 
@@ -1,9 +1,9 @@
1
1
 
2
- > @prosopo/procaptcha-bundle@4.2.4 build
2
+ > @prosopo/procaptcha-bundle@4.3.0 build
3
3
  > npm run build:cross-env -- --mode ${NODE_ENV:-development}
4
4
 
5
5
 
6
- > @prosopo/procaptcha-bundle@4.2.4 build:cross-env
6
+ > @prosopo/procaptcha-bundle@4.3.0 build:cross-env
7
7
  > vite build --config vite.esm.config.ts --mode production
8
8
 
9
9
  ViteEsmConfig: .
@@ -61,7 +61,7 @@ ViteEsmConfig: .
61
61
  vite v8.1.5 building ssr environment for production...
62
62
  Bundle build started
63
63
  
64
- 11 modules transformed.
64
+ 12 modules transformed.
65
65
  rendering chunks...
66
66
  computing gzip size...
67
67
  dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
@@ -69,11 +69,12 @@ dist/util/widgetThemeResolver.js 0.55 kB │ gzip: 0.29 kB
69
69
  dist/util/timeout.js 0.61 kB │ gzip: 0.29 kB
70
70
  dist/util/config.js 0.62 kB │ gzip: 0.33 kB
71
71
  dist/util/captcha/components/bundleCaptcha.js 0.68 kB │ gzip: 0.35 kB
72
+ dist/util/startMode.js 0.78 kB │ gzip: 0.39 kB
72
73
  dist/util/configCreator.js 0.86 kB │ gzip: 0.45 kB
73
74
  dist/util/language.js 1.01 kB │ gzip: 0.44 kB
74
75
  dist/util/clientSession.js 1.03 kB │ gzip: 0.55 kB
75
- dist/util/captcha/captchaRenderer.js 2.04 kB │ gzip: 0.72 kB
76
+ dist/util/captcha/captchaRenderer.js 2.14 kB │ gzip: 0.74 kB
76
77
  dist/util/widgetFactory.js 2.52 kB │ gzip: 0.85 kB
77
- dist/index.js 8.85 kB │ gzip: 3.14 kB
78
+ dist/index.js 9.91 kB │ gzip: 3.36 kB
78
79
 
79
- ✓ built in 54ms
80
+ ✓ built in 57ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,73 @@
1
1
  # @prosopo/procaptcha-bundle
2
2
 
3
+ ## 4.3.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/dotenv@3.0.54
55
+ - @prosopo/locale@3.4.1
56
+ - @prosopo/procaptcha-common@2.12.6
57
+ - @prosopo/procaptcha-frictionless@2.14.0
58
+ - @prosopo/types@5.6.0
59
+ - @prosopo/util@3.3.8
60
+ - @prosopo/widget-skeleton@2.8.7
61
+
62
+ ## 4.2.5
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [a62b994]
66
+ - Updated dependencies [a447afa]
67
+ - @prosopo/types@5.5.3
68
+ - @prosopo/procaptcha-common@2.12.5
69
+ - @prosopo/procaptcha-frictionless@2.13.23
70
+
3
71
  ## 4.2.4
4
72
  ### Patch Changes
5
73
 
@@ -3,9 +3,11 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_config = require("./util/config.cjs");
6
+ const require_startMode = require("./util/startMode.cjs");
6
7
  const require_widgetFactory = require("./util/widgetFactory.cjs");
7
8
  const require_widgetThemeResolver = require("./util/widgetThemeResolver.cjs");
8
9
  let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
10
+ let _prosopo_types = require("@prosopo/types");
9
11
  let _prosopo_util = require("@prosopo/util");
10
12
  //#region src/index.ts
11
13
  var BUNDLE_NAMES = ["procaptcha.bundle.iife.js", "procaptcha.bundle.js"];
@@ -37,6 +39,7 @@ var widgetFactory = new require_widgetFactory.WidgetFactory(new require_widgetTh
37
39
  */
38
40
  var startDetectorPrefetch = (siteKey, flags) => {
39
41
  if (!siteKey) return;
42
+ if (flags.startMode === _prosopo_types.StartModeEnum.manual) return;
40
43
  Promise.all([import("@prosopo/procaptcha-frictionless"), import("@prosopo/procaptcha-common")]).then(([frictionless, common]) => {
41
44
  frictionless.prefetchDetector(process.env.PROSOPO_DEFAULT_ENVIRONMENT, common.pickIpMode(flags), siteKey);
42
45
  }).catch(() => void 0);
@@ -51,18 +54,21 @@ var implicitRender = async () => {
51
54
  const web3 = firstElement.getAttribute("data-web3");
52
55
  const ipv4 = firstElement.getAttribute("data-ipv4") === "true";
53
56
  const ipv6 = firstElement.getAttribute("data-ipv6") === "true";
57
+ const startMode = require_startMode.resolveStartMode(void 0, firstElement);
54
58
  if (!siteKey) {
55
59
  console.error("No site key found");
56
60
  return;
57
61
  }
58
62
  startDetectorPrefetch(siteKey, {
59
63
  ipv4,
60
- ipv6
64
+ ipv6,
65
+ startMode
61
66
  });
62
67
  const implicitRenderOptions = {
63
68
  siteKey,
64
69
  ipv4,
65
- ipv6
70
+ ipv6,
71
+ startMode
66
72
  };
67
73
  registerWidgets(await widgetFactory.createWidgets(elements, implicitRenderOptions, !(web3 === "true")), elements, implicitRenderOptions, !(web3 === "true"), false);
68
74
  }
@@ -72,15 +78,18 @@ var implicitRender = async () => {
72
78
  const callback = button.getAttribute("data-callback") || "";
73
79
  const ipv4 = button.getAttribute("data-ipv4") === "true";
74
80
  const ipv6 = button.getAttribute("data-ipv6") === "true";
81
+ const startMode = require_startMode.resolveStartMode(void 0, button);
75
82
  startDetectorPrefetch(siteKey, {
76
83
  ipv4,
77
- ipv6
84
+ ipv6,
85
+ startMode
78
86
  });
79
87
  const buttonRenderOptions = {
80
88
  siteKey,
81
89
  callback,
82
90
  ipv4,
83
- ipv6
91
+ ipv6,
92
+ startMode
84
93
  };
85
94
  registerWidgets(await widgetFactory.createWidgets([button], buttonRenderOptions, true, true), [button], buttonRenderOptions, true, true);
86
95
  button.addEventListener("click", async (event) => {
@@ -99,7 +108,10 @@ var implicitRender = async () => {
99
108
  * factory legitimately yields nothing for an element it cannot mount into.
100
109
  */
101
110
  var render = async (element, renderOptions) => {
102
- startDetectorPrefetch(renderOptions.siteKey, renderOptions);
111
+ startDetectorPrefetch(renderOptions.siteKey, {
112
+ ...renderOptions,
113
+ startMode: require_startMode.resolveStartMode(renderOptions, element)
114
+ });
103
115
  const hasInvisibleSize = Object.prototype.hasOwnProperty.call(renderOptions, "size") && renderOptions.size === "invisible";
104
116
  const isWeb2 = !renderOptions.web3;
105
117
  const invisible = hasInvisibleSize || element.tagName.toLowerCase() === "button";
@@ -135,6 +147,27 @@ var execute = () => {
135
147
  });
136
148
  document.dispatchEvent(executeEvent);
137
149
  };
150
+ /** Starts a `startMode: "manual"` widget; omit the id to start all of them. */
151
+ var start = (widgetId) => {
152
+ const ids = void 0 === widgetId ? Array.from(procaptchaWidgets.keys()) : [widgetId];
153
+ if (ids.length === 0) {
154
+ console.error("No Procaptcha widgets found to start");
155
+ return;
156
+ }
157
+ for (const id of ids) {
158
+ const entry = procaptchaWidgets.get(id);
159
+ if (!entry) {
160
+ console.error(`No Procaptcha widget found with id ${id}`);
161
+ continue;
162
+ }
163
+ const detail = { element: entry.element };
164
+ document.dispatchEvent(new CustomEvent(_prosopo_types.PROCAPTCHA_START_EVENT, {
165
+ detail,
166
+ bubbles: true,
167
+ cancelable: false
168
+ }));
169
+ }
170
+ };
138
171
  function findProcaptchaContainers() {
139
172
  const containers = [];
140
173
  const invisibleContainers = Array.from(document.querySelectorAll("[data-size=\"invisible\"]"));
@@ -145,7 +178,7 @@ function findProcaptchaContainers() {
145
178
  for (const container of idContainers) if (!containers.includes(container)) containers.push(container);
146
179
  return containers;
147
180
  }
148
- var start = () => {
181
+ var boot = () => {
149
182
  const { onloadUrlCallback, renderExplicit } = require_config.extractParams(BUNDLE_NAMES);
150
183
  let readyCalled = false;
151
184
  if (renderExplicit !== "explicit") {
@@ -167,7 +200,7 @@ var start = () => {
167
200
  * widget id to reset one widget, or omit it to reset every widget on the page.
168
201
  *
169
202
  * This remounts rather than merely unmounting. The previous implementation
170
- * unmounted every root and then called `start()`, which only re-renders when
203
+ * unmounted every root and then called `boot()`, which only re-renders when
171
204
  * the page uses implicit rendering — and even then only via the
172
205
  * `document.readyState` fallback, because the script's `load` event has long
173
206
  * since fired. On an explicitly-rendered page nothing came back at all: the
@@ -175,7 +208,7 @@ var start = () => {
175
208
  * request was ever made. Rebuilding from the stored descriptor makes reset
176
209
  * behave the same way on both paths.
177
210
  *
178
- * `start()` is deliberately not called here any more. It re-renders implicit
211
+ * `boot()` is deliberately not called here any more. It re-renders implicit
179
212
  * widgets, which would double up with the remount below, and it attaches
180
213
  * another `load` listener to the script tag on every call.
181
214
  */
@@ -214,7 +247,8 @@ window.procaptcha = {
214
247
  render,
215
248
  reset,
216
249
  remove,
217
- execute
250
+ execute,
251
+ start
218
252
  };
219
253
  var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
220
254
  detail: { timestamp: Date.now() },
@@ -222,10 +256,11 @@ var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
222
256
  cancelable: false
223
257
  });
224
258
  document.dispatchEvent(procaptchaReadyEvent);
225
- start();
259
+ boot();
226
260
  //#endregion
227
261
  exports.default = ready;
228
262
  exports.execute = execute;
229
263
  exports.remove = remove;
230
264
  exports.render = render;
231
265
  exports.reset = reset;
266
+ exports.start = start;
@@ -1,4 +1,5 @@
1
1
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_startMode = require("../startMode.cjs");
2
3
  const require_language = require("../language.cjs");
3
4
  const require_clientSession = require("../clientSession.cjs");
4
5
  const require_configCreator = require("../configCreator.cjs");
@@ -29,6 +30,7 @@ var CaptchaRenderer = class {
29
30
  require_timeout.setValidChallengeLength(renderOptions, element, config);
30
31
  require_language.setLanguage(renderOptions, element, config);
31
32
  require_clientSession.setClientSessionId(renderOptions, element, config);
33
+ require_startMode.setStartMode(renderOptions, element, config);
32
34
  }
33
35
  makeEmotionCache(cacheKey, container) {
34
36
  return (0, _emotion_cache.default)({
@@ -0,0 +1,20 @@
1
+ let _prosopo_types = require("@prosopo/types");
2
+ //#region src/util/startMode.ts
3
+ var START_MODE_ATTRIBUTE = "data-start-mode";
4
+ var resolveStartMode = (renderOptions, element) => {
5
+ const requested = renderOptions?.startMode || element.getAttribute("data-start-mode");
6
+ if (!requested) return _prosopo_types.StartModeEnum.auto;
7
+ const parsed = _prosopo_types.StartModeSchema.safeParse(requested);
8
+ if (!parsed.success) {
9
+ console.error(`Ignoring unknown start mode "${requested}"; expected one of ${_prosopo_types.StartModeSchema.options.join(", ")}`);
10
+ return _prosopo_types.StartModeEnum.auto;
11
+ }
12
+ return parsed.data;
13
+ };
14
+ var setStartMode = (renderOptions, element, config) => {
15
+ config.startMode = resolveStartMode(renderOptions, element);
16
+ };
17
+ //#endregion
18
+ exports.START_MODE_ATTRIBUTE = START_MODE_ATTRIBUTE;
19
+ exports.resolveStartMode = resolveStartMode;
20
+ exports.setStartMode = setStartMode;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import type { ProcaptchaRenderOptions } from "@prosopo/types";
1
+ import { type ProcaptchaRenderOptions } from "@prosopo/types";
2
2
  export declare const render: (element: Element, renderOptions: ProcaptchaRenderOptions) => Promise<string | undefined>;
3
3
  export default function ready(fn: () => void): void;
4
4
  export declare const execute: () => void;
5
+ export declare const start: (widgetId?: string) => void;
5
6
  declare global {
6
7
  interface Window {
7
8
  procaptcha: {
@@ -10,6 +11,7 @@ declare global {
10
11
  reset: typeof reset;
11
12
  remove: typeof remove;
12
13
  execute: typeof execute;
14
+ start: typeof start;
13
15
  };
14
16
  }
15
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAoB,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AA0LhF,eAAO,MAAM,MAAM,YACT,OAAO,iBACD,uBAAuB,KACpC,OAAO,CAAC,MAAM,GAAG,SAAS,CA6B5B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,QAY3C;AAED,eAAO,MAAM,OAAO,YAqBnB,CAAC;AAkCF,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QACf,UAAU,EAAE;YACX,KAAK,EAAE,OAAO,KAAK,CAAC;YACpB,MAAM,EAAE,OAAO,MAAM,CAAC;YACtB,KAAK,EAAE,OAAO,KAAK,CAAC;YACpB,MAAM,EAAE,OAAO,MAAM,CAAC;YACtB,OAAO,EAAE,OAAO,OAAO,CAAC;SACxB,CAAC;KACF;CACD;AAoDD,eAAO,MAAM,KAAK,cAAqB,MAAM,KAAG,OAAO,CAAC,IAAI,CAuB3D,CAAC;AAQF,eAAO,MAAM,MAAM,cAAe,MAAM,KAAG,IAW1C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAGN,KAAK,uBAAuB,EAG5B,MAAM,gBAAgB,CAAC;AAgMxB,eAAO,MAAM,MAAM,YACT,OAAO,iBACD,uBAAuB,KACpC,OAAO,CAAC,MAAM,GAAG,SAAS,CAgC5B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,QAY3C;AAED,eAAO,MAAM,OAAO,YAqBnB,CAAC;AAGF,eAAO,MAAM,KAAK,cAAe,MAAM,KAAG,IAwBzC,CAAC;AAkCF,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QACf,UAAU,EAAE;YACX,KAAK,EAAE,OAAO,KAAK,CAAC;YACpB,MAAM,EAAE,OAAO,MAAM,CAAC;YACtB,KAAK,EAAE,OAAO,KAAK,CAAC;YACpB,MAAM,EAAE,OAAO,MAAM,CAAC;YACtB,OAAO,EAAE,OAAO,OAAO,CAAC;YACxB,KAAK,EAAE,OAAO,KAAK,CAAC;SACpB,CAAC;KACF;CACD;AAoDD,eAAO,MAAM,KAAK,cAAqB,MAAM,KAAG,OAAO,CAAC,IAAI,CAuB3D,CAAC;AAQF,eAAO,MAAM,MAAM,cAAe,MAAM,KAAG,IAW1C,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import "./_virtual/_rolldown/runtime.js";
2
2
  import { extractParams, getProcaptchaScript } from "./util/config.js";
3
+ import { resolveStartMode } from "./util/startMode.js";
3
4
  import { WidgetFactory } from "./util/widgetFactory.js";
4
5
  import { WidgetThemeResolver } from "./util/widgetThemeResolver.js";
5
6
  import { getWindowCallback } from "@prosopo/procaptcha-common";
7
+ import { PROCAPTCHA_START_EVENT, StartModeEnum } from "@prosopo/types";
6
8
  import { at } from "@prosopo/util";
7
9
  //#region src/index.ts
8
10
  var BUNDLE_NAMES = ["procaptcha.bundle.iife.js", "procaptcha.bundle.js"];
@@ -34,6 +36,7 @@ var widgetFactory = new WidgetFactory(new WidgetThemeResolver());
34
36
  */
35
37
  var startDetectorPrefetch = (siteKey, flags) => {
36
38
  if (!siteKey) return;
39
+ if (flags.startMode === StartModeEnum.manual) return;
37
40
  Promise.all([import("@prosopo/procaptcha-frictionless"), import("@prosopo/procaptcha-common")]).then(([frictionless, common]) => {
38
41
  frictionless.prefetchDetector(process.env.PROSOPO_DEFAULT_ENVIRONMENT, common.pickIpMode(flags), siteKey);
39
42
  }).catch(() => void 0);
@@ -48,18 +51,21 @@ var implicitRender = async () => {
48
51
  const web3 = firstElement.getAttribute("data-web3");
49
52
  const ipv4 = firstElement.getAttribute("data-ipv4") === "true";
50
53
  const ipv6 = firstElement.getAttribute("data-ipv6") === "true";
54
+ const startMode = resolveStartMode(void 0, firstElement);
51
55
  if (!siteKey) {
52
56
  console.error("No site key found");
53
57
  return;
54
58
  }
55
59
  startDetectorPrefetch(siteKey, {
56
60
  ipv4,
57
- ipv6
61
+ ipv6,
62
+ startMode
58
63
  });
59
64
  const implicitRenderOptions = {
60
65
  siteKey,
61
66
  ipv4,
62
- ipv6
67
+ ipv6,
68
+ startMode
63
69
  };
64
70
  registerWidgets(await widgetFactory.createWidgets(elements, implicitRenderOptions, !(web3 === "true")), elements, implicitRenderOptions, !(web3 === "true"), false);
65
71
  }
@@ -69,15 +75,18 @@ var implicitRender = async () => {
69
75
  const callback = button.getAttribute("data-callback") || "";
70
76
  const ipv4 = button.getAttribute("data-ipv4") === "true";
71
77
  const ipv6 = button.getAttribute("data-ipv6") === "true";
78
+ const startMode = resolveStartMode(void 0, button);
72
79
  startDetectorPrefetch(siteKey, {
73
80
  ipv4,
74
- ipv6
81
+ ipv6,
82
+ startMode
75
83
  });
76
84
  const buttonRenderOptions = {
77
85
  siteKey,
78
86
  callback,
79
87
  ipv4,
80
- ipv6
88
+ ipv6,
89
+ startMode
81
90
  };
82
91
  registerWidgets(await widgetFactory.createWidgets([button], buttonRenderOptions, true, true), [button], buttonRenderOptions, true, true);
83
92
  button.addEventListener("click", async (event) => {
@@ -96,7 +105,10 @@ var implicitRender = async () => {
96
105
  * factory legitimately yields nothing for an element it cannot mount into.
97
106
  */
98
107
  var render = async (element, renderOptions) => {
99
- startDetectorPrefetch(renderOptions.siteKey, renderOptions);
108
+ startDetectorPrefetch(renderOptions.siteKey, {
109
+ ...renderOptions,
110
+ startMode: resolveStartMode(renderOptions, element)
111
+ });
100
112
  const hasInvisibleSize = Object.prototype.hasOwnProperty.call(renderOptions, "size") && renderOptions.size === "invisible";
101
113
  const isWeb2 = !renderOptions.web3;
102
114
  const invisible = hasInvisibleSize || element.tagName.toLowerCase() === "button";
@@ -132,6 +144,27 @@ var execute = () => {
132
144
  });
133
145
  document.dispatchEvent(executeEvent);
134
146
  };
147
+ /** Starts a `startMode: "manual"` widget; omit the id to start all of them. */
148
+ var start = (widgetId) => {
149
+ const ids = void 0 === widgetId ? Array.from(procaptchaWidgets.keys()) : [widgetId];
150
+ if (ids.length === 0) {
151
+ console.error("No Procaptcha widgets found to start");
152
+ return;
153
+ }
154
+ for (const id of ids) {
155
+ const entry = procaptchaWidgets.get(id);
156
+ if (!entry) {
157
+ console.error(`No Procaptcha widget found with id ${id}`);
158
+ continue;
159
+ }
160
+ const detail = { element: entry.element };
161
+ document.dispatchEvent(new CustomEvent(PROCAPTCHA_START_EVENT, {
162
+ detail,
163
+ bubbles: true,
164
+ cancelable: false
165
+ }));
166
+ }
167
+ };
135
168
  function findProcaptchaContainers() {
136
169
  const containers = [];
137
170
  const invisibleContainers = Array.from(document.querySelectorAll("[data-size=\"invisible\"]"));
@@ -142,7 +175,7 @@ function findProcaptchaContainers() {
142
175
  for (const container of idContainers) if (!containers.includes(container)) containers.push(container);
143
176
  return containers;
144
177
  }
145
- var start = () => {
178
+ var boot = () => {
146
179
  const { onloadUrlCallback, renderExplicit } = extractParams(BUNDLE_NAMES);
147
180
  let readyCalled = false;
148
181
  if (renderExplicit !== "explicit") {
@@ -164,7 +197,7 @@ var start = () => {
164
197
  * widget id to reset one widget, or omit it to reset every widget on the page.
165
198
  *
166
199
  * This remounts rather than merely unmounting. The previous implementation
167
- * unmounted every root and then called `start()`, which only re-renders when
200
+ * unmounted every root and then called `boot()`, which only re-renders when
168
201
  * the page uses implicit rendering — and even then only via the
169
202
  * `document.readyState` fallback, because the script's `load` event has long
170
203
  * since fired. On an explicitly-rendered page nothing came back at all: the
@@ -172,7 +205,7 @@ var start = () => {
172
205
  * request was ever made. Rebuilding from the stored descriptor makes reset
173
206
  * behave the same way on both paths.
174
207
  *
175
- * `start()` is deliberately not called here any more. It re-renders implicit
208
+ * `boot()` is deliberately not called here any more. It re-renders implicit
176
209
  * widgets, which would double up with the remount below, and it attaches
177
210
  * another `load` listener to the script tag on every call.
178
211
  */
@@ -211,7 +244,8 @@ window.procaptcha = {
211
244
  render,
212
245
  reset,
213
246
  remove,
214
- execute
247
+ execute,
248
+ start
215
249
  };
216
250
  var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
217
251
  detail: { timestamp: Date.now() },
@@ -219,6 +253,6 @@ var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
219
253
  cancelable: false
220
254
  });
221
255
  document.dispatchEvent(procaptchaReadyEvent);
222
- start();
256
+ boot();
223
257
  //#endregion
224
- export { ready as default, execute, remove, render, reset };
258
+ export { ready as default, execute, remove, render, reset, start };