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

decap-cms-lib-pat

v0.2.0

Published

CMS-issued scoped Personal Access Token (PAT) minting, hashing and bearer verification for Decap CMS-based servers.

Readme

decap-cms-lib-pat

CMS-issued scoped Personal Access Token (PAT) primitives for Decap CMS-based servers: minting, hashing at rest, and bearer verification.

This library is server-side only (Node crypto). It does not touch storage or transport -- callers inject a lookupPatByHash and a verifySessionToken function and get back a single seam that resolves any bearer string to { user, scopes }.

Scope vocabulary

Scopes follow a resource:action convention and are an open vocabulary. The CMS ships these well-known defaults:

content:read | content:write | media:read | media:write | config:read

Consumers building custom dashboards (Decap CMS supports injected React components) or fronting a non-CMS surface (e.g. a B2B shop) may grant their own namespaced scopes, such as shipping:read or orders:write -- this library validates the resource:action shape, it does not restrict the vocabulary.

Wildcards:

  • admin (or the equivalent *) grants every scope.
  • resource:* grants every action on that resource (e.g. content:* grants both content:read and content:write).

Wildcard membership is resolved at check time by hasScope; stored scope sets are never expanded (an open vocabulary has no enumerable "all"). Use normalizeScopes to canonicalize a set for storage (dedupe; collapse a global grant to a single admin).

Usage

import {
  mintPersonalAccessToken,
  resolveBearer,
  requireScope,
  UnauthorizedError,
} from 'decap-cms-lib-pat';

// Minting (e.g. from an admin "create token" action)
const { token, record } = mintPersonalAccessToken(
  { userId: user.id, scopes: ['content:read', 'media:read'], name: 'ci-agent' },
  { generateId: () => uuid() },
);
// `token` is shown to the caller exactly once. Persist `record` (hash only).

// Verifying a bearer (the shared seam for REST/MCP)
const ctx = await resolveBearer(req.headers.authorization?.replace(/^Bearer /, ''), {
  verifySessionToken: bearer => verifyOAuthAccessToken(bearer), // existing OAuth seam, untouched
  lookupPatByHash: hash => db.pats.findByHash(hash),
  onPatUsed: record => db.pats.touchLastUsed(record.id),
});
if (!ctx) throw new UnauthorizedError();

// Enforcement
requireScope(ctx, 'content:write'); // throws InsufficientScopeError if not granted

What's deferred

This package ships token minting, hashing, the {user, scopes} bearer resolution seam, and scope enforcement -- fully tested. It does not include:

  • Wiring resolveBearer into the live decap-api authorize(ctx) hook (that seam lives in laikacms/laikacms, a separate private repo).
  • Storage adapters (SQL/DynamoDB) for PatRecord -- consumers bring their own; the shape is storage-agnostic on purpose.
  • The admin management UI (create with scope picker, show-once, list, revoke).

See DCMS-1409.