@prosopo/procaptcha 2.7.18 → 2.9.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,316 @@
1
1
  # @prosopo/procaptcha
2
2
 
3
+ ## 2.9.5
4
+ ### Patch Changes
5
+
6
+ - Updated dependencies [1e3a838]
7
+ - @prosopo/config@3.1.20
8
+ - @prosopo/procaptcha-common@2.9.5
9
+ - @prosopo/api@3.1.24
10
+ - @prosopo/common@3.1.20
11
+ - @prosopo/datasets@3.0.34
12
+ - @prosopo/types@3.5.3
13
+ - @prosopo/util@3.1.5
14
+ - @prosopo/util-crypto@13.5.22
15
+
16
+ ## 2.9.4
17
+ ### Patch Changes
18
+
19
+ - 5659b24: Release 3.4.4
20
+ - Updated dependencies [f912439]
21
+ - Updated dependencies [5659b24]
22
+ - @prosopo/common@3.1.19
23
+ - @prosopo/procaptcha-common@2.9.4
24
+ - @prosopo/util-crypto@13.5.21
25
+ - @prosopo/datasets@3.0.33
26
+ - @prosopo/types@3.5.2
27
+ - @prosopo/util@3.1.4
28
+ - @prosopo/api@3.1.23
29
+ - @prosopo/config@3.1.19
30
+
31
+ ## 2.9.3
32
+ ### Patch Changes
33
+
34
+ - 50c4120: Release 3.4.3
35
+ - Updated dependencies [52cd544]
36
+ - Updated dependencies [b117ba3]
37
+ - Updated dependencies [50c4120]
38
+ - @prosopo/types@3.5.1
39
+ - @prosopo/procaptcha-common@2.9.3
40
+ - @prosopo/util-crypto@13.5.20
41
+ - @prosopo/datasets@3.0.32
42
+ - @prosopo/common@3.1.18
43
+ - @prosopo/util@3.1.3
44
+ - @prosopo/api@3.1.22
45
+ - @prosopo/config@3.1.18
46
+
47
+ ## 2.9.2
48
+ ### Patch Changes
49
+
50
+ - 618703f: Release 3.4.2
51
+ - Updated dependencies [618703f]
52
+ - Updated dependencies [e20ad6b]
53
+ - @prosopo/procaptcha-common@2.9.2
54
+ - @prosopo/util-crypto@13.5.19
55
+ - @prosopo/datasets@3.0.31
56
+ - @prosopo/common@3.1.17
57
+ - @prosopo/types@3.5.0
58
+ - @prosopo/util@3.1.2
59
+ - @prosopo/api@3.1.21
60
+ - @prosopo/config@3.1.17
61
+
62
+ ## 2.9.1
63
+ ### Patch Changes
64
+
65
+ - 11303d9: Release 3.4.0
66
+ - 18cb28b: Release 3.4.1
67
+ - Updated dependencies [11303d9]
68
+ - Updated dependencies [18cb28b]
69
+ - Updated dependencies [11303d9]
70
+ - @prosopo/procaptcha-common@2.9.1
71
+ - @prosopo/util-crypto@13.5.18
72
+ - @prosopo/datasets@3.0.30
73
+ - @prosopo/common@3.1.16
74
+ - @prosopo/types@3.4.1
75
+ - @prosopo/util@3.1.1
76
+ - @prosopo/api@3.1.20
77
+ - @prosopo/config@3.1.16
78
+
79
+ ## 2.9.0
80
+ ### Minor Changes
81
+
82
+ - 6768f14: Update salt
83
+
84
+ ### Patch Changes
85
+
86
+ - f3f7aec: Release 3.4.0
87
+ - Updated dependencies [f3f7aec]
88
+ - Updated dependencies [6768f14]
89
+ - @prosopo/procaptcha-common@2.9.0
90
+ - @prosopo/util-crypto@13.5.17
91
+ - @prosopo/datasets@3.0.29
92
+ - @prosopo/common@3.1.15
93
+ - @prosopo/types@3.4.0
94
+ - @prosopo/util@3.1.0
95
+ - @prosopo/api@3.1.19
96
+ - @prosopo/config@3.1.15
97
+
98
+ ## 2.8.7
99
+ ### Patch Changes
100
+
101
+ - Release 3.3.1
102
+ - 0824221: Release 3.2.4
103
+ - 72810f4: Fix TypeScript type checking by reordering project references and updating typecheck commands
104
+ - Updated dependencies [97edf3f]
105
+ - Updated dependencies
106
+ - Updated dependencies [0824221]
107
+ - @prosopo/types@3.3.0
108
+ - @prosopo/procaptcha-common@2.8.7
109
+ - @prosopo/util-crypto@13.5.16
110
+ - @prosopo/datasets@3.0.28
111
+ - @prosopo/common@3.1.14
112
+ - @prosopo/util@3.0.17
113
+ - @prosopo/api@3.1.18
114
+ - @prosopo/config@3.1.14
115
+
116
+ ## 2.8.6
117
+ ### Patch Changes
118
+
119
+ - 008d112: Release 3.3.0
120
+ - Updated dependencies [509be28]
121
+ - Updated dependencies [008d112]
122
+ - @prosopo/types@3.2.1
123
+ - @prosopo/procaptcha-common@2.8.6
124
+ - @prosopo/util-crypto@13.5.15
125
+ - @prosopo/datasets@3.0.27
126
+ - @prosopo/common@3.1.13
127
+ - @prosopo/util@3.0.16
128
+ - @prosopo/api@3.1.17
129
+ - @prosopo/config@3.1.13
130
+
131
+ ## 2.8.5
132
+ ### Patch Changes
133
+
134
+ - 0824221: Release 3.2.4
135
+ - 72810f4: Fix TypeScript type checking by reordering project references and updating typecheck commands
136
+ - Updated dependencies [cf48565]
137
+ - Updated dependencies [0824221]
138
+ - @prosopo/types@3.2.0
139
+ - @prosopo/procaptcha-common@2.8.5
140
+ - @prosopo/util-crypto@13.5.14
141
+ - @prosopo/datasets@3.0.26
142
+ - @prosopo/common@3.1.12
143
+ - @prosopo/util@3.0.15
144
+ - @prosopo/api@3.1.16
145
+ - @prosopo/config@3.1.12
146
+
147
+ ## 2.8.4
148
+ ### Patch Changes
149
+
150
+ - 1a23649: Release 3.2.3
151
+ - Updated dependencies [0d1a33e]
152
+ - Updated dependencies [0d1a33e]
153
+ - Updated dependencies [1a23649]
154
+ - @prosopo/types@3.1.4
155
+ - @prosopo/procaptcha-common@2.8.4
156
+ - @prosopo/util-crypto@13.5.13
157
+ - @prosopo/datasets@3.0.25
158
+ - @prosopo/common@3.1.11
159
+ - @prosopo/util@3.0.14
160
+ - @prosopo/api@3.1.15
161
+ - @prosopo/config@3.1.11
162
+
163
+ ## 2.8.3
164
+ ### Patch Changes
165
+
166
+ - 657a827: Release 3.2.2
167
+ - Updated dependencies [36b23e0]
168
+ - Updated dependencies [657a827]
169
+ - @prosopo/api@3.1.14
170
+ - @prosopo/procaptcha-common@2.8.3
171
+ - @prosopo/util-crypto@13.5.12
172
+ - @prosopo/datasets@3.0.24
173
+ - @prosopo/common@3.1.10
174
+ - @prosopo/types@3.1.3
175
+ - @prosopo/util@3.0.13
176
+ - @prosopo/config@3.1.10
177
+
178
+ ## 2.8.2
179
+ ### Patch Changes
180
+
181
+ - 4440947: fix type-only tsc compilation
182
+ - 7bdaca6: Release 3.2.1
183
+ - Updated dependencies [4440947]
184
+ - Updated dependencies [7bdaca6]
185
+ - Updated dependencies [809b984]
186
+ - Updated dependencies [1249ce0]
187
+ - Updated dependencies [809b984]
188
+ - @prosopo/procaptcha-common@2.8.2
189
+ - @prosopo/util-crypto@13.5.11
190
+ - @prosopo/datasets@3.0.23
191
+ - @prosopo/common@3.1.9
192
+ - @prosopo/types@3.1.2
193
+ - @prosopo/util@3.0.12
194
+ - @prosopo/api@3.1.13
195
+ - @prosopo/config@3.1.9
196
+
197
+ ## 2.8.1
198
+ ### Patch Changes
199
+
200
+ - 6fe8570: Release 3.2.0
201
+ - Updated dependencies [1f980c4]
202
+ - Updated dependencies [6fe8570]
203
+ - @prosopo/types@3.1.1
204
+ - @prosopo/procaptcha-common@2.8.1
205
+ - @prosopo/util-crypto@13.5.10
206
+ - @prosopo/datasets@3.0.22
207
+ - @prosopo/common@3.1.8
208
+ - @prosopo/util@3.0.11
209
+ - @prosopo/api@3.1.12
210
+ - @prosopo/config@3.1.8
211
+
212
+ ## 2.8.0
213
+ ### Minor Changes
214
+
215
+ - 8bdc7f0: Using detector to select provider
216
+
217
+ ### Patch Changes
218
+
219
+ - f304be9: Release 3.1.13
220
+ - Updated dependencies [f304be9]
221
+ - Updated dependencies [8bdc7f0]
222
+ - @prosopo/procaptcha-common@2.8.0
223
+ - @prosopo/util-crypto@13.5.9
224
+ - @prosopo/datasets@3.0.21
225
+ - @prosopo/common@3.1.7
226
+ - @prosopo/types@3.1.0
227
+ - @prosopo/util@3.0.10
228
+ - @prosopo/api@3.1.11
229
+ - @prosopo/config@3.1.7
230
+
231
+ ## 2.7.25
232
+ ### Patch Changes
233
+
234
+ - a07db04: Release 3.1.12
235
+ - Updated dependencies [9eed772]
236
+ - Updated dependencies [a07db04]
237
+ - Updated dependencies [ebb0168]
238
+ - @prosopo/datasets@3.0.20
239
+ - @prosopo/config@3.1.6
240
+ - @prosopo/api@3.1.10
241
+ - @prosopo/util@3.0.9
242
+ - @prosopo/common@3.1.6
243
+ - @prosopo/procaptcha-common@2.7.18
244
+ - @prosopo/types@3.0.10
245
+ - @prosopo/util-crypto@13.5.8
246
+
247
+ ## 2.7.24
248
+ ### Patch Changes
249
+
250
+ - @prosopo/api@3.1.9
251
+ - @prosopo/datasets@3.0.19
252
+
253
+ ## 2.7.23
254
+ ### Patch Changes
255
+
256
+ - 6960643: lint detect missing and unneccessary imports
257
+ - Updated dependencies [6960643]
258
+ - @prosopo/procaptcha-common@2.7.17
259
+ - @prosopo/util-crypto@13.5.7
260
+ - @prosopo/datasets@3.0.18
261
+ - @prosopo/common@3.1.5
262
+ - @prosopo/types@3.0.9
263
+ - @prosopo/util@3.0.8
264
+ - @prosopo/api@3.1.8
265
+
266
+ ## 2.7.22
267
+ ### Patch Changes
268
+
269
+ - Updated dependencies [30e7d4d]
270
+ - @prosopo/procaptcha-common@2.7.16
271
+ - @prosopo/datasets@3.0.17
272
+ - @prosopo/config@3.1.5
273
+ - @prosopo/account@2.7.14
274
+ - @prosopo/api@3.1.7
275
+ - @prosopo/common@3.1.4
276
+ - @prosopo/load-balancer@2.6.19
277
+ - @prosopo/types@3.0.8
278
+ - @prosopo/util@3.0.7
279
+ - @prosopo/util-crypto@13.5.6
280
+
281
+ ## 2.7.21
282
+ ### Patch Changes
283
+
284
+ - 1f3a02f: Release 3.1.8
285
+ - Updated dependencies [1f3a02f]
286
+ - @prosopo/procaptcha-common@2.7.15
287
+ - @prosopo/datasets@3.0.16
288
+ - @prosopo/api@3.1.6
289
+
290
+ ## 2.7.20
291
+ ### Patch Changes
292
+
293
+ - Updated dependencies [926df8a]
294
+ - @prosopo/procaptcha-common@2.7.14
295
+ - @prosopo/datasets@3.0.15
296
+ - @prosopo/api@3.1.5
297
+
298
+ ## 2.7.19
299
+ ### Patch Changes
300
+
301
+ - Updated dependencies [44ffda2]
302
+ - Updated dependencies [a49b538]
303
+ - @prosopo/config@3.1.4
304
+ - @prosopo/common@3.1.3
305
+ - @prosopo/account@2.7.13
306
+ - @prosopo/api@3.1.4
307
+ - @prosopo/datasets@3.0.14
308
+ - @prosopo/load-balancer@2.6.18
309
+ - @prosopo/procaptcha-common@2.7.13
310
+ - @prosopo/types@3.0.7
311
+ - @prosopo/util@3.0.6
312
+ - @prosopo/util-crypto@13.5.5
313
+
3
314
  ## 2.7.18
