@prosopo/api 3.5.19 → 3.5.20

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