{"name":"@peculiar/x509","version":"3.0.0","keywords":["certificate","cms","csr","ec","pkcs10","pkcs7","rsa","x509"],"author":{"name":"Peculiar Ventures LLC"},"license":"MIT","_id":"@peculiar/x509@3.0.0","maintainers":[{"name":"rmhrisk","email":"ryan_hurst@hotmail.com"},{"name":"microshine","email":"microshine@mail.ru"},{"name":"yury.strozhevsky","email":"yury@strozhevsky.com"},{"name":"peculiarventures","email":"info@peculiarventures.com"},{"name":"apilguk","email":"apilguk@gmail.com"},{"name":"donskov","email":"donskovdmitriyv@gmail.com"},{"name":"worldthirteen","email":"mihailzachepilo@gmail.com"}],"contributors":[{"name":"Miroshin Stepan","email":"microshine@mail.ru"}],"homepage":"https://github.com/PeculiarVentures/x509#readme","bugs":{"url":"https://github.com/PeculiarVentures/x509/issues"},"dist":{"shasum":"5bda704cc24841d6ef9ff8b9c67987f2c78fd488","tarball":"http://registry-npm.ywwl.com/@peculiar/x509/download/@peculiar/x509-3.0.0.tgz","fileCount":5,"integrity":"sha512-1zMViQ7z99f7sdV1SML7FAkzz7HWbovINN4hEvdPx47m3JGgxV9649L5Xpu7yVWdJa/n0UNIXV+NKRHVjXNEcQ==","signatures":[{"sig":"MEYCIQDhpApAeh1JEAi7tjBjxEj6xGvfpjEBA+pc51oTLlUXuQIhAJ1UzQptB3HgD58DK8pLQ1WMTCR3HkCdgz6UUa3VG/Mw","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCZ/tO80MgNxug3eRkARbsfnHZuUOY4qPVq7yyHARLz9wIhAMSn8YSCMpi7s+kjVIXj1dyiIdgXbJsQe+vtb+fyuNou","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@peculiar%2fx509@3.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":171345,"size":34828,"noattachment":false,"key":"/@peculiar/x509/-/@peculiar/x509-3.0.0.tgz"},"main":"./build/index.js","type":"module","types":"./build/index.d.ts","module":"./build/index.js","engines":{"node":"^20.19.0 || >=22.12.0"},"exports":{".":"./build/index.js","./package.json":"./package.json"},"gitHead":"925ec1334f83d76cb8cc455550f94d6a1dd687ea","scripts":{"lint":"oxlint","test":"vitest run","build":"tsdown","format":"oxfmt","prepack":"npm run build","coverage":"vitest run --coverage","lint:fix":"oxlint --fix","typecheck":"tsc --noEmit","format:check":"oxfmt --check"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"d462d90c-045a-453d-8cce-0249c43ff14e"}},"devEngines":{"packageManager":{"name":"npm","onFail":"error","version":">=10"}},"repository":{"url":"git+https://github.com/PeculiarVentures/x509.git","type":"git"},"_npmVersion":"11.19.0","description":"@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","directories":{},"sideEffects":false,"_nodeVersion":"24.21.0","allowScripts":{"fsevents@2.3.3":true},"dependencies":{"tsyringe":"^4.10.0","@peculiar/utils":"^4.1.0","@peculiar/asn1-cms":"^3.0.0","@peculiar/asn1-csr":"^3.0.0","@peculiar/asn1-ecc":"^3.0.0","@peculiar/asn1-rsa":"^3.0.0","@peculiar/asn1-x509":"^3.0.0","@peculiar/asn1-pkcs9":"^3.0.0","@peculiar/asn1-x509-post-quantum":"^3.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"oxfmt":"^0.75.0","asn1js":"^4.0.0","oxlint":"^1.90.0","tsdown":"^0.23.2","vitest":"^5.0.5","typescript":"^6.0.3","@types/node":"^24.19.2","@abraham/reflection":"^0.13.0","@peculiar/webcrypto":"^2.0.0","@vitest/coverage-v8":"^5.0.5","@peculiar/asn1-schema":"^3.0.0","@arethetypeswrong/core":"^0.18.5"},"peerDependencies":{"@peculiar/asn1-schema":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/x509_3.0.0_1793112343073_0.7310146957743742","host":"s3://npm-registry-packages-npm-production"},"readme":"<h1 align=\"center\">\n  @peculiar/x509\n</h1>\n\n<div align=\"center\">\n\n![NPM License](https://img.shields.io/npm/l/@peculiar/x509)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/PeculiarVentures/x509/publish.yml?branch=master&label=publish)\n[![npm version](https://img.shields.io/npm/v/@peculiar/x509.svg)](https://www.npmjs.com/package/@peculiar/x509)\n![Coveralls](https://img.shields.io/coverallsCoverage/github/PeculiarVentures/x509)\n[![npm downloads](https://img.shields.io/npm/dm/@peculiar/x509.svg)](https://www.npmjs.com/package/@peculiar/x509)\n\n</div>\n\n- [About](#about)\n- [Installation](#installation)\n- [⚠️ Reflect Polyfill Required](#-reflect-polyfill-required)\n- [Breaking Changes In v3](#breaking-changes-in-v3)\n- [Documentation](#documentation)\n- [Usage](#usage)\n  - [Browser](#browser)\n  - [Set a crypto provider](#set-a-crypto-provider)\n- [Examples](#examples)\n- [Contributing](#contributing)\n\n## About\n\n`@peculiar/x509` is a TypeScript/JavaScript library for X.509 certificates, certificate requests (PKCS#10), and certificate revocation lists (CRLs) in browsers and Node.js. It parses, creates, and verifies them with WebCrypto, builds certificate chains, and reads and writes PKCS#7 certificate lists. It is built on [`@peculiar/asn1-schema`](https://github.com/PeculiarVentures/asn1-schema).\n\n## Installation\n\n```bash\nnpm install @peculiar/x509 reflect-metadata\n```\n\n## ⚠️ Reflect Polyfill Required\n\n**This library requires a Reflect API polyfill.** You must install one of the following and import it at the top of your entry point:\n\n- [reflect-metadata](https://www.npmjs.com/package/reflect-metadata)\n- [core-js](https://www.npmjs.com/package/core-js) (`core-js/full/reflect`)\n- [@abraham/reflection](https://www.npmjs.com/package/@abraham/reflection)\n\n**Example with reflect-metadata:**\n\n```js\nimport \"reflect-metadata\";\nimport * as x509 from \"@peculiar/x509\";\n// ...\n```\n\nIf 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.\n\n## Breaking Changes In v3\n\nv3 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.\n\n- **TypeScript compiling to CommonJS:** use `\"module\": \"node20\"` or `\"nodenext\"` (`node16` fails with TS1479). ESM and bundler setups need no changes.\n- **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`).\n- **Deep imports** (`@peculiar/x509/build/x509.cjs.js`, `@peculiar/x509/build/x509.es.js`) are blocked by `exports`; import from `@peculiar/x509`.\n- **No browser script bundle:** `build/x509.js` (the `x509` global for `<script>` tags) and the `unpkg`/`jsdelivr` fields are removed, so an unversioned `<script src=\"https://unpkg.com/@peculiar/x509\">` stops working. Bundle the package or import it from esm.sh as a module (see [Browser](#browser)), or pin `@peculiar/x509@2` for the old script.\n- **`@peculiar/asn1-schema` 3 is a peer dependency**, and the `@peculiar/asn1-*` packages move to 3 (which need `asn1js` 4). npm installs peers automatically; the app must end up with a single copy of each. ASN.1 objects built with asn1-schema 2 packages (for example a `Certificate` from `@peculiar/asn1-x509` 2) can't be passed to x509 3, so upgrade other libraries that use them at the same time.\n- **`pvtsutils` is replaced by `@peculiar/utils` 4.** Hex input (serial numbers, key identifiers, `#` name values) is read as before. Byte input passed as a view (`Uint8Array`, `Buffer`) is now copied, so `rawData` no longer shares memory with it; Base64 text with line breaks, which v2 rejected as `raw` input, is decoded; and `SharedArrayBuffer` input is accepted.\n- **Trailing data is rejected:** DER/BER input (certificates, CRLs, CSRs, public keys, extensions, PKCS#7 lists) that continues after the encoded structure throws `Unexpected data after the ASN.1 structure`. v2 ignored the extra bytes but kept them in `rawData` and thumbprints.\n- **`@peculiar/webcrypto`** as the crypto provider: use 2.x, which shares asn1-schema 3 with x509. Next to asn1-schema 3, 1.x keeps two private asn1-schema 2 copies and its ECDSA signing fails with `Cannot get schema for 'EcDsaSignature' target`.\n\n## Documentation\n\nDocumentation, the API reference, and runnable examples are at [peculiarventures.github.io/x509](https://peculiarventures.github.io/x509/).\n\n## Usage\n\n```js\nimport \"reflect-metadata\";\nimport * as x509 from \"@peculiar/x509\";\n\n// Create a self-signed certificate with a WebCrypto key pair\nconst algorithm = { name: \"ECDSA\", namedCurve: \"P-256\", hash: \"SHA-256\" };\nconst keys = await crypto.subtle.generateKey(algorithm, false, [\"sign\", \"verify\"]);\nconst cert = await x509.X509CertificateGenerator.createSelfSigned({\n  name: \"CN=Example\",\n  keys,\n  signingAlgorithm: algorithm,\n  extensions: [new x509.BasicConstraintsExtension(true, undefined, true)],\n});\nconst pem = cert.toString(\"pem\");\n\n// Parse a certificate from PEM, Base64, hex, or DER and read it\nconst parsed = new x509.X509Certificate(pem);\nconsole.log(parsed.subject); // CN=Example\nconsole.log(await parsed.verify()); // true: self-signed and valid now\n```\n\n### Browser\n\nBundle `@peculiar/x509` with your app (Vite, webpack, esbuild, Rollup), or load the ESM build from a CDN that serves npm packages as browser modules, such as [esm.sh](https://esm.sh). Import the Reflect polyfill first:\n\n```html\n<script type=\"module\">\n  import \"https://esm.sh/reflect-metadata\";\n  import * as x509 from \"https://esm.sh/@peculiar/x509@3\";\n\n  const cert = new x509.X509Certificate(pem);\n  console.log(cert.subject);\n</script>\n```\n\n> WARN: Pin the version in the URL, and prefer bundling or hosting your own copy for production.\n\n### Set a crypto provider\n\nBy default the library uses the platform's WebCrypto (`globalThis.crypto`), which browsers and Node.js provide. To use another WebCrypto implementation, for example [`@peculiar/webcrypto`](https://www.npmjs.com/package/@peculiar/webcrypto) 2.x for algorithms your platform lacks, set it as the provider:\n\n```js\nimport * as x509 from \"@peculiar/x509\";\nimport { Crypto } from \"@peculiar/webcrypto\";\n\nx509.cryptoProvider.set(new Crypto());\n```\n\n## Examples\n\nRunnable examples are on the [website](https://peculiarventures.github.io/x509/docs/examples/):\n\n- Certificates: [read a certificate](https://peculiarventures.github.io/x509/docs/examples/certificates/parse-certificate), [create a self-signed certificate](https://peculiarventures.github.io/x509/docs/examples/certificates/self-signed), [issue and verify a certificate](https://peculiarventures.github.io/x509/docs/examples/certificates/issue-certificate), [distinguished names](https://peculiarventures.github.io/x509/docs/examples/certificates/names)\n- Certificate requests: [create a certificate request](https://peculiarventures.github.io/x509/docs/examples/requests/create-csr), [issue a certificate from a request](https://peculiarventures.github.io/x509/docs/examples/requests/sign-csr)\n- Revocation: [create and check a CRL](https://peculiarventures.github.io/x509/docs/examples/revocation/crl)\n- Chains and bundles: [build a certificate chain](https://peculiarventures.github.io/x509/docs/examples/chains/build-chain), [search paths to a trusted anchor](https://peculiarventures.github.io/x509/docs/examples/chains/build-to-anchor), [PKCS#7 files and PEM bundles](https://peculiarventures.github.io/x509/docs/examples/chains/pkcs7)\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, commit conventions and the release flow.\n","publish_time":1793112343177,"_cnpm_publish_time":1793112343177,"dist-tags":{"beta":"1.3.3-beta.0","latest":"3.1.0"}}