@blamejs/pki 0.6.26 → 0.6.27

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 CHANGED
@@ -4,6 +4,16 @@ 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.27 — 2026-09-02
8
+
9
+ The SCEP client can reach a CA through a forward proxy, with Basic authentication over an https proxy.
10
+
11
+ ### Added
12
+
13
+ - pki.transport gains forward-proxy support: request.proxy = { url, auth?, tls? } opens a CONNECT tunnel to the proxy and negotiates the origin's TLS inside the tunnel under the same trust anchors and rejectUnauthorized as a direct connection, so the proxy relays the encrypted origin session without being able to read it and cannot substitute the origin certificate.
14
+ - Basic proxy authentication (RFC 7617) is sent only over an https:// proxy, whose certificate is verified against proxy.tls (its own trust anchors, separate from the origin's), so credentials ride the authenticated TLS-to-proxy channel. A plaintext http:// proxy is tunnel-only; supplying auth for one is refused with transport/proxy-auth-requires-tls rather than exposing the credentials to the proxy hop. A proxy certificate that does not verify is transport/proxy-tls-failed.
15
+ - pki.scep threads opts.proxy through every network verb (getCACaps, getCACert, getNextCACert, enroll, renew, getCert, getCrl). A malformed proxy option (scep/bad-proxy), a non-2xx CONNECT (scep/proxy-connect-failed), a 407 with no or rejected credentials (scep/proxy-auth-required, scep/proxy-auth-failed), and a plaintext-http origin (scep/insecure-url) each fail closed. Digest proxy authentication is not included in this release.
16
+
7
17
  ## v0.6.26 — 2026-09-02
8
18
 
9
19
  pki.path.build can prefer the certification path whose policies satisfy a caller-supplied policy set.
