@blamejs/pki 0.1.24 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/oid.js CHANGED
@@ -74,7 +74,8 @@ var FAMILIES = {
74
74
  // RFC 5755 attribute-certificate id-pe extensions: ac-auditIdentity sec. 4.3.1,
75
75
  // aaControls sec. 7.4, ac-proxying sec. 7.2).
76
76
  pkixAccess: { base: [1, 3, 6, 1, 5, 5, 7, 1], of: {
77
- authorityInfoAccess: 1, acAuditIdentity: 4, aaControls: 6, acProxying: 10 } },
77
+ authorityInfoAccess: 1, acAuditIdentity: 4, aaControls: 6, acProxying: 10,
78
+ acmeIdentifier: 31 } },
78
79
 
79
80
  // id-aca -- RFC 5755 attribute-certificate attribute types on the id-pkix 10 arc:
80
81
  // authenticationInfo sec. 4.4.1 .. group sec. 4.4.4, plus encAttrs sec. 7.1 (the encrypted-
@@ -56,6 +56,38 @@ function pemDecode(text, label, PemError) {
56
56
  return der;
57
57
  }
58
58
 
59
+ // pemDecodeAll(text, label, PemError): decode EVERY PEM block under the STRICT
60
+ // RFC 7468 profile for application/pem-certificate-chain (RFC 8555 sec. 9.1) --
61
+ // each block must carry `label` (default CERTIFICATE), explanatory text MUST NOT
62
+ // appear before/between/after blocks (errata 5983: certchain = stricttextualmsg
63
+ // *(eol stricttextualmsg)), and at least one block is required. Every block's
64
+ // base64 body is canonical (the pemDecode rule); returns an array of DER buffers.
65
+ function pemDecodeAll(text, label, PemError) {
66
+ label = label || "CERTIFICATE";
67
+ if (Buffer.isBuffer(text)) {
68
+ if (text.length > constants.LIMITS.PEM_MAX_BYTES) throw new PemError("pem/too-large", "PEM input exceeds size cap");
69
+ text = text.toString("latin1");
70
+ }
71
+ if (typeof text !== "string") throw new PemError("pem/bad-input", "pemDecodeAll expects a string or Buffer");
72
+ if (text.length > constants.LIMITS.PEM_MAX_BYTES) throw new PemError("pem/too-large", "PEM input exceeds size cap");
73
+ var re = /-----BEGIN ([A-Z0-9 ]+)-----([\s\S]*?)-----END \1-----/g;
74
+ var blocks = [];
75
+ var lastEnd = 0, m;
76
+ while ((m = re.exec(text)) !== null) {
77
+ if (/\S/.test(text.slice(lastEnd, m.index))) throw new PemError("pem/explanatory-text", "explanatory text is not permitted around PEM blocks (RFC 8555 sec. 9.1)");
78
+ if (m[1] !== label) throw new PemError("pem/label-mismatch", "expected " + JSON.stringify(label) + " block, got " + JSON.stringify(m[1]));
79
+ var b64 = m[2].replace(/[\r\n\t ]+/g, "");
80
+ if (!/^[A-Za-z0-9+/]*={0,2}$/.test(b64) || b64.length % 4 !== 0) throw new PemError("pem/bad-base64", "PEM body is not canonical base64 (RFC 4648 sec. 3.5)");
81
+ var der = Buffer.from(b64, "base64");
82
+ if (der.toString("base64") !== b64) throw new PemError("pem/bad-base64", "PEM base64 body is not canonical (RFC 4648 sec. 3.5)");
83
+ blocks.push(der);
84
+ lastEnd = re.lastIndex;
85
+ }
86
+ if (blocks.length === 0) throw new PemError("pem/no-block", "no PEM block found");
87
+ if (/\S/.test(text.slice(lastEnd))) throw new PemError("pem/explanatory-text", "explanatory text is not permitted after the PEM chain (RFC 8555 sec. 9.1)");
88
+ return blocks;
89
+ }
90
+
59
91
  // The label must be re-readable by this module's own PEM_RE (uppercase
60
92
  // alphanumeric words separated by single spaces, a subset of the RFC 7468
61
93
  // sec. 3 label grammar). Anything else (lowercase, a leading/trailing space,
@@ -1022,6 +1054,7 @@ function signedEnvelope(ns, tbsSchema, opts) {
1022
1054
 
1023
1055
  module.exports = {
1024
1056
  pemDecode: pemDecode,
1057
+ pemDecodeAll: pemDecodeAll,
1025
1058
  pemEncode: pemEncode,
1026
1059
  coerceToDer: coerceToDer,
1027
1060
  decodeRoot: decodeRoot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/pki",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "Pure-JavaScript PKI toolkit that owns its stack — X.509, ASN.1/DER, CMS, PQC-first.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "blamejs contributors",
@@ -65,10 +65,12 @@
65
65
  "lint": "eslint --max-warnings 0 .",
66
66
  "fuzz": "npm ci --prefix fuzz && npx --prefix fuzz jazzer fuzz/asn1-der.fuzz.js -- -max_total_time=60",
67
67
  "gates": "node test/layer-0-primitives/codebase-patterns.test.js && node scripts/validate-source-comment-blocks.js && node scripts/check-api-snapshot.js",
68
+ "coverage": "c8 --include=lib/** --include=index.js --reporter=text-summary --reporter=lcov node test/smoke.js",
68
69
  "prepack": "node scripts/check-pack-against-gitignore.js",
69
70
  "check:vendor-currency": "node scripts/check-vendor-currency.js"
70
71
  },
71
72
  "devDependencies": {
73
+ "c8": "11.0.0",
72
74
  "esbuild": "0.28.1",
73
75
  "eslint": "10.3.0"
74
76
  }
package/sbom.cdx.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
3
3
  "bomFormat": "CycloneDX",
4
4
  "specVersion": "1.5",
5
- "serialNumber": "urn:uuid:dfb00f98-2ca7-4fd1-b0e7-90fccf92604a",
5
+ "serialNumber": "urn:uuid:51669f50-bf8f-4b65-8c89-e8fd503b0399",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-07-10T12:57:51.582Z",
8
+ "timestamp": "2026-07-10T23:32:35.928Z",
9
9
  "lifecycles": [
10
10
  {
11
11
  "phase": "build"
@@ -19,14 +19,14 @@
19
19
  }
20
20
  ],
21
21
  "component": {
22
- "bom-ref": "@blamejs/pki@0.1.24",
22
+ "bom-ref": "@blamejs/pki@0.1.26",
23
23
  "type": "application",
24
24
  "name": "pki",
25
- "version": "0.1.24",
25
+ "version": "0.1.26",
26
26
  "scope": "required",
27
27
  "author": "blamejs contributors",
28
28
  "description": "Pure-JavaScript PKI toolkit that owns its stack — X.509, ASN.1/DER, CMS, PQC-first.",
29
- "purl": "pkg:npm/%40blamejs/pki@0.1.24",
29
+ "purl": "pkg:npm/%40blamejs/pki@0.1.26",
30
30
  "properties": [],
31
31
  "externalReferences": [
32
32
  {
@@ -54,7 +54,7 @@
54
54
  "components": [],
55
55
  "dependencies": [
56
56
  {
57
- "ref": "@blamejs/pki@0.1.24",
57
+ "ref": "@blamejs/pki@0.1.26",
58
58
  "dependsOn": []
59
59
  }
60
60
  ]