pkijs.com
Every page in this reference is generated from the toolkit's own source comments. Zero npm runtime dependencies — the cryptography runs on Node's native node:crypto (classical and FIPS post-quantum), nothing vendored.
Quick start
npm install @blamejs/pki
var pki = require("@blamejs/pki");
var cert = pki.schema.x509.parse(pemText);
cert.subject.dn; // "CN=example.com, O=Example"
cert.validity.notAfter; // Date
cert.signatureAlgorithm.name; // "sha256WithRSAEncryption"
pki.schema.parse(der) detects which of the toolkit's registered formats the bytes encode — certificate, CRL, CSR, CMS, OCSP, PKCS#8, PKCS#12, timestamp token, and the rest — and routes to the owning parser. pki.schema.all() lists the registered formats.Design tenets
- Zero runtime dependencies. The published package's dependency object is empty; the cryptography is Node's own
node:crypto. - Fail closed. Every verify path throws; malformed input is a typed
PkiErrorwith a stabledomain/reasoncode. - Strict DER. The codec rejects every non-DER shape and enforces size and depth caps before it walks a byte.
- Post-quantum first. ML-DSA, ML-KEM, and SLH-DSA resolve through the same OID-keyed registry as the classical algorithms.
- Standards are the contract. Every structure maps to a named RFC, and a parser round-trips a valid input to identical bytes.
Namespaces
Constants
Functional scale helpers (`C.TIME.*`, `C.BYTES.*`) plus the toolkit version and shared codec limits.
ASN.1 / DER
Strict, fail-closed DER decode / encode with a navigable node tree and typed readers + builders.
WebCrypto
A zero-dep, PQC-first W3C WebCrypto (`SubtleCrypto`) engine over `node:crypto`: ML-DSA and SLH-DSA signatures alongside the full classical algorithm set.
Schema
One declarative schema engine; every PKI format (X.509, CRL, ...) is a member composed on it. Detect-and-parse DER, or call a format directly.
X.509
Parse DER / PEM X.509 certificates into structured, validated fields with named algorithms, extensions, and real-`Date` validity windows.