X402 Proxy Template: Add bot management filtering support#952
Conversation
e03b809 to
280136a
Compare
Adds optional Bot Management Filtering to x402-proxy-template. When enabled (requires Bot Management for Enterprise), allows: - Humans (bot score > threshold) to access protected routes for FREE - Excepted bots (by detection ID) to access protected routes for FREE - All other bot traffic must pay Changes: - Add bot_score_threshold and except_detection_ids config options - Create src/bot-management/ directory with isolated filtering logic - Add bot reference registry for AI agent setup - Update AGENTS.md with Bot Management Filtering setup flow - Simplify wrangler.jsonc examples Non-Bot Management users can ignore the entire src/bot-management/ directory.
280136a to
f78414a
Compare
|
Preview link not generated: you must be on a branch, not on a fork. |
| return false; | ||
| } | ||
|
|
||
| const botScore = botManagement.score ?? 99; // Default to human if no score |
There was a problem hiding this comment.
The default above for no botManagement is to always require payment. Yet here, if for some reason we don't have a score, we default to human (no payment). Is this intended?
There was a problem hiding this comment.
Thanks for the catch - it would be best to default to always require payment.
That way, it would match the behavior of the proxy template when there is no bot management configuration at all.
I've added a console.warn for this this scenario, and removed the fallback to 99.
If botManagement data is present but score is undefined/null, fall back to requiring payment instead of defaulting to 99 (human). This ensures consistent 'safe default' behavior - when we can't evaluate bot status, we require payment. Addresses review feedback from @edevil
Description
Adds optional Bot Management Filtering to x402-proxy-template. When enabled (requires Bot Management for Enterprise), allows:
Changes
bot_score_thresholdandexcept_detection_idsconfig options to protected patternssrc/bot-management/directory with isolated filtering logicNon-Bot Management users can ignore the entire
src/bot-management/directory.Checklist
-templatepackage.jsonis populated<!-- dash-content-start -->and<!-- dash-content-end -->to designate the Dash readme preview.gitignorefile existspackage.jsoncontains adeploycommandpackage.jsoncontainsprivate: trueand noversionfieldExample
package.json