@prosopo/procaptcha-frictionless 2.19.0 → 2.21.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.
@@ -2,21 +2,23 @@ $ NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mo
2
2
  ViteCommonJSConfig: .
3
3
  {
4
4
  tsConfigPaths: [
5
- '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
6
- '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
7
- '/home/runner/work/captcha/captcha/packages/procaptcha-pow/tsconfig.json',
8
5
  '/home/runner/work/captcha/captcha/packages/api/tsconfig.json',
9
6
  '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
7
+ '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
8
+ '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
10
9
  '/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
11
10
  '/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
12
11
  '/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
13
- '/home/runner/work/captcha/captcha/packages/fingerprint/tsconfig.json',
14
- '/home/runner/work/captcha/captcha/packages/fingerprintjs/tsconfig.json',
12
+ '/home/runner/work/captcha/captcha/packages/procaptcha-audio/tsconfig.json',
15
13
  '/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json',
16
14
  '/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json',
17
15
  '/home/runner/work/captcha/captcha/packages/widget-skeleton/tsconfig.json',
18
16
  '/home/runner/work/captcha/captcha/packages/account/tsconfig.json',
17
+ '/home/runner/work/captcha/captcha/packages/fingerprint/tsconfig.json',
18
+ '/home/runner/work/captcha/captcha/packages/fingerprintjs/tsconfig.json',
19
19
  '/home/runner/work/captcha/captcha/packages/keyring/tsconfig.json',
20
+ '/home/runner/work/captcha/captcha/packages/procaptcha-icon-order/tsconfig.json',
21
+ '/home/runner/work/captcha/captcha/packages/procaptcha-pow/tsconfig.json',
20
22
  '/home/runner/work/captcha/captcha/packages/procaptcha-puzzle/tsconfig.json',
21
23
  '/home/runner/work/captcha/captcha/packages/procaptcha-react/tsconfig.json',
22
24
  '/home/runner/work/captcha/captcha/packages/procaptcha/tsconfig.json',
@@ -25,21 +27,23 @@ ViteCommonJSConfig: .
25
27
  }
26
28
  {
27
29
  externals: [
28
- '@prosopo/locale',
29
- '@prosopo/util',
30
- '@prosopo/procaptcha-pow',
31
30
  '@prosopo/api',
32
31
  '@prosopo/types',
32
+ '@prosopo/locale',
33
+ '@prosopo/util',
33
34
  '@prosopo/util-crypto',
34
35
  '@prosopo/common',
35
36
  '@prosopo/logger',
36
- '@prosopo/fingerprint',
37
- '@prosopo/fingerprintjs',
37
+ '@prosopo/procaptcha-audio',
38
38
  '@prosopo/procaptcha-common',
39
39
  '@prosopo/load-balancer',
40
40
  '@prosopo/widget-skeleton',
41
41
  '@prosopo/account',
42
+ '@prosopo/fingerprint',
43
+ '@prosopo/fingerprintjs',
42
44
  '@prosopo/keyring',
45
+ '@prosopo/procaptcha-icon-order',
46
+ '@prosopo/procaptcha-pow',
43
47
  '@prosopo/procaptcha-puzzle',
44
48
  '@prosopo/procaptcha-react',
45
49
  '@prosopo/procaptcha',
@@ -59,7 +63,7 @@ dist/cjs/sessionInvalidatedRecovery.cjs 2.50 kB │ gzip: 1.14 kB
59
63
  dist/cjs/frictionlessResultGuard.cjs 2.75 kB │ gzip: 1.39 kB
60
64
  dist/cjs/detectorPrefetch.cjs 2.97 kB │ gzip: 1.34 kB
61
65
  dist/cjs/authenticatedBadge.cjs 3.16 kB │ gzip: 1.23 kB
62
- dist/cjs/customDetectBot.cjs 5.96 kB │ gzip: 1.80 kB
63
- dist/cjs/procaptchaFrictionless.cjs 11.27 kB │ gzip: 3.21 kB
66
+ dist/cjs/customDetectBot.cjs 6.14 kB │ gzip: 1.84 kB
67
+ dist/cjs/procaptchaFrictionless.cjs 13.57 kB │ gzip: 3.79 kB
64
68
 
65
- ✓ built in 43ms
69
+ ✓ built in 52ms
@@ -1,5 +1,5 @@
1
1
  $ tsc --build --verbose
2
- 1:38:11 PM - Projects in this build:
2
+ 11:34:09 AM - Projects in this build:
3
3
  * ../../dev/config/tsconfig.json
4
4
  * ../util/tsconfig.json
5
5
  * ../locale/tsconfig.json
@@ -8,13 +8,15 @@ $ tsc --build --verbose
8
8
  * ../api/tsconfig.json
9
9
  * ../logger/tsconfig.json
10
10
  * ../common/tsconfig.json
11
- * ../fingerprintjs/tsconfig.json
12
- * ../fingerprint/tsconfig.json
13
11
  * ../load-balancer/tsconfig.json
14
12
  * ../widget-skeleton/tsconfig.json
13
+ * ../fingerprintjs/tsconfig.json
14
+ * ../fingerprint/tsconfig.json
15
15
  * ../keyring/tsconfig.json
16
16
  * ../account/tsconfig.json
17
17
  * ../procaptcha-common/tsconfig.json
18
+ * ../procaptcha-audio/tsconfig.json
19
+ * ../procaptcha-icon-order/tsconfig.json
18
20
  * ../procaptcha-pow/tsconfig.json
19
21
  * ../procaptcha-puzzle/tsconfig.json
20
22
  * ../datasets/tsconfig.json
@@ -22,47 +24,51 @@ $ tsc --build --verbose
22
24
  * ../procaptcha-react/tsconfig.json
23
25
  * tsconfig.json
24
26
 
25
- 1:38:11 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'
27
+ 11:34:09 AM - 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'
28
+
29
+ 11:34:09 AM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
30
+
31
+ 11:34:09 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
26
32
 
27
- 1:38:11 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
33
+ 11:34:09 AM - 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'
28
34
 
29
- 1:38:11 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
35
+ 11:34:09 AM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
30
36
 
31
- 1:38:11 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'
37
+ 11:34:09 AM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/tests/apiHarness.ts' is older than output '../api/tsconfig.tsbuildinfo'
32
38
 
33
- 1:38:11 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'
39
+ 11:34:09 AM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
34
40
 
35
- 1:38:11 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/tests/apiHarness.ts' is older than output '../api/tsconfig.tsbuildinfo'
41
+ 11:34:09 AM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/error.ts' is older than output '../common/tsconfig.tsbuildinfo'
36
42
 
37
- 1:38:11 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
43
+ 11:34:09 AM - 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'
38
44
 
39
- 1:38:11 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
45
+ 11:34:09 AM - 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'
40
46
 
41
- 1:38:11 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
47
+ 11:34:09 AM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
42
48
 
43
- 1:38:11 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
49
+ 11:34:09 AM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
44
50
 
45
- 1:38:12 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/developmentProviderUrl.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
51
+ 11:34:09 AM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/pair/decode.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
46
52
 
47
- 1:38:12 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/theme.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
53
+ 11:34:09 AM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
48
54
 
49
- 1:38:12 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/pair/decode.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
55
+ 11:34:09 AM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/state/managerLifecycle.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
50
56
 
51
- 1:38:12 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
57
+ 11:34:09 AM - Project '../procaptcha-audio/tsconfig.json' is up to date because newest input '../procaptcha-audio/src/tests/domHarness.ts' is older than output '../procaptcha-audio/tsconfig.tsbuildinfo'
52
58
 
53
- 1:38:12 PM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/extensionLoader.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
59
+ 11:34:09 AM - Project '../procaptcha-icon-order/tsconfig.json' is up to date because newest input '../procaptcha-icon-order/src/index.ts' is older than output '../procaptcha-icon-order/tsconfig.tsbuildinfo'
54
60
 
55
- 1:38:12 PM - Project '../procaptcha-pow/tsconfig.json' is up to date because newest input '../procaptcha-pow/src/tests/manager.unit.test.ts' is older than output '../procaptcha-pow/tsconfig.tsbuildinfo'
61
+ 11:34:09 AM - Project '../procaptcha-pow/tsconfig.json' is up to date because newest input '../procaptcha-pow/src/tests/manager.unit.test.ts' is older than output '../procaptcha-pow/tsconfig.tsbuildinfo'
56
62
 
57
- 1:38:12 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'
63
+ 11:34:09 AM - Project '../procaptcha-puzzle/tsconfig.json' is up to date because newest input '../procaptcha-puzzle/src/tests/invisibleCanvasVisibility.unit.test.ts' is older than output '../procaptcha-puzzle/tsconfig.tsbuildinfo'
58
64
 
59
- 1:38:12 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/index.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
65
+ 11:34:09 AM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/index.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
60
66
 
61
- 1:38:12 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/index.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
67
+ 11:34:09 AM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/modules/Manager.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
62
68
 
63
- 1:38:12 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'
69
+ 11:34:09 AM - 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'
64
70
 
65
- 1:38:12 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
71
+ 11:34:09 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
66
72
 
67
- 1:38:12 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-frictionless/tsconfig.json'...
73
+ 11:34:09 AM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-frictionless/tsconfig.json'...
68
74
 
@@ -3,21 +3,23 @@ $ vite build --config vite.esm.config.ts --mode production
3
3
  ViteEsmConfig: .
4
4
  {
5
5
  tsConfigPaths: [
6
- '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
7
- '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
8
- '/home/runner/work/captcha/captcha/packages/procaptcha-pow/tsconfig.json',
9
6
  '/home/runner/work/captcha/captcha/packages/api/tsconfig.json',
10
7
  '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
8
+ '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
9
+ '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
11
10
  '/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
12
11
  '/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
13
12
  '/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
14
- '/home/runner/work/captcha/captcha/packages/fingerprint/tsconfig.json',
15
- '/home/runner/work/captcha/captcha/packages/fingerprintjs/tsconfig.json',
13
+ '/home/runner/work/captcha/captcha/packages/procaptcha-audio/tsconfig.json',
16
14
  '/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json',
17
15
  '/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json',
18
16
  '/home/runner/work/captcha/captcha/packages/widget-skeleton/tsconfig.json',
19
17
  '/home/runner/work/captcha/captcha/packages/account/tsconfig.json',
18
+ '/home/runner/work/captcha/captcha/packages/fingerprint/tsconfig.json',
19
+ '/home/runner/work/captcha/captcha/packages/fingerprintjs/tsconfig.json',
20
20
  '/home/runner/work/captcha/captcha/packages/keyring/tsconfig.json',
21
+ '/home/runner/work/captcha/captcha/packages/procaptcha-icon-order/tsconfig.json',
22
+ '/home/runner/work/captcha/captcha/packages/procaptcha-pow/tsconfig.json',
21
23
  '/home/runner/work/captcha/captcha/packages/procaptcha-puzzle/tsconfig.json',
22
24
  '/home/runner/work/captcha/captcha/packages/procaptcha-react/tsconfig.json',
23
25
  '/home/runner/work/captcha/captcha/packages/procaptcha/tsconfig.json',
@@ -26,21 +28,23 @@ ViteEsmConfig: .
26
28
  }
27
29
  {
28
30
  externals: [
29
- '@prosopo/locale',
30
- '@prosopo/util',
31
- '@prosopo/procaptcha-pow',
32
31
  '@prosopo/api',
33
32
  '@prosopo/types',
33
+ '@prosopo/locale',
34
+ '@prosopo/util',
34
35
  '@prosopo/util-crypto',
35
36
  '@prosopo/common',
36
37
  '@prosopo/logger',
37
- '@prosopo/fingerprint',
38
- '@prosopo/fingerprintjs',
38
+ '@prosopo/procaptcha-audio',
39
39
  '@prosopo/procaptcha-common',
40
40
  '@prosopo/load-balancer',
41
41
  '@prosopo/widget-skeleton',
42
42
  '@prosopo/account',
43
+ '@prosopo/fingerprint',
44
+ '@prosopo/fingerprintjs',
43
45
  '@prosopo/keyring',
46
+ '@prosopo/procaptcha-icon-order',
47
+ '@prosopo/procaptcha-pow',
44
48
  '@prosopo/procaptcha-puzzle',
45
49
  '@prosopo/procaptcha-react',
46
50
  '@prosopo/procaptcha',
@@ -61,7 +65,7 @@ dist/sessionInvalidatedRecovery.js 2.41 kB │ gzip: 1.13 kB
61
65
  dist/authenticatedBadge.js 2.68 kB │ gzip: 1.20 kB
62
66
  dist/frictionlessResultGuard.js 2.68 kB │ gzip: 1.39 kB
63
67
  dist/detectorPrefetch.js 2.85 kB │ gzip: 1.31 kB
64
- dist/customDetectBot.js 5.78 kB │ gzip: 1.78 kB
65
- dist/procaptchaFrictionless.js 10.72 kB │ gzip: 3.19 kB
68
+ dist/customDetectBot.js 5.96 kB │ gzip: 1.81 kB
69
+ dist/procaptchaFrictionless.js 12.99 kB │ gzip: 3.77 kB
66
70
 
67
- ✓ built in 39ms
71
+ ✓ built in 48ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,85 @@
1
1
  # @prosopo/procaptcha-frictionless
2
2
 
3
+ ## 2.21.0
4
+ ### Minor Changes
5
+
6
+ - 4570692: Let a user swap the puzzle captcha for an image challenge, on sites where Prosopo has switched it on.
7
+
8
+ Sites get a new staff-only setting, `widgetFeatureFlags.puzzleImageSwitch`. It is off by default and has no stored default. When it is on and the site allows image challenges, the puzzle response says `imageSwitchAvailable: true`. The puzzle then shows a small grid icon next to its title, with a "Switch to an image challenge" tooltip on hover or keyboard focus. After two wrong answers or refreshes in a row, the icon fills with the primary colour and its tooltip shows without a hover, because a touch screen has no hover. The tooltip goes away once the user starts moving the piece.
9
+
10
+ Pressing it re-mints the session the same way refresh does, with `switchToImage: true`. The provider only honours that when the request is a refresh of a puzzle session on the same site and the switch is on. The new session is then an image challenge with reason `PUZZLE_USER_SWITCH`. Like the refresh limit, it only ever moves from puzzle to image, so a client that fakes the request can only make its own challenge harder.
11
+
12
+ Also fixes a wrong puzzle answer restarting the whole widget. The user was sent back to the checkbox instead of getting a new puzzle with "Not quite — try again", and a wasted `/frictionless` request went out. The puzzle now retries in place.
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [4570692]
17
+ - @prosopo/procaptcha-puzzle@2.17.0
18
+ - @prosopo/procaptcha-common@2.21.0
19
+ - @prosopo/api@4.6.0
20
+ - @prosopo/types@5.15.0
21
+ - @prosopo/locale@3.9.0
22
+ - @prosopo/procaptcha-audio@0.2.1
23
+ - @prosopo/procaptcha-icon-order@0.2.1
24
+ - @prosopo/procaptcha-pow@2.13.10
25
+ - @prosopo/procaptcha-react@2.14.1
26
+ - @prosopo/common@3.1.64
27
+
28
+ ## 2.20.0
29
+ ### Minor Changes
30
+
31
+ - b299a91: An audio challenge, offered only as an accessibility alternative, like reCAPTCHA's audio option. The user hears a short sequence of spoken digits and types them in.
32
+
33
+ It is off by default and needs two switches. Prosopo has to turn on the `captchaTypeFeatureFlags.audio` feature flag for the site, which the site owner cannot do, and the site owner has to set `audioAccessibilityEnabled`. When both are on, image, puzzle and icon-order challenges show a "Use audio instead" button. Pressing it swaps the visual challenge for the audio one. After a wrong answer the user stays on audio and gets a fresh clip.
34
+
35
+ Audio is never a captcha type that can be selected or routed to. A site's `captchaType`, traffic-filter categories, Restrict rules and the site-key CLI all reject it, and routing, PoW escalation and the severity tiers leave it out. The provider only serves audio against the visual session the user was already given, and only on a site with both switches on; any other audio request is refused before the session is used up, and a request without a session is always refused.
36
+
37
+ The spoken digits are synthesised by `@prosopo/audio-assets`, so there is no recorded set of clips to collect. The answer never leaves the provider, and a challenge can be submitted and verified only once, even under concurrent requests. `@prosopo/procaptcha-audio` is the widget. It and the "Use audio instead" button are built on the shared widget code in `@prosopo/procaptcha-common`, and the provider side is built on the shared interactive-captcha code that puzzle and icon-order use.
38
+
39
+ The demo playground has audio pages, and there is an end-to-end test for it.
40
+ - e13d7a8: New captcha type: `iconOrder`. The user is shown a frame of icons and a legend, and clicks the legend's icons in the order given.
41
+
42
+ Icon-order is off by default. Only Prosopo can switch it on for a site, with the `captchaTypeFeatureFlags.iconOrder` feature flag; the site owner cannot. A site without the flag is never served icon-order by any route, and the challenge endpoint refuses it. Once the flag is on, the owner can still keep icon-order out of the frictionless flow with `frictionlessTypes.iconOrder`, the same way as image and puzzle.
43
+
44
+ The answer never leaves the provider. Icon positions are stored on the challenge record, and the widget receives only the rendered frame and legend. Grading checks order as well as position, and each icon's hit radius scales with its size. Verifying a token is single-use under concurrent requests.
45
+
46
+ `@prosopo/icon-order-assets` draws the imagery, and `@prosopo/procaptcha-icon-order` is the widget. Its text is translated into every supported language.
47
+
48
+ Puzzle and icon-order now share their server code: challenge and solution handlers, the verify route, the submit and verify pipeline, and the database record methods. The widget code they have in common moves into `@prosopo/procaptcha-common`: the lazy mount wrapper, manager expiry and dispose, spent-session handling, behavioural data encryption and trusted click coordinates. Puzzle's behaviour is unchanged.
49
+
50
+ The demo playground has icon-order pages, and there is an end-to-end test for it.
51
+
52
+ ### Patch Changes
53
+
54
+ - bdac756: The checkbox can be clicked as soon as the widget appears, instead of spinning until bot detection has finished.
55
+
56
+ Detection downloads and runs a detector bundle before the widget knows which challenge to show, which took around three seconds on staging. The checkbox used to sit in its loading state for all of that. Now it is live from the first paint. A click made while detection is still running switches the box to "Checking", is remembered along with where the user clicked, and is replayed on whichever challenge detection picks, so the user never has to click twice.
57
+
58
+ This includes a click made after detection has answered but while the chosen challenge's code is still downloading. That click was being dropped, because the widget checked for a held click before the download rather than after it.
59
+
60
+ It also includes a click whose press begins on the placeholder just as the challenge is ready. Swapping the box out mid-press made the browser deliver the click to neither box, so the swap now waits, for up to a second, for the press to finish.
61
+
62
+ Nothing about what a token needs has changed: no challenge opens and no token is issued until detection has produced a verdict, so clicking early does not let a bot skip it. Synthetic clicks are still ignored, and a detection failure still falls back the same way it did before.
63
+
64
+ Tests: the checkbox is live while detection is pending; a click during detection shows the spinner and opens the chosen challenge with the click position once detection lands; a keyboard activation is held the same way; a synthetic click is ignored. `manualStart.test.ts` is renamed `startMode.test.ts`, since it now covers both start modes.
65
+
66
+ The e2e `clickIAmHuman` helper now waits on `/captcha/image` rather than any `/captcha/*` request. Cypress now clicks the checkbox before `/frictionless` has answered, so the broad pattern was catching that response instead of the image challenge.
67
+
68
+ The e2e checkbox helpers also click straight off a fresh query, rather than through a wrapped element. The widget swaps its placeholder checkbox for the challenge's own once detection answers, and a wrapped element that has left the page reports a (0, 0) position, so the click landed on the page corner.
69
+ - Updated dependencies [b299a91]
70
+ - Updated dependencies [e13d7a8]
71
+ - Updated dependencies [270395d]
72
+ - @prosopo/types@5.14.0
73
+ - @prosopo/api@4.5.0
74
+ - @prosopo/procaptcha-audio@0.2.0
75
+ - @prosopo/procaptcha-common@2.20.0
76
+ - @prosopo/procaptcha-react@2.14.0
77
+ - @prosopo/procaptcha-puzzle@2.16.0
78
+ - @prosopo/procaptcha-icon-order@0.2.0
79
+ - @prosopo/locale@3.8.0
80
+ - @prosopo/common@3.1.63
81
+ - @prosopo/procaptcha-pow@2.13.9
82
+
3
83
  ## 2.19.0
4
84
  ### Minor Changes
5
85
 
@@ -64,7 +64,7 @@ var withTimeout = async (promise, ms) => {
64
64
  throw error;
65
65
  }
66
66
  };
67
- var customDetectBot = async (config, container, restartFn, retryContext, refreshOf) => {
67
+ var customDetectBot = async (config, container, restartFn, retryContext, refreshOf, switchToImage) => {
68
68
  if (!config.account.address) throw new _prosopo_common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
69
69
  const ipMode = (0, _prosopo_procaptcha_common.pickIpMode)(config);
70
70
  const extClassPromise = (0, _prosopo_procaptcha_common.ExtensionLoader)(config.web2);
@@ -98,7 +98,7 @@ var customDetectBot = async (config, container, restartFn, retryContext, refresh
98
98
  if (providerDetect === void 0) {
99
99
  const userAccount = await ext.getAccount(config);
100
100
  const { currentUrl: fallbackUrl, iframeUrl: fallbackIframeUrl } = getCurrentPageUrls();
101
- const captcha = await withTimeout(providerApi.getFrictionlessCaptcha(void 0, void 0, config.account.address, userAccount.account.address, config.mode, void 0, void 0, fallbackUrl, fallbackIframeUrl, clientSessionId, refreshOf), 1e4);
101
+ const captcha = await withTimeout(providerApi.getFrictionlessCaptcha(void 0, void 0, config.account.address, userAccount.account.address, config.mode, void 0, void 0, fallbackUrl, fallbackIframeUrl, clientSessionId, refreshOf, switchToImage), 1e4);
102
102
  if (captcha.dns_url) try {
103
103
  fetch(captcha.dns_url, {
104
104
  method: "GET",
@@ -116,13 +116,14 @@ var customDetectBot = async (config, container, restartFn, retryContext, refresh
116
116
  userAccount,
117
117
  error: captcha.error,
118
118
  hp: captcha.hp,
119
- agent: captcha.agent
119
+ agent: captcha.agent,
120
+ audioAlternativeAvailable: captcha.audioAlternativeAvailable
120
121
  };
121
122
  }
122
123
  const detectionResult = await providerDetect(container, restartFn, () => ext.getAccount(config), detectorOptions);
123
124
  const userAccount = detectionResult.userAccount;
124
125
  const { currentUrl, iframeUrl } = getCurrentPageUrls();
125
- const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, void 0, detectorSessionId, currentUrl, iframeUrl, clientSessionId, refreshOf);
126
+ const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, void 0, detectorSessionId, currentUrl, iframeUrl, clientSessionId, refreshOf, switchToImage);
126
127
  if (detectionResult.getSimdReadings) detectionResult.getSimdReadings(6e4).catch(() => void 0);
127
128
  const captcha = await withTimeout(captchaPromise, 1e4);
128
129
  if (captcha.dns_url) try {
@@ -143,6 +144,7 @@ var customDetectBot = async (config, container, restartFn, retryContext, refresh
143
144
  error: captcha.error,
144
145
  hp: captcha.hp,
145
146
  agent: captcha.agent,
147
+ audioAlternativeAvailable: captcha.audioAlternativeAvailable,
146
148
  behaviorCollector1: detectionResult.mouseTracker,
147
149
  behaviorCollector2: detectionResult.touchTracker,
148
150
  behaviorCollector3: detectionResult.clickTracker,
@@ -8,10 +8,21 @@ let _prosopo_types = require("@prosopo/types");
8
8
  let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
9
9
  //#region src/procaptchaFrictionless.ts
10
10
  var NO_SESSION_FOUND_KEY = "CAPTCHA.NO_SESSION_FOUND";
11
+ var MAX_PRESS_HOLD_MS = 1e3;
11
12
  var PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
12
13
  var ProcaptchaLoader = async () => (await import("@prosopo/procaptcha-react")).mountProcaptchaImageWidget;
13
14
  var ProcaptchaPuzzleLoader = async () => (await import("@prosopo/procaptcha-puzzle")).mountProcaptchaPuzzleWidget;
15
+ var ProcaptchaIconOrderLoader = async () => (await import("@prosopo/procaptcha-icon-order")).mountProcaptchaIconOrderWidget;
14
16
  var ProcaptchaPowLoader = async () => (await import("@prosopo/procaptcha-pow")).mountProcaptchaPowWidget;
17
+ var ProcaptchaAudioLoader = async () => (await import("@prosopo/procaptcha-audio")).mountProcaptchaAudioWidget;
18
+ /** Solvers that ask for a fresh session through `onReload`. */
19
+ var reloadableSolverLoaders = /* @__PURE__ */ new Map([
20
+ [_prosopo_types.CaptchaType.image, ProcaptchaLoader],
21
+ [_prosopo_types.CaptchaType.puzzle, ProcaptchaPuzzleLoader],
22
+ [_prosopo_types.CaptchaType.iconOrder, ProcaptchaIconOrderLoader]
23
+ ]);
24
+ /** Mirrors the provider's `isAudioAlternativeSessionType`. */
25
+ var offersAudioAlternative = (captchaType) => reloadableSolverLoaders.has(captchaType);
15
26
  var defaultLoadingState = (attemptCount) => ({
16
27
  loading: false,
17
28
  attemptCount
@@ -28,6 +39,10 @@ var mountProcaptchaFrictionless = (container, props) => {
28
39
  let nextMountAutoStart = false;
29
40
  let nextMountShowRetry = true === props.startShowRetry;
30
41
  let nextRefreshOf;
42
+ let nextSwitchToImage = false;
43
+ let replacementCount = 0;
44
+ let audioChosen = false;
45
+ let audioAlternativeAvailable = false;
31
46
  const manualStart = _prosopo_types.StartModeEnum.manual === config.startMode;
32
47
  let manualStarted = false;
33
48
  let pendingExecute = false;
@@ -36,6 +51,21 @@ var mountProcaptchaFrictionless = (container, props) => {
36
51
  container.appendChild(slot);
37
52
  let solver;
38
53
  let placeholder;
54
+ let pressReleased;
55
+ teardown.addEventListener(slot, "pointerdown", (event) => {
56
+ if (!placeholder || !(0, _prosopo_procaptcha_common.isEventTrusted)(event)) return;
57
+ pressReleased = new Promise((resolve) => {
58
+ const release = () => {
59
+ clearTimeout(timer);
60
+ window.removeEventListener("pointerup", release, true);
61
+ window.removeEventListener("pointercancel", release, true);
62
+ setTimeout(resolve, 0);
63
+ };
64
+ const timer = setTimeout(release, MAX_PRESS_HOLD_MS);
65
+ window.addEventListener("pointerup", release, true);
66
+ window.addEventListener("pointercancel", release, true);
67
+ });
68
+ });
39
69
  const clearSlot = () => {
40
70
  solver?.destroy();
41
71
  solver = void 0;
@@ -88,6 +118,7 @@ var mountProcaptchaFrictionless = (container, props) => {
88
118
  (widgetContainer ?? document).dispatchEvent(new CustomEvent(PROCAPTCHA_EXECUTE_EVENT));
89
119
  };
90
120
  const renderForCaptchaType = async (captchaType, frictionlessState, autoStart = false, escalationCoords) => {
121
+ audioChosen = audioChosen && offersAudioAlternative(captchaType);
91
122
  const onEscalate = (next, newSessionId, coords) => {
92
123
  if (escalatedSessionIds.has(newSessionId)) return;
93
124
  escalatedSessionIds.add(newSessionId);
@@ -112,25 +143,37 @@ var mountProcaptchaFrictionless = (container, props) => {
112
143
  nextMountAutoStart = true;
113
144
  nextMountShowRetry = true === options?.showRetry;
114
145
  nextRefreshOf = true === options?.refresh ? frictionlessState.sessionId : void 0;
146
+ nextSwitchToImage = true === options?.refresh && true === options?.switchToImage;
147
+ replacementCount = nextSwitchToImage ? 0 : replacementCount + 1;
115
148
  sessionInvalidatedAttempts.current = 0;
116
149
  resetState(0);
117
150
  start();
118
151
  };
119
- const forcedAutoStart = nextMountAutoStart;
120
- nextMountAutoStart = false;
121
- const startShowRetry = nextMountShowRetry;
122
- nextMountShowRetry = false;
123
- const { autoStart: resumedAutoStart, startCoords: retryStartCoords } = require_sessionInvalidatedRecovery.consumeRetryMountProps(pendingRetryCoords, autoStart || forcedAutoStart);
124
- const widgetProps = {
125
- config,
126
- callbacks,
127
- frictionlessState,
128
- i18n,
129
- autoStart: resumedAutoStart,
130
- startCoords: escalationCoords ?? retryStartCoords,
131
- startShowRetry,
132
- onSessionInvalidated,
133
- container: widgetContainer
152
+ const onRequestAudioAlternative = () => {
153
+ audioChosen = true;
154
+ nextMountAutoStart = true;
155
+ sessionInvalidatedAttempts.current = 0;
156
+ resetState(0);
157
+ start();
158
+ };
159
+ const takeWidgetProps = () => {
160
+ const forcedAutoStart = nextMountAutoStart;
161
+ nextMountAutoStart = false;
162
+ const startShowRetry = nextMountShowRetry;
163
+ nextMountShowRetry = false;
164
+ const { autoStart: resumedAutoStart, startCoords: retryStartCoords } = require_sessionInvalidatedRecovery.consumeRetryMountProps(pendingRetryCoords, autoStart || forcedAutoStart);
165
+ return {
166
+ config,
167
+ callbacks,
168
+ frictionlessState,
169
+ i18n,
170
+ autoStart: resumedAutoStart,
171
+ startCoords: escalationCoords ?? retryStartCoords,
172
+ startShowRetry,
173
+ startReplacementCount: replacementCount,
174
+ onSessionInvalidated,
175
+ container: widgetContainer
176
+ };
134
177
  };
135
178
  if (_prosopo_types.CaptchaType.authenticated === captchaType) {
136
179
  if (!frictionlessState.sessionId) {
@@ -154,33 +197,30 @@ var mountProcaptchaFrictionless = (container, props) => {
154
197
  });
155
198
  return;
156
199
  }
157
- if (_prosopo_types.CaptchaType.image === captchaType) {
158
- const mount = await ProcaptchaLoader();
200
+ const loadReloadableSolver = audioChosen ? ProcaptchaAudioLoader : reloadableSolverLoaders.get(captchaType);
201
+ if (loadReloadableSolver) {
202
+ const offerAudio = audioAlternativeAvailable && !audioChosen;
203
+ const mount = await loadReloadableSolver();
204
+ await pressReleased;
159
205
  if (destroyed) return;
160
206
  clearSlot();
161
207
  solver = mount(slot, {
162
- ...widgetProps,
163
- onReload
164
- });
165
- replayPendingExecute();
166
- return;
167
- }
168
- if (_prosopo_types.CaptchaType.puzzle === captchaType) {
169
- const mount = await ProcaptchaPuzzleLoader();
170
- if (destroyed) return;
171
- clearSlot();
172
- solver = mount(slot, {
173
- ...widgetProps,
174
- onReload
208
+ ...takeWidgetProps(),
209
+ onReload,
210
+ ...offerAudio && {
211
+ audioAlternativeAvailable: true,
212
+ onRequestAudioAlternative
213
+ }
175
214
  });
176
215
  replayPendingExecute();
177
216
  return;
178
217
  }
179
218
  const mount = await ProcaptchaPowLoader();
219
+ await pressReleased;
180
220
  if (destroyed) return;
181
221
  clearSlot();
182
222
  solver = mount(slot, {
183
- ...widgetProps,
223
+ ...takeWidgetProps(),
184
224
  onEscalate
185
225
  });
186
226
  replayPendingExecute();
@@ -195,7 +235,7 @@ var mountProcaptchaFrictionless = (container, props) => {
195
235
  await (0, _prosopo_procaptcha_common.providerRetry)(async () => {
196
236
  state.attemptCount += 1;
197
237
  const configOutput = _prosopo_types.ProcaptchaConfigSchema.parse(config);
198
- const result = await detectBot(configOutput, widgetContainer, restart, { attempt: state.attemptCount }, nextRefreshOf);
238
+ const result = await detectBot(configOutput, widgetContainer, restart, { attempt: state.attemptCount }, nextRefreshOf, nextSwitchToImage);
199
239
  const guard = require_frictionlessResultGuard.evaluateFrictionlessResult(result);
200
240
  if ("error" === guard.kind) {
201
241
  if (guard.retryable) throw new Error(guard.message);
@@ -209,6 +249,7 @@ var mountProcaptchaFrictionless = (container, props) => {
209
249
  return;
210
250
  }
211
251
  nextRefreshOf = void 0;
252
+ nextSwitchToImage = false;
212
253
  const frictionlessState = {
213
254
  provider: result.provider,
214
255
  sessionId: result.sessionId,
@@ -224,6 +265,7 @@ var mountProcaptchaFrictionless = (container, props) => {
224
265
  hp: result.hp,
225
266
  agent: result.agent
226
267
  };
268
+ audioAlternativeAvailable = true === result.audioAlternativeAvailable;
227
269
  await renderForCaptchaType(result.captchaType, frictionlessState);
228
270
  state = {
229
271
  ...state,
@@ -253,16 +295,16 @@ var mountProcaptchaFrictionless = (container, props) => {
253
295
  if (config.language) if (i18n) {
254
296
  if (i18n.language !== config.language) i18n.changeLanguage(config.language);
255
297
  } else (0, _prosopo_locale.loadI18next)(false, config.language);
298
+ const clickCoords = (event) => "clientX" in event && "clientY" in event ? require_sessionInvalidatedRecovery.normaliseRetryCoords(event.clientX, event.clientY) : null;
256
299
  const manualCheckboxHandler = async (event) => {
257
- let x = 0;
258
- let y = 0;
259
- if ("clientX" in event && "clientY" in event) {
260
- x = event.clientX;
261
- y = event.clientY;
262
- }
263
- await startManually(true, require_sessionInvalidatedRecovery.normaliseRetryCoords(x, y) ?? void 0);
300
+ await startManually(true, clickCoords(event) ?? void 0);
301
+ };
302
+ const holdClickUntilDetected = (event) => {
303
+ pendingRetryCoords.current = clickCoords(event);
304
+ nextMountAutoStart = true;
305
+ renderPlaceholder(config.mode, void 0, true);
264
306
  };
265
- renderPlaceholder(config.mode, state.errorMessage, !manualStart, manualStart ? manualCheckboxHandler : void 0);
307
+ renderPlaceholder(config.mode, state.errorMessage, false, manualStart ? manualCheckboxHandler : holdClickUntilDetected);
266
308
  if (manualStart) {
267
309
  teardown.addEventListener(document, _prosopo_types.PROCAPTCHA_START_EVENT, (event) => {
268
310
  const detail = event.detail;
@@ -1 +1 @@
1
- {"version":3,"file":"customDetectBot.d.ts","sourceRoot":"","sources":["../src/customDetectBot.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACX,oBAAoB,EAGpB,MAAM,gBAAgB,CAAC;AA0FxB,eAAO,MAAM,WAAW,GAAU,CAAC,WACzB,OAAO,CAAC,CAAC,CAAC,MACf,MAAM,KACR,OAAO,CAAC,CAAC,CAoBX,CAAC;AAEF,QAAA,MAAM,eAAe,EAAE,oBA2PtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"customDetectBot.d.ts","sourceRoot":"","sources":["../src/customDetectBot.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACX,oBAAoB,EAGpB,MAAM,gBAAgB,CAAC;AA0FxB,eAAO,MAAM,WAAW,GAAU,CAAC,WACzB,OAAO,CAAC,CAAC,CAAC,MACf,MAAM,KACR,OAAO,CAAC,CAAC,CAoBX,CAAC;AAEF,QAAA,MAAM,eAAe,EAAE,oBAgQtB,CAAC;AAEF,eAAe,eAAe,CAAC"}