micro509 0.12.0 → 0.14.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 (123) hide show
  1. package/README.md +78 -30
  2. package/dist/crypto/crypto.d.ts +73 -0
  3. package/dist/crypto/crypto.js +74 -0
  4. package/dist/crypto/crypto.js.map +1 -0
  5. package/dist/crypto.d.ts +4 -0
  6. package/dist/crypto.js +2 -0
  7. package/dist/der/der.d.ts +127 -0
  8. package/dist/der/der.js +171 -0
  9. package/dist/der/der.js.map +1 -0
  10. package/dist/der.d.ts +4 -0
  11. package/dist/der.js +4 -0
  12. package/dist/index.d.ts +13 -9
  13. package/dist/index.js +17 -15
  14. package/dist/internal/asn1/asn1.d.ts +20 -0
  15. package/dist/internal/asn1/asn1.js +80 -37
  16. package/dist/internal/asn1/asn1.js.map +1 -1
  17. package/dist/internal/asn1/der.d.ts +173 -0
  18. package/dist/internal/asn1/der.js +116 -38
  19. package/dist/internal/asn1/der.js.map +1 -1
  20. package/dist/internal/asn1/oids.js +7 -1
  21. package/dist/internal/asn1/oids2.js +9 -2
  22. package/dist/internal/asn1/oids2.js.map +1 -1
  23. package/dist/internal/crypto/algorithm-names.js +4 -0
  24. package/dist/internal/crypto/algorithm-names.js.map +1 -1
  25. package/dist/internal/crypto/pbes2.d.ts +38 -0
  26. package/dist/internal/crypto/pbes2.js +9 -10
  27. package/dist/internal/crypto/pbes2.js.map +1 -1
  28. package/dist/internal/crypto/rsa-pss.js +2 -0
  29. package/dist/internal/crypto/rsa-pss.js.map +1 -1
  30. package/dist/internal/crypto/sig-verify.d.ts +31 -0
  31. package/dist/internal/crypto/sig-verify.js +10 -8
  32. package/dist/internal/crypto/sig-verify.js.map +1 -1
  33. package/dist/internal/shared/base64.js +7 -1
  34. package/dist/internal/shared/base64.js.map +1 -1
  35. package/dist/internal/shared/dn.d.ts +16 -0
  36. package/dist/internal/shared/dn.js +149 -12
  37. package/dist/internal/shared/dn.js.map +1 -1
  38. package/dist/internal/shared/ip.d.ts +69 -0
  39. package/dist/internal/shared/ip.js +18 -1
  40. package/dist/internal/shared/ip.js.map +1 -1
  41. package/dist/internal/shared/rfc3454-tables.js +1782 -0
  42. package/dist/internal/shared/rfc3454-tables.js.map +1 -0
  43. package/dist/internal/verify/name-constraints-engine.js +47 -15
  44. package/dist/internal/verify/name-constraints-engine.js.map +1 -1
  45. package/dist/internal/verify/policy-engine.js +85 -94
  46. package/dist/internal/verify/policy-engine.js.map +1 -1
  47. package/dist/internal/verify/verify-path.d.ts +7 -0
  48. package/dist/internal/verify/verify-path.js +49 -45
  49. package/dist/internal/verify/verify-path.js.map +1 -1
  50. package/dist/internal/x509/directory-name.js +24 -0
  51. package/dist/internal/x509/directory-name.js.map +1 -0
  52. package/dist/internal/x509/extension-bits.js +14 -11
  53. package/dist/internal/x509/extension-bits.js.map +1 -1
  54. package/dist/internal/x509/extension-errors.d.ts +6 -0
  55. package/dist/internal/x509/extension-errors.js +20 -0
  56. package/dist/internal/x509/extension-errors.js.map +1 -0
  57. package/dist/internal/x509/extension-registry.js +113 -55
  58. package/dist/internal/x509/extension-registry.js.map +1 -1
  59. package/dist/internal/x509/general-name-tags.js +28 -0
  60. package/dist/internal/x509/general-name-tags.js.map +1 -0
  61. package/dist/internal/x509/general-name.js +97 -0
  62. package/dist/internal/x509/general-name.js.map +1 -0
  63. package/dist/internal/x509/name-fields.js +20 -10
  64. package/dist/internal/x509/name-fields.js.map +1 -1
  65. package/dist/keys/keys.d.ts +16 -2
  66. package/dist/keys/keys.js +311 -170
  67. package/dist/keys/keys.js.map +1 -1
  68. package/dist/keys.d.ts +3 -2
  69. package/dist/keys.js +3 -2
  70. package/dist/pem/pem.d.ts +3 -2
  71. package/dist/pem/pem.js +112 -30
  72. package/dist/pem/pem.js.map +1 -1
  73. package/dist/pkcs/pkcs12-mac.js +3 -3
  74. package/dist/pkcs/pkcs12-mac.js.map +1 -1
  75. package/dist/pkcs/pkcs7.d.ts +85 -21
  76. package/dist/pkcs/pkcs7.js +261 -186
  77. package/dist/pkcs/pkcs7.js.map +1 -1
  78. package/dist/pkcs.d.ts +2 -2
  79. package/dist/result/result.d.ts +18 -10
  80. package/dist/result/result.js +20 -12
  81. package/dist/result/result.js.map +1 -1
  82. package/dist/result.d.ts +2 -2
  83. package/dist/result.js +2 -2
  84. package/dist/revocation/chain.js +154 -103
  85. package/dist/revocation/chain.js.map +1 -1
  86. package/dist/revocation/crl.d.ts +13 -2
  87. package/dist/revocation/crl.js +415 -236
  88. package/dist/revocation/crl.js.map +1 -1
  89. package/dist/revocation/ocsp.d.ts +58 -17
  90. package/dist/revocation/ocsp.js +186 -174
  91. package/dist/revocation/ocsp.js.map +1 -1
  92. package/dist/revocation/revocation.d.ts +4 -4
  93. package/dist/revocation/revocation.js +48 -30
  94. package/dist/revocation/revocation.js.map +1 -1
  95. package/dist/revocation.d.ts +4 -4
  96. package/dist/revocation.js +5 -5
  97. package/dist/verify/identity.d.ts +2 -1
  98. package/dist/verify/identity.js +2 -1
  99. package/dist/verify/identity.js.map +1 -1
  100. package/dist/verify/policy.d.ts +6 -1
  101. package/dist/verify/verify.d.ts +18 -3
  102. package/dist/verify/verify.js +66 -41
  103. package/dist/verify/verify.js.map +1 -1
  104. package/dist/verify.d.ts +2 -1
  105. package/dist/verify.js +4 -3
  106. package/dist/x509/certificate.d.ts +36 -13
  107. package/dist/x509/certificate.js +36 -19
  108. package/dist/x509/certificate.js.map +1 -1
  109. package/dist/x509/csr.d.ts +6 -3
  110. package/dist/x509/extensions.d.ts +59 -22
  111. package/dist/x509/extensions.js +384 -117
  112. package/dist/x509/extensions.js.map +1 -1
  113. package/dist/x509/name-text.js +2 -0
  114. package/dist/x509/name-text.js.map +1 -1
  115. package/dist/x509/name.d.ts +8 -5
  116. package/dist/x509/name.js +17 -12
  117. package/dist/x509/name.js.map +1 -1
  118. package/dist/x509/parse.d.ts +104 -18
  119. package/dist/x509/parse.js +127 -163
  120. package/dist/x509/parse.js.map +1 -1
  121. package/dist/x509.d.ts +8 -5
  122. package/dist/x509.js +10 -8
  123. package/package.json +52 -34
