@prosopo/procaptcha-bundle 4.2.5 → 4.4.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 (59) 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 +16 -15
  4. package/CHANGELOG.md +85 -0
  5. package/dist/cjs/index.cjs +101 -21
  6. package/dist/cjs/util/captcha/captchaRenderer.cjs +20 -1
  7. package/dist/cjs/util/configCreator.cjs +4 -2
  8. package/dist/cjs/util/startMode.cjs +20 -0
  9. package/dist/cjs/util/widgetFactory.cjs +8 -5
  10. package/dist/index.d.ts +4 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +101 -22
  13. package/dist/index.js.map +1 -1
  14. package/dist/tests/bind.unit.test.d.ts +2 -0
  15. package/dist/tests/bind.unit.test.d.ts.map +1 -0
  16. package/dist/tests/bind.unit.test.js +166 -0
  17. package/dist/tests/bind.unit.test.js.map +1 -0
  18. package/dist/tests/detectorPrefetch.unit.test.js.map +1 -1
  19. package/dist/tests/procaptchaReady.unit.test.js +1 -0
  20. package/dist/tests/procaptchaReady.unit.test.js.map +1 -1
  21. package/dist/tests/reset.unit.test.js +6 -2
  22. package/dist/tests/reset.unit.test.js.map +1 -1
  23. package/dist/tests/start.unit.test.d.ts +2 -0
  24. package/dist/tests/start.unit.test.d.ts.map +1 -0
  25. package/dist/tests/start.unit.test.js +103 -0
  26. package/dist/tests/start.unit.test.js.map +1 -0
  27. package/dist/tests/util/startMode.test.d.ts +2 -0
  28. package/dist/tests/util/startMode.test.d.ts.map +1 -0
  29. package/dist/tests/util/startMode.test.js +48 -0
  30. package/dist/tests/util/startMode.test.js.map +1 -0
  31. package/dist/util/captcha/captchaRenderer.d.ts +1 -1
  32. package/dist/util/captcha/captchaRenderer.d.ts.map +1 -1
  33. package/dist/util/captcha/captchaRenderer.js +20 -1
  34. package/dist/util/captcha/captchaRenderer.js.map +1 -1
  35. package/dist/util/configCreator.d.ts +14 -2
  36. package/dist/util/configCreator.d.ts.map +1 -1
  37. package/dist/util/configCreator.js +5 -3
  38. package/dist/util/configCreator.js.map +1 -1
  39. package/dist/util/startMode.d.ts +5 -0
  40. package/dist/util/startMode.d.ts.map +1 -0
  41. package/dist/util/startMode.js +18 -0
  42. package/dist/util/startMode.js.map +1 -0
  43. package/dist/util/widgetFactory.d.ts +7 -2
  44. package/dist/util/widgetFactory.d.ts.map +1 -1
  45. package/dist/util/widgetFactory.js +8 -5
  46. package/dist/util/widgetFactory.js.map +1 -1
  47. package/package.json +12 -12
  48. package/src/index.ts +145 -28
  49. package/src/tests/bind.unit.test.ts +227 -0
  50. package/src/tests/detectorPrefetch.unit.test.ts +2 -2
  51. package/src/tests/procaptchaReady.unit.test.ts +1 -0
  52. package/src/tests/reset.unit.test.ts +9 -3
  53. package/src/tests/start.unit.test.ts +155 -0
  54. package/src/tests/util/startMode.test.ts +113 -0
  55. package/src/util/captcha/captchaRenderer.tsx +33 -13
  56. package/src/util/configCreator.ts +29 -11
  57. package/src/util/startMode.ts +53 -0
  58. package/src/util/widgetFactory.ts +10 -3
  59. package/tsconfig.tsbuildinfo +1 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > @prosopo/procaptcha-bundle@4.2.5 build:cjs
2
+ > @prosopo/procaptcha-bundle@4.4.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/startMode.cjs 0.89 kB │ gzip: 0.40 kB
68
+ dist/cjs/util/configCreator.cjs 1.00 kB │ gzip: 0.50 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/widgetFactory.cjs 2.78 kB │ gzip: 0.90 kB
73
+ dist/cjs/util/captcha/captchaRenderer.cjs 3.04 kB │ gzip: 1.00 kB
74
+ dist/cjs/index.cjs 11.88 kB │ gzip: 3.88 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 41ms
78
+ ✓ built in 59ms
@@ -1,8 +1,8 @@
1
1
 
