@prosopo/api 3.5.19 → 3.5.21

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.
Files changed (35) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +14 -14
  2. package/.turbo/turbo-build$colon$tsc.log +9 -9
  3. package/.turbo/turbo-build.log +16 -13
  4. package/CHANGELOG.md +14 -0
  5. package/dist/_virtual/_rolldown/runtime.js +3 -0
  6. package/dist/api/HttpClientBase.js +68 -81
  7. package/dist/api/HttpError.js +11 -11
  8. package/dist/api/ProviderApi.js +304 -430
  9. package/dist/api/apiClient.js +9 -9
  10. package/dist/api/index.js +3 -9
  11. package/dist/cjs/api/HttpClientBase.cjs +69 -81
  12. package/dist/cjs/api/HttpError.cjs +11 -11
  13. package/dist/cjs/api/ProviderApi.cjs +305 -430
  14. package/dist/cjs/api/apiClient.cjs +10 -10
  15. package/dist/cjs/api/index.cjs +9 -11
  16. package/dist/cjs/index.cjs +9 -11
  17. package/dist/index.js +4 -10
  18. package/dist/tests/api.test-d.d.ts +2 -0
  19. package/dist/tests/api.test-d.d.ts.map +1 -0
  20. package/dist/tests/api.test-d.js +66 -0
  21. package/dist/tests/api.test-d.js.map +1 -0
  22. package/dist/tests/apiHarness.d.ts +25 -0
  23. package/dist/tests/apiHarness.d.ts.map +1 -0
  24. package/dist/tests/apiHarness.js +87 -0
  25. package/dist/tests/apiHarness.js.map +1 -0
  26. package/dist/tests/httpClientBase.unit.test.d.ts +2 -0
  27. package/dist/tests/httpClientBase.unit.test.d.ts.map +1 -0
  28. package/dist/tests/httpClientBase.unit.test.js +257 -0
  29. package/dist/tests/httpClientBase.unit.test.js.map +1 -0
  30. package/dist/tests/providerApi.unit.test.d.ts +2 -0
  31. package/dist/tests/providerApi.unit.test.d.ts.map +1 -0
  32. package/dist/tests/providerApi.unit.test.js +536 -0
  33. package/dist/tests/providerApi.unit.test.js.map +1 -0
  34. package/package.json +10 -7
  35. package/vite.test.config.ts +19 -0
