@prosopo/provider 2.9.8 → 3.0.6
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/CHANGELOG.md +186 -0
- package/dist/api/admin/apiRegisterSiteKeyEndpoint.d.ts.map +1 -1
- package/dist/api/admin/apiRegisterSiteKeyEndpoint.js +4 -4
- package/dist/api/admin/apiRegisterSiteKeyEndpoint.js.map +1 -1
- package/dist/api/admin/apiRemoveDetectorKeyEndpoint.d.ts.map +1 -1
- package/dist/api/admin/apiRemoveDetectorKeyEndpoint.js +5 -5
- package/dist/api/admin/apiRemoveDetectorKeyEndpoint.js.map +1 -1
- package/dist/api/admin/apiUpdateDetectorKeyEndpoint.d.ts.map +1 -1
- package/dist/api/admin/apiUpdateDetectorKeyEndpoint.js +5 -5
- package/dist/api/admin/apiUpdateDetectorKeyEndpoint.js.map +1 -1
- package/dist/api/blacklistRequestInspector.d.ts +6 -8
- package/dist/api/blacklistRequestInspector.d.ts.map +1 -1
- package/dist/api/blacklistRequestInspector.js +38 -20
- package/dist/api/blacklistRequestInspector.js.map +1 -1
- package/dist/api/block.d.ts.map +1 -1
- package/dist/api/block.js +5 -5
- package/dist/api/block.js.map +1 -1
- package/dist/api/captcha.d.ts.map +1 -1
- package/dist/api/captcha.js +114 -24
- package/dist/api/captcha.js.map +1 -1
- package/dist/api/domainMiddleware.d.ts.map +1 -1
- package/dist/api/domainMiddleware.js +3 -3
- package/dist/api/domainMiddleware.js.map +1 -1
- package/dist/api/headerCheckMiddleware.js +2 -2
- package/dist/api/headerCheckMiddleware.js.map +1 -1
- package/dist/api/ja4Middleware.d.ts.map +1 -1
- package/dist/api/ja4Middleware.js +18 -6
- package/dist/api/ja4Middleware.js.map +1 -1
- package/dist/api/public.d.ts +1 -2
- package/dist/api/public.d.ts.map +1 -1
- package/dist/api/public.js +9 -4
- package/dist/api/public.js.map +1 -1
- package/dist/api/validateAddress.d.ts +2 -2
- package/dist/api/validateAddress.d.ts.map +1 -1
- package/dist/api/validateAddress.js +10 -4
- package/dist/api/validateAddress.js.map +1 -1
- package/dist/api/verify.d.ts.map +1 -1
- package/dist/api/verify.js +8 -7
- package/dist/api/verify.js.map +1 -1
- package/dist/cjs/api/admin/apiRegisterSiteKeyEndpoint.cjs +3 -3
- package/dist/cjs/api/admin/apiRemoveDetectorKeyEndpoint.cjs +4 -4
- package/dist/cjs/api/admin/apiUpdateDetectorKeyEndpoint.cjs +4 -4
- package/dist/cjs/api/blacklistRequestInspector.cjs +36 -21
- package/dist/cjs/api/block.cjs +4 -5
- package/dist/cjs/api/captcha.cjs +116 -39
- package/dist/cjs/api/domainMiddleware.cjs +3 -3
- package/dist/cjs/api/headerCheckMiddleware.cjs +1 -1
- package/dist/cjs/api/ja4Middleware.cjs +17 -8
- package/dist/cjs/api/public.cjs +9 -4
- package/dist/cjs/api/validateAddress.cjs +12 -6
- package/dist/cjs/api/verify.cjs +13 -12
- package/dist/cjs/index.cjs +1 -5
- package/dist/cjs/schedulers/captchaScheduler.cjs +11 -7
- package/dist/cjs/schedulers/getClientList.cjs +12 -5
- package/dist/cjs/tasks/captchaManager.cjs +76 -23
- package/dist/cjs/tasks/client/clientTasks.cjs +25 -19
- package/dist/cjs/tasks/detection/decodePayload.cjs +284 -362
- package/dist/cjs/tasks/frictionless/frictionlessTasks.cjs +32 -25
- package/dist/cjs/tasks/imgCaptcha/imgCaptchaTasks.cjs +37 -26
- package/dist/cjs/tasks/powCaptcha/powTasks.cjs +19 -18
- package/dist/cjs/tasks/powCaptcha/powTasksUtils.cjs +5 -3
- package/dist/cjs/tasks/tasks.cjs +11 -2
- package/dist/cjs/util.cjs +58 -8
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/schedulers/captchaScheduler.d.ts +1 -1
- package/dist/schedulers/captchaScheduler.d.ts.map +1 -1
- package/dist/schedulers/captchaScheduler.js +11 -3
- package/dist/schedulers/captchaScheduler.js.map +1 -1
- package/dist/schedulers/getClientList.d.ts +1 -1
- package/dist/schedulers/getClientList.d.ts.map +1 -1
- package/dist/schedulers/getClientList.js +12 -3
- package/dist/schedulers/getClientList.js.map +1 -1
- package/dist/tasks/captchaManager.d.ts +14 -1
- package/dist/tasks/captchaManager.d.ts.map +1 -1
- package/dist/tasks/captchaManager.js +67 -24
- package/dist/tasks/captchaManager.js.map +1 -1
- package/dist/tasks/client/clientTasks.d.ts.map +1 -1
- package/dist/tasks/client/clientTasks.js +26 -18
- package/dist/tasks/client/clientTasks.js.map +1 -1
- package/dist/tasks/detection/decodePayload.d.ts +2 -2
- package/dist/tasks/detection/decodePayload.d.ts.map +1 -1
- package/dist/tasks/detection/decodePayload.js +184 -230
- package/dist/tasks/detection/decodePayload.js.map +1 -1
- package/dist/tasks/frictionless/frictionlessTasks.d.ts +4 -5
- package/dist/tasks/frictionless/frictionlessTasks.d.ts.map +1 -1
- package/dist/tasks/frictionless/frictionlessTasks.js +32 -24
- package/dist/tasks/frictionless/frictionlessTasks.js.map +1 -1
- package/dist/tasks/imgCaptcha/imgCaptchaTasks.d.ts +1 -1
- package/dist/tasks/imgCaptcha/imgCaptchaTasks.d.ts.map +1 -1
- package/dist/tasks/imgCaptcha/imgCaptchaTasks.js +38 -25
- package/dist/tasks/imgCaptcha/imgCaptchaTasks.js.map +1 -1
- package/dist/tasks/powCaptcha/powTasks.d.ts +1 -1
- package/dist/tasks/powCaptcha/powTasks.d.ts.map +1 -1
- package/dist/tasks/powCaptcha/powTasks.js +17 -18
- package/dist/tasks/powCaptcha/powTasks.js.map +1 -1
- package/dist/tasks/powCaptcha/powTasksUtils.d.ts +1 -1
- package/dist/tasks/powCaptcha/powTasksUtils.d.ts.map +1 -1
- package/dist/tasks/powCaptcha/powTasksUtils.js +5 -3
- package/dist/tasks/powCaptcha/powTasksUtils.js.map +1 -1
- package/dist/tasks/tasks.d.ts +3 -2
- package/dist/tasks/tasks.d.ts.map +1 -1
- package/dist/tasks/tasks.js +13 -3
- package/dist/tasks/tasks.js.map +1 -1
- package/dist/tests/integration/imgCaptcha.integration.test.js +3 -2
- package/dist/tests/integration/imgCaptcha.integration.test.js.map +1 -1
- package/dist/tests/integration/powCaptcha.integration.test.js +9 -9
- package/dist/tests/integration/powCaptcha.integration.test.js.map +1 -1
- package/dist/tests/integration/registerSitekey.d.ts.map +1 -1
- package/dist/tests/integration/registerSitekey.js +13 -2
- package/dist/tests/integration/registerSitekey.js.map +1 -1
- package/dist/tests/unit/api/ignoreMiddleware.unit.test.d.ts +2 -0
- package/dist/tests/unit/api/ignoreMiddleware.unit.test.d.ts.map +1 -0
- package/dist/tests/unit/api/ignoreMiddleware.unit.test.js +43 -0
- package/dist/tests/unit/api/ignoreMiddleware.unit.test.js.map +1 -0
- package/dist/tests/unit/api/ja4Middleware.unit.test.js +18 -4
- package/dist/tests/unit/api/ja4Middleware.unit.test.js.map +1 -1
- package/dist/tests/unit/schedulers/captchaScheduler.unit.test.js +30 -18
- package/dist/tests/unit/schedulers/captchaScheduler.unit.test.js.map +1 -1
- package/dist/tests/unit/tasks/captchaManager.unit.test.js +11 -5
- package/dist/tests/unit/tasks/captchaManager.unit.test.js.map +1 -1
- package/dist/tests/unit/tasks/client/clientTasks.unit.test.js +43 -19
- package/dist/tests/unit/tasks/client/clientTasks.unit.test.js.map +1 -1
- package/dist/tests/unit/tasks/dataset/datasetTasks.unit.test.js +11 -4
- package/dist/tests/unit/tasks/dataset/datasetTasks.unit.test.js.map +1 -1
- package/dist/tests/unit/tasks/frictionless/frictionlessTasks.unit.test.js +9 -8
- package/dist/tests/unit/tasks/frictionless/frictionlessTasks.unit.test.js.map +1 -1
- package/dist/tests/unit/tasks/imgCaptcha/imgCaptchaTasks.unit.test.js +29 -10
- package/dist/tests/unit/tasks/imgCaptcha/imgCaptchaTasks.unit.test.js.map +1 -1
- package/dist/tests/unit/tasks/powCaptcha/powTasks.unit.test.js +2 -3
- package/dist/tests/unit/tasks/powCaptcha/powTasks.unit.test.js.map +1 -1
- package/dist/tests/unit/tasks/powCaptcha/powTasksUtils.unit.test.js +4 -2
- package/dist/tests/unit/tasks/powCaptcha/powTasksUtils.unit.test.js.map +1 -1
- package/dist/tests/unit/util.unit.test.js +110 -2
- package/dist/tests/unit/util.unit.test.js.map +1 -1
- package/dist/util.d.ts +5 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +57 -5
- package/dist/util.js.map +1 -1
- package/package.json +24 -20
- package/vite.test.config.ts +1 -1
- package/dist/api/authMiddleware.d.ts +0 -6
- package/dist/api/authMiddleware.d.ts.map +0 -1
- package/dist/api/authMiddleware.js +0 -82
- package/dist/api/authMiddleware.js.map +0 -1
- package/dist/api/requestLoggerMiddleware.d.ts +0 -4
- package/dist/api/requestLoggerMiddleware.d.ts.map +0 -1
- package/dist/api/requestLoggerMiddleware.js +0 -12
- package/dist/api/requestLoggerMiddleware.js.map +0 -1
- package/dist/cjs/api/authMiddleware.cjs +0 -81
- package/dist/cjs/api/requestLoggerMiddleware.cjs +0 -14
- package/dist/tests/unit/api/authMiddleware.unit.test.d.ts +0 -2
- package/dist/tests/unit/api/authMiddleware.unit.test.d.ts.map +0 -1
- package/dist/tests/unit/api/authMiddleware.unit.test.js +0 -125
- package/dist/tests/unit/api/authMiddleware.unit.test.js.map +0 -1
|
@@ -40,12 +40,12 @@ class FrictionlessManager extends captchaManager.CaptchaManager {
|
|
|
40
40
|
[types.ApiParams.status]: "ok"
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
async scoreIncreaseAccessPolicy(
|
|
44
|
-
const accessPolicyPenalty =
|
|
43
|
+
async scoreIncreaseAccessPolicy(accessPolicy, baseBotScore, botScore, tokenId) {
|
|
44
|
+
const accessPolicyPenalty = accessPolicy?.frictionlessScore || this.config.penalties.PENALTY_ACCESS_RULE;
|
|
45
45
|
botScore += accessPolicyPenalty;
|
|
46
|
-
this.logger.info({
|
|
47
|
-
|
|
48
|
-
});
|
|
46
|
+
this.logger.info(() => ({
|
|
47
|
+
msg: "Address has an image captcha config defined"
|
|
48
|
+
}));
|
|
49
49
|
await this.db.updateFrictionlessTokenRecord(tokenId, {
|
|
50
50
|
score: botScore,
|
|
51
51
|
scoreComponents: {
|
|
@@ -56,7 +56,10 @@ class FrictionlessManager extends captchaManager.CaptchaManager {
|
|
|
56
56
|
return botScore;
|
|
57
57
|
}
|
|
58
58
|
async scoreIncreaseTimestamp(timestamp, baseBotScore, botScore, tokenId) {
|
|
59
|
-
this.logger.info(
|
|
59
|
+
this.logger.info(() => ({
|
|
60
|
+
msg: "Timestamp is older than 10 minutes",
|
|
61
|
+
data: { timestamp: new Date(timestamp) }
|
|
62
|
+
}));
|
|
60
63
|
botScore += this.config.penalties.PENALTY_OLD_TIMESTAMP;
|
|
61
64
|
await this.db.updateFrictionlessTokenRecord(tokenId, {
|
|
62
65
|
score: botScore,
|
|
@@ -77,41 +80,45 @@ class FrictionlessManager extends captchaManager.CaptchaManager {
|
|
|
77
80
|
process.env.BOT_DECRYPTION_KEY,
|
|
78
81
|
...await this.getDetectorKeys()
|
|
79
82
|
].filter((k) => k);
|
|
80
|
-
this.logger.debug({
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
this.logger.debug(() => ({
|
|
84
|
+
msg: "Decrypting score",
|
|
85
|
+
data: {
|
|
86
|
+
keysLength: decryptKeys.length,
|
|
87
|
+
keys: decryptKeys.map(
|
|
88
|
+
(k) => k ? `${k.slice(0, 5)}...${k.slice(-5)}` || "" : ""
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
87
92
|
let baseBotScore;
|
|
88
93
|
let timestamp;
|
|
89
94
|
for (const [keyIndex, key] of decryptKeys.entries()) {
|
|
90
95
|
try {
|
|
91
96
|
const { baseBotScore: s, timestamp: t } = await getBotScore.getBotScore(token, key);
|
|
92
|
-
this.logger.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
this.logger.info(() => ({
|
|
98
|
+
msg: "Successfully decrypted score",
|
|
99
|
+
data: {
|
|
100
|
+
key: key ? `${key.slice(0, 5)}...${key.slice(-5)}` : "",
|
|
101
|
+
baseBotScore: s,
|
|
102
|
+
timestamp: t
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
98
105
|
baseBotScore = s;
|
|
99
106
|
timestamp = t;
|
|
100
107
|
break;
|
|
101
108
|
} catch (err) {
|
|
102
109
|
if (keyIndex === decryptKeys.length - 1) {
|
|
103
|
-
this.logger.warn({
|
|
104
|
-
|
|
105
|
-
});
|
|
110
|
+
this.logger.warn(() => ({
|
|
111
|
+
msg: "Error decrypting score: no more keys to try"
|
|
112
|
+
}));
|
|
106
113
|
baseBotScore = 1;
|
|
107
114
|
timestamp = 0;
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
118
|
if (baseBotScore === void 0 || timestamp === void 0) {
|
|
112
|
-
this.logger.error({
|
|
113
|
-
|
|
114
|
-
});
|
|
119
|
+
this.logger.error(() => ({
|
|
120
|
+
msg: "Error decrypting score: baseBotScore or timestamp is undefined"
|
|
121
|
+
}));
|
|
115
122
|
baseBotScore = 1;
|
|
116
123
|
timestamp = 0;
|
|
117
124
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const util$1 = require("@polkadot/util");
|
|
4
|
-
const utilCrypto = require("@polkadot/util-crypto");
|
|
5
4
|
const common = require("@prosopo/common");
|
|
6
5
|
const datasets = require("@prosopo/datasets");
|
|
7
6
|
const types = require("@prosopo/types");
|
|
8
7
|
const util$2 = require("@prosopo/util");
|
|
8
|
+
const utilCrypto = require("@prosopo/util-crypto");
|
|
9
9
|
const lang = require("../../rules/lang.cjs");
|
|
10
10
|
const util = require("../../util.cjs");
|
|
11
11
|
const captchaManager = require("../captchaManager.cjs");
|
|
@@ -110,10 +110,14 @@ class ImgCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
110
110
|
userAccount
|
|
111
111
|
);
|
|
112
112
|
if (!verification.isValid) {
|
|
113
|
-
|
|
114
|
-
throw new common.ProsopoEnvError("GENERAL.INVALID_SIGNATURE", {
|
|
113
|
+
const err = new common.ProsopoEnvError("GENERAL.INVALID_SIGNATURE", {
|
|
115
114
|
context: { failedFuncName: this.dappUserSolution.name, userAccount }
|
|
116
115
|
});
|
|
116
|
+
this.logger.info(() => ({
|
|
117
|
+
err,
|
|
118
|
+
msg: "Invalid user timestamp signature"
|
|
119
|
+
}));
|
|
120
|
+
throw err;
|
|
117
121
|
}
|
|
118
122
|
const providerRequestHashSignatureVerify = utilCrypto.signatureVerify(
|
|
119
123
|
util$1.stringToHex(requestHash.toString()),
|
|
@@ -121,14 +125,18 @@ class ImgCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
121
125
|
this.pair.address
|
|
122
126
|
);
|
|
123
127
|
if (!providerRequestHashSignatureVerify.isValid) {
|
|
124
|
-
|
|
125
|
-
throw new common.ProsopoEnvError("GENERAL.INVALID_SIGNATURE", {
|
|
128
|
+
const err = new common.ProsopoEnvError("GENERAL.INVALID_SIGNATURE", {
|
|
126
129
|
context: {
|
|
127
130
|
failedFuncName: this.dappUserSolution.name,
|
|
128
131
|
userAccount,
|
|
129
132
|
error: "requestHash signature is invalid"
|
|
130
133
|
}
|
|
131
134
|
});
|
|
135
|
+
this.logger.info(() => ({
|
|
136
|
+
err,
|
|
137
|
+
msg: "Invalid provider requestHash signature"
|
|
138
|
+
}));
|
|
139
|
+
throw err;
|
|
132
140
|
}
|
|
133
141
|
let response = {
|
|
134
142
|
captchas: [],
|
|
@@ -211,7 +219,9 @@ class ImgCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
211
219
|
};
|
|
212
220
|
}
|
|
213
221
|
} else {
|
|
214
|
-
this.logger.info(
|
|
222
|
+
this.logger.info(() => ({
|
|
223
|
+
msg: "Request hash not found"
|
|
224
|
+
}));
|
|
215
225
|
}
|
|
216
226
|
return response;
|
|
217
227
|
}
|
|
@@ -253,11 +263,15 @@ class ImgCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
253
263
|
async validateDappUserSolutionRequestIsPending(requestHash, pendingRecord, userAccount, captchaIds) {
|
|
254
264
|
const currentTime = Date.now();
|
|
255
265
|
if (!pendingRecord) {
|
|
256
|
-
this.logger.info(
|
|
266
|
+
this.logger.info(() => ({
|
|
267
|
+
msg: "No pending record found"
|
|
268
|
+
}));
|
|
257
269
|
return false;
|
|
258
270
|
}
|
|
259
271
|
if (pendingRecord.deadlineTimestamp < currentTime) {
|
|
260
|
-
this.logger.info(
|
|
272
|
+
this.logger.info(() => ({
|
|
273
|
+
msg: "Deadline for responding to captcha has expired"
|
|
274
|
+
}));
|
|
261
275
|
return false;
|
|
262
276
|
}
|
|
263
277
|
if (pendingRecord) {
|
|
@@ -303,21 +317,14 @@ class ImgCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
303
317
|
async verifyImageCaptchaSolution(user, dapp, commitmentId, maxVerifiedTime, ip) {
|
|
304
318
|
const solution = await (commitmentId ? this.getDappUserCommitmentById(commitmentId) : this.getDappUserCommitmentByAccount(user, dapp));
|
|
305
319
|
if (!solution) {
|
|
306
|
-
this.logger.debug(
|
|
320
|
+
this.logger.debug(() => ({
|
|
321
|
+
msg: "Not verified - no solution found"
|
|
322
|
+
}));
|
|
307
323
|
return { status: "API.USER_NOT_VERIFIED_NO_SOLUTION", verified: false };
|
|
308
324
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.logger.debug(`Invalid IP address: ${ip}`);
|
|
313
|
-
return { status: "API.USER_NOT_VERIFIED", verified: false };
|
|
314
|
-
}
|
|
315
|
-
if (solution.ipAddress !== ipV4Address.bigInt()) {
|
|
316
|
-
this.logger.debug(
|
|
317
|
-
`IP address mismatch: ${util.getIPAddressFromBigInt(solution.ipAddress).address} !== ${ip}`
|
|
318
|
-
);
|
|
319
|
-
return { status: "API.USER_NOT_VERIFIED", verified: false };
|
|
320
|
-
}
|
|
325
|
+
const ipValidation = util.validateIpAddress(ip, solution.ipAddress, this.logger);
|
|
326
|
+
if (!ipValidation.isValid) {
|
|
327
|
+
return { status: "API.USER_NOT_VERIFIED", verified: false };
|
|
321
328
|
}
|
|
322
329
|
if (solution.serverChecked) {
|
|
323
330
|
return { status: "API.USER_ALREADY_VERIFIED", verified: false };
|
|
@@ -331,7 +338,9 @@ class ImgCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
331
338
|
const currentTime = Date.now();
|
|
332
339
|
const timeSinceCompletion = currentTime - solution.requestedAtTimestamp;
|
|
333
340
|
if (timeSinceCompletion > maxVerifiedTime) {
|
|
334
|
-
this.logger.debug(
|
|
341
|
+
this.logger.debug(() => ({
|
|
342
|
+
msg: "Not verified - timed out"
|
|
343
|
+
}));
|
|
335
344
|
return {
|
|
336
345
|
status: "API.USER_NOT_VERIFIED_TIME_EXPIRED",
|
|
337
346
|
verified: false
|
|
@@ -346,10 +355,12 @@ class ImgCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
346
355
|
);
|
|
347
356
|
if (tokenRecord) {
|
|
348
357
|
score = frictionlessTasksUtils.computeFrictionlessScore(tokenRecord?.scoreComponents);
|
|
349
|
-
this.logger.info({
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
358
|
+
this.logger.info(() => ({
|
|
359
|
+
data: {
|
|
360
|
+
tscoreComponents: tokenRecord?.scoreComponents,
|
|
361
|
+
score
|
|
362
|
+
}
|
|
363
|
+
}));
|
|
353
364
|
}
|
|
354
365
|
}
|
|
355
366
|
return {
|
|
@@ -65,7 +65,9 @@ class PowCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
65
65
|
);
|
|
66
66
|
const challengeRecord = await this.db.getPowCaptchaRecordByChallenge(challenge);
|
|
67
67
|
if (!challengeRecord) {
|
|
68
|
-
this.logger.debug(
|
|
68
|
+
this.logger.debug(() => ({
|
|
69
|
+
msg: `No record of this challenge: ${challenge}`
|
|
70
|
+
}));
|
|
69
71
|
return false;
|
|
70
72
|
}
|
|
71
73
|
if (!util$1.verifyRecency(challenge, timeout)) {
|
|
@@ -112,21 +114,18 @@ class PowCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
112
114
|
async serverVerifyPowCaptchaSolution(dappAccount, challenge, timeout, ip) {
|
|
113
115
|
const challengeRecord = await this.db.getPowCaptchaRecordByChallenge(challenge);
|
|
114
116
|
if (!challengeRecord) {
|
|
115
|
-
this.logger.debug(
|
|
117
|
+
this.logger.debug(() => ({
|
|
118
|
+
msg: `No record of this challenge: ${challenge}`
|
|
119
|
+
}));
|
|
116
120
|
return { verified: false };
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.logger.debug(
|
|
126
|
-
`IP address mismatch: ${util$2.getIPAddressFromBigInt(challengeRecord.ipAddress).address} !== ${ip}`
|
|
127
|
-
);
|
|
128
|
-
return { verified: false };
|
|
129
|
-
}
|
|
122
|
+
const ipValidation = util$2.validateIpAddress(
|
|
123
|
+
ip,
|
|
124
|
+
challengeRecord.ipAddress,
|
|
125
|
+
this.logger
|
|
126
|
+
);
|
|
127
|
+
if (!ipValidation.isValid) {
|
|
128
|
+
return { verified: false };
|
|
130
129
|
}
|
|
131
130
|
if (challengeRecord.result.status !== types.CaptchaStatus.approved) {
|
|
132
131
|
throw new common.ProsopoApiError("CAPTCHA.INVALID_SOLUTION", {
|
|
@@ -158,10 +157,12 @@ class PowCaptchaManager extends captchaManager.CaptchaManager {
|
|
|
158
157
|
);
|
|
159
158
|
if (tokenRecord) {
|
|
160
159
|
score = frictionlessTasksUtils.computeFrictionlessScore(tokenRecord?.scoreComponents);
|
|
161
|
-
this.logger.info({
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
this.logger.info(() => ({
|
|
161
|
+
data: {
|
|
162
|
+
tscoreComponents: { ...tokenRecord?.scoreComponents || {} },
|
|
163
|
+
score
|
|
164
|
+
}
|
|
165
|
+
}));
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
return { verified: true, ...score ? { score } : {} };
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const sha256 = require("@noble/hashes/sha256");
|
|
4
4
|
const util = require("@polkadot/util");
|
|
5
|
-
const utilCrypto = require("@polkadot/util-crypto");
|
|
6
5
|
const common = require("@prosopo/common");
|
|
6
|
+
const utilCrypto = require("@prosopo/util-crypto");
|
|
7
7
|
const validateSolution = (nonce, challenge, difficulty) => Array.from(sha256.sha256(new TextEncoder().encode(nonce + challenge))).map((byte) => byte.toString(16).padStart(2, "0")).join("").startsWith("0".repeat(difficulty));
|
|
8
|
-
const checkPowSignature = (
|
|
8
|
+
const checkPowSignature = (message, signature, address, signatureType) => {
|
|
9
9
|
const signatureVerification = utilCrypto.signatureVerify(
|
|
10
|
-
util.stringToHex(
|
|
10
|
+
util.stringToHex(message),
|
|
11
11
|
signature,
|
|
12
12
|
address
|
|
13
13
|
);
|
|
@@ -16,6 +16,8 @@ const checkPowSignature = (challenge, signature, address, signatureType) => {
|
|
|
16
16
|
context: {
|
|
17
17
|
ERROR: `Signature is invalid for this message: ${signatureType}`,
|
|
18
18
|
failedFuncName: checkPowSignature.name,
|
|
19
|
+
address,
|
|
20
|
+
message,
|
|
19
21
|
signature,
|
|
20
22
|
signatureType
|
|
21
23
|
}
|
package/dist/cjs/tasks/tasks.cjs
CHANGED
|
@@ -7,11 +7,11 @@ const frictionlessTasks = require("./frictionless/frictionlessTasks.cjs");
|
|
|
7
7
|
const imgCaptchaTasks = require("./imgCaptcha/imgCaptchaTasks.cjs");
|
|
8
8
|
const powTasks = require("./powCaptcha/powTasks.cjs");
|
|
9
9
|
class Tasks {
|
|
10
|
-
constructor(env) {
|
|
10
|
+
constructor(env, logger) {
|
|
11
11
|
this.config = env.config;
|
|
12
12
|
this.db = env.getDb();
|
|
13
13
|
this.captchaConfig = env.config.captchas;
|
|
14
|
-
this.logger = common.getLogger(env.config.logLevel, "Tasks");
|
|
14
|
+
this.logger = logger || common.getLogger(common.parseLogLevel(env.config.logLevel), "Tasks");
|
|
15
15
|
if (!env.pair) {
|
|
16
16
|
throw new common.ProsopoEnvError("DEVELOPER.MISSING_PROVIDER_PAIR", {
|
|
17
17
|
context: { failedFuncName: "Tasks.constructor" }
|
|
@@ -47,5 +47,14 @@ class Tasks {
|
|
|
47
47
|
this.logger
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
+
setLogger(logger) {
|
|
51
|
+
this.logger = logger;
|
|
52
|
+
this.powCaptchaManager.logger = logger;
|
|
53
|
+
this.datasetManager.logger = logger;
|
|
54
|
+
this.imgCaptchaManager.logger = logger;
|
|
55
|
+
this.clientTaskManager.logger = logger;
|
|
56
|
+
this.frictionlessManager.logger = logger;
|
|
57
|
+
this.db.logger = logger;
|
|
58
|
+
}
|
|
50
59
|
}
|
|
51
60
|
exports.Tasks = Tasks;
|
package/dist/cjs/util.cjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const address = require("@polkadot/util-crypto/address");
|
|
4
3
|
const hex = require("@polkadot/util/hex");
|
|
5
4
|
const is = require("@polkadot/util/is");
|
|
6
5
|
const common = require("@prosopo/common");
|
|
7
6
|
const types = require("@prosopo/types");
|
|
8
7
|
const util = require("@prosopo/util");
|
|
8
|
+
const utilCrypto = require("@prosopo/util-crypto");
|
|
9
9
|
const ipAddress = require("ip-address");
|
|
10
|
-
function encodeStringAddress(address
|
|
10
|
+
function encodeStringAddress(address) {
|
|
11
11
|
try {
|
|
12
|
-
return
|
|
13
|
-
is.isHex(address
|
|
12
|
+
return utilCrypto.encodeAddress(
|
|
13
|
+
is.isHex(address) ? hex.hexToU8a(address) : utilCrypto.decodeAddress(address)
|
|
14
14
|
);
|
|
15
15
|
} catch (err) {
|
|
16
16
|
throw new common.ProsopoContractError("CONTRACT.INVALID_ADDRESS", {
|
|
17
|
-
context: { address
|
|
17
|
+
context: { address }
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -44,19 +44,69 @@ async function checkIfTaskIsRunning(taskName, db) {
|
|
|
44
44
|
}
|
|
45
45
|
const getIPAddress = (ipAddressString) => {
|
|
46
46
|
try {
|
|
47
|
-
|
|
47
|
+
try {
|
|
48
48
|
return new ipAddress.Address4(ipAddressString);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return new ipAddress.Address6(ipAddressString);
|
|
49
51
|
}
|
|
50
|
-
return new ipAddress.Address6(ipAddressString);
|
|
51
52
|
} catch (e) {
|
|
52
53
|
throw new common.ProsopoEnvError("API.INVALID_IP");
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
const getIPAddressFromBigInt = (ipAddressBigInt) => {
|
|
56
|
-
|
|
57
|
+
try {
|
|
58
|
+
if (ipAddressBigInt > 4228250626n) {
|
|
59
|
+
return ipAddress.Address6.fromBigInt(BigInt(ipAddressBigInt));
|
|
60
|
+
}
|
|
61
|
+
return ipAddress.Address4.fromBigInt(BigInt(ipAddressBigInt));
|
|
62
|
+
} catch (e) {
|
|
63
|
+
throw new common.ProsopoEnvError("API.INVALID_IP");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const validateIpAddress = (ip, challengeRecordIpAddress, logger) => {
|
|
67
|
+
if (!ip) {
|
|
68
|
+
return { isValid: true };
|
|
69
|
+
}
|
|
70
|
+
let ipV4orV6Address;
|
|
71
|
+
try {
|
|
72
|
+
ipV4orV6Address = getIPAddress(ip);
|
|
73
|
+
logger.info(() => ({ data: { ipV4orV6Address } }));
|
|
74
|
+
} catch (e) {
|
|
75
|
+
const errorMessage = `Invalid IP address: ${ip}`;
|
|
76
|
+
logger.info(() => ({ msg: errorMessage }));
|
|
77
|
+
return { isValid: false, errorMessage };
|
|
78
|
+
}
|
|
79
|
+
let challengeIpV4orV6Address = getIPAddressFromBigInt(
|
|
80
|
+
challengeRecordIpAddress
|
|
81
|
+
);
|
|
82
|
+
ipV4orV6Address = "address4" in ipV4orV6Address && ipV4orV6Address.address4 ? ipV4orV6Address.address4 : ipV4orV6Address;
|
|
83
|
+
challengeIpV4orV6Address = "address4" in challengeIpV4orV6Address && challengeIpV4orV6Address.address4 ? challengeIpV4orV6Address.address4 : challengeIpV4orV6Address;
|
|
84
|
+
if (ipV4orV6Address.v4 && !challengeIpV4orV6Address.v4) {
|
|
85
|
+
challengeIpV4orV6Address = new ipAddress.Address4(
|
|
86
|
+
challengeIpV4orV6Address.to4().correctForm()
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
if (!ipV4orV6Address.v4 && challengeIpV4orV6Address.v4) {
|
|
90
|
+
ipV4orV6Address = new ipAddress.Address6(
|
|
91
|
+
ipV4orV6Address.to4().correctForm()
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (challengeIpV4orV6Address.bigInt() - ipV4orV6Address.bigInt() !== 0n) {
|
|
95
|
+
const errorMessage = `IP address mismatch: ${challengeIpV4orV6Address.address} !== ${ipV4orV6Address.address}`;
|
|
96
|
+
logger.info(() => ({
|
|
97
|
+
msg: errorMessage,
|
|
98
|
+
data: {
|
|
99
|
+
challengeIp: challengeIpV4orV6Address.address,
|
|
100
|
+
providedIp: ipV4orV6Address.address
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
103
|
+
return { isValid: false, errorMessage };
|
|
104
|
+
}
|
|
105
|
+
return { isValid: true };
|
|
57
106
|
};
|
|
58
107
|
exports.checkIfTaskIsRunning = checkIfTaskIsRunning;
|
|
59
108
|
exports.encodeStringAddress = encodeStringAddress;
|
|
60
109
|
exports.getIPAddress = getIPAddress;
|
|
61
110
|
exports.getIPAddressFromBigInt = getIPAddressFromBigInt;
|
|
62
111
|
exports.shuffleArray = shuffleArray;
|
|
112
|
+
exports.validateIpAddress = validateIpAddress;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from "./util.js";
|
|
|
3
3
|
export * from "./api/block.js";
|
|
4
4
|
export * from "./api/captcha.js";
|
|
5
5
|
export * from "./api/verify.js";
|
|
6
|
-
export * from "./api/authMiddleware.js";
|
|
7
6
|
export * from "./api/ja4Middleware.js";
|
|
8
7
|
export * from "./api/public.js";
|
|
9
8
|
export * from "./api/domainMiddleware.js";
|
|
@@ -11,7 +10,6 @@ export * from "./schedulers/captchaScheduler.js";
|
|
|
11
10
|
export * from "./schedulers/getClientList.js";
|
|
12
11
|
export * from "./api/headerCheckMiddleware.js";
|
|
13
12
|
export * from "./api/admin/createApiAdminRoutesProvider.js";
|
|
14
|
-
export * from "./api/requestLoggerMiddleware.js";
|
|
15
13
|
export * from "./api/ignoreMiddleware.js";
|
|
16
14
|
export * from "./api/robotsMiddleware.js";
|
|
17
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ export * from "./util.js";
|
|
|
3
3
|
export * from "./api/block.js";
|
|
4
4
|
export * from "./api/captcha.js";
|
|
5
5
|
export * from "./api/verify.js";
|
|
6
|
-
export * from "./api/authMiddleware.js";
|
|
7
6
|
export * from "./api/ja4Middleware.js";
|
|
8
7
|
export * from "./api/public.js";
|
|
9
8
|
export * from "./api/domainMiddleware.js";
|
|
@@ -11,7 +10,6 @@ export * from "./schedulers/captchaScheduler.js";
|
|
|
11
10
|
export * from "./schedulers/getClientList.js";
|
|
12
11
|
export * from "./api/headerCheckMiddleware.js";
|
|
13
12
|
export * from "./api/admin/createApiAdminRoutesProvider.js";
|
|
14
|
-
export * from "./api/requestLoggerMiddleware.js";
|
|
15
13
|
export * from "./api/ignoreMiddleware.js";
|
|
16
14
|
export * from "./api/robotsMiddleware.js";
|
|
17
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KeyringPair } from "@
|
|
1
|
+
import type { KeyringPair } from "@prosopo/types";
|
|
2
2
|
import { type ProsopoConfigOutput } from "@prosopo/types";
|
|
3
3
|
export declare function storeCaptchasExternally(pair: KeyringPair, cronSchedule: string, config: ProsopoConfigOutput): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=captchaScheduler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captchaScheduler.d.ts","sourceRoot":"","sources":["../../src/schedulers/captchaScheduler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"captchaScheduler.d.ts","sourceRoot":"","sources":["../../src/schedulers/captchaScheduler.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,mBAAmB,EAAsB,MAAM,gBAAgB,CAAC;AAK9E,wBAAsB,uBAAuB,CAC5C,IAAI,EAAE,WAAW,EACjB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,mBAAmB,iBA8B3B"}
|
|
@@ -9,11 +9,19 @@ export async function storeCaptchasExternally(pair, cronSchedule, config) {
|
|
|
9
9
|
const tasks = new Tasks(env);
|
|
10
10
|
const job = new CronJob(cronSchedule, async () => {
|
|
11
11
|
const taskRunning = await checkIfTaskIsRunning(ScheduledTaskNames.StoreCommitmentsExternal, env.getDb());
|
|
12
|
-
env.logger.info(
|
|
12
|
+
env.logger.info(() => ({
|
|
13
|
+
data: { taskRunning },
|
|
14
|
+
msg: `${ScheduledTaskNames.StoreCommitmentsExternal} task running: ${taskRunning}`,
|
|
15
|
+
}));
|
|
13
16
|
if (!taskRunning) {
|
|
14
|
-
env.logger.info(
|
|
17
|
+
env.logger.info(() => ({
|
|
18
|
+
msg: `${ScheduledTaskNames.StoreCommitmentsExternal} task....`,
|
|
19
|
+
}));
|
|
15
20
|
await tasks.clientTaskManager.storeCommitmentsExternal().catch((err) => {
|
|
16
|
-
env.logger.error(
|
|
21
|
+
env.logger.error(() => ({
|
|
22
|
+
err,
|
|
23
|
+
msg: "Error storing commitments externally",
|
|
24
|
+
}));
|
|
17
25
|
});
|
|
18
26
|
}
|
|
19
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captchaScheduler.js","sourceRoot":"","sources":["../../src/schedulers/captchaScheduler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"captchaScheduler.js","sourceRoot":"","sources":["../../src/schedulers/captchaScheduler.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAA4B,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC5C,IAAiB,EACjB,YAAoB,EACpB,MAA2B;IAE3B,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;IAEpB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IAE7B,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAC7C,kBAAkB,CAAC,wBAAwB,EAC3C,GAAG,CAAC,KAAK,EAAE,CACX,CAAC;QACF,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YACtB,IAAI,EAAE,EAAE,WAAW,EAAE;YACrB,GAAG,EAAE,GAAG,kBAAkB,CAAC,wBAAwB,kBAAkB,WAAW,EAAE;SAClF,CAAC,CAAC,CAAC;QACJ,IAAI,CAAC,WAAW,EAAE,CAAC;YAClB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;gBACtB,GAAG,EAAE,GAAG,kBAAkB,CAAC,wBAAwB,WAAW;aAC9D,CAAC,CAAC,CAAC;YACJ,MAAM,KAAK,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACtE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;oBACvB,GAAG;oBACH,GAAG,EAAE,sCAAsC;iBAC3C,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,KAAK,EAAE,CAAC;AACb,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KeyringPair } from "@
|
|
1
|
+
import type { KeyringPair } from "@prosopo/types";
|
|
2
2
|
import { type ProsopoConfigOutput } from "@prosopo/types";
|
|
3
3
|
export declare function getClientList(pair: KeyringPair, cronSchedule: string, config: ProsopoConfigOutput): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=getClientList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getClientList.d.ts","sourceRoot":"","sources":["../../src/schedulers/getClientList.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getClientList.d.ts","sourceRoot":"","sources":["../../src/schedulers/getClientList.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,mBAAmB,EAAsB,MAAM,gBAAgB,CAAC;AAW9E,wBAAsB,aAAa,CAClC,IAAI,EAAE,WAAW,EACjB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,mBAAmB,iBA+B3B"}
|
|
@@ -9,11 +9,20 @@ export async function getClientList(pair, cronSchedule, config) {
|
|
|
9
9
|
const tasks = new Tasks(env);
|
|
10
10
|
const job = new CronJob(cronSchedule, async () => {
|
|
11
11
|
const taskRunning = await checkIfTaskIsRunning(ScheduledTaskNames.GetClientList, env.getDb());
|
|
12
|
-
env.logger.info(
|
|
12
|
+
env.logger.info(() => ({
|
|
13
|
+
msg: `${ScheduledTaskNames.GetClientList} task running: ${taskRunning}`,
|
|
14
|
+
data: { taskRunning },
|
|
15
|
+
}));
|
|
13
16
|
if (!taskRunning) {
|
|
14
|
-
env.logger.info(
|
|
17
|
+
env.logger.info(() => ({
|
|
18
|
+
msg: `${ScheduledTaskNames.GetClientList} task....`,
|
|
19
|
+
data: {},
|
|
20
|
+
}));
|
|
15
21
|
await tasks.clientTaskManager.getClientList().catch((err) => {
|
|
16
|
-
env.logger.error(
|
|
22
|
+
env.logger.error(() => ({
|
|
23
|
+
err,
|
|
24
|
+
msg: "Error getting client list",
|
|
25
|
+
}));
|
|
17
26
|
});
|
|
18
27
|
}
|
|
19
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getClientList.js","sourceRoot":"","sources":["../../src/schedulers/getClientList.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getClientList.js","sourceRoot":"","sources":["../../src/schedulers/getClientList.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAA4B,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAQlD,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,IAAiB,EACjB,YAAoB,EACpB,MAA2B;IAE3B,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;IAEpB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IAE7B,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAC7C,kBAAkB,CAAC,aAAa,EAChC,GAAG,CAAC,KAAK,EAAE,CACX,CAAC;QACF,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YACtB,GAAG,EAAE,GAAG,kBAAkB,CAAC,aAAa,kBAAkB,WAAW,EAAE;YACvE,IAAI,EAAE,EAAE,WAAW,EAAE;SACrB,CAAC,CAAC,CAAC;QACJ,IAAI,CAAC,WAAW,EAAE,CAAC;YAClB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;gBACtB,GAAG,EAAE,GAAG,kBAAkB,CAAC,aAAa,WAAW;gBACnD,IAAI,EAAE,EAAE;aACR,CAAC,CAAC,CAAC;YACJ,MAAM,KAAK,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC3D,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;oBACvB,GAAG;oBACH,GAAG,EAAE,2BAA2B;iBAChC,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,KAAK,EAAE,CAAC;AACb,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { KeyringPair } from "@polkadot/keyring/types";
|
|
2
1
|
import { type Logger } from "@prosopo/common";
|
|
3
2
|
import type { TranslationKey } from "@prosopo/locale";
|
|
3
|
+
import type { KeyringPair } from "@prosopo/types";
|
|
4
4
|
import { CaptchaType, Tier } from "@prosopo/types";
|
|
5
5
|
import type { ClientRecord, FrictionlessTokenId, IProviderDatabase, IUserDataSlim, Session } from "@prosopo/types-database";
|
|
6
|
+
import { type AccessRulesStorage } from "@prosopo/user-access-policy";
|
|
6
7
|
export declare class CaptchaManager {
|
|
7
8
|
pair: KeyringPair;
|
|
8
9
|
db: IProviderDatabase;
|
|
@@ -20,6 +21,18 @@ export declare class CaptchaManager {
|
|
|
20
21
|
status: string;
|
|
21
22
|
verified: boolean;
|
|
22
23
|
};
|
|
24
|
+
getPrioritisedAccessPolicies(userAccessRulesStorage: AccessRulesStorage, clientId: string, userScope: {
|
|
25
|
+
[key: string]: bigint | string | undefined;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
type?: any;
|
|
28
|
+
captchaType?: any;
|
|
29
|
+
description?: any;
|
|
30
|
+
solvedImagesCount?: any;
|
|
31
|
+
imageThreshold?: any;
|
|
32
|
+
powDifficulty?: any;
|
|
33
|
+
unsolvedImagesCount?: any;
|
|
34
|
+
frictionlessScore?: any;
|
|
35
|
+
} | undefined>;
|
|
23
36
|
getDetectorKeys(): Promise<string[]>;
|
|
24
37
|
static canClientSeeScore(tier: Tier, score?: number): boolean | 0 | undefined;
|
|
25
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captchaManager.d.ts","sourceRoot":"","sources":["../../src/tasks/captchaManager.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"captchaManager.d.ts","sourceRoot":"","sources":["../../src/tasks/captchaManager.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAa,WAAW,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EACX,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,KAAK,kBAAkB,EAIvB,MAAM,6BAA6B,CAAC;AAGrC,qBAAa,cAAc;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,EAAE,iBAAiB,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;gBAEH,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM;IAM/D,iCAAiC,CAAC,aAAa,EAAE,OAAO;IAOxD,cAAc,CACnB,cAAc,EAAE,YAAY,GAAG,aAAa,EAC5C,WAAW,EAAE,WAAW,EACxB,SAAS,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QACV,KAAK,EAAE,OAAO,CAAC;QACf,MAAM,CAAC,EAAE,cAAc,CAAC;QACxB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;QAC1C,IAAI,EAAE,WAAW,CAAC;KAClB,CAAC;IA+EF,uBAAuB,CACtB,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EACpC,KAAK,CAAC,EAAE,MAAM;;;;;IAaT,4BAA4B,CACjC,sBAAsB,EAAE,kBAAkB,EAC1C,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;KAC3C;;;;;;;;;;IAkDI,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI1C,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM;CAGnD"}
|