2
- > @prosopo/procaptcha-bundle@4.2.5 build:tsc
2
+ > @prosopo/procaptcha-bundle@4.4.0 build:tsc
3
3
  > tsc --build --verbose
4
4
 
5
- 1:56:47 PM - Projects in this build:
5
+ 1:15:52 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
- 1:56:47 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
+ 1:15:52 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'
31
31
 
32
- 1:56:47 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
32
+ 1:15:52 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:56:47 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
34
+ 1:15:53 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
35
35
 
36
- 1:56:47 PM - Project '../dotenv/tsconfig.json' is up to date because newest input '../dotenv/src/index.ts' is older than output '../dotenv/tsconfig.tsbuildinfo'
36
+ 1:15:53 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
- 1:56:47 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
38
+ 1:15:53 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
- 1:56:47 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
+ 1:15:53 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
- 1:56:47 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/index.ts' is older than output '../types/tsconfig.tsbuildinfo'
42
+ 1:15:53 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
- 1:56:47 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
44
+ 1:15:53 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
- 1:56:47 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
46
+ 1:15:53 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/utils/batches.ts' is older than output '../common/tsconfig.tsbuildinfo'
47
47
 
48
- 1:56:47 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
+ 1:15:53 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
- 1:56:47 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
50
+ 1:15:53 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
- 1:56:47 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
+ 1:15:53 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'
53
53
 
54
- 1:56:47 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/constants.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
54
+ 1:15:53 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'
55
55
 
56
- 1:56:47 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/index.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
56
+ 1:15:53 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'
57
57
 
58
- 1:56:47 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/workers/cryptoWorker.ts' is older than output '../account/tsconfig.tsbuildinfo'
58
+ 1:15:53 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
- 1:56:47 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
+ 1:15:53 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'
61
61
 
62
- 1:56:47 PM - Project '../procaptcha-pow/tsconfig.json' is up to date because newest input '../procaptcha-pow/src/index.ts' is older than output '../procaptcha-pow/tsconfig.tsbuildinfo'
62
+ 1:15:53 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
- 1:56:47 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
+ 1:15:53 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
- 1:56:47 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/index.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
66
+ 1:15:53 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'
67
67
 
68
- 1:56:47 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/index.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
68
+ 1:15:53 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/modules/Manager.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
69
69
 
70
- 1:56:47 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'
70
+ 1:15:53 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'
71
71
 
72
- 1:56:47 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
+ 1:15:53 PM - Project '../procaptcha-frictionless/tsconfig.json' is up to date because newest input '../procaptcha-frictionless/src/customDetectBot.ts' is older than output '../procaptcha-frictionless/tsconfig.tsbuildinfo'
73
73
 
74
- 1:56:47 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
74
+ 1:15:53 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
75
75
 
76
- 1:56:47 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-bundle/tsconfig.json'...
76
+ 1:15:53 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.5 build
2
+ > @prosopo/procaptcha-bundle@4.4.0 build
3
3
  > npm run build:cross-env -- --mode ${NODE_ENV:-development}
4
4
 
5
5
 
6
- > @prosopo/procaptcha-bundle@4.2.5 build:cross-env
6
+ > @prosopo/procaptcha-bundle@4.4.0 build:cross-env
7
7
  > vite build --config vite.esm.config.ts --mode production
8
8
 
9
9
  ViteEsmConfig: .
@@ -61,19 +61,20 @@ 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
- dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
68
- dist/util/widgetThemeResolver.js 0.55 kB │ gzip: 0.29 kB
69
- dist/util/timeout.js 0.61 kB │ gzip: 0.29 kB
70
- dist/util/config.js 0.62 kB │ gzip: 0.33 kB
71
- dist/util/captcha/components/bundleCaptcha.js 0.68 kB │ gzip: 0.35 kB
72
- dist/util/configCreator.js 0.86 kB │ gzip: 0.45 kB
73
- dist/util/language.js 1.01 kB │ gzip: 0.44 kB
74
- 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/widgetFactory.js 2.52 kB │ gzip: 0.85 kB
77
- dist/index.js 8.85 kB │ gzip: 3.14 kB
67
+ dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
68
+ dist/util/widgetThemeResolver.js 0.55 kB │ gzip: 0.29 kB
69
+ dist/util/timeout.js 0.61 kB │ gzip: 0.29 kB
70
+ dist/util/config.js 0.62 kB │ gzip: 0.33 kB
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
73
+ dist/util/configCreator.js 0.98 kB │ gzip: 0.49 kB
74
+ dist/util/language.js 1.01 kB │ gzip: 0.44 kB
75
+ dist/util/clientSession.js 1.03 kB │ gzip: 0.55 kB
76
+ dist/util/widgetFactory.js 2.57 kB │ gzip: 0.87 kB
77
+ dist/util/captcha/captchaRenderer.js 2.64 kB │ gzip: 0.92 kB
78
+ dist/index.js 11.43 kB │ gzip: 3.79 kB
78
79
 
