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

@get401/node

v0.1.0

Published

Core Node.js SDK for get401 authentication — EdDSA/Ed25519 JWT verification.

Readme

@get401/node

Core Node.js SDK for get401 authentication. Verifies EdDSA/Ed25519 JWTs, fetches and caches the public key, and parses token claims.

Backend only. This library is designed for Node.js server environments (Express, Next.js route handlers, etc.), not browser code.

Used directly by @get401/next and @get401/express. You can also use it standalone in any Node.js application.

Installation

npm install @get401/node
# or
pnpm add @get401/node

Requires Node.js ≥ 18 (for native fetch and Web Crypto).

Quick start

import { Get401Client, TokenVerifier } from '@get401/node'

const client = new Get401Client({
  appId: 'your-app-id',
  origin: 'https://yourapp.com',
})
const verifier = new TokenVerifier(client)

const claims = await verifier.verify(tokenString)

console.log(claims.sub)    // user public ID
console.log(claims.roles)  // ['USER']
console.log(claims.scope)  // 'read,write'

Configuration

new Get401Client({
  appId: 'your-app-id',           // required — sent as X-App-Id header
  origin: 'https://yourapp.com',  // required — sent as Origin header
  host: 'https://app.get401.com', // optional — defaults to get401 cloud
})

TokenClaims reference

| Field | Type | Description | |-------|------|-------------| | sub | string | User's public ID | | exp | number | Expiration Unix timestamp | | iat | number | Issued-at Unix timestamp | | iss | string | Token issuer | | roles | string[] | Roles granted — e.g. ['USER'] | | scope | string | Comma-separated scope string |

Helper functions

import {
  hasRole, hasAnyRole, hasAllRoles,
  hasScope, getScopes,
  isAuthenticatedUser,
} from '@get401/node'

hasRole(claims, 'USER')                  // boolean
hasAnyRole(claims, 'USER', 'ADMIN')      // boolean
hasAllRoles(claims, 'USER', 'PREMIUM')   // boolean

hasScope(claims, 'read')                 // boolean
getScopes(claims)                        // ['read', 'write']

isAuthenticatedUser(claims)              // true when roles includes 'USER'

Error handling

All errors extend Get401Error.

| Error class | When thrown | |-------------|-------------| | TokenExpiredError | exp is in the past | | InvalidTokenError | Malformed token or invalid signature | | InvalidAlgorithmError | Token declares an algorithm other than EdDSA | | PublicKeyFetchError | Could not reach the get401 backend |

import {
  TokenExpiredError,
  InvalidAlgorithmError,
  Get401Error,
} from '@get401/node'

try {
  const claims = await verifier.verify(token)
} catch (error) {
  if (error instanceof TokenExpiredError) {
    // prompt re-login
  } else if (error instanceof Get401Error) {
    // catch-all for any get401 error
  }
}

Public key caching

The client caches the public key automatically until the backend-provided expiresAt timestamp passes. Force a refresh when needed:

await client.getPublicKey({ forceRefresh: true })