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

@armco/iam-server

v0.1.1

Published

Server-side JWT validation and middleware for IAM

Readme

@armco/iam-server

Server-side JWT validation and middleware for IAM.

Installation

npm install @armco/iam-server

Quick Start

Standalone Verifier

import { createIAMVerifier } from '@armco/iam-server';

const verifier = createIAMVerifier({
  issuer: 'http://localhost:5000',
  audience: 'my-api',
});

// Verify a token
const result = await verifier.verify(token);
if (result.valid) {
  console.log('User ID:', result.payload.sub);
  console.log('Email:', result.payload.email);
  console.log('Roles:', result.payload.roles);
}

// Or authenticate and get structured user info
const user = await verifier.authenticate(token);
if (user) {
  console.log(user.id, user.email, user.roles, user.scopes);
}

Express Middleware

import express from 'express';
import { createAuthMiddleware, requireRole } from '@armco/iam-server/express';

const app = express();

// Create auth middleware
const auth = createAuthMiddleware({
  issuer: 'http://localhost:5000',
  audience: 'my-api',
});

// Protect all /api routes
app.use('/api', auth());

// Access user in handlers
app.get('/api/profile', (req, res) => {
  res.json({
    id: req.user.id,
    email: req.user.email,
    roles: req.user.roles,
  });
});

// Require specific role
app.get('/api/admin', auth({ roles: ['admin'] }), (req, res) => {
  res.json({ message: 'Admin access granted' });
});

// Require specific scope
app.get('/api/data', auth({ scopes: ['read:data'] }), (req, res) => {
  res.json({ data: '...' });
});

// Or use standalone middleware
app.delete('/api/users/:id', auth(), requireRole('admin'), handler);

Configuration

interface IAMServerConfig {
  /** IAM server base URL */
  issuer: string;
  /** Expected audience (your app's client_id) */
  audience: string;
  /** Cache JWKS keys (default: true) */
  cacheKeys?: boolean;
  /** JWKS cache TTL in seconds (default: 3600) */
  cacheTTL?: number;
  /** Required scopes for all requests */
  requiredScopes?: string[];
  /** Custom claim to extract user ID from (default: 'sub') */
  userIdClaim?: string;
}

API Reference

IAMVerifier

| Method | Description | |--------|-------------| | verify(token) | Verify JWT, returns { valid, payload?, error? } | | authenticate(token) | Verify and return AuthenticatedUser or null | | hasRole(user, roles) | Check if user has any of the roles | | hasAllRoles(user, roles) | Check if user has all roles | | hasScope(user, scopes) | Check if user has any of the scopes | | hasAllScopes(user, scopes) | Check if user has all scopes | | clearCache() | Force JWKS refresh on next verify |

Express Middleware

| Function | Description | |----------|-------------| | createAuthMiddleware(config) | Create auth middleware factory | | auth(options?) | Middleware that requires valid token | | requireRole(roles) | Middleware to check roles (use after auth) | | requireScope(scopes) | Middleware to check scopes (use after auth) | | createOptionalAuthMiddleware(config) | Attaches user if token present, doesn't require it |

AuthenticatedUser

interface AuthenticatedUser {
  id: string;        // Global identity ID (from 'sub')
  userId?: string;   // Tenant-specific user ID
  tenantId?: string; // Tenant ID
  email?: string;
  username?: string;
  roles: string[];
  scopes: string[];
  claims: JWTPayload; // Raw JWT payload
}

Development

cd packages/iam-server
npm install
npm run build
npm run dev  # Watch mode