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

@skiesjs/auth-express

v0.1.0

Published

Express 5 JWT middleware and secure refresh-cookie delivery for Skies Node.js.

Readme

@skiesjs/auth-express

Express 5 authentication boundaries for @skiesjs/auth: explicit JWT middleware for protected slices and one secure refresh-cookie convention for web clients. Token verification stays in @skiesjs/auth; canonical error rendering stays in @skiesjs/express.

Protect a slice

Create the middleware once from the same AccessTokens boundary used to issue access tokens, then pass it visibly as mapSlice's authorize middleware. Successful verification writes a typed CurrentUser to res.locals; missing, malformed, invalid, and expired credentials stop at the canonical 401 response.

import { AccessTokens } from "@skiesjs/auth";
import { currentUser, requireJwt, type AuthenticatedLocals } from "@skiesjs/auth-express";
import { mapSlice } from "@skiesjs/express";

const accessTokens = new AccessTokens(secret, "myapp", "myapp-api");
const authorize = requireJwt(accessTokens);

mapSlice(router, openApi, contract, {
  authorize,
  toInput: ({ params }) => ({ walletId: params.walletId }),
  handle,
});

// In ordinary downstream Express middleware, currentUser(res) returns CurrentUser and throws
// if requireJwt was accidentally omitted or registered after the handler.
router.get("/me", authorize, (_req, res) => res.json(currentUser(res)));

AuthenticatedLocals is available when an application wants to annotate its own Express handler generics directly. The currentUser(res) accessor is usually simpler and keeps the middleware-order guard at runtime.

Deliver refresh tokens

RefreshCookie defaults to a host-only, SameSite=Strict, / cookie. HttpOnly is always set. Secure is omitted only on plain HTTP for localhost, 127.0.0.1, or [::1]; HTTPS and every non-loopback host remain Secure, including an HTTP hop behind TLS termination.

import { RefreshCookie } from "@skiesjs/auth-express";

const refresh = new RefreshCookie({
  name: "myapp_refresh",
  path: "/account",
  // domain: ".example.com", // opt in only when sibling subdomains must share it
  // sameSite: "lax",
});

if (refresh.isWeb(req)) {
  refresh.setRefresh(req, res, token, expires);
}

const presentedToken = refresh.refreshFrom(req, req.body.refreshToken);
refresh.clear(res);

isWeb recognizes only the case-insensitive exact X-Client: web value. Reading is intentionally independent of that header: any nonempty named cookie wins, otherwise refreshFrom returns the supplied body token or "". Both setting and clearing append rather than replace existing Set-Cookie headers, and clearing reuses the configured path/domain.