Opaque credential primitives (mint, hash, timing-safe compare) and TTL constants for OAuth token management without database dependencies.
// Source: https://github.com/VeriTeknik/pluggedin-app | License: MIT | Copyright 2025 Plugged.in
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Opaque credential primitives for the OAuth authorization server.
*
* Opaque rather than JWT: revocation is a real requirement here (refresh-token
* family revocation, user-initiated disconnect), and a single indexed lookup is
* cheap. JWTs would make revocation a denylist problem.
*
* Nothing in this module touches the database, so it stays trivially testable.
*/
import { createHash, randomBytes, timingSafeEqual } from 'crypto';
/** 32 bytes of CSPRNG output, base64url — 43 characters, no padding. */
export function mintCredential(): string {
return randomBytes(32).toString('base64url');
}
export function hashC
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key