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

@broberg/local-guard

v0.2.0

Published

One guard for a local HTTP daemon on 127.0.0.1: Host must name this loopback address on its own port (421 — closes DNS rebinding), and a write must be application/json (415 — a cross-site page cannot send that without a CORS preflight). Framework-free cor

Downloads

912

Readme

@broberg/local-guard

One guard for a local HTTP daemon on 127.0.0.1. Two rules, no token, because a browser cannot break either:

| rule | refused with | closes | |---|---|---| | Host must be 127.0.0.1:<port>, localhost:<port> or [::1]:<port> | 421 | DNS rebinding — a rebound page sends its own name | | a write (POST/PUT/PATCH/DELETE) must be application/json | 415 | cross-site "simple" POSTs — a form cannot send JSON without a CORS preflight |

curl, MCP clients and agents already send both, so nothing legitimate changes. A body-less DELETE (an MCP session close) is allowed: DELETE always needs a preflight cross-site.

Extracted from @broberg/lens-daemon (security sweep 2026-10-21) so lens and auth-relay stop carrying copies (F108).

// Hono
import { localRequestGuard } from "@broberg/local-guard/hono";
app.use("*", localRequestGuard({ port: 7475, name: "lens daemon" }));

// any fetch handler (Bun.serve, Deno, workers)
import { guardResponse } from "@broberg/local-guard";
const refused = guardResponse(req, { port, name: "ARS" });
if (refused) return refused;

// just the verdict
import { checkLocalRequest } from "@broberg/local-guard";
checkLocalRequest(req, { port }); // null | { status: 421, reason: "host", host } | { status: 415, reason: "content-type", contentType }
  • port is required — two daemons on one machine must refuse each other's Host. A port outside 1–65535 throws at setup.
  • The JSON body defaults to lens-daemon's { ok: false, error }; pass body: (refusal, message) => … to keep your own shape (auth-relay uses { error }).
  • extraHosts (0.2.0) — further exact host:port values a daemon answers on beyond loopback, e.g. its tailnet address (localRequestGuard({ port: 7480, extraHosts: ["100.78.170.62:7480"] })). No wildcard; compared case-insensitively; the write rule still applies.
  • Host is judged before the content type, so a rebound page learns nothing about the write rule.

Not this package's job: authentication (that is @broberg/sso / a token), and CORS configuration beyond refusing.