@prosopo/api 3.5.18 → 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.
- package/.turbo/turbo-build$colon$cjs.log +14 -14
- package/.turbo/turbo-build$colon$tsc.log +9 -9
- package/.turbo/turbo-build.log +16 -13
- package/CHANGELOG.md +15 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/api/HttpClientBase.js +68 -81
- package/dist/api/HttpError.js +11 -11
- package/dist/api/ProviderApi.js +304 -430
- package/dist/api/apiClient.js +9 -9
- package/dist/api/index.js +3 -9
- package/dist/cjs/api/HttpClientBase.cjs +69 -81
- package/dist/cjs/api/HttpError.cjs +11 -11
- package/dist/cjs/api/ProviderApi.cjs +305 -430
- package/dist/cjs/api/apiClient.cjs +10 -10
- package/dist/cjs/api/index.cjs +9 -11
- package/dist/cjs/index.cjs +9 -11
- package/dist/index.js +4 -10
- package/package.json +6 -6
package/dist/api/ProviderApi.js
CHANGED
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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 };
|