@blamejs/pki 0.1.32 → 0.2.1
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 +38 -0
- package/README.md +3 -1
- package/index.js +13 -0
- package/lib/asn1-der.js +31 -22
- package/lib/constants.js +33 -0
- package/lib/ct.js +13 -12
- package/lib/est.js +10 -10
- package/lib/framework-error.js +13 -0
- package/lib/guard-all.js +15 -0
- package/lib/guard-crypto.js +31 -1
- package/lib/guard-encoding.js +90 -0
- package/lib/guard-identifier.js +56 -0
- package/lib/guard-json.js +149 -0
- package/lib/guard-limits.js +58 -8
- package/lib/guard-range.js +40 -7
- package/lib/guard-text.js +7 -0
- package/lib/jose.js +17 -128
- package/lib/merkle.js +7 -16
- package/lib/oid.js +33 -10
- package/lib/path-validate.js +173 -16
- package/lib/schema-attrcert.js +5 -0
- package/lib/schema-cms.js +22 -1
- package/lib/schema-crmf.js +3 -5
- package/lib/schema-ocsp.js +5 -1
- package/lib/schema-pkix.js +92 -12
- package/lib/shbs.js +348 -0
- package/lib/trust.js +707 -0
- package/lib/webcrypto.js +18 -7
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/lib/webcrypto.js
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
var nodeCrypto = require("node:crypto");
|
|
37
37
|
var frameworkError = require("./framework-error");
|
|
38
38
|
var guard = require("./guard-all");
|
|
39
|
+
var constants = require("./constants");
|
|
39
40
|
|
|
40
41
|
// Single-owner error class -- co-located with its module (framework-error
|
|
41
42
|
// stays the cross-module home; this is webcrypto-private). withCause: a
|
|
@@ -55,7 +56,13 @@ function _toArrayBuffer(buf) {
|
|
|
55
56
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
function
|
|
59
|
+
function _wcErr(code, msg) { return new WebCryptoError(code, msg); }
|
|
60
|
+
// STRICT base64url decode via the shared encoding guard: a missing / non-canonical
|
|
61
|
+
// / non-alphabet value throws webcrypto/data rather than silently importing WRONG
|
|
62
|
+
// key material (the lenient Buffer.from(String(undefined),"base64url") returned a
|
|
63
|
+
// bogus 6-byte key). Node's own canonical JWK export (_rawPublic) round-trips
|
|
64
|
+
// cleanly, so the strictness is benign there and fail-closed on untrusted import.
|
|
65
|
+
function _b64urlToBuf(s, who) { return guard.encoding.base64url(s, null, _wcErr, "webcrypto/data", who || "base64url value"); }
|
|
59
66
|
function _bufToB64url(buf) { return Buffer.from(buf).toString("base64url"); }
|
|
60
67
|
|
|
61
68
|
function _normalizeAlg(algorithm, who) {
|
|
@@ -548,11 +555,15 @@ SubtleCrypto.prototype.unwrapKey = async function unwrapKey(format, wrappedKey,
|
|
|
548
555
|
var keyData;
|
|
549
556
|
if (format === "jwk") {
|
|
550
557
|
// A NON-authenticating unwrap algorithm (AES-CBC / AES-CTR) decrypts
|
|
551
|
-
// tampered bytes "successfully", so this
|
|
552
|
-
//
|
|
553
|
-
//
|
|
554
|
-
|
|
555
|
-
|
|
558
|
+
// tampered bytes "successfully", so this parse is the first point that can
|
|
559
|
+
// notice. The shared JSON guard parses strictly (bounded, fatal UTF-8, and a
|
|
560
|
+
// smuggled duplicate member rejected rather than resolved last-wins), and its
|
|
561
|
+
// failure surfaces as the module's typed webcrypto/data (W3C: DataError).
|
|
562
|
+
keyData = guard.json.parse(bytes, WebCryptoError, {
|
|
563
|
+
maxBytes: constants.LIMITS.JSON_MAX_BYTES, maxDepth: constants.LIMITS.JSON_MAX_DEPTH,
|
|
564
|
+
badJson: "webcrypto/data", tooDeep: "webcrypto/data", duplicateMember: "webcrypto/data",
|
|
565
|
+
tooLarge: "webcrypto/data", badInput: "webcrypto/data", label: "the unwrapped JWK",
|
|
566
|
+
});
|
|
556
567
|
} else {
|
|
557
568
|
keyData = bytes;
|
|
558
569
|
}
|
|
@@ -592,7 +603,7 @@ SubtleCrypto.prototype.importKey = async function importKey(format, keyData, alg
|
|
|
592
603
|
if (format === "jwk") {
|
|
593
604
|
var jwk = keyData;
|
|
594
605
|
if (jwk.kty === "oct") {
|
|
595
|
-
var kbuf = _b64urlToBuf(jwk.k);
|
|
606
|
+
var kbuf = _b64urlToBuf(jwk.k, "JWK oct key material");
|
|
596
607
|
var s2 = nodeCrypto.createSecretKey(kbuf);
|
|
597
608
|
var a2 = (name === "HMAC") ? { name: name, hash: _hashObj(alg.hash), length: kbuf.length * 8 } : { name: name, length: kbuf.length * 8 };
|
|
598
609
|
return new CryptoKey("secret", extractable, a2, usages, s2);
|
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:1e68f63c-e550-4432-9b59-4cca3a0ddc64",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-07-
|
|
8
|
+
"timestamp": "2026-07-12T01:48:49.026Z",
|
|
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.2.1",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "pki",
|
|
25
|
-
"version": "0.1
|
|
25
|
+
"version": "0.2.1",
|
|
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.2.1",
|
|
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.2.1",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|