79
- ✓ built in 62ms
80
+ ✓ built in 59ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,90 @@
1
1
  # @prosopo/procaptcha-bundle
2
2
 
3
+ ## 4.4.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/util@3.3.9
25
+ - @prosopo/procaptcha-common@2.13.0
26
+ - @prosopo/procaptcha-frictionless@2.15.0
27
+ - @prosopo/dotenv@3.0.55
28
+
29
+ ## 4.3.0
30
+ ### Minor Changes
31
+
32
+ - 80f73c1: Sites can now control when the widget starts working.
33
+
34
+ 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.
35
+
36
+ - 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.
37
+ - 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.
38
+
39
+ 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.
40
+
41
+ ### Patch Changes
42
+
43
+ - 89dd38a: chore(deps): batch the outstanding dependabot bumps into one upgrade
44
+
45
+ Rolls up dependabot PRs #3112, #3127-#3134 and #3159. Majors: `mongoose`
46
+ 8 -> 9, `bson` 6 -> 7, `@noble/curves` 1 -> 2, `@polkadot/util-crypto`
47
+ 13 -> 14, `@typegoose/auto-increment` 4 -> 5, `@babel/preset-env` 7 -> 8,
48
+ `@types/jsdom` 21 -> 30, `@types/bcrypt` 5 -> 6, `@actions/github` 6 -> 9,
49
+ `testcontainers` 11 -> 12. The rest are minor/patch.
50
+
51
+ Code changes the majors forced:
52
+ - `@noble/curves` v2 requires `.js` specifiers and renamed the point API,
53
+ so `secp256k1.ProjectivePoint.fromHex(...).toRawBytes()` becomes
54
+ `secp256k1.Point.fromBytes(...).toBytes()`, `RistrettoPoint` becomes
55
+ `ristretto255.Point`, and `abstract/utils` moves to `utils.js`.
56
+ - mongoose 9 drops `RootFilterQuery` (now `QueryFilter`), no longer sets
57
+ `background: true` on schema indexes by default, and no longer declares
58
+ `id` on `Document`, which un-hid a mismatch between
59
+ `updateDappUserCommitment`'s `Hash` parameter and the `string` `id` it
60
+ filters on.
61
+ - mongoose 9 rejects an aggregation-pipeline update (an array) unless the
62
+ call passes `updatePipeline: true`, so the six pipeline writes in
63
+ `ProviderDatabase` now opt in explicitly.
64
+ - mongoose 9's `castUpdate` throws on a `$setOnInsert` key inside `$set`.
65
+ `storeUserImageCaptchaSolution` passed its record straight in as the
66
+ update, and mongoose's `moveImmutableProperties` mutates that object on
67
+ an upsert -- adding the very `$setOnInsert` key the record then carried
68
+ into `CentralDbStreamer.streamImageRecord`. Image records stopped
69
+ reaching the central DB (the streamer is fire-and-forget, so it only
70
+ logged) and signup verification returned 500. The update is now an
71
+ explicit `$set` over a shallow copy.
72
+ - `@prosopo/database` moves from mongodb 6.20 to 7.5 to match the driver
73
+ mongoose 9 pulls, so bson 7 is the only copy resolvable in the package.
74
+ - `vitest`/`@vitest/coverage-v8` go to 4.1.11 alongside dependabot's
75
+ `@vitest/spy` bump; leaving them at 4.1.10 installed a second copy of
76
+ `@vitest/spy` and broke type inference in the provider test utils.
77
+ - Updated dependencies [89dd38a]
78
+ - Updated dependencies [80f73c1]
79
+ - Updated dependencies [8a670d3]
80
+ - @prosopo/dotenv@3.0.54
81
+ - @prosopo/locale@3.4.1
82
+ - @prosopo/procaptcha-common@2.12.6
83
+ - @prosopo/procaptcha-frictionless@2.14.0
84
+ - @prosopo/types@5.6.0
85
+ - @prosopo/util@3.3.8
86
+ - @prosopo/widget-skeleton@2.8.7
87
+
3
88
  ## 4.2.5
