{"name":"@peculiar/x509","version":"2.2.0","keywords":["certificate","cms","csr","ec","pkcs10","pkcs7","rsa","x509"],"author":{"name":"Peculiar Ventures LLC"},"license":"MIT","_id":"@peculiar/x509@2.2.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":"51f5c753b1cd761ddb6d0aa742e042da4f35a06d","tarball":"http://registry-npm.ywwl.com/@peculiar/x509/download/@peculiar/x509-2.2.0.tgz","fileCount":7,"integrity":"sha512-adpW58ySPQMOUPv8pTKT3RIyCFqfUFt8X05ukPdtkQToXDVr8dMtxuenik1yx8tNFTbpApWsM/Hi5SzlIx48+Q==","signatures":[{"sig":"MEUCIAcH1dSYOa3uFlkfuvQXT9jAB3lE0QN9X4h5fRlImtUQAiEAhj55hfVaKsMIQ9DbbTfNhlwLa4FuRMAApduaQ1ZPICs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCHsyRXL92JLBCL2NmIXU4+JvUkC+dPlqNcKzMPV7lKxQIhAPWegPj/yMEPR8vciTj5YccJa+d/PtJi/XnLHXymZYxF","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@peculiar%2fx509@2.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":593309,"size":112798,"noattachment":false,"key":"/@peculiar/x509/-/@peculiar/x509-2.2.0.tgz"},"main":"build/x509.cjs.js","_from":"file:release-package/peculiar-x509-2.2.0.tgz","types":"build/index.d.ts","unpkg":"build/x509.js","module":"build/x509.es.js","engines":{"node":">=20.0.0"},"scripts":{"fmt":"oxfmt","pub":"npm run pub:patch","lint":"oxlint","test":"vitest run","build":"npm run build:module","rebuild":"npm run clear && npm run build","coverage":"vitest run --coverage","git:push":"git push --follow-tags","lint:fix":"oxlint --fix","coveralls":"vitest run --coverage && cat coverage/lcov.info | coveralls","fmt:check":"oxfmt --check","pub:major":"npm version major && npm run git:push","pub:minor":"npm version minor && npm run git:push","pub:patch":"npm version patch && npm run git:push","test:watch":"vitest","build:module":"rollup -c"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"24944ca1-5050-4641-863e-4c37671a3ba7"}},"_resolved":"/home/runner/work/x509/x509/release-package/peculiar-x509-2.2.0.tgz","_integrity":"sha512-adpW58ySPQMOUPv8pTKT3RIyCFqfUFt8X05ukPdtkQToXDVr8dMtxuenik1yx8tNFTbpApWsM/Hi5SzlIx48+Q==","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":{},"_nodeVersion":"24.21.0","allowScripts":{"fsevents@2.3.3":true},"dependencies":{"tslib":"^2.8.1","tsyringe":"^4.10.0","pvtsutils":"^1.3.6","@peculiar/asn1-cms":"^2.11.0","@peculiar/asn1-csr":"^2.11.0","@peculiar/asn1-ecc":"^2.11.0","@peculiar/asn1-rsa":"^2.11.0","@peculiar/asn1-x509":"^2.11.0","@peculiar/asn1-pkcs9":"^2.11.0","@peculiar/asn1-schema":"^2.11.0","@peculiar/asn1-x509-post-quantum":"^2.11.0"},"_hasShrinkwrap":false,"devDependencies":{"oxfmt":"^0.73.0","oxlint":"^1.88.0","rimraf":"^6.1.3","rollup":"^4.64.6","vitest":"^5.0.4","typescript":"^6.0.3","@babel/core":"^7.29.7","@types/node":"^24.19.2","@babel/preset-env":"^7.29.7","rollup-plugin-dts":"^6.5.1","@abraham/reflection":"^0.13.0","@peculiar/webcrypto":"^1.7.1","@vitest/coverage-v8":"^5.0.4","@rollup/plugin-babel":"^7.1.0","@rollup/plugin-terser":"^1.0.0","@rollup/plugin-commonjs":"^29.0.3","rollup-plugin-typescript2":"^0.37.0","@rollup/plugin-node-resolve":"^16.0.3"},"_npmOperationalInternal":{"tmp":"tmp/x509_2.2.0_1792057209660_0.9029620826331426","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":1792057209797,"_cnpm_publish_time":1792057209797,"dist-tags":{"beta":"1.3.3-beta.0","latest":"3.1.0"}}