
Client-side bot detection library with 28 weighted modules, behavioral analysis, browser fingerprinting, honeypots, and server-side verification. Detects headless browsers, Selenium, Puppeteer, Playwright, and stealth automation frameworks.
Client-side bot and automation detection library with weighted scoring, behavioral analysis, browser fingerprinting, and configurable thresholds. Detects headless browsers, Selenium, Puppeteer, Playwright, CDP-based tools, and stealth automation frameworks.
v2.1.0 — anti-detection honeypots, GPU-stable canvas fingerprinting, enhanced behavioral analysis, lazy initialization, server-side tamper detection, request fingerprint binding, and rate limiting.
human, suspicious, bot with corresponding friction actions (monitor, challenge, block)Browser Your Server
┌──────────────────────────┐ ┌──────────────────────┐
│ Collector (singleton) │ POST │ Express Middleware │
│ ├─ 28 detection modules│ signals │ ├─ NonceManager │
│ ├─ BehaviorTracker │ + nonce │ ├─ RateLimiter │
│ ├─ HoneypotTraps │───────────▶│ ├─ TamperDetector │
│ ├─ Stack trace traps │ │ ├─ computeVerdict() │
│ └─ IframeContext │ │ └─ Proof-of-Work │
│ │ verdict │ │
│ ↓ collect() → │ + proof │ Returns: │
│ DetectionResult[] │◀───────────│ { verdict, score, │
└──────────────────────────┘ │ confidence, proof, │
│ tamperScore } │
└──────────────────────┘
│
▼
Session-gated endpoint
(login, checkout, etc.)
validates proof before
granting access
Key principle: The browser only collects raw DetectionResult[] signals. The server computes the final verdict using a secret weight table. Client-computed verdicts are never trusted.
npm install
npm run build
Outputs to dist/:
botdetect.min.js (with polyfills, ~151 KB)botdetect-clean.min.js (modern browsers only, ~74 KB)<script src="/path/to/botdetect.min.js"></script>
<script>
BotDetect.collector.enableTraps();
BotDetect.collector.enableBehavioralTracking();
BotDetect.collector.enableHoneypots();
</script>
cd server
npm install express cors express-session
node example-integration.js
async function onLogin() {
const { nonce } = await (await fetch('/api/botdetect/nonce')).json();
BotDetect.collector.setNonce(nonce);
const signals = await BotDetect.collector.collect();
const resp = await fetch('/api/botdetect/verify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ signals, nonce })
});
const { verdict, score, proof, friction } = await resp.json();
document.getElementById('botdetect-proof').value = proof;
document.getElementById('login-form').submit();
}
app.post('/api/login', (req, res) => {
const bd = req.session.botdetect;
if (!bd) return res.status(403).json({ error: 'no_verification' });
if (bd.verdict === 'bot') return res.status(403).json({ error: 'access_denied' });
if (bd.verdict === 'suspicious') return challengeCaptcha(req, res);
res.json({ success: true });
});
import Collector from './collector/Collector';
// or via global: BotDetect.collector
| Method | Returns | Description |
|---|---|---|
getInstance(config?) | Collector | Singleton accessor |
configure(config) | void | Update config at runtime |
getConfig() | CollectorConfig | Current configuration |
init() | void | Lazy-init traps, tracking, honeypots |
enableTraps() | void | Install stack trace traps on DOM APIs |
enableBehavioralTracking() | void | Start mouse/keyboard/scroll monitoring |
enableHoneypots(container?) | void | Install honeypot fields |
collect() | Promise<DetectionResult[]> | Run all detections |
setNonce(nonce) | void | Store server-issued nonce |
getSessionId() | string | Unique session identifier |
getFingerprint() | string | Session fingerprint hash |
resetBehavioralData() | void | Clear behavioral data |
destroy() | void | Clean up all listeners and DOM elements |
import Detector from './detector/Detector';
| Method | Returns | Description |
|---|---|---|
getInstance(config?) | Detector | Singleton accessor |
configure(config) | void | Update config |
analyze(results) | DetectionVerdict | Score + classify (local debug only) |
handleError(error) | DetectionVerdict | Fallback verdict on failure |
Warning:
analyze()runs entirely in the browser. Never use its output for production decisions.
interface DetectionResult {
name: string; // Module name
score: number; // 0.0 – 1.0
weight: number; // 1 – 10 (importance)
detail?: string; // Human-readable description
}
interface DetectionVerdict {
verdict: 'bot' | 'suspicious' | 'human';
score: number; // 0.0 – 1.0
confidence: number; // 0.0 – 1.0
signals: DetectionResult[];
threshold: number;
friction: 'monitor' | 'challenge' | 'block';
}
interface CollectorConfig {
detectionTimeoutMs: number; // per-module timeout (default: 3000)
enableTraps: boolean;
enableBehavioralTracking: boolean;
enableHoneypots: boolean;
thresholds: { strict: number; balanced: number; relaxed: number };
}
const { createBotDetectEndpoint } = require('./server');