@prosopo/api 3.1.41 → 3.4.9

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, behavioralData, salt) {
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,
@@ -88,7 +98,9 @@ class ProviderApi extends apiClient.ApiClient {
88
98
  }
89
99
  },
90
100
  ...behavioralData && { [types.ApiParams.behavioralData]: behavioralData },
91
- ...salt && { [types.ApiParams.salt]: salt }
101
+ ...salt && { [types.ApiParams.salt]: salt },
102
+ ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings },
103
+ ...clientMetaData && { [types.ApiParams.clientMetaData]: clientMetaData }
92
104
  });
93
105
  return this.post(types.ClientApiPaths.SubmitPowCaptchaSolution, body, {
94
106
  headers: {
@@ -97,19 +109,82 @@ class ProviderApi extends apiClient.ApiClient {
97
109
  }
98
110
  });
99
111
  }
100
- 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) {
101
172
  const body = {
102
173
  [types.ApiParams.token]: token,
103
174
  [types.ApiParams.headHash]: headHash,
104
175
  [types.ApiParams.dapp]: dapp,
105
- [types.ApiParams.user]: user
176
+ [types.ApiParams.user]: user,
177
+ ...mode && { [types.ApiParams.mode]: mode },
178
+ ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings }
106
179
  };
107
- return this.post(types.ClientApiPaths.GetFrictionlessCaptchaChallenge, body, {
180
+ const { data, headers } = await this.postWithHeaders(types.ClientApiPaths.GetFrictionlessCaptchaChallenge, body, {
108
181
  headers: {
109
182
  "Prosopo-Site-Key": this.account,
110
183
  "Prosopo-User": user
111
184
  }
112
185
  });
186
+ const hp = headers.get("x-prosopo-meta");
187
+ return hp ? { ...data, [types.ApiParams.hp]: hp } : data;
113
188
  }
114
189
  submitUserEvents(events, string) {
115
190
  return this.post(
@@ -136,13 +211,16 @@ class ProviderApi extends apiClient.ApiClient {
136
211
  }
137
212
  });
138
213
  }
139
- submitPowCaptchaVerify(token, signatureHex, recencyLimit, user, ip) {
214
+ submitPowCaptchaVerify(token, signatureHex, recencyLimit, user, ip, email) {
140
215
  const body = {
141
216
  [types.ApiParams.token]: token,
142
217
  [types.ApiParams.dappSignature]: signatureHex,
143
218
  [types.ApiParams.verifiedTimeout]: recencyLimit,
144
219
  [types.ApiParams.ip]: ip
145
220
  };
221
+ if (email) {
222
+ body[types.ApiParams.email] = email;
223
+ }
146
224
  return this.post(types.ClientApiPaths.VerifyPowCaptchaSolution, body, {
147
225
  headers: {
148
226
  "Prosopo-Site-Key": this.account,
@@ -159,6 +237,38 @@ class ProviderApi extends apiClient.ApiClient {
159
237
  }
160
238
  });
161
239
  }
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
+ }
162
272
  updateDetectorKey(detectorKey, jwt) {
163
273
  return this.post(
164
274
  types.AdminApiPaths.UpdateDetectorKey,
@@ -171,6 +281,87 @@ class ProviderApi extends apiClient.ApiClient {
171
281
  }
172
282
  );
173
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}`
301
+ }
302
+ }
303
+ );
304
+ }
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
+ }
174
365
  removeDetectorKey(detectorKey, jwt, expirationInSeconds) {
175
366
  return this.post(
176
367
  types.AdminApiPaths.RemoveDetectorKey,
@@ -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;
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/api",
3
- "version": "3.1.41",
3
+ "version": "3.4.9",
4
4
  "description": "Wrapper for the provider API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,7 +26,8 @@
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "git+https://github.com/prosopo/captcha.git"
29
+ "url": "git+https://github.com/prosopo/captcha.git",
30
+ "directory": "packages/api"
30
31
  },
31
32
  "author": "PROSOPO LIMITED <info@prosopo.io>",
32
33
  "license": "Apache-2.0",
@@ -35,10 +36,10 @@
35
36
  },
36
37
  "homepage": "https://github.com/prosopo/captcha#readme",
37
38
  "dependencies": {
38
- "@prosopo/types": "3.8.0"
39
+ "@prosopo/types": "4.3.1"
39
40
  },
40
41
  "devDependencies": {
41
- "@prosopo/config": "3.3.0",
42
+ "@prosopo/config": "3.3.1",
42
43
  "@types/node": "22.10.2",
43
44
  "@vitest/coverage-v8": "3.2.4",
44
45
  "concurrently": "9.0.1",