@prosopo/procaptcha 2.11.31 → 2.11.33

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.
@@ -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
  The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
42
- vite v8.1.5 building ssr environment for production...
42
+ vite v8.1.6 building ssr environment for production...
43
43
  Bundle build started
44
44
  
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.17 kB │ gzip: 0.78 kB
52
- dist/cjs/modules/Manager.cjs 15.58 kB │ gzip: 4.29 kB
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
- ✓ built in 44ms
54
+ ✓ built in 68ms
@@ -1,12 +1,12 @@
1
1
  $ tsc --build --verbose
2
- 10:01:52 AM - Projects in this build:
2
+ 5:08:19 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
- 10:01:52 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'
21
+ 5:08:19 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
- 10:01:52 AM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
23
+ 5:08:19 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
- 10:01:52 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/process.ts' is older than output '../locale/tsconfig.tsbuildinfo'
25
+ 5:08:19 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
26
26
 
27
- 10:01:52 AM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
27
+ 5:08:19 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
- 10:01:52 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'
29
+ 5:08:19 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
- 10:01:52 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'
31
+ 5:08:19 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/errorCodes.ts' is older than output '../common/tsconfig.tsbuildinfo'
32
32
 
33
- 10:01:52 AM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
33
+ 5:08:19 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
34
34
 
35
- 10:01:52 AM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/tests/captcha.unit.test.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
35
+ 5:08:19 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
- 10:01:52 AM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
37
+ 5:08:19 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
- 10:01:52 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'
39
+ 5:08:19 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'
40
40
 
41
- 10:01:52 AM - 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'
41
+ 5:08:19 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'
42
42
 
43
- 10:01:52 AM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
43
+ 5:08:19 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
- 10:01:52 AM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
45
+ 5:08:19 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
- 10:01:52 AM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/keyring/keyring.test.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
47
+ 5:08:19 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
- 10:01:52 AM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
49
+ 5:08:19 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/workers/cryptoWorker.ts' is older than output '../account/tsconfig.tsbuildinfo'
50
50
 
51
- 10:01:52 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'
51
+ 5:08:19 PM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/tests/reload.unit.test.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
52
52
 
53
- 10:01:52 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
53
+ 5:08:19 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
54
54
 
55
- 10:01:52 AM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha/tsconfig.json'...
55
+ 5:08:19 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha/tsconfig.json'...
56
56
 
@@ -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',
@@ -24,11 +24,11 @@ ViteEsmConfig: .
24
24
  externals: [
25
25
  '@prosopo/datasets',
26
26
  '@prosopo/common',
27
+ '@prosopo/types',
27
28
  '@prosopo/locale',
28
29
  '@prosopo/util',
29
- '@prosopo/logger',
30
- '@prosopo/types',
31
30
  '@prosopo/util-crypto',
31
+ '@prosopo/logger',
32
32
  '@prosopo/api',
33
33
  '@prosopo/load-balancer',
34
34
  '@prosopo/procaptcha-common',
@@ -40,7 +40,7 @@ ViteEsmConfig: .
40
40
  ]
41
41
  }
42
42
  The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
43
- vite v8.1.5 building ssr environment for production...
43
+ vite v8.1.6 building ssr environment for production...
44
44
  Bundle build started
45
45
  
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.09 kB │ gzip: 0.78 kB
54
- dist/modules/Manager.js 14.75 kB │ gzip: 4.24 kB
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
- ✓ built in 46ms
56
+ ✓ built in 62ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,72 @@
1
1
  # @prosopo/procaptcha
2
2
 
