micro509 0.18.0 → 0.19.0

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 (99) hide show
  1. package/CHANGELOG.md +88 -1
  2. package/dist/crypto/crypto.d.ts +11 -2
  3. package/dist/crypto/crypto.js +30 -17
  4. package/dist/crypto/crypto.js.map +1 -1
  5. package/dist/crypto.d.ts +2 -2
  6. package/dist/der/der.js.map +1 -1
  7. package/dist/index.d.ts +6 -5
  8. package/dist/internal/asn1/asn1.js +10 -2
  9. package/dist/internal/asn1/asn1.js.map +1 -1
  10. package/dist/internal/asn1/ber.js.map +1 -1
  11. package/dist/internal/asn1/decode-refusal.js.map +1 -1
  12. package/dist/internal/asn1/der.js.map +1 -1
  13. package/dist/internal/asn1/oids.js.map +1 -1
  14. package/dist/internal/crypto/algorithm-names.js.map +1 -1
  15. package/dist/internal/crypto/ecdsa.js.map +1 -1
  16. package/dist/internal/crypto/hash.js.map +1 -1
  17. package/dist/internal/crypto/pbes2.js.map +1 -1
  18. package/dist/internal/crypto/prime-ec.js.map +1 -1
  19. package/dist/internal/crypto/rsa-pss.js.map +1 -1
  20. package/dist/internal/crypto/sig-verify.d.ts +40 -0
  21. package/dist/internal/crypto/sig-verify.js +152 -65
  22. package/dist/internal/crypto/sig-verify.js.map +1 -1
  23. package/dist/internal/crypto/signing.js.map +1 -1
  24. package/dist/internal/jose/base64url.js.map +1 -1
  25. package/dist/internal/jose/json-data.js.map +1 -1
  26. package/dist/internal/jose/strict-json.js.map +1 -1
  27. package/dist/internal/shared/base64.js.map +1 -1
  28. package/dist/internal/shared/dn.js.map +1 -1
  29. package/dist/internal/shared/idna.js.map +1 -1
  30. package/dist/internal/shared/ip.js.map +1 -1
  31. package/dist/internal/shared/mailbox.js.map +1 -1
  32. package/dist/internal/shared/punycode.js.map +1 -1
  33. package/dist/internal/shared/uri-host.js.map +1 -1
  34. package/dist/internal/verify/name-constraints-engine.js.map +1 -1
  35. package/dist/internal/verify/policy-engine.js.map +1 -1
  36. package/dist/internal/verify/spki-distrust.js.map +1 -1
  37. package/dist/internal/verify/verify-path.js +222 -116
  38. package/dist/internal/verify/verify-path.js.map +1 -1
  39. package/dist/internal/x509/directory-name.js.map +1 -1
  40. package/dist/internal/x509/extension-bits.js.map +1 -1
  41. package/dist/internal/x509/extension-errors.js.map +1 -1
  42. package/dist/internal/x509/extension-registry.js.map +1 -1
  43. package/dist/internal/x509/general-name-profile.js.map +1 -1
  44. package/dist/internal/x509/general-name.js.map +1 -1
  45. package/dist/internal/x509/name-fields.js.map +1 -1
  46. package/dist/internal/x509/or-address.js.map +1 -1
  47. package/dist/jose/base64url.js.map +1 -1
  48. package/dist/jose/errors.js.map +1 -1
  49. package/dist/jose/jwe.js.map +1 -1
  50. package/dist/jose/jwks.js.map +1 -1
  51. package/dist/jose/jws.js.map +1 -1
  52. package/dist/jose/jwt.js.map +1 -1
  53. package/dist/jose/remote-jwks.js.map +1 -1
  54. package/dist/kdf/argon2-arithmetic.js.map +1 -1
  55. package/dist/kdf/argon2-core.js.map +1 -1
  56. package/dist/kdf/argon2-memory.js.map +1 -1
  57. package/dist/kdf/argon2-portable.js.map +1 -1
  58. package/dist/kdf/argon2.js.map +1 -1
  59. package/dist/keys/keys.js.map +1 -1
  60. package/dist/pem/pem.js.map +1 -1
  61. package/dist/pkcs/pfx.js.map +1 -1
  62. package/dist/pkcs/pkcs12-mac.js +1 -1
  63. package/dist/pkcs/pkcs12-mac.js.map +1 -1
  64. package/dist/pkcs/pkcs7.d.ts +10 -0
  65. package/dist/pkcs/pkcs7.js +106 -88
  66. package/dist/pkcs/pkcs7.js.map +1 -1
  67. package/dist/result/result.js.map +1 -1
  68. package/dist/revocation/chain.d.ts +67 -13
  69. package/dist/revocation/chain.js +429 -301
  70. package/dist/revocation/chain.js.map +1 -1
  71. package/dist/revocation/crl.d.ts +65 -11
  72. package/dist/revocation/crl.js +492 -202
  73. package/dist/revocation/crl.js.map +1 -1
  74. package/dist/revocation/ocsp.d.ts +79 -24
  75. package/dist/revocation/ocsp.js +417 -231
  76. package/dist/revocation/ocsp.js.map +1 -1
  77. package/dist/revocation/revocation.d.ts +68 -13
  78. package/dist/revocation/revocation.js +194 -73
  79. package/dist/revocation/revocation.js.map +1 -1
  80. package/dist/revocation.d.ts +4 -4
  81. package/dist/ssh/ssh.js.map +1 -1
  82. package/dist/ssh/wire.js.map +1 -1
  83. package/dist/verify/identity.d.ts +2 -2
  84. package/dist/verify/identity.js +2 -2
  85. package/dist/verify/identity.js.map +1 -1
  86. package/dist/verify/verify.d.ts +84 -32
  87. package/dist/verify/verify.js +221 -171
  88. package/dist/verify/verify.js.map +1 -1
  89. package/dist/verify.d.ts +3 -2
  90. package/dist/x509/certificate.js.map +1 -1
  91. package/dist/x509/csr.js.map +1 -1
  92. package/dist/x509/extensions.js.map +1 -1
  93. package/dist/x509/fingerprint.js.map +1 -1
  94. package/dist/x509/name-text.js.map +1 -1
  95. package/dist/x509/name.js.map +1 -1
  96. package/dist/x509/parse.d.ts +6 -2
  97. package/dist/x509/parse.js +121 -121
  98. package/dist/x509/parse.js.map +1 -1
  99. package/package.json +11 -11
@@ -1,21 +1,21 @@
1
1
  import { canonicalizeOid as e } from "../internal/asn1/asn1.js";
2
2
  import { decodeRefusalOf as t, rethrowDecodeRefusal as n } from "../internal/asn1/decode-refusal.js";
3
3
  import { OIDS as r } from "../internal/asn1/oids.js";
