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

@teamamw/public-route-gate

v0.2.0

Published

AMW shared helpers for public route gating — access-code, portal-token HMAC, finalize-token

Readme

@amw/public-route-gate

Shared helpers for AMW public routes. Solves the recurring public-surface bugs from autonomous-sweep r13-r15 (May 23 2026):

  • Mutator-no-access-code: public POST/PATCH/DELETE on slug resources that fire side effects without requiring access_code. → requireAccessCodeIfSet.
  • Public-route-no-token: public routes that accept ?email= as sole auth, leading to email enumeration. → mintPortalToken + verifyPortalToken.
  • Finalize-style flows: random per-row session token issued at create-time. → mintSessionToken + verifySessionToken.
  • Timing oracles: → timingSafeStringEqual.

Install

npm install @amw/public-route-gate

Quick start

Pattern A — human-shared access code (proposals, marketing docs)

import { requireAccessCodeIfSet } from '@amw/public-route-gate'

const gateProposal = requireAccessCodeIfSet({
  lookupAccessCode: async (slug) => {
    const r = await pool.query('SELECT access_code FROM proposals WHERE slug=$1', [slug])
    return r.rows[0]?.access_code ?? null
  },
})

router.post('/proposals/:slug/approve', async (req, res) => {
  const gate = await gateProposal(req.params.slug, req)
  if (!gate.ok) return res.status(gate.status).json({ error: gate.error })
  // ... safe to UPDATE / send email / kick off billing
})

Pattern B — HMAC portal token (billing portal, customer self-service)

import { mintPortalToken, verifyPortalToken } from '@amw/public-route-gate'

// Mint at link-creation time (admin widget / billing email):
const token = mintPortalToken({
  resourceId: customer.id,
  identifier: customer.email.toLowerCase(),
  secret: process.env.BILLING_PORTAL_SECRET!,
})
const url = `https://amworldgroup.com/billing?email=${enc(customer.email)}&token=${token}`

// Verify on the public route:
if (!verifyPortalToken({
  token: req.query.token,
  resourceId: customer.id,
  identifier: email,
  secret: process.env.BILLING_PORTAL_SECRET!,
})) {
  return res.status(401).json({ error: 'Invalid token' })
}

Pattern C — random session token (finalize-style flows)

import { mintSessionToken, verifySessionToken } from '@amw/public-route-gate'

// At /submit (create):
const finalizeToken = mintSessionToken()
await pool.query(
  'INSERT INTO funnel_submissions(..., finalize_token) VALUES (...,$N)',
  [..., finalizeToken],
)
res.json({ submission_id: id, finalize_token: finalizeToken })

// At /finalize (action):
const row = await pool.query('SELECT finalize_token FROM funnel_submissions WHERE id=$1', [id])
if (!verifySessionToken(req.body.finalize_token, row.rows[0]?.finalize_token)) {
  return res.status(401).json({ error: 'Invalid token' })
}

License

MIT