@@ -1,6 +1,7 @@
1
1
  import { parseCertificateFromSource as e } from "../x509/parse.js";
2
- import { checkCertificateRevocationAgainstCrl as t, parseCertificateRevocationListDerOrThrow as n, parseCertificateRevocationListPemOrThrow as r, revocationReasonFromCode as i } from "./crl.js";
3
- import { parseOcspResponseDerOrThrow as a, parseOcspResponsePemOrThrow as o, validateOcspResponse as s } from "./ocsp.js";
2
+ import { checkCertificateRevocationAgainstCrl as t, coversAllDistributionPointReasons as n, parseCertificateRevocationListDerOrThrow as r, parseCertificateRevocationListPemOrThrow as i, revocationReasonFromCode as a } from "./crl.js";
3
+ import { verifyCertificateChain as o } from "../verify/verify.js";
4
+ import { parseOcspResponseDerOrThrow as s, parseOcspResponsePemOrThrow as c, validateOcspResponse as l } from "./ocsp.js";
4
5
  //#region src/revocation/chain.ts
5
6
  /**
6
7
  * Granular reasons why revocation status could not be determined.
@@ -15,7 +16,7 @@ import { parseOcspResponseDerOrThrow as a, parseOcspResponsePemOrThrow as o, val
15
16
  * `crl_signer_revoked`, `crl_signer_indeterminate`, and OCSP equivalents
16
17
  * - **Freshness**: `crl_expired`, `ocsp_response_expired`
17
18
  */
