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

protector-shield

v5.0.2

Published

Maximum protection shield for Node.js servers - intercepts HTTP requests, blocks suspicious traffic, and logs threats

Readme

Protector v5

Maximum protection shield for Node.js HTTP servers. Intercepts all incoming requests at the core level, detects and blocks suspicious traffic from servers, bots, and automated tools, while allowing only legitimate browser-based requests.

Features

  • Core-Level Interception: Overrides http.createServer to inspect every HTTP request
  • Intelligent Threat Detection: Identifies requests from servers, curl, Postman, bots, and missing headers
  • Immediate Blocking: Rejects suspicious requests with HTTP 403 Forbidden
  • Selective Logging: Only logs suspicious requests to JSON files on disk
  • Framework Agnostic: Works with Express, Fastify, raw Node.js, or any HTTP server
  • No Dependencies: Uses only Node.js core modules (http, fs, path)
  • Fail-Safe Design: Blocks requests if protection mechanisms fail
  • Localhost Allowance: Permits localhost requests for development

Installation

npm install protector

Usage

Wrap your server startup function with protector():

const protector = require('protector');
const http = require('http');

protector(() => {
  const server = http.createServer((req, res) => {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello, protected world!');
  });

  server.listen(3000, () => {
    console.log('Server running on port 3000');
  });
});

Works with Express:

const protector = require('protector');
const express = require('express');

protector(() => {
  const app = express();
  app.get('/', (req, res) => res.send('Protected Express app'));
  app.listen(3000);
});

Session Binding

Protector v5 introduces session binding to further enhance security by tying requests to specific browser sessions.

Creating a Session

const { createSession } = require('protector');

const { sessionId, token } = createSession();
// Send sessionId and token to the client

Sending Session to Client

After creating a session, send the sessionId and token to the client in a response:

const { createSession } = require('protector');

app.get('/init-session', (req, res) => {
  const { sessionId, token } = createSession();
  res.json({ sessionId, token });
});

The client should store these values and include them in headers for subsequent requests.

Validating Sessions in Your Application

In your request handlers, validate the session:

const { validateSession } = require('protector');

app.get('/protected', (req, res) => {
  const sessionId = req.headers['x-session-id'];
  const token = req.headers['x-session-token'];
  
  if (!validateSession(sessionId, token)) {
    return res.status(403).send('Invalid session');
  }
  
  res.send('Protected content');
});

Rotating Tokens

Optionally rotate tokens periodically:

const { rotateSessionToken } = require('protector');

const newToken = rotateSessionToken(sessionId);
// Send newToken to client

Security Logic

Requests are flagged as suspicious if:

  • Missing User-Agent header
  • User-Agent contains bot/server indicators (bot, curl, wget, python, java/, postman, etc.)
  • Missing Accept header
  • Missing Accept-Language header
  • Abnormal HTTP methods (only GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH allowed)

Logging

Suspicious requests are logged to protector-logs/suspicious-requests.json with:

  • IP address
  • HTTP method
  • URL
  • Timestamp
  • Reason for flagging

Architecture

  • index.js: Main entry point
  • lib/runtime.js: Runtime lock mechanism
  • shield/ipShield.js: Core request inspection and blocking
  • storage/logger.js: JSON-based persistent logging

Requirements

  • Node.js >= 18
  • No external dependencies

License

MIT