@prosopo/api 3.1.37 → 3.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  const types = require("@prosopo/types");
3
3
  const apiClient = require("./apiClient.cjs");
4
4
  class ProviderApi extends apiClient.ApiClient {
5
- getCaptchaChallenge(userAccount, randomProvider, sessionId) {
5
+ getCaptchaChallenge(userAccount, randomProvider, sessionId, simdReadings) {
6
6
  const { provider } = randomProvider;
7
7
  const dappAccount = this.account;
8
8
  const body = {
@@ -13,6 +13,9 @@ class ProviderApi extends apiClient.ApiClient {
13
13
  if (sessionId) {
14
14
  body[types.ApiParams.sessionId] = sessionId;
15
15
  }
16
+ if (simdReadings) {
17
+ body[types.ApiParams.simdReadings] = simdReadings;
18
+ }
16
19
  return this.post(types.ClientApiPaths.GetImageCaptchaChallenge, body, {
17
20
  headers: {
18
21
  "Prosopo-Site-Key": this.account,
@@ -20,7 +23,7 @@ class ProviderApi extends apiClient.ApiClient {
20
23
  }
21
24
  });
22
25
  }
23
- submitCaptchaSolution(captchas, requestHash, userAccount, timestamp, providerRequestHashSignature, userTimestampSignature) {
26
+ submitCaptchaSolution(captchas, requestHash, userAccount, timestamp, providerRequestHashSignature, userTimestampSignature, behavioralData, simdReadings, clientMetaData) {
24
27
  const body = {
25
28
  [types.ApiParams.user]: userAccount,
26
29
  [types.ApiParams.dapp]: this.account,
@@ -34,7 +37,10 @@ class ProviderApi extends apiClient.ApiClient {
34
37
  [types.ApiParams.provider]: {
35
38
  [types.ApiParams.requestHash]: providerRequestHashSignature
36
39
  }
37
- }
40
+ },
41
+ ...behavioralData && { [types.ApiParams.behavioralData]: behavioralData },
42
+ ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings },
43
+ ...clientMetaData && { [types.ApiParams.clientMetaData]: clientMetaData }
38
44
  };
39
45
  return this.post(types.ClientApiPaths.SubmitImageCaptchaSolution, body, {
40
46
  headers: {
@@ -43,7 +49,7 @@ class ProviderApi extends apiClient.ApiClient {
43
49
  }
44
50
  });
45
51
  }
46
- verifyDappUser(token, signature, userAccount, maxVerifiedTime, ip) {
52
+ verifyDappUser(token, signature, userAccount, maxVerifiedTime, ip, email) {
47
53
  const payload = {
48
54
  [types.ApiParams.token]: token,
49
55
  [types.ApiParams.dappSignature]: signature,
@@ -52,6 +58,9 @@ class ProviderApi extends apiClient.ApiClient {
52
58
  if (maxVerifiedTime) {
53
59
  payload[types.ApiParams.maxVerifiedTime] = maxVerifiedTime;
54
60
  }
61
+ if (email) {
62
+ payload[types.ApiParams.email] = email;
63
+ }
55
64
  return this.post(types.ClientApiPaths.VerifyImageCaptchaSolutionDapp, payload, {
56
65
  headers: {
57
66
  "Prosopo-Site-Key": this.account,
@@ -59,11 +68,12 @@ class ProviderApi extends apiClient.ApiClient {
59
68
  }
60
69
  });
61
70
  }
62
- getPowCaptchaChallenge(user, dapp, sessionId) {
71
+ getPowCaptchaChallenge(user, dapp, sessionId, simdReadings) {
63
72
  const body = {
64
73
  [types.ApiParams.user]: user.toString(),
65
74
  [types.ApiParams.dapp]: dapp.toString(),
66
- ...sessionId && { [types.ApiParams.sessionId]: sessionId }
75
+ ...sessionId && { [types.ApiParams.sessionId]: sessionId },
76
+ ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings }
67
77
  };
68
78
  return this.post(types.ClientApiPaths.GetPowCaptchaChallenge, body, {
69
79
  headers: {
@@ -72,7 +82,7 @@ class ProviderApi extends apiClient.ApiClient {
72
82
  }
73
83
  });
74
84
  }
75
- submitPowCaptchaSolution(challenge, userAccount, dappAccount, nonce, userTimestampSignature, timeout) {
85
+ submitPowCaptchaSolution(challenge, userAccount, dappAccount, nonce, userTimestampSignature, timeout, behavioralData, salt, simdReadings, clientMetaData) {
76
86
  const body = types.SubmitPowCaptchaSolutionBody.parse({
77
87
  [types.ApiParams.challenge]: challenge.challenge,
78
88
  [types.ApiParams.difficulty]: challenge.difficulty,
@@ -86,7 +96,11 @@ class ProviderApi extends apiClient.ApiClient {
86
96
  [types.ApiParams.user]: {
87
97
  [types.ApiParams.timestamp]: userTimestampSignature
88
98
  }
89
- }
99
+ },
100
+ ...behavioralData && { [types.ApiParams.behavioralData]: behavioralData },
101
+ ...salt && { [types.ApiParams.salt]: salt },
102
+ ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings },
103
+ ...clientMetaData && { [types.ApiParams.clientMetaData]: clientMetaData }
90
104
  });
91
105
  return this.post(types.ClientApiPaths.SubmitPowCaptchaSolution, body, {
92
106
  headers: {
@@ -95,19 +109,82 @@ class ProviderApi extends apiClient.ApiClient {
95
109
  }
96
110
  });
97
111
  }
98
- getFrictionlessCaptcha(token, headHash, dapp, user) {
112
+ getPuzzleCaptchaChallenge(user, dapp, sessionId, simdReadings) {
113
+ const body = {
114
+ [types.ApiParams.user]: user.toString(),
115
+ [types.ApiParams.dapp]: dapp.toString(),
116
+ ...sessionId && { [types.ApiParams.sessionId]: sessionId },
117
+ ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings }
118
+ };
119
+ return this.post(types.ClientApiPaths.GetPuzzleCaptchaChallenge, body, {
120
+ headers: {
121
+ "Prosopo-Site-Key": this.account,
122
+ "Prosopo-User": user
123
+ }
124
+ });
125
+ }
126
+ submitPuzzleCaptchaSolution(challenge, userAccount, dappAccount, finalX, finalY, puzzleEvents, userTimestampSignature, timeout, behavioralData, salt, simdReadings, clientMetaData) {
127
+ const body = types.SubmitPuzzleCaptchaSolutionBody.parse({
128
+ [types.ApiParams.challenge]: challenge.challenge,
129
+ [types.ApiParams.timestamp]: challenge.timestamp,
130
+ [types.ApiParams.user]: userAccount.toString(),
131
+ [types.ApiParams.dapp]: dappAccount.toString(),
132
+ [types.ApiParams.finalX]: finalX,
133
+ [types.ApiParams.finalY]: finalY,
134
+ [types.ApiParams.puzzleEvents]: puzzleEvents,
135
+ [types.ApiParams.verifiedTimeout]: timeout,
136
+ [types.ApiParams.signature]: {
137
+ [types.ApiParams.provider]: challenge[types.ApiParams.signature][types.ApiParams.provider],
138
+ [types.ApiParams.user]: {
139
+ [types.ApiParams.timestamp]: userTimestampSignature
140
+ }
141
+ },
142
+ ...behavioralData && { [types.ApiParams.behavioralData]: behavioralData },
143
+ ...salt && { [types.ApiParams.salt]: salt },
144
+ ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings },
145
+ ...clientMetaData && { [types.ApiParams.clientMetaData]: clientMetaData }
146
+ });
147
+ return this.post(types.ClientApiPaths.SubmitPuzzleCaptchaSolution, body, {
148
+ headers: {
149
+ "Prosopo-Site-Key": this.account,
150
+ "Prosopo-User": userAccount
151
+ }
152
+ });
153
+ }
154
+ submitPuzzleCaptchaVerify(token, signatureHex, recencyLimit, user, ip, email) {
155
+ const body = {
156
+ [types.ApiParams.token]: token,
157
+ [types.ApiParams.dappSignature]: signatureHex,
158
+ [types.ApiParams.verifiedTimeout]: recencyLimit,
159
+ [types.ApiParams.ip]: ip
160
+ };
161
+ if (email) {
162
+ body[types.ApiParams.email] = email;
163
+ }
164
+ return this.post(types.ClientApiPaths.VerifyPuzzleCaptchaSolution, body, {
165
+ headers: {
166
+ "Prosopo-Site-Key": this.account,
167
+ "Prosopo-User": user
168
+ }
169
+ });
170
+ }
171
+ async getFrictionlessCaptcha(token, headHash, dapp, user, mode, simdReadings) {
99
172
  const body = {
100
173
  [types.ApiParams.token]: token,
101
174
  [types.ApiParams.headHash]: headHash,
102
175
  [types.ApiParams.dapp]: dapp,
103
- [types.ApiParams.user]: user
176
+ [types.ApiParams.user]: user,
177
+ ...mode && { [types.ApiParams.mode]: mode },
178
+ ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings }
104
179
  };
105
- return this.post(types.ClientApiPaths.GetFrictionlessCaptchaChallenge, body, {
180
+ const { data, headers } = await this.postWithHeaders(types.ClientApiPaths.GetFrictionlessCaptchaChallenge, body, {
106
181
  headers: {
107
182
  "Prosopo-Site-Key": this.account,
108
183
  "Prosopo-User": user
109
184
  }
110
185
  });
186
+ const hp = headers.get("x-prosopo-meta");
187
+ return hp ? { ...data, [types.ApiParams.hp]: hp } : data;
111
188
  }
112
189
  submitUserEvents(events, string) {
113
190
  return this.post(
@@ -134,13 +211,16 @@ class ProviderApi extends apiClient.ApiClient {
134
211
  }
135
212
  });
136
213
  }
137
- submitPowCaptchaVerify(token, signatureHex, recencyLimit, user, ip) {
214
+ submitPowCaptchaVerify(token, signatureHex, recencyLimit, user, ip, email) {
138
215
  const body = {
139
216
  [types.ApiParams.token]: token,
140
217
  [types.ApiParams.dappSignature]: signatureHex,
141
218
  [types.ApiParams.verifiedTimeout]: recencyLimit,
142
219
  [types.ApiParams.ip]: ip
143
220
  };
221
+ if (email) {
222
+ body[types.ApiParams.email] = email;
223
+ }
144
224
  return this.post(types.ClientApiPaths.VerifyPowCaptchaSolution, body, {
145
225
  headers: {
146
226
  "Prosopo-Site-Key": this.account,
@@ -148,30 +228,141 @@ class ProviderApi extends apiClient.ApiClient {
148
228
  }
149
229
  });
150
230
  }
151
- registerSiteKey(siteKey, tier, settings, timestamp, signature) {
231
+ registerSiteKey(siteKey, tier, settings, jwt) {
152
232
  const body = { siteKey, tier, settings };
153
233
  return this.post(types.AdminApiPaths.SiteKeyRegister, body, {
154
234
  headers: {
155
235
  "Prosopo-Site-Key": this.account,
156
- timestamp,
157
- signature
236
+ Authorization: `Bearer ${jwt}`
158
237
  }
159
238
  });
160
239
  }
161
- updateDetectorKey(detectorKey, timestamp, signature) {
240
+ registerSiteKeys(siteKeys, jwt) {
241
+ return this.post(types.AdminApiPaths.SiteKeysRegister, siteKeys, {
242
+ headers: {
243
+ "Prosopo-Site-Key": this.account,
244
+ Authorization: `Bearer ${jwt}`
245
+ }
246
+ });
247
+ }
248
+ removeSiteKey(siteKey, jwt) {
249
+ return this.post(
250
+ types.AdminApiPaths.SiteKeyRemove,
251
+ types.RemoveSitekeyBody.parse({ siteKey }),
252
+ {
253
+ headers: {
254
+ "Prosopo-Site-Key": this.account,
255
+ Authorization: `Bearer ${jwt}`
256
+ }
257
+ }
258
+ );
259
+ }
260
+ removeSiteKeys(siteKeys, jwt) {
261
+ return this.post(
262
+ types.AdminApiPaths.SiteKeysRemove,
263
+ types.RemoveSitekeysBody.parse(siteKeys),
264
+ {
265
+ headers: {
266
+ "Prosopo-Site-Key": this.account,
267
+ Authorization: `Bearer ${jwt}`
268
+ }
269
+ }
270
+ );
271
+ }
272
+ updateDetectorKey(detectorKey, jwt) {
162
273
  return this.post(
163
274
  types.AdminApiPaths.UpdateDetectorKey,
164
275
  types.UpdateDetectorKeyBody.parse({ detectorKey }),
165
276
  {
166
277
  headers: {
167
278
  "Prosopo-Site-Key": this.account,
168
- timestamp,
169
- signature
279
+ Authorization: `Bearer ${jwt}`
280
+ }
281
+ }
282
+ );
283
+ }
284
+ updateDecisionMachine(scope, runtime, source, jwt, dappAccount, language, name, version, captchaType) {
285
+ return this.post(
286
+ types.AdminApiPaths.UpdateDecisionMachine,
287
+ types.UpdateDecisionMachineBody.parse({
288
+ [types.ApiParams.decisionMachineScope]: scope,
289
+ [types.ApiParams.decisionMachineRuntime]: runtime,
290
+ [types.ApiParams.decisionMachineSource]: source,
291
+ [types.ApiParams.decisionMachineLanguage]: language,
292
+ [types.ApiParams.decisionMachineName]: name,
293
+ [types.ApiParams.decisionMachineVersion]: version,
294
+ [types.ApiParams.decisionMachineCaptchaType]: captchaType,
295
+ [types.ApiParams.dapp]: dappAccount
296
+ }),
297
+ {
298
+ headers: {
299
+ "Prosopo-Site-Key": this.account,
300
+ Authorization: `Bearer ${jwt}`
170
301
  }
171
302
  }
172
303
  );
173
304
  }
174
- removeDetectorKey(detectorKey, timestamp, signature, expirationInSeconds) {
305
+ getAllDecisionMachines(jwt) {
306
+ return this.post(
307
+ types.AdminApiPaths.GetAllDecisionMachines,
308
+ types.GetAllDecisionMachinesBody.parse({}),
309
+ {
310
+ headers: {
311
+ "Prosopo-Site-Key": this.account,
312
+ Authorization: `Bearer ${jwt}`
313
+ }
314
+ }
315
+ );
316
+ }
317
+ getDecisionMachine(id, jwt) {
318
+ return this.post(
319
+ types.AdminApiPaths.GetDecisionMachine,
320
+ types.GetDecisionMachineBody.parse({ id }),
321
+ {
322
+ headers: {
323
+ "Prosopo-Site-Key": this.account,
324
+ Authorization: `Bearer ${jwt}`
325
+ }
326
+ }
327
+ );
328
+ }
329
+ removeDecisionMachine(id, jwt) {
330
+ return this.post(
331
+ types.AdminApiPaths.RemoveDecisionMachine,
332
+ types.RemoveDecisionMachineBody.parse({ id }),
333
+ {
334
+ headers: {
335
+ "Prosopo-Site-Key": this.account,
336
+ Authorization: `Bearer ${jwt}`
337
+ }
338
+ }
339
+ );
340
+ }
341
+ removeAllDecisionMachines(jwt) {
342
+ return this.post(
343
+ types.AdminApiPaths.RemoveAllDecisionMachines,
344
+ types.RemoveAllDecisionMachinesBody.parse({}),
345
+ {
346
+ headers: {
347
+ "Prosopo-Site-Key": this.account,
348
+ Authorization: `Bearer ${jwt}`
349
+ }
350
+ }
351
+ );
352
+ }
353
+ clearAllCounters(jwt, dappAccount) {
354
+ return this.post(
355
+ types.AdminApiPaths.ClearAllCounters,
356
+ types.ClearAllCountersBody.parse({ [types.ApiParams.dapp]: dappAccount }),
357
+ {
358
+ headers: {
359
+ "Prosopo-Site-Key": this.account,
360
+ Authorization: `Bearer ${jwt}`
361
+ }
362
+ }
363
+ );
364
+ }
365
+ removeDetectorKey(detectorKey, jwt, expirationInSeconds) {
175
366
  return this.post(
176
367
  types.AdminApiPaths.RemoveDetectorKey,
177
368
  types.RemoveDetectorKeyBodySpec.parse({
@@ -181,8 +372,7 @@ class ProviderApi extends apiClient.ApiClient {
181
372
  {
182
373
  headers: {
183
374
  "Prosopo-Site-Key": this.account,
184
- timestamp,
185
- signature
375
+ Authorization: `Bearer ${jwt}`
186
376
  }
187
377
  }
188
378
  );
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const HttpClientBase = require("./HttpClientBase.cjs");
4
+ const HttpError = require("./HttpError.cjs");
4
5
  const ProviderApi = require("./ProviderApi.cjs");
5
6
  const apiClient = require("./apiClient.cjs");
6
7
  exports.HttpClientBase = HttpClientBase.HttpClientBase;
8
+ exports.HttpError = HttpError.HttpError;
7
9
  exports.ProviderApi = ProviderApi;
8
10
  exports.ApiClient = apiClient.ApiClient;
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("./api/index.cjs");
4
+ const HttpError = require("./api/HttpError.cjs");
4
5
  const ProviderApi = require("./api/ProviderApi.cjs");
5
6
  const apiClient = require("./api/apiClient.cjs");
6
7
  const HttpClientBase = require("./api/HttpClientBase.cjs");
8
+ exports.HttpError = HttpError.HttpError;
7
9
  exports.ProviderApi = ProviderApi;
8
10
  exports.ApiClient = apiClient.ApiClient;
9
11
  exports.HttpClientBase = HttpClientBase.HttpClientBase;
@@ -0,0 +1,2 @@
1
+ export * from "./api/index.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import "./api/index.js";
2
+ import { HttpError } from "./api/HttpError.js";
2
3
  import { default as default2 } from "./api/ProviderApi.js";
3
4
  import { ApiClient } from "./api/apiClient.js";
4
5
  import { HttpClientBase } from "./api/HttpClientBase.js";
5
6
  export {
6
7
  ApiClient,
7
8
  HttpClientBase,
9
+ HttpError,
8
10
  default2 as ProviderApi
9
11
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/api",
3
- "version": "3.1.37",
3
+ "version": "3.4.8",
4
4
  "description": "Wrapper for the provider API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,14 +18,16 @@
18
18
  },
19
19
  "scripts": {
20
20
  "clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
21
- "build": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
21
+ "build": "npm run build:cross-env -- --mode ${NODE_ENV:-development}",
22
+ "build:cross-env": "vite build --config vite.esm.config.ts",
22
23
  "build:tsc": "tsc --build --verbose",
23
24
  "build:cjs": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
24
25
  "typecheck": "tsc --project tsconfig.types.json"
25
26
  },
26
27
  "repository": {
27
28
  "type": "git",
28
- "url": "git+https://github.com/prosopo/captcha.git"
29
+ "url": "git+https://github.com/prosopo/captcha.git",
30
+ "directory": "packages/api"
29
31
  },
30
32
  "author": "PROSOPO LIMITED <info@prosopo.io>",
31
33
  "license": "Apache-2.0",
@@ -34,10 +36,10 @@
34
36
  },
35
37
  "homepage": "https://github.com/prosopo/captcha#readme",
36
38
  "dependencies": {
37
- "@prosopo/types": "3.6.4"
39
+ "@prosopo/types": "4.3.0"
38
40
  },
39
41
  "devDependencies": {
40
- "@prosopo/config": "3.1.26",
42
+ "@prosopo/config": "3.3.1",
41
43
  "@types/node": "22.10.2",
42
44
  "@vitest/coverage-v8": "3.2.4",
43
45
  "concurrently": "9.0.1",
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- // Copyright 2021-2025 Prosopo (UK) Ltd.
2
+ // Copyright 2021-2026 Prosopo (UK) Ltd.
3
3
  //
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2025 Prosopo (UK) Ltd.
1
+ // Copyright 2021-2026 Prosopo (UK) Ltd.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.