@blamejs/pki 0.5.17 → 0.5.19
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 +60 -0
- package/lib/acme.js +6 -4
- package/lib/cmp-build.js +15 -1
- package/lib/cms-encrypt.js +155 -14
- package/lib/cms-sign.js +15 -1
- package/lib/crl-sign.js +61 -2
- package/lib/guard-intrinsic.js +27 -0
- package/lib/jose.js +82 -35
- package/lib/key.js +6 -0
- package/lib/pkcs12-build.js +201 -11
- package/lib/tsp-sign.js +64 -0
- package/lib/webcrypto.js +165 -90
- package/lib/x509-sign.js +37 -0
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/lib/x509-sign.js
CHANGED
|
@@ -53,6 +53,27 @@ var OID_SKI = O("subjectKeyIdentifier");
|
|
|
53
53
|
|
|
54
54
|
// The recognized keys of the `extensions` spec object; an unknown key is a typo and throws at
|
|
55
55
|
// config-time (a custom extension is passed as pre-encoded DER via the array form).
|
|
56
|
+
// The three caller-owned objects pki.x509.sign reads, each with its own door. A key nothing here
|
|
57
|
+
// names is a typo or a misplaced argument, and the failure it causes is invisible: the certificate
|
|
58
|
+
// builds, signs, and simply does not carry what was asked for. `spec.extension` (one letter short
|
|
59
|
+
// of `extensions`) emitted a certificate with NO extensions at all -- no basicConstraints on an
|
|
60
|
+
// intended CA, no keyUsage on an intended constrained leaf. `spec.issuer` is the other shape: the
|
|
61
|
+
// issuer is argument TWO, and nesting it in the spec left the certificate SELF-SIGNED with nothing
|
|
62
|
+
// to read as a failure.
|
|
63
|
+
//
|
|
64
|
+
// Every table is derived from what the function actually reads, not from the doc block, because a
|
|
65
|
+
// table naming a key nothing reads reopens the hole it was added to close.
|
|
66
|
+
var KNOWN_SPEC_KEYS = {
|
|
67
|
+
subject: 1, subjectPublicKey: 1, notBefore: 1, notAfter: 1, serialNumber: 1, extensions: 1,
|
|
68
|
+
};
|
|
69
|
+
// The issuer names itself in one of two FORMS, and the cert form wins unconditionally: when
|
|
70
|
+
// `issuer.cert` is present the builder takes the DN and the public key from it and never reads
|
|
71
|
+
// `name` or `publicKey`. A union accepted `{ key, cert, name: "Different CA", publicKey }` and
|
|
72
|
+
// signed under the certificate's identity while discarding the identity the caller wrote out.
|
|
73
|
+
var KNOWN_ISSUER_CERT_KEYS = { key: 1, cert: 1 };
|
|
74
|
+
var KNOWN_ISSUER_EXPLICIT_KEYS = { key: 1, name: 1, publicKey: 1 };
|
|
75
|
+
var KNOWN_SIGN_OPTS = { digestAlgorithm: 1, pem: 1, pss: 1 };
|
|
76
|
+
|
|
56
77
|
var KNOWN_EXT_KEYS = {
|
|
57
78
|
subjectKeyIdentifier: 1, authorityKeyIdentifier: 1, keyUsage: 1, keyUsageCritical: 1,
|
|
58
79
|
extendedKeyUsage: 1, extendedKeyUsageCritical: 1, basicConstraints: 1, subjectAltName: 1,
|
|
@@ -282,6 +303,22 @@ function _sign(spec, issuer, opts) {
|
|
|
282
303
|
opts = opts || {};
|
|
283
304
|
if (!spec || typeof spec !== "object" || Buffer.isBuffer(spec)) throw _err("x509/bad-input", "the certificate spec must be an object");
|
|
284
305
|
issuer = issuer || {};
|
|
306
|
+
// Before a single field is read, so a misspelling is a refusal rather than an omission carried
|
|
307
|
+
// into a signed certificate. The issuer message names its own argument because the mistake this
|
|
308
|
+
// catches most often is putting the issuer inside the spec, where it self-signed in silence.
|
|
309
|
+
guard.identifier.assertKnownKeys(spec, KNOWN_SPEC_KEYS, _err, "x509/bad-input", function (k) {
|
|
310
|
+
return "unknown certificate spec field " + JSON.stringify(k) +
|
|
311
|
+
(k === "issuer" ? "; the issuer is the SECOND argument to pki.x509.sign, not a spec field" : "") +
|
|
312
|
+
(k === "extension" ? "; the extensions spec field is `extensions`" : "");
|
|
313
|
+
});
|
|
314
|
+
var byCert = issuer.cert != null;
|
|
315
|
+
guard.identifier.assertKnownKeys(issuer, byCert ? KNOWN_ISSUER_CERT_KEYS : KNOWN_ISSUER_EXPLICIT_KEYS,
|
|
316
|
+
_err, "x509/bad-input", function (k) {
|
|
317
|
+
return "unknown issuer field " + JSON.stringify(k) + " for the " + (byCert
|
|
318
|
+
? "certificate form; issuer.cert supplies the name and the public key, so they are not read here"
|
|
319
|
+
: "explicit form; the issuer takes { key, name, publicKey }, or { key, cert } to take both from a certificate");
|
|
320
|
+
});
|
|
321
|
+
guard.identifier.assertKnownKeys(opts, KNOWN_SIGN_OPTS, _err, "x509/bad-input", "pki.x509.sign has an unknown option ");
|
|
285
322
|
if (issuer.key == null) throw _err("x509/bad-input", "a signing key (issuer.key, a PKCS#8 private key) is required");
|
|
286
323
|
|
|
287
324
|
var spki = _reqDer(spec.subjectPublicKey, "spec.subjectPublicKey (the SPKI DER of the certified key)");
|
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:d0064cbc-a37c-4d4f-ae67-0b9ba6887de2",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-08-
|
|
8
|
+
"timestamp": "2026-08-20T21:35:06.293Z",
|
|
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.5.
|
|
22
|
+
"bom-ref": "@blamejs/pki@0.5.19",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "pki",
|
|
25
|
-
"version": "0.5.
|
|
25
|
+
"version": "0.5.19",
|
|
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.5.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/pki@0.5.19",
|
|
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.5.
|
|
57
|
+
"ref": "@blamejs/pki@0.5.19",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|