@prosopo/provider 3.13.6 → 3.13.7
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 +103 -0
- package/.turbo/turbo-build.log +103 -0
- package/CHANGELOG.md +22 -0
- package/dist/api/captcha/contextAwareValidation.js +20 -0
- package/dist/api/captcha/getFrictionlessCaptchaChallenge.js +51 -30
- package/dist/cjs/api/captcha/contextAwareValidation.cjs +20 -0
- package/dist/cjs/api/captcha/getFrictionlessCaptchaChallenge.cjs +50 -29
- package/dist/cjs/tasks/client/clientTasks.cjs +33 -7
- package/dist/cjs/tasks/detection/decodePayload.cjs +731 -385
- package/dist/cjs/tasks/frictionless/frictionlessTasks.cjs +2 -2
- package/dist/tasks/client/clientTasks.js +34 -8
- package/dist/tasks/detection/decodePayload.js +731 -385
- package/dist/tasks/detection/getBotScore.js +2 -2
- package/dist/tasks/frictionless/frictionlessTasks.js +2 -2
- package/package.json +18 -18
|
@@ -341,8 +341,8 @@ class FrictionlessManager extends captchaManager.CaptchaManager {
|
|
|
341
341
|
decryptionFailed
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
|
-
async
|
|
345
|
-
return this.db.
|
|
344
|
+
async getClientContextEntropy(siteKey, contextType) {
|
|
345
|
+
return this.db.getClientContextEntropy(siteKey, contextType);
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
exports.DEFAULT_ENTROPY = DEFAULT_ENTROPY;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createPrivateKey } from "node:crypto";
|
|
2
2
|
import { ProsopoApiError } from "@prosopo/common";
|
|
3
3
|
import { CaptchaDatabase, ClientDatabase } from "@prosopo/database";
|
|
4
|
-
import { ScheduledTaskNames, ScheduledTaskStatus } from "@prosopo/types";
|
|
4
|
+
import { ScheduledTaskNames, ScheduledTaskStatus, Tier } from "@prosopo/types";
|
|
5
5
|
import { majorityAverage, parseUrl } from "@prosopo/util";
|
|
6
6
|
import { validateSiteKey } from "../../api/validateAddress.js";
|
|
7
|
+
const SAMPLE_SIZE = 100;
|
|
7
8
|
const isValidPrivateKey = (privateKeyString) => {
|
|
8
9
|
const privateKey = Buffer.from(privateKeyString, "base64").toString("ascii");
|
|
9
10
|
try {
|
|
@@ -210,14 +211,39 @@ class ClientTaskManager {
|
|
|
210
211
|
ScheduledTaskStatus.Running
|
|
211
212
|
);
|
|
212
213
|
try {
|
|
213
|
-
|
|
214
|
+
let clients = await this.providerDB.getAllClientRecords();
|
|
215
|
+
clients = clients.filter((client) => client.tier !== Tier.Free);
|
|
216
|
+
this.logger.info(() => ({
|
|
217
|
+
msg: `Calculating entropies for ${clients.length} clients`
|
|
218
|
+
}));
|
|
214
219
|
for (const client of clients) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
220
|
+
if (client.settings?.contextAware?.enabled) {
|
|
221
|
+
const contextTypes = Object.keys(
|
|
222
|
+
client.settings.contextAware.contexts ?? {}
|
|
223
|
+
);
|
|
224
|
+
for (const contextType of contextTypes) {
|
|
225
|
+
const contextSamples = await this.providerDB.sampleContextEntropy(
|
|
226
|
+
SAMPLE_SIZE,
|
|
227
|
+
client.account,
|
|
228
|
+
contextType
|
|
229
|
+
);
|
|
230
|
+
if (contextSamples.length < SAMPLE_SIZE) {
|
|
231
|
+
this.logger.info(() => ({
|
|
232
|
+
msg: `Skipping ${contextType} entropy calculation for client ${client.account} due to insufficient samples (${contextSamples.length}/${SAMPLE_SIZE})`
|
|
233
|
+
}));
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const contextAvgEntropy = majorityAverage(contextSamples);
|
|
237
|
+
this.logger.info(() => ({
|
|
238
|
+
msg: `Calculated ${contextType} entropy for client ${client.account}: ${contextAvgEntropy}`
|
|
239
|
+
}));
|
|
240
|
+
await this.providerDB.setClientContextEntropy(
|
|
241
|
+
client.account,
|
|
242
|
+
contextType,
|
|
243
|
+
contextAvgEntropy
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
221
247
|
}
|
|
222
248
|
await this.providerDB.updateScheduledTaskStatus(
|
|
223
249
|
taskID,
|