18
- const c = [
19
+ const u = [
19
20
  "no_applicable_crl",
20
21
  "no_applicable_ocsp",
21
22
  "distribution_point_mismatch",
@@ -39,7 +40,7 @@ const c = [
39
40
  * Parses a CRL from various source formats.
40
41
  */
41
42
  function parseCrlFromSource(e) {
42
- return typeof e == "object" && "issuer" in e ? e : typeof e == "string" ? r(e) : n(e);
43
+ return typeof e == "object" && "issuer" in e ? e : typeof e == "string" ? i(e) : r(e);
43
44
  }
44
45
  /**
45
46
  * Parses a certificate from various source formats, returning undefined on failure.
@@ -61,26 +62,57 @@ function sameCertificate(e, t) {
61
62
  return !0;
62
63
  }
63
64
  /**
64
- * Searches for a certificate that could have signed the given CRL.
65
- * Matches by AKI/SKI or issuer/subject DN.
65
+ * Yields every certificate that could have signed the given CRL, AKI/SKI
66
+ * matches before DN matches. All candidates are returned so a certificate whose
67
+ * subject DN collides with the genuine CRL issuer cannot shadow it: each is
68
+ * tried against the CRL signature and its own path to the trust anchor.
66
69
  */
67
- function findIndirectCrlIssuer(e, t, n) {
70
+ function findIndirectCrlIssuers(e, t, n) {
68
71
  let r = [];
69
72
  for (let e of t) {
70
73
  let t = parseCertificateSafe(e);
71
74
  t !== void 0 && r.push(t);
72
75
  }
73
- let i = [...r, ...n];
74
- if (e.authorityKeyIdentifier !== void 0) {
75
- for (let t of i) if (t.subjectKeyIdentifier !== void 0 && normalizeHex(e.authorityKeyIdentifier) === normalizeHex(t.subjectKeyIdentifier)) return t;
76
- }
77
- for (let t of i) if (e.issuer.derHex === t.subject.derHex) return t;
76
+ let i = [...r, ...n], a = [], push = (e) => {
77
+ a.some((t) => sameCertificate(t, e)) || a.push(e);
78
+ };
79
+ if (e.authorityKeyIdentifier !== void 0) for (let t of i) t.subjectKeyIdentifier !== void 0 && normalizeHex(e.authorityKeyIdentifier) === normalizeHex(t.subjectKeyIdentifier) && push(t);
80
+ for (let t of i) e.issuer.derHex === t.subject.derHex && push(t);
81
+ return a;
78
82
  }
79
83
  /** Lowercases a hex string for bytewise comparison. */
80
84
  function normalizeHex(e) {
81
85
  return e.toLowerCase();
82
86
  }
83
87
  /**
88
+ * RFC 5280 §6.3.3(f): confirms the CRL issuer certificate has a valid
89
+ * certification path to the same trust anchor as the certificate under test. A
90
+ * signer already inside the validated chain is authorized by construction. The
91
+ * path check runs without revocation to avoid unbounded recursion.
92
+ */
93
+ async function crlSignerChainsToAnchor(e, t, n, r) {
94
+ if (t.some((t) => sameCertificate(t, e))) return !0;
95
+ let i = t[t.length - 1];
96
+ if (i === void 0) return !1;
97
+ let a = [], addCandidate = (t) => {
98
+ sameCertificate(t, e) || sameCertificate(t, i) || a.some((e) => sameCertificate(e, t)) || a.push(t);
99
+ };
100
+ for (let e = 0; e < t.length - 1; e += 1) {
101
+ let n = t[e];
102
+ n !== void 0 && addCandidate(n);
103
+ }
104
+ for (let e of n) {
105
+ let t = parseCertificateSafe(e);
106
+ t !== void 0 && addCandidate(t);
107
+ }
108
+ return (await o({
109
+ leaf: e.der,
110
+ intermediates: a.map((e) => e.der),
111
+ roots: [i.der],
112
+ at: r
113
+ })).ok;
114
+ }
115
+ /**
84
116
  * Builds a unique cache key for a certificate.
85
117
  * Uses issuer DN + serial number which uniquely identifies a cert.
86
118
  */
@@ -120,27 +152,41 @@ function findSignerIssuer(e, t) {
120
152
  * Checks if a CRL signer certificate is revoked by examining available CRLs.
121
153
  * Recursively validates the CRL signer of any CRL used to check revocation.
122
154
  */
123
- async function checkSignerRevocation(e, n, r) {
124
- let i = r.chain.some((e) => sameCertificate(e, n));
125
- for (let i of r.crls) {
126
- let a;
127
- try {
128
- a = parseCrlFromSource(i);
129
- } catch {
130
- continue;
131
- }
132
- let o = await t({
133
- certificate: e,
134
- issuerCertificate: n,
135
- crl: a,
136
- at: r.at
137
- });
138
- if (o.ok) {
139
- if (o.value.status === "revoked") return "resolved-revoked";
140
- if (o.value.status === "good" && await validateCrlSigner(n, r) === "resolved-valid") return "resolved-valid";
141
- }
155
+ async function checkSignerRevocation(e, t, r) {
156
+ let i = r.chain.some((e) => sameCertificate(e, t)), a = /* @__PURE__ */ new Set();
157
+ for (let n of r.crls) {
158
+ let i = await checkSignerAgainstCrl(e, t, n, r);
159
+ if (i.kind === "revoked") return "resolved-revoked";
160
+ for (let e of i.reasons) a.add(e);
161
+ }
162
+ return n(a) || i ? "resolved-valid" : "resolved-indeterminate";
163
+ }
164
+ const d = {
165
+ kind: "reasons",
166
+ reasons: []
167
+ };
168
+ /**
169
+ * Evaluates one CRL against a signer. A CRL that does not parse, does not
170
+ * apply, or is itself signed by a signer that is not known good yields no
171
+ * evidence rather than a verdict.
172
+ */
173
+ async function checkSignerAgainstCrl(e, n, r, i) {
174
+ let a;
175
+ try {
176
+ a = parseCrlFromSource(r);
177
+ } catch {
178
+ return d;
142
179
  }
143
- return i ? "resolved-valid" : "resolved-indeterminate";
180
+ let o = await t({
181
+ certificate: e,
182
+ issuerCertificate: n,
183
+ crl: a,
184
+ at: i.at
185
+ });
186
+ return o.ok ? o.value.status === "revoked" ? { kind: "revoked" } : await validateCrlSigner(n, i) === "resolved-valid" ? {
187
+ kind: "reasons",
188
+ reasons: o.value.coveredReasons
189
+ } : d : d;
144
190
  }
145
191
  /** Builds the `revoked` CertificateRevocationStatus for a CRL hit. */
146
192
  function buildCrlRevokedStatus(e, t, n, r, i) {
@@ -160,7 +206,7 @@ function buildCrlRevokedStatus(e, t, n, r, i) {
160
206
  }
161
207
  /** Parses an OCSP response from PEM string or DER bytes. */
162
208
  function parseOcspResponseFromSource(e) {
163
- return typeof e == "string" ? o(e) : a(e);
209
+ return typeof e == "string" ? c(e) : s(e);
164
210
  }
165
211
  /** Maps a {@linkcode validateOcspResponse} failure code to an indeterminate reason. */
166
212
  function ocspIndeterminateReasonFromFailure(e) {
@@ -176,10 +222,11 @@ function ocspIndeterminateReasonFromFailure(e) {
176
222
  case "issuer_mismatch":
177
223
  case "nonce_mismatch":
178
224
  case "request_mismatch": return "no_applicable_ocsp";
225
+ default: throw Error(`Unhandled ValidateOcspResponse failure code: ${String(e)}`);
179
226
  }
180
227
  }
181
228
  /** Validation failures worth retrying with an explicit responder certificate. */
182
- const l = /* @__PURE__ */ new Set([
229
+ const f = /* @__PURE__ */ new Set([
183
230
  "signature_invalid",
184
231
  "responder_id_mismatch",
185
232
  "responder_chain_invalid",
@@ -196,15 +243,15 @@ async function validateOcspResponseWithResponderFallback(e, t, n, r) {
196
243
  ...n.trustedOcspResponders === void 0 ? {} : { trustedOcspResponders: n.trustedOcspResponders },
197
244
  ...n.policy?.ocspResponderRevocation === void 0 ? {} : { responderRevocationPolicy: n.policy.ocspResponderRevocation },
198
245
  ...n.crls === void 0 ? {} : { responderRevocationCrls: n.crls }
199
- }, a = await s({
246
+ }, a = await l({
200
247
  response: e,
201
248
  ...i
202
249
  });
203
- if (a.ok || !l.has(a.code)) return a;
250
+ if (a.ok || !f.has(a.code)) return a;
204
251
  for (let t of n.extraCertificates ?? []) {
205
252
  let n = parseCertificateSafe(t);
206
253
  if (n === void 0) continue;
207
- let r = await s({
254
+ let r = await l({
208
255
  response: e,
209
256
  ...i,
210
257
  responderCertificate: n
@@ -223,7 +270,7 @@ async function validateOcspResponseWithResponderFallback(e, t, n, r) {
223
270
  * sufficient to attribute the entry to `cert`.
224
271
  */
225
272
  async function evaluateOcspEvidence(e, t, n) {
226
- let { ocspResponses: r = [], at: a = /* @__PURE__ */ new Date() } = n, o = [], s = /* @__PURE__ */ new Set();
273
+ let { ocspResponses: r = [], at: i = /* @__PURE__ */ new Date() } = n, o = [], s = /* @__PURE__ */ new Set();
227
274
  for (let c of r) {
228
275
  let r;
229
276
  try {
@@ -237,13 +284,13 @@ async function evaluateOcspEvidence(e, t, n) {
237
284
  }
238
285
  let l = (r.responses ?? []).find((t) => normalizeHex(t.certId.serialNumberHex) === normalizeHex(e.serialNumberHex));
239
286
  if (l === void 0) continue;
240
- let u = await validateOcspResponseWithResponderFallback(r, t, n, a);
287
+ let u = await validateOcspResponseWithResponderFallback(r, t, n, i);
241
288
  if (!u.ok) {
242
289
  s.add(ocspIndeterminateReasonFromFailure(u.code));
243
290
  continue;
244
291
  }
245
292
  if (l.certStatus === "revoked") {
246
- let t = i(l.revocationReasonCode);
293
+ let t = a(l.revocationReasonCode);
247
294
  return {
248
295
  status: {
249
296
  certificate: e,
@@ -283,80 +330,94 @@ async function evaluateOcspEvidence(e, t, n) {
283
330
  };
284
331
  }
285
332
  /**
286
- * Evaluates revocation status for a single certificate using available CRLs.
287
- * Returns both status and any execution errors encountered.
288
- *
289
- * Tries the chain issuer first; if that fails, searches extraCertificates
290
- * and chain for an indirect CRL issuer that matches the CRL's AKI or issuer DN.
291
- *
292
- * Also validates that CRL signers are not revoked (RFC 5280 §6.3.3).
333
+ * Runs each candidate signer through the full pipeline for one base CRL:
334
+ * signature/applicability, RFC 5280 §6.3.3(f) path to the anchor, then signer
335
+ * revocation. A candidate that verifies the signature but fails a later step
336
+ * does not shadow a subsequent usable signer, so the search continues. Returns
337
+ * a revoked status when one is found; otherwise records good or diagnostic
338
+ * evidence into `state`.
293
339
  */
294
- const u = [
295
- "keyCompromise",
296
- "cACompromise",
297
- "affiliationChanged",
298
- "superseded",
299
- "cessationOfOperation",
300
- "certificateHold",
301
- "privilegeWithdrawn",
302
- "aACompromise"
303
- ];
304
- async function evaluateCrlEvidence(e, t, n, r) {
305
- let { crls: i = [], extraCertificates: a = [], chain: o = [], at: s = /* @__PURE__ */ new Date() } = n, c = {
340
+ async function resolveBaseCrlAgainstSigners(e) {
341
+ let { cert: t, baseCrl: n, applicableDelta: r, crlThisUpdate: i, issuer: a, extraCertificates: o, chain: s, at: c, signerCtx: l, state: u } = e;
342
+ for (let e of collectCrlSignerCandidates(n, a, o, s)) {
343
+ let a = await checkCrlWithIssuer(t, n, r, e, c);
344
+ if (!a.ok) continue;
345
+ if (!await crlSignerChainsToAnchor(e, s, o, c)) {
346
+ u.sawCrlSignerNotAuthorized = !0;
347
+ continue;
348
+ }
349
+ let d = await validateCrlSigner(e, l);
350
+ if (d === "resolved-revoked") {
351
+ u.sawCrlSignerRevoked = !0;
352
+ continue;
353
+ }
354
+ if (d === "resolved-indeterminate") {
355
+ u.sawCrlSignerIndeterminate = !0;
356
+ continue;
357
+ }
358
+ if (a.value.status === "revoked") return buildCrlRevokedStatus(t, e, i, a.value.revocationDate, a.value.reasonCode);
359
+ recordGoodCrlEvidence(u, e, i, a.value.coveredReasons);
360
+ return;
361
+ }
362
+ }
363
+ async function evaluateCrlEvidence(e, t, r, i) {
364
+ let { crls: a = [], extraCertificates: o = [], chain: s = [], at: c = /* @__PURE__ */ new Date() } = r, l = {
306
365
  executionErrors: [],
307
366
  coveredReasons: /* @__PURE__ */ new Set(),
308
367
  sawCrlSignerRevoked: !1,
309
368
  sawCrlSignerIndeterminate: !1,
369
+ sawCrlSignerNotAuthorized: !1,
310
370
  sawGood: !1
311
- }, l = parseCrlEvidenceSources(i, c.executionErrors), d = l.filter((e) => e.baseCrlNumber === void 0), f = l.filter((e) => e.baseCrlNumber !== void 0);
371
+ }, u = parseCrlEvidenceSources(a, l.executionErrors), d = u.filter((e) => e.baseCrlNumber === void 0), f = u.filter((e) => e.baseCrlNumber !== void 0);
312
372
  for (let n of d) {
313
- let i = findApplicableDeltaCrl(n, f), l = await checkCrlWithAvailableIssuers(e, n, i, t, a, o, s);
314
- if (!l.result.ok) continue;
315
- let u = await validateCrlSigner(l.signer, r);
316
- if (u === "resolved-revoked") {
317
- c.sawCrlSignerRevoked = !0;
318
- continue;
319
- }
320
- if (u === "resolved-indeterminate") {
321
- c.sawCrlSignerIndeterminate = !0;
322
- continue;
323
- }
324
- let d = i !== void 0 && i.thisUpdate.getTime() > n.thisUpdate.getTime() ? i.thisUpdate : n.thisUpdate;
325
- if (l.result.value.status === "revoked") return {
326
- status: buildCrlRevokedStatus(e, l.signer, d, l.result.value.revocationDate, l.result.value.reasonCode),
327
- executionErrors: c.executionErrors
373
+ let r = findApplicableDeltaCrl(n, f), a = await resolveBaseCrlAgainstSigners({
374
+ cert: e,
375
+ baseCrl: n,
376
+ applicableDelta: r,
377
+ crlThisUpdate: r !== void 0 && r.thisUpdate.getTime() > n.thisUpdate.getTime() ? r.thisUpdate : n.thisUpdate,
378
+ issuer: t,
379
+ extraCertificates: o,
380
+ chain: s,
381
+ at: c,
382
+ signerCtx: i,
383
+ state: l
384
+ });
385
+ if (a !== void 0) return {
386
+ status: a,
387
+ executionErrors: l.executionErrors
328
388
  };
329
- recordGoodCrlEvidence(c, l.signer, d, n);
330
389
  }
331
- if (c.sawGood && c.freshestGood !== void 0) return u.every((e) => c.coveredReasons.has(e)) ? {
390
+ return l.sawGood && l.freshestGood !== void 0 ? n(l.coveredReasons) ? {
332
391
  status: {
333
392
  certificate: e,
334
393
  status: "good",
335
394
  source: {
336
395
  kind: "crl",
337
- signerCertificate: c.freshestGood.signer,
338
- thisUpdate: c.freshestGood.thisUpdate
396
+ signerCertificate: l.freshestGood.signer,
397
+ thisUpdate: l.freshestGood.thisUpdate
339
398
  }
340
399
  },
341
- executionErrors: c.executionErrors
400
+ executionErrors: l.executionErrors
342
401
  } : {
343
402
  status: {
344
403
  certificate: e,
345
404
  status: "indeterminate",
346
405
  indeterminateReasons: ["reason_coverage_incomplete"]
347
406
  },
348
- executionErrors: c.executionErrors
349
- };
350
- let p = [];
351
- return c.sawCrlSignerRevoked ? p.push("crl_signer_revoked") : c.sawCrlSignerIndeterminate ? p.push("crl_signer_indeterminate") : p.push("no_applicable_crl"), {
407
+ executionErrors: l.executionErrors
408
+ } : {
352
409
  status: {
353
410
  certificate: e,
354
411
  status: "indeterminate",
355
- indeterminateReasons: p
412
+ indeterminateReasons: [crlUnavailableReason(l)]
356
413
  },
357
- executionErrors: c.executionErrors
414
+ executionErrors: l.executionErrors
358
415
  };
359
416
  }
417
+ /** Most specific indeterminate reason when no CRL yielded a usable verdict. */
418
+ function crlUnavailableReason(e) {
419
+ return e.sawCrlSignerRevoked ? "crl_signer_revoked" : e.sawCrlSignerNotAuthorized ? "crl_signer_not_authorized" : e.sawCrlSignerIndeterminate ? "crl_signer_indeterminate" : "no_applicable_crl";
420
+ }
360
421
  /** Parses complete and delta CRL evidence while retaining source provenance. */
361
422
  function parseCrlEvidenceSources(e, t) {
362
423
  let n = [];
@@ -373,21 +434,11 @@ function parseCrlEvidenceSources(e, t) {
373
434
  function findApplicableDeltaCrl(e, t) {
374
435
  return t.find((t) => t.issuer.derHex === e.issuer.derHex && t.baseCrlNumber !== void 0 && e.crlNumber !== void 0 && BigInt(t.baseCrlNumber) <= BigInt(e.crlNumber));
375
436
  }
376
- /** Evaluates a CRL against each available issuer until applicable evidence is found. */
377
- async function checkCrlWithAvailableIssuers(e, t, n, r, i, a, o) {
378
- let s = await checkCrlWithIssuer(e, t, n, r, o);
379
- if (s.ok) return {
380
- result: s,
381
- signer: r
382
- };
383
- let c = findIndirectCrlIssuer(t, i, a);
384
- return c === void 0 || sameCertificate(c, r) ? {
385
- result: s,
386
- signer: r
387
- } : {
388
- result: await checkCrlWithIssuer(e, t, n, c, o),
389
- signer: c
390
- };
437
+ /** The direct issuer first, then deduplicated indirect CRL-issuer candidates. */
438
+ function collectCrlSignerCandidates(e, t, n, r) {
439
+ let i = [t];
440
+ for (let t of findIndirectCrlIssuers(e, n, r)) i.some((e) => sameCertificate(e, t)) || i.push(t);
441
+ return i;
391
442
  }
392
443
  function checkCrlWithIssuer(e, n, r, i, a) {
393
444
  return t({
@@ -403,7 +454,7 @@ function recordGoodCrlEvidence(e, t, n, r) {
403
454
  signer: t,
404
455
  thisUpdate: n
405
456
  });
406
- for (let t of r.issuingDistributionPoint?.onlySomeReasons?.flags ?? u) e.coveredReasons.add(t);
457
+ for (let t of r) e.coveredReasons.add(t);
407
458
  }
408
459
  /**
409
460
  * Evaluates revocation status for a single certificate by combining OCSP and
@@ -498,6 +549,6 @@ async function checkChainRevocation(e) {
498
549
  };
499
550
  }
500
551
  //#endregion
501
- export { c as REVOCATION_INDETERMINATE_REASONS, checkChainRevocation };
552
+ export { u as REVOCATION_INDETERMINATE_REASONS, checkChainRevocation };
502
553
 
503
554
  //# sourceMappingURL=chain.js.map