4
89
  ### Patch Changes
5
90
 
@@ -3,20 +3,23 @@ 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"];
12
14
  var procaptchaWidgets = /* @__PURE__ */ new Map();
13
15
  var widgetIdCounter = 0;
14
16
  var nextWidgetId = () => `procaptcha-widget-${widgetIdCounter++}`;
15
- var registerWidgets = (roots, elements, renderOptions, isWeb2, invisible) => roots.map((root, index) => {
17
+ var registerWidgets = (widgets, elements, renderOptions, isWeb2, invisible) => widgets.map(({ root, container }, index) => {
16
18
  const id = nextWidgetId();
17
19
  procaptchaWidgets.set(id, {
18
20
  root,
19
21
  element: (0, _prosopo_util.at)(elements, index),
22
+ target: container,
20
23
  renderOptions,
21
24
  isWeb2,
22
25
  invisible
@@ -37,6 +40,7 @@ var widgetFactory = new require_widgetFactory.WidgetFactory(new require_widgetTh
37
40
  */
38
41
  var startDetectorPrefetch = (siteKey, flags) => {
39
42
  if (!siteKey) return;
43
+ if (flags.startMode === _prosopo_types.StartModeEnum.manual) return;
40
44
  Promise.all([import("@prosopo/procaptcha-frictionless"), import("@prosopo/procaptcha-common")]).then(([frictionless, common]) => {
41
45
  frictionless.prefetchDetector(process.env.PROSOPO_DEFAULT_ENVIRONMENT, common.pickIpMode(flags), siteKey);
42
46
  }).catch(() => void 0);
@@ -51,20 +55,26 @@ var implicitRender = async () => {
51
55
  const web3 = firstElement.getAttribute("data-web3");
52
56
  const ipv4 = firstElement.getAttribute("data-ipv4") === "true";
53
57
  const ipv6 = firstElement.getAttribute("data-ipv6") === "true";
58
+ const startMode = require_startMode.resolveStartMode(void 0, firstElement);
54
59
  if (!siteKey) {
55
60
  console.error("No site key found");
56
61
  return;
57
62
  }
58
63
  startDetectorPrefetch(siteKey, {
59
64
  ipv4,
60
- ipv6
65
+ ipv6,
66
+ startMode
61
67
  });
62
68
  const implicitRenderOptions = {
63
69
  siteKey,
64
70
  ipv4,
65
- ipv6
71
+ ipv6,
72
+ startMode
66
73
  };
67
- registerWidgets(await widgetFactory.createWidgets(elements, implicitRenderOptions, !(web3 === "true")), elements, implicitRenderOptions, !(web3 === "true"), false);
74
+ registerWidgets(await widgetFactory.createWidgets(elements, implicitRenderOptions, !(web3 === "true")), elements, implicitRenderOptions, !(web3 === "true"), false).forEach((id, index) => {
75
+ const selector = (0, _prosopo_util.at)(elements, index).getAttribute("data-bind");
76
+ if (selector) bindTrigger(id, selector);
77
+ });
68
78
  }
69
79
  const invisibleButtons = Array.from(document.getElementsByClassName("procaptcha")).filter((button) => button.tagName.toLowerCase() === "button");
70
80
  if (invisibleButtons.length) for (const button of invisibleButtons) {
@@ -72,20 +82,23 @@ var implicitRender = async () => {
72
82
  const callback = button.getAttribute("data-callback") || "";
73
83
  const ipv4 = button.getAttribute("data-ipv4") === "true";
74
84
  const ipv6 = button.getAttribute("data-ipv6") === "true";
85
+ const startMode = require_startMode.resolveStartMode(void 0, button);
75
86
  startDetectorPrefetch(siteKey, {
76
87
  ipv4,
77
- ipv6
88
+ ipv6,
89
+ startMode
78
90
  });
79
91
  const buttonRenderOptions = {
80
92
  siteKey,
81
93
  callback,
82
94
  ipv4,
83
- ipv6
95
+ ipv6,
96
+ startMode
84
97
  };
85
- registerWidgets(await widgetFactory.createWidgets([button], buttonRenderOptions, true, true), [button], buttonRenderOptions, true, true);
98
+ const [id] = registerWidgets(await widgetFactory.createWidgets([button], buttonRenderOptions, true, true), [button], buttonRenderOptions, true, true);
86
99
  button.addEventListener("click", async (event) => {
87
100
  event.preventDefault();
88
- execute();
101
+ execute(id);
89
102
  });
90
103
  }
91
104
  };
@@ -99,11 +112,16 @@ var implicitRender = async () => {
99
112
  * factory legitimately yields nothing for an element it cannot mount into.
100
113
  */
101
114
  var render = async (element, renderOptions) => {
102
- startDetectorPrefetch(renderOptions.siteKey, renderOptions);
115
+ startDetectorPrefetch(renderOptions.siteKey, {
116
+ ...renderOptions,
117
+ startMode: require_startMode.resolveStartMode(renderOptions, element)
118
+ });
103
119
  const hasInvisibleSize = Object.prototype.hasOwnProperty.call(renderOptions, "size") && renderOptions.size === "invisible";
104
120
  const isWeb2 = !renderOptions.web3;
105
121
  const invisible = hasInvisibleSize || element.tagName.toLowerCase() === "button";
106
- return registerWidgets(await widgetFactory.createWidgets([element], renderOptions, isWeb2, invisible), [element], renderOptions, isWeb2, invisible)[0];
122
+ const id = registerWidgets(await widgetFactory.createWidgets([element], renderOptions, isWeb2, invisible), [element], renderOptions, isWeb2, invisible)[0];
123
+ if (id && renderOptions.bind) bindTrigger(id, renderOptions.bind);
124
+ return id;
107
125
  };
108
126
  function ready(fn) {
109
127
  if (document && document.readyState !== "loading") {
@@ -118,8 +136,18 @@ function ready(fn) {
118
136
  });
119
137
  }
120
138
  }
121
- var execute = () => {
122
- const containers = findProcaptchaContainers();
139
+ /**
140
+ * Starts verification. With no id the event goes to `document` and every
141
+ * widget responds; with an id (as returned by `render()`) only that widget
142
+ * runs.
143
+ */
144
+ var execute = (widgetId) => {
145
+ const targeted = void 0 === widgetId ? void 0 : procaptchaWidgets.get(widgetId);
146
+ if (void 0 !== widgetId && !targeted) {
147
+ console.error(`No Procaptcha widget found with id ${widgetId}`);
148
+ return;
149
+ }
150
+ const containers = targeted ? [targeted.element] : findProcaptchaContainers();
123
151
  if (containers.length === 0) {
124
152
  console.error("No Procaptcha containers found for execution");
125
153
  return;
@@ -130,11 +158,59 @@ var execute = () => {
130
158
  containerCount: containers.length,
131
159
  timestamp: Date.now()
132
160
  },
133
- bubbles: true,
161
+ bubbles: !targeted,
134
162
  cancelable: true
135
163
  });
164
+ if (targeted) {
165
+ targeted.target.dispatchEvent(executeEvent);
166
+ return;
167
+ }
136
168
  document.dispatchEvent(executeEvent);
137
169
  };
170
+ /**
171
+ * The click's default is prevented so a submit button does not post the form
172
+ * before a token exists.
173
+ */
174
+ var bindTrigger = (widgetId, selector) => {
175
+ const entry = procaptchaWidgets.get(widgetId);
176
+ if (!entry) {
177
+ console.error(`No Procaptcha widget found with id ${widgetId}`);
178
+ return;
179
+ }
180
+ const trigger = document.querySelector(selector);
181
+ if (!trigger) {
182
+ console.error(`Procaptcha: no element matches bind selector ${selector}`);
183
+ return;
184
+ }
185
+ entry.unbindTrigger?.();
186
+ const onClick = (event) => {
187
+ event.preventDefault();
188
+ execute(widgetId);
189
+ };
190
+ trigger.addEventListener("click", onClick);
191
+ entry.unbindTrigger = () => trigger.removeEventListener("click", onClick);
192
+ };
193
+ /** Starts a `startMode: "manual"` widget; omit the id to start all of them. */
194
+ var start = (widgetId) => {
195
+ const ids = void 0 === widgetId ? Array.from(procaptchaWidgets.keys()) : [widgetId];
196
+ if (ids.length === 0) {
197
+ console.error("No Procaptcha widgets found to start");
198
+ return;
199
+ }
200
+ for (const id of ids) {
201
+ const entry = procaptchaWidgets.get(id);
202
+ if (!entry) {
203
+ console.error(`No Procaptcha widget found with id ${id}`);
204
+ continue;
205
+ }
206
+ const detail = { element: entry.element };
207
+ document.dispatchEvent(new CustomEvent(_prosopo_types.PROCAPTCHA_START_EVENT, {
208
+ detail,
209
+ bubbles: true,
210
+ cancelable: false
211
+ }));
212
+ }
213
+ };
138
214
  function findProcaptchaContainers() {
139
215
  const containers = [];
140
216
  const invisibleContainers = Array.from(document.querySelectorAll("[data-size=\"invisible\"]"));
@@ -145,7 +221,7 @@ function findProcaptchaContainers() {
145
221
  for (const container of idContainers) if (!containers.includes(container)) containers.push(container);
146
222
  return containers;
147
223
  }
148
- var start = () => {
224
+ var boot = () => {
149
225
  const { onloadUrlCallback, renderExplicit } = require_config.extractParams(BUNDLE_NAMES);
150
226
  let readyCalled = false;
151
227
  if (renderExplicit !== "explicit") {
@@ -167,7 +243,7 @@ var start = () => {
167
243
  * widget id to reset one widget, or omit it to reset every widget on the page.
168
244
  *
169
245
  * This remounts rather than merely unmounting. The previous implementation
170
- * unmounted every root and then called `start()`, which only re-renders when
246
+ * unmounted every root and then called `boot()`, which only re-renders when
171
247
  * the page uses implicit rendering — and even then only via the
172
248
  * `document.readyState` fallback, because the script's `load` event has long
173
249
  * since fired. On an explicitly-rendered page nothing came back at all: the
@@ -175,7 +251,7 @@ var start = () => {
175
251
  * request was ever made. Rebuilding from the stored descriptor makes reset
176
252
  * behave the same way on both paths.
177
253
  *
178
- * `start()` is deliberately not called here any more. It re-renders implicit
254
+ * `boot()` is deliberately not called here any more. It re-renders implicit
179
255
  * widgets, which would double up with the remount below, and it attaches
180
256
  * another `load` listener to the script tag on every call.
181
257
  */
@@ -185,10 +261,11 @@ var reset = async (widgetId) => {
185
261
  const current = procaptchaWidgets.get(id);
186
262
  if (!current) continue;
187
263
  current.root.unmount();
188
- const [root] = await widgetFactory.createWidgets([current.element], current.renderOptions, current.isWeb2, current.invisible);
189
- if (root) procaptchaWidgets.set(id, {
264
+ const [widget] = await widgetFactory.createWidgets([current.element], current.renderOptions, current.isWeb2, current.invisible);
265
+ if (widget) procaptchaWidgets.set(id, {
190
266
  ...current,
191
- root
267
+ root: widget.root,
268
+ target: widget.container
192
269
  });
193
270
  else procaptchaWidgets.delete(id);
194
271
  }
@@ -204,6 +281,7 @@ var remove = (widgetId) => {
204
281
  for (const id of ids) {
205
282
  const entry = procaptchaWidgets.get(id);
206
283
  if (!entry) continue;
284
+ entry.unbindTrigger?.();
207
285
  entry.root.unmount();
208
286
  entry.element.innerHTML = "";
209
287
  procaptchaWidgets.delete(id);
@@ -214,7 +292,8 @@ window.procaptcha = {
214
292
  render,
215
293
  reset,
216
294
  remove,
217
- execute
295
+ execute,
296
+ start
218
297
  };
219
298
  var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
220
299
  detail: { timestamp: Date.now() },
@@ -222,10 +301,11 @@ var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
222
301
  cancelable: false
223
302
  });
224
303
  document.dispatchEvent(procaptchaReadyEvent);
225
- start();
304
+ boot();
226
305
  //#endregion
227
306
  exports.default = ready;
228
307
  exports.execute = execute;
229
308
  exports.remove = remove;
230
309
  exports.render = render;
231
310
  exports.reset = reset;
311
+ exports.start = start;
@@ -1,18 +1,36 @@
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");
5
6
  const require_timeout = require("../timeout.cjs");
6
7
  const require_bundleCaptcha = require("./components/bundleCaptcha.cjs");
8
+ let _prosopo_types = require("@prosopo/types");
7
9
  let _emotion_cache = require("@emotion/cache");
8
10
  _emotion_cache = require_runtime.__toESM(_emotion_cache, 1);
9
11
  let _emotion_react = require("@emotion/react");
10
12
  let react_dom_client = require("react-dom/client");
11
13
  let react_jsx_runtime = require("react/jsx-runtime");
12
14
  //#region src/util/captcha/captchaRenderer.tsx
15
+ var resolveRequestedPlacement = (element, renderOptions) => {
16
+ const requested = renderOptions.placement ?? element.getAttribute("data-placement");
17
+ if (!requested) return void 0;
18
+ const parsed = _prosopo_types.Placement.safeParse(requested);
19
+ return parsed.success ? parsed.data : void 0;
20
+ };
13
21
  var CaptchaRenderer = class {
14
22
  renderCaptcha(settings, container, renderOptions, callbacks, isWeb2, i18n, invisible, widgetContainer, sourceElement) {
15
- const config = require_configCreator.createConfig(renderOptions.siteKey, renderOptions.theme, renderOptions.language, isWeb2, invisible, renderOptions.userAccountAddress, renderOptions.ipv4, renderOptions.ipv6);
23
+ const config = require_configCreator.createConfig({
24
+ siteKey: renderOptions.siteKey,
25
+ theme: renderOptions.theme,
26
+ language: renderOptions.language,
27
+ web2: isWeb2,
28
+ invisible,
29
+ placement: resolveRequestedPlacement(sourceElement || container, renderOptions),
30
+ userAccountAddress: renderOptions.userAccountAddress,
31
+ ipv4: renderOptions.ipv4,
32
+ ipv6: renderOptions.ipv6
33
+ });
16
34
  this.readAndValidateSettings(sourceElement || container, config, renderOptions);
17
35
  const reactRoot = this.createReactRoot(container, settings.identifierPrefix);
18
36
  const emotionCache = this.makeEmotionCache(settings.emotionCacheKey, container);
@@ -29,6 +47,7 @@ var CaptchaRenderer = class {
29
47
  require_timeout.setValidChallengeLength(renderOptions, element, config);
30
48
  require_language.setLanguage(renderOptions, element, config);
31
49
  require_clientSession.setClientSessionId(renderOptions, element, config);
50
+ require_startMode.setStartMode(renderOptions, element, config);
32
51
  }
33
52
  makeEmotionCache(cacheKey, container) {
34
53
  return (0, _emotion_cache.default)({
@@ -1,7 +1,8 @@
1
1
  let _prosopo_types = require("@prosopo/types");
2
2
  //#region src/util/configCreator.ts
3
- function createConfig(siteKey, theme = "light", language, web2 = true, invisible = false, userAccountAddress, ipv4 = false, ipv6 = false) {
4
- if (!siteKey) siteKey = process.env.PROSOPO_SITE_KEY || "";
3
+ function createConfig(options = {}) {
4
+ const { theme = "light", language, web2 = true, invisible = false, placement, userAccountAddress, ipv4 = false, ipv6 = false } = options;
5
+ const siteKey = options.siteKey || process.env.PROSOPO_SITE_KEY || "";
5
6
  return _prosopo_types.ProcaptchaConfigSchema.parse({
6
7
  defaultEnvironment: process.env.PROSOPO_DEFAULT_ENVIRONMENT ? _prosopo_types.EnvironmentTypesSchema.parse(process.env.PROSOPO_DEFAULT_ENVIRONMENT) : _prosopo_types.EnvironmentTypesSchema.enum.development,
7
8
  userAccountAddress: userAccountAddress || "",
@@ -10,6 +11,7 @@ function createConfig(siteKey, theme = "light", language, web2 = true, invisible
10
11
  mongoAtlasUri: process.env.PROSOPO_MONGO_EVENTS_URI || "",
11
12
  web2,
12
13
  mode: invisible ? "invisible" : "visible",
14
+ placement: (0, _prosopo_types.resolvePlacement)(placement, invisible),
13
15
  theme,
14
16
  language,
15
17
  ipv4,
@@ -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;