4
- import { verifySignedDataDetailed as i } from "../internal/crypto/sig-verify.js";
5
- import { compareDistinguishedNames as a } from "../internal/shared/dn.js";
6
- import { asciiLowercase as o, domainToAscii as s } from "../internal/shared/idna.js";
7
- import { parseIpAddressToBytes as c } from "../internal/shared/ip.js";
8
- import { presentedSmtpUtf8MailboxDomain as l } from "../internal/shared/mailbox.js";
9
- import { createNameConstraintValidationState as u, evaluateNameConstraints as d } from "../internal/verify/name-constraints-engine.js";
10
- import { createPolicyValidationState as f, evaluatePolicyChain as p } from "../internal/verify/policy-engine.js";
11
- import { createSpkiDistrustCheck as m } from "../internal/verify/spki-distrust.js";
12
- import { assertPathBuildingChecks as h, authorityKeyIdentifierMismatch as g, buildChainInternal as _, countCaCertificatesBelowParsed as v, isSelfIssued as y, isWithinValidity as b, loadCertificates as x, loadSingleCertificate as S, verifyCertificateSignature as C } from "../internal/verify/verify-path.js";
13
- import { normalizeLabelSeparators as w, parsePresentedSrvName as T, parseSrvNameRestriction as E, parseUriNameConstraint as D } from "../internal/x509/general-name-profile.js";
14
- import { DECODE_REFUSAL_CODES as O, errorResult as k, indexedErrorResult as A, indexedMicro509Error as j, micro509Error as M } from "../result/result.js";
15
- import { checkChainRevocation as N } from "../revocation/chain.js";
16
- import { assertCrlMaxAge as P } from "../revocation/crl.js";
17
- import { matchServiceIdentity as F } from "./identity.js";
18
- import { parseCertificateDerOrThrow as I, parseCertificateSigningRequestDerOrThrow as L, parseCertificateSigningRequestPemOrThrow as R } from "../x509/parse.js";
4
+ import { callerVerification as i, resolveSignatureVerifiers as a, verifySignedDataDetailed as o } from "../internal/crypto/sig-verify.js";
5
+ import { compareDistinguishedNames as s } from "../internal/shared/dn.js";
6
+ import { asciiLowercase as c, domainToAscii as l } from "../internal/shared/idna.js";
7
+ import { parseIpAddressToBytes as u } from "../internal/shared/ip.js";
8
+ import { presentedSmtpUtf8MailboxDomain as d } from "../internal/shared/mailbox.js";
9
+ import { createNameConstraintValidationState as f, evaluateNameConstraints as p } from "../internal/verify/name-constraints-engine.js";
10
+ import { createPolicyValidationState as m, evaluatePolicyChain as h } from "../internal/verify/policy-engine.js";
11
+ import { createSpkiDistrustCheck as g } from "../internal/verify/spki-distrust.js";
12
+ import { anchorWorkingKey as _, assertPathBuildingChecks as v, authorityKeyIdentifierMismatch as y, buildChainInternal as b, carriesTrustAnchorKey as x, certificateWorkingKey as S, countCaCertificatesBelowParsed as C, isSelfIssued as w, isWithinValidity as T, loadCertificates as E, loadSingleCertificate as D, signatureChecksWith as O, verifyCertificateSignature as k, workingParametersAt as A } from "../internal/verify/verify-path.js";
13
+ import { normalizeLabelSeparators as j, parsePresentedSrvName as M, parseSrvNameRestriction as N, parseUriNameConstraint as P } from "../internal/x509/general-name-profile.js";
14
+ import { DECODE_REFUSAL_CODES as F, errorResult as I, indexedErrorResult as L, indexedMicro509Error as R, micro509Error as z } from "../result/result.js";
15
+ import { checkChainRevocation as B } from "../revocation/chain.js";
16
+ import { assertClockSkew as V, assertCrlMaxAge as H } from "../revocation/crl.js";
17
+ import { matchServiceIdentity as U } from "./identity.js";
18
+ import { parseCertificateDerOrThrow as W, parseCertificateSigningRequestDerOrThrow as G, parseCertificateSigningRequestPemOrThrow as K } from "../x509/parse.js";
19
19
  // src/verify/verify.ts
20
20
  /**
21
21
  * Public certificate and CSR verification APIs.
@@ -64,10 +64,11 @@ import { parseCertificateDerOrThrow as I, parseCertificateSigningRequestDerOrThr
64
64
  * - `public_key_distrusted` — a certificate or bare trust anchor uses an explicitly distrusted SHA-256 SPKI.
65
65
  * - `certificate_revoked` — revocation evidence confirms a chain certificate is revoked.
66
66
  * - `revocation_indeterminate` — revocation status could not be determined under a hard-fail policy.
67
+ * - `malformed` — a certificate source does not decode as a certificate, or the leaf source holds other than exactly one.
67
68
  * - `unsupported` — a certificate source holds a construct micro509 does not decode (see `ParseCertificateErrorCode`).
68
69
  * - `limit_exceeded` — a certificate source exceeds a micro509 decoding limit (see `ParseCertificateErrorCode`).
69
70
  */