4
315
  ### Patch Changes
5
316
 
@@ -58,8 +58,8 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
58
58
  const account = await loadAccount();
59
59
  let captchaApi = state.captchaApi;
60
60
  if (!frictionlessState?.provider) {
61
- const getRandomProviderResponse = await procaptchaCommon.getRandomActiveProvider(
62
- getConfig()
61
+ const getRandomProviderResponse = await procaptchaCommon.getProcaptchaRandomActiveProvider(
62
+ getConfig().defaultEnvironment
63
63
  );
64
64
  const providerUrl = getRandomProviderResponse.provider.url;
65
65
  const providerApi = await loadProviderApi(providerUrl);
@@ -133,15 +133,19 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
133
133
  }
134
134
  updateState({ showModal: false });
135
135
  const challenge = state.challenge;
136
- const salt = utilCrypto.randomAsHex();
137
136
  const captchaSolution = state.challenge.captchas.map(
138
137
  (captcha, index) => {
139
138
  const solution = util.at(state.solutions, index);
139
+ const coords = solution.flatMap(([_, x, y]) => [x, y]);
140
+ const salt = utilCrypto.randomAsHex(
141
+ coords.map((x) => x.toString(16).length + 4).reduce((acc, curr) => acc + curr, 0)
142
+ );
143
+ const saltCoord = util.embedData(salt, coords);
140
144
  return {
141
145
  captchaId: captcha.captchaId,
142
146
  captchaContentId: captcha.captchaContentId,
143
- salt,
144
- solution
147
+ salt: saltCoord,
148
+ solution: solution.flatMap((s) => s[0])
145
149
  };
146
150
  }
147
151
  );
@@ -228,7 +232,7 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
228
232
  await start();
229
233
  }
