npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pathum_01/bot-detect

v0.1.0

Published

Lightweight browser bot detection SDK with behavioral telemetry

Downloads

130

Readme

bot-detect

Browser bot-detection SDK you can install on any website to collect behavioral signals and post them to your backend.

Install

npm install @pathum_01/bot-detect

Quick usage

import { initBotDetect } from "@pathum_01/bot-detect";

const botDetect = initBotDetect({
  siteKey: "your_public_site_key",
  endpoint: "https://your-api.example.com/v1/events",
  autoTrack: true,
  flushIntervalMs: 5000,
  debug: true
});

// Optional: stop tracking later
// botDetect.stop();

What it collects

  • Browser environment signals (UA, webdriver flag, languages, screen, etc.)
  • Behavioral events (mousemove, click, keydown, visibilitychange)
  • Session summary metrics (first input delay, typing speed, event ratios)
  • Local risk score (0-100) with reasons

Server endpoint contract

POST /v1/events should accept JSON payload like:

{
  "siteKey": "your_public_site_key",
  "sessionId": "abc123",
  "url": "https://example.com/signup",
  "collectedAt": 1710000000000,
  "signals": {},
  "eventSummary": {},
  "localAssessment": { "score": 55, "reasons": ["navigator.webdriver=true"] },
  "events": []
}

Important: always compute the final decision on your server, not only in the browser.

Vercel deployment

This repo is Vercel-ready:

  • Root page: / via index.html
  • API endpoint: /api/events via api/events.js

After deploy, test:

  • GET https://<your-project>.vercel.app/
  • GET https://<your-project>.vercel.app/api/events

Set environment variables in Vercel:

  • BOT_DETECT_SITE_KEY - validates incoming siteKey
  • ALLOWED_ORIGINS - comma-separated origins for strict CORS (required)
  • RATE_LIMIT_WINDOW_MS - rate limit window in ms (default 60000)
  • RATE_LIMIT_MAX - max requests per IP per window (default 60)
  • UPSTASH_REDIS_REST_URL - Upstash Redis REST URL for event persistence
  • UPSTASH_REDIS_REST_TOKEN - Upstash Redis REST auth token
  • UPSTASH_EVENTS_KEY - Redis list key (default bot_detect_events)
  • UPSTASH_MAX_EVENTS - max kept events in Redis list (default 1000)

Production hardening included

  • Strict CORS allowlist enforcement for POST /api/events
  • Per-IP rate limiting with response headers
  • Security headers (X-Frame-Options, Referrer-Policy, etc.)
  • Structured server-side event logging
  • Optional persistent logging to Upstash Redis (falls back to Vercel logs)