@blamejs/pki 0.6.28 → 0.6.30

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +1 -1
  3. package/lib/acme.js +10 -8
  4. package/lib/asn1-der.js +9 -7
  5. package/lib/attrcert-sign.js +8 -8
  6. package/lib/byte-reader.js +1 -1
  7. package/lib/byte-writer.js +1 -1
  8. package/lib/cmc-verify.js +4 -4
  9. package/lib/cmp-build.js +9 -5
  10. package/lib/cmp-session.js +9 -4
  11. package/lib/cms-verify.js +22 -17
  12. package/lib/composite-kem.js +2 -2
  13. package/lib/constants.js +1 -0
  14. package/lib/crl-sign.js +5 -5
  15. package/lib/crmf-sign.js +3 -3
  16. package/lib/csr-sign.js +2 -2
  17. package/lib/ct.js +3 -3
  18. package/lib/est.js +34 -22
  19. package/lib/framework-error.js +2 -2
  20. package/lib/guard-identifier.js +18 -1
  21. package/lib/hpke.js +2 -2
  22. package/lib/http-transport.js +82 -10
  23. package/lib/inspect.js +1 -1
  24. package/lib/jose.js +1 -1
  25. package/lib/key.js +7 -7
  26. package/lib/lint.js +1 -1
  27. package/lib/merkle.js +2 -6
  28. package/lib/mime.js +2 -2
  29. package/lib/ocsp.js +6 -6
  30. package/lib/oid.js +1 -1
  31. package/lib/path-validate.js +13 -13
  32. package/lib/pkcs12-build.js +4 -4
  33. package/lib/rfc3339.js +2 -2
  34. package/lib/scep.js +3 -15
  35. package/lib/schema-all.js +1 -1
  36. package/lib/schema-attrcert.js +1 -1
  37. package/lib/schema-cmc.js +2 -2
  38. package/lib/schema-cmp.js +8 -9
  39. package/lib/schema-cms.js +3 -3
  40. package/lib/schema-crmf.js +3 -3
  41. package/lib/schema-csr.js +1 -1
  42. package/lib/schema-csrattrs.js +1 -1
  43. package/lib/schema-engine.js +4 -4
  44. package/lib/schema-ocsp.js +1 -1
  45. package/lib/schema-pkcs12.js +2 -2
  46. package/lib/schema-pkcs8.js +2 -2
  47. package/lib/schema-smime.js +1 -1
  48. package/lib/schema-tsp.js +6 -6
  49. package/lib/schema-x509.js +2 -2
  50. package/lib/shbs.js +3 -4
  51. package/lib/sign-scheme.js +1 -1
  52. package/lib/sigstore.js +2 -2
  53. package/lib/smime.js +16 -16
  54. package/lib/tls-cert-compress.js +7 -7
  55. package/lib/trust.js +5 -5
  56. package/lib/tsp-sign.js +8 -6
  57. package/lib/webauthn.js +23 -19
  58. package/lib/webcrypto.js +3 -3
  59. package/lib/x509-sign.js +5 -5
  60. package/package.json +1 -1
  61. package/sbom.cdx.json +6 -6
package/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ 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.30 — 2026-09-04
8
+
9
+ Reference documentation is corrected across the toolkit: a mistyped signed-attribute field name, and options and return fields the code accepts or returns that the reference had omitted.
10
+
11
+ ### Changed
12
+
13
+ - Options and return fields the code accepts or returns are now documented across pki.cms, pki.tsp, pki.pkcs12, pki.hpke, pki.path, pki.ocsp, pki.asn1, pki.est, pki.acme, and pki.webauthn. In particular, pki.webauthn.verifyAssertion is documented as checking the challenge and origin when expectedChallenge / expectedOrigin / expectedTopOrigin are supplied with clientDataJSON.
14
+ - Reference prose across the toolkit and the documentation site is reworded for consistency.
15
+
16
+ ### Fixed
17
+
18
+ - pki.smime.sign documented additionalSignedAttributes as [{ oid, values }]; the code reads the type field, so a caller following the reference would pass an unrecognized field. The correct form is [{ type, values }].
19
+ - pki.ocsp.buildErrorResponse is documented as returning a Buffer; the signature previously showed Buffer | string, but the verb has no PEM option and every path returns DER.
20
+ - The pki.schema.all example output lists csrattrs, which the enumeration returns between cmp and ocsp-request.
21
+ - The pki.acme.client method list documents updateAccount and listOrders, which the client returns.
22
+ - pki.tsp.verify now includes policyName on a failure verdict; it already returned the resolved policy name on a valid verdict and the raw policy on both, so a refused token carries the same descriptive fields as a valid one.
23
+
24
+ ## v0.6.29 — 2026-09-03
25
+
26
+ The EST, ACME, and CMP clients reach a CA through a forward HTTP proxy, with the same opts.proxy the SCEP client already accepts.
27
+
28
+ ### Added
29
+
30
+ - pki.est.cacerts / simpleenroll / simplereenroll / serverkeygen / csrattrs / fullcmc, pki.acme.client, pki.cmp.transfer, and the pki.cmp.session client (which forwards it to every enrollment, polling, revocation, and confirmation leg) accept opts.proxy = { url, auth?, tls? } to reach the CA through a forward HTTP proxy, the same option pki.scep accepts. The origin TLS is negotiated inside the proxy's CONNECT tunnel under the identical origin trust policy; Basic authentication (RFC 7617) is sent only over an https:// proxy verified against proxy.tls, and an http:// proxy is tunnel-only. The option is deep-copied at the call so a later change to the caller's object cannot alter the proxy in use.
31
+
7
32
  ## v0.6.28 — 2026-09-02
8
33
 
9
34
  pki.path.build returns the best accepted path when the candidate cap is reached during policy ranking, instead of discarding it.
