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

jsrab

v1.0.1

Published

An advanced addon to detect and filter botting in any form from node js games

Readme

JSRAB (JavaScript Regex Anti-Bot)

JSRAB is a highly advanced, enterprise-grade filtration service and anti-cheat engine designed specifically for Node.js real-time applications, WebSockets, and multiplayer games.

By combining mathematical entropy analysis, leaky-bucket rate limiting, physics-based movement tracking, and comprehensive regex validation, JSRAB protects your server from spam joins, packet flooding, SQLi/XSS injection, speed-hacking, and automated macro bots.


Features

  • Reputation-Based Penalties: Clients are assigned a reputation score. Minor infractions (like spamming actions) lower the score. Severe infractions (injection attempts) result in immediate bans. Scores naturally recover over time for legitimate players.
  • Physics Anomaly Detection: Calculates vector velocity (Distance over Time) to detect speed-hacking and teleportation in game environments.
  • Mathematical Entropy Analysis: Calculates the Shannon Entropy of string payloads to detect "keyboard mashing" bots (e.g., asdfqwer or aaaaaa).
  • Connection Mitigation: Protects against DDoS/Botnet connection flooding using token-bucket rate limits per IP.
  • Deep Regex Filtration: Configurable regex matrices to catch XSS, SQL Injection, Command Injection, and chat spam.
  • Professional Telemetry: Clean, non-intrusive, enterprise-standard logging. No AI-generated conversational logs. Just raw, actionable data.

Installation

npm install jsrab

Usage & Integration

JSRAB is designed to be injected at the middleware or socket interception layer of your application.

Example 1: Integrating with WebSockets (ws)

const WebSocket = require('ws');
const JSRab = require('jsrab');

const wss = new WebSocket.Server({ port: 8080 });

// Initialize JSRAB with custom thresholds
const antiBot = new JSRab({
    reputation: { banThreshold: 0, startingScore: 100 },
    inputs: { maxActionsPerSecond: 20 },
    movement: { maxVelocityPerSecond: 60.5 }
});

// Event Listeners for telemetry & logging
antiBot.on('ban', (data) => {
    // data: { identifier, reason, expiration }
    console.log(`[SEC-OPS] Target locked out: ${data.identifier}`);
});

wss.on('connection', (ws, req) => {
    const ip = req.socket.remoteAddress;
    const clientId = generateUniqueId(); 
    
    // 1. Connection Filtration
    if (!antiBot.evaluateConnection(ip, clientId)) {
        return ws.close(4000, 'Connection rejected by security policy.');
    }

    ws.on('message', (message) => {
        const payload = message.toString();

        // 2. Payload & Regex Filtration
        if (!antiBot.evaluatePayload(clientId, payload)) {
            // Malicious payload detected. JSRAB handles reputation drops automatically.
            return; 
        }

        // 3. Action / Spam Limiting
        if (!antiBot.evaluateAction(clientId)) {
            ws.send(JSON.stringify({ error: 'Rate limit exceeded. Slow down.' }));
            return;
        }

        // 4. Movement Validation (If payload is a movement packet)
        const parsed = JSON.parse(payload);
        if (parsed.type === 'MOVE') {
            const isValid = antiBot.evaluateMovement(clientId, parsed.x, parsed.y, parsed.z);
            if (!isValid) {
                // Client is speed-hacking or lagging heavily. Rubber-band them.
                ws.send(JSON.stringify({ type: 'RUBBER_BAND', msg: 'Movement anomalous' }));
                return;
            }
        }
        
        // Process legitimate game logic here...
    });
});

Advanced Configuration Options

JSRAB is completely customizable. You can pass an options object to the constructor to override any default limit.

const customOptions = {
    reputation: {
        startingScore: 100,
        banThreshold: 0,      // Score at which a ban is triggered
        warnThreshold: 40,    // Score at which 'warn' event is emitted
        decayRate: 5,         // Points passively recovered per minute
    },
    connections: {
        maxPerIpPerMinute: 10,
        blockDurationMs: 900000, // 15 minutes
    },
    inputs: {
        maxPayloadSizeBytes: 2048,
        maxActionsPerSecond: 15,
        gibberishDetection: true,
        minEntropy: 1.2, // Below this = repetitive spam (aaaaa)
        maxEntropy: 4.8, // Above this = high-randomness bots (a%1g#9v)
    },
    movement: {
        enabled: true,
        maxVelocityPerSecond: 50.0,
        toleranceBuffer: 1.1, // 10% leniency for network latency
    },
    regex: {
        enabled: true,
        patterns: [
            // Add custom patterns. 'penalty' is how much reputation is lost.
            { name: 'PROFANITY', regex: /\b(badword1|badword2)\b/i, penalty: 15 }
        ]
    },
    logging: {
        enabled: true,
        level: 'WARN' // Options: DEBUG, INFO, WARN, ERROR
    }
};

const antiBot = new JSRab(customOptions);

Events API

JSRAB extends the standard Node EventEmitter. You can listen to the following events to bridge JSRAB with your database or UI:

| Event | Description | Payload Data | |-------|-------------|--------------| | flag | Fired when a client loses reputation points. | { clientId, reason, penalty, remainingReputation } | | warn | Fired when a client's reputation drops below the warning threshold. | { clientId, reputation } | | ban | Fired when a client hits 0 reputation or is IP-blocked. | { identifier, reason, expiration } |


Built for scale.