230
234
  };
231
- const select = (hash) => {
235
+ const select = (hash, x, y) => {
232
236
  if (!state.challenge) {
233
237
  throw new common.ProsopoError("CAPTCHA.NO_CAPTCHA", {
234
238
  context: { error: "Cannot select, no Captcha found in state" }
@@ -244,10 +248,11 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
244
248
  const index = state.index;
245
249
  const solutions = state.solutions;
246
250
  const solution = util.at(solutions, index);
247
- if (solution.includes(hash)) {
248
- solution.splice(solution.indexOf(hash), 1);
251
+ if (solution.some((s) => s[0] === hash)) {
252
+ const newSolution = solution.filter((s) => s[0] !== hash);
253
+ solutions[index] = newSolution;
249
254
  } else {
250
- solution.push(hash);
255
+ solutions[index] = [...solution, [hash, x || 0, y || 0]];
251
256
  }
252
257
  updateState({ solutions });
253
258
  };
@@ -1,9 +1,9 @@
1
1
  import { stringToHex } from "@polkadot/util/string";
2
2
  import { ProviderApi } from "@prosopo/api";
3
3
  import { ProsopoDatasetError, ProsopoError, ProsopoEnvError } from "@prosopo/common";
4
- import { getDefaultEvents, buildUpdateState, providerRetry, getRandomActiveProvider, ExtensionLoader } from "@prosopo/procaptcha-common";
4
+ import { getDefaultEvents, buildUpdateState, providerRetry, getProcaptchaRandomActiveProvider, ExtensionLoader } from "@prosopo/procaptcha-common";
5
5
  import { ProcaptchaConfigSchema, ApiParams, encodeProcaptchaOutput } from "@prosopo/types";
6
- import { sleep, at, hashToHex } from "@prosopo/util";
6
+ import { sleep, at, embedData, hashToHex } from "@prosopo/util";
7
7
  import { randomAsHex } from "@prosopo/util-crypto";
8
8
  import { ProsopoCaptchaApi } from "./ProsopoCaptchaApi.js";
9
9
  const defaultState = () => {
@@ -56,8 +56,8 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
56
56
  const account = await loadAccount();
57
57
  let captchaApi = state.captchaApi;
58
58
  if (!frictionlessState?.provider) {
59
- const getRandomProviderResponse = await getRandomActiveProvider(
60
- getConfig()
59
+ const getRandomProviderResponse = await getProcaptchaRandomActiveProvider(
60
+ getConfig().defaultEnvironment
61
61
  );
62
62
  const providerUrl = getRandomProviderResponse.provider.url;
63
63
  const providerApi = await loadProviderApi(providerUrl);
@@ -131,15 +131,19 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
131
131
  }
132
132
  updateState({ showModal: false });
133
133
  const challenge = state.challenge;
134
- const salt = randomAsHex();
135
134
  const captchaSolution = state.challenge.captchas.map(
136
135
  (captcha, index) => {
137
136
  const solution = at(state.solutions, index);
137
+ const coords = solution.flatMap(([_, x, y]) => [x, y]);
138
+ const salt = randomAsHex(
139
+ coords.map((x) => x.toString(16).length + 4).reduce((acc, curr) => acc + curr, 0)
140
+ );
141
+ const saltCoord = embedData(salt, coords);
138
142
  return {
139
143
  captchaId: captcha.captchaId,
140
144
  captchaContentId: captcha.captchaContentId,
141
- salt,
142
- solution
145
+ salt: saltCoord,
146
+ solution: solution.flatMap((s) => s[0])
143
147
  };
144
148
  }
145
149
  );
@@ -226,7 +230,7 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
226
230
  await start();
227
231
  }
228
232
  };
229
- const select = (hash) => {
233
+ const select = (hash, x, y) => {
230
234
  if (!state.challenge) {
231
235
  throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
232
236
  context: { error: "Cannot select, no Captcha found in state" }
@@ -242,10 +246,11 @@ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessSt
242
246
  const index = state.index;
243
247
  const solutions = state.solutions;
244
248
  const solution = at(solutions, index);
245
- if (solution.includes(hash)) {
246
- solution.splice(solution.indexOf(hash), 1);
249
+ if (solution.some((s) => s[0] === hash)) {
250
+ const newSolution = solution.filter((s) => s[0] !== hash);
251
+ solutions[index] = newSolution;
247
252
  } else {
248
- solution.push(hash);
253
+ solutions[index] = [...solution, [hash, x || 0, y || 0]];
249
254
  }
250
255
  updateState({ solutions });
251
256
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha",
3
- "version": "2.7.18",
3
+ "version": "2.9.5",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "build": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
16
16
  "build:tsc": "tsc --build --verbose",
17
17
  "build:cjs": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
18
- "typecheck": "tsc --build --declaration --emitDeclarationOnly"
18
+ "typecheck": "tsc --project tsconfig.types.json"
19
19
  },
20
20
  "exports": {
21
21
  ".": {
@@ -32,23 +32,14 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@polkadot/util": "12.6.2",
35
- "@prosopo/account": "2.7.12",
36
- "@prosopo/api": "3.1.3",
37
- "@prosopo/common": "3.1.2",
38
- "@prosopo/datasets": "3.0.13",
39
- "@prosopo/load-balancer": "2.6.17",
40
- "@prosopo/procaptcha-common": "2.7.12",
41
- "@prosopo/types": "3.0.6",
42
- "@prosopo/util": "3.0.5",
43
- "@prosopo/util-crypto": "13.5.4",
44
- "@typegoose/auto-increment": "4.13.0",
45
- "axios": "1.10.0",
46
- "esbuild": "0.25.6",
47
- "express": "4.21.2",
48
- "jsdom": "25.0.0",
49
- "@prosopo/config": "3.1.3",
50
- "openpgp": "5.11.3",
51
- "webpack-dev-server": "5.2.2"
35
+ "@prosopo/api": "3.1.24",
36
+ "@prosopo/common": "3.1.20",
37
+ "@prosopo/config": "3.1.20",
38
+ "@prosopo/datasets": "3.0.34",
39
+ "@prosopo/procaptcha-common": "2.9.5",
40
+ "@prosopo/types": "3.5.3",
41
+ "@prosopo/util": "3.1.5",
42
+ "@prosopo/util-crypto": "13.5.22"
52
43
  },
53
44
  "overrides": {
54
45
  "@polkadot/extension-inject": {
@@ -63,6 +54,7 @@
63
54
  }
64
55
  },
65
56
  "devDependencies": {
57
+ "@types/node": "22.10.2",
66
58
  "@vitest/coverage-v8": "3.0.9",
67
59
  "concurrently": "9.0.1",
68
60
  "del-cli": "6.0.0",