@prosopo/procaptcha 2.11.32 → 2.11.34
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 +8 -8
- package/.turbo/turbo-build$colon$tsc.log +20 -20
- package/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +65 -0
- package/dist/cjs/modules/Manager.cjs +82 -22
- package/dist/cjs/modules/ProsopoCaptchaApi.cjs +18 -3
- package/dist/errorSites.d.ts +24 -0
- package/dist/errorSites.d.ts.map +1 -0
- package/dist/errorSites.js +2 -0
- package/dist/errorSites.js.map +1 -0
- package/dist/modules/Manager.d.ts.map +1 -1
- package/dist/modules/Manager.js +83 -23
- package/dist/modules/Manager.js.map +1 -1
- package/dist/modules/ProsopoCaptchaApi.d.ts.map +1 -1
- package/dist/modules/ProsopoCaptchaApi.js +19 -4
- package/dist/modules/ProsopoCaptchaApi.js.map +1 -1
- package/dist/tests/manager.unit.test.js +24 -9
- package/dist/tests/manager.unit.test.js.map +1 -1
- package/dist/tests/prosopoCaptchaApi.unit.test.js +10 -5
- package/dist/tests/prosopoCaptchaApi.unit.test.js.map +1 -1
- package/package.json +15 -15
|
@@ -4,11 +4,11 @@ ViteCommonJSConfig: .
|
|
|
4
4
|
tsConfigPaths: [
|
|
5
5
|
'/home/runner/work/captcha/captcha/packages/datasets/tsconfig.json',
|
|
6
6
|
'/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
|
|
7
|
+
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
7
8
|
'/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
|
|
8
9
|
'/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
|
|
9
|
-
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
10
|
-
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
11
10
|
'/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
|
|
11
|
+
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
12
12
|
'/home/runner/work/captcha/captcha/packages/api/tsconfig.json',
|
|
13
13
|
'/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json',
|
|
14
14
|
'/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json',
|
|
@@ -23,11 +23,11 @@ ViteCommonJSConfig: .
|
|
|
23
23
|
externals: [
|
|
24
24
|
'@prosopo/datasets',
|
|
25
25
|
'@prosopo/common',
|
|
26
|
+
'@prosopo/types',
|
|
26
27
|
'@prosopo/locale',
|
|
27
28
|
'@prosopo/util',
|
|
28
|
-
'@prosopo/logger',
|
|
29
|
-
'@prosopo/types',
|
|
30
29
|
'@prosopo/util-crypto',
|
|
30
|
+
'@prosopo/logger',
|
|
31
31
|
'@prosopo/api',
|
|
32
32
|
'@prosopo/load-balancer',
|
|
33
33
|
'@prosopo/procaptcha-common',
|
|
@@ -39,7 +39,7 @@ ViteCommonJSConfig: .
|
|
|
39
39
|
]
|
|
40
40
|
}
|
|
41
41
|
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
42
|
-
[36mvite v8.1.
|
|
42
|
+
[36mvite v8.1.6 [32mbuilding ssr environment for production...[36m[39m
|
|
43
43
|
Bundle build started
|
|
44
44
|
[2K
|
|
45
45
|
✓ 6 modules transformed.
|
|
@@ -48,7 +48,7 @@ computing gzip size...
|
|
|
48
48
|
dist/cjs/modules/index.cjs 0.34 kB │ gzip: 0.13 kB
|
|
49
49
|
dist/cjs/index.cjs 0.44 kB │ gzip: 0.19 kB
|
|
50
50
|
dist/cjs/modules/collector.cjs 1.83 kB │ gzip: 0.59 kB
|
|
51
|
-
dist/cjs/modules/ProsopoCaptchaApi.cjs 2.
|
|
52
|
-
dist/cjs/modules/Manager.cjs
|
|
51
|
+
dist/cjs/modules/ProsopoCaptchaApi.cjs 2.33 kB │ gzip: 0.82 kB
|
|
52
|
+
dist/cjs/modules/Manager.cjs 16.38 kB │ gzip: 4.38 kB
|
|
53
53
|
|
|
54
|
-
[32m✓ built in
|
|
54
|
+
[32m✓ built in 45ms[39m
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
$ tsc --build --verbose
|
|
2
|
-
|
|
2
|
+
7:41:02 PM - Projects in this build:
|
|
3
3
|
* ../../dev/config/tsconfig.json
|
|
4
4
|
* ../util/tsconfig.json
|
|
5
5
|
* ../locale/tsconfig.json
|
|
6
|
-
* ../logger/tsconfig.json
|
|
7
6
|
* ../util-crypto/tsconfig.json
|
|
8
7
|
* ../types/tsconfig.json
|
|
9
8
|
* ../common/tsconfig.json
|
|
9
|
+
* ../logger/tsconfig.json
|
|
10
10
|
* ../datasets/tsconfig.json
|
|
11
11
|
* ../api/tsconfig.json
|
|
12
12
|
* ../load-balancer/tsconfig.json
|
|
@@ -18,39 +18,39 @@ $ tsc --build --verbose
|
|
|
18
18
|
* ../procaptcha-common/tsconfig.json
|
|
19
19
|
* tsconfig.json
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
7:41:02 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'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
7:41:02 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
7:41:02 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/process.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
7:41:02 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
7:41:02 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
7:41:02 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/tests/utils/objectUtils.unit.test.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
7:41:02 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/tests/loggerBrowser.unit.test.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
7:41:02 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/errorSites.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
7:41:02 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
7:41:02 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'
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
7:41:02 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/webComponent/createWidget.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
7:41:02 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
7:41:02 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.test.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
7:41:02 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'
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
7:41:02 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
7:41:02 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'
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
7:41:02 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
7:41:02 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha/tsconfig.json'...
|
|
56
56
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -5,11 +5,11 @@ ViteEsmConfig: .
|
|
|
5
5
|
tsConfigPaths: [
|
|
6
6
|
'/home/runner/work/captcha/captcha/packages/datasets/tsconfig.json',
|
|
7
7
|
'/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
|
|
8
|
+
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
8
9
|
'/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
|
|
9
10
|
'/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
|
|
10
|
-
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
11
|
-
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
12
11
|
'/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
|
|
12
|
+
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
13
13
|
'/home/runner/work/captcha/captcha/packages/api/tsconfig.json',
|
|
14
14
|
'/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json',
|
|
15
15
|
'/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json',
|
|
@@ -20,15 +20,16 @@ ViteEsmConfig: .
|
|
|
20
20
|
'/home/runner/work/captcha/captcha/packages/keyring/tsconfig.json'
|
|
21
21
|
]
|
|
22
22
|
}
|
|
23
|
+
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
23
24
|
{
|
|
24
25
|
externals: [
|
|
25
26
|
'@prosopo/datasets',
|
|
26
27
|
'@prosopo/common',
|
|
28
|
+
'@prosopo/types',
|
|
27
29
|
'@prosopo/locale',
|
|
28
30
|
'@prosopo/util',
|
|
29
|
-
'@prosopo/logger',
|
|
30
|
-
'@prosopo/types',
|
|
31
31
|
'@prosopo/util-crypto',
|
|
32
|
+
'@prosopo/logger',
|
|
32
33
|
'@prosopo/api',
|
|
33
34
|
'@prosopo/load-balancer',
|
|
34
35
|
'@prosopo/procaptcha-common',
|
|
@@ -39,8 +40,7 @@ ViteEsmConfig: .
|
|
|
39
40
|
'@prosopo/keyring'
|
|
40
41
|
]
|
|
41
42
|
}
|
|
42
|
-
[
|
|
43
|
-
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
43
|
+
[36mvite v8.1.6 [32mbuilding ssr environment for production...[36m[39m
|
|
44
44
|
Bundle build started
|
|
45
45
|
[2K
|
|
46
46
|
✓ 6 modules transformed.
|
|
@@ -50,7 +50,7 @@ dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
|
|
|
50
50
|
dist/modules/index.js 0.20 kB │ gzip: 0.11 kB
|
|
51
51
|
dist/index.js 0.27 kB │ gzip: 0.14 kB
|
|
52
52
|
dist/modules/collector.js 1.81 kB │ gzip: 0.59 kB
|
|
53
|
-
dist/modules/ProsopoCaptchaApi.js 2.
|
|
54
|
-
dist/modules/Manager.js
|
|
53
|
+
dist/modules/ProsopoCaptchaApi.js 2.23 kB │ gzip: 0.80 kB
|
|
54
|
+
dist/modules/Manager.js 15.49 kB │ gzip: 4.32 kB
|
|
55
55
|
|
|
56
|
-
[32m✓ built in
|
|
56
|
+
[32m✓ built in 56ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# @prosopo/procaptcha
|
|
2
2
|
|
|
3
|
+
## 2.11.34
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- Updated dependencies [49892fc]
|
|
7
|
+
- @prosopo/locale@3.12.1
|
|
8
|
+
- @prosopo/types@5.17.1
|
|
9
|
+
- @prosopo/api@4.7.5
|
|
10
|
+
- @prosopo/common@3.3.0
|
|
11
|
+
- @prosopo/datasets@3.2.10
|
|
12
|
+
- @prosopo/load-balancer@2.11.14
|
|
13
|
+
- @prosopo/procaptcha-common@2.21.7
|
|
14
|
+
|
|
15
|
+
## 2.11.33
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 46b97b7: Roll up the open Dependabot updates: express 5 (with `@types/express` 5), dotenv 18, undici 8, geolib 4, vitest 5, vite 8.1.6 everywhere, 17 minor and patch bumps (Babel, mongoose, i18next, ip-address, turbo and others), `@angular/router` in the Angular demo, and a GitHub Actions bump.
|
|
19
|
+
|
|
20
|
+
The whole vitest family moves to 5.0.4, including `@vitest/coverage-v8`, because `@vitest/browser-playwright` 5 only works with vitest 5. The `@types/express-serve-static-core` override moves to 5.1.3 to match `@types/express` 5.
|
|
21
|
+
|
|
22
|
+
`@prosopo/dotenv` now loads env files with `quiet: true`. Since dotenv 17, every load prints an "injected env" line to stderr unless told not to.
|
|
23
|
+
- d2148c8: Errors now carry a fixed code and a site instead of a translation key.
|
|
24
|
+
|
|
25
|
+
Every error is a `ProsopoError` with a `code` from one list in
|
|
26
|
+
`@prosopo/common` (`ERROR_CODES`) and an `errorSite` such as `PROV-12`, which
|
|
27
|
+
names the one place it was thrown. Together they make the `errorId`, e.g.
|
|
28
|
+
`SITE_KEY_INVALID:PROV-31`, which the widget shows after the message so a
|
|
29
|
+
screenshot is enough to find the throw.
|
|
30
|
+
|
|
31
|
+
What a client sees:
|
|
32
|
+
|
|
33
|
+
- A public error (bad site key, blocked network, and so on) sends its code,
|
|
34
|
+
English message, data and errorId.
|
|
35
|
+
- Anything else sends only `BACKEND_ERROR:<site>` (or `FRONTEND_ERROR:<site>`
|
|
36
|
+
from the widget) and a status. Internal details never leave the server.
|
|
37
|
+
|
|
38
|
+
The provider no longer translates errors. The widget looks up
|
|
39
|
+
`ERRORS.<CODE>` in its catalogue and falls back to the English message. The
|
|
40
|
+
old error classes (`ProsopoApiError`, `ProsopoEnvError` and the rest), the
|
|
41
|
+
`key`/`messageEn` fields and `localiseErrorMessage` are gone.
|
|
42
|
+
|
|
43
|
+
Other changes in behaviour:
|
|
44
|
+
|
|
45
|
+
- An error with no specific code is a hidden 500.
|
|
46
|
+
- Errors no longer log themselves when they are created. The server logs each
|
|
47
|
+
unhandled one once: 5xx as errors, 4xx at debug.
|
|
48
|
+
- An invalid PoW signature is a 401 instead of a 500.
|
|
49
|
+
- `stringifyBigInts` returns a copy instead of changing its input, so frozen
|
|
50
|
+
error context can be logged.
|
|
51
|
+
- The provider's last hand-written error replies now use the same error body.
|
|
52
|
+
These were the missing-header 401s, the access-policy block, autoBan, the
|
|
53
|
+
metrics 401/403 and the rate limiter. The rate limiter answers with a new
|
|
54
|
+
public `RATE_LIMITED` (429) code.
|
|
55
|
+
- Updated dependencies [46b97b7]
|
|
56
|
+
- Updated dependencies [d2148c8]
|
|
57
|
+
- Updated dependencies [2bcf2fe]
|
|
58
|
+
- @prosopo/api@4.7.4
|
|
59
|
+
- @prosopo/common@3.3.0
|
|
60
|
+
- @prosopo/datasets@3.2.9
|
|
61
|
+
- @prosopo/load-balancer@2.11.13
|
|
62
|
+
- @prosopo/locale@3.12.0
|
|
63
|
+
- @prosopo/procaptcha-common@2.21.6
|
|
64
|
+
- @prosopo/types@5.17.0
|
|
65
|
+
- @prosopo/util@3.3.16
|
|
66
|
+
- @prosopo/util-crypto@13.6.1
|
|
67
|
+
|
|
3
68
|
## 2.11.32
|
|
4
69
|
### Patch Changes
|
|
5
70
|
|
|
@@ -86,10 +86,10 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
|
|
|
86
86
|
if (state.sessionId && state.sessionId === spentSessionId) {
|
|
87
87
|
updateState({
|
|
88
88
|
loading: false,
|
|
89
|
-
error: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
89
|
+
error: (0, _prosopo_common.toPublicError)(new _prosopo_common.ProsopoError({
|
|
90
|
+
code: "NO_SESSION_FOUND",
|
|
91
|
+
errorSite: "PCAP-18"
|
|
92
|
+
}), "FRONTEND_ERROR")
|
|
93
93
|
});
|
|
94
94
|
events.onError(/* @__PURE__ */ new Error("No session found"));
|
|
95
95
|
return;
|
|
@@ -101,14 +101,15 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
|
|
|
101
101
|
if (challenge.error) {
|
|
102
102
|
updateState({
|
|
103
103
|
loading: false,
|
|
104
|
-
error:
|
|
105
|
-
message: challenge.error.message,
|
|
106
|
-
key: challenge.error.key || "API.UNKNOWN_ERROR"
|
|
107
|
-
}
|
|
104
|
+
error: challenge.error
|
|
108
105
|
});
|
|
109
106
|
events.onError(new Error(challenge.error?.message));
|
|
110
107
|
} else {
|
|
111
|
-
if (challenge.captchas.length <= 0) throw new _prosopo_common.
|
|
108
|
+
if (challenge.captchas.length <= 0) throw new _prosopo_common.ProsopoError({
|
|
109
|
+
code: "RECORD_NOT_FOUND",
|
|
110
|
+
errorSite: "PCAP-1",
|
|
111
|
+
message: "No captchas returned from provider"
|
|
112
|
+
});
|
|
112
113
|
const timeMillis = challenge.captchas.map((captcha) => captcha.timeLimitMs || config.captchas.image.challengeTimeout).reduce((a, b) => a + b);
|
|
113
114
|
const timeout = setTimeout(() => {
|
|
114
115
|
if (disposed) return;
|
|
@@ -133,7 +134,12 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
|
|
|
133
134
|
const submit = async () => {
|
|
134
135
|
await (0, _prosopo_procaptcha_common.providerRetry)(async () => {
|
|
135
136
|
clearTimeout();
|
|
136
|
-
if (!state.challenge) throw new _prosopo_common.ProsopoError(
|
|
137
|
+
if (!state.challenge) throw new _prosopo_common.ProsopoError({
|
|
138
|
+
code: "RECORD_NOT_FOUND",
|
|
139
|
+
errorSite: "PCAP-2",
|
|
140
|
+
message: "No captcha found",
|
|
141
|
+
context: { error: "Cannot submit, no Captcha found in state" }
|
|
142
|
+
});
|
|
137
143
|
updateState({ showModal: false });
|
|
138
144
|
const challenge = state.challenge;
|
|
139
145
|
const captchaSolution = state.challenge.captchas.map((captcha, index) => {
|
|
@@ -158,10 +164,25 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
|
|
|
158
164
|
});
|
|
159
165
|
const account = getAccount();
|
|
160
166
|
const signer = getExtension(account).signer;
|
|
161
|
-
if (!(0, _prosopo_util.at)(challenge.captchas, 0).datasetId) throw new _prosopo_common.
|
|
167
|
+
if (!(0, _prosopo_util.at)(challenge.captchas, 0).datasetId) throw new _prosopo_common.ProsopoError({
|
|
168
|
+
code: "INVALID_DATA",
|
|
169
|
+
errorSite: "PCAP-3",
|
|
170
|
+
message: "Invalid captcha id",
|
|
171
|
+
context: { error: "No datasetId set for challenge" }
|
|
172
|
+
});
|
|
162
173
|
const captchaApi = state.captchaApi;
|
|
163
|
-
if (!captchaApi) throw new _prosopo_common.ProsopoError(
|
|
164
|
-
|
|
174
|
+
if (!captchaApi) throw new _prosopo_common.ProsopoError({
|
|
175
|
+
code: "INVALID_REQUEST",
|
|
176
|
+
errorSite: "PCAP-4",
|
|
177
|
+
message: "Invalid token",
|
|
178
|
+
context: { error: "No Captcha API found in state" }
|
|
179
|
+
});
|
|
180
|
+
if (!signer || !signer.signRaw) throw new _prosopo_common.ProsopoError({
|
|
181
|
+
code: "CONFIG_INVALID",
|
|
182
|
+
errorSite: "PCAP-5",
|
|
183
|
+
message: "Can't find the keyringpair for {{address}}",
|
|
184
|
+
context: { error: "Signer is not defined, cannot sign message to prove account ownership" }
|
|
185
|
+
});
|
|
165
186
|
const userTimestampSignature = await signer.signRaw({
|
|
166
187
|
address: account.account.address,
|
|
167
188
|
data: (0, _polkadot_util_string.stringToHex)(challenge[_prosopo_types.ApiParams.timestamp]),
|
|
@@ -235,8 +256,18 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
|
|
|
235
256
|
* @param inputMethod how the image was selected; pointer when not given
|
|
236
257
|
*/
|
|
237
258
|
const select = (hash, x, y, inputMethod = _prosopo_types.InputMethod.pointer) => {
|
|
238
|
-
if (!state.challenge) throw new _prosopo_common.ProsopoError(
|
|
239
|
-
|
|
259
|
+
if (!state.challenge) throw new _prosopo_common.ProsopoError({
|
|
260
|
+
code: "RECORD_NOT_FOUND",
|
|
261
|
+
errorSite: "PCAP-6",
|
|
262
|
+
message: "No captcha found",
|
|
263
|
+
context: { error: "Cannot select, no Captcha found in state" }
|
|
264
|
+
});
|
|
265
|
+
if (state.index >= state.challenge.captchas.length || state.index < 0) throw new _prosopo_common.ProsopoError({
|
|
266
|
+
code: "RECORD_NOT_FOUND",
|
|
267
|
+
errorSite: "PCAP-7",
|
|
268
|
+
message: "No captcha found",
|
|
269
|
+
context: { error: "Cannot select, index is out of range for this Captcha" }
|
|
270
|
+
});
|
|
240
271
|
const index = state.index;
|
|
241
272
|
const solutions = state.solutions;
|
|
242
273
|
const solution = (0, _prosopo_util.at)(solutions, index);
|
|
@@ -253,14 +284,27 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
|
|
|
253
284
|
* Proceed to the next round of the challenge.
|
|
254
285
|
*/
|
|
255
286
|
const nextRound = () => {
|
|
256
|
-
if (!state.challenge) throw new _prosopo_common.ProsopoError(
|
|
257
|
-
|
|
287
|
+
if (!state.challenge) throw new _prosopo_common.ProsopoError({
|
|
288
|
+
code: "RECORD_NOT_FOUND",
|
|
289
|
+
errorSite: "PCAP-8",
|
|
290
|
+
message: "No captcha found",
|
|
291
|
+
context: { error: "Cannot select, no Captcha found in state" }
|
|
292
|
+
});
|
|
293
|
+
if (state.index + 1 >= state.challenge.captchas.length) throw new _prosopo_common.ProsopoError({
|
|
294
|
+
code: "RECORD_NOT_FOUND",
|
|
295
|
+
errorSite: "PCAP-9",
|
|
296
|
+
message: "No captcha found",
|
|
297
|
+
context: { error: "Cannot select, index is out of range for this Captcha" }
|
|
298
|
+
});
|
|
258
299
|
updateState({ index: state.index + 1 });
|
|
259
300
|
};
|
|
260
301
|
const loadProviderApi = async (providerUrl) => {
|
|
261
302
|
const config = getConfig();
|
|
262
303
|
const siteKey = config.account.address;
|
|
263
|
-
if (!siteKey) throw new _prosopo_common.
|
|
304
|
+
if (!siteKey) throw new _prosopo_common.ProsopoError({
|
|
305
|
+
code: "SITE_KEY_MISSING",
|
|
306
|
+
errorSite: "PCAP-10"
|
|
307
|
+
});
|
|
264
308
|
return {
|
|
265
309
|
providerApi: new _prosopo_api.ProviderApi(providerUrl, siteKey, void 0, (0, _prosopo_locale.widgetLanguageHeaders)(config.language)),
|
|
266
310
|
siteKey
|
|
@@ -291,7 +335,11 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
|
|
|
291
335
|
*/
|
|
292
336
|
const loadAccount = async () => {
|
|
293
337
|
const config = getConfig();
|
|
294
|
-
if (!config.web2 && !config.userAccountAddress) throw new _prosopo_common.
|
|
338
|
+
if (!config.web2 && !config.userAccountAddress) throw new _prosopo_common.ProsopoError({
|
|
339
|
+
code: "ACCOUNT_NOT_FOUND",
|
|
340
|
+
errorSite: "PCAP-11",
|
|
341
|
+
context: { error: "Account address has not been set for web3 mode" }
|
|
342
|
+
});
|
|
295
343
|
const selectAccount = async () => {
|
|
296
344
|
const ext = new (await ((0, _prosopo_procaptcha_common.ExtensionLoader)(config.web2)))();
|
|
297
345
|
if (frictionlessState) return frictionlessState.userAccount;
|
|
@@ -302,15 +350,27 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
|
|
|
302
350
|
return getAccount();
|
|
303
351
|
};
|
|
304
352
|
const getAccount = () => {
|
|
305
|
-
if (!state.account) throw new _prosopo_common.
|
|
353
|
+
if (!state.account) throw new _prosopo_common.ProsopoError({
|
|
354
|
+
code: "ACCOUNT_NOT_FOUND",
|
|
355
|
+
errorSite: "PCAP-12",
|
|
356
|
+
context: { error: "Account not loaded" }
|
|
357
|
+
});
|
|
306
358
|
return state.account;
|
|
307
359
|
};
|
|
308
360
|
const getDappAccount = () => {
|
|
309
|
-
if (!state.dappAccount) throw new _prosopo_common.
|
|
361
|
+
if (!state.dappAccount) throw new _prosopo_common.ProsopoError({
|
|
362
|
+
code: "SITE_KEY_MISSING",
|
|
363
|
+
errorSite: "PCAP-13"
|
|
364
|
+
});
|
|
310
365
|
return state.dappAccount;
|
|
311
366
|
};
|
|
312
367
|
const getExtension = (account) => {
|
|
313
|
-
if (!account.extension) throw new _prosopo_common.
|
|
368
|
+
if (!account.extension) throw new _prosopo_common.ProsopoError({
|
|
369
|
+
code: "WALLET_NOT_FOUND",
|
|
370
|
+
errorSite: "PCAP-14",
|
|
371
|
+
message: "Polkadot extension not found",
|
|
372
|
+
context: { error: "Extension not loaded" }
|
|
373
|
+
});
|
|
314
374
|
return account.extension;
|
|
315
375
|
};
|
|
316
376
|
let disposed = false;
|
|
@@ -20,11 +20,21 @@ var ProsopoCaptchaApi = class {
|
|
|
20
20
|
for (const captcha of captchaChallenge.captchas) for (const item of captcha.items) if (item.data) item.data = `https://${item.data.replace(/^http(s)*:\/\//, "")}`;
|
|
21
21
|
return captchaChallenge;
|
|
22
22
|
} catch (error) {
|
|
23
|
-
throw new _prosopo_common.
|
|
23
|
+
throw new _prosopo_common.ProsopoError({
|
|
24
|
+
code: "INVALID_DATA",
|
|
25
|
+
errorSite: "PCAP-15",
|
|
26
|
+
message: "Invalid captcha challenge",
|
|
27
|
+
cause: error
|
|
28
|
+
});
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
async submitCaptchaSolution(userTimestampSignature, requestHash, solutions, timestamp, providerRequestHashSignature, behavioralData, simdReadings, clientMetaData) {
|
|
27
|
-
if (solutions.length === 0) throw new _prosopo_common.
|
|
32
|
+
if (solutions.length === 0) throw new _prosopo_common.ProsopoError({
|
|
33
|
+
code: "INVALID_DATA",
|
|
34
|
+
errorSite: "PCAP-16",
|
|
35
|
+
message: "Invalid captcha challenge",
|
|
36
|
+
context: { error: "No captcha solutions to commit to" }
|
|
37
|
+
});
|
|
28
38
|
const tree = new _prosopo_datasets.CaptchaMerkleTree();
|
|
29
39
|
const captchasHashed = solutions.map((captcha) => (0, _prosopo_datasets.computeCaptchaSolutionHash)(captcha));
|
|
30
40
|
tree.build(captchasHashed);
|
|
@@ -33,7 +43,12 @@ var ProsopoCaptchaApi = class {
|
|
|
33
43
|
try {
|
|
34
44
|
result = await this.providerApi.submitCaptchaSolution(solutions, requestHash, this.userAccount, timestamp, providerRequestHashSignature, userTimestampSignature, behavioralData, simdReadings, clientMetaData);
|
|
35
45
|
} catch (error) {
|
|
36
|
-
throw new _prosopo_common.
|
|
46
|
+
throw new _prosopo_common.ProsopoError({
|
|
47
|
+
code: "INVALID_DATA",
|
|
48
|
+
errorSite: "PCAP-17",
|
|
49
|
+
message: "Invalid captcha challenge",
|
|
50
|
+
cause: error
|
|
51
|
+
});
|
|
37
52
|
}
|
|
38
53
|
return [result, commitmentId];
|
|
39
54
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare module "@prosopo/common" {
|
|
2
|
+
interface ErrorSites {
|
|
3
|
+
"PCAP-1": true;
|
|
4
|
+
"PCAP-2": true;
|
|
5
|
+
"PCAP-3": true;
|
|
6
|
+
"PCAP-4": true;
|
|
7
|
+
"PCAP-5": true;
|
|
8
|
+
"PCAP-6": true;
|
|
9
|
+
"PCAP-7": true;
|
|
10
|
+
"PCAP-8": true;
|
|
11
|
+
"PCAP-9": true;
|
|
12
|
+
"PCAP-10": true;
|
|
13
|
+
"PCAP-11": true;
|
|
14
|
+
"PCAP-12": true;
|
|
15
|
+
"PCAP-13": true;
|
|
16
|
+
"PCAP-14": true;
|
|
17
|
+
"PCAP-15": true;
|
|
18
|
+
"PCAP-16": true;
|
|
19
|
+
"PCAP-17": true;
|
|
20
|
+
"PCAP-18": true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=errorSites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorSites.d.ts","sourceRoot":"","sources":["../src/errorSites.ts"],"names":[],"mappings":"AAcA,OAAO,QAAQ,iBAAiB,CAAC;IAChC,UAAU,UAAU;QACnB,QAAQ,EAAE,IAAI,CAAC;QACf,QAAQ,EAAE,IAAI,CAAC;QACf,QAAQ,EAAE,IAAI,CAAC;QACf,QAAQ,EAAE,IAAI,CAAC;QACf,QAAQ,EAAE,IAAI,CAAC;QACf,QAAQ,EAAE,IAAI,CAAC;QACf,QAAQ,EAAE,IAAI,CAAC;QACf,QAAQ,EAAE,IAAI,CAAC;QACf,QAAQ,EAAE,IAAI,CAAC;QACf,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;KAChB;CACD;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorSites.js","sourceRoot":"","sources":["../src/errorSites.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/modules/Manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/modules/Manager.ts"],"names":[],"mappings":"AA4BA,OAAO,EAMN,KAAK,iBAAiB,EACtB,WAAW,EACX,KAAK,mBAAmB,EAExB,KAAK,4BAA4B,EAEjC,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAG5B,MAAM,gBAAgB,CAAC;AAwBxB,wBAAgB,OAAO,CACtB,cAAc,EAAE,4BAA4B,EAC5C,KAAK,EAAE,eAAe,EACtB,aAAa,EAAE,uBAAuB,EACtC,SAAS,EAAE,mBAAmB,EAC9B,iBAAiB,CAAC,EAAE,iBAAiB,EAGrC,gBAAgB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,EAM3C,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI;kEAiDpC,WAAW;;;mBAmZlB,MAAM,MACR,MAAM,MACN,MAAM,gBACG,WAAW;;;;EAmNzB"}
|