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

intentkit-auth

v1.0.1

Published

JWT authentication adapter for IntentKit via jose

Readme

intentkit-auth

JWT authentication adapter for IntentKit — token signing, verification, and decoding via jose.

Supports symmetric secrets (HMAC) for full sign+verify, and JWKS endpoints (Auth0, Okta, etc.) for verify-only flows.

Install

npm install intentkit-auth

Quick Start

import { defineFunction, IntentRegistry, createContext, serve, z } from 'intentkit';
import { createAuthProvider, type AuthClient } from 'intentkit-auth';

// Register your functions
const registry = new IntentRegistry().register(createToken, verifyToken, decodeToken);

// Create context (no database needed for auth-only projects)
const context = await createContext({ events: true });

// Boot MCP server with auth provider
await serve({
  name: 'my-auth-agent',
  registry,
  context,
  providers: [
    createAuthProvider({
      secret: process.env.JWT_SECRET!,
      issuer: 'my-service',
      audience: 'my-api',
    }),
  ],
});

Configuration

| Option | Default | Description | |--------|---------|-------------| | secret | -- | Symmetric secret for HMAC signing + verification | | jwksUrl | -- | JWKS endpoint URL for asymmetric verification (e.g., Auth0) | | issuer | -- | Expected iss claim (validated on verify) | | audience | -- | Expected aud claim (validated on verify) | | algorithm | 'HS256' / auto | Signing algorithm (HS256 for secret, auto-detected for JWKS) | | defaultExpiry | '1h' | Default token expiry (jose duration format) | | name | 'auth' | Provider name in ctx.providers |

You must provide at least one of secret or jwksUrl. Provide both to sign with a symmetric secret and also accept tokens signed by an asymmetric key (JWKS).

Common Provider Configs

Symmetric Secret (simple):

createAuthProvider({
  secret: process.env.JWT_SECRET!,
  defaultExpiry: '24h',
})

JWKS Endpoint (Auth0):

createAuthProvider({
  jwksUrl: 'https://your-tenant.auth0.com/.well-known/jwks.json',
  issuer: 'https://your-tenant.auth0.com/',
  audience: 'https://your-api.example.com',
})

JWKS Endpoint (Okta):

createAuthProvider({
  jwksUrl: 'https://your-org.okta.com/oauth2/default/v1/keys',
  issuer: 'https://your-org.okta.com/oauth2/default',
  audience: 'api://default',
})

Issuer + Audience Validation:

createAuthProvider({
  secret: process.env.JWT_SECRET!,
  issuer: 'my-service',
  audience: 'my-api',
  algorithm: 'HS384',
  defaultExpiry: '8h',
})

Using in Functions

Access the auth client via ctx.providers.auth:

import { defineFunction, z } from 'intentkit';
import type { AuthClient } from 'intentkit-auth';

export const loginUser = defineFunction({
  name: 'login_user',
  intent: 'Authenticate a user and return a signed JWT token',
  permissions: ['auth:sign'],
  requires: ['auth'],  // Validates provider exists at startup

  input: z.object({
    user_id: z.string(),
    role: z.string(),
  }),
  output: z.object({
    token: z.string(),
  }),

  execute: async (input, ctx) => {
    const auth = ctx.providers.auth as AuthClient;

    const token = await auth.sign(
      { role: input.role },
      { subject: input.user_id, expiresIn: '24h' },
    );

    return { token };
  },
});

Example Functions

The package includes 3 ready-to-use functions in functions/tokens.ts:

| Function | Intent | Permission | |----------|--------|------------| | create_token | Create a signed JWT token with custom claims | auth:sign | | verify_token | Verify a token's signature and expiration | auth:verify | | decode_token | Decode a token without verification | auth:read |

Import and register them:

import { createToken, verifyToken, decodeToken } from 'intentkit-auth/functions';

const registry = new IntentRegistry()
  .register(createToken, verifyToken, decodeToken);

AuthClient API

The full client interface for custom function implementations:

interface AuthClient {
  // Sign a payload into a JWT token (requires symmetric secret)
  sign(payload: Record<string, unknown>, options?: SignOptions): Promise<string>;

  // Verify a token's signature and claims
  verify(token: string): Promise<VerifyResult>;

  // Decode without verification (never trust unverified data)
  decode(token: string): TokenPayload;

  // Health check
  ping(): Promise<boolean>;
}

interface SignOptions {
  subject?: string;       // sub claim
  expiresIn?: string;     // override default expiry (e.g., '2h', '7d')
  claims?: Record<string, unknown>;  // additional claims
}

interface VerifyResult {
  valid: boolean;         // signature + claims valid
  payload: TokenPayload;  // decoded payload
  expired: boolean;       // failed specifically due to expiration
}

interface TokenPayload {
  sub?: string;
  iss?: string;
  aud?: string;
  exp?: number;
  iat?: number;
  [key: string]: unknown;
}

Claude Desktop Config

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "auth": {
      "command": "node",
      "args": ["path/to/your/serve.js"],
      "env": {
        "JWT_SECRET": "your-secret-key"
      }
    }
  }
}

Architecture

Claude (Dispatch / Desktop)
    | MCP tool call
IntentKit (serve + permissions + hooks)
    | ctx.providers.auth
intentkit-auth (AuthClientImpl)
    |
  jose
  (JWT)
    |
Tokens (signed / verified / decoded)

The AuthClient is stateless -- created once at server startup. healthCheck() performs a sign+verify round-trip (symmetric) or fetches the JWKS endpoint (asymmetric). No connections to close on shutdown.

License

MIT