Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring staging up to date with main #1578

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/provider/src/api/captcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,6 @@ export function prosopoRouter(env: ProviderEnvironment): Router {
clientConfig?.settings?.frictionlessThreshold ||
DEFAULT_FRICTIONLESS_THRESHOLD;

// Store the token
const tokenId = await tasks.db.storeFrictionlessTokenRecord({
token,
score: botScore,
threshold: botThreshold,
});

// Check if the IP address is blocked
const ipAddress = getIPAddress(req.ip || "");
const isIpBlocked = await tasks.frictionlessManager.checkIpRules(
Expand All @@ -475,8 +468,16 @@ export function prosopoRouter(env: ProviderEnvironment): Router {
if (Number(botScore) > botThreshold)
return res.json(tasks.frictionlessManager.sendImageCaptcha());

// Store the token
const tokenId = await tasks.db.storeFrictionlessTokenRecord({
token,
score: botScore,
threshold: botThreshold,
});

const response =
await tasks.frictionlessManager.sendPowCaptcha(tokenId);

return res.json(response);
} catch (err) {
console.error("Error in frictionless captcha challenge:", err);
Expand Down
Loading