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>
8.1 KiB
8.1 KiB
@suaveplan/auth - Provider-agnostic authentication: JWT lifecycle, API key management, session management, and request middleware with pluggable storage adapters
Summary
Provider-agnostic authentication library for Suaveplan. Ships JWT token lifecycle, API key management, session management, and framework-agnostic middleware — all backed by a pluggable AuthAdapter interface.
Documentation tree
- auth — (no submodules)
- auth — (no submodules)
- memory — (no submodules)
- memory — (no submodules)
- api-keys — (no submodules)
- api-keys — (no submodules)
- errors — (no submodules)
- auth-error — (no submodules)
- jwt — (no submodules)
- token-lifecycle — (no submodules)
- middleware — (no submodules)
- auth-middleware — (no submodules)
- schemas — (no submodules)
- auth.schemas — (no submodules)
Packages
| Module | Description |
|---|---|
| errors/auth-error | Stable AUTH.* error code registry and concrete error classes |
| types/auth.types | All public interfaces and type aliases |
| schemas/auth.schemas | Zod validation schemas for option types |
| adapters/auth-adapter | AuthAdapter interface definition |
| adapters/memory-adapter | In-memory AuthAdapter implementation |
| api-keys | Full API key lifecycle |
| jwt/token-lifecycle | JWT issue, validate, refresh, revoke |
| middleware/auth-middleware | Permission middleware helpers |
Quick Start
import {
MemoryAuthAdapter,
issueToken,
validateSessionToken,
createApiKey,
validateApiKey,
requirePermission,
} from "@suaveplan/auth";
const adapter = new MemoryAuthAdapter();
const jwtOpts = { secret: process.env["JWT_SECRET"] ?? "" };
// Issue JWT tokens
const { accessToken, refreshToken } = await issueToken(adapter, userId, jwtOpts);
// Validate
const result = await validateSessionToken(adapter, accessToken, jwtOpts);
// API keys
const { rawKey } = await createApiKey(adapter, { name: "CI Key", userId });
const v = await validateApiKey(adapter, rawKey);
// Middleware
const adminOnly = requirePermission("admin:write", adapter, jwtOpts);