package/README.md CHANGED
@@ -222,8 +222,8 @@ comment blocks, is at [pkijs.com](https://pkijs.com).
222
222
  | `pki.schema.cmp` | CMP messages (RFC 9810): the header (version, sender and recipient including the anonymous NULL-DN, nonces, transaction id, general info), the 27-arm body (certificate requests via the CRMF parser, an encrypted certificate's EnvelopedData via CMS, response / revocation / confirmation / error / support / polling arms structural, the rest raw), and the exact `headerBytes` and `bodyBytes` slices an external verifier reconstructs the protected part from. The CMP-before-OCSP dispatch order is enforced Fail-closed — `parse`, `pemDecode`, `pemEncode` |
223
223
  | `pki.schema.csrattrs` | EST CSR Attributes (`CsrAttrs`, RFC 8951 §3.5 / RFC 9908) — the `AttrOrOID` items a server sends to shape an enrollment: bare OIDs, attributes with raw values, and decoded views of the RFC 9908 meaningful types (extension requests, EC and RSA key-type conventions, the certification-request-info template). Unknown types are surfaced raw; structure and the RFC 9908 semantic MUSTs are fail-closed — `parse` |
224
224
  | `pki.est` | Enrollment over Secure Transport (RFC 7030 / 8951 / 9908 / 7616). The client verbs `cacerts`, `simpleenroll`, `simplereenroll`, `serverkeygen`, `csrattrs`, and `fullcmc` drive the RFC 7030 flow over `pki.transport` (inject your own via `opts.transport`, or take the fail-closed default): HTTPS only, an explicit trust anchor required, same-origin redirects followed while a downgrade or loop is refused, a 202 Retry-After surfaced but never slept, HTTP Basic or Digest (RFC 7616, SHA-256 / SHA-512-256; MD5 and no-qop refused by default) answered only after the server is authenticated, and the issued certificate chosen by public-key match. `serverkeygen` requests a server-generated key, cleartext or an opaque CMS EnvelopedData, with encryption bound to the CSR's key-identifier attribute over a confidentiality-bearing cipher. `csrattrs` fetches the CA's RFC 9908 attributes policy. `fullcmc` (§4.3) carries a CMC Full PKI Request and reduces the CA's answer through `pki.cmc.verify` to one terminal outcome, refusing a response that fails to echo the transaction and nonce the request carried, or that covers a key the request never asked for; a certs-only reply to a bound request is refused rather than read as an issuance. Under the verbs sit the transport-agnostic codecs they compose: the RFC 8951 base64 transfer codec (which ignores Content-Transfer-Encoding), the `multipart/mixed` splitter, the certs-only and serverkeygen response validators over CMS, the enroll-attribute builders, and the HTTP response classifier — `transferDecode`/`transferEncode`, `parseCertsOnly`, `splitMultipartMixed`, `parseServerKeygenResponse`, `findIssuedCert`, `classifyResponse`, `paths`, and the builders |
225
- | `pki.scep` | SCEP pkiMessage codec (RFC 8894), the client side of Simple Certificate Enrollment. `build(spec)` assembles a request: a `PKCSReq` or `RenewalReq` wraps a PKCS#10 certification request, whose own proof-of-possession it verifies first; a `CertPoll` wraps an IssuerAndSubject naming the issuing CA and the request subject; and a `GetCert` or `GetCRL` wraps an IssuerAndSerialNumber naming a certificate by its issuer and a positive serial of at most 20 octets. It encrypts the messageData to the CA as the inner EnvelopedData (`pkcsPKIEnvelope`, AES-128-CBC), and signs that under the transaction attributes RFC 8894 §3.2 defines, a messageType, a caller-unique transactionId, and a 16-byte senderNonce. The recipient CA certificate must assert `keyEncipherment`. `build` also issues the CA-side `CertRep` response (§3.3.2): a SUCCESS envelopes a certs-only SignedData of the issued certificate (or the CRL for a GetCRL) to the requester and signs it under the CA key, while a FAILURE (carrying a `failInfo`) or a PENDING omits the pkcsPKIEnvelope and is signed detached, each echoing the request's senderNonce as `recipientNonce`. `parse(bytes, opts?)` reads a `PKCSReq`, `RenewalReq`, `CertPoll`, `GetCert`, `GetCRL`, or `CertRep` back (a messageType outside the RFC 8894 registry is refused): it verifies the outer signature first and refuses a message whose signature does not check, so the transaction attributes it returns come only from a verified signer, never alongside a false verdict. Because a valid signature only proves self-consistency with the embedded certificate, pass `opts.signerCert` to authenticate a CA response against the CA certificate you hold (a public-key mismatch is refused, `signerAuthenticated` reports the result); a caller that omits it gets a crypto-only verdict and must authenticate the surfaced `signerCert` itself. It maps the messageType, pkiStatus, failInfo, and the nonces from their RFC 8894 enumerants and refuses an unknown one; given `recipientKey` it decrypts the `pkcsPKIEnvelope` to the messageData, and given `expectedSenderNonce` it refuses a response whose recipientNonce does not echo it. It reads a CA's CertRep in full. `getCACaps(baseUrl, opts?)`, `getCACert(baseUrl, opts?)`, `getNextCACert(baseUrl, opts)`, `enroll(baseUrl, opts)`, `renew(baseUrl, opts)`, `getCert(baseUrl, opts)`, and `getCrl(baseUrl, opts)` carry that codec to a live CA over HTTP (RFC 8894 §4) through an injectable transport (`pki.transport.https` by default): `getCACaps` reports the CA's advertised capabilities and never lowers the client's algorithm choice on the unauthenticated response, `getCACert` pins the CA certificate to an out-of-band `expectedFingerprint` a returned certificate must match, `getNextCACert` fetches the CA's next (rollover) certificate and verifies the SignedData response against the current CA certificate (`caCertificate`) before returning it, refusing a response signed by any other key, and `enroll` and `renew` POST a PKCSReq or RenewalReq, authenticate the CertRep against the CA certificate and its nonce echo, select the issued certificate by public-key match, throw on a FAILURE with the CA's failInfo, and poll a PENDING response with CertPoll requests until the CA answers or a bounded poll-count and total-wait budget is spent. `getCert` and `getCrl` retrieve an already-issued certificate or a CA CRL by issuer and serial number, authenticated the same way; RFC 8894 §2.6, §2.7, and §3.3.4 recommend these queries only where HTTP certificate-store access (RFC 4387), LDAP, or a CRL distribution point is unavailable, so prefer those where a CA offers them. A PKIOperation goes over HTTP POST by default; `httpMethod: "GET"` carries it base64-encoded in the URL query for a legacy CA that accepts only GET (RFC 8894 §4.1). HTTP proxy authentication is not yet built — `build`, `parse`, `parseCapabilities`, `getCACaps`, `getCACert`, `getNextCACert`, `enroll`, `renew`, `getCert`, `getCrl` |
226
- | `pki.transport` | The shared, fail-closed `node:https` transport the enrollment clients drive. `pki.transport.https(defaults)` returns a `transport(request) → { status, headers, body, tls }`, where `tls` carries the negotiated `protocol`, `cipher`, and raw `peerCertificate`. This is the toolkit's only socket choke point: an explicit trust anchor (or an opt-in to the system store) is required, `rejectUnauthorized` is always on, TLS is floored at 1.2, the response body is capped while it streams, and a stalled socket times out. The EST, ACME, and CMP clients reuse it verbatim. If you inject your own transport, return `tls` too: `pki.est.serverkeygen` asserts the negotiated cipher can protect the delivered private key, and a transport that reports no cipher is trusted rather than refused, so omitting the field silently skips that check — `https` |
225
+ | `pki.scep` | SCEP pkiMessage codec (RFC 8894), the client side of Simple Certificate Enrollment. `build(spec)` assembles a request: a `PKCSReq` or `RenewalReq` wraps a PKCS#10 certification request, whose own proof-of-possession it verifies first; a `CertPoll` wraps an IssuerAndSubject naming the issuing CA and the request subject; and a `GetCert` or `GetCRL` wraps an IssuerAndSerialNumber naming a certificate by its issuer and a positive serial of at most 20 octets. It encrypts the messageData to the CA as the inner EnvelopedData (`pkcsPKIEnvelope`, AES-128-CBC), and signs that under the transaction attributes RFC 8894 §3.2 defines, a messageType, a caller-unique transactionId, and a 16-byte senderNonce. The recipient CA certificate must assert `keyEncipherment`. `build` also issues the CA-side `CertRep` response (§3.3.2): a SUCCESS envelopes a certs-only SignedData of the issued certificate (or the CRL for a GetCRL) to the requester and signs it under the CA key, while a FAILURE (carrying a `failInfo`) or a PENDING omits the pkcsPKIEnvelope and is signed detached, each echoing the request's senderNonce as `recipientNonce`. `parse(bytes, opts?)` reads a `PKCSReq`, `RenewalReq`, `CertPoll`, `GetCert`, `GetCRL`, or `CertRep` back (a messageType outside the RFC 8894 registry is refused): it verifies the outer signature first and refuses a message whose signature does not check, so the transaction attributes it returns come only from a verified signer, never alongside a false verdict. Because a valid signature only proves self-consistency with the embedded certificate, pass `opts.signerCert` to authenticate a CA response against the CA certificate you hold (a public-key mismatch is refused, `signerAuthenticated` reports the result); a caller that omits it gets a crypto-only verdict and must authenticate the surfaced `signerCert` itself. It maps the messageType, pkiStatus, failInfo, and the nonces from their RFC 8894 enumerants and refuses an unknown one; given `recipientKey` it decrypts the `pkcsPKIEnvelope` to the messageData, and given `expectedSenderNonce` it refuses a response whose recipientNonce does not echo it. It reads a CA's CertRep in full. `getCACaps(baseUrl, opts?)`, `getCACert(baseUrl, opts?)`, `getNextCACert(baseUrl, opts)`, `enroll(baseUrl, opts)`, `renew(baseUrl, opts)`, `getCert(baseUrl, opts)`, and `getCrl(baseUrl, opts)` carry that codec to a live CA over HTTP (RFC 8894 §4) through an injectable transport (`pki.transport.https` by default): `getCACaps` reports the CA's advertised capabilities and never lowers the client's algorithm choice on the unauthenticated response, `getCACert` pins the CA certificate to an out-of-band `expectedFingerprint` a returned certificate must match, `getNextCACert` fetches the CA's next (rollover) certificate and verifies the SignedData response against the current CA certificate (`caCertificate`) before returning it, refusing a response signed by any other key, and `enroll` and `renew` POST a PKCSReq or RenewalReq, authenticate the CertRep against the CA certificate and its nonce echo, select the issued certificate by public-key match, throw on a FAILURE with the CA's failInfo, and poll a PENDING response with CertPoll requests until the CA answers or a bounded poll-count and total-wait budget is spent. `getCert` and `getCrl` retrieve an already-issued certificate or a CA CRL by issuer and serial number, authenticated the same way; RFC 8894 §2.6, §2.7, and §3.3.4 recommend these queries only where HTTP certificate-store access (RFC 4387), LDAP, or a CRL distribution point is unavailable, so prefer those where a CA offers them. A PKIOperation goes over HTTP POST by default; `httpMethod: "GET"` carries it base64-encoded in the URL query for a legacy CA that accepts only GET (RFC 8894 §4.1). Every verb reaches an https CA through a forward proxy with `opts.proxy = { url, auth?, tls? }`: a `CONNECT` tunnel is opened to the proxy and the origin TLS is negotiated inside it, so the proxy carries the enrollment without being able to read it or substitute the origin certificate. Basic proxy authentication (RFC 7617) is sent only over an `https://` proxy, where it rides the authenticated TLS-to-proxy channel; an `http://` proxy is tunnel-only, and credentials over a plaintext proxy are refused rather than exposed (see `pki.transport`) — `build`, `parse`, `parseCapabilities`, `getCACaps`, `getCACert`, `getNextCACert`, `enroll`, `renew`, `getCert`, `getCrl` |
226
+ | `pki.transport` | The shared, fail-closed `node:https` transport the enrollment clients drive. `pki.transport.https(defaults)` returns a `transport(request) → { status, headers, body, tls }`, where `tls` carries the negotiated `protocol`, `cipher`, and raw `peerCertificate`. This is the toolkit's only socket choke point: an explicit trust anchor (or an opt-in to the system store) is required, `rejectUnauthorized` is always on, TLS is floored at 1.2, the response body is capped while it streams, and a stalled socket times out. The EST, ACME, and CMP clients reuse it verbatim. A `request.proxy = { url, auth?, tls? }` reaches the origin through a forward proxy: a `CONNECT` tunnel is opened to the proxy and the origin TLS is negotiated inside it under the identical origin trust policy, so the proxy cannot read the origin's encrypted session or substitute an authenticated origin certificate. Basic proxy credentials are sent only over an `https://` proxy, whose own certificate is verified against `proxy.tls`, so they ride an authenticated channel; a plaintext `http://` proxy is tunnel-only and carrying `auth` on one is refused (`proxy-auth-requires-tls`) rather than exposing the credentials to the proxy hop. A malformed option, a failed CONNECT, an unverified proxy certificate, or an unaccepted credential fails closed. `pki.scep` threads it through as `opts.proxy`. If you inject your own transport, return `tls` too: `pki.est.serverkeygen` asserts the negotiated cipher can protect the delivered private key, and a transport that reports no cipher is trusted rather than refused, so omitting the field silently skips that check — `https` |
227
227
  | `pki.jose` | Flattened JWS (RFC 7515) and JWK thumbprints (RFC 7638). `sign` and `verify` run a Flattened JWS against declarative profiles (ACME outer, EAB inner, keyChange inner) that carry the required and forbidden header rules as data. `base64url` is the strict RFC 4648 §5 codec, rejecting padding, non-alphabet characters, and non-canonical trailing bits. `parseJson` is a bounded reader that refuses duplicate members at any depth. `thumbprint` is the RFC 7638 / 8037 / 9964 canonical digest. The algorithm registry binds each `alg` to its key type (ES/RS/PS/EdDSA/ML-DSA), leaving no code path for `alg:none`, an RS256→HS256 key confusion, or an all-zero ECDSA signature; `assertPublicJwk` refuses a JWK carrying private material, so an exported private key is never published. `opts.key` names the key a message must be signed under and governs: where the profile also permits an embedded header `jwk`, the two must be the same key — compared as RFC 7638 thumbprints, so member order cannot make equal keys differ — and a disagreement is refused rather than resolved in the message's favor. `keySource` reports which key answered, since a signature checked against a key you named is a different claim from one checked against the key the message carried — `sign`, `verify`, `base64url`, `parseJson`, `thumbprint`, `assertPublicJwk` |
228
228
  | `pki.acme` | ACME (RFC 8555 / 8737 / 8738 / 9773). `client(directoryUrl, opts)` is a stateful client driving a live CA directory over `pki.transport`: `newAccount`, `newOrder`, `newAuthz`, `getOrder`, `getAuthorization`, `getChallenge`, `respondToChallenge`, `finalize`, `pollOrder`, `pollAuthorization`, and `downloadCertificate` walk the issuance flow, with `newAuthz` pre-authorizing a single identifier (§7.4.1) and `downloadCertificate` binding the issued certificate to the order — its key, its identifiers, or both; at least one is required by default and the result reports `boundToKey` / `boundToIdentifiers` — before choosing among alternate chains (`Link rel="alternate"`, §7.4.2, via a `selectChain` predicate bounded by `maxAlternates`). `revokeCert` (account-key or certificate-key signed), `keyChange`, `updateAccount` (change the account contacts, §7.3.2), `listOrders` (the account's orders list, following the §7.1.2.1 `Link rel="next"` pagination bounded by a page cap and confined to the orders origin), `deactivateAccount`, `deactivateAuthorization`, `renewalInfo` (ARI), `renewalWindow` (the RFC 9773 §4.2/4.3 renewal decision), and `scheduleRenewal` (the §4.1 auto-sleeping renewal loop that sleeps until the selected instant and refetches until it is time to renew, stopping at the certificate's notAfter) complete the lifecycle. Every URL is HTTPS only, an explicit trust anchor is required, each request carries a fresh single-use nonce with a bounded badNonce retry (and, when `opts.resignKeys` supplies caller-approved alternative account-key algorithms, a bounded RFC 8555 §6.2 badSignatureAlgorithm re-sign that the CA's advertised list can only filter, never widen, so it cannot force a weaker algorithm), reads are POST-as-GET, polling is bounded and sleeps on a Retry-After via an injectable sleeper capped by a poll count and a total-wait budget, and every response body is size-capped. The transport is injectable via `opts.transport`. Over the message layer it composes resource-object validators (closed status enums, conditional-required fields, unknown fields ignored), the three §7.1.6 state machines, the request builders (newAccount with External Account Binding, newOrder with `replaces`, finalize with a CSR identifier-set match and account-key-reuse rejection, challenge responses, deactivation, revokeCert in both key modes, the keyChange nested JWS, POST-as-GET), the http-01 / dns-01 / tls-alpn-01 challenge computations, the dns and ip identifier validators, and the ARI certID with serial sign-padding preserved — `client`, `validate`, `identify`, `assertTransition`, the builders, `keyAuthorization`, `http01`, `dns01`, `tlsAlpn01Extension`, `verifyTlsAlpn01`, `ariCertId` |
229
229
  | `pki.schema.smime` | S/MIME ESS signed-attribute values (RFC 5035 / RFC 8551). `parseSigningCertificate` and `parseSigningCertificateV2` bind a signature to its signing certificate (cert hash, hash algorithm, issuer `GeneralNames` and serial); `parseSmimeCapabilities` decodes the ordered capability list; `decodeAttribute` dispatches a CMS attribute by OID, enforcing the single-value rule and deferring on unknown types. A companion decoder for CMS signed attributes rather than an auto-routed format — `parseSigningCertificate`, `parseSigningCertificateV2`, `parseSmimeCapabilities`, `decodeAttribute` |
@@ -44,6 +44,7 @@
44
44
  */
45
45
 
46
46
  var nodeHttps = require("node:https");
47
+ var nodeHttp = require("node:http");
47
48
  var nodeNet = require("node:net");
48
49
  var nodeTls = require("node:tls");
49
50
  var nodeDns = require("node:dns");
@@ -191,6 +192,81 @@ function _classifyError(e, C) {
191
192
  return C("transport-error");
192
193
  }
193
194
 
195
+ function _keySet(names) { var m = Object.create(null); for (var i = 0; i < names.length; i++) m[names[i]] = true; return m; }
196
+ var PROXY_KEYS = _keySet(["url", "auth", "tls"]);
197
+ var PROXY_AUTH_KEYS = _keySet(["scheme", "username", "password"]);
198
+ var PROXY_TLS_KEYS = _keySet(["anchors", "useSystemStore", "servername", "minVersion"]);
199
+
200
+ function _validateProxy(request, defaults, E, C, url) {
201
+ var proxy = request.proxy !== undefined ? request.proxy : defaults.proxy;
202
+ if (proxy === undefined || proxy === null) return null;
203
+ guard.identifier.assertPlainRecord(proxy, E, C("bad-proxy"), "opts.proxy");
204
+ guard.identifier.assertKnownKeys(proxy, PROXY_KEYS, E, C("bad-proxy"), "opts.proxy has an unknown option ");
205
+ var purl;
206
+ try { purl = new URL(String(proxy.url)); }
207
+ catch (e) { throw E(C("bad-proxy"), "opts.proxy.url did not parse: " + guard.text.showValue(proxy.url), e); }
208
+ if (purl.protocol !== "http:" && purl.protocol !== "https:") throw E(C("bad-proxy"), "opts.proxy.url must be an http or https URL, got " + purl.protocol);
209
+ if (purl.username || purl.password) throw E(C("bad-proxy"), "opts.proxy.url must not carry credentials in its userinfo; supply opts.proxy.auth over an https proxy");
210
+ var secure = purl.protocol === "https:";
211
+ if (!secure && proxy.tls !== undefined && proxy.tls !== null) throw E(C("bad-proxy"), "opts.proxy.tls applies only to an https proxy; an http proxy connection is plaintext (a supplied tls policy would be silently ignored)");
212
+
213
+ var auth = null;
214
+ if (proxy.auth !== undefined && proxy.auth !== null) {
215
+ if (!secure) throw E(C("proxy-auth-requires-tls"), "proxy credentials cannot be sent over a plaintext http proxy, where the proxy hop would expose them; use an https proxy URL");
216
+ guard.identifier.assertPlainRecord(proxy.auth, E, C("bad-proxy"), "opts.proxy.auth");
217
+ guard.identifier.assertKnownKeys(proxy.auth, PROXY_AUTH_KEYS, E, C("bad-proxy"), "opts.proxy.auth has an unknown option ");
218
+ var scheme = proxy.auth.scheme;
219
+ if (scheme === "digest") throw E(C("proxy-unsupported-scheme"), "Digest proxy authentication is not supported in this release; use 'basic' over an https proxy");
220
+ if (scheme !== "basic") throw E(C("bad-proxy"), "opts.proxy.auth.scheme must be 'basic', got " + guard.text.showValue(scheme));
221
+ if (typeof proxy.auth.username !== "string" || typeof proxy.auth.password !== "string") throw E(C("bad-proxy"), "opts.proxy.auth requires a string username and password");
222
+ if (proxy.auth.username.indexOf(":") !== -1) throw E(C("bad-proxy"), "a Basic proxy user-id must not contain a colon (RFC 7617 sec. 2)");
223
+ auth = { scheme: "basic", username: proxy.auth.username, password: proxy.auth.password };
224
+ }
225
+
226
+ var proxyTls = null;
227
+ if (secure) {
228
+ var ptls = proxy.tls;
229
+ if (ptls !== undefined && ptls !== null) {
230
+ guard.identifier.assertPlainRecord(ptls, E, C("bad-proxy"), "opts.proxy.tls");
231
+ guard.identifier.assertKnownKeys(ptls, PROXY_TLS_KEYS, E, C("bad-proxy"), "opts.proxy.tls has an unknown option ");
232
+ if (ptls.servername !== undefined && ptls.servername !== null && typeof ptls.servername !== "string") throw E(C("bad-proxy"), "opts.proxy.tls.servername must be a string");
233
+ }
234
+ var pAnchors = ptls ? ptls.anchors : undefined;
235
+ var pUseSystem = ptls ? ptls.useSystemStore === true : false;
236
+ var pHasAnchors = pAnchors !== undefined && pAnchors !== null && !(Array.isArray(pAnchors) && pAnchors.length === 0);
237
+ if (!pHasAnchors && !pUseSystem) throw E(C("bad-proxy"), "an https proxy requires explicit tls trust: set proxy.tls.anchors or proxy.tls.useSystemStore");
238
+ if (pHasAnchors) {
239
+ var pAnchorList = Array.isArray(pAnchors) ? pAnchors : [pAnchors];
240
+ for (var pai = 0; pai < pAnchorList.length; pai++) {
241
+ var pan = pAnchorList[pai];
242
+ if (typeof pan !== "string" && !Buffer.isBuffer(pan)) throw E(C("bad-proxy"), "opts.proxy.tls.anchors must be a PEM string or a DER Buffer (or an array of them)");
243
+ }
244
+ }
245
+ var pMinVersion = (ptls && ptls.minVersion) || DEFAULT_MIN_VERSION;
246
+ if (pMinVersion !== "TLSv1.2" && pMinVersion !== "TLSv1.3") throw E(C("bad-proxy"), "proxy.tls.minVersion must be 'TLSv1.2' or 'TLSv1.3', got " + pMinVersion);
247
+ var pCa = [];
248
+ if (pHasAnchors) pCa = pCa.concat(_pemifyAnchors(pAnchors));
249
+ if (pUseSystem) pCa = pCa.concat(_systemCa());
250
+ proxyTls = { ca: pCa.length ? pCa : undefined, minVersion: pMinVersion, servername: (ptls && ptls.servername) || null };
251
+ }
252
+
253
+ var originHost = _stripIpv6Brackets(url.hostname);
254
+ var originAuthHost = nodeNet.isIP(originHost) === 6 ? "[" + originHost + "]" : originHost;
255
+ var phost = _stripIpv6Brackets(purl.hostname);
256
+ return { secure: secure, host: phost, port: purl.port ? +purl.port : (secure ? 443 : 80), originHost: originHost, originAuthority: originAuthHost + ":" + (url.port || 443), auth: auth, proxyTls: proxyTls };
257
+ }
258
+
259
+ function _basicProxyHeader(auth) {
260
+ return "Basic " + Buffer.from(auth.username + ":" + auth.password, "utf8").toString("base64");
261
+ }
262
+ function _proxyErrorClass(e, C) {
263
+ var code = String((e && e.code) || "");
264
+ if (code.indexOf("ERR_TLS") === 0 || code.indexOf("ERR_SSL") === 0 || code.indexOf("SSL") !== -1 ||
265
+ code.indexOf("CERT") !== -1 || code.indexOf("SELF_SIGNED") !== -1 || code.indexOf("VERIFY") !== -1 ||
266
+ code.indexOf("_SIGNATURE") !== -1 || code.indexOf("ALTNAME") !== -1) return C("proxy-tls-failed");
267
+ return C("proxy-connect-failed");
268
+ }
269
+
194
270
  /**
195
271
  * @primitive pki.transport.https
196
272
  * @signature pki.transport.https(defaults?) -> transport
@@ -222,7 +298,8 @@ function _classifyError(e, C) {
222
298
  * - `tls.minVersion` -- 'TLSv1.2' (default) or 'TLSv1.3'; never below the floor.
223
299
  * - `tls.servername` / `tls.checkServerIdentity` -- SNI + RFC 6125 identity; may tighten, never disable.
224
300
  * - `timeout` -- ms (default C.TIME.seconds(30)); `maxResponseBytes` -- default LIMITS.HTTP_MAX_RESPONSE_BYTES, tightenable downward only.
225
- * - `blockPrivateAddresses` -- boolean; when true, an IP-literal host OR a hostname resolving to a private / loopback / link-local address is refused (`transport/blocked-address`), and a resolved address is pinned for the connection. For fetching an untrusted-certificate URL (AIA caIssuers); default false.
301
+ * - `blockPrivateAddresses` -- boolean; when true, an IP-literal host OR a hostname resolving to a private / loopback / link-local address is refused (`transport/blocked-address`), and a resolved address is pinned for the connection. For fetching an untrusted-certificate URL (AIA caIssuers); default false. It cannot be combined with `proxy`: a forward proxy resolves the origin itself, so the transport cannot enforce the block on it, and the combination is refused (`transport/bad-proxy`).
302
+ * - `proxy` -- reach the https origin through a forward HTTP proxy: `{ url: "http://proxy:3128" | "https://proxy:3128", auth?: { scheme: "basic", username, password }, tls?: { anchors, useSystemStore, servername, minVersion } }`. A CONNECT tunnel is opened to the proxy and the origin's TLS is negotiated inside it under the identical origin trust policy, so the proxy cannot read the origin's encrypted session or substitute the origin certificate. `auth` requires an `https://` proxy: Basic credentials ride the authenticated TLS-to-proxy channel (verified against `proxy.tls`, which is required for an https proxy), so a plaintext `http://` proxy carrying `auth` is refused (`transport/proxy-auth-requires-tls`) rather than leaking the credentials to the proxy hop. An `http://` proxy is tunnel-only. Digest is not supported (`transport/proxy-unsupported-scheme`). A `407` is `transport/proxy-auth-failed` (credentials rejected) or `transport/proxy-auth-required` (none supplied); a proxy certificate that does not verify is `transport/proxy-tls-failed`; a non-2xx CONNECT is `transport/proxy-connect-failed`; a malformed option is `transport/bad-proxy`. Off by default (a direct connection).
226
303
  * @example
227
304
  * var t = pki.transport.https({ tls: { anchors: [caPem] } });
228
305
  * var res = await t({ method: "GET", url: "https://ca.example/.well-known/est/cacerts" });
@@ -257,6 +334,7 @@ function httpsTransport(defaults) {
257
334
  if (guard.bytes.isByteSource(body)) body = guard.bytes.source(body, E, C("bad-input"), "the request body");
258
335
 
259
336
  var reqHeaders = Object.assign({}, request.headers || {});
337
+ Object.keys(reqHeaders).forEach(function (k) { var lk = k.toLowerCase(); if (lk === "proxy-authorization" || lk === "proxy-connection") delete reqHeaders[k]; });
260
338
  if (body != null && body !== "") {
261
339
  Object.keys(reqHeaders).forEach(function (k) { var lk = k.toLowerCase(); if (lk === "content-length" || lk === "transfer-encoding") delete reqHeaders[k]; });
262
340
  reqHeaders["Content-Length"] = Buffer.byteLength(body);
@@ -292,13 +370,15 @@ function httpsTransport(defaults) {
292
370
  return callerCsi(host, cert2);
293
371
  };
294
372
  }
373
+ var proxyInfo = _validateProxy(request, defaults, E, C, url);
295
374
  var blockPrivate = (request.blockPrivateAddresses !== undefined ? request.blockPrivateAddresses : defaults.blockPrivateAddresses) === true;
375
+ if (blockPrivate && proxyInfo) throw E(C("bad-proxy"), "blockPrivateAddresses cannot be enforced through a forward proxy, which resolves the origin itself and would reach a private origin the transport never checks; use a direct connection for a private-address-blocked fetch");
296
376
  if (blockPrivate) {
297
377
  if (_isBlockedIp(host)) throw E(C("blocked-address"), "refusing to connect to the private / loopback / link-local address literal " + host);
298
378
  options.lookup = _guardedLookup;
299
379
  }
300
380
 
301
- return { options: options, timeout: timeout, maxBytes: maxBytes, body: body };
381
+ return { options: options, timeout: timeout, maxBytes: maxBytes, body: body, proxy: proxyInfo, blockPrivate: blockPrivate, callerCsi: callerCsi };
302
382
  }
303
383
 
304
384
  var _transportFn = function transport(request) {
@@ -308,59 +388,138 @@ function httpsTransport(defaults) {
308
388
  catch (e) { return Promise.reject(e); }
309
389
  return new Promise(function (resolve, reject) {
310
390
  var settled = false;
311
- var req;
391
+ var req = null;
392
+ var creq = null;
393
+ var tunnelSocket = null;
312
394
  var timer = null;
313
395
  function clearTimer() { if (timer) { clearTimeout(timer); timer = null; } }
314
- function fail(code, msg, cause) {
396
+ function _quietDestroy(x) {
397
+ // allow:swallow-unverified destroy() is idempotent and does not throw in practice; a
398
+ try { if (x) x.destroy(); } catch (_e) { }
399
+ }
400
+ function _settleReject(err) {
315
401
  if (settled) return;
316
402
  settled = true;
317
403
  clearTimer();
318
- // allow:swallow-unverified req.destroy() is idempotent and does not throw in practice; a
319
- try { if (req) req.destroy(); } catch (_e) { }
320
- reject(E(code, msg, cause));
404
+ _quietDestroy(req);
405
+ _quietDestroy(creq);
406
+ _quietDestroy(tunnelSocket);
407
+ reject(err);
321
408
  }
409
+ function fail(code, msg, cause) { _settleReject(E(code, msg, cause)); }
322
410
  timer = setTimeout(function () { fail(C("timeout"), "the request timed out after " + prep.timeout + "ms"); }, prep.timeout);
323
- try {
324
- req = nodeHttps.request(prep.options, function (res) {
325
- var proto = res.socket && res.socket.getProtocol ? res.socket.getProtocol() : null;
326
- var cipher = res.socket && res.socket.getCipher ? res.socket.getCipher() : null;
327
- var peer = res.socket && res.socket.getPeerCertificate ? res.socket.getPeerCertificate() : null;
328
- var declared = parseInt((res.headers || {})["content-length"], 10);
329
- if (Number.isFinite(declared) && declared > prep.maxBytes) { fail(C("response-too-large"), "the declared content-length " + declared + " exceeds the " + prep.maxBytes + "-byte cap (RFC 7030 sec. 6)"); return; }
330
- var buf = Buffer.allocUnsafe(0);
331
- var len = 0;
332
- var total = 0;
333
- res.on("data", function (chunk) {
334
- total += chunk.length;
335
- if (total > prep.maxBytes) { fail(C("response-too-large"), "the response exceeded the " + prep.maxBytes + "-byte cap (RFC 7030 sec. 6)"); return; }
336
- if (len + chunk.length > buf.length) {
337
- var want = Math.min(prep.maxBytes, Math.max(buf.length ? buf.length * 2 : 8192, len + chunk.length));
338
- var grown = Buffer.allocUnsafe(want);
339
- buf.copy(grown, 0, 0, len);
340
- buf = grown;
341
- }
342
- chunk.copy(buf, len);
343
- len += chunk.length;
344
- });
345
- res.on("end", function () {
346
- if (settled) return;
347
- settled = true;
348
- clearTimer();
349
- var lower = {};
350
- Object.keys(res.headers || {}).forEach(function (k) { lower[k.toLowerCase()] = res.headers[k]; });
351
- resolve({
352
- status: res.statusCode,
353
- headers: lower,
354
- body: Buffer.from(buf.subarray(0, len)),
355
- tls: { protocol: proto, cipher: cipher, peerCertificate: peer && peer.raw ? peer.raw : null },
411
+
412
+ function issue(options) {
413
+ try {
414
+ req = nodeHttps.request(options, function (res) {
415
+ var proto = res.socket && res.socket.getProtocol ? res.socket.getProtocol() : null;
416
+ var cipher = res.socket && res.socket.getCipher ? res.socket.getCipher() : null;
417
+ var peer = res.socket && res.socket.getPeerCertificate ? res.socket.getPeerCertificate() : null;
418
+ var declared = parseInt((res.headers || {})["content-length"], 10);
419
+ if (Number.isFinite(declared) && declared > prep.maxBytes) { fail(C("response-too-large"), "the declared content-length " + declared + " exceeds the " + prep.maxBytes + "-byte cap (RFC 7030 sec. 6)"); return; }
420
+ var buf = Buffer.allocUnsafe(0);
421
+ var len = 0;
422
+ var total = 0;
423
+ res.on("data", function (chunk) {
424
+ total += chunk.length;
425
+ if (total > prep.maxBytes) { fail(C("response-too-large"), "the response exceeded the " + prep.maxBytes + "-byte cap (RFC 7030 sec. 6)"); return; }
426
+ if (len + chunk.length > buf.length) {
427
+ var want = Math.min(prep.maxBytes, Math.max(buf.length ? buf.length * 2 : 8192, len + chunk.length));
428
+ var grown = Buffer.allocUnsafe(want);
429
+ buf.copy(grown, 0, 0, len);
430
+ buf = grown;
431
+ }
432
+ chunk.copy(buf, len);
433
+ len += chunk.length;
356
434
  });
435
+ res.on("end", function () {
436
+ if (settled) return;
437
+ settled = true;
438
+ clearTimer();
439
+ var lower = {};
440
+ Object.keys(res.headers || {}).forEach(function (k) { lower[k.toLowerCase()] = res.headers[k]; });
441
+ resolve({
442
+ status: res.statusCode,
443
+ headers: lower,
444
+ body: Buffer.from(buf.subarray(0, len)),
445
+ tls: { protocol: proto, cipher: cipher, peerCertificate: peer && peer.raw ? peer.raw : null },
446
+ });
447
+ });
448
+ res.on("error", function (e) { fail(C("transport-error"), "the response stream failed", e); });
357
449
  });
358
- res.on("error", function (e) { fail(C("transport-error"), "the response stream failed", e); });
359
- });
360
- req.on("error", function (e) { fail(_classifyError(e, C), "the request failed: " + ((e && e.message) || String(e)), e); });
361
- if (prep.body != null && prep.body !== "") req.write(prep.body);
362
- req.end();
363
- } catch (e) { fail(C("transport-error"), "the request could not be initiated: " + ((e && e.message) || String(e)), e); }
450
+ req.on("error", function (e) { fail(_classifyError(e, C), "the request failed: " + ((e && e.message) || String(e)), e); });
451
+ if (prep.body != null && prep.body !== "") req.write(prep.body);
452
+ req.end();
453
+ } catch (e) { fail(C("transport-error"), "the request could not be initiated: " + ((e && e.message) || String(e)), e); }
454
+ }
455
+
456
+ if (!prep.proxy) { issue(prep.options); return; }
457
+
458
+ var pinfo = prep.proxy;
459
+ var pheaders = { Host: pinfo.originAuthority, Connection: "keep-alive" };
460
+ if (pinfo.auth) pheaders["Proxy-Authorization"] = _basicProxyHeader(pinfo.auth);
461
+ var connectOpts = { host: pinfo.host, port: pinfo.port, method: "CONNECT", path: pinfo.originAuthority, headers: pheaders, agent: false };
462
+ var cr;
463
+ try {
464
+ if (pinfo.secure) {
465
+ connectOpts.ca = pinfo.proxyTls.ca;
466
+ connectOpts.rejectUnauthorized = true;
467
+ connectOpts.minVersion = pinfo.proxyTls.minVersion;
468
+ var pIdentity = pinfo.proxyTls.servername || pinfo.host;
469
+ connectOpts.servername = (pIdentity && !nodeNet.isIP(pIdentity)) ? pIdentity : "";
470
+ connectOpts.checkServerIdentity = function (host, cert) { return nodeTls.checkServerIdentity(pIdentity, cert); };
471
+ cr = nodeHttps.request(connectOpts);
472
+ } else {
473
+ cr = nodeHttp.request(connectOpts);
474
+ }
475
+ } catch (e) { fail(C("proxy-connect-failed"), "the CONNECT request could not be initiated: " + ((e && e.message) || String(e)), e); return; }
476
+ creq = cr;
477
+ var done = false;
478
+ function onProxyResponse(res, socket) {
479
+ if (done) { if (socket) _quietDestroy(socket); return; }
480
+ done = true;
481
+ if (settled) { if (socket) _quietDestroy(socket); return; }
482
+ var sc = res.statusCode;
483
+ if (socket && sc >= 200 && sc < 300) {
484
+ tunnelSocket = socket;
485
+ creq = null;
486
+ socket.on("error", function (e) { fail(_classifyError(e, C), "the tunnel socket failed: " + ((e && e.message) || String(e)), e); });
487
+ var idHost = prep.options.servername || pinfo.originHost;
488
+ issue(Object.assign({}, prep.options, {
489
+ createConnection: function () {
490
+ return nodeTls.connect({
491
+ socket: socket,
492
+ host: prep.options.hostname,
493
+ servername: prep.options.servername,
494
+ ca: prep.options.ca,
495
+ minVersion: prep.options.minVersion,
496
+ rejectUnauthorized: true,
497
+ checkServerIdentity: function (host, cert) {
498
+ var baseErr = nodeTls.checkServerIdentity(idHost, cert);
499
+ if (baseErr) return baseErr;
500
+ return prep.callerCsi ? prep.callerCsi(idHost, cert) : undefined;
501
+ },
502
+ cert: prep.options.cert,
503
+ key: prep.options.key,
504
+ });
505
+ },
506
+ }));
507
+ return;
508
+ }
509
+ if (socket) _quietDestroy(socket);
510
+ if (sc === 407) { fail(C(pinfo.auth ? "proxy-auth-failed" : "proxy-auth-required"), pinfo.auth ? "the proxy rejected the supplied credentials (HTTP 407)" : "the proxy requires authentication; supply proxy.auth over an https proxy (HTTP 407)"); return; }
511
+ fail(C("proxy-connect-failed"), "the proxy answered CONNECT with HTTP " + sc);
512
+ }
513
+ cr.on("connect", function (res, socket) { onProxyResponse(res, socket); });
514
+ cr.on("response", function (res) {
515
+ // allow:swallow-unverified draining the proxy error body is best-effort; the verdict is the status
516
+ res.on("data", function () { });
517
+ res.on("error", function () { });
518
+ res.on("end", function () { });
519
+ onProxyResponse(res, null);
520
+ });
521
+ cr.on("error", function (e) { fail(pinfo.secure ? _proxyErrorClass(e, C) : C("proxy-connect-failed"), "the CONNECT request failed: " + ((e && e.message) || String(e)), e); });
522
+ cr.end();
364
523
  });
365
524
  };
366
525
  _transportFn.blocksPrivateAddresses = true;
package/lib/scep.js CHANGED
@@ -685,6 +685,7 @@ function _pkiRequest(method, opUrl, reqMsg, clientOpts) {
685
685
  }
686
686
  function _drive(method, url, body, headers, opts, transport, budgets) {
687
687
  var redirects = 0, curMethod = method, curBody = body, initialOrigin = url.origin;
688
+ var proxySnap = _snapshotProxy(opts.proxy);
688
689
  var tlsBase = _tlsForRequest(opts);
689
690
  var allowCrossOrigin = !!opts.allowCrossOriginRedirect;
690
691
  function _hopTls(current) {
@@ -697,6 +698,7 @@ function _drive(method, url, body, headers, opts, transport, budgets) {
697
698
  }
698
699
  function step(current) {
699
700
  var req = { method: curMethod, url: current.href, headers: headers, tls: _hopTls(current), timeout: budgets.timeout, maxResponseBytes: budgets.maxResponseBytes };
701
+ if (proxySnap != null) req.proxy = proxySnap;
700
702
  if (curBody != null) req.body = curBody;
701
703
  return transport(req).then(function (res) {
702
704
  res = res || {};
@@ -715,6 +717,19 @@ function _drive(method, url, body, headers, opts, transport, budgets) {
715
717
  }
716
718
  return step(url);
717
719
  }
720
+ function _copyAnchor(a) { return Buffer.isBuffer(a) ? Buffer.from(a) : a; }
721
+ function _snapshotProxy(p) {
722
+ if (p == null || typeof p !== "object" || Array.isArray(p)) return p;
723
+ var out = Object.assign({}, p);
724
+ if (p.auth != null && typeof p.auth === "object" && !Array.isArray(p.auth)) out.auth = Object.assign({}, p.auth);
725
+ if (p.tls != null && typeof p.tls === "object" && !Array.isArray(p.tls)) {
726
+ out.tls = Object.assign({}, p.tls);
727
+ var a = p.tls.anchors;
728
+ if (Array.isArray(a)) out.tls.anchors = a.map(_copyAnchor);
729
+ else if (a != null) out.tls.anchors = _copyAnchor(a);
730
+ }
731
+ return out;
732
+ }
718
733
  function _client(method, url, body, headers, opts) {
719
734
  var transport = opts.transport || httpTransport.https({ E: _err, errPrefix: "scep" });
720
735
  var budgets = {
@@ -798,7 +813,7 @@ function _assertStrongProfile(caps, profile) {
798
813
  * - `transport` -- an injected transport (defaults to `pki.transport.https`); the request is a GET with no body.
799
814
  * - `expectSCEPStandard` -- refuse (`scep/weak-profile`) if the response does not advertise `SCEPStandard`.
800
815
  * - `requireStrongProfile` -- refuse unless AES + SHA-256 + POSTPKIOperation are all advertised.
801
- * - `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` -- transport bounds.
816
+ * - `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` / `proxy` -- transport bounds (`proxy` reaches the CA through a forward HTTP proxy; see pki.transport).
802
817
  * @example
803
818
  * // requires: scepTransport -- an injected transport (omit to use pki.transport.https)
804
819
  * var caps = await pki.scep.getCACaps("http://ca.example/scep", { transport: scepTransport });
@@ -870,7 +885,7 @@ function _normalizeFingerprint(fp, algName) {
870
885
  * @opts
871
886
  * - `expectedFingerprint` -- a hex string or Buffer; a returned certificate must hash to it, or the response is refused.
872
887
  * - `fingerprintAlgorithm` -- the hash for the fingerprint (default "sha256").
873
- * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` -- transport bounds.
888
+ * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` / `proxy` -- transport bounds (`proxy` reaches the CA through a forward HTTP proxy; see pki.transport).
874
889
  * @example
875
890
  * // requires: scepCaCertTransport -- an injected transport returning a single CA certificate
876
891
  * var ca = await pki.scep.getCACert("http://ca.example/scep", { transport: scepCaCertTransport });
@@ -925,7 +940,7 @@ async function getCACert(baseUrl, opts) {
925
940
  *
926
941
  * @opts
927
942
  * - `caCertificate` -- the current SCEP CA certificate DER; the response is authenticated against its key (required).
928
- * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` -- transport bounds.
943
+ * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` / `proxy` -- transport bounds (`proxy` reaches the CA through a forward HTTP proxy; see pki.transport).
929
944
  * @example
930
945
  * // requires: caCertDer -- the current CA certificate (from getCACert), scepTransport
931
946
  * var next = await pki.scep.getNextCACert("http://ca.example/scep", { caCertificate: caCertDer, transport: scepTransport });
@@ -1032,6 +1047,7 @@ async function _pkiOperation(messageType, baseUrl, opts, verbName) {
1032
1047
  allowCrossOriginRedirect: opts.allowCrossOriginRedirect,
1033
1048
  timeout: opts.timeout,
1034
1049
  maxResponseBytes: opts.maxResponseBytes,
1050
+ proxy: _snapshotProxy(opts.proxy),
1035
1051
  };
1036
1052
  var postUrl = _scepUrl(baseUrl, "PKIOperation");
1037
1053
  var httpMethod = _pkiMethod(opts);
@@ -1096,7 +1112,7 @@ async function _pkiOperation(messageType, baseUrl, opts, verbName) {
1096
1112
  * - `sleep` -- an injectable sleeper `(ms) -> Promise` for the Retry-After wait (default a real timer).
1097
1113
  * - `onRetryAfter` -- an optional observer `(delaySeconds) -> void` called before each poll sleep.
1098
1114
  * - `httpMethod` -- `"POST"` (default) or `"GET"`. RFC 8894 sec. 4.1 sends the PKIOperation message over POST; `"GET"` carries it base64-encoded in the URL `message` query for a legacy CA that lacks POST.
1099
- * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` -- transport bounds.
1115
+ * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` / `proxy` -- transport bounds (`proxy` reaches the CA through a forward HTTP proxy; see pki.transport).
1100
1116
  * @example
1101
1117
  * // requires: scepCsr, caCertDer, clientCertDer, clientKeyPkcs8, scepTransport
1102
1118
  * var out = await pki.scep.enroll("http://ca.example/scep", { csr: scepCsr, caCert: caCertDer,
@@ -1172,7 +1188,7 @@ async function _queryOperation(messageType, baseUrl, opts, verbName) {
1172
1188
  var recipientKey = _captureRecipientKey(opts.recipientKey);
1173
1189
  var signer = { cert: guard.bytes.snapshotSource(opts.signer.cert, ScepError, "scep/bad-input", "signer.cert"), key: opts.signer.key };
1174
1190
  var want = _resolveQueryTarget(opts);
1175
- var clientOpts = { transport: opts.transport, tls: opts.tls != null ? Object.assign({}, opts.tls) : opts.tls, maxRedirects: opts.maxRedirects, allowCrossOriginRedirect: opts.allowCrossOriginRedirect, timeout: opts.timeout, maxResponseBytes: opts.maxResponseBytes };
1191
+ var clientOpts = { transport: opts.transport, tls: opts.tls != null ? Object.assign({}, opts.tls) : opts.tls, maxRedirects: opts.maxRedirects, allowCrossOriginRedirect: opts.allowCrossOriginRedirect, timeout: opts.timeout, maxResponseBytes: opts.maxResponseBytes, proxy: _snapshotProxy(opts.proxy) };
1176
1192
  var senderNonce = nodeCrypto.randomBytes(16);
1177
1193
  var transactionId = opts.transactionId != null ? opts.transactionId : _defaultTransactionId();
1178
1194
  var httpMethod = _pkiMethod(opts);
@@ -1211,7 +1227,7 @@ async function _queryOperation(messageType, baseUrl, opts, verbName) {
1211
1227
  * - `responderCert` -- the certificate to authenticate the CA response signature against (defaults to `caCert`).
1212
1228
  * - `transactionId` -- a caller-unique PrintableString (defaults to 16 random bytes, hex-encoded).
1213
1229
  * - `httpMethod` -- `"POST"` (default) or `"GET"`. RFC 8894 sec. 4.1 sends the PKIOperation message over POST; `"GET"` carries it base64-encoded in the URL `message` query for a legacy CA that lacks POST.
1214
- * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` -- transport bounds.
1230
+ * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` / `proxy` -- transport bounds (`proxy` reaches the CA through a forward HTTP proxy; see pki.transport).
1215
1231
  * @example
1216
1232
  * // requires: clientCertDer, caCertDer, clientKeyPkcs8, scepTransport
1217
1233
  * var out = await pki.scep.getCert("http://ca.example/scep", { certificate: clientCertDer, caCert: caCertDer,
@@ -1260,7 +1276,7 @@ async function getCert(baseUrl, opts) {
1260
1276
  * - `responderCert` -- the certificate to authenticate the CA response against (defaults to `caCert`).
1261
1277
  * - `transactionId` -- a caller-unique PrintableString (defaults to 16 random bytes, hex-encoded).
1262
1278
  * - `httpMethod` -- `"POST"` (default) or `"GET"`. RFC 8894 sec. 4.1 sends the PKIOperation message over POST; `"GET"` carries it base64-encoded in the URL `message` query for a legacy CA that lacks POST.
1263
- * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` -- transport bounds.
1279
+ * - `transport` / `timeout` / `maxResponseBytes` / `maxRedirects` / `tls` / `allowCrossOriginRedirect` / `proxy` -- transport bounds (`proxy` reaches the CA through a forward HTTP proxy; see pki.transport).
1264
1280
  * @example
1265
1281
  * // requires: clientCertDer, caCertDer, clientKeyPkcs8, scepTransport
1266
1282
  * var out = await pki.scep.getCrl("http://ca.example/scep", { certificate: clientCertDer, caCert: caCertDer,
@@ -1283,7 +1299,7 @@ async function getCrl(baseUrl, opts) {
1283
1299
  return { crl: match, crls: crls, transactionId: q.transactionId };
1284
1300
  }
1285
1301
 
1286
- var _TRANSPORT_KEYS = { transport: 1, timeout: 1, maxResponseBytes: 1, maxRedirects: 1, tls: 1, allowCrossOriginRedirect: 1 };
1302
+ var _TRANSPORT_KEYS = { transport: 1, timeout: 1, maxResponseBytes: 1, maxRedirects: 1, tls: 1, allowCrossOriginRedirect: 1, proxy: 1 };
1287
1303
  function _withKeys(extra) { var o = {}, k; for (k in _TRANSPORT_KEYS) o[k] = 1; for (k in extra) o[k] = 1; return o; }
1288
1304
  var _CACAPS_KEYS = _withKeys({ expectSCEPStandard: 1, requireStrongProfile: 1 });
1289
1305
  var _CACERT_KEYS = _withKeys({ expectedFingerprint: 1, fingerprintAlgorithm: 1 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/pki",
3
- "version": "0.6.26",
3
+ "version": "0.6.27",
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",
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:58de7cb1-c804-4545-aa09-1f5a777abac3",
5
+ "serialNumber": "urn:uuid:9742df6c-59a0-4fce-a64b-ddc916ee2fba",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-09-02T11:38:48.889Z",
8
+ "timestamp": "2026-09-02T20:36:04.064Z",
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.26",
22
+ "bom-ref": "@blamejs/pki@0.6.27",
23
23
  "type": "application",
24
24
  "name": "pki",
25
- "version": "0.6.26",
25
+ "version": "0.6.27",
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.26",
29
+ "purl": "pkg:npm/%40blamejs/pki@0.6.27",
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.26",
57
+ "ref": "@blamejs/pki@0.6.27",
58
58
  "dependsOn": []
59
59
  }
60
60
  ]