@blamejs/pki 0.6.9 → 0.6.10
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 +8 -0
- package/lib/est.js +15 -5
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ All notable changes to `@blamejs/pki` are documented here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this
|
|
5
5
|
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## v0.6.10 — 2026-08-31
|
|
8
|
+
|
|
9
|
+
pki.est computes a response body's length from a single read of res.body, shared by one helper across every verb, so a caller-supplied transport whose res.body getter changes between reads cannot desync the type check from the measured length.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- pki.est reads a response body's length from a single access of res.body rather than re-reading it across the null / string / BufferSource type-check arms. A caller-supplied transport whose res.body getter returns different values across reads could otherwise size the body from a different value than the one the type check classified. The five identical per-verb length computations are consolidated into one shared helper that reads res.body once.
|
|
14
|
+
|
|
7
15
|
## v0.6.9 — 2026-08-31
|
|
8
16
|
|
|
9
17
|
pki.cmp.verify holds a received PKIMessage to the RFC 9483 sec. 3.5 header rules, and pki.path.build and pki.est read a response body an injected transport returns as any BufferSource, not only a Node Buffer.
|
package/lib/est.js
CHANGED
|
@@ -196,6 +196,16 @@ function transferDecode(body) {
|
|
|
196
196
|
return der;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
// The byte length of a transport response body for the size-cap and empty-body checks: a null / absent body
|
|
200
|
+
// is 0, a string its UTF-8 byte length, and any BufferSource (a Buffer / Uint8Array / ArrayBuffer / DataView
|
|
201
|
+
// from an injected transport) its byte count through the byte guard -- never a String()-coerced comma list.
|
|
202
|
+
// res.body is read ONCE so a lying getter on an injected response cannot change it between the arms.
|
|
203
|
+
function _bodyLen(res) {
|
|
204
|
+
var body = res.body;
|
|
205
|
+
return body == null ? 0 : (typeof body === "string" ? Buffer.byteLength(body, "utf8")
|
|
206
|
+
: (Buffer.isBuffer(body) ? guard.bytes.lengthOf(body) : guard.bytes.lengthOf(guard.bytes.source(body, EstError, "est/bad-input", "the response body"))));
|
|
207
|
+
}
|
|
208
|
+
|
|
199
209
|
/**
|
|
200
210
|
* @primitive pki.est.transferEncode
|
|
201
211
|
* @signature pki.est.transferEncode(der) -> string
|
|
@@ -1152,7 +1162,7 @@ function _drive(method, url, body, headers, opts, transport, budgets) {
|
|
|
1152
1162
|
// Measure an injected string body as UTF-8 -- the byte width the body is decoded/transfer-decoded at,
|
|
1153
1163
|
// and what the real socket transport counts -- so a non-ASCII body (multi-byte chars are ~half the
|
|
1154
1164
|
// count under latin1) cannot undercount past the DoS cap and reach body handling.
|
|
1155
|
-
var blen =
|
|
1165
|
+
var blen = _bodyLen(res);
|
|
1156
1166
|
if (blen > budgets.maxResponseBytes) throw E("est/response-too-large", "the response body (" + blen + " bytes) exceeds the " + budgets.maxResponseBytes + "-byte cap (RFC 7030 sec. 6)");
|
|
1157
1167
|
// The transport contract returns lowercased headers, but the injectable seam only promises
|
|
1158
1168
|
// { status, headers, body }; normalize here so a redirect Location / WWW-Authenticate from an
|
|
@@ -1302,7 +1312,7 @@ function _certsResult(op, res, opts, csrSpki) {
|
|
|
1302
1312
|
if (verdict.status !== "ok") throw E("est/http-error", "an EST " + op + " response must be HTTP 200 or 202 (RFC 7030 sec. 4.1.3 / 4.2.3), got " + res.status);
|
|
1303
1313
|
// Measure the body as UTF-8 for parity with the transport cap above (this check only distinguishes empty
|
|
1304
1314
|
// from non-empty, where the encoding is immaterial, but the shape is kept uniform so no site undercounts).
|
|
1305
|
-
var bodyLen =
|
|
1315
|
+
var bodyLen = _bodyLen(res);
|
|
1306
1316
|
if (bodyLen === 0) throw E("est/empty-body", "a 200 " + op + " response carried an empty body (RFC 7030 sec. 4.1.3 / 4.2.3)");
|
|
1307
1317
|
var parsed = parseCertsOnly(transferDecode(res.body));
|
|
1308
1318
|
if (op === "cacerts") return { certificates: parsed.certificates, crls: parsed.crls };
|
|
@@ -1866,7 +1876,7 @@ function _fullcmcResult(res, opts, wanted, sent) {
|
|
|
1866
1876
|
"an EST /fullcmc response must be HTTP 200 or 202 (RFC 7030 sec. 4.3.2), got " + res.status);
|
|
1867
1877
|
}
|
|
1868
1878
|
|
|
1869
|
-
var bodyLen =
|
|
1879
|
+
var bodyLen = _bodyLen(res);
|
|
1870
1880
|
if (bodyLen === 0) throw E("est/empty-body", "a 200 /fullcmc response carried an empty body (RFC 7030 sec. 4.3.2)");
|
|
1871
1881
|
var der = transferDecode(res.body);
|
|
1872
1882
|
|
|
@@ -2265,7 +2275,7 @@ async function _serverkeygenResult(res, opts, derived) {
|
|
|
2265
2275
|
// A 202 is an enrollment posture (RFC 7030 sec. 4.4 treats /serverkeygen as an enroll): surfaced, never slept.
|
|
2266
2276
|
if (verdict.status === "retry") return { retry: true, retryAfterSeconds: verdict.retryAfterSeconds, retryAfterDate: verdict.retryAfterDate };
|
|
2267
2277
|
if (verdict.status !== "ok") throw E("est/http-error", "an EST serverkeygen response must be HTTP 200 or 202 (RFC 7030 sec. 4.4.2), got " + res.status);
|
|
2268
|
-
var bodyLen =
|
|
2278
|
+
var bodyLen = _bodyLen(res);
|
|
2269
2279
|
if (bodyLen === 0) throw E("est/empty-body", "a 200 serverkeygen response carried an empty body (RFC 7030 sec. 4.4.2)");
|
|
2270
2280
|
_assertConfidentialCipher(res);
|
|
2271
2281
|
// parseServerKeygenResponse does the per-part transfer-decode; the recipient coherence is bound to the CSR.
|
|
@@ -2367,7 +2377,7 @@ function _csrattrsResult(res, opts) {
|
|
|
2367
2377
|
// A 202 is nonconforming for a policy GET (sec. 4.5.2 lists only 200 / 204 / 404).
|
|
2368
2378
|
if (verdict.status === "retry") throw E("est/http-error", "a /csrattrs response must be HTTP 200, 204, or 404, not 202 (RFC 7030 sec. 4.5.2)");
|
|
2369
2379
|
if (verdict.status !== "ok") throw E("est/http-error", "an EST csrattrs response must be HTTP 200 / 204 / 404 (RFC 7030 sec. 4.5.2), got " + res.status);
|
|
2370
|
-
var bodyLen =
|
|
2380
|
+
var bodyLen = _bodyLen(res);
|
|
2371
2381
|
// An empty HTTP body is distinct from a valid EMPTY CsrAttrs (`30 00` / base64 `MAA=`), which parses as {items:[]}.
|
|
2372
2382
|
if (bodyLen === 0) throw E("est/empty-body", "a 200 csrattrs response carried an empty body (RFC 7030 sec. 4.5.2)");
|
|
2373
2383
|
var attrs = csrattrsFmt.parse(transferDecode(res.body));
|
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:bf09eeaa-91f9-4b51-807c-b6184d2dfdce",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-08-
|
|
8
|
+
"timestamp": "2026-08-31T16:54:53.965Z",
|
|
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.6.
|
|
22
|
+
"bom-ref": "@blamejs/pki@0.6.10",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "pki",
|
|
25
|
-
"version": "0.6.
|
|
25
|
+
"version": "0.6.10",
|
|
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.6.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/pki@0.6.10",
|
|
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.6.
|
|
57
|
+
"ref": "@blamejs/pki@0.6.10",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|