@prosopo/provider 4.11.0 → 4.11.2
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 +8 -8
- package/.turbo/turbo-build$colon$tsc.log +24 -24
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +61 -0
- package/dist/api/admin/apiRemoveDetectorKeyEndpoint.d.ts.map +1 -1
- package/dist/api/captcha/getFrictionlessCaptchaChallenge/handler.d.ts.map +1 -1
- package/dist/api/captcha/getFrictionlessCaptchaChallenge/handler.js +32 -33
- package/dist/api/captcha/getFrictionlessCaptchaChallenge/handler.js.map +1 -1
- package/dist/api/captcha/submitPoWCaptchaSolution.d.ts.map +1 -1
- package/dist/api/captcha/submitPoWCaptchaSolution.js +24 -3
- package/dist/api/captcha/submitPoWCaptchaSolution.js.map +1 -1
- package/dist/cjs/api/captcha/getFrictionlessCaptchaChallenge/handler.cjs +32 -33
- package/dist/cjs/api/captcha/submitPoWCaptchaSolution.cjs +24 -3
- package/dist/cjs/tasks/detection/decodeBehavior.cjs +243 -220
- package/dist/cjs/tasks/detection/decodeBehavior.js +1 -1
- package/dist/cjs/tasks/detection/decodePayload.cjs +383 -764
- package/dist/cjs/tasks/detection/decodePayload.js +1 -1
- package/dist/cjs/tasks/detection/decodeSimd.cjs +225 -238
- package/dist/cjs/tasks/detection/decodeSimd.js +1 -1
- package/dist/cjs/tasks/powCaptcha/powTasks.cjs +5 -1
- package/dist/cjs/tasks/spam/checkTrafficFilter.cjs +14 -1
- package/dist/tasks/detection/decodeBehavior.d.ts +2 -2
- package/dist/tasks/detection/decodeBehavior.d.ts.map +1 -1
- package/dist/tasks/detection/decodeBehavior.js +1 -1
- package/dist/tasks/detection/decodeBehavior.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 +1 -1
- package/dist/tasks/detection/decodePayload.js.map +1 -1
- package/dist/tasks/detection/decodeSimd.d.ts +2 -2
- package/dist/tasks/detection/decodeSimd.d.ts.map +1 -1
- package/dist/tasks/detection/decodeSimd.js +1 -1
- package/dist/tasks/detection/decodeSimd.js.map +1 -1
- package/dist/tasks/detection/getBotScore.js +2 -2
- package/dist/tasks/powCaptcha/powTasks.d.ts.map +1 -1
- package/dist/tasks/powCaptcha/powTasks.js +5 -1
- package/dist/tasks/powCaptcha/powTasks.js.map +1 -1
- package/dist/tasks/spam/checkTrafficFilter.d.ts.map +1 -1
- package/dist/tasks/spam/checkTrafficFilter.js +14 -1
- package/dist/tasks/spam/checkTrafficFilter.js.map +1 -1
- package/dist/tests/integration/clientSettingsPersistence.integration.test.js +1 -0
- package/dist/tests/integration/clientSettingsPersistence.integration.test.js.map +1 -1
- package/dist/tests/integration/mocks/solvedTestCaptchas.d.ts +1 -0
- package/dist/tests/integration/mocks/solvedTestCaptchas.d.ts.map +1 -1
- package/dist/tests/unit/tasks/spam/checkTrafficFilter.unit.test.js +84 -0
- package/dist/tests/unit/tasks/spam/checkTrafficFilter.unit.test.js.map +1 -1
- package/package.json +14 -14
|
@@ -62,11 +62,6 @@ const getFrictionlessCaptchaChallenge = (env, userAccessRulesStorage) => async (
|
|
|
62
62
|
)
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
|
-
const tasks$1 = new tasks.Tasks(env, req.logger);
|
|
66
|
-
const decodedSimdReadings = await decryptSimdReadings.decryptIncomingSimdReadings(
|
|
67
|
-
tasks$1.frictionlessManager,
|
|
68
|
-
simdReadings
|
|
69
|
-
);
|
|
70
65
|
if (testSiteKey.isReservedTestSiteKey(dapp)) {
|
|
71
66
|
req.logger.warn(() => ({
|
|
72
67
|
msg: "Reserved TEST site key - returning invisible PoW session",
|
|
@@ -79,13 +74,13 @@ const getFrictionlessCaptchaChallenge = (env, userAccessRulesStorage) => async (
|
|
|
79
74
|
)
|
|
80
75
|
);
|
|
81
76
|
}
|
|
77
|
+
const tasks$1 = new tasks.Tasks(env, req.logger);
|
|
82
78
|
const userSitekeyIpHash = hashUserIp.hashUserIp(user, normalizedIp, dapp);
|
|
83
|
-
const { existingToken, dedup } = await
|
|
84
|
-
tasks$1,
|
|
85
|
-
token,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
79
|
+
const [decodedSimdReadings, { existingToken, dedup }, clientRecord] = await Promise.all([
|
|
80
|
+
decryptSimdReadings.decryptIncomingSimdReadings(tasks$1.frictionlessManager, simdReadings),
|
|
81
|
+
sessionDedup.resolveSessionDedup(tasks$1, token, userSitekeyIpHash, req.logger),
|
|
82
|
+
tasks$1.db.getClientRecord(dapp)
|
|
83
|
+
]);
|
|
89
84
|
if (existingToken) {
|
|
90
85
|
req.logger.info(() => ({
|
|
91
86
|
token: existingToken,
|
|
@@ -99,7 +94,6 @@ const getFrictionlessCaptchaChallenge = (env, userAccessRulesStorage) => async (
|
|
|
99
94
|
})
|
|
100
95
|
);
|
|
101
96
|
}
|
|
102
|
-
const clientRecord = await tasks$1.db.getClientRecord(dapp);
|
|
103
97
|
if (!clientRecord) {
|
|
104
98
|
return next(
|
|
105
99
|
new common.ProsopoApiError("API.SITE_KEY_NOT_REGISTERED", {
|
|
@@ -160,6 +154,29 @@ const getFrictionlessCaptchaChallenge = (env, userAccessRulesStorage) => async (
|
|
|
160
154
|
const lScore = tasks$1.frictionlessManager.checkLangRules(
|
|
161
155
|
req.headers["accept-language"] || ""
|
|
162
156
|
);
|
|
157
|
+
const userScope = blacklistRequestInspector.getRequestUserScope(
|
|
158
|
+
util.flatten(req.headers),
|
|
159
|
+
req.ja4,
|
|
160
|
+
normalizedIp,
|
|
161
|
+
user,
|
|
162
|
+
void 0,
|
|
163
|
+
void 0,
|
|
164
|
+
countryCode,
|
|
165
|
+
asn
|
|
166
|
+
);
|
|
167
|
+
const [decryptedPayload, validation, accessPolicies] = await Promise.all([
|
|
168
|
+
tasks$1.frictionlessManager.decryptPayload(token, headHash),
|
|
169
|
+
tasks$1.frictionlessManager.isValidRequest(
|
|
170
|
+
clientRecord,
|
|
171
|
+
types.CaptchaType.frictionless,
|
|
172
|
+
env
|
|
173
|
+
),
|
|
174
|
+
tasks$1.frictionlessManager.getPrioritisedAccessPolicies(
|
|
175
|
+
userAccessRulesStorage,
|
|
176
|
+
dapp,
|
|
177
|
+
userScope
|
|
178
|
+
)
|
|
179
|
+
]);
|
|
163
180
|
const {
|
|
164
181
|
baseBotScore,
|
|
165
182
|
timestamp,
|
|
@@ -172,7 +189,7 @@ const getFrictionlessCaptchaChallenge = (env, userAccessRulesStorage) => async (
|
|
|
172
189
|
decryptionFailed,
|
|
173
190
|
triggeredDetectors,
|
|
174
191
|
shadowDomPenalty
|
|
175
|
-
} =
|
|
192
|
+
} = decryptedPayload;
|
|
176
193
|
req.logger.debug(() => ({
|
|
177
194
|
msg: "Decrypted payload",
|
|
178
195
|
data: {
|
|
@@ -185,11 +202,7 @@ const getFrictionlessCaptchaChallenge = (env, userAccessRulesStorage) => async (
|
|
|
185
202
|
}
|
|
186
203
|
}));
|
|
187
204
|
let botScore = baseBotScore + lScore;
|
|
188
|
-
const { valid, reason } =
|
|
189
|
-
clientRecord,
|
|
190
|
-
types.CaptchaType.frictionless,
|
|
191
|
-
env
|
|
192
|
-
);
|
|
205
|
+
const { valid, reason } = validation;
|
|
193
206
|
if (!valid) {
|
|
194
207
|
return next(
|
|
195
208
|
new common.ProsopoApiError(reason || "API.BAD_REQUEST", {
|
|
@@ -239,21 +252,7 @@ const getFrictionlessCaptchaChallenge = (env, userAccessRulesStorage) => async (
|
|
|
239
252
|
...req.ja4 && { ja4: req.ja4 }
|
|
240
253
|
}
|
|
241
254
|
});
|
|
242
|
-
const
|
|
243
|
-
util.flatten(req.headers),
|
|
244
|
-
req.ja4,
|
|
245
|
-
normalizedIp,
|
|
246
|
-
user,
|
|
247
|
-
void 0,
|
|
248
|
-
void 0,
|
|
249
|
-
countryCode,
|
|
250
|
-
asn
|
|
251
|
-
);
|
|
252
|
-
const userAccessPolicy = (await tasks$1.frictionlessManager.getPrioritisedAccessPolicies(
|
|
253
|
-
userAccessRulesStorage,
|
|
254
|
-
dapp,
|
|
255
|
-
userScope
|
|
256
|
-
))[0];
|
|
255
|
+
const userAccessPolicy = accessPolicies[0];
|
|
257
256
|
const accessPolicyOutcome = await accessPolicy.handleAccessPolicy(
|
|
258
257
|
{
|
|
259
258
|
tasks: tasks$1,
|
|
@@ -40,7 +40,8 @@ const submitPoWCaptchaSolution = (env) => async (req, res, next) => {
|
|
|
40
40
|
behavioralData,
|
|
41
41
|
salt,
|
|
42
42
|
simdReadings,
|
|
43
|
-
clientMetaData
|
|
43
|
+
clientMetaData,
|
|
44
|
+
fingerprintProof
|
|
44
45
|
} = parsed;
|
|
45
46
|
validateAddress.validateSiteKey(dapp);
|
|
46
47
|
validateAddress.validateAddr(user);
|
|
@@ -66,6 +67,14 @@ const submitPoWCaptchaSolution = (env) => async (req, res, next) => {
|
|
|
66
67
|
const flatHeaders = util.flatten(req.headers);
|
|
67
68
|
const userAgent = req.headers["user-agent"] ?? "";
|
|
68
69
|
const countryCode = req.ipInfo && "isValid" in req.ipInfo && req.ipInfo.isValid ? req.ipInfo.countryCode : void 0;
|
|
70
|
+
req.logger.info(() => ({
|
|
71
|
+
msg: fingerprintProof ? "fingerprintProof detected" : "no fingerprintProof on PoW submission",
|
|
72
|
+
data: {
|
|
73
|
+
fingerprintProofPresent: fingerprintProof !== void 0,
|
|
74
|
+
fingerprintProofBytes: fingerprintProof?.length ?? 0,
|
|
75
|
+
challenge
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
69
78
|
tasks$1.powCaptchaManager.setPostPowContext({
|
|
70
79
|
ip: req.ip || "",
|
|
71
80
|
countryCode,
|
|
@@ -75,7 +84,8 @@ const submitPoWCaptchaSolution = (env) => async (req, res, next) => {
|
|
|
75
84
|
raw: {
|
|
76
85
|
headers: flatHeaders,
|
|
77
86
|
userAgent,
|
|
78
|
-
...req.ja4 && { ja4: req.ja4 }
|
|
87
|
+
...req.ja4 && { ja4: req.ja4 },
|
|
88
|
+
...fingerprintProof && { fingerprintProof }
|
|
79
89
|
}
|
|
80
90
|
});
|
|
81
91
|
const persistedSolutionTimeout = clientRecord.settings.solutionTimeout;
|
|
@@ -93,6 +103,16 @@ const submitPoWCaptchaSolution = (env) => async (req, res, next) => {
|
|
|
93
103
|
simdReadings,
|
|
94
104
|
clientMetaData
|
|
95
105
|
);
|
|
106
|
+
if (result.routingOutput) {
|
|
107
|
+
req.logger.info(() => ({
|
|
108
|
+
msg: "post-PoW routing decision",
|
|
109
|
+
data: {
|
|
110
|
+
routedCaptchaType: result.routingOutput?.captchaType,
|
|
111
|
+
routingReason: result.routingOutput?.reason,
|
|
112
|
+
challenge
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
96
116
|
const escalation = await buildEscalation(tasks$1, result, challenge);
|
|
97
117
|
const response = {
|
|
98
118
|
status: "ok",
|
|
@@ -134,6 +154,7 @@ const buildEscalation = async (tasks2, result, challenge) => {
|
|
|
134
154
|
);
|
|
135
155
|
if (!originSession) return void 0;
|
|
136
156
|
const routed = result.routingOutput;
|
|
157
|
+
const selectionReason = routed.reason ?? originSession.reason;
|
|
137
158
|
const newSession = await tasks2.frictionlessManager.createSession(
|
|
138
159
|
originSession.token,
|
|
139
160
|
originSession.score,
|
|
@@ -149,7 +170,7 @@ const buildEscalation = async (tasks2, result, challenge) => {
|
|
|
149
170
|
originSession.webView,
|
|
150
171
|
originSession.iFrame,
|
|
151
172
|
originSession.decryptedHeadHash,
|
|
152
|
-
|
|
173
|
+
selectionReason,
|
|
153
174
|
void 0,
|
|
154
175
|
void 0,
|
|
155
176
|
originSession.ipInfo,
|