package/README.md CHANGED
@@ -223,7 +223,7 @@ comment blocks, is at [pkijs.com](https://pkijs.com).
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
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` |
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. The SCEP, EST, ACME, and CMP clients each thread 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` |
package/lib/acme.js CHANGED
@@ -513,7 +513,7 @@ function validate(kind, obj) {
513
513
  * @related pki.acme.validate
514
514
  *
515
515
  * Classify an ACME JSON object into exactly one kind by its discriminating
516
- * member set -- `"jws"`, `"problem"`, `"directory"`, `"order"`, `"authorization"`,
516
+ * member set: `"jws"`, `"problem"`, `"directory"`, `"order"`, `"authorization"`,
517
517
  * `"challenge"`, `"account"`, `"renewalInfo"`, or `"unknown"`. The discriminators
518
518
  * are proven mutually exclusive; a DER structure identifies as `"unknown"`.
519
519
  *
@@ -1109,7 +1109,7 @@ async function finalize(o) {
1109
1109
  * @related pki.acme.http01, pki.acme.dns01
1110
1110
  *
1111
1111
  * Build a challenge-response POST (RFC 8555 sec. 7.5.1): a kid-signed JWS whose
1112
- * payload is the type-defined response object -- `{}` for the three registered
1112
+ * payload is the type-defined response object: `{}` for the three registered
1113
1113
  * challenge types (http-01 / dns-01 / tls-alpn-01), which is DISTINCT from a
1114
1114
  * POST-as-GET empty payload. `opts` = `{ key, alg, nonce, url, kid, payload? }`
1115
1115
  * (payload default `{}`; pass a custom object for a future challenge type).
@@ -1139,7 +1139,7 @@ function challengeResponse(o) {
1139
1139
  * @related pki.acme.validate
1140
1140
  *
1141
1141
  * Build a deactivation POST (RFC 8555 sec. 7.3.6 account / sec. 7.5.2
1142
- * authorization): a kid-signed JWS with the payload `{"status":"deactivated"}` --
1142
+ * authorization): a kid-signed JWS with the payload `{"status":"deactivated"}`,
1143
1143
  * the only client-settable status. `opts` = `{ key, alg, nonce, url, kid }`.
1144
1144
  *
1145
1145
  * @example
@@ -1196,7 +1196,7 @@ function updateAccount(o) {
1196
1196
  * Build a revokeCert request (RFC 8555 sec. 7.6): a JWS whose payload `certificate`
1197
1197
  * is the base64url of the DER certificate and optional `reason` is an assigned
1198
1198
  * RFC 5280 CRLReason (0-6, 8-10; 7 is unassigned). Signed EITHER by the account key (`kid` mode) OR by the
1199
- * certificate key (`jwk` mode) -- pass exactly one. `opts` = `{ key, alg, nonce,
1199
+ * certificate key (`jwk` mode). Pass exactly one. `opts` = `{ key, alg, nonce,
1200
1200
  * url, certificate (DER Buffer), reason?, kid? | jwk? }`.
1201
1201
  *
1202
1202
  * @example
@@ -1347,7 +1347,7 @@ function parseAriCertId(certId) {
1347
1347
  *
1348
1348
  * Validate an ARI RenewalInfo object (RFC 9773 sec. 4.2): a `suggestedWindow` with
1349
1349
  * RFC 3339 `start` and `end`, `end` strictly after `start` (an inverted or
1350
- * zero-width window throws `acme/bad-renewal-window` -- the client treats it as no
1350
+ * zero-width window throws `acme/bad-renewal-window`: the client treats it as no
1351
1351
  * response, defusing a renewal stampede), and an optional `explanationURL`.
1352
1352
  * Returns the object.
1353
1353
  *
@@ -1758,13 +1758,14 @@ function _parseLinkNext(headers, base) { var m = _parseLinkRelation(headers, bas
1758
1758
  * capped by a poll count and a total-wait budget. Returns a client
1759
1759
  * object: `directory`, `newAccount`, `newOrder`, `newAuthz`, `getOrder` / `getAuthorization` / `getChallenge`,
1760
1760
  * `respondToChallenge`, `finalize`, `pollOrder` / `pollAuthorization`, `downloadCertificate`,
1761
- * `revokeCert`, `deactivateAccount` / `deactivateAuthorization`, `keyChange`, `renewalInfo`, `renewalWindow`, `scheduleRenewal`.
1761
+ * `revokeCert`, `deactivateAccount` / `deactivateAuthorization`, `updateAccount`, `listOrders`, `keyChange`, `renewalInfo`, `renewalWindow`, `scheduleRenewal`.
1762
1762
  *
1763
1763
  * @opts
1764
1764
  * - `accountKey` / `accountJwk` / `alg` -- REQUIRED: the account private key, its public JWK, and the JWS alg.
1765
1765
  * - `transport` -- injectable transport(request) -> {status, headers, body}; default pki.transport.https.
1766
1766
  * - `tls` -- { anchors, useSystemStore, cert, key, minVersion, servername, checkServerIdentity } for the default transport.
1767
1767
  * - `timeout` / `maxResponseBytes` / `maxRedirects` -- transport budgets; `maxNonceRetries` -- badNonce retry cap (default 1).
1768
+ * - `proxy` -- reach the ACME server through a forward HTTP proxy (`{ url, auth?, tls? }`; see pki.transport).
1768
1769
  * - `maxPolls` / `maxTotalWait` / `sleep` -- poll-loop budgets + an injectable sleeper; `clock` -- an injectable receipt clock (default Date.now) for a Retry-After HTTP-date.
1769
1770
  * - `resignKeys` -- optional ordered `[{ alg, key }]` enabling the RFC 8555 sec. 6.2 badSignatureAlgorithm re-sign. When a CA rejects the account `alg` and advertises the algs it supports, the first entry whose `alg` the CA advertised re-signs the request once and retries. Each `key` is a CryptoKey for the SAME account key material under that `alg`: an RSA account key signs RS256 and PS256 from one key, and its registered public JWK verifies either. The caller's order selects and the CA's list only filters, so a spoofed badSignatureAlgorithm cannot force a weaker alg (sec. 10). Absent, or with no advertised match, the badSignatureAlgorithm surfaces unchanged.
1770
1771
  * - `newAuthz(identifier)` -- pre-authorize a single identifier (RFC 8555 sec. 7.4.1) -> { authorization, url }.
@@ -1778,7 +1779,7 @@ function _parseLinkNext(headers, base) { var m = _parseLinkRelation(headers, bas
1778
1779
  */
1779
1780
  var _CLIENT_OPTS = {
1780
1781
  accountKey: 1, accountJwk: 1, alg: 1, resignKeys: 1, transport: 1, tls: 1, timeout: 1, maxResponseBytes: 1,
1781
- maxRedirects: 1, maxNonceRetries: 1, maxPolls: 1, maxTotalWait: 1, sleep: 1, clock: 1,
1782
+ maxRedirects: 1, maxNonceRetries: 1, maxPolls: 1, maxTotalWait: 1, sleep: 1, clock: 1, proxy: 1,
1782
1783
  };
1783
1784
  var _METHOD_OPTS = {
1784
1785
  finalize: { csr: 1, identifiers: 1 },
@@ -1845,6 +1846,7 @@ function client(directoryUrl, opts) {
1845
1846
  }
1846
1847
  var budgets = {
1847
1848
  tls: _clientTls(opts),
1849
+ proxy: httpTransport.snapshotProxy(opts.proxy),
1848
1850
  timeout: guard.limits.cap(opts.timeout, "timeout", CLIENT_DEFAULT_TIMEOUT, { E: E, code: "acme/bad-input", min: 1, max: CLIENT_MAX_TIMEOUT }),
1849
1851
  maxResponseBytes: guard.limits.cap(opts.maxResponseBytes, "maxResponseBytes", constants.LIMITS.HTTP_MAX_RESPONSE_BYTES, { E: E, code: "acme/bad-input", min: 1, max: constants.LIMITS.HTTP_MAX_RESPONSE_BYTES }),
1850
1852
  maxRedirects: guard.limits.cap(opts.maxRedirects, "maxRedirects", 5, { E: E, code: "acme/bad-input", min: 0, max: 32 }),
@@ -1908,7 +1910,7 @@ function client(directoryUrl, opts) {
1908
1910
  function _send(method, url, headers, body) { return _sendFollowing(method, url, headers, body, 0); }
1909
1911
  function _sendFollowing(method, url, headers, body, redirects) {
1910
1912
  var reqHeaders = Object.assign({ "user-agent": CLIENT_USER_AGENT }, headers || {});
1911
- return transport({ method: method, url: url, headers: reqHeaders, body: body, tls: _tlsFor(url), timeout: budgets.timeout, maxResponseBytes: budgets.maxResponseBytes }).then(function (res) {
1913
+ return transport({ method: method, url: url, headers: reqHeaders, body: body, tls: _tlsFor(url), proxy: budgets.proxy, timeout: budgets.timeout, maxResponseBytes: budgets.maxResponseBytes }).then(function (res) {
1912
1914
  res = res || {};
1913
1915
  var h = {};
1914
1916
  Object.keys(res.headers || {}).forEach(function (k) { h[k.toLowerCase()] = res.headers[k]; });
package/lib/asn1-der.js CHANGED
@@ -23,8 +23,8 @@
23
23
  * turn a node into a JS value (BigInt, dotted OID, Date, string); the
24
24
  * `build.*` helpers construct canonical DER from JS values. Because DER
25
25
  * is canonical, each value the `build.*` helpers emit has exactly one
26
- * valid encoding -- byte-identical to any other conformant DER encoder's
27
- * output -- and decoding it reproduces the value it was built from.
26
+ * valid encoding, byte-identical to any other conformant DER encoder's
27
+ * output, and decoding it reproduces the value it was built from.
28
28
  *
29
29
  * @card
30
30
  * Strict, fail-closed DER decode / encode with a navigable node tree
@@ -112,9 +112,10 @@ function _asBuffer(input, who) {
112
112
  *
113
113
  * Parse DER into a node tree. Each node is
114
114
  * `{ tagClass, constructed, tagNumber, header, length, content, children,
115
- * bytes }`, where `content` is the primitive value slice, `children` the
116
- * decoded sub-nodes of a constructed node, and `bytes` the full TLV slice
117
- * (all zero-copy views over the input).
115
+ * bytes, contentStart, contentEnd }`, where `content` is the primitive value slice, `children` the
116
+ * decoded sub-nodes of a constructed node, `bytes` the full TLV slice, and
117
+ * `contentStart` / `contentEnd` the content slice's byte offsets in the input
118
+ * (all slices are zero-copy views over the input).
118
119
  *
119
120
  * Throws `Asn1Error` on any non-DER shape: indefinite length, a
120
121
  * non-minimal length or a length that overruns the buffer, trailing bytes
@@ -124,13 +125,14 @@ function _asBuffer(input, who) {
124
125
  * `ber: true` is a scoped relaxation for formats whose content regions are
125
126
  * normatively BER (RFC 7292 PKCS#12): it accepts an indefinite length on a
126
127
  * constructed value and a constructed OCTET STRING, whose segments are
127
- * reassembled into one primitive `content`. Nothing else is relaxed --
128
+ * reassembled into one primitive `content`. Nothing else is relaxed:
128
129
  * definite lengths stay minimal, an indefinite length on a primitive value
129
130
  * and a foreign-type segment still reject, and the size / depth caps hold.
130
131
  *
131
132
  * @opts
132
133
  * maxBytes: number, // default: C.LIMITS.DER_MAX_BYTES (16 MiB)
133
134
  * maxDepth: number, // default: C.LIMITS.DER_MAX_DEPTH (64)
135
+ * maxItems: number, // default: C.LIMITS.DER_MAX_ITEMS (total decoded node cap)
134
136
  * allowTrailing: boolean, // default false; allow bytes after the top TLV
135
137
  * ber: boolean, // default false; accept indefinite lengths +
136
138
  * // constructed OCTET STRINGs (BER content regions)
@@ -680,7 +682,7 @@ function encodeIdentifier(classBits, constructed, tagNumber) {
680
682
  * @spec X.690, ISO/IEC 8825-1
681
683
  * @related pki.asn1.decode
682
684
  *
683
- * Low-level TLV encoder -- prepend the identifier + DER length to a content
685
+ * Low-level TLV encoder: prepend the identifier + DER length to a content
684
686
  * buffer. Most callers use the higher-level `build.*` helpers; this is the
685
687
  * escape hatch for context-tagged and implicitly-tagged constructions.
686
688
  *
@@ -583,17 +583,17 @@ function _unsupportedCritical(ac) {
583
583
  * @defends attribute-certificate-forgery (CWE-347)
584
584
  * @related pki.attrcert.sign, pki.path.validate, pki.schema.attrcert.parse
585
585
  *
586
- * Verify an RFC 5755 attribute certificate. An AC carries privilege attributes -- a role, a group, a
587
- * clearance -- so a consumer that reads them without this grants privileges on unauthenticated
586
+ * Verify an RFC 5755 attribute certificate. An AC carries privilege attributes (a role, a group, a
587
+ * clearance), so a consumer that reads them without this grants privileges on unauthenticated
588
588
  * input. `ac` is a DER `Buffer`, a PEM string, or a parsed attribute certificate; `issuer` is
589
589
  * `{ name, publicKey }`, the AC issuer this verifier trusts as an AC issuer, which section 5 item 4
590
590
  * makes the verifier's own configuration and this verb therefore refuses to infer from the AC.
591
- * `issuer.name` takes every form `pki.attrcert.sign` accepts for the issuing AA -- a string, an
592
- * array of RDNs, or raw `Name` DER -- and is compared as a distinguished name (RFC 5280 section
591
+ * `issuer.name` takes every form `pki.attrcert.sign` accepts for the issuing AA (a string, an
592
+ * array of RDNs, or raw `Name` DER) and is compared as a distinguished name (RFC 5280 section
593
593
  * 7.1), so an AC issued under a multi-RDN authority name is verifiable under that same name.
594
594
  *
595
595
  * Both options are read at the call, before signature verification suspends it, so a caller that
596
- * reuses or rewrites its options object -- including calling `setTime` on the `Date` it passed in --
596
+ * reuses or rewrites its options object (including calling `setTime` on the `Date` it passed in)
597
597
  * cannot change the verdict that call returns.
598
598
  *
599
599
  * The checks it performs are section 5's items 2, 4, 5, 6 and 7: the signature over the exact
@@ -613,7 +613,7 @@ function _unsupportedCritical(ac) {
613
613
  * (RFC 5280 sec. 7.2), a mailbox matches its local-part exactly and its host-part case-insensitively
614
614
  * (sec. 7.5), and a directoryName goes through the same distinguished-name comparison the rest of
615
615
  * the toolkit uses (sec. 7.1). A URI compares as encoded, because sec. 7.4 makes URI equality a full
616
- * RFC 3987 normalization -- percent-encoding, path segments and scheme-based rules -- and a partial
616
+ * RFC 3987 normalization (percent-encoding, path segments and scheme-based rules) and a partial
617
617
  * one could match a URI it should not. A form with no comparison here (otherName, ediPartyName,
618
618
  * x400Address) leaves `targetingChecked: false` and never a pass. Every one of those limits can
619
619
  * refuse a target a fuller comparison would accept, and none can accept one it would refuse.
@@ -627,8 +627,8 @@ function _unsupportedCritical(ac) {
627
627
  *
628
628
  * Revocation is section 6, outside the seven. This verb implements that section's "never revoke"
629
629
  * scheme, which AC users MUST support: it holds no revocation evidence and follows no pointer out
630
- * of the certificate. The section states the consequence -- "If only the 'never revoke' scheme is
631
- * supported, then all ACs that do not contain a noRevAvail extension, MUST be rejected" -- because
630
+ * of the certificate. The section states the consequence, "If only the 'never revoke' scheme is
631
+ * supported, then all ACs that do not contain a noRevAvail extension, MUST be rejected", because
632
632
  * an issuer that omits noRevAvail is stating that revocation status checks are supported, and a
633
633
  * verdict that skipped one would grant privileges the issuer expected to be able to withdraw. So an
634
634
  * AC carrying `noRevAvail` verifies with `revocationChecked: true` and `noRevAvail: true`, and one
@@ -3,7 +3,7 @@
3
3
  "use strict";
4
4
  /**
5
5
  * @internal
6
- * lib/byte-reader.js -- a bounded big-endian byte cursor: the shared ENCODING-layer
6
+ * lib/byte-reader.js: a bounded big-endian byte cursor, the shared ENCODING-layer
7
7
  * primitive under the toolkit's non-ASN.1 length-prefixed wire formats (TLS-vector
8
8
  * SCTs in pki.ct, the packed big-endian TPM2B_* / authenticatorData structures in
9
9
  * pki.webauthn). Every read is length-checked against a hard [pos, end) window
@@ -3,7 +3,7 @@
3
3
  "use strict";
4
4
  /**
5
5
  * @internal
6
- * lib/byte-writer.js -- a growable big-endian byte sink: the ENCODING-layer twin of
6
+ * lib/byte-writer.js: a growable big-endian byte sink, the ENCODING-layer twin of
7
7
  * lib/byte-reader.js, the shared producer under the toolkit's non-ASN.1 length-prefixed
8
8
  * wire formats (the TLS-vector SCT list pki.ct emits; any future TLS-presentation
9
9
  * producer). Every fixed-width integer is range-checked against its field width and
package/lib/cmc-verify.js CHANGED
@@ -200,11 +200,11 @@ function _governingStatus(statuses, outcome) {
200
200
  * Interpret a Full PKI Response into one terminal verdict. `response` is the DER or a PEM `CMS`
201
201
  * block; an already-parsed message is interpreted too, but only under `allowUnverified: true`,
202
202
  * because both carriers authenticate over BYTES and a parsed object the caller still owns pins
203
- * none. `sent` is what the client retained from its request --
203
+ * none. `sent` is what the client retained from its request:
204
204
  * `transactionId`, `senderNonce`, `dataReturn`, and `bodyPartIDs` (every identifier the request
205
205
  * carried). Each of those is checked only if it was sent, and once sent an absent or differing
206
206
  * echo is a refusal: that asymmetry is the replay defense. `bodyPartIDs` is the same rule applied
207
- * to what the response is ABOUT -- a status naming a body part the request never sent is refused
207
+ * to what the response is ABOUT: a status naming a body part the request never sent is refused
208
208
  * with `cmc/body-part-unknown`, which the transaction and nonce cannot catch, since a server can
209
209
  * echo both correctly while reporting on something else.
210
210
  *
@@ -229,7 +229,7 @@ function _governingStatus(statuses, outcome) {
229
229
  * The carrier's signature MUST be verified (RFC 5272 sec. 3.2.1.3.4). A conforming SignedData
230
230
  * carries its own signer certificate, so the ordinary case needs nothing from the caller: the
231
231
  * signature is checked and the verdict reports `signatureVerified: true`. Where the signer cannot be
232
- * found -- not embedded and not supplied -- the posture is fail-closed with a NAMED opt-out rather
232
+ * found (not embedded and not supplied), the posture is fail-closed with a NAMED opt-out rather
233
233
  * than a silent one: pass `certs` with the responder's certificate, or `allowUnverified: true` and
234
234
  * the verdict reports `signatureVerified: false`. Doing neither is refused, because that is the case
235
235
  * where a caller would otherwise assume a check happened. The opt-out covers "could not check",
@@ -245,7 +245,7 @@ function _governingStatus(statuses, outcome) {
245
245
  * who holds the key gets an authenticated verdict instead of the unauthenticated opt-out.
246
246
  *
247
247
  * Nothing is trusted here. `certificates` is the CMS certificate bag, where RFC 5272 sec. 4.2
248
- * puts the issued certificates -- surfaced raw for the caller to run through `pki.path.validate`,
248
+ * puts the issued certificates, surfaced raw for the caller to run through `pki.path.validate`,
249
249
  * and a Publish Trust Anchors control is surfaced as `publishTrustAnchors` with `trusted: false`,
250
250
  * never added to any store (RFC 5272 sec. 6.15 makes accepting one a four-part manual decision).
251
251
  * The CMS signature is likewise the caller's to verify through `pki.cms.verify`.
package/lib/cmp-build.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * @title Certificate management protocol messages
9
9
  * @fullname CMP (Certificate Management Protocol, RFC 4210)
10
10
  * @intro The RFC 9810 Certificate Management Protocol producing side. `pki.cmp.build` assembles a
11
- * `PKIMessage` -- a `PKIHeader` (sender / recipient / transaction metadata), a `PKIBody` carrying one
11
+ * `PKIMessage`: a `PKIHeader` (sender / recipient / transaction metadata), a `PKIBody` carrying one
12
12
  * request or transaction (an `ir` / `cr` / `kur` certificate request via `pki.crmf.build`, a `p10cr`
13
13
  * PKCS#10 via `pki.csr.sign`, a `certConf` / `pollReq` / `genm` / `rr`, or a `nested` wrapper of other
14
14
  * PKIMessages an RA forwards), and an optional
@@ -682,7 +682,7 @@ function _collectExtraCerts(opts, protCertDer) {
682
682
  * @spec RFC 9810, RFC 9481, RFC 9579
683
683
  * @related pki.schema.cmp.parse
684
684
  *
685
- * Build an RFC 9810 CMP `PKIMessage` -- the producing-side inverse of `pki.schema.cmp.parse`. `message` is
685
+ * Build an RFC 9810 CMP `PKIMessage`, the producing-side inverse of `pki.schema.cmp.parse`. `message` is
686
686
  * `{ header, body }`: `header` carries the `sender` / `recipient` GeneralNames plus optional transaction
687
687
  * metadata (`transactionID`, `senderNonce`, `messageTime`, `freeText`, `generalInfo`, ...); `body` is a
688
688
  * single-key object naming the arm. Request-side: `{ ir }` / `{ cr }` / `{ kur }` / `{ krr }` (key recovery,
@@ -735,7 +735,7 @@ var DEFAULT_TRANSFER_TIMEOUT = constants.TIME.seconds(30);
735
735
  var MAX_TRANSFER_TIMEOUT = constants.TIME.seconds(600);
736
736
  var PKIXCMP = "application/pkixcmp";
737
737
  var PKIXCMP_POLL = "application/pkixcmp-poll";
738
- var KNOWN_TRANSFER_OPTS = { transport: 1, tls: 1, headers: 1, timeout: 1, maxResponseBytes: 1 };
738
+ var KNOWN_TRANSFER_OPTS = { transport: 1, tls: 1, headers: 1, timeout: 1, maxResponseBytes: 1, proxy: 1 };
739
739
 
740
740
  function _cmpMessageDer(input) {
741
741
  var der;
@@ -799,6 +799,9 @@ function _transfer(url, message, opts) {
799
799
  }
800
800
  var timeout = guard.limits.cap(opts.timeout, "timeout", DEFAULT_TRANSFER_TIMEOUT, { E: _err, code: "cmp/bad-input", min: 1, max: MAX_TRANSFER_TIMEOUT });
801
801
  var maxResponseBytes = guard.limits.cap(opts.maxResponseBytes, "maxResponseBytes", constants.LIMITS.HTTP_MAX_RESPONSE_BYTES, { E: _err, code: "cmp/bad-input", min: 1, max: constants.LIMITS.HTTP_MAX_RESPONSE_BYTES });
802
+ var proxy;
803
+ try { proxy = httpTransport.snapshotProxy(opts.proxy); }
804
+ catch (e) { throw _err("cmp/bad-input", "the options object could not be read", e); }
802
805
  var headers = {};
803
806
  Object.keys(opts.headers || {}).forEach(function (k) {
804
807
  var lk = k.toLowerCase();
@@ -806,7 +809,7 @@ function _transfer(url, message, opts) {
806
809
  });
807
810
  headers["content-type"] = PKIXCMP;
808
811
  var tls = _tlsForTransfer(opts);
809
- return Promise.resolve(transport({ method: "POST", url: parsedUrl.href, headers: headers, body: der, tls: tls, timeout: timeout, maxResponseBytes: maxResponseBytes })).then(function (res) {
812
+ return Promise.resolve(transport({ method: "POST", url: parsedUrl.href, headers: headers, body: der, tls: tls, proxy: proxy, timeout: timeout, maxResponseBytes: maxResponseBytes })).then(function (res) {
810
813
  res = res || {};
811
814
  var h = {};
812
815
  Object.keys(res.headers || {}).forEach(function (k) { h[k.toLowerCase()] = res.headers[k]; });
@@ -900,6 +903,7 @@ function wellKnownUrl(base, opts) {
900
903
  * overridable (any casing), and the request-framing headers (`content-length`, `transfer-encoding`) are
901
904
  * stripped -- the transport computes Content-Length from the exact body, so a caller cannot desync framing.
902
905
  * - `timeout` -- ms (default 30s); `maxResponseBytes` -- streaming cap, tightenable downward only.
906
+ * - `proxy` -- reach the CA through a forward HTTP proxy (`{ url, auth?, tls? }`; see pki.transport).
903
907
  * @example
904
908
  * var reqDer = await pki.cmp.build(
905
909
  * { header: { sender: { directoryName: "CN=client" }, recipient: { directoryName: "CN=CA" } },
@@ -920,7 +924,7 @@ function wellKnownUrl(base, opts) {
920
924
  *
921
925
  * Build an RFC 9811 sec. 3.4 CMP request-URI under the `/.well-known/cmp` prefix (RFC 8615). The four forms:
922
926
  * `<base>/.well-known/cmp`, `.../<operation>`, `.../p/<label>`, and `.../p/<label>/<operation>`. A pure string
923
- * builder over an authority-rooted well-known path (RFC 8615) -- https vs http is left to the transport (both
927
+ * builder over an authority-rooted well-known path (RFC 8615): https vs http is left to the transport (both
924
928
  * forms are accepted, RFC 9811 sec. 3.4), but the `base` MUST be an http(s) URL. It rejects (`cmp/bad-url`) an
925
929
  * unparseable `base`, a non-http(s) scheme (`file:`/`data:`/a custom scheme has an opaque origin), a `base`
926
930
  * carrying a path / query / fragment (a well-known URI is authority-rooted; a path would capture it), and a
@@ -21,6 +21,7 @@ var webcrypto = require("./webcrypto");
21
21
  var frameworkError = require("./framework-error");
22
22
  var sleepUtil = require("./sleep");
23
23
  var retryAfter = require("./http-retry-after");
24
+ var httpTransport = require("./http-transport");
24
25
 
25
26
  var CmpError = frameworkError.CmpError;
26
27
  function _err(code, message, cause) { return new CmpError(code, message, cause); }
@@ -52,7 +53,7 @@ var COMPOSITE_PH_HASHALG = { "SHA-256": "sha256", "SHA-384": "sha384", "SHA-512"
52
53
  var KNOWN_SESSION_OPTS = {
53
54
  url: 1, key: 1, cert: 1, mac: 1, trustAnchors: 1, intermediates: 1, recipient: 1, sender: 1,
54
55
  extraCerts: 1, implicitConfirm: 1, maxPolls: 1, maxTotalWait: 1, sleep: 1, time: 1,
55
- transport: 1, tls: 1, headers: 1, timeout: 1, maxResponseBytes: 1, pss: 1, digestAlgorithm: 1,
56
+ transport: 1, tls: 1, headers: 1, timeout: 1, maxResponseBytes: 1, proxy: 1, pss: 1, digestAlgorithm: 1,
56
57
  acceptCert: 1, senderKID: 1, recipKID: 1, expectedSender: 1,
57
58
  };
58
59
 
@@ -264,14 +265,14 @@ function _certConfHash(certDer) {
264
265
  * requirements, whose template must omit `publicKey`, `serialNumber`, `signingAlg`, `issuerUID` and
265
266
  * `subjectUID`, and whose `keySpec` states key requirements as `algId` (a non-RSA AlgorithmIdentifier) or
266
267
  * `rsaKeyLen` (a positive integer); and `{ crlUpdate: { issuer, dpn?, thisUpdate? } }` for a CRL from a
267
- * named source, held to that source -- the issuer under the RFC 5280 sec. 7.1 rule, a distribution point
268
- * against the CRL's own `issuingDistributionPoint` where it states one -- and to the supplied `thisUpdate`.
268
+ * named source, held to that source (the issuer under the RFC 5280 sec. 7.1 rule, a distribution point
269
+ * against the CRL's own `issuingDistributionPoint` where it states one) and to the supplied `thisUpdate`.
269
270
  * A request naming both sends the dpn (sec. 4.3.4: the dpn choice when a distribution point name is
270
271
  * available) and holds the answer to the issuer as well. The issuer is REQUIRED, since a distribution
271
272
  * point name alone leaves the answer unbound: a complete CRL states no scope to compare it against.
272
273
  * Terminal `outcome`: `answered` (with `operation`, `present`, and the decoded `value`),
273
274
  * `rejected`, or `poll-timeout`. An absent response value is `present: false` with a null `value`, which is
274
- * how each of the four says "nothing available" -- never conflated with an empty result. Delayed delivery
275
+ * how each of the four says "nothing available", never conflated with an empty result. Delayed delivery
275
276
  * for both verbs arrives as an error message carrying the `waiting` status (sec. 4.4) and drives the same
276
277
  * bounded poll loop, with the `pollReq` referring to the whole message.
277
278
  *
@@ -286,6 +287,7 @@ function _certConfHash(certDer) {
286
287
  * - `acceptCert` -- an async policy `(certDer, { status, grantedWithMods }) => boolean` consulted before the certConf; return true to accept, anything else to veto (a `grantedWithMods` certificate the CA changed). A veto sends a rejecting certConf and yields `outcome: "rejected"` with the certificate still surfaced. Incompatible with `implicitConfirm` (no reject leg exists), so the combination throws at construction.
287
288
  * - `transport` -- injectable transport(request) -> {status, headers, body}; default pki.transport.https.
288
289
  * - `tls` / `headers` / `timeout` / `maxResponseBytes` -- transport config + budgets.
290
+ * - `proxy` -- reach the CA through a forward HTTP proxy (`{ url, auth?, tls? }`; see pki.transport).
289
291
  * - `maxPolls` / `maxTotalWait` / `sleep` -- poll-loop budgets + an injectable sleeper; `time` -- verify-time clock.
290
292
  * - `extraCerts` / `pss` / `digestAlgorithm` -- passed through to the request protection build.
291
293
  * @example
@@ -304,6 +306,7 @@ function _certConfHash(certDer) {
304
306
  function session(opts) {
305
307
  if (opts == null) opts = {};
306
308
  guard.identifier.assertPlainRecord(opts, _err, "cmp/bad-input", "opts");
309
+ guard.identifier.optionsObject(opts, _err, "cmp/bad-input", "opts");
307
310
  guard.identifier.assertKnownKeys(opts, KNOWN_SESSION_OPTS, _err, "cmp/bad-input", "unknown session opts field ");
308
311
  opts = Object.assign({}, opts);
309
312
  if (typeof opts.url !== "string" || !opts.url) throw _err("cmp/bad-input", "opts.url (the CMP endpoint) is required");
@@ -319,6 +322,7 @@ function session(opts) {
319
322
  if (isMac && Array.isArray(opts.trustAnchors) && opts.trustAnchors.length === 0) opts.trustAnchors = null;
320
323
  if (opts.trustAnchors != null && _engine && _engine.toAnchor) _asCertList(opts.trustAnchors).forEach(function (a) { try { _engine.toAnchor(a); } catch (e) { throw _err("cmp/bad-input", "opts.trustAnchors: each entry must be a certificate (DER/PEM/parsed) or a { name, publicKey, algorithm } anchor tuple -- " + ((e && e.message) || e), e); } });
321
324
  if (opts.intermediates != null && _engine && _engine.coerceCert) _asCertList(opts.intermediates).forEach(function (c) { try { _engine.coerceCert(c); } catch (e) { throw _err("cmp/bad-input", "opts.intermediates: each entry must be a certificate (DER/PEM/parsed) -- " + ((e && e.message) || e), e); } });
325
+ var _proxySnap = httpTransport.snapshotProxy(opts.proxy);
322
326
  var _expectedSenderCert = null;
323
327
  var _expectedSenderDer = null;
324
328
  if (opts.expectedSender != null) {
@@ -428,6 +432,7 @@ function session(opts) {
428
432
  function _transferOpts() {
429
433
  var o = {};
430
434
  ["transport", "tls", "headers", "timeout", "maxResponseBytes"].forEach(function (k) { if (opts[k] != null) o[k] = opts[k]; });
435
+ if (_proxySnap != null) o.proxy = _proxySnap;
431
436
  return o;
432
437
  }
433
438
 
package/lib/cms-verify.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * @nav Verification
7
7
  * @title CMS
8
8
  * @fullname CMS (Cryptographic Message Syntax) signing and verification
9
- * @intro Verify a CMS SignedData signature (RFC 5652 sec. 5) -- the structure S/MIME signed
9
+ * @intro Verify a CMS SignedData signature (RFC 5652 sec. 5), the structure S/MIME signed
10
10
  * mail, RFC 3161 timestamp tokens, and code-signing all rest on. `verify(cms, opts)` parses
11
11
  * the SignedData (over the strict `pki.schema.cms` codec), locates each SignerInfo's signer
12
12
  * certificate by its issuerAndSerialNumber or subjectKeyIdentifier, and checks the signature
@@ -406,7 +406,7 @@ async function _verifyOneCountersig(vDer, targetSig, parsedCerts) {
406
406
 
407
407
  /**
408
408
  * @primitive pki.cms.verify
409
- * @signature pki.cms.verify(input, opts?) -> Promise<{ valid, trusted, eContentType, signers }>
409
+ * @signature pki.cms.verify(input, opts?) -> Promise<{ valid, trusted, eContentType, eContent, signers }>
410
410
  * @since 0.2.14
411
411
  * @status stable
412
412
  * @spec RFC 5652
@@ -416,15 +416,16 @@ async function _verifyOneCountersig(vDer, targetSig, parsedCerts) {
416
416
  * @related pki.schema.cms.parse, pki.path.validate
417
417
  *
418
418
  * Verify a CMS SignedData signature (RFC 5652 sec. 5). `input` is a PEM string, a DER
419
- * `Buffer`, or a parsed `pki.schema.cms` object. Returns `{ valid, trusted, eContentType, signers }`
420
- * where each `signers[i]` is `{ ok, sid, cert, trusted, signedAttributesPresent }` (`cert` the
421
- * matched signer certificate DER) or carries a `code` on a structural failure; `valid` is true when
419
+ * `Buffer`, or a parsed `pki.schema.cms` object. Returns `{ valid, trusted, eContentType, eContent, signers }`
420
+ * (`eContent` the encapsulated content when present, else null) where each `signers[i]` is
421
+ * `{ ok, sid, cert, trusted, signedAttributesPresent, signedAttributes, unsignedAttrs, digestAlgorithm, countersignatures }`
422
+ * (`cert` the matched signer certificate DER) or carries a `code` on a structural failure; `valid` is true when
422
423
  * there is at least one signer and every signer verified.
423
424
  *
424
425
  * `eContentType` and `signedAttributesPresent` are there for a caller whose profile is stricter
425
- * than RFC 5652's. Signing WITH attributes and signing the content directly are different claims --
426
+ * than RFC 5652's. Signing WITH attributes and signing the content directly are different claims:
426
427
  * attributes bind a content type and a signing time alongside the digest, content-only binds
427
- * nothing but the bytes -- and one message may carry a signer of each. A profile that requires
428
+ * nothing but the bytes. One message may carry a signer of each. A profile that requires
428
429
  * attributes (RFC 8551 S/MIME does) or a particular content type can enforce it from the verdict,
429
430
  * with no need to parse the message a second time.
430
431
  *
@@ -434,9 +435,8 @@ async function _verifyOneCountersig(vDer, targetSig, parsedCerts) {
434
435
  * certificate, sign with it, and embed it, so that says nothing about WHO signed. `trusted` says
435
436
  * every signer chained to a root named in `opts.trustAnchors`, validated through the same RFC 5280
436
437
  * path engine `pki.path.validate` uses. Without anchors there is nothing to chain to and `trusted`
437
- * is `false` -- a definite answer, not a missing one. Anchors that cannot be read are a
438
- * configuration fault and throw. Absorbing them into `trusted: false` would report a verdict
439
- * about the message for a check that never ran.
438
+ * is `false`, a definite answer, not a missing one. Anchors that cannot be read are a
439
+ * configuration fault and throw.
440
440
  *
441
441
  * Trust is decided from the certificate the SignerInfo selected, the one reported as
442
442
  * `signers[i].cert`, never from another certificate that happens to share its key. A
@@ -706,6 +706,9 @@ function _addCert(out, der) {
706
706
  * @opts eContentType The encapsulated content type (an OID name). Default `data`.
707
707
  * @opts signedAttributes Include signed attributes (content-type, message-digest, signing-time);
708
708
  * false signs the content directly. Default true.
709
+ * @opts additionalSignedAttributes Extra signed attributes to add to every SignerInfo, each
710
+ * `{ type, values }` (`type` an OID name or dotted string, `values` an
711
+ * array of DER value `Buffer`s). Covered by the signature.
709
712
  * @opts signingTime A `Date` for the signing-time attribute, or false to omit it.
710
713
  * @opts sid `"issuerAndSerial"` (default) or `"ski"` (subjectKeyIdentifier).
711
714
  * @opts certificates Embed the signer certificates in the output. Default true.
@@ -739,7 +742,7 @@ var sign = cmsSign.sign;
739
742
  * Add one or more countersignatures to an existing CMS SignedData (RFC 5652 sec. 11.4). A
740
743
  * countersignature is itself a `SignerInfo` whose signature covers the CONTENTS of the countersigned
741
744
  * SignerInfo's signature value (not the content), attached as the `id-countersignature` unsigned
742
- * attribute -- the construction Authenticode timestamps and signature-attestation workflows rest on.
745
+ * attribute, the construction Authenticode timestamps and signature-attestation workflows rest on.
743
746
  * `cms` is the SignedData (a DER `Buffer` or a PEM `CMS` string; the wire bytes are preserved, so
744
747
  * the countersigned primary still verifies byte-for-byte). Each `signers[i]` is the same descriptor
745
748
  * `pki.cms.sign` takes (`{ cert, key, digestAlgorithm?, pss? }`, any RSA / RSASSA-PSS / ECDSA /
@@ -784,7 +787,7 @@ var countersign = cmsSign.countersign;
784
787
  * Encrypt content as a CMS EnvelopedData (CBC content), AuthEnvelopedData (AEAD content, the
785
788
  * default), or EncryptedData. `recipients` is an ARRAY of recipient descriptors for the enveloped
786
789
  * family, each wrapping the same fresh content-encryption key: `{ cert }` auto-dispatches off the
787
- * recipient certificate's public-key algorithm -- RSA yields a ktri with RSAES-OAEP-SHA256 (PKCS#1
790
+ * recipient certificate's public-key algorithm: RSA yields a ktri with RSAES-OAEP-SHA256 (PKCS#1
788
791
  * v1.5 is never emitted); EC P-256/384/521 a kari with ephemeral-static ECDH and the X9.63 KDF;
789
792
  * X25519/X448 a kari per RFC 8418 (HKDF); ML-KEM-512/768/1024 an ori/KEMRecipientInfo per RFC
790
793
  * 9629 + 9936; a composite ML-KEM (id-MLKEM768-* / id-MLKEM1024-*, draft-lamps-pq-composite-kem) the
@@ -827,7 +830,7 @@ var encrypt = cmsEncrypt.encrypt;
827
830
  * @spec RFC 5652, RFC 2104, RFC 4231, RFC 3370
828
831
  * @related pki.cms.decrypt, pki.schema.cms.parse
829
832
  *
830
- * Produce a CMS AuthenticatedData (RFC 5652 sec. 9): CLEARTEXT content plus a MAC (HMAC-SHA-2) --
833
+ * Produce a CMS AuthenticatedData (RFC 5652 sec. 9): CLEARTEXT content plus a MAC (HMAC-SHA-2),
831
834
  * authenticated but not encrypted, the authenticated-only sibling of AuthEnvelopedData. A single
832
835
  * fresh MAC key is minted and wrapped for every recipient with the same RecipientInfo model
833
836
  * `pki.cms.encrypt` uses for a content-encryption key, so `recipients` is the identical array of
@@ -835,8 +838,8 @@ var encrypt = cmsEncrypt.encrypt;
835
838
  * `{ password }` (pwri), or `{ kek, kekId }` (kekri). By default the MAC covers the authenticated
836
839
  * attributes (a content-type and a message-digest = digest of the content) re-tagged to the EXPLICIT
837
840
  * SET OF (RFC 5652 sec. 9.2); with `authenticatedAttributes: false` (id-data content only) it covers
838
- * the content octets directly. `pki.cms.decrypt` recovers the MAC key, recomputes the MAC, and --
839
- * with authenticated attributes -- independently confirms the message-digest before releasing the
841
+ * the content octets directly. `pki.cms.decrypt` recovers the MAC key, recomputes the MAC, and
842
+ * (with authenticated attributes) independently confirms the message-digest before releasing the
840
843
  * content, returning `authenticated: true`. Malformed input throws a typed `CmsError`.
841
844
  *
842
845
  * @opts macAlgorithm `"hmac-sha256"` (default) / `"hmac-sha384"` / `"hmac-sha512"`.
@@ -847,6 +850,8 @@ var encrypt = cmsEncrypt.encrypt;
847
850
  * @opts authAttrs Extra authenticated attributes appended to the content-type + message-digest pair.
848
851
  * @opts contentType The encapsulated content type (an OID name). Default `data`.
849
852
  * @opts keyIdentifier `"issuerAndSerial"` (default) or `"subjectKeyIdentifier"`.
853
+ * @opts oaepHash The RSAES-OAEP hash for ktri recipients wrapping the MAC key: `"sha256"` (default) / `"sha384"` / `"sha512"`.
854
+ * @opts ukm User keying material (a Buffer) for kari / kemri recipients.
850
855
  * @opts pem Return a PEM string (`-----BEGIN CMS-----`) instead of a DER Buffer.
851
856
  * @example
852
857
  * // authenticate a message to an RSA recipient, then verify the MAC via decrypt
@@ -890,7 +895,7 @@ var authenticate = cmsEncrypt.authenticate;
890
895
  * recipient type: a `ktri` or ephemeral-static `kari` message is minted by anyone holding the recipient's
891
896
  * PUBLIC key, and a `pwri` or `kekri` message by any co-recipient sharing the secret. Read
892
897
  * `authenticated: true` as "these bytes were not altered after the key was chosen", and do not read it as
893
- * a sender identity -- to bind one, verify a signature (`pki.cms.verify`) over the plaintext.
898
+ * a sender identity. To bind one, verify a signature (`pki.cms.verify`) over the plaintext.
894
899
  * `authenticatedBy` names what the integrity rests on (`"content-encryption-key"` for AEAD,
895
900
  * `"message-authentication-key"` for AuthenticatedData, `null` for an unauthenticated cipher).
896
901
  * `originatorInfo` is surfaced as the sender supplied it and is UNAUTHENTICATED: it sits outside the
@@ -958,7 +963,7 @@ var compress = cmsCompress.compress;
958
963
  * decompression-bomb / resource-exhaustion defense (CWE-409): a cap breach throws
959
964
  * `cms/decompress-too-large`, and every malformed / truncated / corrupt stream collapses to the uniform
960
965
  * `cms/decompress-failed`. `opts.maxOutputBytes` tightens the cap DOWNWARD only. The verdict carries NO
961
- * `authenticated` / `valid` field -- CompressedData is not a security assertion (RFC 8551 sec. 2.4.5).
966
+ * `authenticated` / `valid` field. CompressedData is not a security assertion (RFC 8551 sec. 2.4.5).
962
967
  *
963
968
  * @opts maxOutputBytes Lower the decompressed-output cap (a DoS bound; downward only).
964
969
  * @example
@@ -13,8 +13,8 @@
13
13
  * recovers the same secret from that ciphertext and the composite private key. Each component KEM
14
14
  * runs independently, and the two secrets are mixed through the SHA3-256 combiner that also binds the
15
15
  * traditional ciphertext, the traditional public key, and a per-algorithm label. All twelve registered
16
- * algorithms -- ML-KEM-768 and ML-KEM-1024 paired with RSA-OAEP 2048/3072/4096, ECDH over
17
- * P-256/P-384/P-521 and brainpool, X25519, and X448 -- are verified against the draft Appendix G
16
+ * algorithms (ML-KEM-768 and ML-KEM-1024 paired with RSA-OAEP 2048/3072/4096, ECDH over
17
+ * P-256/P-384/P-521 and brainpool, X25519, and X448) are verified against the draft Appendix G
18
18
  * known-answer vectors.
19
19
  * @spec draft-ietf-lamps-pq-composite-kem
20
20
  * @card Establish a shared secret with a hybrid post-quantum plus traditional KEM.
package/lib/constants.js CHANGED
@@ -125,6 +125,7 @@ var LIMITS = {
125
125
  SCT_MAX_BYTES: BYTES.kib(64) + 1,
126
126
  SCT_MAX_COUNT: 256,
127
127
  MERKLE_MAX_PROOF_NODES: 65,
128
+ PROXY_MAX_TLS_ANCHORS: 256,
128
129
  PATH_MAX_CERTS: 100,
129
130
  PATH_MAX_POLICY_NODES: 4096,
130
131
  PATH_BUILD_MAX_DEPTH: 20,