API Key Manager (lib/keys.ts)

rekey · apps/api/src/lib/keys.ts · typescript · MIT
auth, security, integration

Generates and verifies public and secret API keys using SHA-256 hashing. Use this for secure authentication in server-side and client-side applications.

// Source: https://github.com/rekey-dev/rekey | License: MIT | Copyright 2026 Rekey
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * API key generation + verification.
 *
 * Two key formats:
 *
 *   - **Public key** (browser-safe): `rp_pub_<slug>_<random16>`
 *     One per Application. Shipped to the browser by `@rekey.dev/react`. The
 *     SDK uses it to call public, unauthenticated-from-server endpoints
 *     (sign-in widgets, plan listing, etc.).
 *
 *   - **Secret key** (server-only): `rp_<live|test>_<random32>`
 *     Many per Application. Used by `@rekey.dev/node` for trusted server-side
 *     calls. Stored as SHA-256 hash; the raw key is shown to the user
 *     exactly once at creation.
 *
 * Why SHA-256 and not Argon2? API keys are high-entropy random tok

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key