Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9.4 KiB
9.4 KiB
@suaveplan/jwt-tenant - JWT-based multi-tenant token issuance and verification with Ed25519/ECDSA signing, JWKS rotation, and injectable clock
Summary
JWT-based multi-tenant token issuance and verification for Suaveplan. Ships an Ed25519 / ECDSA-P256 signing pipeline, in-memory JWKS store with rotation and expiration, JWKS HTTP endpoint formatter, token issuer and verifier with injectable clock, and structured JWT_TENANT_* error codes — all backed by jose, Zod-validated configs, and OpenTelemetry instrumentation.
Documentation tree
- errors — (no submodules)
- jwt-tenant-error — (no submodules)
- in-memory-key-store — (no submodules)
- in-memory-key-store — (no submodules)
- jwks-endpoint — (no submodules)
- jwks-endpoint — (no submodules)
- key-generator — (no submodules)
- key-generator — (no submodules)
- schemas — (no submodules)
- jwt-tenant.schemas — (no submodules)
- token-issuer — (no submodules)
- token-issuer — (no submodules)
- token-verifier — (no submodules)
- token-verifier — (no submodules)
Install
bun add @suaveplan/jwt-tenant
Quick start
import {
createInMemoryKeyStore,
createTokenIssuer,
createTokenVerifier,
generateKeyPair,
} from "@suaveplan/jwt-tenant";
const keyPair = await generateKeyPair({ algorithm: "EdDSA" });
const store = createInMemoryKeyStore();
await store.add(keyPair);
const issuer = createTokenIssuer({ store, issuer: "https://auth.example.com" });
const token = await issuer.sign({
subject: "user-123",
tenantId: "tenant-abc",
expiresIn: 3600,
});
const verifier = createTokenVerifier({ store, issuer: "https://auth.example.com" });
const claims = await verifier.verify(token);
Modules
- Errors —
JwtTenantError,JWT_TENANT_CODES, structured error registry - Key generator —
generateKeyPair, JWK import/export, expiration helpers - In-memory key store — JWKS storage with rotation and expiration
- JWKS endpoint —
createJWKSEndpoint,formatJWKSResponsefor.well-known/jwks.json - Token issuer —
createTokenIssuer,signToken - Token verifier —
createTokenVerifier, claim validation - Schemas — Zod schemas for all public option bundles
- Types — shared type definitions