package
Public Key Infrastructure (PKI) is the basis of how identity and key management is performed on the web today. PKIjs is a pure JavaScript library implementing the formats that are used in PKI applications. It is built on WebCrypto and aspires to make it p
npm install pkijsGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
PKIjs provides a Typescript implementation of the most common formats and algorithms needed to build PKI-enabled applications
npm install pkijs asn1jsasn1js is a peer dependency: pkijs and your application must use the same copy (see below).
v4 is ESM-only and requires Node.js ^20.19.0 || >=22.12.0 (was >=16.0.0). CommonJS code can still require("pkijs") on these versions; Node.js 22.0–22.11 can't. The exported API is unchanged, but some input handling changed with the move from pvutils/pvtsutils to @peculiar/utils (last three items).
"module": "node20" or "nodenext" (node16 fails with TS1479). ESM and bundler setups need no changes.transformIgnorePatterns doesn't exclude pkijs and its ESM dependencies (asn1js, bytestreamjs, @peculiar/utils, @noble/hashes).pkijs/build/index.js, pkijs/build/index.es.js) are blocked by exports; import from pkijs.bytestreamjs moves to 3. Install asn1js@^4 next to pkijs. pkijs checks instanceof asn1js.Sequence and similar on values you pass in, so they must come from the same asn1js copy as pkijs's: values built with asn1js 3 fail those checks. Upgrade other libraries that still depend on asn1js 3 (such as @peculiar/asn1-schema 2) at the same time.RSAPublicKey and ECPublicKey fromJSON() throw a TypeError when a JWK member isn't base64url (padding is still accepted), and SignedCertificateTimestamp#verify() throws one when the log key isn't base64. v3 decoded such text into wrong bytes or failed later with an AsnError. RSAPublicKey.fromJSON() also decodes n and e exactly: v3 turned e = 3 into 196608, cut longer exponents to 3 bytes, and kept a trailing zero byte on some modulus lengths.SignedCertificateTimestamp toStream(), toSchema() and verify() throw a RangeError for an invalid or pre-1970 timestamp; v3 wrote 0 or wrapped bytes.PkiObject#toString() accepts only "hex", "base64" and "base64url" (v3 also took "utf8", "binary" and "utf16"), and throws a , like the other constructors.You can find the PKI.js documentation on the website.
Want to file a bug, contribute some code, or improve documentation? Excellent! See CONTRIBUTING.md for development setup, commit conventions and the release flow.
microshine
microshine@mail.ru
new CertificateChainValidationEngine(null)TypeErrorEstimated unpacked size across 4 packages.
1.7 MB
Includes dependencies.
3 direct dependencies.