@prosopo/procaptcha-puzzle 2.14.7 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build$colon$cjs.log +6 -9
- package/.turbo/turbo-build$colon$tsc.log +19 -22
- package/.turbo/turbo-build.log +7 -13
- package/CHANGELOG.md +65 -0
- package/LICENSE +201 -0
- package/dist/cjs/components/procaptchaPuzzle.cjs +2 -17
- package/dist/cjs/components/procaptchaWidget.cjs +22 -19
- package/dist/cjs/components/puzzleCanvas.cjs +35 -5
- package/dist/cjs/services/Manager.cjs +10 -44
- package/dist/components/procaptchaPuzzle.d.ts +3 -3
- package/dist/components/procaptchaPuzzle.d.ts.map +1 -1
- package/dist/components/procaptchaPuzzle.js +2 -17
- package/dist/components/procaptchaPuzzle.js.map +1 -1
- package/dist/components/procaptchaWidget.d.ts.map +1 -1
- package/dist/components/procaptchaWidget.js +21 -18
- package/dist/components/procaptchaWidget.js.map +1 -1
- package/dist/components/puzzleCanvas.d.ts +4 -2
- package/dist/components/puzzleCanvas.d.ts.map +1 -1
- package/dist/components/puzzleCanvas.js +36 -6
- package/dist/components/puzzleCanvas.js.map +1 -1
- package/dist/services/Manager.d.ts.map +1 -1
- package/dist/services/Manager.js +11 -45
- package/dist/services/Manager.js.map +1 -1
- package/dist/tests/procaptchaWidget.unit.test.js +91 -0
- package/dist/tests/procaptchaWidget.unit.test.js.map +1 -1
- package/dist/tests/puzzleCanvas.unit.test.js +69 -0
- package/dist/tests/puzzleCanvas.unit.test.js.map +1 -1
- package/package.json +72 -71
- package/src/components/procaptchaPuzzle.ts +0 -54
- package/src/components/procaptchaWidget.ts +0 -429
- package/src/components/puzzleCanvas.ts +0 -658
- package/src/index.ts +0 -16
- package/src/services/Manager.ts +0 -529
- package/src/tests/domHarness.ts +0 -122
- package/src/tests/invisibleCanvasVisibility.unit.test.ts +0 -181
- package/src/tests/manager.unit.test.ts +0 -840
- package/src/tests/managerHarness.ts +0 -169
- package/src/tests/procaptchaPuzzle.test-d.ts +0 -212
- package/src/tests/procaptchaPuzzle.unit.test.ts +0 -138
- package/src/tests/procaptchaWidget.unit.test.ts +0 -777
- package/src/tests/puzzleCanvas.unit.test.ts +0 -662
- package/tsconfig.cjs.json +0 -43
- package/tsconfig.json +0 -44
- package/tsconfig.tsbuildinfo +0 -1
- package/tsconfig.types.json +0 -9
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
> @prosopo/procaptcha-puzzle@2.14.7 build:cjs
|
|
3
|
-
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
|
-
|
|
1
|
+
$ NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
5
2
|
ViteCommonJSConfig: .
|
|
6
3
|
{
|
|
7
4
|
tsConfigPaths: [
|
|
@@ -46,10 +43,10 @@ Bundle build started
|
|
|
46
43
|
✓ 6 modules transformed.
|
|
47
44
|
rendering chunks...
|
|
48
45
|
computing gzip size...
|
|
46
|
+
dist/cjs/components/procaptchaPuzzle.cjs 0.47 kB │ gzip: 0.22 kB
|
|
49
47
|
dist/cjs/index.cjs 0.60 kB │ gzip: 0.21 kB
|
|
50
|
-
dist/cjs/components/
|
|
51
|
-
dist/cjs/
|
|
52
|
-
dist/cjs/
|
|
53
|
-
dist/cjs/components/puzzleCanvas.cjs 13.73 kB │ gzip: 4.11 kB
|
|
48
|
+
dist/cjs/components/procaptchaWidget.cjs 8.18 kB │ gzip: 2.22 kB
|
|
49
|
+
dist/cjs/services/Manager.cjs 8.61 kB │ gzip: 2.42 kB
|
|
50
|
+
dist/cjs/components/puzzleCanvas.cjs 15.20 kB │ gzip: 4.47 kB
|
|
54
51
|
|
|
55
|
-
[32m✓ built in
|
|
52
|
+
[32m✓ built in 45ms[39m
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> tsc --build --verbose
|
|
4
|
-
|
|
5
|
-
12:38:48 PM - Projects in this build:
|
|
1
|
+
$ tsc --build --verbose
|
|
2
|
+
10:11:54 AM - Projects in this build:
|
|
6
3
|
* ../../dev/config/tsconfig.json
|
|
7
4
|
* ../util/tsconfig.json
|
|
8
5
|
* ../locale/tsconfig.json
|
|
@@ -20,37 +17,37 @@
|
|
|
20
17
|
* ../procaptcha-common/tsconfig.json
|
|
21
18
|
* tsconfig.json
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
10:11:54 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'
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
10:11:54 AM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/table.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
10:11:54 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
10:11:54 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'
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
10:11:54 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'
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
10:11:54 AM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
10:11:54 AM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/logger.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
10:11:55 AM - 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'
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
10:11:55 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'
|
|
40
37
|
|
|
41
|
-
|
|
38
|
+
10:11:55 AM - 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'
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
10:11:55 AM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/sources/session_storage.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
10:11:55 AM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
10:11:55 AM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/index.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
10:11:55 AM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/index.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
50
47
|
|
|
51
|
-
|
|
48
|
+
10:11:55 AM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/tests/testModeBanner.unit.test.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
|
|
52
49
|
|
|
53
|
-
|
|
50
|
+
10:11:55 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
10:11:55 AM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-puzzle/tsconfig.json'...
|
|
56
53
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
> @prosopo/procaptcha-puzzle@2.14.7 build:cross-env
|
|
7
|
-
> vite build --config vite.esm.config.ts --mode production
|
|
8
|
-
|
|
1
|
+
$ pnpm run build:cross-env --mode ${NODE_ENV:-development}
|
|
2
|
+
$ vite build --config vite.esm.config.ts --mode production
|
|
9
3
|
ViteEsmConfig: .
|
|
10
4
|
{
|
|
11
5
|
tsConfigPaths: [
|
|
@@ -51,10 +45,10 @@ Bundle build started
|
|
|
51
45
|
rendering chunks...
|
|
52
46
|
computing gzip size...
|
|
53
47
|
dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
|
|
48
|
+
dist/components/procaptchaPuzzle.js 0.33 kB │ gzip: 0.19 kB
|
|
54
49
|
dist/index.js 0.38 kB │ gzip: 0.16 kB
|
|
55
|
-
dist/components/
|
|
56
|
-
dist/
|
|
57
|
-
dist/
|
|
58
|
-
dist/components/puzzleCanvas.js 13.15 kB │ gzip: 4.10 kB
|
|
50
|
+
dist/components/procaptchaWidget.js 7.81 kB │ gzip: 2.22 kB
|
|
51
|
+
dist/services/Manager.js 8.06 kB │ gzip: 2.38 kB
|
|
52
|
+
dist/components/puzzleCanvas.js 14.47 kB │ gzip: 4.46 kB
|
|
59
53
|
|
|
60
|
-
[32m✓ built in
|
|
54
|
+
[32m✓ built in 110ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# @prosopo/procaptcha-puzzle
|
|
2
2
|
|
|
3
|
+
## 2.16.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
- 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.
|
|
7
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
The demo playground has audio pages, and there is an end-to-end test for it.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 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.
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
|
|
24
|
+
`@prosopo/icon-order-assets` draws the imagery, and `@prosopo/procaptcha-icon-order` is the widget. Its text is translated into every supported language.
|
|
25
|
+
|
|
26
|
+
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.
|
|
27
|
+
|
|
28
|
+
The demo playground has icon-order pages, and there is an end-to-end test for it.
|
|
29
|
+
- Updated dependencies [b299a91]
|
|
30
|
+
- Updated dependencies [e13d7a8]
|
|
31
|
+
- Updated dependencies [270395d]
|
|
32
|
+
- @prosopo/types@5.14.0
|
|
33
|
+
- @prosopo/api@4.5.0
|
|
34
|
+
- @prosopo/procaptcha-common@2.20.0
|
|
35
|
+
- @prosopo/locale@3.8.0
|
|
36
|
+
- @prosopo/common@3.1.63
|
|
37
|
+
|
|
38
|
+
## 2.15.0
|
|
39
|
+
### Minor Changes
|
|
40
|
+
|
|
41
|
+
- dcb691b: Add a refresh control to the puzzle captcha.
|
|
42
|
+
|
|
43
|
+
A user who can't solve the puzzle they were given can now ask for a different one, from a button in the puzzle's header. The replacement comes through a new frictionless session, like a wrong answer already does.
|
|
44
|
+
|
|
45
|
+
The widget tells the provider which session was refreshed (`refreshOf`). The provider then records `refreshOf`, `refreshCount` and `refreshedAfterMs` on the new session, so refresh behaviour can be scored later. After three refreshes in a row it serves an image challenge instead, with reason `PUZZLE_REFRESH_LIMIT`. It only does this if the site has image enabled. The switch only goes from puzzle to image, so a client that lies about its refreshes can only make its own challenge harder. A client that leaves the field out gets a normal session, the same as reloading the page.
|
|
46
|
+
|
|
47
|
+
The image widget's reload button now reports itself as a refresh too. That way a user who was moved onto image isn't sent back to the puzzle by their next reload.
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [1c13037]
|
|
52
|
+
- Updated dependencies [2e69b83]
|
|
53
|
+
- Updated dependencies [f961dab]
|
|
54
|
+
- Updated dependencies [a17e8eb]
|
|
55
|
+
- Updated dependencies [7d57d2a]
|
|
56
|
+
- Updated dependencies [dcb691b]
|
|
57
|
+
- Updated dependencies [80b7780]
|
|
58
|
+
- Updated dependencies [dd4c27c]
|
|
59
|
+
- @prosopo/types@5.13.0
|
|
60
|
+
- @prosopo/procaptcha-common@2.19.0
|
|
61
|
+
- @prosopo/util@3.3.14
|
|
62
|
+
- @prosopo/api@4.4.0
|
|
63
|
+
- @prosopo/locale@3.7.0
|
|
64
|
+
- @prosopo/common@3.1.62
|
|
65
|
+
- @prosopo/util-crypto@13.6.0
|
|
66
|
+
- @prosopo/widget-skeleton@2.10.1
|
|
67
|
+
|
|
3
68
|
## 2.14.7
|
|
4
69
|
### Patch Changes
|
|
5
70
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2022 PROSOPO LIMITED
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -1,22 +1,7 @@
|
|
|
1
|
+
let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
|
|
1
2
|
//#region src/components/procaptchaPuzzle.ts
|
|
2
|
-
/**
|
|
3
|
-
* Dynamic import so the puzzle widget lands in its own chunk, replacing the
|
|
4
|
-
* `lazy()` + `<Suspense>` pair that used to provide the split.
|
|
5
|
-
*/
|
|
6
3
|
var loadProcaptchaPuzzle = async () => (await Promise.resolve().then(() => require("./procaptchaWidget.cjs"))).mountProcaptchaPuzzleWidget;
|
|
7
|
-
var mountProcaptchaPuzzle = (
|
|
8
|
-
let destroyed = false;
|
|
9
|
-
let inner;
|
|
10
|
-
loadProcaptchaPuzzle().then((mount) => {
|
|
11
|
-
if (destroyed) return;
|
|
12
|
-
inner = mount(container, props);
|
|
13
|
-
});
|
|
14
|
-
return { destroy: () => {
|
|
15
|
-
destroyed = true;
|
|
16
|
-
inner?.destroy();
|
|
17
|
-
inner = void 0;
|
|
18
|
-
} };
|
|
19
|
-
};
|
|
4
|
+
var mountProcaptchaPuzzle = (0, _prosopo_procaptcha_common.lazyMount)(loadProcaptchaPuzzle);
|
|
20
5
|
//#endregion
|
|
21
6
|
exports.loadProcaptchaPuzzle = loadProcaptchaPuzzle;
|
|
22
7
|
exports.mountProcaptchaPuzzle = mountProcaptchaPuzzle;
|
|
@@ -5,7 +5,6 @@ let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
|
|
|
5
5
|
let _prosopo_types = require("@prosopo/types");
|
|
6
6
|
let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
|
|
7
7
|
//#region src/components/procaptchaWidget.ts
|
|
8
|
-
var PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
|
|
9
8
|
var mountProcaptchaPuzzleWidget = (container, props) => {
|
|
10
9
|
const teardown = new _prosopo_procaptcha_common.Teardown();
|
|
11
10
|
const config = props.config;
|
|
@@ -50,16 +49,21 @@ var mountProcaptchaPuzzleWidget = (container, props) => {
|
|
|
50
49
|
showRetry = true;
|
|
51
50
|
puzzlePhase = "dragging";
|
|
52
51
|
scheduler.schedule();
|
|
52
|
+
await replaceChallenge({ showRetry: true });
|
|
53
|
+
};
|
|
54
|
+
const replaceChallenge = async (options) => {
|
|
53
55
|
if (frictionlessState?.sessionId && props.onReload) {
|
|
54
56
|
puzzlePhase = "submitting";
|
|
55
57
|
scheduler.schedule();
|
|
56
|
-
props.onReload(lastCoords?.x, lastCoords?.y,
|
|
58
|
+
props.onReload(lastCoords?.x, lastCoords?.y, options);
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
61
|
try {
|
|
60
62
|
const newChallenge = await manager.start();
|
|
61
|
-
if (newChallenge)
|
|
62
|
-
|
|
63
|
+
if (newChallenge) {
|
|
64
|
+
challengeData = newChallenge;
|
|
65
|
+
puzzlePhase = "dragging";
|
|
66
|
+
} else {
|
|
63
67
|
puzzlePhase = "checkbox";
|
|
64
68
|
challengeData = null;
|
|
65
69
|
showRetry = false;
|
|
@@ -72,6 +76,14 @@ var mountProcaptchaPuzzleWidget = (container, props) => {
|
|
|
72
76
|
loading = false;
|
|
73
77
|
scheduler.schedule();
|
|
74
78
|
};
|
|
79
|
+
const handleRefresh = () => {
|
|
80
|
+
if ("dragging" !== puzzlePhase) return;
|
|
81
|
+
callbacks.onReload?.();
|
|
82
|
+
showRetry = false;
|
|
83
|
+
puzzlePhase = "submitting";
|
|
84
|
+
scheduler.schedule();
|
|
85
|
+
replaceChallenge({ refresh: true });
|
|
86
|
+
};
|
|
75
87
|
const handleDismiss = () => {
|
|
76
88
|
puzzlePhase = "checkbox";
|
|
77
89
|
challengeData = null;
|
|
@@ -94,7 +106,9 @@ var mountProcaptchaPuzzleWidget = (container, props) => {
|
|
|
94
106
|
translator,
|
|
95
107
|
placement: config.placement,
|
|
96
108
|
anchor: props.container,
|
|
97
|
-
onDismiss: handleDismiss
|
|
109
|
+
onDismiss: handleDismiss,
|
|
110
|
+
audioAlternative: (0, _prosopo_procaptcha_common.audioAlternativeOffer)(props, translator.isReady() ? translator.t("WIDGET.AUDIO_ALTERNATIVE") : ""),
|
|
111
|
+
onRefresh: handleRefresh
|
|
98
112
|
});
|
|
99
113
|
const runErrorEffect = () => {
|
|
100
114
|
if (store.state.error === lastError) return;
|
|
@@ -144,18 +158,7 @@ var mountProcaptchaPuzzleWidget = (container, props) => {
|
|
|
144
158
|
loading = true;
|
|
145
159
|
showRetry = false;
|
|
146
160
|
scheduler.schedule();
|
|
147
|
-
|
|
148
|
-
let y = 0;
|
|
149
|
-
if (!(0, _prosopo_procaptcha_common.isEventTrusted)(event)) {} else if ("touches" in event && event.touches.length > 0) {
|
|
150
|
-
const touch = event.touches[0];
|
|
151
|
-
if (touch) {
|
|
152
|
-
x = touch.clientX;
|
|
153
|
-
y = touch.clientY;
|
|
154
|
-
}
|
|
155
|
-
} else if ("clientX" in event && "clientY" in event) {
|
|
156
|
-
x = event.clientX;
|
|
157
|
-
y = event.clientY;
|
|
158
|
-
}
|
|
161
|
+
const { x, y } = (0, _prosopo_procaptcha_common.trustedClickCoords)(event);
|
|
159
162
|
lastCoords = {
|
|
160
163
|
x,
|
|
161
164
|
y
|
|
@@ -198,8 +201,8 @@ var mountProcaptchaPuzzleWidget = (container, props) => {
|
|
|
198
201
|
}
|
|
199
202
|
})();
|
|
200
203
|
};
|
|
201
|
-
if (props.container) teardown.addEventListener(props.container, PROCAPTCHA_EXECUTE_EVENT, handleExecute);
|
|
202
|
-
if (isInvisible) teardown.addEventListener(document, PROCAPTCHA_EXECUTE_EVENT, handleExecute);
|
|
204
|
+
if (props.container) teardown.addEventListener(props.container, _prosopo_procaptcha_common.PROCAPTCHA_EXECUTE_EVENT, handleExecute);
|
|
205
|
+
if (isInvisible) teardown.addEventListener(document, _prosopo_procaptcha_common.PROCAPTCHA_EXECUTE_EVENT, handleExecute);
|
|
203
206
|
if (config.language) if (i18n) {
|
|
204
207
|
if (i18n.language !== config.language) i18n.changeLanguage(config.language);
|
|
205
208
|
} else (0, _prosopo_locale.loadI18next)(false, config.language);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
|
|
2
|
+
let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
|
|
2
3
|
//#region src/components/puzzleCanvas.ts
|
|
3
4
|
var CONTAINER_WIDTH = 300;
|
|
4
5
|
var CONTAINER_HEIGHT = 200;
|
|
@@ -174,18 +175,26 @@ var mountPuzzleCanvas = (initialProps) => {
|
|
|
174
175
|
},
|
|
175
176
|
children: [backgroundLayer, piece]
|
|
176
177
|
});
|
|
178
|
+
const instructionText = (0, _prosopo_procaptcha_common.createElement)("span", { attributes: { id: instructionId } });
|
|
179
|
+
const refreshSlot = (0, _prosopo_procaptcha_common.createElement)("div", { style: {
|
|
180
|
+
position: "absolute",
|
|
181
|
+
right: "8px",
|
|
182
|
+
top: "50%",
|
|
183
|
+
transform: "translateY(-50%)"
|
|
184
|
+
} });
|
|
177
185
|
const instruction = (0, _prosopo_procaptcha_common.createElement)("div", {
|
|
178
|
-
attributes: { id: instructionId },
|
|
179
186
|
style: {
|
|
187
|
+
position: "relative",
|
|
180
188
|
borderRadius: "20px 20px 0 0",
|
|
181
|
-
padding: "12px
|
|
189
|
+
padding: "12px 48px",
|
|
182
190
|
width: `${CONTAINER_WIDTH}px`,
|
|
183
191
|
boxSizing: "border-box",
|
|
184
192
|
textAlign: "center",
|
|
185
193
|
fontSize: "14px",
|
|
186
194
|
fontWeight: 500,
|
|
187
195
|
transition: "color 0.3s ease, border-color 0.3s ease"
|
|
188
|
-
}
|
|
196
|
+
},
|
|
197
|
+
children: [instructionText, refreshSlot]
|
|
189
198
|
});
|
|
190
199
|
const panel = (0, _prosopo_procaptcha_common.createElement)("div", {
|
|
191
200
|
style: {
|
|
@@ -197,6 +206,15 @@ var mountPuzzleCanvas = (initialProps) => {
|
|
|
197
206
|
},
|
|
198
207
|
children: [instruction, area]
|
|
199
208
|
});
|
|
209
|
+
const refreshButtonProps = () => ({
|
|
210
|
+
themeColor: _prosopo_widget_skeleton.lightTheme === props.theme ? "light" : "dark",
|
|
211
|
+
label: t("WIDGET.PUZZLE.REFRESH", { defaultValue: "Show a different puzzle" }),
|
|
212
|
+
compact: true,
|
|
213
|
+
onReload: () => {
|
|
214
|
+
if (!props.submitting && !dragging) props.onRefresh?.();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
const refreshButton = props.onRefresh ? (0, _prosopo_procaptcha_common.mountReloadButton)(refreshSlot, refreshButtonProps()) : void 0;
|
|
200
218
|
const surfaceProps = () => ({
|
|
201
219
|
show: true,
|
|
202
220
|
placement: props.placement,
|
|
@@ -207,6 +225,12 @@ var mountPuzzleCanvas = (initialProps) => {
|
|
|
207
225
|
});
|
|
208
226
|
const surface = (0, _prosopo_procaptcha_common.mountChallengeSurface)(surfaceProps());
|
|
209
227
|
surface.content.append(style, announcer, keyboardHint, panel);
|
|
228
|
+
const audioAlternativeFooterProps = () => ({
|
|
229
|
+
offer: props.audioAlternative,
|
|
230
|
+
theme: props.theme,
|
|
231
|
+
width: CONTAINER_WIDTH
|
|
232
|
+
});
|
|
233
|
+
const audioAlternativeFooter = (0, _prosopo_procaptcha_common.mountAudioAlternativeFooter)(panel, audioAlternativeFooterProps());
|
|
210
234
|
const announce = (message, delayMs = 0) => {
|
|
211
235
|
if (void 0 !== announceTimer) {
|
|
212
236
|
clearTimeout(announceTimer);
|
|
@@ -265,7 +289,7 @@ var mountPuzzleCanvas = (initialProps) => {
|
|
|
265
289
|
transform: visible ? "scale(1)" : "scale(0.9)",
|
|
266
290
|
animation: shaking ? "prosopo-puzzle-shake 0.5s ease" : "none"
|
|
267
291
|
});
|
|
268
|
-
|
|
292
|
+
instructionText.textContent = props.showRetry ? t("WIDGET.PUZZLE.RETRY", { defaultValue: "Not quite — try again" }) : t("WIDGET.PUZZLE.DRAG", { defaultValue: "Drag the piece to the target" });
|
|
269
293
|
keyboardHint.textContent = t("WIDGET.PUZZLE.KEYBOARD_HINT", { defaultValue: "Use the arrow keys to move the piece, holding shift for smaller steps. Press Enter to submit it, Home to put it back at the start, or Escape to cancel." });
|
|
270
294
|
(0, _prosopo_procaptcha_common.applyStyles)(instruction, {
|
|
271
295
|
backgroundColor: theme.palette.surface,
|
|
@@ -273,11 +297,15 @@ var mountPuzzleCanvas = (initialProps) => {
|
|
|
273
297
|
color: props.showRetry ? theme.palette.error.main : theme.palette.onSurface,
|
|
274
298
|
borderBottom: `2px solid ${props.showRetry ? theme.palette.error.main : "transparent"}`
|
|
275
299
|
});
|
|
300
|
+
(0, _prosopo_procaptcha_common.applyStyles)(refreshSlot, { visibility: props.submitting ? "hidden" : "visible" });
|
|
301
|
+
refreshButton?.update(refreshButtonProps());
|
|
276
302
|
(0, _prosopo_procaptcha_common.applyStyles)(area, {
|
|
277
303
|
background: `linear-gradient(135deg, ${theme.palette.surface} 0%, ${theme.palette.primaryContainer.main} 50%, ${theme.palette.surface} 100%)`,
|
|
278
304
|
opacity: props.submitting ? .6 : 1,
|
|
279
|
-
pointerEvents: props.submitting ? "none" : "auto"
|
|
305
|
+
pointerEvents: props.submitting ? "none" : "auto",
|
|
306
|
+
borderRadius: props.audioAlternative ? "0" : "0 0 20px 20px"
|
|
280
307
|
});
|
|
308
|
+
audioAlternativeFooter.update(audioAlternativeFooterProps());
|
|
281
309
|
for (const tile of backgroundTiles) tile.src = props.background;
|
|
282
310
|
(0, _prosopo_procaptcha_common.applyAttributes)(piece, {
|
|
283
311
|
tabindex: props.submitting ? -1 : 0,
|
|
@@ -443,6 +471,8 @@ var mountPuzzleCanvas = (initialProps) => {
|
|
|
443
471
|
},
|
|
444
472
|
destroy: () => {
|
|
445
473
|
teardown.run();
|
|
474
|
+
audioAlternativeFooter.destroy();
|
|
475
|
+
refreshButton?.destroy();
|
|
446
476
|
surface.destroy();
|
|
447
477
|
}
|
|
448
478
|
};
|