Cloudflare Worker implementation for Adscore bot and proxy traffic detection, based on Adscore/nodejs-common.
You can configure the worker using Cloudflare Worker environment variables (in the Cloudflare dashboard or wrangler.toml) or by updating variables.js in the root folder before building:
export const variables = {
ADSCORE_ZONE_REQUEST_KEY: "<paste_request_key_here_or_leave_empty>",
ALLOWED_VERDICTS: ["ok", "junk", "proxy"],
ADSCORE_ZONE_API_KEY: "<paste_api_key_here_or_leave_empty>",
ADSCORE_ZONE_RESPONSE_KEY: "<paste_response_key_here_or_leave_empty>",
};ADSCORE_ZONE_API_KEY: Your Adscore Zone API key.ADSCORE_ZONE_RESPONSE_KEY: Your Adscore Zone response key (for signature verification).ALLOWED_VERDICTS: List of verdicts allowed to pass through to your origin (e.g.["ok", "junk", "proxy", "bot"], or"ok,junk,proxy"when passed as a string environment variable).ADSCORE_ZONE_REQUEST_KEY: Optional request signing key.DEBUG: Optional boolean (true/"true") to enable verification debug logging.
Requires Node.js >= 18.19.0.
-
Install dependencies:
npm i
-
Build the worker with your configured
variables.js:npm run dev
This generates
dist/worker.jsanddist/libsodium.wasm. -
Deploy to Cloudflare using Wrangler:
npm run deploy
v5_0101M– Sodium Secretbox, Msgpack
v5_0200H– OpenSSL CBC, HTTP query (RFC 3986)v5_0201H– OpenSSL GCM, HTTP query (RFC 3986)v5_0200J– OpenSSL CBC, JSONv5_0201J– OpenSSL GCM, JSON- Signature v4 – Hashing (HMAC) and Signing (ECDSA)
MIT License. See LICENSE for details.