UNPKG

codalware-auth

Version:

Complete authentication system with enterprise security, attack protection, team workspaces, waitlist, billing, UI components, 2FA, and account recovery - production-ready in 5 minutes. Enhanced CLI with verification, rollback, and App Router scaffolding.

21 lines (17 loc) 584 B
import crypto from 'crypto'; export function generateToken(bytes = 32): string { return crypto.randomBytes(bytes).toString('base64url'); } export function hmacHash(secret: string, token: string): string { return crypto.createHmac('sha256', secret).update(token).digest('hex'); } export function timingSafeEqualHex(a: string, b: string): boolean { try { const ab = Buffer.from(a, 'hex'); const bb = Buffer.from(b, 'hex'); if (ab.length !== bb.length) return false; return crypto.timingSafeEqual(ab, bb); } catch { return false; } }