Profile
Back to NewsBack
GitHub Trending 8 min
Reader Mode
PeculiarVentures/x509: @peculiar/x509 is an easy to use TypeScript/Javascript library based on @peculiar/asn1-schema that makes generating X.509 Certificates and Certificate Requests as well as validating certificate chains easy

PeculiarVentures/x509: @peculiar/x509 is an easy to use TypeScript/Javascript library based on @peculiar/asn1-schema that makes generating X.509 Certificates and Certificate Requests as well as validating certificate chains easy

12 hours ago

@peculiar/x509

- Browser - Set crypto provider for Node.js - Create a self-signed certificate - Parse a X509 certificate - Create a PKCS#10 certificate request - Decoded X509 certificate - Verify a certificate - Build a certificate chain - Export a list of X509 certificates to PKCS#7 format

About

@peculiar/x509 is an easy to use TypeScript/Javascript library based on @peculiar/asn1-schema that makes generating X.509 Certificates and Certificate Requests as well as validating certificate chains easy.

⚠️ Reflect Polyfill Required

This library requires a Reflect API polyfill. You must install one of the following and import it at the top of your entry point:

Example with reflect-metadata:
import "reflect-metadata";
import * as x509 from "@peculiar/x509";
// ...

If you see the error "tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point." — install one of the polyfills above and add the import before any @peculiar/x509 imports.

Installation

npm install @peculiar/x509

Breaking Changes In v3

v3 is ESM-only and requires Node.js ^20.19.0 || >=22.12.0 (was >=20.0.0). CommonJS code can still require("@peculiar/x509") on these versions; Node.js 20.0–20.18 and 22.0–22.11 can't. The public API is unchanged, and the Reflect polyfill is still required.

  • TypeScript compiling to CommonJS: use "module": "node20" or "nodenext" (node16 fails with TS1479). ESM and bundler setups need no changes.
  • Jest in CommonJS mode: switch to ESM mode or Vitest, or configure an ESM-to-CommonJS transformer and make sure transformIgnorePatterns doesn't exclude @peculiar/x509 and its ESM dependencies (@peculiar/asn1-*, asn1js, @peculiar/utils).
  • Deep imports (@peculiar/x509/build/x509.cjs.js, @peculiar/x509/build/x509.es.js) are blocked by exports; import from @peculiar/x509.
  • No browser script bundle: build/x509.js (the x509 global for Chat with me