@blamejs/pki 0.1.24 → 0.1.25
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/CHANGELOG.md +15 -0
- package/README.md +3 -1
- package/index.js +12 -0
- package/lib/acme.js +1159 -0
- package/lib/constants.js +10 -0
- package/lib/framework-error.js +18 -0
- package/lib/jose.js +616 -0
- package/lib/oid.js +2 -1
- package/lib/schema-pkix.js +33 -0
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
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-
|
package/lib/schema-pkix.js
CHANGED
|
@@ -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
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:
|
|
5
|
+
"serialNumber": "urn:uuid:fa2f7437-a88e-47ad-959f-8d019edc06e0",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-07-
|
|
8
|
+
"timestamp": "2026-07-10T18:29:08.522Z",
|
|
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.
|
|
22
|
+
"bom-ref": "@blamejs/pki@0.1.25",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "pki",
|
|
25
|
-
"version": "0.1.
|
|
25
|
+
"version": "0.1.25",
|
|
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.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/pki@0.1.25",
|
|
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.
|
|
57
|
+
"ref": "@blamejs/pki@0.1.25",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|