@webdecoy/node 0.21.3 → 0.22.0

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/dist/index.js CHANGED
@@ -72,6 +72,7 @@ __export(index_exports, {
72
72
  createAgentVerifier: () => createAgentVerifier,
73
73
  createCaptchaEndpoints: () => createCaptchaEndpoints,
74
74
  createClearanceGate: () => createClearanceGate,
75
+ createDetectAndGate: () => createDetectAndGate,
75
76
  createFetchGuard: () => createFetchGuard,
76
77
  deriveAndArm: () => deriveAndArm,
77
78
  deriveKey: () => deriveKey,
@@ -348,6 +349,267 @@ function toWireDetectionRequest(request) {
348
349
  return { ...request, request_metadata: metadata };
349
350
  }
350
351
 
352
+ // src/bots/registry.generated.ts
353
+ var BOT_CATEGORIES = [
354
+ "training_crawler",
355
+ "ai_search_crawler",
356
+ "ai_agent",
357
+ "ai_assistant",
358
+ "search_crawler",
359
+ "seo_crawler",
360
+ "security_scanner",
361
+ "generic_scraper",
362
+ "archiver",
363
+ "fetcher",
364
+ "monitoring",
365
+ "headless_browser",
366
+ "feed_reader",
367
+ "commercial_scraper",
368
+ "none"
369
+ ];
370
+ var BOT_REGISTRY = [
371
+ { id: "reflectionbot", name: "Reflectionbot", category: "training_crawler", organization: "Reflection AI", baseScore: 70, respectsRobots: true, uaPatterns: ["reflectionbot"] },
372
+ { id: "gptbot", name: "GPTBot", category: "training_crawler", organization: "OpenAI", baseScore: 85, respectsRobots: true, uaPatterns: ["gptbot"] },
373
+ { id: "claudebot", name: "ClaudeBot", category: "training_crawler", organization: "Anthropic", baseScore: 85, respectsRobots: true, uaPatterns: ["claudebot"] },
374
+ { id: "anthropic", name: "Anthropic", category: "training_crawler", organization: "Anthropic", baseScore: 85, respectsRobots: true, uaPatterns: ["anthropic-ai"] },
375
+ { id: "claude-web", name: "Claude-Web", category: "training_crawler", organization: "Anthropic", baseScore: 85, respectsRobots: true, uaPatterns: ["claude-web"] },
376
+ { id: "ccbot", name: "CCBot", category: "training_crawler", organization: "Common Crawl", baseScore: 80, respectsRobots: true, uaPatterns: ["ccbot"] },
377
+ { id: "google-extended", name: "Google-Extended", category: "training_crawler", organization: "Google", baseScore: 80, respectsRobots: true, uaPatterns: ["google-extended"] },
378
+ { id: "bytespider", name: "ByteSpider", category: "training_crawler", organization: "ByteDance", baseScore: 75, respectsRobots: false, uaPatterns: ["bytespider"] },
379
+ { id: "amazonbot", name: "Amazonbot", category: "training_crawler", organization: "Amazon", baseScore: 70, respectsRobots: true, uaPatterns: ["amazonbot"] },
380
+ { id: "facebookbot", name: "FacebookBot", category: "training_crawler", organization: "Meta", baseScore: 70, respectsRobots: true, uaPatterns: ["facebookbot"] },
381
+ { id: "meta-externalagent", name: "Meta-ExternalAgent", category: "training_crawler", organization: "Meta", baseScore: 75, respectsRobots: true, uaPatterns: ["meta-externalagent"] },
382
+ { id: "cohere-ai", name: "Cohere", category: "training_crawler", organization: "Cohere", baseScore: 80, respectsRobots: true, uaPatterns: ["cohere-ai", "cohere"] },
383
+ { id: "applebot-extended", name: "Applebot-Extended", category: "training_crawler", organization: "Apple", baseScore: 75, respectsRobots: true, uaPatterns: ["applebot-extended"] },
384
+ { id: "youbot", name: "YouBot", category: "training_crawler", organization: "You.com", baseScore: 75, respectsRobots: true, uaPatterns: ["youbot"] },
385
+ { id: "mistral", name: "MistralBot", category: "training_crawler", organization: "Mistral AI", baseScore: 80, respectsRobots: true, uaPatterns: ["mistralbot"] },
386
+ { id: "gemini", name: "Gemini", category: "training_crawler", organization: "Google", baseScore: 80, respectsRobots: true, uaPatterns: ["gemini"] },
387
+ { id: "ai2bot", name: "AI2Bot", category: "training_crawler", organization: "Allen Institute for AI", baseScore: 75, respectsRobots: true, uaPatterns: ["ai2bot"] },
388
+ { id: "deepseek", name: "DeepSeek", category: "training_crawler", organization: "DeepSeek", baseScore: 80, respectsRobots: true, uaPatterns: ["deepseek"] },
389
+ { id: "qwen", name: "Qwen", category: "training_crawler", organization: "Alibaba", baseScore: 75, respectsRobots: true, uaPatterns: ["qwen"] },
390
+ { id: "webzio", name: "Webz.io", category: "training_crawler", organization: "Webz.io", baseScore: 70, respectsRobots: false, uaPatterns: ["webzio"] },
391
+ { id: "sentibot", name: "Sentibot", category: "training_crawler", organization: "Sentibot", baseScore: 70, respectsRobots: false, uaPatterns: ["sentibot"] },
392
+ { id: "omgili", name: "Omgili", category: "training_crawler", organization: "Webz.io", baseScore: 70, respectsRobots: false, uaPatterns: ["omgili"] },
393
+ { id: "img2dataset", name: "img2dataset", category: "training_crawler", organization: "LAION", baseScore: 75, respectsRobots: false, uaPatterns: ["img2dataset"] },
394
+ { id: "timpibot", name: "Timpibot", category: "training_crawler", organization: "Timpi", baseScore: 70, respectsRobots: true, uaPatterns: ["timpibot"] },
395
+ { id: "velenpublicwebcrawler", name: "VelenPublicWebCrawler", category: "training_crawler", organization: "Velen", baseScore: 70, respectsRobots: false, uaPatterns: ["velenpublicwebcrawler"] },
396
+ { id: "isscyberriskcrawler", name: "ISSCyberRiskCrawler", category: "training_crawler", organization: "ISS", baseScore: 65, respectsRobots: false, uaPatterns: ["isscyberriskcrawler"] },
397
+ { id: "friendlycrawler", name: "FriendlyCrawler", category: "training_crawler", organization: "Unknown", baseScore: 65, respectsRobots: true, uaPatterns: ["friendlycrawler"] },
398
+ { id: "duckassistbot", name: "DuckAssistBot", category: "ai_search_crawler", organization: "DuckDuckGo", baseScore: 65, respectsRobots: true, uaPatterns: ["duckassistbot"] },
399
+ { id: "sofyabot", name: "SofyaBot", category: "ai_search_crawler", organization: "Sofya", baseScore: 65, respectsRobots: true, uaPatterns: ["sofyabot"] },
400
+ { id: "xai-searchbot", name: "xAI-SearchBot", category: "ai_search_crawler", organization: "xAI", baseScore: 70, respectsRobots: true, uaPatterns: ["xai-searchbot"] },
401
+ { id: "linkupbot", name: "LinkupBot", category: "ai_search_crawler", organization: "Linkup", baseScore: 65, respectsRobots: true, uaPatterns: ["linkupbot"] },
402
+ { id: "perplexitybot", name: "PerplexityBot", category: "ai_search_crawler", organization: "Perplexity AI", baseScore: 80, respectsRobots: true, uaPatterns: ["perplexitybot"] },
403
+ { id: "claude-searchbot", name: "Claude-SearchBot", category: "ai_search_crawler", organization: "Anthropic", baseScore: 75, respectsRobots: true, uaPatterns: ["claude-searchbot"] },
404
+ { id: "oai-searchbot", name: "OAI-SearchBot", category: "ai_search_crawler", organization: "OpenAI", baseScore: 80, respectsRobots: true, uaPatterns: ["oai-searchbot"] },
405
+ { id: "searchgpt", name: "SearchGPT", category: "ai_search_crawler", organization: "OpenAI", baseScore: 75, respectsRobots: true, uaPatterns: ["searchgpt"] },
406
+ { id: "phind", name: "Phind", category: "ai_search_crawler", organization: "Phind", baseScore: 70, respectsRobots: true, uaPatterns: ["phind"] },
407
+ { id: "kagi", name: "Kagi", category: "ai_search_crawler", organization: "Kagi", baseScore: 65, respectsRobots: true, uaPatterns: ["kagi"] },
408
+ { id: "exa", name: "Exa", category: "ai_search_crawler", organization: "Exa AI", baseScore: 70, respectsRobots: true, uaPatterns: ["exasearchbot", "exabot"] },
409
+ { id: "shapbot", name: "ShapBot", category: "ai_search_crawler", organization: "Parallel Web Systems", baseScore: 65, respectsRobots: true, uaPatterns: ["shapbot"] },
410
+ { id: "meta-webindexer", name: "Meta-WebIndexer", category: "ai_search_crawler", organization: "Meta", baseScore: 70, respectsRobots: true, uaPatterns: ["meta-webindexer"] },
411
+ { id: "metaphor", name: "Metaphor", category: "ai_search_crawler", organization: "Metaphor", baseScore: 70, respectsRobots: true, uaPatterns: ["metaphor"] },
412
+ { id: "tavily", name: "Tavily", category: "ai_search_crawler", organization: "Tavily", baseScore: 70, respectsRobots: true, uaPatterns: ["tavily"] },
413
+ { id: "brave-search", name: "BraveSearch", category: "ai_search_crawler", organization: "Brave", baseScore: 65, respectsRobots: true, uaPatterns: ["bravesearch"] },
414
+ { id: "neeva", name: "NeevaBot", category: "ai_search_crawler", organization: "Neeva", baseScore: 65, respectsRobots: true, uaPatterns: ["neevabot"] },
415
+ { id: "operator", name: "Operator", category: "ai_agent", organization: "OpenAI", baseScore: 75, respectsRobots: true, uaPatterns: ["operator"] },
416
+ { id: "claude-user", name: "Claude-User", category: "ai_agent", organization: "Anthropic", baseScore: 75, respectsRobots: true, uaPatterns: ["claude-user"] },
417
+ { id: "gemini-user", name: "Gemini-User", category: "ai_agent", organization: "Google", baseScore: 75, respectsRobots: true, uaPatterns: ["gemini-user"] },
418
+ { id: "googleagent-mariner", name: "GoogleAgent-Mariner", category: "ai_agent", organization: "Google", baseScore: 75, respectsRobots: true, uaPatterns: ["googleagent-mariner", "mariner"] },
419
+ { id: "amazon-buyforme", name: "AmazonBuyForMe", category: "ai_agent", organization: "Amazon", baseScore: 70, respectsRobots: true, uaPatterns: ["amazonbuyforme", "buyforme"] },
420
+ { id: "browser-use", name: "Browser-Use", category: "ai_agent", organization: "Open Source", baseScore: 70, respectsRobots: false, uaPatterns: ["browser-use"] },
421
+ { id: "stagehand", name: "Stagehand", category: "ai_agent", organization: "Browserbase", baseScore: 70, respectsRobots: false, uaPatterns: ["stagehand"] },
422
+ { id: "manus-user", name: "Manus-User", category: "ai_agent", organization: "Manus", baseScore: 70, respectsRobots: false, uaPatterns: ["manus-user"] },
423
+ { id: "multion", name: "MultiOn", category: "ai_agent", organization: "MultiOn", baseScore: 70, respectsRobots: false, uaPatterns: ["multion"] },
424
+ { id: "iboubot", name: "IbouBot", category: "search_crawler", organization: "Ibou", baseScore: 30, respectsRobots: true, uaPatterns: ["iboubot"] },
425
+ { id: "googlebot", name: "Googlebot", category: "search_crawler", organization: "Google", baseScore: 30, respectsRobots: true, uaPatterns: ["googlebot"] },
426
+ { id: "google-inspectiontool", name: "Google-InspectionTool", category: "search_crawler", organization: "Google", baseScore: 30, respectsRobots: true, uaPatterns: ["google-inspectiontool"] },
427
+ { id: "bingbot", name: "Bingbot", category: "search_crawler", organization: "Microsoft", baseScore: 30, respectsRobots: true, uaPatterns: ["bingbot"] },
428
+ { id: "msnbot", name: "MSNBot", category: "search_crawler", organization: "Microsoft", baseScore: 30, respectsRobots: true, uaPatterns: ["msnbot"] },
429
+ { id: "yandexbot", name: "YandexBot", category: "search_crawler", organization: "Yandex", baseScore: 35, respectsRobots: true, uaPatterns: ["yandexbot"] },
430
+ { id: "baiduspider", name: "Baiduspider", category: "search_crawler", organization: "Baidu", baseScore: 40, respectsRobots: true, uaPatterns: ["baiduspider"] },
431
+ { id: "duckduckbot", name: "DuckDuckBot", category: "search_crawler", organization: "DuckDuckGo", baseScore: 30, respectsRobots: true, uaPatterns: ["duckduckbot"] },
432
+ { id: "applebot", name: "Applebot", category: "search_crawler", organization: "Apple", baseScore: 30, respectsRobots: true, uaPatterns: ["applebot"] },
433
+ { id: "sogou", name: "Sogou Spider", category: "search_crawler", organization: "Sogou", baseScore: 40, respectsRobots: true, uaPatterns: ["sogou"] },
434
+ { id: "qwantify", name: "Qwantify", category: "search_crawler", organization: "Qwant", baseScore: 35, respectsRobots: true, uaPatterns: ["qwantify"] },
435
+ { id: "naver", name: "Naver", category: "search_crawler", organization: "Naver", baseScore: 35, respectsRobots: true, uaPatterns: ["naver", "yeti"] },
436
+ { id: "seznam", name: "SeznamBot", category: "search_crawler", organization: "Seznam", baseScore: 35, respectsRobots: true, uaPatterns: ["seznambot"] },
437
+ { id: "ecosia", name: "Ecosia", category: "search_crawler", organization: "Ecosia", baseScore: 30, respectsRobots: true, uaPatterns: ["ecosia"] },
438
+ { id: "mojeek", name: "MojeekBot", category: "search_crawler", organization: "Mojeek", baseScore: 35, respectsRobots: true, uaPatterns: ["mojeekbot"] },
439
+ { id: "yahoo-slurp", name: "Yahoo! Slurp", category: "search_crawler", organization: "Yahoo", baseScore: 30, respectsRobots: true, uaPatterns: ["slurp"] },
440
+ { id: "ahrefsbot", name: "AhrefsBot", category: "seo_crawler", organization: "Ahrefs", baseScore: 50, respectsRobots: true, uaPatterns: ["ahrefsbot", "ahrefs"] },
441
+ { id: "semrushbot", name: "SemrushBot", category: "seo_crawler", organization: "Semrush", baseScore: 50, respectsRobots: true, uaPatterns: ["semrushbot", "semrush"] },
442
+ { id: "mj12bot", name: "MJ12bot", category: "seo_crawler", organization: "Majestic", baseScore: 50, respectsRobots: true, uaPatterns: ["mj12bot"] },
443
+ { id: "dotbot", name: "DotBot", category: "seo_crawler", organization: "Moz", baseScore: 50, respectsRobots: true, uaPatterns: ["dotbot"] },
444
+ { id: "rogerbot", name: "Rogerbot", category: "seo_crawler", organization: "Moz", baseScore: 50, respectsRobots: true, uaPatterns: ["rogerbot"] },
445
+ { id: "screaming-frog", name: "Screaming Frog", category: "seo_crawler", organization: "Screaming Frog", baseScore: 55, respectsRobots: true, uaPatterns: ["screaming frog"] },
446
+ { id: "sitebulb", name: "Sitebulb", category: "seo_crawler", organization: "Sitebulb", baseScore: 55, respectsRobots: true, uaPatterns: ["sitebulb"] },
447
+ { id: "deepcrawl", name: "DeepCrawl", category: "seo_crawler", organization: "Lumar", baseScore: 50, respectsRobots: true, uaPatterns: ["deepcrawl"] },
448
+ { id: "oncrawl", name: "OnCrawl", category: "seo_crawler", organization: "OnCrawl", baseScore: 50, respectsRobots: true, uaPatterns: ["oncrawl"] },
449
+ { id: "botify", name: "Botify", category: "seo_crawler", organization: "Botify", baseScore: 50, respectsRobots: true, uaPatterns: ["botify"] },
450
+ { id: "contentking", name: "ContentKing", category: "seo_crawler", organization: "ContentKing", baseScore: 50, respectsRobots: true, uaPatterns: ["contentking"] },
451
+ { id: "sistrix", name: "SISTRIX", category: "seo_crawler", organization: "SISTRIX", baseScore: 50, respectsRobots: true, uaPatterns: ["sistrix"] },
452
+ { id: "serpstat", name: "Serpstat", category: "seo_crawler", organization: "Serpstat", baseScore: 50, respectsRobots: true, uaPatterns: ["serpstat"] },
453
+ { id: "spyfu", name: "SpyFu", category: "seo_crawler", organization: "SpyFu", baseScore: 50, respectsRobots: true, uaPatterns: ["spyfu"] },
454
+ { id: "nessus", name: "Nessus", category: "security_scanner", organization: "Tenable", baseScore: 70, respectsRobots: false, uaPatterns: ["nessus"] },
455
+ { id: "qualys", name: "Qualys", category: "security_scanner", organization: "Qualys", baseScore: 70, respectsRobots: false, uaPatterns: ["qualys"] },
456
+ { id: "shodan", name: "Shodan", category: "security_scanner", organization: "Shodan", baseScore: 75, respectsRobots: false, uaPatterns: ["shodan"] },
457
+ { id: "censys", name: "Censys", category: "security_scanner", organization: "Censys", baseScore: 75, respectsRobots: false, uaPatterns: ["censys"] },
458
+ { id: "nmap", name: "Nmap", category: "security_scanner", organization: "Open Source", baseScore: 70, respectsRobots: false, uaPatterns: ["nmap"] },
459
+ { id: "zap", name: "OWASP ZAP", category: "security_scanner", organization: "OWASP", baseScore: 70, respectsRobots: false, uaPatterns: ["zap/"] },
460
+ { id: "burp", name: "Burp Suite", category: "security_scanner", organization: "PortSwigger", baseScore: 70, respectsRobots: false, uaPatterns: ["burp"] },
461
+ { id: "nikto", name: "Nikto", category: "security_scanner", organization: "Open Source", baseScore: 70, respectsRobots: false, uaPatterns: ["nikto"] },
462
+ { id: "nuclei", name: "Nuclei", category: "security_scanner", organization: "ProjectDiscovery", baseScore: 70, respectsRobots: false, uaPatterns: ["nuclei"] },
463
+ { id: "acunetix", name: "Acunetix", category: "security_scanner", organization: "Invicti", baseScore: 70, respectsRobots: false, uaPatterns: ["acunetix"] },
464
+ { id: "netsparker", name: "Netsparker", category: "security_scanner", organization: "Invicti", baseScore: 70, respectsRobots: false, uaPatterns: ["netsparker"] },
465
+ { id: "detectify", name: "Detectify", category: "security_scanner", organization: "Detectify", baseScore: 65, respectsRobots: false, uaPatterns: ["detectify"] },
466
+ { id: "intruder", name: "Intruder", category: "security_scanner", organization: "Intruder", baseScore: 65, respectsRobots: false, uaPatterns: ["intruder"] },
467
+ { id: "python-requests", name: "Python-Requests", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["python-requests"] },
468
+ { id: "python-urllib", name: "Python-urllib", category: "generic_scraper", organization: "Python", baseScore: 55, respectsRobots: false, uaPatterns: ["python-urllib"] },
469
+ { id: "python", name: "Python", category: "generic_scraper", organization: "Python", baseScore: 50, respectsRobots: false, uaPatterns: ["python/"] },
470
+ { id: "scrapy", name: "Scrapy", category: "generic_scraper", organization: "Scrapy", baseScore: 65, respectsRobots: true, uaPatterns: ["scrapy"] },
471
+ { id: "httpx", name: "HTTPX", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["httpx"] },
472
+ { id: "aiohttp", name: "aiohttp", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["aiohttp"] },
473
+ { id: "beautifulsoup", name: "BeautifulSoup", category: "generic_scraper", organization: "Open Source", baseScore: 60, respectsRobots: false, uaPatterns: ["beautifulsoup"] },
474
+ { id: "node-fetch", name: "node-fetch", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["node-fetch"] },
475
+ { id: "axios", name: "Axios", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["axios/"] },
476
+ { id: "got", name: "Got", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["got/"] },
477
+ { id: "undici", name: "Undici", category: "generic_scraper", organization: "Node.js", baseScore: 55, respectsRobots: false, uaPatterns: ["undici"] },
478
+ { id: "go-http-client", name: "Go-HTTP-Client", category: "generic_scraper", organization: "Go", baseScore: 55, respectsRobots: false, uaPatterns: ["go-http-client"] },
479
+ { id: "colly", name: "Colly", category: "generic_scraper", organization: "Open Source", baseScore: 65, respectsRobots: true, uaPatterns: ["colly"] },
480
+ { id: "java", name: "Java", category: "generic_scraper", organization: "Oracle", baseScore: 50, respectsRobots: false, uaPatterns: ["java/"] },
481
+ { id: "okhttp", name: "OkHttp", category: "generic_scraper", organization: "Square", baseScore: 55, respectsRobots: false, uaPatterns: ["okhttp"] },
482
+ { id: "apache-httpclient", name: "Apache-HttpClient", category: "generic_scraper", organization: "Apache", baseScore: 55, respectsRobots: false, uaPatterns: ["apache-httpclient"] },
483
+ { id: "jsoup", name: "Jsoup", category: "generic_scraper", organization: "Open Source", baseScore: 60, respectsRobots: false, uaPatterns: ["jsoup"] },
484
+ { id: "guzzlehttp", name: "GuzzleHttp", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["guzzlehttp"] },
485
+ { id: "php", name: "PHP", category: "generic_scraper", organization: "PHP", baseScore: 50, respectsRobots: false, uaPatterns: ["php/"] },
486
+ { id: "ruby", name: "Ruby", category: "generic_scraper", organization: "Ruby", baseScore: 50, respectsRobots: false, uaPatterns: ["ruby"] },
487
+ { id: "faraday", name: "Faraday", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["faraday"] },
488
+ { id: "mechanize", name: "Mechanize", category: "generic_scraper", organization: "Open Source", baseScore: 60, respectsRobots: false, uaPatterns: ["mechanize"] },
489
+ { id: "headlesschrome", name: "HeadlessChrome", category: "headless_browser", organization: "Google", baseScore: 70, respectsRobots: false, uaPatterns: ["headlesschrome"] },
490
+ { id: "puppeteer", name: "Puppeteer", category: "headless_browser", organization: "Google", baseScore: 70, respectsRobots: false, uaPatterns: ["puppeteer"] },
491
+ { id: "playwright", name: "Playwright", category: "headless_browser", organization: "Microsoft", baseScore: 70, respectsRobots: false, uaPatterns: ["playwright"] },
492
+ { id: "selenium", name: "Selenium", category: "headless_browser", organization: "Open Source", baseScore: 70, respectsRobots: false, uaPatterns: ["selenium"] },
493
+ { id: "phantomjs", name: "PhantomJS", category: "headless_browser", organization: "Open Source", baseScore: 75, respectsRobots: false, uaPatterns: ["phantomjs"] },
494
+ { id: "splash", name: "Splash", category: "headless_browser", organization: "Scrapinghub", baseScore: 70, respectsRobots: false, uaPatterns: ["splash"] },
495
+ { id: "browserless", name: "Browserless", category: "headless_browser", organization: "Browserless", baseScore: 65, respectsRobots: false, uaPatterns: ["browserless"] },
496
+ { id: "browserbase", name: "Browserbase", category: "headless_browser", organization: "Browserbase", baseScore: 65, respectsRobots: false, uaPatterns: ["browserbase"] },
497
+ { id: "ia-archiver", name: "Internet Archive", category: "archiver", organization: "Internet Archive", baseScore: 25, respectsRobots: true, uaPatterns: ["ia_archiver"] },
498
+ { id: "archive-org-bot", name: "Archive.org", category: "archiver", organization: "Internet Archive", baseScore: 25, respectsRobots: true, uaPatterns: ["archive.org_bot"] },
499
+ { id: "wayback", name: "Wayback Machine", category: "archiver", organization: "Internet Archive", baseScore: 25, respectsRobots: true, uaPatterns: ["wayback"] },
500
+ { id: "heritrix", name: "Heritrix", category: "archiver", organization: "Internet Archive", baseScore: 30, respectsRobots: true, uaPatterns: ["heritrix"] },
501
+ { id: "brozzler", name: "Brozzler", category: "archiver", organization: "Internet Archive", baseScore: 30, respectsRobots: true, uaPatterns: ["brozzler"] },
502
+ { id: "facebookexternalhit", name: "Facebook", category: "fetcher", organization: "Meta", baseScore: 25, respectsRobots: true, uaPatterns: ["facebookexternalhit"] },
503
+ { id: "facebot", name: "Facebot", category: "fetcher", organization: "Meta", baseScore: 25, respectsRobots: true, uaPatterns: ["facebot"] },
504
+ { id: "twitterbot", name: "Twitterbot", category: "fetcher", organization: "X Corp", baseScore: 25, respectsRobots: true, uaPatterns: ["twitterbot"] },
505
+ { id: "linkedinbot", name: "LinkedInBot", category: "fetcher", organization: "LinkedIn", baseScore: 25, respectsRobots: true, uaPatterns: ["linkedinbot"] },
506
+ { id: "slackbot", name: "Slackbot", category: "fetcher", organization: "Slack", baseScore: 25, respectsRobots: true, uaPatterns: ["slackbot"] },
507
+ { id: "telegrambot", name: "TelegramBot", category: "fetcher", organization: "Telegram", baseScore: 25, respectsRobots: true, uaPatterns: ["telegrambot"] },
508
+ { id: "whatsapp", name: "WhatsApp", category: "fetcher", organization: "Meta", baseScore: 25, respectsRobots: true, uaPatterns: ["whatsapp"] },
509
+ { id: "discordbot", name: "Discordbot", category: "fetcher", organization: "Discord", baseScore: 25, respectsRobots: true, uaPatterns: ["discordbot"] },
510
+ { id: "pinterestbot", name: "Pinterest", category: "fetcher", organization: "Pinterest", baseScore: 30, respectsRobots: true, uaPatterns: ["pinterest"] },
511
+ { id: "tumblr", name: "Tumblr", category: "fetcher", organization: "Automattic", baseScore: 30, respectsRobots: true, uaPatterns: ["tumblr"] },
512
+ { id: "reddit", name: "Reddit", category: "fetcher", organization: "Reddit", baseScore: 30, respectsRobots: true, uaPatterns: ["reddit"] },
513
+ { id: "embedly", name: "Embedly", category: "fetcher", organization: "Medium", baseScore: 30, respectsRobots: true, uaPatterns: ["embedly"] },
514
+ { id: "iframely", name: "Iframely", category: "fetcher", organization: "Iframely", baseScore: 30, respectsRobots: true, uaPatterns: ["iframely"] },
515
+ { id: "curl", name: "cURL", category: "fetcher", organization: "Open Source", baseScore: 45, respectsRobots: false, uaPatterns: ["curl/"] },
516
+ { id: "wget", name: "Wget", category: "fetcher", organization: "GNU", baseScore: 45, respectsRobots: false, uaPatterns: ["wget/"] },
517
+ { id: "libwww-perl", name: "libwww-perl", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["libwww-perl"] },
518
+ { id: "lwp", name: "LWP", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["lwp-"] },
519
+ { id: "httrack", name: "HTTrack", category: "fetcher", organization: "Open Source", baseScore: 60, respectsRobots: true, uaPatterns: ["httrack"] },
520
+ { id: "webdecoybot", name: "WebDecoyBot", category: "monitoring", organization: "WebDecoy", baseScore: 5, respectsRobots: true, uaPatterns: ["webdecoybot"] },
521
+ { id: "uptimerobot", name: "UptimeRobot", category: "monitoring", organization: "UptimeRobot", baseScore: 20, respectsRobots: true, uaPatterns: ["uptimerobot"] },
522
+ { id: "pingdom", name: "Pingdom", category: "monitoring", organization: "SolarWinds", baseScore: 20, respectsRobots: true, uaPatterns: ["pingdom"] },
523
+ { id: "statuscake", name: "StatusCake", category: "monitoring", organization: "StatusCake", baseScore: 20, respectsRobots: true, uaPatterns: ["statuscake"] },
524
+ { id: "better-uptime", name: "Better Uptime", category: "monitoring", organization: "Better Stack", baseScore: 20, respectsRobots: true, uaPatterns: ["betteruptime"] },
525
+ { id: "datadog-synthetics", name: "Datadog Synthetics", category: "monitoring", organization: "Datadog", baseScore: 25, respectsRobots: true, uaPatterns: ["datadog"] },
526
+ { id: "newrelic", name: "New Relic", category: "monitoring", organization: "New Relic", baseScore: 25, respectsRobots: true, uaPatterns: ["newrelic"] },
527
+ { id: "site24x7", name: "Site24x7", category: "monitoring", organization: "Zoho", baseScore: 20, respectsRobots: true, uaPatterns: ["site24x7"] },
528
+ { id: "freshping", name: "Freshping", category: "monitoring", organization: "Freshworks", baseScore: 20, respectsRobots: true, uaPatterns: ["freshping"] },
529
+ { id: "hetrixtools", name: "HetrixTools", category: "monitoring", organization: "HetrixTools", baseScore: 20, respectsRobots: true, uaPatterns: ["hetrixtools"] },
530
+ { id: "nodeping", name: "NodePing", category: "monitoring", organization: "NodePing", baseScore: 20, respectsRobots: true, uaPatterns: ["nodeping"] },
531
+ { id: "gtmetrix", name: "GTmetrix", category: "monitoring", organization: "GTmetrix", baseScore: 20, respectsRobots: true, uaPatterns: ["gtmetrix"] },
532
+ { id: "chrome-lighthouse", name: "Lighthouse", category: "monitoring", organization: "Google", baseScore: 20, respectsRobots: true, uaPatterns: ["chrome-lighthouse", "google page speed"] },
533
+ { id: "feedly", name: "Feedly", category: "feed_reader", organization: "Feedly", baseScore: 25, respectsRobots: true, uaPatterns: ["feedly"] },
534
+ { id: "feedfetcher-google", name: "Feedfetcher-Google", category: "feed_reader", organization: "Google", baseScore: 25, respectsRobots: true, uaPatterns: ["feedfetcher"] },
535
+ { id: "newsblur", name: "NewsBlur", category: "feed_reader", organization: "NewsBlur", baseScore: 25, respectsRobots: true, uaPatterns: ["newsblur"] },
536
+ { id: "inoreader", name: "Inoreader", category: "feed_reader", organization: "Inoreader", baseScore: 25, respectsRobots: true, uaPatterns: ["inoreader"] },
537
+ { id: "theoldreader", name: "The Old Reader", category: "feed_reader", organization: "The Old Reader", baseScore: 25, respectsRobots: true, uaPatterns: ["theoldreader"] },
538
+ { id: "feedbin", name: "Feedbin", category: "feed_reader", organization: "Feedbin", baseScore: 25, respectsRobots: true, uaPatterns: ["feedbin"] },
539
+ { id: "miniflux", name: "Miniflux", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["miniflux"] },
540
+ { id: "freshrss", name: "FreshRSS", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["freshrss"] },
541
+ { id: "commafeed", name: "CommaFeed", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["commafeed"] },
542
+ { id: "diffbot", name: "Diffbot", category: "commercial_scraper", organization: "Diffbot", baseScore: 70, respectsRobots: true, uaPatterns: ["diffbot"] },
543
+ { id: "import-io", name: "Import.io", category: "commercial_scraper", organization: "Import.io", baseScore: 65, respectsRobots: true, uaPatterns: ["import.io"] },
544
+ { id: "bright-data", name: "Bright Data", category: "commercial_scraper", organization: "Bright Data", baseScore: 70, respectsRobots: false, uaPatterns: ["brightdata", "luminati"] },
545
+ { id: "oxylabs", name: "Oxylabs", category: "commercial_scraper", organization: "Oxylabs", baseScore: 70, respectsRobots: false, uaPatterns: ["oxylabs"] },
546
+ { id: "scrapingbee", name: "ScrapingBee", category: "commercial_scraper", organization: "ScrapingBee", baseScore: 65, respectsRobots: true, uaPatterns: ["scrapingbee"] },
547
+ { id: "scrapingant", name: "ScrapingAnt", category: "commercial_scraper", organization: "ScrapingAnt", baseScore: 65, respectsRobots: true, uaPatterns: ["scrapingant"] },
548
+ { id: "zyte", name: "Zyte", category: "commercial_scraper", organization: "Zyte", baseScore: 65, respectsRobots: true, uaPatterns: ["zyte", "scrapinghub"] },
549
+ { id: "apify", name: "Apify", category: "commercial_scraper", organization: "Apify", baseScore: 65, respectsRobots: true, uaPatterns: ["apify"] },
550
+ { id: "crawlbase", name: "Crawlbase", category: "commercial_scraper", organization: "Crawlbase", baseScore: 65, respectsRobots: true, uaPatterns: ["crawlbase"] },
551
+ { id: "webscrapingapi", name: "WebScrapingAPI", category: "commercial_scraper", organization: "WebScrapingAPI", baseScore: 65, respectsRobots: true, uaPatterns: ["webscrapingapi"] },
552
+ { id: "chatgpt-user", name: "ChatGPT-User", category: "ai_assistant", organization: "OpenAI", baseScore: 85, respectsRobots: true, uaPatterns: ["chatgpt-user"] },
553
+ { id: "perplexity-user", name: "Perplexity-User", category: "ai_assistant", organization: "Perplexity AI", baseScore: 75, respectsRobots: false, uaPatterns: ["perplexity-user"] },
554
+ { id: "mistralai-user", name: "MistralAI-User", category: "ai_assistant", organization: "Mistral AI", baseScore: 75, respectsRobots: true, uaPatterns: ["mistralai-user"] },
555
+ { id: "exauser", name: "ExaUser", category: "ai_assistant", organization: "Exa AI", baseScore: 70, respectsRobots: false, uaPatterns: ["exauser"] },
556
+ { id: "shap-user", name: "Shap-User", category: "ai_assistant", organization: "Parallel Web Systems", baseScore: 65, respectsRobots: false, uaPatterns: ["shap-user"] },
557
+ { id: "meta-externalfetcher", name: "Meta-ExternalFetcher", category: "ai_assistant", organization: "Meta", baseScore: 70, respectsRobots: false, uaPatterns: ["meta-externalfetcher"] },
558
+ { id: "gemini-deep-research", name: "Gemini-Deep-Research", category: "ai_assistant", organization: "Google", baseScore: 65, respectsRobots: true, uaPatterns: ["gemini-deep-research"] },
559
+ { id: "copilot", name: "Microsoft Copilot", category: "ai_assistant", organization: "Microsoft", baseScore: 65, respectsRobots: true, uaPatterns: ["copilot"] },
560
+ { id: "cortana", name: "Cortana", category: "ai_assistant", organization: "Microsoft", baseScore: 60, respectsRobots: true, uaPatterns: ["cortana"] },
561
+ { id: "siri", name: "Siri", category: "ai_assistant", organization: "Apple", baseScore: 60, respectsRobots: true, uaPatterns: ["siri"] }
562
+ ];
563
+
564
+ // src/bots/index.ts
565
+ var AI_CATEGORIES = /* @__PURE__ */ new Set([
566
+ "training_crawler",
567
+ "ai_search_crawler",
568
+ "ai_agent",
569
+ "ai_assistant"
570
+ ]);
571
+ var UNKNOWN = Object.freeze({
572
+ known: false,
573
+ category: "none",
574
+ score: 0,
575
+ isAI: false
576
+ });
577
+ var MAX_CACHE = 1e3;
578
+ var cache = /* @__PURE__ */ new Map();
579
+ function matchUserAgent(userAgent) {
580
+ if (!userAgent) return void 0;
581
+ const cached = cache.get(userAgent);
582
+ if (cached !== void 0) return cached ?? void 0;
583
+ const ua = userAgent.toLowerCase();
584
+ let found = null;
585
+ for (const agent of BOT_REGISTRY) {
586
+ for (const pattern of agent.uaPatterns) {
587
+ if (ua.includes(pattern)) {
588
+ found = agent;
589
+ break;
590
+ }
591
+ }
592
+ if (found) break;
593
+ }
594
+ if (cache.size >= MAX_CACHE) cache.clear();
595
+ cache.set(userAgent, found);
596
+ return found ?? void 0;
597
+ }
598
+ function classifyUserAgent(userAgent) {
599
+ const agent = matchUserAgent(userAgent);
600
+ if (!agent) return UNKNOWN;
601
+ return {
602
+ known: true,
603
+ id: agent.id,
604
+ name: agent.name,
605
+ category: agent.category,
606
+ organization: agent.organization,
607
+ score: agent.baseScore,
608
+ respectsRobots: agent.respectsRobots,
609
+ isAI: AI_CATEGORIES.has(agent.category)
610
+ };
611
+ }
612
+
351
613
  // src/local-analysis.ts
352
614
  var DATACENTER_RANGES = [
353
615
  // AWS
@@ -409,7 +671,7 @@ function isDatacenterIP(ip) {
409
671
  function hasSuspiciousHeaders(metadata) {
410
672
  const userAgent = metadata.user_agent || "";
411
673
  const headers = metadata.headers || {};
412
- const hasBotUA = SUSPICIOUS_PATTERNS.userAgents.some((pattern) => pattern.test(userAgent));
674
+ const hasBotUA = SUSPICIOUS_PATTERNS.userAgents.some((pattern) => pattern.test(userAgent)) || matchUserAgent(userAgent) !== void 0;
413
675
  const missingCommonHeaders = SUSPICIOUS_PATTERNS.missingHeaders.filter(
414
676
  (header2) => !headers[header2] && !headers[header2.toLowerCase()]
415
677
  );
@@ -1112,518 +1374,257 @@ function resolveProperty(path, context) {
1112
1374
  return void 0;
1113
1375
  }
1114
1376
  if (path.length === 1) return void 0;
1115
- return void 0;
1116
- }
1117
- function resolveCall(object, method, args, context) {
1118
- const namespace = object[0];
1119
- if (namespace === "req" && method === "header") {
1120
- if (args.length !== 1) return void 0;
1121
- const headerName = evaluate(args[0], context);
1122
- if (typeof headerName !== "string") return void 0;
1123
- return context.headers[headerName.toLowerCase()];
1124
- }
1125
- return void 0;
1126
- }
1127
- function evaluateUnary(op, operand, context) {
1128
- const val = evaluate(operand, context);
1129
- if (op === "not") {
1130
- if (val === void 0) return false;
1131
- return !val;
1132
- }
1133
- return void 0;
1134
- }
1135
- function evaluateBinary(op, left, right, context) {
1136
- if (op === "and") {
1137
- const l2 = evaluate(left, context);
1138
- if (l2 === void 0 || l2 === false) return false;
1139
- const r2 = evaluate(right, context);
1140
- if (r2 === void 0) return false;
1141
- return !!r2;
1142
- }
1143
- if (op === "or") {
1144
- const l2 = evaluate(left, context);
1145
- if (l2 === void 0 ? false : !!l2) return true;
1146
- const r2 = evaluate(right, context);
1147
- if (r2 === void 0) return false;
1148
- return !!r2;
1149
- }
1150
- const l = evaluate(left, context);
1151
- const r = evaluate(right, context);
1152
- if (l === void 0 || r === void 0) return false;
1153
- switch (op) {
1154
- case "==":
1155
- return l === r;
1156
- case "!=":
1157
- return l !== r;
1158
- case ">":
1159
- return typeof l === "number" && typeof r === "number" && l > r;
1160
- case ">=":
1161
- return typeof l === "number" && typeof r === "number" && l >= r;
1162
- case "<":
1163
- return typeof l === "number" && typeof r === "number" && l < r;
1164
- case "<=":
1165
- return typeof l === "number" && typeof r === "number" && l <= r;
1166
- case "in": {
1167
- if (!Array.isArray(r)) return false;
1168
- return r.includes(l);
1169
- }
1170
- case "not in": {
1171
- if (!Array.isArray(r)) return false;
1172
- return !r.includes(l);
1173
- }
1174
- case "matches": {
1175
- if (typeof l !== "string" || typeof r !== "string") return false;
1176
- if (r.length > MAX_REGEX_LENGTH) return false;
1177
- try {
1178
- return new RegExp(r).test(l);
1179
- } catch {
1180
- return false;
1181
- }
1182
- }
1183
- default:
1184
- return false;
1185
- }
1186
- }
1187
-
1188
- // src/rules/filter-rule.ts
1189
- var FilterRule = class {
1190
- constructor(config) {
1191
- this.expression = config.expression;
1192
- this.action = config.action ?? "DENY";
1193
- this.dryRun = config.dryRun ?? false;
1194
- this.name = `filter:${this.expression.slice(0, 50)}`;
1195
- const parser = new Parser(config.expression);
1196
- this.ast = parser.parse();
1197
- }
1198
- evaluate(context) {
1199
- if (!context.enrichment && this.expression.includes("ip.")) {
1200
- return {
1201
- action: "ALLOW",
1202
- rule: this.name,
1203
- state: "NOT_RUN",
1204
- reason: "No IP enrichment available \u2014 filter needs an API key"
1205
- };
1206
- }
1207
- const result = evaluate(this.ast, context);
1208
- if (result) {
1209
- return {
1210
- action: this.dryRun ? "ALLOW" : this.action,
1211
- rule: this.name,
1212
- reason: `Filter matched: ${this.expression}`,
1213
- metadata: {
1214
- expression: this.expression,
1215
- dryRun: this.dryRun
1216
- }
1217
- };
1218
- }
1219
- return {
1220
- action: "ALLOW",
1221
- rule: this.name
1222
- };
1223
- }
1224
- };
1225
-
1226
- // src/rules/tripwire-rule.ts
1227
- var DEFAULT_TRIPWIRE_PATHS = [
1228
- "/.git/config",
1229
- "/.git/HEAD",
1230
- "/.env",
1231
- "/.env.local",
1232
- "/.env.production",
1233
- "/wp-config.php",
1234
- "/config.php",
1235
- "/.aws/credentials",
1236
- "/.ssh/id_rsa",
1237
- "/backup.zip",
1238
- "/backup.sql",
1239
- "/database.sql",
1240
- "/dump.sql",
1241
- "/.DS_Store",
1242
- "/phpinfo.php",
1243
- "/server-status",
1244
- "/actuator/env",
1245
- "/.vscode/sftp.json"
1246
- ];
1247
- function canonicalizeTripwirePath(path) {
1248
- const noQuery = path.split("?")[0].split("#")[0];
1249
- return cleanSlashesAndDots(decodePercentAscii(noQuery));
1250
- }
1251
- function decodePercentAscii(s) {
1252
- for (let i = 0; i < 4; i++) {
1253
- const next = decodePercentAsciiOnce(s);
1254
- if (next === s) break;
1255
- s = next;
1256
- }
1257
- return s;
1258
- }
1259
- function decodePercentAsciiOnce(s) {
1260
- if (!s.includes("%")) return s;
1261
- let out = "";
1262
- for (let i = 0; i < s.length; i++) {
1263
- if (s[i] === "%" && i + 2 < s.length) {
1264
- const hi = unhexNibble(s.charCodeAt(i + 1));
1265
- const lo = unhexNibble(s.charCodeAt(i + 2));
1266
- if (hi >= 0 && lo >= 0) {
1267
- const v = hi << 4 | lo;
1268
- if (v < 128) {
1269
- out += String.fromCharCode(v);
1270
- i += 2;
1271
- continue;
1272
- }
1273
- }
1274
- }
1275
- out += s[i];
1276
- }
1277
- return out;
1278
- }
1279
- function unhexNibble(c) {
1280
- if (c >= 48 && c <= 57) return c - 48;
1281
- if (c >= 97 && c <= 102) return c - 97 + 10;
1282
- if (c >= 65 && c <= 70) return c - 65 + 10;
1283
- return -1;
1284
- }
1285
- function cleanSlashesAndDots(s) {
1286
- if (s === "") return s;
1287
- const hadTrailing = s.length > 1 && s[s.length - 1] === "/";
1288
- const stack = [];
1289
- for (const p of s.split("/")) {
1290
- if (p === "" || p === ".") continue;
1291
- if (p === "..") {
1292
- if (stack.length > 0) stack.pop();
1293
- continue;
1294
- }
1295
- stack.push(p);
1296
- }
1297
- let res = "/" + stack.join("/");
1298
- if (hadTrailing && res !== "/") res += "/";
1299
- return res;
1300
- }
1301
- var TripwireRule = class {
1302
- constructor(config = {}) {
1303
- this.name = "tripwire";
1304
- const paths = [...config.paths ?? []];
1305
- if (config.includeDefaults ?? true) paths.push(...DEFAULT_TRIPWIRE_PATHS);
1306
- this.exact = new Set(paths.map(canonicalizeTripwirePath));
1307
- this.prefixes = (config.prefixes ?? []).map(canonicalizeTripwirePath);
1308
- this.patterns = config.patterns ?? [];
1309
- this.action = config.action ?? "DENY";
1310
- this.dryRun = config.dryRun ?? false;
1311
- }
1312
- evaluate(context) {
1313
- const path = canonicalizeTripwirePath(context.path);
1314
- const hit = this.exact.has(path) || this.prefixes.some((prefix) => path.startsWith(prefix)) || this.patterns.some((re2) => re2.test(path));
1315
- if (hit) {
1316
- return {
1317
- action: this.dryRun ? "ALLOW" : this.action,
1318
- rule: this.name,
1319
- reason: `Tripwire hit: ${path} \u2014 hidden honeypot path, deterministic automated-intent signal`,
1320
- metadata: { path, dryRun: this.dryRun, confidence: 100 }
1321
- };
1322
- }
1323
- return { action: "ALLOW", rule: this.name };
1324
- }
1325
- };
1326
-
1327
- // src/rules/bot-rule.ts
1328
- var BotRule = class {
1329
- constructor(config = {}) {
1330
- this.name = "bots";
1331
- this.categories = new Set(config.categories ?? []);
1332
- this.agents = new Set((config.agents ?? []).map((a) => a.toLowerCase()));
1333
- this.ai = config.ai ?? false;
1334
- this.allow = new Set((config.allow ?? []).map((a) => a.toLowerCase()));
1335
- this.action = config.action ?? "DENY";
1336
- this.dryRun = config.dryRun ?? false;
1377
+ return void 0;
1378
+ }
1379
+ function resolveCall(object, method, args, context) {
1380
+ const namespace = object[0];
1381
+ if (namespace === "req" && method === "header") {
1382
+ if (args.length !== 1) return void 0;
1383
+ const headerName = evaluate(args[0], context);
1384
+ if (typeof headerName !== "string") return void 0;
1385
+ return context.headers[headerName.toLowerCase()];
1337
1386
  }
1338
- evaluate(context) {
1339
- const bot = context.bot;
1340
- if (!bot?.known) return { action: "ALLOW", rule: this.name };
1341
- const id = bot.id?.toLowerCase();
1342
- const name = bot.name?.toLowerCase();
1343
- if (id && this.allow.has(id) || name && this.allow.has(name)) {
1344
- return { action: "ALLOW", rule: this.name };
1345
- }
1346
- const matched = this.ai && bot.isAI || this.categories.has(bot.category) || id !== void 0 && this.agents.has(id) || name !== void 0 && this.agents.has(name);
1347
- if (!matched) return { action: "ALLOW", rule: this.name };
1348
- return {
1349
- action: this.dryRun ? "ALLOW" : this.action,
1350
- rule: this.name,
1351
- reason: `${bot.name ?? "Bot"} (${bot.category}) matched a bot policy rule`,
1352
- metadata: {
1353
- bot: bot.id,
1354
- botName: bot.name,
1355
- category: bot.category,
1356
- organization: bot.organization,
1357
- dryRun: this.dryRun,
1358
- // Deliberately not 100. The match is a self-declared User-Agent, and a
1359
- // downstream consumer that treats this like a tripwire hit would be
1360
- // wrong: a tripwire proves behaviour, this repeats a claim.
1361
- confidence: 70
1362
- }
1363
- };
1387
+ return void 0;
1388
+ }
1389
+ function evaluateUnary(op, operand, context) {
1390
+ const val = evaluate(operand, context);
1391
+ if (op === "not") {
1392
+ if (val === void 0) return false;
1393
+ return !val;
1364
1394
  }
1365
- };
1366
-
1367
- // src/bots/registry.generated.ts
1368
- var BOT_CATEGORIES = [
1369
- "training_crawler",
1370
- "ai_search_crawler",
1371
- "ai_agent",
1372
- "ai_assistant",
1373
- "search_crawler",
1374
- "seo_crawler",
1375
- "security_scanner",
1376
- "generic_scraper",
1377
- "archiver",
1378
- "fetcher",
1379
- "monitoring",
1380
- "headless_browser",
1381
- "feed_reader",
1382
- "commercial_scraper",
1383
- "none"
1384
- ];
1385
- var BOT_REGISTRY = [
1386
- { id: "reflectionbot", name: "Reflectionbot", category: "training_crawler", organization: "Reflection AI", baseScore: 70, respectsRobots: true, uaPatterns: ["reflectionbot"] },
1387
- { id: "gptbot", name: "GPTBot", category: "training_crawler", organization: "OpenAI", baseScore: 85, respectsRobots: true, uaPatterns: ["gptbot"] },
1388
- { id: "claudebot", name: "ClaudeBot", category: "training_crawler", organization: "Anthropic", baseScore: 85, respectsRobots: true, uaPatterns: ["claudebot"] },
1389
- { id: "anthropic", name: "Anthropic", category: "training_crawler", organization: "Anthropic", baseScore: 85, respectsRobots: true, uaPatterns: ["anthropic-ai"] },
1390
- { id: "claude-web", name: "Claude-Web", category: "training_crawler", organization: "Anthropic", baseScore: 85, respectsRobots: true, uaPatterns: ["claude-web"] },
1391
- { id: "ccbot", name: "CCBot", category: "training_crawler", organization: "Common Crawl", baseScore: 80, respectsRobots: true, uaPatterns: ["ccbot"] },
1392
- { id: "google-extended", name: "Google-Extended", category: "training_crawler", organization: "Google", baseScore: 80, respectsRobots: true, uaPatterns: ["google-extended"] },
1393
- { id: "bytespider", name: "ByteSpider", category: "training_crawler", organization: "ByteDance", baseScore: 75, respectsRobots: false, uaPatterns: ["bytespider"] },
1394
- { id: "amazonbot", name: "Amazonbot", category: "training_crawler", organization: "Amazon", baseScore: 70, respectsRobots: true, uaPatterns: ["amazonbot"] },
1395
- { id: "facebookbot", name: "FacebookBot", category: "training_crawler", organization: "Meta", baseScore: 70, respectsRobots: true, uaPatterns: ["facebookbot"] },
1396
- { id: "meta-externalagent", name: "Meta-ExternalAgent", category: "training_crawler", organization: "Meta", baseScore: 75, respectsRobots: true, uaPatterns: ["meta-externalagent"] },
1397
- { id: "cohere-ai", name: "Cohere", category: "training_crawler", organization: "Cohere", baseScore: 80, respectsRobots: true, uaPatterns: ["cohere-ai", "cohere"] },
1398
- { id: "applebot-extended", name: "Applebot-Extended", category: "training_crawler", organization: "Apple", baseScore: 75, respectsRobots: true, uaPatterns: ["applebot-extended"] },
1399
- { id: "youbot", name: "YouBot", category: "training_crawler", organization: "You.com", baseScore: 75, respectsRobots: true, uaPatterns: ["youbot"] },
1400
- { id: "mistral", name: "MistralBot", category: "training_crawler", organization: "Mistral AI", baseScore: 80, respectsRobots: true, uaPatterns: ["mistralbot"] },
1401
- { id: "gemini", name: "Gemini", category: "training_crawler", organization: "Google", baseScore: 80, respectsRobots: true, uaPatterns: ["gemini"] },
1402
- { id: "ai2bot", name: "AI2Bot", category: "training_crawler", organization: "Allen Institute for AI", baseScore: 75, respectsRobots: true, uaPatterns: ["ai2bot"] },
1403
- { id: "deepseek", name: "DeepSeek", category: "training_crawler", organization: "DeepSeek", baseScore: 80, respectsRobots: true, uaPatterns: ["deepseek"] },
1404
- { id: "qwen", name: "Qwen", category: "training_crawler", organization: "Alibaba", baseScore: 75, respectsRobots: true, uaPatterns: ["qwen"] },
1405
- { id: "webzio", name: "Webz.io", category: "training_crawler", organization: "Webz.io", baseScore: 70, respectsRobots: false, uaPatterns: ["webzio"] },
1406
- { id: "sentibot", name: "Sentibot", category: "training_crawler", organization: "Sentibot", baseScore: 70, respectsRobots: false, uaPatterns: ["sentibot"] },
1407
- { id: "omgili", name: "Omgili", category: "training_crawler", organization: "Webz.io", baseScore: 70, respectsRobots: false, uaPatterns: ["omgili"] },
1408
- { id: "img2dataset", name: "img2dataset", category: "training_crawler", organization: "LAION", baseScore: 75, respectsRobots: false, uaPatterns: ["img2dataset"] },
1409
- { id: "timpibot", name: "Timpibot", category: "training_crawler", organization: "Timpi", baseScore: 70, respectsRobots: true, uaPatterns: ["timpibot"] },
1410
- { id: "velenpublicwebcrawler", name: "VelenPublicWebCrawler", category: "training_crawler", organization: "Velen", baseScore: 70, respectsRobots: false, uaPatterns: ["velenpublicwebcrawler"] },
1411
- { id: "isscyberriskcrawler", name: "ISSCyberRiskCrawler", category: "training_crawler", organization: "ISS", baseScore: 65, respectsRobots: false, uaPatterns: ["isscyberriskcrawler"] },
1412
- { id: "friendlycrawler", name: "FriendlyCrawler", category: "training_crawler", organization: "Unknown", baseScore: 65, respectsRobots: true, uaPatterns: ["friendlycrawler"] },
1413
- { id: "duckassistbot", name: "DuckAssistBot", category: "ai_search_crawler", organization: "DuckDuckGo", baseScore: 65, respectsRobots: true, uaPatterns: ["duckassistbot"] },
1414
- { id: "sofyabot", name: "SofyaBot", category: "ai_search_crawler", organization: "Sofya", baseScore: 65, respectsRobots: true, uaPatterns: ["sofyabot"] },
1415
- { id: "xai-searchbot", name: "xAI-SearchBot", category: "ai_search_crawler", organization: "xAI", baseScore: 70, respectsRobots: true, uaPatterns: ["xai-searchbot"] },
1416
- { id: "linkupbot", name: "LinkupBot", category: "ai_search_crawler", organization: "Linkup", baseScore: 65, respectsRobots: true, uaPatterns: ["linkupbot"] },
1417
- { id: "perplexitybot", name: "PerplexityBot", category: "ai_search_crawler", organization: "Perplexity AI", baseScore: 80, respectsRobots: true, uaPatterns: ["perplexitybot"] },
1418
- { id: "claude-searchbot", name: "Claude-SearchBot", category: "ai_search_crawler", organization: "Anthropic", baseScore: 75, respectsRobots: true, uaPatterns: ["claude-searchbot"] },
1419
- { id: "oai-searchbot", name: "OAI-SearchBot", category: "ai_search_crawler", organization: "OpenAI", baseScore: 80, respectsRobots: true, uaPatterns: ["oai-searchbot"] },
1420
- { id: "searchgpt", name: "SearchGPT", category: "ai_search_crawler", organization: "OpenAI", baseScore: 75, respectsRobots: true, uaPatterns: ["searchgpt"] },
1421
- { id: "phind", name: "Phind", category: "ai_search_crawler", organization: "Phind", baseScore: 70, respectsRobots: true, uaPatterns: ["phind"] },
1422
- { id: "kagi", name: "Kagi", category: "ai_search_crawler", organization: "Kagi", baseScore: 65, respectsRobots: true, uaPatterns: ["kagi"] },
1423
- { id: "exa", name: "Exa", category: "ai_search_crawler", organization: "Exa AI", baseScore: 70, respectsRobots: true, uaPatterns: ["exasearchbot", "exabot"] },
1424
- { id: "shapbot", name: "ShapBot", category: "ai_search_crawler", organization: "Parallel Web Systems", baseScore: 65, respectsRobots: true, uaPatterns: ["shapbot"] },
1425
- { id: "meta-webindexer", name: "Meta-WebIndexer", category: "ai_search_crawler", organization: "Meta", baseScore: 70, respectsRobots: true, uaPatterns: ["meta-webindexer"] },
1426
- { id: "metaphor", name: "Metaphor", category: "ai_search_crawler", organization: "Metaphor", baseScore: 70, respectsRobots: true, uaPatterns: ["metaphor"] },
1427
- { id: "tavily", name: "Tavily", category: "ai_search_crawler", organization: "Tavily", baseScore: 70, respectsRobots: true, uaPatterns: ["tavily"] },
1428
- { id: "brave-search", name: "BraveSearch", category: "ai_search_crawler", organization: "Brave", baseScore: 65, respectsRobots: true, uaPatterns: ["bravesearch"] },
1429
- { id: "neeva", name: "NeevaBot", category: "ai_search_crawler", organization: "Neeva", baseScore: 65, respectsRobots: true, uaPatterns: ["neevabot"] },
1430
- { id: "operator", name: "Operator", category: "ai_agent", organization: "OpenAI", baseScore: 75, respectsRobots: true, uaPatterns: ["operator"] },
1431
- { id: "claude-user", name: "Claude-User", category: "ai_agent", organization: "Anthropic", baseScore: 75, respectsRobots: true, uaPatterns: ["claude-user"] },
1432
- { id: "gemini-user", name: "Gemini-User", category: "ai_agent", organization: "Google", baseScore: 75, respectsRobots: true, uaPatterns: ["gemini-user"] },
1433
- { id: "googleagent-mariner", name: "GoogleAgent-Mariner", category: "ai_agent", organization: "Google", baseScore: 75, respectsRobots: true, uaPatterns: ["googleagent-mariner", "mariner"] },
1434
- { id: "amazon-buyforme", name: "AmazonBuyForMe", category: "ai_agent", organization: "Amazon", baseScore: 70, respectsRobots: true, uaPatterns: ["amazonbuyforme", "buyforme"] },
1435
- { id: "browser-use", name: "Browser-Use", category: "ai_agent", organization: "Open Source", baseScore: 70, respectsRobots: false, uaPatterns: ["browser-use"] },
1436
- { id: "stagehand", name: "Stagehand", category: "ai_agent", organization: "Browserbase", baseScore: 70, respectsRobots: false, uaPatterns: ["stagehand"] },
1437
- { id: "manus-user", name: "Manus-User", category: "ai_agent", organization: "Manus", baseScore: 70, respectsRobots: false, uaPatterns: ["manus-user"] },
1438
- { id: "multion", name: "MultiOn", category: "ai_agent", organization: "MultiOn", baseScore: 70, respectsRobots: false, uaPatterns: ["multion"] },
1439
- { id: "iboubot", name: "IbouBot", category: "search_crawler", organization: "Ibou", baseScore: 30, respectsRobots: true, uaPatterns: ["iboubot"] },
1440
- { id: "googlebot", name: "Googlebot", category: "search_crawler", organization: "Google", baseScore: 30, respectsRobots: true, uaPatterns: ["googlebot"] },
1441
- { id: "google-inspectiontool", name: "Google-InspectionTool", category: "search_crawler", organization: "Google", baseScore: 30, respectsRobots: true, uaPatterns: ["google-inspectiontool"] },
1442
- { id: "bingbot", name: "Bingbot", category: "search_crawler", organization: "Microsoft", baseScore: 30, respectsRobots: true, uaPatterns: ["bingbot"] },
1443
- { id: "msnbot", name: "MSNBot", category: "search_crawler", organization: "Microsoft", baseScore: 30, respectsRobots: true, uaPatterns: ["msnbot"] },
1444
- { id: "yandexbot", name: "YandexBot", category: "search_crawler", organization: "Yandex", baseScore: 35, respectsRobots: true, uaPatterns: ["yandexbot"] },
1445
- { id: "baiduspider", name: "Baiduspider", category: "search_crawler", organization: "Baidu", baseScore: 40, respectsRobots: true, uaPatterns: ["baiduspider"] },
1446
- { id: "duckduckbot", name: "DuckDuckBot", category: "search_crawler", organization: "DuckDuckGo", baseScore: 30, respectsRobots: true, uaPatterns: ["duckduckbot"] },
1447
- { id: "applebot", name: "Applebot", category: "search_crawler", organization: "Apple", baseScore: 30, respectsRobots: true, uaPatterns: ["applebot"] },
1448
- { id: "sogou", name: "Sogou Spider", category: "search_crawler", organization: "Sogou", baseScore: 40, respectsRobots: true, uaPatterns: ["sogou"] },
1449
- { id: "qwantify", name: "Qwantify", category: "search_crawler", organization: "Qwant", baseScore: 35, respectsRobots: true, uaPatterns: ["qwantify"] },
1450
- { id: "naver", name: "Naver", category: "search_crawler", organization: "Naver", baseScore: 35, respectsRobots: true, uaPatterns: ["naver", "yeti"] },
1451
- { id: "seznam", name: "SeznamBot", category: "search_crawler", organization: "Seznam", baseScore: 35, respectsRobots: true, uaPatterns: ["seznambot"] },
1452
- { id: "ecosia", name: "Ecosia", category: "search_crawler", organization: "Ecosia", baseScore: 30, respectsRobots: true, uaPatterns: ["ecosia"] },
1453
- { id: "mojeek", name: "MojeekBot", category: "search_crawler", organization: "Mojeek", baseScore: 35, respectsRobots: true, uaPatterns: ["mojeekbot"] },
1454
- { id: "yahoo-slurp", name: "Yahoo! Slurp", category: "search_crawler", organization: "Yahoo", baseScore: 30, respectsRobots: true, uaPatterns: ["slurp"] },
1455
- { id: "ahrefsbot", name: "AhrefsBot", category: "seo_crawler", organization: "Ahrefs", baseScore: 50, respectsRobots: true, uaPatterns: ["ahrefsbot", "ahrefs"] },
1456
- { id: "semrushbot", name: "SemrushBot", category: "seo_crawler", organization: "Semrush", baseScore: 50, respectsRobots: true, uaPatterns: ["semrushbot", "semrush"] },
1457
- { id: "mj12bot", name: "MJ12bot", category: "seo_crawler", organization: "Majestic", baseScore: 50, respectsRobots: true, uaPatterns: ["mj12bot"] },
1458
- { id: "dotbot", name: "DotBot", category: "seo_crawler", organization: "Moz", baseScore: 50, respectsRobots: true, uaPatterns: ["dotbot"] },
1459
- { id: "rogerbot", name: "Rogerbot", category: "seo_crawler", organization: "Moz", baseScore: 50, respectsRobots: true, uaPatterns: ["rogerbot"] },
1460
- { id: "screaming-frog", name: "Screaming Frog", category: "seo_crawler", organization: "Screaming Frog", baseScore: 55, respectsRobots: true, uaPatterns: ["screaming frog"] },
1461
- { id: "sitebulb", name: "Sitebulb", category: "seo_crawler", organization: "Sitebulb", baseScore: 55, respectsRobots: true, uaPatterns: ["sitebulb"] },
1462
- { id: "deepcrawl", name: "DeepCrawl", category: "seo_crawler", organization: "Lumar", baseScore: 50, respectsRobots: true, uaPatterns: ["deepcrawl"] },
1463
- { id: "oncrawl", name: "OnCrawl", category: "seo_crawler", organization: "OnCrawl", baseScore: 50, respectsRobots: true, uaPatterns: ["oncrawl"] },
1464
- { id: "botify", name: "Botify", category: "seo_crawler", organization: "Botify", baseScore: 50, respectsRobots: true, uaPatterns: ["botify"] },
1465
- { id: "contentking", name: "ContentKing", category: "seo_crawler", organization: "ContentKing", baseScore: 50, respectsRobots: true, uaPatterns: ["contentking"] },
1466
- { id: "sistrix", name: "SISTRIX", category: "seo_crawler", organization: "SISTRIX", baseScore: 50, respectsRobots: true, uaPatterns: ["sistrix"] },
1467
- { id: "serpstat", name: "Serpstat", category: "seo_crawler", organization: "Serpstat", baseScore: 50, respectsRobots: true, uaPatterns: ["serpstat"] },
1468
- { id: "spyfu", name: "SpyFu", category: "seo_crawler", organization: "SpyFu", baseScore: 50, respectsRobots: true, uaPatterns: ["spyfu"] },
1469
- { id: "nessus", name: "Nessus", category: "security_scanner", organization: "Tenable", baseScore: 70, respectsRobots: false, uaPatterns: ["nessus"] },
1470
- { id: "qualys", name: "Qualys", category: "security_scanner", organization: "Qualys", baseScore: 70, respectsRobots: false, uaPatterns: ["qualys"] },
1471
- { id: "shodan", name: "Shodan", category: "security_scanner", organization: "Shodan", baseScore: 75, respectsRobots: false, uaPatterns: ["shodan"] },
1472
- { id: "censys", name: "Censys", category: "security_scanner", organization: "Censys", baseScore: 75, respectsRobots: false, uaPatterns: ["censys"] },
1473
- { id: "nmap", name: "Nmap", category: "security_scanner", organization: "Open Source", baseScore: 70, respectsRobots: false, uaPatterns: ["nmap"] },
1474
- { id: "zap", name: "OWASP ZAP", category: "security_scanner", organization: "OWASP", baseScore: 70, respectsRobots: false, uaPatterns: ["zap/"] },
1475
- { id: "burp", name: "Burp Suite", category: "security_scanner", organization: "PortSwigger", baseScore: 70, respectsRobots: false, uaPatterns: ["burp"] },
1476
- { id: "nikto", name: "Nikto", category: "security_scanner", organization: "Open Source", baseScore: 70, respectsRobots: false, uaPatterns: ["nikto"] },
1477
- { id: "nuclei", name: "Nuclei", category: "security_scanner", organization: "ProjectDiscovery", baseScore: 70, respectsRobots: false, uaPatterns: ["nuclei"] },
1478
- { id: "acunetix", name: "Acunetix", category: "security_scanner", organization: "Invicti", baseScore: 70, respectsRobots: false, uaPatterns: ["acunetix"] },
1479
- { id: "netsparker", name: "Netsparker", category: "security_scanner", organization: "Invicti", baseScore: 70, respectsRobots: false, uaPatterns: ["netsparker"] },
1480
- { id: "detectify", name: "Detectify", category: "security_scanner", organization: "Detectify", baseScore: 65, respectsRobots: false, uaPatterns: ["detectify"] },
1481
- { id: "intruder", name: "Intruder", category: "security_scanner", organization: "Intruder", baseScore: 65, respectsRobots: false, uaPatterns: ["intruder"] },
1482
- { id: "python-requests", name: "Python-Requests", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["python-requests"] },
1483
- { id: "python-urllib", name: "Python-urllib", category: "generic_scraper", organization: "Python", baseScore: 55, respectsRobots: false, uaPatterns: ["python-urllib"] },
1484
- { id: "python", name: "Python", category: "generic_scraper", organization: "Python", baseScore: 50, respectsRobots: false, uaPatterns: ["python/"] },
1485
- { id: "scrapy", name: "Scrapy", category: "generic_scraper", organization: "Scrapy", baseScore: 65, respectsRobots: true, uaPatterns: ["scrapy"] },
1486
- { id: "httpx", name: "HTTPX", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["httpx"] },
1487
- { id: "aiohttp", name: "aiohttp", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["aiohttp"] },
1488
- { id: "beautifulsoup", name: "BeautifulSoup", category: "generic_scraper", organization: "Open Source", baseScore: 60, respectsRobots: false, uaPatterns: ["beautifulsoup"] },
1489
- { id: "node-fetch", name: "node-fetch", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["node-fetch"] },
1490
- { id: "axios", name: "Axios", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["axios/"] },
1491
- { id: "got", name: "Got", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["got/"] },
1492
- { id: "undici", name: "Undici", category: "generic_scraper", organization: "Node.js", baseScore: 55, respectsRobots: false, uaPatterns: ["undici"] },
1493
- { id: "go-http-client", name: "Go-HTTP-Client", category: "generic_scraper", organization: "Go", baseScore: 55, respectsRobots: false, uaPatterns: ["go-http-client"] },
1494
- { id: "colly", name: "Colly", category: "generic_scraper", organization: "Open Source", baseScore: 65, respectsRobots: true, uaPatterns: ["colly"] },
1495
- { id: "java", name: "Java", category: "generic_scraper", organization: "Oracle", baseScore: 50, respectsRobots: false, uaPatterns: ["java/"] },
1496
- { id: "okhttp", name: "OkHttp", category: "generic_scraper", organization: "Square", baseScore: 55, respectsRobots: false, uaPatterns: ["okhttp"] },
1497
- { id: "apache-httpclient", name: "Apache-HttpClient", category: "generic_scraper", organization: "Apache", baseScore: 55, respectsRobots: false, uaPatterns: ["apache-httpclient"] },
1498
- { id: "jsoup", name: "Jsoup", category: "generic_scraper", organization: "Open Source", baseScore: 60, respectsRobots: false, uaPatterns: ["jsoup"] },
1499
- { id: "guzzlehttp", name: "GuzzleHttp", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["guzzlehttp"] },
1500
- { id: "php", name: "PHP", category: "generic_scraper", organization: "PHP", baseScore: 50, respectsRobots: false, uaPatterns: ["php/"] },
1501
- { id: "ruby", name: "Ruby", category: "generic_scraper", organization: "Ruby", baseScore: 50, respectsRobots: false, uaPatterns: ["ruby"] },
1502
- { id: "faraday", name: "Faraday", category: "generic_scraper", organization: "Open Source", baseScore: 55, respectsRobots: false, uaPatterns: ["faraday"] },
1503
- { id: "mechanize", name: "Mechanize", category: "generic_scraper", organization: "Open Source", baseScore: 60, respectsRobots: false, uaPatterns: ["mechanize"] },
1504
- { id: "headlesschrome", name: "HeadlessChrome", category: "headless_browser", organization: "Google", baseScore: 70, respectsRobots: false, uaPatterns: ["headlesschrome"] },
1505
- { id: "puppeteer", name: "Puppeteer", category: "headless_browser", organization: "Google", baseScore: 70, respectsRobots: false, uaPatterns: ["puppeteer"] },
1506
- { id: "playwright", name: "Playwright", category: "headless_browser", organization: "Microsoft", baseScore: 70, respectsRobots: false, uaPatterns: ["playwright"] },
1507
- { id: "selenium", name: "Selenium", category: "headless_browser", organization: "Open Source", baseScore: 70, respectsRobots: false, uaPatterns: ["selenium"] },
1508
- { id: "phantomjs", name: "PhantomJS", category: "headless_browser", organization: "Open Source", baseScore: 75, respectsRobots: false, uaPatterns: ["phantomjs"] },
1509
- { id: "splash", name: "Splash", category: "headless_browser", organization: "Scrapinghub", baseScore: 70, respectsRobots: false, uaPatterns: ["splash"] },
1510
- { id: "browserless", name: "Browserless", category: "headless_browser", organization: "Browserless", baseScore: 65, respectsRobots: false, uaPatterns: ["browserless"] },
1511
- { id: "browserbase", name: "Browserbase", category: "headless_browser", organization: "Browserbase", baseScore: 65, respectsRobots: false, uaPatterns: ["browserbase"] },
1512
- { id: "ia-archiver", name: "Internet Archive", category: "archiver", organization: "Internet Archive", baseScore: 25, respectsRobots: true, uaPatterns: ["ia_archiver"] },
1513
- { id: "archive-org-bot", name: "Archive.org", category: "archiver", organization: "Internet Archive", baseScore: 25, respectsRobots: true, uaPatterns: ["archive.org_bot"] },
1514
- { id: "wayback", name: "Wayback Machine", category: "archiver", organization: "Internet Archive", baseScore: 25, respectsRobots: true, uaPatterns: ["wayback"] },
1515
- { id: "heritrix", name: "Heritrix", category: "archiver", organization: "Internet Archive", baseScore: 30, respectsRobots: true, uaPatterns: ["heritrix"] },
1516
- { id: "brozzler", name: "Brozzler", category: "archiver", organization: "Internet Archive", baseScore: 30, respectsRobots: true, uaPatterns: ["brozzler"] },
1517
- { id: "facebookexternalhit", name: "Facebook", category: "fetcher", organization: "Meta", baseScore: 25, respectsRobots: true, uaPatterns: ["facebookexternalhit"] },
1518
- { id: "facebot", name: "Facebot", category: "fetcher", organization: "Meta", baseScore: 25, respectsRobots: true, uaPatterns: ["facebot"] },
1519
- { id: "twitterbot", name: "Twitterbot", category: "fetcher", organization: "X Corp", baseScore: 25, respectsRobots: true, uaPatterns: ["twitterbot"] },
1520
- { id: "linkedinbot", name: "LinkedInBot", category: "fetcher", organization: "LinkedIn", baseScore: 25, respectsRobots: true, uaPatterns: ["linkedinbot"] },
1521
- { id: "slackbot", name: "Slackbot", category: "fetcher", organization: "Slack", baseScore: 25, respectsRobots: true, uaPatterns: ["slackbot"] },
1522
- { id: "telegrambot", name: "TelegramBot", category: "fetcher", organization: "Telegram", baseScore: 25, respectsRobots: true, uaPatterns: ["telegrambot"] },
1523
- { id: "whatsapp", name: "WhatsApp", category: "fetcher", organization: "Meta", baseScore: 25, respectsRobots: true, uaPatterns: ["whatsapp"] },
1524
- { id: "discordbot", name: "Discordbot", category: "fetcher", organization: "Discord", baseScore: 25, respectsRobots: true, uaPatterns: ["discordbot"] },
1525
- { id: "pinterestbot", name: "Pinterest", category: "fetcher", organization: "Pinterest", baseScore: 30, respectsRobots: true, uaPatterns: ["pinterest"] },
1526
- { id: "tumblr", name: "Tumblr", category: "fetcher", organization: "Automattic", baseScore: 30, respectsRobots: true, uaPatterns: ["tumblr"] },
1527
- { id: "reddit", name: "Reddit", category: "fetcher", organization: "Reddit", baseScore: 30, respectsRobots: true, uaPatterns: ["reddit"] },
1528
- { id: "embedly", name: "Embedly", category: "fetcher", organization: "Medium", baseScore: 30, respectsRobots: true, uaPatterns: ["embedly"] },
1529
- { id: "iframely", name: "Iframely", category: "fetcher", organization: "Iframely", baseScore: 30, respectsRobots: true, uaPatterns: ["iframely"] },
1530
- { id: "curl", name: "cURL", category: "fetcher", organization: "Open Source", baseScore: 45, respectsRobots: false, uaPatterns: ["curl/"] },
1531
- { id: "wget", name: "Wget", category: "fetcher", organization: "GNU", baseScore: 45, respectsRobots: false, uaPatterns: ["wget/"] },
1532
- { id: "libwww-perl", name: "libwww-perl", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["libwww-perl"] },
1533
- { id: "lwp", name: "LWP", category: "fetcher", organization: "Perl", baseScore: 50, respectsRobots: false, uaPatterns: ["lwp-"] },
1534
- { id: "httrack", name: "HTTrack", category: "fetcher", organization: "Open Source", baseScore: 60, respectsRobots: true, uaPatterns: ["httrack"] },
1535
- { id: "webdecoybot", name: "WebDecoyBot", category: "monitoring", organization: "WebDecoy", baseScore: 5, respectsRobots: true, uaPatterns: ["webdecoybot"] },
1536
- { id: "uptimerobot", name: "UptimeRobot", category: "monitoring", organization: "UptimeRobot", baseScore: 20, respectsRobots: true, uaPatterns: ["uptimerobot"] },
1537
- { id: "pingdom", name: "Pingdom", category: "monitoring", organization: "SolarWinds", baseScore: 20, respectsRobots: true, uaPatterns: ["pingdom"] },
1538
- { id: "statuscake", name: "StatusCake", category: "monitoring", organization: "StatusCake", baseScore: 20, respectsRobots: true, uaPatterns: ["statuscake"] },
1539
- { id: "better-uptime", name: "Better Uptime", category: "monitoring", organization: "Better Stack", baseScore: 20, respectsRobots: true, uaPatterns: ["betteruptime"] },
1540
- { id: "datadog-synthetics", name: "Datadog Synthetics", category: "monitoring", organization: "Datadog", baseScore: 25, respectsRobots: true, uaPatterns: ["datadog"] },
1541
- { id: "newrelic", name: "New Relic", category: "monitoring", organization: "New Relic", baseScore: 25, respectsRobots: true, uaPatterns: ["newrelic"] },
1542
- { id: "site24x7", name: "Site24x7", category: "monitoring", organization: "Zoho", baseScore: 20, respectsRobots: true, uaPatterns: ["site24x7"] },
1543
- { id: "freshping", name: "Freshping", category: "monitoring", organization: "Freshworks", baseScore: 20, respectsRobots: true, uaPatterns: ["freshping"] },
1544
- { id: "hetrixtools", name: "HetrixTools", category: "monitoring", organization: "HetrixTools", baseScore: 20, respectsRobots: true, uaPatterns: ["hetrixtools"] },
1545
- { id: "nodeping", name: "NodePing", category: "monitoring", organization: "NodePing", baseScore: 20, respectsRobots: true, uaPatterns: ["nodeping"] },
1546
- { id: "gtmetrix", name: "GTmetrix", category: "monitoring", organization: "GTmetrix", baseScore: 20, respectsRobots: true, uaPatterns: ["gtmetrix"] },
1547
- { id: "chrome-lighthouse", name: "Lighthouse", category: "monitoring", organization: "Google", baseScore: 20, respectsRobots: true, uaPatterns: ["chrome-lighthouse", "google page speed"] },
1548
- { id: "feedly", name: "Feedly", category: "feed_reader", organization: "Feedly", baseScore: 25, respectsRobots: true, uaPatterns: ["feedly"] },
1549
- { id: "feedfetcher-google", name: "Feedfetcher-Google", category: "feed_reader", organization: "Google", baseScore: 25, respectsRobots: true, uaPatterns: ["feedfetcher"] },
1550
- { id: "newsblur", name: "NewsBlur", category: "feed_reader", organization: "NewsBlur", baseScore: 25, respectsRobots: true, uaPatterns: ["newsblur"] },
1551
- { id: "inoreader", name: "Inoreader", category: "feed_reader", organization: "Inoreader", baseScore: 25, respectsRobots: true, uaPatterns: ["inoreader"] },
1552
- { id: "theoldreader", name: "The Old Reader", category: "feed_reader", organization: "The Old Reader", baseScore: 25, respectsRobots: true, uaPatterns: ["theoldreader"] },
1553
- { id: "feedbin", name: "Feedbin", category: "feed_reader", organization: "Feedbin", baseScore: 25, respectsRobots: true, uaPatterns: ["feedbin"] },
1554
- { id: "miniflux", name: "Miniflux", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["miniflux"] },
1555
- { id: "freshrss", name: "FreshRSS", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["freshrss"] },
1556
- { id: "commafeed", name: "CommaFeed", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["commafeed"] },
1557
- { id: "diffbot", name: "Diffbot", category: "commercial_scraper", organization: "Diffbot", baseScore: 70, respectsRobots: true, uaPatterns: ["diffbot"] },
1558
- { id: "import-io", name: "Import.io", category: "commercial_scraper", organization: "Import.io", baseScore: 65, respectsRobots: true, uaPatterns: ["import.io"] },
1559
- { id: "bright-data", name: "Bright Data", category: "commercial_scraper", organization: "Bright Data", baseScore: 70, respectsRobots: false, uaPatterns: ["brightdata", "luminati"] },
1560
- { id: "oxylabs", name: "Oxylabs", category: "commercial_scraper", organization: "Oxylabs", baseScore: 70, respectsRobots: false, uaPatterns: ["oxylabs"] },
1561
- { id: "scrapingbee", name: "ScrapingBee", category: "commercial_scraper", organization: "ScrapingBee", baseScore: 65, respectsRobots: true, uaPatterns: ["scrapingbee"] },
1562
- { id: "scrapingant", name: "ScrapingAnt", category: "commercial_scraper", organization: "ScrapingAnt", baseScore: 65, respectsRobots: true, uaPatterns: ["scrapingant"] },
1563
- { id: "zyte", name: "Zyte", category: "commercial_scraper", organization: "Zyte", baseScore: 65, respectsRobots: true, uaPatterns: ["zyte", "scrapinghub"] },
1564
- { id: "apify", name: "Apify", category: "commercial_scraper", organization: "Apify", baseScore: 65, respectsRobots: true, uaPatterns: ["apify"] },
1565
- { id: "crawlbase", name: "Crawlbase", category: "commercial_scraper", organization: "Crawlbase", baseScore: 65, respectsRobots: true, uaPatterns: ["crawlbase"] },
1566
- { id: "webscrapingapi", name: "WebScrapingAPI", category: "commercial_scraper", organization: "WebScrapingAPI", baseScore: 65, respectsRobots: true, uaPatterns: ["webscrapingapi"] },
1567
- { id: "chatgpt-user", name: "ChatGPT-User", category: "ai_assistant", organization: "OpenAI", baseScore: 85, respectsRobots: true, uaPatterns: ["chatgpt-user"] },
1568
- { id: "perplexity-user", name: "Perplexity-User", category: "ai_assistant", organization: "Perplexity AI", baseScore: 75, respectsRobots: false, uaPatterns: ["perplexity-user"] },
1569
- { id: "mistralai-user", name: "MistralAI-User", category: "ai_assistant", organization: "Mistral AI", baseScore: 75, respectsRobots: true, uaPatterns: ["mistralai-user"] },
1570
- { id: "exauser", name: "ExaUser", category: "ai_assistant", organization: "Exa AI", baseScore: 70, respectsRobots: false, uaPatterns: ["exauser"] },
1571
- { id: "shap-user", name: "Shap-User", category: "ai_assistant", organization: "Parallel Web Systems", baseScore: 65, respectsRobots: false, uaPatterns: ["shap-user"] },
1572
- { id: "meta-externalfetcher", name: "Meta-ExternalFetcher", category: "ai_assistant", organization: "Meta", baseScore: 70, respectsRobots: false, uaPatterns: ["meta-externalfetcher"] },
1573
- { id: "gemini-deep-research", name: "Gemini-Deep-Research", category: "ai_assistant", organization: "Google", baseScore: 65, respectsRobots: true, uaPatterns: ["gemini-deep-research"] },
1574
- { id: "copilot", name: "Microsoft Copilot", category: "ai_assistant", organization: "Microsoft", baseScore: 65, respectsRobots: true, uaPatterns: ["copilot"] },
1575
- { id: "cortana", name: "Cortana", category: "ai_assistant", organization: "Microsoft", baseScore: 60, respectsRobots: true, uaPatterns: ["cortana"] },
1576
- { id: "siri", name: "Siri", category: "ai_assistant", organization: "Apple", baseScore: 60, respectsRobots: true, uaPatterns: ["siri"] }
1577
- ];
1395
+ return void 0;
1396
+ }
1397
+ function evaluateBinary(op, left, right, context) {
1398
+ if (op === "and") {
1399
+ const l2 = evaluate(left, context);
1400
+ if (l2 === void 0 || l2 === false) return false;
1401
+ const r2 = evaluate(right, context);
1402
+ if (r2 === void 0) return false;
1403
+ return !!r2;
1404
+ }
1405
+ if (op === "or") {
1406
+ const l2 = evaluate(left, context);
1407
+ if (l2 === void 0 ? false : !!l2) return true;
1408
+ const r2 = evaluate(right, context);
1409
+ if (r2 === void 0) return false;
1410
+ return !!r2;
1411
+ }
1412
+ const l = evaluate(left, context);
1413
+ const r = evaluate(right, context);
1414
+ if (l === void 0 || r === void 0) return false;
1415
+ switch (op) {
1416
+ case "==":
1417
+ return l === r;
1418
+ case "!=":
1419
+ return l !== r;
1420
+ case ">":
1421
+ return typeof l === "number" && typeof r === "number" && l > r;
1422
+ case ">=":
1423
+ return typeof l === "number" && typeof r === "number" && l >= r;
1424
+ case "<":
1425
+ return typeof l === "number" && typeof r === "number" && l < r;
1426
+ case "<=":
1427
+ return typeof l === "number" && typeof r === "number" && l <= r;
1428
+ case "in": {
1429
+ if (!Array.isArray(r)) return false;
1430
+ return r.includes(l);
1431
+ }
1432
+ case "not in": {
1433
+ if (!Array.isArray(r)) return false;
1434
+ return !r.includes(l);
1435
+ }
1436
+ case "matches": {
1437
+ if (typeof l !== "string" || typeof r !== "string") return false;
1438
+ if (r.length > MAX_REGEX_LENGTH) return false;
1439
+ try {
1440
+ return new RegExp(r).test(l);
1441
+ } catch {
1442
+ return false;
1443
+ }
1444
+ }
1445
+ default:
1446
+ return false;
1447
+ }
1448
+ }
1578
1449
 
1579
- // src/bots/index.ts
1580
- var AI_CATEGORIES = /* @__PURE__ */ new Set([
1581
- "training_crawler",
1582
- "ai_search_crawler",
1583
- "ai_agent",
1584
- "ai_assistant"
1585
- ]);
1586
- var UNKNOWN = Object.freeze({
1587
- known: false,
1588
- category: "none",
1589
- score: 0,
1590
- isAI: false
1591
- });
1592
- var MAX_CACHE = 1e3;
1593
- var cache = /* @__PURE__ */ new Map();
1594
- function matchUserAgent(userAgent) {
1595
- if (!userAgent) return void 0;
1596
- const cached = cache.get(userAgent);
1597
- if (cached !== void 0) return cached ?? void 0;
1598
- const ua = userAgent.toLowerCase();
1599
- let found = null;
1600
- for (const agent of BOT_REGISTRY) {
1601
- for (const pattern of agent.uaPatterns) {
1602
- if (ua.includes(pattern)) {
1603
- found = agent;
1604
- break;
1450
+ // src/rules/filter-rule.ts
1451
+ var FilterRule = class {
1452
+ constructor(config) {
1453
+ this.expression = config.expression;
1454
+ this.action = config.action ?? "DENY";
1455
+ this.dryRun = config.dryRun ?? false;
1456
+ this.name = `filter:${this.expression.slice(0, 50)}`;
1457
+ const parser = new Parser(config.expression);
1458
+ this.ast = parser.parse();
1459
+ }
1460
+ evaluate(context) {
1461
+ if (!context.enrichment && this.expression.includes("ip.")) {
1462
+ return {
1463
+ action: "ALLOW",
1464
+ rule: this.name,
1465
+ state: "NOT_RUN",
1466
+ reason: "No IP enrichment available \u2014 filter needs an API key"
1467
+ };
1468
+ }
1469
+ const result = evaluate(this.ast, context);
1470
+ if (result) {
1471
+ return {
1472
+ action: this.dryRun ? "ALLOW" : this.action,
1473
+ rule: this.name,
1474
+ reason: `Filter matched: ${this.expression}`,
1475
+ metadata: {
1476
+ expression: this.expression,
1477
+ dryRun: this.dryRun
1478
+ }
1479
+ };
1480
+ }
1481
+ return {
1482
+ action: "ALLOW",
1483
+ rule: this.name
1484
+ };
1485
+ }
1486
+ };
1487
+
1488
+ // src/rules/tripwire-rule.ts
1489
+ var DEFAULT_TRIPWIRE_PATHS = [
1490
+ "/.git/config",
1491
+ "/.git/HEAD",
1492
+ "/.env",
1493
+ "/.env.local",
1494
+ "/.env.production",
1495
+ "/wp-config.php",
1496
+ "/config.php",
1497
+ "/.aws/credentials",
1498
+ "/.ssh/id_rsa",
1499
+ "/backup.zip",
1500
+ "/backup.sql",
1501
+ "/database.sql",
1502
+ "/dump.sql",
1503
+ "/.DS_Store",
1504
+ "/phpinfo.php",
1505
+ "/server-status",
1506
+ "/actuator/env",
1507
+ "/.vscode/sftp.json"
1508
+ ];
1509
+ function canonicalizeTripwirePath(path) {
1510
+ const noQuery = path.split("?")[0].split("#")[0];
1511
+ return cleanSlashesAndDots(decodePercentAscii(noQuery));
1512
+ }
1513
+ function decodePercentAscii(s) {
1514
+ for (let i = 0; i < 4; i++) {
1515
+ const next = decodePercentAsciiOnce(s);
1516
+ if (next === s) break;
1517
+ s = next;
1518
+ }
1519
+ return s;
1520
+ }
1521
+ function decodePercentAsciiOnce(s) {
1522
+ if (!s.includes("%")) return s;
1523
+ let out = "";
1524
+ for (let i = 0; i < s.length; i++) {
1525
+ if (s[i] === "%" && i + 2 < s.length) {
1526
+ const hi = unhexNibble(s.charCodeAt(i + 1));
1527
+ const lo = unhexNibble(s.charCodeAt(i + 2));
1528
+ if (hi >= 0 && lo >= 0) {
1529
+ const v = hi << 4 | lo;
1530
+ if (v < 128) {
1531
+ out += String.fromCharCode(v);
1532
+ i += 2;
1533
+ continue;
1534
+ }
1605
1535
  }
1606
1536
  }
1607
- if (found) break;
1537
+ out += s[i];
1608
1538
  }
1609
- if (cache.size >= MAX_CACHE) cache.clear();
1610
- cache.set(userAgent, found);
1611
- return found ?? void 0;
1539
+ return out;
1612
1540
  }
1613
- function classifyUserAgent(userAgent) {
1614
- const agent = matchUserAgent(userAgent);
1615
- if (!agent) return UNKNOWN;
1616
- return {
1617
- known: true,
1618
- id: agent.id,
1619
- name: agent.name,
1620
- category: agent.category,
1621
- organization: agent.organization,
1622
- score: agent.baseScore,
1623
- respectsRobots: agent.respectsRobots,
1624
- isAI: AI_CATEGORIES.has(agent.category)
1625
- };
1541
+ function unhexNibble(c) {
1542
+ if (c >= 48 && c <= 57) return c - 48;
1543
+ if (c >= 97 && c <= 102) return c - 97 + 10;
1544
+ if (c >= 65 && c <= 70) return c - 65 + 10;
1545
+ return -1;
1546
+ }
1547
+ function cleanSlashesAndDots(s) {
1548
+ if (s === "") return s;
1549
+ const hadTrailing = s.length > 1 && s[s.length - 1] === "/";
1550
+ const stack = [];
1551
+ for (const p of s.split("/")) {
1552
+ if (p === "" || p === ".") continue;
1553
+ if (p === "..") {
1554
+ if (stack.length > 0) stack.pop();
1555
+ continue;
1556
+ }
1557
+ stack.push(p);
1558
+ }
1559
+ let res = "/" + stack.join("/");
1560
+ if (hadTrailing && res !== "/") res += "/";
1561
+ return res;
1626
1562
  }
1563
+ var TripwireRule = class {
1564
+ constructor(config = {}) {
1565
+ this.name = "tripwire";
1566
+ const paths = [...config.paths ?? []];
1567
+ if (config.includeDefaults ?? true) paths.push(...DEFAULT_TRIPWIRE_PATHS);
1568
+ this.exact = new Set(paths.map(canonicalizeTripwirePath));
1569
+ this.prefixes = (config.prefixes ?? []).map(canonicalizeTripwirePath);
1570
+ this.patterns = config.patterns ?? [];
1571
+ this.action = config.action ?? "DENY";
1572
+ this.dryRun = config.dryRun ?? false;
1573
+ }
1574
+ evaluate(context) {
1575
+ const path = canonicalizeTripwirePath(context.path);
1576
+ const hit = this.exact.has(path) || this.prefixes.some((prefix) => path.startsWith(prefix)) || this.patterns.some((re2) => re2.test(path));
1577
+ if (hit) {
1578
+ return {
1579
+ action: this.dryRun ? "ALLOW" : this.action,
1580
+ rule: this.name,
1581
+ reason: `Tripwire hit: ${path} \u2014 hidden honeypot path, deterministic automated-intent signal`,
1582
+ metadata: { path, dryRun: this.dryRun, confidence: 100 }
1583
+ };
1584
+ }
1585
+ return { action: "ALLOW", rule: this.name };
1586
+ }
1587
+ };
1588
+
1589
+ // src/rules/bot-rule.ts
1590
+ var BotRule = class {
1591
+ constructor(config = {}) {
1592
+ this.name = "bots";
1593
+ this.categories = new Set(config.categories ?? []);
1594
+ this.agents = new Set((config.agents ?? []).map((a) => a.toLowerCase()));
1595
+ this.ai = config.ai ?? false;
1596
+ this.allow = new Set((config.allow ?? []).map((a) => a.toLowerCase()));
1597
+ this.action = config.action ?? "DENY";
1598
+ this.dryRun = config.dryRun ?? false;
1599
+ }
1600
+ evaluate(context) {
1601
+ const bot = context.bot;
1602
+ if (!bot?.known) return { action: "ALLOW", rule: this.name };
1603
+ const id = bot.id?.toLowerCase();
1604
+ const name = bot.name?.toLowerCase();
1605
+ if (id && this.allow.has(id) || name && this.allow.has(name)) {
1606
+ return { action: "ALLOW", rule: this.name };
1607
+ }
1608
+ const matched = this.ai && bot.isAI || this.categories.has(bot.category) || id !== void 0 && this.agents.has(id) || name !== void 0 && this.agents.has(name);
1609
+ if (!matched) return { action: "ALLOW", rule: this.name };
1610
+ return {
1611
+ action: this.dryRun ? "ALLOW" : this.action,
1612
+ rule: this.name,
1613
+ reason: `${bot.name ?? "Bot"} (${bot.category}) matched a bot policy rule`,
1614
+ metadata: {
1615
+ bot: bot.id,
1616
+ botName: bot.name,
1617
+ category: bot.category,
1618
+ organization: bot.organization,
1619
+ dryRun: this.dryRun,
1620
+ // Deliberately not 100. The match is a self-declared User-Agent, and a
1621
+ // downstream consumer that treats this like a tripwire hit would be
1622
+ // wrong: a tripwire proves behaviour, this repeats a claim.
1623
+ confidence: 70
1624
+ }
1625
+ };
1626
+ }
1627
+ };
1627
1628
 
1628
1629
  // src/rules/bot-policy.ts
1629
1630
  var AI_CATEGORIES2 = /* @__PURE__ */ new Set([
@@ -5144,115 +5145,6 @@ function createClearanceGate(options = {}) {
5144
5145
  };
5145
5146
  }
5146
5147
 
5147
- // src/client-signals.ts
5148
- var MemoryClientSignalStore = class {
5149
- constructor(options = {}) {
5150
- this.sync = true;
5151
- this.entries = /* @__PURE__ */ new Map();
5152
- this.ttl = options.ttl ?? 9e5;
5153
- this.max = options.max ?? 1e4;
5154
- }
5155
- get(sessionId) {
5156
- const entry = this.entries.get(sessionId);
5157
- if (!entry) return void 0;
5158
- if (Date.now() - entry.at > this.ttl) {
5159
- this.entries.delete(sessionId);
5160
- return void 0;
5161
- }
5162
- return entry;
5163
- }
5164
- set(verdict) {
5165
- this.entries.delete(verdict.sessionId);
5166
- this.entries.set(verdict.sessionId, verdict);
5167
- while (this.entries.size > this.max) {
5168
- const oldest = this.entries.keys().next();
5169
- if (oldest.done) break;
5170
- this.entries.delete(oldest.value);
5171
- }
5172
- }
5173
- get size() {
5174
- return this.entries.size;
5175
- }
5176
- };
5177
- var CLIENT_SESSION_COOKIE = "wd_cs";
5178
- var CLIENT_SESSION_HEADER = "x-wd-session";
5179
- function readClientSession(headers) {
5180
- const cookie = headers["cookie"];
5181
- if (cookie) {
5182
- for (const part of cookie.split(";")) {
5183
- const eq = part.indexOf("=");
5184
- if (eq < 0) continue;
5185
- if (part.slice(0, eq).trim() === CLIENT_SESSION_COOKIE) {
5186
- const value = part.slice(eq + 1).trim();
5187
- if (value) return value;
5188
- }
5189
- }
5190
- }
5191
- const header2 = headers[CLIENT_SESSION_HEADER];
5192
- return header2 || void 0;
5193
- }
5194
- var ClientSignalRule = class {
5195
- constructor(config) {
5196
- this.name = "client-signals";
5197
- this.store = config.store;
5198
- this.minScore = config.minScore;
5199
- this.action = config.action ?? "DENY";
5200
- this.dryRun = config.dryRun ?? false;
5201
- }
5202
- async prepare(context) {
5203
- if (this.store.sync) return;
5204
- const sessionId = readClientSession(context.headers);
5205
- if (!sessionId) return;
5206
- const verdict = await this.store.get(sessionId);
5207
- if (verdict) {
5208
- context.prepared ?? (context.prepared = {});
5209
- context.prepared[this.name] = verdict;
5210
- }
5211
- }
5212
- evaluate(context) {
5213
- const sessionId = readClientSession(context.headers);
5214
- if (!sessionId) {
5215
- return {
5216
- action: "ALLOW",
5217
- rule: this.name,
5218
- state: "NOT_RUN",
5219
- reason: "No browser session \u2014 the client widget did not run for this request"
5220
- };
5221
- }
5222
- const verdict = this.store.sync ? this.store.get(sessionId) : context.prepared?.[this.name];
5223
- if (!verdict) {
5224
- return {
5225
- action: "ALLOW",
5226
- rule: this.name,
5227
- state: "NOT_RUN",
5228
- reason: "No signals recorded for this session yet"
5229
- };
5230
- }
5231
- const bad = this.minScore !== void 0 ? verdict.score >= this.minScore : verdict.recommendation === "block";
5232
- if (!bad) {
5233
- return {
5234
- action: "ALLOW",
5235
- rule: this.name,
5236
- metadata: { score: verdict.score, recommendation: verdict.recommendation }
5237
- };
5238
- }
5239
- return {
5240
- action: this.dryRun ? "ALLOW" : this.action,
5241
- rule: this.name,
5242
- reason: `Client signals scored ${verdict.score.toFixed(2)} (${verdict.recommendation})`,
5243
- metadata: {
5244
- score: verdict.score,
5245
- recommendation: verdict.recommendation,
5246
- sessionId,
5247
- dryRun: this.dryRun
5248
- }
5249
- };
5250
- }
5251
- };
5252
- function clientSignals(config) {
5253
- return new ClientSignalRule(config);
5254
- }
5255
-
5256
5148
  // src/adapter-core.ts
5257
5149
  function shouldSkipPath(path, patterns) {
5258
5150
  if (!patterns || patterns.length === 0) return false;
@@ -5390,6 +5282,184 @@ function createFetchGuard(options = {}) {
5390
5282
  };
5391
5283
  }
5392
5284
 
5285
+ // src/detect-and-gate.ts
5286
+ var DECISION_HEADER = "x-webdecoy-decision";
5287
+ var DETECTION_ID_HEADER = "x-webdecoy-detection-id";
5288
+ var WOULD_BLOCK_HEADER = "x-webdecoy-would-block";
5289
+ var warnedBadKey = false;
5290
+ function createDetectAndGate(options = {}) {
5291
+ const gate = createClearanceGate(options);
5292
+ const trustProxy = options.trustProxy ?? 1;
5293
+ let guard = null;
5294
+ let guardKey = "";
5295
+ let failedKey = "";
5296
+ function guardFor(apiKey) {
5297
+ if (guard && guardKey === apiKey) return guard;
5298
+ if (failedKey === apiKey) return null;
5299
+ try {
5300
+ guard = createFetchGuard({ ...options, apiKey, trustProxy, honeytoken: false, mode: options.mode ?? "monitor" });
5301
+ guardKey = apiKey;
5302
+ return guard;
5303
+ } catch (error) {
5304
+ failedKey = apiKey;
5305
+ if (!warnedBadKey) {
5306
+ warnedBadKey = true;
5307
+ console.warn(
5308
+ `[WebDecoy] detection is off: ${error instanceof Error ? error.message : "the API key was rejected"}`
5309
+ );
5310
+ }
5311
+ return null;
5312
+ }
5313
+ }
5314
+ async function detect(request, apiKey) {
5315
+ try {
5316
+ const g = guardFor(apiKey);
5317
+ if (!g) return null;
5318
+ if (shouldSkipPath(new URL(request.url).pathname, options.skipPaths)) return null;
5319
+ return await g.check(request);
5320
+ } catch {
5321
+ return null;
5322
+ }
5323
+ }
5324
+ async function runGate(request, context) {
5325
+ try {
5326
+ return await gate(request, context);
5327
+ } catch {
5328
+ return { action: "continue", headers: null, verdict: null };
5329
+ }
5330
+ }
5331
+ return async (request, context) => {
5332
+ const apiKey = (options.apiKey ?? fromEnv("WEBDECOY_API_KEY")).trim();
5333
+ if (!apiKey) return { outcome: await runGate(request, context), decision: null };
5334
+ const [guarded, gated] = await Promise.all([detect(request, apiKey), runGate(request, context)]);
5335
+ if (!guarded) return { outcome: gated, decision: null };
5336
+ const { decision, response } = guarded;
5337
+ if (response) return { outcome: { action: "respond", response }, decision };
5338
+ if (gated.action === "respond") return { outcome: gated, decision };
5339
+ try {
5340
+ const headers = gated.headers ? new Headers(gated.headers) : tt(request);
5341
+ headers.delete(DECISION_HEADER);
5342
+ headers.delete(DETECTION_ID_HEADER);
5343
+ headers.delete(WOULD_BLOCK_HEADER);
5344
+ headers.set(DECISION_HEADER, decision.detection?.decision ?? "");
5345
+ headers.set(DETECTION_ID_HEADER, decision.detection?.detection_id ?? "");
5346
+ headers.set(WOULD_BLOCK_HEADER, String(!decision.allowed));
5347
+ return { outcome: { action: "continue", headers, verdict: gated.verdict }, decision };
5348
+ } catch {
5349
+ return { outcome: gated, decision };
5350
+ }
5351
+ };
5352
+ }
5353
+
5354
+ // src/client-signals.ts
5355
+ var MemoryClientSignalStore = class {
5356
+ constructor(options = {}) {
5357
+ this.sync = true;
5358
+ this.entries = /* @__PURE__ */ new Map();
5359
+ this.ttl = options.ttl ?? 9e5;
5360
+ this.max = options.max ?? 1e4;
5361
+ }
5362
+ get(sessionId) {
5363
+ const entry = this.entries.get(sessionId);
5364
+ if (!entry) return void 0;
5365
+ if (Date.now() - entry.at > this.ttl) {
5366
+ this.entries.delete(sessionId);
5367
+ return void 0;
5368
+ }
5369
+ return entry;
5370
+ }
5371
+ set(verdict) {
5372
+ this.entries.delete(verdict.sessionId);
5373
+ this.entries.set(verdict.sessionId, verdict);
5374
+ while (this.entries.size > this.max) {
5375
+ const oldest = this.entries.keys().next();
5376
+ if (oldest.done) break;
5377
+ this.entries.delete(oldest.value);
5378
+ }
5379
+ }
5380
+ get size() {
5381
+ return this.entries.size;
5382
+ }
5383
+ };
5384
+ var CLIENT_SESSION_COOKIE = "wd_cs";
5385
+ var CLIENT_SESSION_HEADER = "x-wd-session";
5386
+ function readClientSession(headers) {
5387
+ const cookie = headers["cookie"];
5388
+ if (cookie) {
5389
+ for (const part of cookie.split(";")) {
5390
+ const eq = part.indexOf("=");
5391
+ if (eq < 0) continue;
5392
+ if (part.slice(0, eq).trim() === CLIENT_SESSION_COOKIE) {
5393
+ const value = part.slice(eq + 1).trim();
5394
+ if (value) return value;
5395
+ }
5396
+ }
5397
+ }
5398
+ const header2 = headers[CLIENT_SESSION_HEADER];
5399
+ return header2 || void 0;
5400
+ }
5401
+ var ClientSignalRule = class {
5402
+ constructor(config) {
5403
+ this.name = "client-signals";
5404
+ this.store = config.store;
5405
+ this.minScore = config.minScore;
5406
+ this.action = config.action ?? "DENY";
5407
+ this.dryRun = config.dryRun ?? false;
5408
+ }
5409
+ async prepare(context) {
5410
+ if (this.store.sync) return;
5411
+ const sessionId = readClientSession(context.headers);
5412
+ if (!sessionId) return;
5413
+ const verdict = await this.store.get(sessionId);
5414
+ if (verdict) {
5415
+ context.prepared ?? (context.prepared = {});
5416
+ context.prepared[this.name] = verdict;
5417
+ }
5418
+ }
5419
+ evaluate(context) {
5420
+ const sessionId = readClientSession(context.headers);
5421
+ if (!sessionId) {
5422
+ return {
5423
+ action: "ALLOW",
5424
+ rule: this.name,
5425
+ state: "NOT_RUN",
5426
+ reason: "No browser session \u2014 the client widget did not run for this request"
5427
+ };
5428
+ }
5429
+ const verdict = this.store.sync ? this.store.get(sessionId) : context.prepared?.[this.name];
5430
+ if (!verdict) {
5431
+ return {
5432
+ action: "ALLOW",
5433
+ rule: this.name,
5434
+ state: "NOT_RUN",
5435
+ reason: "No signals recorded for this session yet"
5436
+ };
5437
+ }
5438
+ const bad = this.minScore !== void 0 ? verdict.score >= this.minScore : verdict.recommendation === "block";
5439
+ if (!bad) {
5440
+ return {
5441
+ action: "ALLOW",
5442
+ rule: this.name,
5443
+ metadata: { score: verdict.score, recommendation: verdict.recommendation }
5444
+ };
5445
+ }
5446
+ return {
5447
+ action: this.dryRun ? "ALLOW" : this.action,
5448
+ rule: this.name,
5449
+ reason: `Client signals scored ${verdict.score.toFixed(2)} (${verdict.recommendation})`,
5450
+ metadata: {
5451
+ score: verdict.score,
5452
+ recommendation: verdict.recommendation,
5453
+ sessionId,
5454
+ dryRun: this.dryRun
5455
+ }
5456
+ };
5457
+ }
5458
+ };
5459
+ function clientSignals(config) {
5460
+ return new ClientSignalRule(config);
5461
+ }
5462
+
5393
5463
  // src/detection/weights.ts
5394
5464
  var DEFAULT_WEIGHTS = {
5395
5465
  vision_ai: 0.15,
@@ -7414,6 +7484,7 @@ function createCaptchaEndpoints(options = {}) {
7414
7484
  createAgentVerifier,
7415
7485
  createCaptchaEndpoints,
7416
7486
  createClearanceGate,
7487
+ createDetectAndGate,
7417
7488
  createFetchGuard,
7418
7489
  deriveAndArm,
7419
7490
  deriveKey,