70
- const z = /* @__PURE__ */ "no_trusted_root.issuer_not_found.signature_invalid.certificate_expired.ca_required.key_cert_sign_required.path_length_exceeded.path_building_limit_exceeded.authority_key_identifier_mismatch.extended_key_usage_invalid.subject_alt_name_mismatch.common_name_fallback_suppressed.self_signed_leaf_not_allowed.unrecognized_critical_extension.no_rev_avail_conflict.display_text_oversized.intermediate_eku_constraint.explicit_policy_required.initial_policy_set_not_satisfied.unsupported_initial_name_constraints.unsupported_name_constraints.name_constraints_violated.unsupported_signature_algorithm_parameters.ec_domain_parameters_missing.public_key_distrusted.certificate_revoked.revocation_indeterminate.unsupported.limit_exceeded".split("."), B = /* @__PURE__ */ new Set([
71
+ const q = /* @__PURE__ */ "no_trusted_root.issuer_not_found.signature_invalid.certificate_expired.ca_required.key_cert_sign_required.path_length_exceeded.path_building_limit_exceeded.authority_key_identifier_mismatch.extended_key_usage_invalid.subject_alt_name_mismatch.common_name_fallback_suppressed.self_signed_leaf_not_allowed.unrecognized_critical_extension.no_rev_avail_conflict.display_text_oversized.intermediate_eku_constraint.explicit_policy_required.initial_policy_set_not_satisfied.unsupported_initial_name_constraints.unsupported_name_constraints.name_constraints_violated.unsupported_signature_algorithm_parameters.ec_domain_parameters_missing.public_key_distrusted.certificate_revoked.revocation_indeterminate.malformed.unsupported.limit_exceeded".split("."), J = /* @__PURE__ */ new Set([
71
72
  r.basicConstraints,
72
73
  r.keyUsage,
73
74
  r.extendedKeyUsage,
@@ -87,7 +88,7 @@ const z = /* @__PURE__ */ "no_trusted_root.issuer_not_found.signature_invalid.ce
87
88
  function loadCertificatePool(e, t) {
88
89
  let n = [];
89
90
  for (let [r, i] of e.entries()) try {
90
- n.push(...x([i]));
91
+ n.push(...E([i]));
91
92
  } catch (e) {
92
93
  return certificateSourceFailure(e, {
93
94
  kind: t,
@@ -100,8 +101,8 @@ function loadCertificatePool(e, t) {
100
101
  };
101
102
  }
102
103
  function certificateSourceFailure(e, n) {
103
- let r = t(e, O);
104
- return r === void 0 ? failure("issuer_not_found", "certificate source is malformed or leaf source does not contain exactly one certificate", 0, detail({
104
+ let r = t(e, F);
105
+ return r === void 0 ? failure("malformed", "certificate source is malformed or leaf source does not contain exactly one certificate", 0, detail({
105
106
  actual: e instanceof Error ? e.message : "certificate source is malformed",
106
107
  source: n
107
108
  })) : failure(r.code, r.message, 0, detail({
@@ -116,41 +117,47 @@ function certificateSourceFailure(e, n) {
116
117
  * for that, or {@linkcode verifyCertificateChain} for the all-in-one API.
117
118
  */
118
119
  async function buildCandidatePathRaw(e) {
119
- h(e.maxPathBuildingChecks);
120
- let t = m(e.distrustedSpkiSha256), n;
120
+ v(e.maxPathBuildingChecks);
121
+ let t = g(e.distrustedSpkiSha256), n = O(a(e.signatureVerifiers)), r;
121
122
  try {
122
- n = S(e.leaf);
123
+ r = D(e.leaf);
123
124
  } catch (e) {
124
125
  return certificateSourceFailure(e, void 0);
125
126
  }
126
- let r = loadCertificatePool(e.intermediates ?? [], "intermediates");
127
- if (!r.ok) return r;
128
- let i = loadCertificatePool(e.roots, "roots");
127
+ let i = loadCertificatePool(e.intermediates ?? [], "intermediates");
129
128
  if (!i.ok) return i;
130
- let a = e.trustAnchors ?? [], o = e.at ?? /* @__PURE__ */ new Date(), s = await _(n, r.certificates, i.certificates, a, o, {
129
+ let o = loadCertificatePool(e.roots, "roots");
130
+ if (!o.ok) return o;
131
+ let s = e.trustAnchors ?? [], c = e.at ?? /* @__PURE__ */ new Date(), l = await b(r, i.certificates, o.certificates, s, c, {
131
132
  failure,
132
133
  detail
133
- }, void 0, e.maxPathBuildingChecks, t), c = s.chain;
134
- if (!s.foundTrustedRoot) return s.failure === void 0 ? s.missingIssuerAt === void 0 ? failure("no_trusted_root", "no trusted root found", void 0, detail({ chainCommonNames: c.map((e) => e.subject.values.commonName ?? "<unnamed>") })) : failure("issuer_not_found", "issuer certificate not found", s.missingIssuerAt, buildFailureDetails(c, s.missingIssuerAt)) : s.failure;
135
- let l = c[c.length - 1];
136
- return l === void 0 ? failure("no_trusted_root", "no trusted root found") : {
134
+ }, n, e.maxPathBuildingChecks, t), u = l.chain;
135
+ if (!l.foundTrustedRoot) return l.failure === void 0 ? l.missingIssuerAt === void 0 ? failure("no_trusted_root", "no trusted root found", void 0, detail({ chainCommonNames: u.map((e) => e.subject.values.commonName ?? "<unnamed>") })) : failure("issuer_not_found", "issuer certificate not found", l.missingIssuerAt, buildFailureDetails(u, l.missingIssuerAt)) : l.failure;
136
+ let d = u[u.length - 1];
137
+ return d === void 0 ? failure("no_trusted_root", "no trusted root found") : {
137
138
  ok: !0,
138
139
  value: {
139
- leaf: n,
140
- chain: c,
141
- root: l,
142
- anchorCertificateInChain: s.anchorCertificateInChain ?? !0,
143
- ...s.trustAnchor !== void 0 && { trustAnchor: s.trustAnchor }
140
+ leaf: r,
141
+ chain: u,
142
+ root: d,
143
+ ...l.trustAnchor === void 0 ? { anchorCertificateInChain: !0 } : {
144
+ anchorCertificateInChain: !1,
145
+ trustAnchor: l.trustAnchor
146
+ }
144
147
  }
145
148
  };
146
149
  }
147
150
  /**
148
151
  * Builds a signature-verified path from a leaf certificate to a trusted root.
149
152
  *
150
- * Parses the supplied certificates, walks the issuer chain, signature-checks
151
- * each link, and returns the first valid path. Does not enforce time, constraints,
152
- * or leaf purpose — call {@linkcode validateCandidatePath} or use the all-in-one
153
- * {@linkcode verifyCertificateChain} for full validation.
153
+ * Parses the supplied certificates, walks the issuer chain, and returns the
154
+ * first path whose links pass. Each link checks the signature, the issuer's
155
+ * validity period, CA and keyCertSign constraints, path length, and key
156
+ * identifiers. {@linkcode validateCandidatePath} checks the leaf's validity
157
+ * period, unrecognized critical extensions, certificate policies, name
158
+ * constraints, and leaf purpose. The all-in-one
159
+ * {@linkcode verifyCertificateChain} also checks service identity and
160
+ * revocation.
154
161
  *
155
162
  * @example
156
163
  * ```ts
@@ -179,22 +186,25 @@ async function buildCandidatePath(e) {
179
186
  * assumed trusted and not re-verified.
180
187
  */
181
188
  async function validateCandidatePathRaw(e) {
182
- let t = m(e.distrustedSpkiSha256);
189
+ let t = g(e.distrustedSpkiSha256);
183
190
  if (e.distrustedSpkiSha256?.length && e.anchorCertificateInChain === !1 && e.trustAnchor === void 0) throw RangeError("trustAnchor is required to check distrust on a path with a bare anchor");
184
191
  let n = e.chain, r = await validatePathDistrust(e, t);
185
192
  if (r !== void 0) return r;
186
- let i = e.at ?? /* @__PURE__ */ new Date(), a = buildValidationState(e, n.length);
187
- if (!a.ok) return a;
188
- let o = n[0];
189
- if (o === void 0) return failure("issuer_not_found", "chain is empty", 0);
190
- let s = await validateSelfSignedLeafAllowed(o, n.length, e);
191
- if (s !== void 0) return s;
192
- let c = await validatePathCertificates(n, i, e.rejectOversizedDisplayText === !0);
193
- if (c !== void 0) return c;
194
- let l = validatePathLengthConstraints(n);
195
- if (l !== void 0) return l;
196
- let u = validatePolicyAndNameConstraints(n, a.value, e.anchorCertificateInChain ?? !0);
197
- return u.ok ? validateLeaf(o, e, u.policyValidation) : u;
193
+ let i = e.at ?? /* @__PURE__ */ new Date(), o = buildValidationState(e, n.length);
194
+ if (!o.ok) return o;
195
+ let s = n[0];
196
+ if (s === void 0) return failure("issuer_not_found", "chain is empty", 0);
197
+ let c = a(e.signatureVerifiers), l = pathWorkingParameters(n, e), u = await validateSelfSignedLeafAllowed(s, n.length, e, {
198
+ verifiers: c,
199
+ workingParameters: { parametersDer: l(0) }
200
+ });
201
+ if (u !== void 0) return u;
202
+ let d = await validatePathCertificates(n, i, e.rejectOversizedDisplayText === !0, c, l);
203
+ if (d !== void 0) return d;
204
+ let f = validatePathLengthConstraints(n);
205
+ if (f !== void 0) return f;
206
+ let p = validatePolicyAndNameConstraints(n, o.value, e.anchorCertificateInChain ?? !0);
207
+ return p.ok ? validateLeaf(s, e, p.policyValidation) : p;
198
208
  }
199
209
  /** Checks signed certificate SPKIs and the separately supplied bare anchor. */
200
210
  async function validatePathDistrust(e, t) {
@@ -202,7 +212,7 @@ async function validatePathDistrust(e, t) {
202
212
  for (let [n, r] of e.chain.entries()) {
203
213
  let e;
204
214
  try {
205
- e = I(r.der);
215
+ e = W(r.der);
206
216
  } catch (e) {
207
217
  return {
208
218
  ...certificateSourceFailure(e, void 0),
@@ -221,25 +231,46 @@ async function validatePathDistrust(e, t) {
221
231
  }
222
232
  }
223
233
  }
224
- /** RFC 5280 §3.2 makes a self-issued certificate self-signed only when the public key it binds verifies its signature. */
225
- async function validateSelfSignedLeafAllowed(e, t, n) {
226
- if (t !== 1 || !y(e) || n.allowSelfSignedLeaf === !0) return;
227
- let r = await C(e, e);
228
- if (r.ok && r.valid) return failure("self_signed_leaf_not_allowed", "self-signed leaf not allowed", 0, detail({ subjectCommonName: e.subject.values.commonName }));
234
+ /**
235
+ * RFC 5280 §3.2 makes a self-issued certificate self-signed only when the
236
+ * public key it binds verifies its signature, with the parameters its path
237
+ * gives that key (RFC 5280 §6.1.4 (e)).
238
+ */
239
+ async function validateSelfSignedLeafAllowed(e, t, n, r) {
240
+ if (t !== 1 || !w(e) || n.allowSelfSignedLeaf === !0) return;
241
+ let i = await k(e, e, r);
242
+ if (i.ok && i.valid) return failure("self_signed_leaf_not_allowed", "self-signed leaf not allowed", 0, detail({ subjectCommonName: e.subject.values.commonName }));
243
+ }
244
+ /**
245
+ * RFC 5280 §6.1.2 (g)-(i) and §6.1.4 (e)-(f) along `chain`: the working key
246
+ * parameters for the issuer at each index. The terminal certificate or the bare
247
+ * anchor initializes them.
248
+ */
249
+ function pathWorkingParameters(e, t) {
250
+ let n = e[e.length - 1];
251
+ if (t.anchorCertificateInChain === !1 || n === void 0) {
252
+ let n = t.trustAnchor === void 0 ? {
253
+ algorithmOid: "",
254
+ parametersDer: void 0
255
+ } : _(t.trustAnchor);
256
+ return (t) => A(e, t, e.length - 1, n);
257
+ }
258
+ let r = S(n);
259
+ return (t) => A(e, t, e.length - 2, r);
229
260
  }
230
261
  /** Validates every certificate and issuer relationship in a candidate path. */
231
- async function validatePathCertificates(e, t, n) {
232
- for (let r = 0; r < e.length; r += 1) {
233
- let i = e[r];
234
- if (i === void 0) return failure("issuer_not_found", "chain element missing", r);
235
- let a = validateCertificateAtPathIndex(i, r, t);
236
- if (a !== void 0) return a;
262
+ async function validatePathCertificates(e, t, n, r, i) {
263
+ for (let a = 0; a < e.length; a += 1) {
264
+ let o = e[a];
265
+ if (o === void 0) return failure("issuer_not_found", "chain element missing", a);
266
+ let s = validateCertificateAtPathIndex(o, a, t);
267
+ if (s !== void 0) return s;
237
268
  if (n) {
238
- let e = validateDisplayTextAtPathIndex(i, r);
269
+ let e = validateDisplayTextAtPathIndex(o, a);
239
270
  if (e !== void 0) return e;
240
271
  }
241
- let o = await validatePathIssuerAtIndex(e, i, r);
242
- if (o !== void 0) return o;
272
+ let c = await validatePathIssuerAtIndex(e, o, a, r, i);
273
+ if (c !== void 0) return c;
243
274
  }
244
275
  }
245
276
  /** RFC 5280 §4.2.1.4 bounds a DisplayText at 200 characters; PKITS 4.8.19 lets the application reject a longer explicitText. */
@@ -263,16 +294,16 @@ function validateDisplayTextAtPathIndex(e, t) {
263
294
  }));
264
295
  }
265
296
  }
266
- async function validatePathIssuerAtIndex(e, t, n) {
297
+ async function validatePathIssuerAtIndex(e, t, n, r, i) {
267
298
  if (n === e.length - 1) return;
268
- let r = e[n + 1];
269
- return r === void 0 ? failure("issuer_not_found", "issuer missing", n) : await validateIssuerAtPathIndex(t, r, n);
299
+ let a = e[n + 1];
300
+ return a === void 0 ? failure("issuer_not_found", "issuer missing", n) : await validateIssuerAtPathIndex(t, a, n, r, i(n + 1));
270
301
  }
271
302
  function validatePathLengthConstraints(e) {
272
303
  for (let t = 1; t < e.length; t += 1) {
273
304
  let n = e[t];
274
305
  if (n === void 0) return failure("issuer_not_found", "chain element missing", t);
275
- let r = v(e, t), i = n.basicConstraints?.pathLength;
306
+ let r = C(e, t), i = n.basicConstraints?.pathLength;
276
307
  if (isNonNegativeInteger(i) && r > i) return pathLengthExceededFailure(n, t, i, r);
277
308
  }
278
309
  }
@@ -284,19 +315,19 @@ function pathLengthExceededFailure(e, t, n, r) {
284
315
  }));
285
316
  }
286
317
  function validatePolicyAndNameConstraints(e, t, n) {
287
- let r = p(e, t.policy, n);
318
+ let r = h(e, t.policy, n);
288
319
  if (!r.ok) return failure(r.error.code, r.error.message, 0, detail({
289
320
  expected: r.error.details?.expected,
290
321
  actual: r.error.details?.actual
291
322
  }));
292
- let i = d(e, t.nameConstraints);
323
+ let i = p(e, t.nameConstraints);
293
324
  return i.ok ? {
294
325
  ok: !0,
295
326
  policyValidation: r.value
296
327
  } : i;
297
328
  }
298
329
  function validateCertificateAtPathIndex(e, t, n) {
299
- if (!b(e, n)) return failure("certificate_expired", "certificate not valid at requested time", t, detail({
330
+ if (!T(e, n)) return failure("certificate_expired", "certificate not valid at requested time", t, detail({
300
331
  subjectCommonName: e.subject.values.commonName,
301
332
  expected: describeDateTime(n),
302
333
  actual: `${describeDateTime(e.notBefore)}..${describeDateTime(e.notAfter)}`
@@ -336,25 +367,28 @@ function validateEcDomainParametersAtPathIndex(e, t) {
336
367
  actual: e.publicKeyAlgorithmParametersDer === void 0 ? "absent" : `tag 0x${(e.publicKeyAlgorithmParametersDer[0] ?? 0).toString(16).padStart(2, "0")}`
337
368
  }));
338
369
  }
339
- async function validateIssuerAtPathIndex(e, t, n) {
340
- if (!a(e.issuer, t.subject)) return failure("issuer_not_found", "issuer distinguished name does not match the candidate issuer subject", n, detail({
370
+ async function validateIssuerAtPathIndex(e, t, n, r, i) {
371
+ if (!s(e.issuer, t.subject)) return failure("issuer_not_found", "issuer distinguished name does not match the candidate issuer subject", n, detail({
341
372
  subjectCommonName: e.subject.values.commonName,
342
373
  issuerCommonName: t.subject.values.commonName
343
374
  }));
344
- let r = await C(e, t);
345
- return r.ok ? r.valid ? validateIssuerConstraintsAtPathIndex(e, t, n) : failure("signature_invalid", "certificate signature does not verify", n, detail({
375
+ let a = await k(e, t, {
376
+ verifiers: r,
377
+ workingParameters: { parametersDer: i }
378
+ });
379
+ return a.ok ? a.valid ? validateIssuerConstraintsAtPathIndex(e, t, n) : failure("signature_invalid", "certificate signature does not verify", n, detail({
346
380
  subjectCommonName: e.subject.values.commonName,
347
381
  issuerCommonName: t.subject.values.commonName
348
- })) : failure(r.code, r.reason, n, detail({
382
+ })) : failure(a.code, a.reason, n, detail({
349
383
  subjectCommonName: e.subject.values.commonName,
350
384
  issuerCommonName: t.subject.values.commonName,
351
- actual: r.reason
385
+ actual: a.reason
352
386
  }));
353
387
  }
354
388
  function validateIssuerConstraintsAtPathIndex(e, t, n) {
355
389
  if (t.basicConstraints?.ca !== !0) return failure("ca_required", "issuer must be a CA certificate", n + 1, detail({ subjectCommonName: t.subject.values.commonName }));
356
390
  if (t.keyUsage !== void 0 && !t.keyUsage.flags.includes("keyCertSign")) return failure("key_cert_sign_required", "issuer missing keyCertSign", n + 1, detail({ subjectCommonName: t.subject.values.commonName }));
357
- if (g(e, t)) return failure("authority_key_identifier_mismatch", "authorityKeyIdentifier does not match issuer subjectKeyIdentifier", n, detail({
391
+ if (y(e, t)) return failure("authority_key_identifier_mismatch", "authorityKeyIdentifier does not match issuer subjectKeyIdentifier", n, detail({
358
392
  subjectCommonName: e.subject.values.commonName,
359
393
  issuerCommonName: t.subject.values.commonName,
360
394
  expected: t.subjectKeyIdentifier,
@@ -368,8 +402,8 @@ function validateIssuerConstraintsAtPathIndex(e, t, n) {
368
402
  async function validateCandidatePath(e) {
369
403
  let n = normalizeValidationChain(e.chain);
370
404
  if (!n.ok) {
371
- let { error: e, index: r } = n, i = t(e, O);
372
- return verifyFailureResult(i === void 0 ? failure("signature_invalid", "certificate input is malformed", r, detail({ actual: e instanceof Error ? e.message : "certificate input is malformed" })) : failure(i.code, i.message, r, detail({ actual: i.message })));
405
+ let { error: e, index: r } = n, i = t(e, F);
406
+ return verifyFailureResult(i === void 0 ? failure("malformed", "certificate input is malformed", r, detail({ actual: e instanceof Error ? e.message : "certificate input is malformed" })) : failure(i.code, i.message, r, detail({ actual: i.message })));
373
407
  }
374
408
  let r = await validateCandidatePathRaw({
375
409
  ...e,
@@ -384,6 +418,12 @@ async function validateCandidatePath(e) {
384
418
  * Equivalent to calling {@linkcode buildCandidatePath} followed by
385
419
  * {@linkcode validateCandidatePath} (plus identity matching when configured).
386
420
  *
421
+ * Success authenticates the certification path of `leaf`. Authenticating a
422
+ * remote peer also takes the transport's proof that the peer holds the leaf's
423
+ * private key: pass the certificate the handshake authenticated as `leaf`,
424
+ * the rest of the peer's chain as `intermediates`, and apply authorization to
425
+ * `value.leaf`.
426
+ *
387
427
  * @example
388
428
  * ```ts
389
429
  * import { verifyCertificateChain } from 'micro509';
@@ -401,59 +441,80 @@ async function validateCandidatePath(e) {
401
441
  * ```
402
442
  */
403
443
  async function verifyCertificateChain(e) {
404
- let t = e.distrustedSpkiSha256 === void 0 ? void 0 : [...e.distrustedSpkiSha256];
405
- P(e.revocation?.policy?.crlMaxAgeMs);
406
- let n = await buildCandidatePath({
407
- leaf: e.leaf,
408
- roots: e.roots,
409
- ...e.intermediates !== void 0 && { intermediates: e.intermediates },
410
- ...e.trustAnchors !== void 0 && { trustAnchors: e.trustAnchors },
411
- ...e.at !== void 0 && { at: e.at },
412
- ...e.maxPathBuildingChecks !== void 0 && { maxPathBuildingChecks: e.maxPathBuildingChecks },
413
- ...t !== void 0 && { distrustedSpkiSha256: t }
414
- });
415
- if (!n.ok) return n;
416
- let r = await validateCandidatePath({
417
- chain: n.value.chain,
418
- anchorCertificateInChain: n.value.anchorCertificateInChain,
419
- ...n.value.trustAnchor !== void 0 && { trustAnchor: n.value.trustAnchor },
420
- ...t !== void 0 && { distrustedSpkiSha256: t },
421
- ...e.at !== void 0 && { at: e.at },
422
- ...e.purpose !== void 0 && { purpose: e.purpose },
423
- ...copyValidationInputs(e),
424
- ...e.allowSelfSignedLeaf !== void 0 && { allowSelfSignedLeaf: e.allowSelfSignedLeaf },
425
- ...e.rejectOversizedDisplayText !== void 0 && { rejectOversizedDisplayText: e.rejectOversizedDisplayText }
426
- });
444
+ let t = {
445
+ ...e,
446
+ at: e.at ?? /* @__PURE__ */ new Date()
447
+ }, n = t.distrustedSpkiSha256 === void 0 ? void 0 : [...t.distrustedSpkiSha256];
448
+ H(t.revocation?.policy?.crlMaxAgeMs), V(t.revocation?.policy?.clockSkewMs);
449
+ let r = await buildCandidatePath(chainBuildInput(t, n));
427
450
  if (!r.ok) return r;
428
- if (e.serviceIdentity !== void 0) {
429
- let t = validateServiceIdentity(n.value.leaf, e.serviceIdentity);
430
- if (!t.ok) return verifyFailureResult(t);
451
+ let i = await validateCandidatePath({
452
+ chain: r.value.chain,
453
+ anchorCertificateInChain: r.value.anchorCertificateInChain,
454
+ ...r.value.trustAnchor !== void 0 && { trustAnchor: r.value.trustAnchor },
455
+ ...n !== void 0 && { distrustedSpkiSha256: n },
456
+ ...t.signatureVerifiers !== void 0 && { signatureVerifiers: t.signatureVerifiers },
457
+ ...t.at !== void 0 && { at: t.at },
458
+ ...t.purpose !== void 0 && { purpose: t.purpose },
459
+ ...copyValidationInputs(t),
460
+ ...t.allowSelfSignedLeaf !== void 0 && { allowSelfSignedLeaf: t.allowSelfSignedLeaf },
461
+ ...t.rejectOversizedDisplayText !== void 0 && { rejectOversizedDisplayText: t.rejectOversizedDisplayText }
462
+ });
463
+ if (!i.ok) return i;
464
+ if (t.serviceIdentity !== void 0) {
465
+ let e = validateServiceIdentity(r.value.leaf, t.serviceIdentity);
466
+ if (!e.ok) return verifyFailureResult(e);
431
467
  }
432
- if (e.revocation !== void 0) {
433
- let t = await validateVerifiedChainRevocation(e, n.value.chain);
434
- if (t !== void 0) return t;
468
+ if (t.revocation !== void 0) {
469
+ let e = await validateVerifiedChainRevocation(t, r.value, n);
470
+ if (e !== void 0) return e;
435
471
  }
436
472
  return {
437
473
  ok: !0,
438
474
  value: {
439
- ...n.value,
440
- policyValidation: r.value.policyValidation
475
+ ...r.value,
476
+ policyValidation: i.value.policyValidation
441
477
  }
442
478
  };
443
479
  }
480
+ /** The path-building half of a {@linkcode VerifyCertificateChainInput}. */
481
+ function chainBuildInput(e, t) {
482
+ return {
483
+ leaf: e.leaf,
484
+ roots: e.roots,
485
+ ...e.intermediates !== void 0 && { intermediates: e.intermediates },
486
+ ...e.trustAnchors !== void 0 && { trustAnchors: e.trustAnchors },
487
+ ...e.at !== void 0 && { at: e.at },
488
+ ...e.maxPathBuildingChecks !== void 0 && { maxPathBuildingChecks: e.maxPathBuildingChecks },
489
+ ...e.signatureVerifiers !== void 0 && { signatureVerifiers: e.signatureVerifiers },
490
+ ...t !== void 0 && { distrustedSpkiSha256: t }
491
+ };
492
+ }
493
+ /**
494
+ * The bare anchor that issued the last certificate of `path`. A path that ends
495
+ * with the anchor's own certificate has none: that certificate is the anchor,
496
+ * which revocation checking leaves out.
497
+ */
498
+ function revocationTrustAnchor(e) {
499
+ let t = e.chain[e.chain.length - 1];
500
+ if (e.trustAnchor !== void 0 && t !== void 0) return x(t, e.trustAnchor) ? void 0 : e.trustAnchor;
501
+ }
444
502
  /** Applies optional revocation evidence to an otherwise verified certificate chain. */
445
- async function validateVerifiedChainRevocation(e, t) {
503
+ async function validateVerifiedChainRevocation(e, t, n) {
446
504
  if (e.revocation === void 0) return;
447
- let n = await N({
448
- chain: t,
505
+ let r = revocationTrustAnchor(t), i = await B({
506
+ chain: t.chain,
507
+ ...r !== void 0 && { trustAnchor: r },
449
508
  ...e.revocation.crls === void 0 ? {} : { crls: e.revocation.crls },
450
509
  ...e.revocation.ocspResponses === void 0 ? {} : { ocspResponses: e.revocation.ocspResponses },
451
510
  ...e.revocation.extraCertificates === void 0 ? {} : { extraCertificates: e.revocation.extraCertificates },
452
511
  ...e.revocation.trustedOcspResponders === void 0 ? {} : { trustedOcspResponders: e.revocation.trustedOcspResponders },
453
512
  ...e.revocation.policy === void 0 ? {} : { policy: e.revocation.policy },
454
- ...e.at === void 0 ? {} : { at: e.at }
513
+ ...e.at === void 0 ? {} : { at: e.at },
514
+ ...e.signatureVerifiers === void 0 ? {} : { signatureVerifiers: e.signatureVerifiers },
515
+ ...n === void 0 ? {} : { distrustedSpkiSha256: n }
455
516
  });
456
- return n.value.decision === "deny" ? revocationFailureResult(n.value) : void 0;
517
+ return i.value.decision === "deny" ? revocationFailureResult(i.value) : void 0;
457
518
  }
458
519
  function revocationFailureResult(e) {
459
520
  let t = e.summary.revokedCertificates[0];
@@ -485,33 +546,21 @@ function revocationFailureIndex(e, t) {
485
546
  * }
486
547
  * ```
487
548
  */
488
- async function verifyCertificateSigningRequest(e) {
489
- let n;
549
+ async function verifyCertificateSigningRequest(e, n = {}) {
550
+ let r = i(n.signatureVerifiers), a;
490
551
  try {
491
- n = typeof e == "string" ? R(e) : L(new Uint8Array(e));
552
+ a = typeof e == "string" ? K(e) : G(new Uint8Array(e));
492
553
  } catch (e) {
493
- let n = t(e, O);
494
- return n === void 0 ? verifyRequestFailureResult("signature_invalid", "certificate request input is malformed", detail({ actual: e instanceof Error ? e.message : "certificate request input is malformed" })) : verifyRequestFailureResult(n.code, n.message, detail({ actual: n.message }));
554
+ let n = t(e, F);
555
+ return n === void 0 ? verifyRequestFailureResult("malformed", "certificate request input is malformed", detail({ actual: e instanceof Error ? e.message : "certificate request input is malformed" })) : verifyRequestFailureResult(n.code, n.message, detail({ actual: n.message }));
495
556
  }
496
- let r;
497
- try {
498
- r = await i(n.signatureAlgorithmOid, n.signatureAlgorithmParametersDer, n.publicKeyAlgorithmOid, n.publicKeyParametersOid, n.subjectPublicKeyInfoDer, n.signatureValue, n.certificationRequestInfoDer);
499
- } catch (e) {
500
- let r = t(e, O);
501
- return r === void 0 ? verifyRequestFailureResult("signature_invalid", "certificate request input is malformed", detail({
502
- subjectCommonName: n.subject.values.commonName,
503
- actual: e instanceof Error ? e.message : "certificate request input is malformed"
504
- })) : verifyRequestFailureResult(r.code, r.message, detail({
505
- subjectCommonName: n.subject.values.commonName,
506
- actual: r.message
507
- }));
508
- }
509
- return r.ok ? r.valid ? {
557
+ let s = await o(a.signatureAlgorithmOid, a.signatureAlgorithmParametersDer, a.publicKeyAlgorithmOid, a.publicKeyParametersOid, a.subjectPublicKeyInfoDer, a.signatureValue, a.signatureValueUnusedBits, a.certificationRequestInfoDer, r);
558
+ return s.ok ? s.valid ? {
510
559
  ok: !0,
511
- value: n
512
- } : verifyRequestFailureResult("signature_invalid", "certificate request signature does not verify", detail({ subjectCommonName: n.subject.values.commonName })) : verifyRequestFailureResult(r.code === "verification_error" ? "signature_invalid" : r.code, r.reason, detail({
513
- subjectCommonName: n.subject.values.commonName,
514
- actual: r.reason
560
+ value: a
561
+ } : verifyRequestFailureResult("signature_invalid", "certificate request signature does not verify", detail({ subjectCommonName: a.subject.values.commonName })) : verifyRequestFailureResult(s.code === "verification_error" ? "signature_invalid" : s.code, s.reason, detail({
562
+ subjectCommonName: a.subject.values.commonName,
563
+ actual: s.reason
515
564
  }));
516
565
  }
517
566
  /**
@@ -532,8 +581,8 @@ async function verifyCertificateSigningRequest(e) {
532
581
  function checkExtendedKeyUsage(e, n) {
533
582
  let r = normalizeValidationChain(e);
534
583
  if (!r.ok) {
535
- let e = t(r.error, O);
536
- return e === void 0 ? ekuCheckFailureResult("leaf_eku_missing", "certificate input is malformed", r.index) : ekuCheckFailureResult(e.code, e.message, r.index);
584
+ let e = t(r.error, F);
585
+ return e === void 0 ? ekuCheckFailureResult("malformed", "certificate input is malformed", r.index) : ekuCheckFailureResult(e.code, e.message, r.index);
537
586
  }
538
587
  let i = r.chain, a = i[0];
539
588
  if (a === void 0) return ekuCheckFailureResult("leaf_eku_missing", "chain is empty", 0);
@@ -553,7 +602,7 @@ function trustAnchorFromCertificate(e) {
553
602
  try {
554
603
  t = reparseCertificateForTrust(e);
555
604
  } catch (e) {
556
- throw n(e, O), Error("certificate input is malformed");
605
+ throw n(e, F), Error("certificate input is malformed");
557
606
  }
558
607
  return {
559
608
  subject: t.subject,
@@ -573,6 +622,7 @@ function baseChainInput(e) {
573
622
  ...e.at !== void 0 && { at: e.at },
574
623
  ...e.maxPathBuildingChecks !== void 0 && { maxPathBuildingChecks: e.maxPathBuildingChecks },
575
624
  ...e.distrustedSpkiSha256 !== void 0 && { distrustedSpkiSha256: e.distrustedSpkiSha256 },
625
+ ...e.signatureVerifiers !== void 0 && { signatureVerifiers: e.signatureVerifiers },
576
626
  ...copyValidationInputs(e)
577
627
  };
578
628
  }
@@ -679,7 +729,7 @@ function validateLeaf(e, t, n) {
679
729
  function validateServiceIdentity(e, t) {
680
730
  let n = validateServiceIdentityInput(t);
681
731
  if (!n.ok) return n;
682
- let r = F({
732
+ let r = U({
683
733
  certificate: reparseCertificateForTrust(e),
684
734
  serviceIdentity: t
685
735
  });
@@ -691,7 +741,7 @@ function validateServiceIdentity(e, t) {
691
741
  message: i.message,
692
742
  index: 0,
693
743
  ...i.details === void 0 ? {} : { details: i.details }
694
- } : i.code !== "subject_alt_name_mismatch" && i.code !== "common_name_fallback_suppressed" && i.code !== "unsupported" && i.code !== "limit_exceeded" ? failure("subject_alt_name_mismatch", "service identity input is malformed", 0, detail({
744
+ } : i.code !== "subject_alt_name_mismatch" && i.code !== "common_name_fallback_suppressed" && i.code !== "malformed" && i.code !== "unsupported" && i.code !== "limit_exceeded" ? failure("subject_alt_name_mismatch", "service identity input is malformed", 0, detail({
695
745
  expected: t.value,
696
746
  actual: i.code
697
747
  })) : {
@@ -703,13 +753,13 @@ function validateServiceIdentity(e, t) {
703
753
  };
704
754
  }
705
755
  function validateServiceIdentityInput(e) {
706
- if (!isRecord(e)) return failure("subject_alt_name_mismatch", "service identity input is malformed", 0);
707
- if (e.type !== "dns" && e.type !== "ip" && e.type !== "uri" && e.type !== "srv") return failure("subject_alt_name_mismatch", "service identity input is malformed", 0, detail({ actual: String(e.type) }));
708
- if (typeof e.value != "string") return failure("subject_alt_name_mismatch", "service identity input is malformed", 0, detail({ actual: e.type }));
756
+ if (!isRecord(e)) return failure("malformed", "service identity input is malformed", 0);
757
+ if (e.type !== "dns" && e.type !== "ip" && e.type !== "uri" && e.type !== "srv") return failure("malformed", "service identity input is malformed", 0, detail({ actual: String(e.type) }));
758
+ if (typeof e.value != "string") return failure("malformed", "service identity input is malformed", 0, detail({ actual: e.type }));
709
759
  if (e.type === "ip") try {
710
- c(e.value);
760
+ u(e.value);
711
761
  } catch {
712
- return failure("subject_alt_name_mismatch", "service identity input is malformed", 0, detail({
762
+ return failure("malformed", "service identity input is malformed", 0, detail({
713
763
  expected: e.value,
714
764
  actual: "ip"
715
765
  }));
@@ -728,9 +778,9 @@ async function verifyChainForExtendedKeyUsageProfile(e, t) {
728
778
  }
729
779
  /** Returns the OID of the first critical extension not in {@linkcode PROCESSED_EXTENSION_OIDS}, or `undefined`. */
730
780
  function findUnprocessedCriticalExtension(e) {
731
- for (let t of e.extensions) if (t.critical && (!B.has(t.oid) || t.oid === r.subjectAltName && e.subjectAltNames?.some(isUninterpretedGeneralName) === !0)) return t.oid;
781
+ for (let t of e.extensions) if (t.critical && (!J.has(t.oid) || t.oid === r.subjectAltName && e.subjectAltNames?.some(isUninterpretedGeneralName) === !0)) return t.oid;
732
782
  }
733
- const V = /* @__PURE__ */ new Set([
783
+ const Y = /* @__PURE__ */ new Set([
734
784
  "otherName",
735
785
  "upn",
736
786
  "krb5PrincipalName",
@@ -740,21 +790,21 @@ const V = /* @__PURE__ */ new Set([
740
790
  ]);
741
791
  function isUninterpretedGeneralName(e) {
742
792
  switch (e.type) {
743
- case "srv": return T(o(e.value)) === void 0;
744
- case "smtpUtf8Mailbox": return l(e.value) === void 0;
745
- default: return V.has(e.type);
793
+ case "srv": return M(c(e.value)) === void 0;
794
+ case "smtpUtf8Mailbox": return d(e.value) === void 0;
795
+ default: return Y.has(e.type);
746
796
  }
747
797
  }
748
798
  /** Constructs a {@linkcode VerifyChainFailure} with the given code, message, optional chain index, and details. */
749
799
  function failure(e, t, n, r) {
750
800
  return {
751
801
  ok: !1,
752
- ...j(e, t, n, r)
802
+ ...R(e, t, n, r)
753
803
  };
754
804
  }
755
805
  /** Wraps a {@linkcode VerifyChainFailure} into the standard indexed error result shape. */
756
806
  function verifyFailureResult(e) {
757
- return A(e);
807
+ return L(e);
758
808
  }
759
809
  /** Wraps a policy outcome into the validate-candidate-path success result shape. */
760
810
  function validateCandidatePathSuccessResult(e) {
@@ -784,7 +834,7 @@ function normalizeValidationChain(e) {
784
834
  };
785
835
  }
786
836
  function reparseCertificateForTrust(e) {
787
- return I(new Uint8Array(e.der));
837
+ return W(new Uint8Array(e.der));
788
838
  }
789
839
  /** Returns `true` if the value is a non-negative integer (including zero). */
790
840
  function isNonNegativeInteger(e) {
@@ -794,18 +844,18 @@ function isNonNegativeInteger(e) {
794
844
  function verifyRequestFailureResult(e, t, n) {
795
845
  let r = {
796
846
  ok: !1,
797
- ...M(e, t, n)
847
+ ...z(e, t, n)
798
848
  };
799
- return k(r);
849
+ return I(r);
800
850
  }
801
851
  /** Constructs an EKU check failure result at the given chain index. */
802
852
  function ekuCheckFailureResult(e, t, n) {
803
853
  let r = {
804
854
  ok: !1,
805
- ...j(e, t, n),
855
+ ...R(e, t, n),
806
856
  index: n
807
857
  };
808
- return A(r);
858
+ return L(r);
809
859
  }
810
860
  /** Merges flat and nested policy fields, with nested taking precedence. */
811
861
  function resolvePolicyValidationInput(e) {
@@ -875,12 +925,12 @@ function detail(e) {
875
925
  }
876
926
  /** Initializes policy and name-constraint validation state for a chain walk. */
877
927
  function buildValidationState(e, t) {
878
- let n = f(resolvePolicyValidationInput(e), t), r = validateInitialNameConstraintsInput(resolveInitialNameConstraintsInput(e));
928
+ let n = m(resolvePolicyValidationInput(e), t), r = validateInitialNameConstraintsInput(resolveInitialNameConstraintsInput(e));
879
929
  return r.ok ? {
880
930
  ok: !0,
881
931
  value: {
882
932
  policy: n,
883
- nameConstraints: u(r.value)
933
+ nameConstraints: f(r.value)
884
934
  }
885
935
  } : r;
886
936
  }
@@ -934,12 +984,12 @@ function validateInitialNameConstraintSubtrees(e, t) {
934
984
  function toAsciiInitialNameConstraint(e) {
935
985
  let { base: t } = e;
936
986
  if (t.type !== "dns" && t.type !== "email" && t.type !== "srv") return e;
937
- let n = t.type === "srv" ? w(t.value) : t.value, r = unconvertedConstraintPrefix(t.type, n), i = n.slice(r.length);
987
+ let n = t.type === "srv" ? j(t.value) : t.value, r = unconvertedConstraintPrefix(t.type, n), i = n.slice(r.length);
938
988
  if (t.type !== "srv" && i.endsWith(".")) return;
939
- let a = t.type === "srv" && i.length === 0 ? void 0 : s(i, "lookup");
989
+ let a = t.type === "srv" && i.length === 0 ? void 0 : l(i, "lookup");
940
990
  if (a !== void 0 && !a.ok) return;
941
991
  let o = `${r}${a?.value ?? ""}`;
942
- if (!(!/^[\x20-\x7e]*$/.test(o) || t.type === "srv" && E(o) === void 0)) return {
992
+ if (!(!/^[\x20-\x7e]*$/.test(o) || t.type === "srv" && N(o) === void 0)) return {
943
993
  ...e,
944
994
  base: {
945
995
  ...t,
@@ -960,7 +1010,7 @@ function describeInvalidInitialNameConstraintForm(e) {
960
1010
  if (!isRecord(t) || typeof t.type != "string") return "invalid subtree";
961
1011
  switch (t.type) {
962
1012
  case "dns": return typeof t.value == "string" ? void 0 : t.type;
963
- case "uri": return typeof t.value == "string" && D(t.value) !== void 0 ? void 0 : t.type;
1013
+ case "uri": return typeof t.value == "string" && P(t.value) !== void 0 ? void 0 : t.type;
964
1014
  case "email": return typeof t.value == "string" && !t.value.includes("@") ? void 0 : t.type;
965
1015
  case "srv": return typeof t.value == "string" && t.value.length > 0 ? void 0 : t.type;
966
1016
  case "directoryName": return typeof t.derHex == "string" ? void 0 : t.type;
@@ -978,6 +1028,6 @@ function invalidInitialNameConstraintsFailure(e) {
978
1028
  function isRecord(e) {
979
1029
  return typeof e == "object" && !!e;
980
1030
  }
981
- export { z as VERIFY_ERROR_CODES, buildCandidatePath, checkExtendedKeyUsage, y as isSelfIssuedCertificate, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest };
1031
+ export { q as VERIFY_ERROR_CODES, buildCandidatePath, checkExtendedKeyUsage, w as isSelfIssuedCertificate, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest };
982
1032
 
983
1033
  //# sourceMappingURL=verify.js.map