@@ -1,432 +1,307 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const types = require("@prosopo/types");
4
- const apiClient = require("./apiClient.cjs");
5
- const VERIFY_FORWARDED_HEADER = "prosopo-verify-forwarded";
6
- class ProviderApi extends apiClient.ApiClient {
7
- constructor() {
8
- super(...arguments);
9
- this.inFlightChallenges = /* @__PURE__ */ new Map();
10
- }
11
- dedupedPost(path, sessionId, body, init) {
12
- if (!sessionId) return this.post(path, body, init);
13
- const key = `${path}|${sessionId}`;
14
- const existing = this.inFlightChallenges.get(key);
15
- if (existing) return existing;
16
- const p = this.post(path, body, init).finally(() => {
17
- this.inFlightChallenges.delete(key);
18
- });
19
- this.inFlightChallenges.set(key, p);
20
- return p;
21
- }
22
- getCaptchaChallenge(userAccount, _randomProvider, sessionId, simdReadings) {
23
- const dappAccount = this.account;
24
- const body = {
25
- [types.ApiParams.dapp]: dappAccount,
26
- [types.ApiParams.user]: userAccount
27
- };
28
- if (sessionId) {
29
- body[types.ApiParams.sessionId] = sessionId;
30
- }
31
- if (simdReadings) {
32
- body[types.ApiParams.simdReadings] = simdReadings;
33
- }
34
- return this.dedupedPost(
35
- types.ClientApiPaths.GetImageCaptchaChallenge,
36
- sessionId,
37
- body,
38
- {
39
- headers: {
40
- "Prosopo-Site-Key": this.account,
41
- "Prosopo-User": userAccount
42
- }
43
- }
44
- );
45
- }
46
- submitCaptchaSolution(captchas, requestHash, userAccount, timestamp, providerRequestHashSignature, userTimestampSignature, behavioralData, simdReadings, clientMetaData) {
47
- const body = {
48
- [types.ApiParams.user]: userAccount,
49
- [types.ApiParams.dapp]: this.account,
50
- [types.ApiParams.captchas]: captchas,
51
- [types.ApiParams.requestHash]: requestHash,
52
- [types.ApiParams.timestamp]: timestamp,
53
- [types.ApiParams.signature]: {
54
- [types.ApiParams.user]: {
55
- [types.ApiParams.timestamp]: userTimestampSignature
56
- },
57
- [types.ApiParams.provider]: {
58
- [types.ApiParams.requestHash]: providerRequestHashSignature
59
- }
60
- },
61
- ...behavioralData && { [types.ApiParams.behavioralData]: behavioralData },
62
- ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings },
63
- ...clientMetaData && { [types.ApiParams.clientMetaData]: clientMetaData }
64
- };
65
- return this.post(types.ClientApiPaths.SubmitImageCaptchaSolution, body, {
66
- headers: {
67
- "Prosopo-Site-Key": this.account,
68
- "Prosopo-User": userAccount
69
- }
70
- });
71
- }
72
- verifyDappUser(token, signature, userAccount, maxVerifiedTime, ip, email) {
73
- const payload = {
74
- [types.ApiParams.token]: token,
75
- [types.ApiParams.dappSignature]: signature,
76
- [types.ApiParams.ip]: ip
77
- };
78
- if (maxVerifiedTime) {
79
- payload[types.ApiParams.maxVerifiedTime] = maxVerifiedTime;
80
- }
81
- if (email) {
82
- payload[types.ApiParams.email] = email;
83
- }
84
- return this.post(types.ClientApiPaths.VerifyImageCaptchaSolutionDapp, payload, {
85
- headers: {
86
- "Prosopo-Site-Key": this.account,
87
- "Prosopo-User": userAccount
88
- }
89
- });
90
- }
91
- getPowCaptchaChallenge(user, dapp, sessionId, simdReadings) {
92
- const body = {
93
- [types.ApiParams.user]: user.toString(),
94
- [types.ApiParams.dapp]: dapp.toString(),
95
- ...sessionId && { [types.ApiParams.sessionId]: sessionId },
96
- ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings }
97
- };
98
- return this.dedupedPost(types.ClientApiPaths.GetPowCaptchaChallenge, sessionId, body, {
99
- headers: {
100
- "Prosopo-Site-Key": this.account,
101
- "Prosopo-User": user
102
- }
103
- });
104
- }
105
- submitPowCaptchaSolution(challenge, userAccount, dappAccount, nonce, userTimestampSignature, behavioralData, salt, simdReadings, clientMetaData, fingerprintProof) {
106
- const body = types.SubmitPowCaptchaSolutionBody.parse({
107
- [types.ApiParams.challenge]: challenge.challenge,
108
- [types.ApiParams.difficulty]: challenge.difficulty,
109
- [types.ApiParams.timestamp]: challenge.timestamp,
110
- [types.ApiParams.user]: userAccount.toString(),
111
- [types.ApiParams.dapp]: dappAccount.toString(),
112
- [types.ApiParams.nonce]: nonce,
113
- [types.ApiParams.signature]: {
114
- [types.ApiParams.provider]: challenge[types.ApiParams.signature][types.ApiParams.provider],
115
- [types.ApiParams.user]: {
116
- [types.ApiParams.timestamp]: userTimestampSignature
117
- }
118
- },
119
- ...behavioralData && { [types.ApiParams.behavioralData]: behavioralData },
120
- ...salt && { [types.ApiParams.salt]: salt },
121
- ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings },
122
- ...clientMetaData && { [types.ApiParams.clientMetaData]: clientMetaData },
123
- ...fingerprintProof && {
124
- [types.ApiParams.fingerprintProof]: fingerprintProof
125
- }
126
- });
127
- return this.post(types.ClientApiPaths.SubmitPowCaptchaSolution, body, {
128
- headers: {
129
- "Prosopo-Site-Key": this.account,
130
- "Prosopo-User": userAccount
131
- }
132
- });
133
- }
134
- getPuzzleCaptchaChallenge(user, dapp, sessionId, simdReadings) {
135
- const body = {
136
- [types.ApiParams.user]: user.toString(),
137
- [types.ApiParams.dapp]: dapp.toString(),
138
- ...sessionId && { [types.ApiParams.sessionId]: sessionId },
139
- ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings }
140
- };
141
- return this.dedupedPost(types.ClientApiPaths.GetPuzzleCaptchaChallenge, sessionId, body, {
142
- headers: {
143
- "Prosopo-Site-Key": this.account,
144
- "Prosopo-User": user
145
- }
146
- });
147
- }
148
- submitPuzzleCaptchaSolution(challenge, userAccount, dappAccount, finalX, finalY, puzzleEvents, userTimestampSignature, behavioralData, salt, simdReadings, clientMetaData) {
149
- const body = types.SubmitPuzzleCaptchaSolutionBody.parse({
150
- [types.ApiParams.challenge]: challenge.challenge,
151
- [types.ApiParams.timestamp]: challenge.timestamp,
152
- [types.ApiParams.user]: userAccount.toString(),
153
- [types.ApiParams.dapp]: dappAccount.toString(),
154
- [types.ApiParams.finalX]: finalX,
155
- [types.ApiParams.finalY]: finalY,
156
- [types.ApiParams.puzzleEvents]: puzzleEvents,
157
- [types.ApiParams.signature]: {
158
- [types.ApiParams.provider]: challenge[types.ApiParams.signature][types.ApiParams.provider],
159
- [types.ApiParams.user]: {
160
- [types.ApiParams.timestamp]: userTimestampSignature
161
- }
162
- },
163
- ...behavioralData && { [types.ApiParams.behavioralData]: behavioralData },
164
- ...salt && { [types.ApiParams.salt]: salt },
165
- ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings },
166
- ...clientMetaData && { [types.ApiParams.clientMetaData]: clientMetaData }
167
- });
168
- return this.post(types.ClientApiPaths.SubmitPuzzleCaptchaSolution, body, {
169
- headers: {
170
- "Prosopo-Site-Key": this.account,
171
- "Prosopo-User": userAccount
172
- }
173
- });
174
- }
175
- submitPuzzleCaptchaVerify(token, signatureHex, user, ip, email) {
176
- const body = {
177
- [types.ApiParams.token]: token,
178
- [types.ApiParams.dappSignature]: signatureHex,
179
- [types.ApiParams.ip]: ip
180
- };
181
- if (email) {
182
- body[types.ApiParams.email] = email;
183
- }
184
- return this.post(types.ClientApiPaths.VerifyPuzzleCaptchaSolution, body, {
185
- headers: {
186
- "Prosopo-Site-Key": this.account,
187
- "Prosopo-User": user
188
- }
189
- });
190
- }
191
- async getFrictionlessCaptcha(token, headHash, dapp, user, mode, simdReadings, currentUrl, iframeUrl) {
192
- const body = {
193
- [types.ApiParams.token]: token,
194
- [types.ApiParams.headHash]: headHash,
195
- [types.ApiParams.dapp]: dapp,
196
- [types.ApiParams.user]: user,
197
- ...mode && { [types.ApiParams.mode]: mode },
198
- ...simdReadings && { [types.ApiParams.simdReadings]: simdReadings },
199
- ...currentUrl && { [types.ApiParams.currentUrl]: currentUrl },
200
- ...iframeUrl && { [types.ApiParams.iframeUrl]: iframeUrl }
201
- };
202
- const { data, headers } = await this.postWithHeaders(types.ClientApiPaths.GetFrictionlessCaptchaChallenge, body, {
203
- headers: {
204
- "Prosopo-Site-Key": this.account,
205
- "Prosopo-User": user
206
- }
207
- });
208
- const hp = headers.get("x-prosopo-meta");
209
- return hp ? { ...data, [types.ApiParams.hp]: hp } : data;
210
- }
211
- submitUserEvents(events, string) {
212
- return this.post(
213
- types.ClientApiPaths.SubmitUserEvents,
214
- { events, string },
215
- {
216
- headers: {
217
- "Prosopo-Site-Key": this.account
218
- }
219
- }
220
- );
221
- }
222
- getProviderStatus() {
223
- return this.fetch(types.ClientApiPaths.GetProviderStatus, {
224
- headers: {
225
- "Prosopo-Site-Key": this.account
226
- }
227
- });
228
- }
229
- getProviderDetails() {
230
- return this.fetch(types.PublicApiPaths.GetProviderDetails, {
231
- headers: {
232
- "Prosopo-Site-Key": this.account
233
- }
234
- });
235
- }
236
- /**
237
- * Forwards an already-parsed verify request body to a verify path on this
238
- * provider, verbatim. Used by a pronode to proxy a verification request
239
- * through to the provider that issued the token (the one the client
240
- * happened to contact is not necessarily the issuer).
241
- */
242
- forwardVerify(path, body, user) {
243
- return this.post(path, body, {
244
- headers: {
245
- "Prosopo-Site-Key": this.account,
246
- "Prosopo-User": user,
247
- [VERIFY_FORWARDED_HEADER]: "true"
248
- }
249
- });
250
- }
251
- submitPowCaptchaVerify(token, signatureHex, user, ip, email) {
252
- const body = {
253
- [types.ApiParams.token]: token,
254
- [types.ApiParams.dappSignature]: signatureHex,
255
- [types.ApiParams.ip]: ip
256
- };
257
- if (email) {
258
- body[types.ApiParams.email] = email;
259
- }
260
- return this.post(types.ClientApiPaths.VerifyPowCaptchaSolution, body, {
261
- headers: {
262
- "Prosopo-Site-Key": this.account,
263
- "Prosopo-User": user
264
- }
265
- });
266
- }
267
- registerSiteKey(siteKey, tier, settings, jwt) {
268
- const body = { siteKey, tier, settings };
269
- return this.post(types.AdminApiPaths.SiteKeyRegister, body, {
270
- headers: {
271
- "Prosopo-Site-Key": this.account,
272
- Authorization: `Bearer ${jwt}`
273
- }
274
- });
275
- }
276
- registerSiteKeys(siteKeys, jwt) {
277
- return this.post(types.AdminApiPaths.SiteKeysRegister, siteKeys, {
278
- headers: {
279
- "Prosopo-Site-Key": this.account,
280
- Authorization: `Bearer ${jwt}`
281
- }
282
- });
283
- }
284
- removeSiteKey(siteKey, jwt) {
285
- return this.post(
286
- types.AdminApiPaths.SiteKeyRemove,
287
- types.RemoveSitekeyBody.parse({ siteKey }),
288
- {
289
- headers: {
290
- "Prosopo-Site-Key": this.account,
291
- Authorization: `Bearer ${jwt}`
292
- }
293
- }
294
- );
295
- }
296
- removeSiteKeys(siteKeys, jwt) {
297
- return this.post(
298
- types.AdminApiPaths.SiteKeysRemove,
299
- types.RemoveSitekeysBody.parse(siteKeys),
300
- {
301
- headers: {
302
- "Prosopo-Site-Key": this.account,
303
- Authorization: `Bearer ${jwt}`
304
- }
305
- }
306
- );
307
- }
308
- updateDetectorKey(detectorKey, jwt) {
309
- return this.post(
310
- types.AdminApiPaths.UpdateDetectorKey,
311
- types.UpdateDetectorKeyBody.parse({ detectorKey }),
312
- {
313
- headers: {
314
- "Prosopo-Site-Key": this.account,
315
- Authorization: `Bearer ${jwt}`
316
- }
317
- }
318
- );
319
- }
320
- updateDecisionMachine(scope, runtime, source, jwt, dappAccount, language, name, version, captchaType, kind) {
321
- return this.post(
322
- types.AdminApiPaths.UpdateDecisionMachine,
323
- types.UpdateDecisionMachineBody.parse({
324
- [types.ApiParams.decisionMachineScope]: scope,
325
- [types.ApiParams.decisionMachineRuntime]: runtime,
326
- [types.ApiParams.decisionMachineSource]: source,
327
- [types.ApiParams.decisionMachineLanguage]: language,
328
- [types.ApiParams.decisionMachineName]: name,
329
- [types.ApiParams.decisionMachineVersion]: version,
330
- [types.ApiParams.decisionMachineCaptchaType]: captchaType,
331
- [types.ApiParams.decisionMachineKind]: kind,
332
- [types.ApiParams.dapp]: dappAccount
333
- }),
334
- {
335
- headers: {
336
- "Prosopo-Site-Key": this.account,
337
- Authorization: `Bearer ${jwt}`
338
- }
339
- }
340
- );
341
- }
342
- getAllDecisionMachines(jwt) {
343
- return this.post(
344
- types.AdminApiPaths.GetAllDecisionMachines,
345
- types.GetAllDecisionMachinesBody.parse({}),
346
- {
347
- headers: {
348
- "Prosopo-Site-Key": this.account,
349
- Authorization: `Bearer ${jwt}`
350
- }
351
- }
352
- );
353
- }
354
- getDecisionMachine(id, jwt) {
355
- return this.post(
356
- types.AdminApiPaths.GetDecisionMachine,
357
- types.GetDecisionMachineBody.parse({ id }),
358
- {
359
- headers: {
360
- "Prosopo-Site-Key": this.account,
361
- Authorization: `Bearer ${jwt}`
362
- }
363
- }
364
- );
365
- }
366
- removeDecisionMachine(id, jwt) {
367
- return this.post(
368
- types.AdminApiPaths.RemoveDecisionMachine,
369
- types.RemoveDecisionMachineBody.parse({ id }),
370
- {
371
- headers: {
372
- "Prosopo-Site-Key": this.account,
373
- Authorization: `Bearer ${jwt}`
374
- }
375
- }
376
- );
377
- }
378
- removeAllDecisionMachines(jwt) {
379
- return this.post(
380
- types.AdminApiPaths.RemoveAllDecisionMachines,
381
- types.RemoveAllDecisionMachinesBody.parse({}),
382
- {
383
- headers: {
384
- "Prosopo-Site-Key": this.account,
385
- Authorization: `Bearer ${jwt}`
386
- }
387
- }
388
- );
389
- }
390
- clearAllCounters(jwt, dappAccount) {
391
- return this.post(
392
- types.AdminApiPaths.ClearAllCounters,
393
- types.ClearAllCountersBody.parse({ [types.ApiParams.dapp]: dappAccount }),
394
- {
395
- headers: {
396
- "Prosopo-Site-Key": this.account,
397
- Authorization: `Bearer ${jwt}`
398
- }
399
- }
400
- );
401
- }
402
- removeDetectorKey(detectorKey, jwt, expirationInSeconds) {
403
- return this.post(
404
- types.AdminApiPaths.RemoveDetectorKey,
405
- types.RemoveDetectorKeyBodySpec.parse({
406
- detectorKey,
407
- expirationInSeconds
408
- }),
409
- {
410
- headers: {
411
- "Prosopo-Site-Key": this.account,
412
- Authorization: `Bearer ${jwt}`
413
- }
414
- }
415
- );
416
- }
417
- toggleMaintenanceMode(enabled, timestamp, signature) {
418
- return this.post(
419
- types.AdminApiPaths.ToggleMaintenanceMode,
420
- types.ToggleMaintenanceModeBody.parse({ enabled }),
421
- {
422
- headers: {
423
- "Prosopo-Site-Key": this.account,
424
- timestamp,
425
- signature
426
- }
427
- }
428
- );
429
- }
430
- }
1
+ const require_apiClient = require("./apiClient.cjs");
2
+ let _prosopo_types = require("@prosopo/types");
3
+ //#region src/api/ProviderApi.ts
4
+ var VERIFY_FORWARDED_HEADER = "prosopo-verify-forwarded";
5
+ var ProviderApi = class extends require_apiClient.ApiClient {
6
+ constructor(..._args) {
7
+ super(..._args);
8
+ this.inFlightChallenges = /* @__PURE__ */ new Map();
9
+ }
10
+ dedupedPost(path, sessionId, body, init) {
11
+ if (!sessionId) return this.post(path, body, init);
12
+ const key = `${path}|${sessionId}`;
13
+ const existing = this.inFlightChallenges.get(key);
14
+ if (existing) return existing;
15
+ const p = this.post(path, body, init).finally(() => {
16
+ this.inFlightChallenges.delete(key);
17
+ });
18
+ this.inFlightChallenges.set(key, p);
19
+ return p;
20
+ }
21
+ getCaptchaChallenge(userAccount, _randomProvider, sessionId, simdReadings) {
22
+ const dappAccount = this.account;
23
+ const body = {
24
+ [_prosopo_types.ApiParams.dapp]: dappAccount,
25
+ [_prosopo_types.ApiParams.user]: userAccount
26
+ };
27
+ if (sessionId) body[_prosopo_types.ApiParams.sessionId] = sessionId;
28
+ if (simdReadings) body[_prosopo_types.ApiParams.simdReadings] = simdReadings;
29
+ return this.dedupedPost(_prosopo_types.ClientApiPaths.GetImageCaptchaChallenge, sessionId, body, { headers: {
30
+ "Prosopo-Site-Key": this.account,
31
+ "Prosopo-User": userAccount
32
+ } });
33
+ }
34
+ submitCaptchaSolution(captchas, requestHash, userAccount, timestamp, providerRequestHashSignature, userTimestampSignature, behavioralData, simdReadings, clientMetaData) {
35
+ const body = {
36
+ [_prosopo_types.ApiParams.user]: userAccount,
37
+ [_prosopo_types.ApiParams.dapp]: this.account,
38
+ [_prosopo_types.ApiParams.captchas]: captchas,
39
+ [_prosopo_types.ApiParams.requestHash]: requestHash,
40
+ [_prosopo_types.ApiParams.timestamp]: timestamp,
41
+ [_prosopo_types.ApiParams.signature]: {
42
+ [_prosopo_types.ApiParams.user]: { [_prosopo_types.ApiParams.timestamp]: userTimestampSignature },
43
+ [_prosopo_types.ApiParams.provider]: { [_prosopo_types.ApiParams.requestHash]: providerRequestHashSignature }
44
+ },
45
+ ...behavioralData && { [_prosopo_types.ApiParams.behavioralData]: behavioralData },
46
+ ...simdReadings && { [_prosopo_types.ApiParams.simdReadings]: simdReadings },
47
+ ...clientMetaData && { [_prosopo_types.ApiParams.clientMetaData]: clientMetaData }
48
+ };
49
+ return this.post(_prosopo_types.ClientApiPaths.SubmitImageCaptchaSolution, body, { headers: {
50
+ "Prosopo-Site-Key": this.account,
51
+ "Prosopo-User": userAccount
52
+ } });
53
+ }
54
+ verifyDappUser(token, signature, userAccount, maxVerifiedTime, ip, email) {
55
+ const payload = {
56
+ [_prosopo_types.ApiParams.token]: token,
57
+ [_prosopo_types.ApiParams.dappSignature]: signature,
58
+ [_prosopo_types.ApiParams.ip]: ip
59
+ };
60
+ if (maxVerifiedTime) payload[_prosopo_types.ApiParams.maxVerifiedTime] = maxVerifiedTime;
61
+ if (email) payload[_prosopo_types.ApiParams.email] = email;
62
+ return this.post(_prosopo_types.ClientApiPaths.VerifyImageCaptchaSolutionDapp, payload, { headers: {
63
+ "Prosopo-Site-Key": this.account,
64
+ "Prosopo-User": userAccount
65
+ } });
66
+ }
67
+ getPowCaptchaChallenge(user, dapp, sessionId, simdReadings) {
68
+ const body = {
69
+ [_prosopo_types.ApiParams.user]: user.toString(),
70
+ [_prosopo_types.ApiParams.dapp]: dapp.toString(),
71
+ ...sessionId && { [_prosopo_types.ApiParams.sessionId]: sessionId },
72
+ ...simdReadings && { [_prosopo_types.ApiParams.simdReadings]: simdReadings }
73
+ };
74
+ return this.dedupedPost(_prosopo_types.ClientApiPaths.GetPowCaptchaChallenge, sessionId, body, { headers: {
75
+ "Prosopo-Site-Key": this.account,
76
+ "Prosopo-User": user
77
+ } });
78
+ }
79
+ submitPowCaptchaSolution(challenge, userAccount, dappAccount, nonce, userTimestampSignature, behavioralData, salt, simdReadings, clientMetaData, fingerprintProof) {
80
+ const body = _prosopo_types.SubmitPowCaptchaSolutionBody.parse({
81
+ [_prosopo_types.ApiParams.challenge]: challenge.challenge,
82
+ [_prosopo_types.ApiParams.difficulty]: challenge.difficulty,
83
+ [_prosopo_types.ApiParams.timestamp]: challenge.timestamp,
84
+ [_prosopo_types.ApiParams.user]: userAccount.toString(),
85
+ [_prosopo_types.ApiParams.dapp]: dappAccount.toString(),
86
+ [_prosopo_types.ApiParams.nonce]: nonce,
87
+ [_prosopo_types.ApiParams.signature]: {
88
+ [_prosopo_types.ApiParams.provider]: challenge[_prosopo_types.ApiParams.signature][_prosopo_types.ApiParams.provider],
89
+ [_prosopo_types.ApiParams.user]: { [_prosopo_types.ApiParams.timestamp]: userTimestampSignature }
90
+ },
91
+ ...behavioralData && { [_prosopo_types.ApiParams.behavioralData]: behavioralData },
92
+ ...salt && { [_prosopo_types.ApiParams.salt]: salt },
93
+ ...simdReadings && { [_prosopo_types.ApiParams.simdReadings]: simdReadings },
94
+ ...clientMetaData && { [_prosopo_types.ApiParams.clientMetaData]: clientMetaData },
95
+ ...fingerprintProof && { [_prosopo_types.ApiParams.fingerprintProof]: fingerprintProof }
96
+ });
97
+ return this.post(_prosopo_types.ClientApiPaths.SubmitPowCaptchaSolution, body, { headers: {
98
+ "Prosopo-Site-Key": this.account,
99
+ "Prosopo-User": userAccount
100
+ } });
101
+ }
102
+ getPuzzleCaptchaChallenge(user, dapp, sessionId, simdReadings) {
103
+ const body = {
104
+ [_prosopo_types.ApiParams.user]: user.toString(),
105
+ [_prosopo_types.ApiParams.dapp]: dapp.toString(),
106
+ ...sessionId && { [_prosopo_types.ApiParams.sessionId]: sessionId },
107
+ ...simdReadings && { [_prosopo_types.ApiParams.simdReadings]: simdReadings }
108
+ };
109
+ return this.dedupedPost(_prosopo_types.ClientApiPaths.GetPuzzleCaptchaChallenge, sessionId, body, { headers: {
110
+ "Prosopo-Site-Key": this.account,
111
+ "Prosopo-User": user
112
+ } });
113
+ }
114
+ submitPuzzleCaptchaSolution(challenge, userAccount, dappAccount, finalX, finalY, puzzleEvents, userTimestampSignature, behavioralData, salt, simdReadings, clientMetaData) {
115
+ const body = _prosopo_types.SubmitPuzzleCaptchaSolutionBody.parse({
116
+ [_prosopo_types.ApiParams.challenge]: challenge.challenge,
117
+ [_prosopo_types.ApiParams.timestamp]: challenge.timestamp,
118
+ [_prosopo_types.ApiParams.user]: userAccount.toString(),
119
+ [_prosopo_types.ApiParams.dapp]: dappAccount.toString(),
120
+ [_prosopo_types.ApiParams.finalX]: finalX,
121
+ [_prosopo_types.ApiParams.finalY]: finalY,
122
+ [_prosopo_types.ApiParams.puzzleEvents]: puzzleEvents,
123
+ [_prosopo_types.ApiParams.signature]: {
124
+ [_prosopo_types.ApiParams.provider]: challenge[_prosopo_types.ApiParams.signature][_prosopo_types.ApiParams.provider],
125
+ [_prosopo_types.ApiParams.user]: { [_prosopo_types.ApiParams.timestamp]: userTimestampSignature }
126
+ },
127
+ ...behavioralData && { [_prosopo_types.ApiParams.behavioralData]: behavioralData },
128
+ ...salt && { [_prosopo_types.ApiParams.salt]: salt },
129
+ ...simdReadings && { [_prosopo_types.ApiParams.simdReadings]: simdReadings },
130
+ ...clientMetaData && { [_prosopo_types.ApiParams.clientMetaData]: clientMetaData }
131
+ });
132
+ return this.post(_prosopo_types.ClientApiPaths.SubmitPuzzleCaptchaSolution, body, { headers: {
133
+ "Prosopo-Site-Key": this.account,
134
+ "Prosopo-User": userAccount
135
+ } });
136
+ }
137
+ submitPuzzleCaptchaVerify(token, signatureHex, user, ip, email) {
138
+ const body = {
139
+ [_prosopo_types.ApiParams.token]: token,
140
+ [_prosopo_types.ApiParams.dappSignature]: signatureHex,
141
+ [_prosopo_types.ApiParams.ip]: ip
142
+ };
143
+ if (email) body[_prosopo_types.ApiParams.email] = email;
144
+ return this.post(_prosopo_types.ClientApiPaths.VerifyPuzzleCaptchaSolution, body, { headers: {
145
+ "Prosopo-Site-Key": this.account,
146
+ "Prosopo-User": user
147
+ } });
148
+ }
149
+ async getFrictionlessCaptcha(token, headHash, dapp, user, mode, simdReadings, currentUrl, iframeUrl) {
150
+ const body = {
151
+ [_prosopo_types.ApiParams.token]: token,
152
+ [_prosopo_types.ApiParams.headHash]: headHash,
153
+ [_prosopo_types.ApiParams.dapp]: dapp,
154
+ [_prosopo_types.ApiParams.user]: user,
155
+ ...mode && { [_prosopo_types.ApiParams.mode]: mode },
156
+ ...simdReadings && { [_prosopo_types.ApiParams.simdReadings]: simdReadings },
157
+ ...currentUrl && { [_prosopo_types.ApiParams.currentUrl]: currentUrl },
158
+ ...iframeUrl && { [_prosopo_types.ApiParams.iframeUrl]: iframeUrl }
159
+ };
160
+ const { data, headers } = await this.postWithHeaders(_prosopo_types.ClientApiPaths.GetFrictionlessCaptchaChallenge, body, { headers: {
161
+ "Prosopo-Site-Key": this.account,
162
+ "Prosopo-User": user
163
+ } });
164
+ const hp = headers.get("x-prosopo-meta");
165
+ return hp ? {
166
+ ...data,
167
+ [_prosopo_types.ApiParams.hp]: hp
168
+ } : data;
169
+ }
170
+ submitUserEvents(events, string) {
171
+ return this.post(_prosopo_types.ClientApiPaths.SubmitUserEvents, {
172
+ events,
173
+ string
174
+ }, { headers: { "Prosopo-Site-Key": this.account } });
175
+ }
176
+ getProviderStatus() {
177
+ return this.fetch(_prosopo_types.ClientApiPaths.GetProviderStatus, { headers: { "Prosopo-Site-Key": this.account } });
178
+ }
179
+ getProviderDetails() {
180
+ return this.fetch(_prosopo_types.PublicApiPaths.GetProviderDetails, { headers: { "Prosopo-Site-Key": this.account } });
181
+ }
182
+ /**
183
+ * Forwards an already-parsed verify request body to a verify path on this
184
+ * provider, verbatim. Used by a pronode to proxy a verification request
185
+ * through to the provider that issued the token (the one the client
186
+ * happened to contact is not necessarily the issuer).
187
+ */
188
+ forwardVerify(path, body, user) {
189
+ return this.post(path, body, { headers: {
190
+ "Prosopo-Site-Key": this.account,
191
+ "Prosopo-User": user,
192
+ [VERIFY_FORWARDED_HEADER]: "true"
193
+ } });
194
+ }
195
+ submitPowCaptchaVerify(token, signatureHex, user, ip, email) {
196
+ const body = {
197
+ [_prosopo_types.ApiParams.token]: token,
198
+ [_prosopo_types.ApiParams.dappSignature]: signatureHex,
199
+ [_prosopo_types.ApiParams.ip]: ip
200
+ };
201
+ if (email) body[_prosopo_types.ApiParams.email] = email;
202
+ return this.post(_prosopo_types.ClientApiPaths.VerifyPowCaptchaSolution, body, { headers: {
203
+ "Prosopo-Site-Key": this.account,
204
+ "Prosopo-User": user
205
+ } });
206
+ }
207
+ registerSiteKey(siteKey, tier, settings, jwt) {
208
+ const body = {
209
+ siteKey,
210
+ tier,
211
+ settings
212
+ };
213
+ return this.post(_prosopo_types.AdminApiPaths.SiteKeyRegister, body, { headers: {
214
+ "Prosopo-Site-Key": this.account,
215
+ Authorization: `Bearer ${jwt}`
216
+ } });
217
+ }
218
+ registerSiteKeys(siteKeys, jwt) {
219
+ return this.post(_prosopo_types.AdminApiPaths.SiteKeysRegister, siteKeys, { headers: {
220
+ "Prosopo-Site-Key": this.account,
221
+ Authorization: `Bearer ${jwt}`
222
+ } });
223
+ }
224
+ removeSiteKey(siteKey, jwt) {
225
+ return this.post(_prosopo_types.AdminApiPaths.SiteKeyRemove, _prosopo_types.RemoveSitekeyBody.parse({ siteKey }), { headers: {
226
+ "Prosopo-Site-Key": this.account,
227
+ Authorization: `Bearer ${jwt}`
228
+ } });
229
+ }
230
+ removeSiteKeys(siteKeys, jwt) {
231
+ return this.post(_prosopo_types.AdminApiPaths.SiteKeysRemove, _prosopo_types.RemoveSitekeysBody.parse(siteKeys), { headers: {
232
+ "Prosopo-Site-Key": this.account,
233
+ Authorization: `Bearer ${jwt}`
234
+ } });
235
+ }
236
+ updateDetectorKey(detectorKey, jwt) {
237
+ return this.post(_prosopo_types.AdminApiPaths.UpdateDetectorKey, _prosopo_types.UpdateDetectorKeyBody.parse({ detectorKey }), { headers: {
238
+ "Prosopo-Site-Key": this.account,
239
+ Authorization: `Bearer ${jwt}`
240
+ } });
241
+ }
242
+ updateDecisionMachine(scope, runtime, source, jwt, dappAccount, language, name, version, captchaType, kind) {
243
+ return this.post(_prosopo_types.AdminApiPaths.UpdateDecisionMachine, _prosopo_types.UpdateDecisionMachineBody.parse({
244
+ [_prosopo_types.ApiParams.decisionMachineScope]: scope,
245
+ [_prosopo_types.ApiParams.decisionMachineRuntime]: runtime,
246
+ [_prosopo_types.ApiParams.decisionMachineSource]: source,
247
+ [_prosopo_types.ApiParams.decisionMachineLanguage]: language,
248
+ [_prosopo_types.ApiParams.decisionMachineName]: name,
249
+ [_prosopo_types.ApiParams.decisionMachineVersion]: version,
250
+ [_prosopo_types.ApiParams.decisionMachineCaptchaType]: captchaType,
251
+ [_prosopo_types.ApiParams.decisionMachineKind]: kind,
252
+ [_prosopo_types.ApiParams.dapp]: dappAccount
253
+ }), { headers: {
254
+ "Prosopo-Site-Key": this.account,
255
+ Authorization: `Bearer ${jwt}`
256
+ } });
257
+ }
258
+ getAllDecisionMachines(jwt) {
259
+ return this.post(_prosopo_types.AdminApiPaths.GetAllDecisionMachines, _prosopo_types.GetAllDecisionMachinesBody.parse({}), { headers: {
260
+ "Prosopo-Site-Key": this.account,
261
+ Authorization: `Bearer ${jwt}`
262
+ } });
263
+ }
264
+ getDecisionMachine(id, jwt) {
265
+ return this.post(_prosopo_types.AdminApiPaths.GetDecisionMachine, _prosopo_types.GetDecisionMachineBody.parse({ id }), { headers: {
266
+ "Prosopo-Site-Key": this.account,
267
+ Authorization: `Bearer ${jwt}`
268
+ } });
269
+ }
270
+ removeDecisionMachine(id, jwt) {
271
+ return this.post(_prosopo_types.AdminApiPaths.RemoveDecisionMachine, _prosopo_types.RemoveDecisionMachineBody.parse({ id }), { headers: {
272
+ "Prosopo-Site-Key": this.account,
273
+ Authorization: `Bearer ${jwt}`
274
+ } });
275
+ }
276
+ removeAllDecisionMachines(jwt) {
277
+ return this.post(_prosopo_types.AdminApiPaths.RemoveAllDecisionMachines, _prosopo_types.RemoveAllDecisionMachinesBody.parse({}), { headers: {
278
+ "Prosopo-Site-Key": this.account,
279
+ Authorization: `Bearer ${jwt}`
280
+ } });
281
+ }
282
+ clearAllCounters(jwt, dappAccount) {
283
+ return this.post(_prosopo_types.AdminApiPaths.ClearAllCounters, _prosopo_types.ClearAllCountersBody.parse({ [_prosopo_types.ApiParams.dapp]: dappAccount }), { headers: {
284
+ "Prosopo-Site-Key": this.account,
285
+ Authorization: `Bearer ${jwt}`
286
+ } });
287
+ }
288
+ removeDetectorKey(detectorKey, jwt, expirationInSeconds) {
289
+ return this.post(_prosopo_types.AdminApiPaths.RemoveDetectorKey, _prosopo_types.RemoveDetectorKeyBodySpec.parse({
290
+ detectorKey,
291
+ expirationInSeconds
292
+ }), { headers: {
293
+ "Prosopo-Site-Key": this.account,
294
+ Authorization: `Bearer ${jwt}`
295
+ } });
296
+ }
297
+ toggleMaintenanceMode(enabled, timestamp, signature) {
298
+ return this.post(_prosopo_types.AdminApiPaths.ToggleMaintenanceMode, _prosopo_types.ToggleMaintenanceModeBody.parse({ enabled }), { headers: {
299
+ "Prosopo-Site-Key": this.account,
300
+ timestamp,
301
+ signature
302
+ } });
303
+ }
304
+ };
305
+ //#endregion
431
306
  exports.VERIFY_FORWARDED_HEADER = VERIFY_FORWARDED_HEADER;
432
307
  exports.default = ProviderApi;