npm install @ferrow/basic-auth-parserHTTP auth header parsing (Basic, Bearer, Digest) with timing-safe credential comparison.
import { parseBasic, timingSafeCompare } from "basic-auth-parser";
const auth = parseBasic("Basic dXNlcjpwYXNz");
if (timingSafeCompare(auth.password, stored)) {
console.log("Authenticated");
}Parse Basic auth (RFC 7617). Splits on first colon only (password can contain colons).
Extract Bearer token.
Parse Digest challenge fields (quoted-string aware).
Constant-time string comparison to prevent timing attacks.
Build WWW-Authenticate challenge header.
- Digest parsing extracts fields; no response verification included
- No SCRAM or other advanced schemes
Part of the ferrow-toolkit collection · Sponsored by Ferrow