3
+ ## 2.11.33
4
+ ### Patch Changes
5
+
6
+ - 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.
7
+
8
+ 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.
9
+
10
+ `@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.
11
+ - d2148c8: Errors now carry a fixed code and a site instead of a translation key.
12
+
13
+ Every error is a `ProsopoError` with a `code` from one list in
14
+ `@prosopo/common` (`ERROR_CODES`) and an `errorSite` such as `PROV-12`, which
15
+ names the one place it was thrown. Together they make the `errorId`, e.g.
16
+ `SITE_KEY_INVALID:PROV-31`, which the widget shows after the message so a
17
+ screenshot is enough to find the throw.
18
+
19
+ What a client sees:
20
+
21
+ - A public error (bad site key, blocked network, and so on) sends its code,
22
+ English message, data and errorId.
23
+ - Anything else sends only `BACKEND_ERROR:<site>` (or `FRONTEND_ERROR:<site>`
24
+ from the widget) and a status. Internal details never leave the server.
25
+
26
+ The provider no longer translates errors. The widget looks up
27
+ `ERRORS.<CODE>` in its catalogue and falls back to the English message. The
28
+ old error classes (`ProsopoApiError`, `ProsopoEnvError` and the rest), the
29
+ `key`/`messageEn` fields and `localiseErrorMessage` are gone.
30
+
31
+ Other changes in behaviour:
32
+
33
+ - An error with no specific code is a hidden 500.
34
+ - Errors no longer log themselves when they are created. The server logs each
35
+ unhandled one once: 5xx as errors, 4xx at debug.
36
+ - An invalid PoW signature is a 401 instead of a 500.
37
+ - `stringifyBigInts` returns a copy instead of changing its input, so frozen
38
+ error context can be logged.
39
+ - The provider's last hand-written error replies now use the same error body.
40
+ These were the missing-header 401s, the access-policy block, autoBan, the
41
+ metrics 401/403 and the rate limiter. The rate limiter answers with a new
42
+ public `RATE_LIMITED` (429) code.
43
+ - Updated dependencies [46b97b7]
44
+ - Updated dependencies [d2148c8]
45
+ - Updated dependencies [2bcf2fe]
46
+ - @prosopo/api@4.7.4
47
+ - @prosopo/common@3.3.0
48
+ - @prosopo/datasets@3.2.9
49
+ - @prosopo/load-balancer@2.11.13
50
+ - @prosopo/locale@3.12.0
51
+ - @prosopo/procaptcha-common@2.21.6
52
+ - @prosopo/types@5.17.0
53
+ - @prosopo/util@3.3.16
54
+ - @prosopo/util-crypto@13.6.1
55
+
56
+ ## 2.11.32
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [b6e9459]
60
+ - @prosopo/locale@3.11.1
61
+ - @prosopo/common@3.2.3
62
+ - @prosopo/types@5.16.3
63
+ - @prosopo/procaptcha-common@2.21.5
64
+ - @prosopo/api@4.7.3
65
+ - @prosopo/datasets@3.2.8
66
+ - @prosopo/load-balancer@2.11.12
67
+ - @prosopo/util@3.3.15
68
+ - @prosopo/util-crypto@13.6.0
69
+
3
70
  ## 2.11.31
4
71
  ### Patch Changes
5
72
 
@@ -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
- message: "No session found",
91
- key: "CAPTCHA.NO_SESSION_FOUND"
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.ProsopoDatasetError("DEVELOPER.PROVIDER_NO_CAPTCHA");
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("CAPTCHA.NO_CAPTCHA", { context: { error: "Cannot submit, no Captcha found in state" } });
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.ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_ID", { context: { error: "No datasetId set for challenge" } });
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("CAPTCHA.INVALID_TOKEN", { context: { error: "No Captcha API found in state" } });
164
- if (!signer || !signer.signRaw) throw new _prosopo_common.ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", { context: { error: "Signer is not defined, cannot sign message to prove account ownership" } });
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("CAPTCHA.NO_CAPTCHA", { context: { error: "Cannot select, no Captcha found in state" } });
239
- if (state.index >= state.challenge.captchas.length || state.index < 0) throw new _prosopo_common.ProsopoError("CAPTCHA.NO_CAPTCHA", { context: { error: "Cannot select, index is out of range for this Captcha" } });
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("CAPTCHA.NO_CAPTCHA", { context: { error: "Cannot select, no Captcha found in state" } });
257
- if (state.index + 1 >= state.challenge.captchas.length) throw new _prosopo_common.ProsopoError("CAPTCHA.NO_CAPTCHA", { context: { error: "Cannot select, index is out of range for this Captcha" } });
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.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
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.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account address has not been set for web3 mode" } });
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.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
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.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
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.ProsopoEnvError("ACCOUNT.NO_POLKADOT_EXTENSION", { context: { error: "Extension not loaded" } });
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.ProsopoEnvError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error } });
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.ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error: "No captcha solutions to commit to" } });
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.ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error } });
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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=errorSites.js.map
@@ -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":"AAgCA,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;;;mBAmYlB,MAAM,MACR,MAAM,MACN,MAAM,gBACG,WAAW;;;;EA0LzB"}
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"}