micro509 0.13.0 → 0.15.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 (165) hide show
  1. package/CHANGELOG.md +2064 -0
  2. package/README.md +111 -183
  3. package/dist/crypto/crypto.d.ts +104 -0
  4. package/dist/crypto/crypto.js +105 -0
  5. package/dist/crypto/crypto.js.map +1 -0
  6. package/dist/crypto.d.ts +4 -0
  7. package/dist/crypto.js +1 -0
  8. package/dist/der/der.d.ts +41 -33
  9. package/dist/der/der.js +26 -24
  10. package/dist/der/der.js.map +1 -1
  11. package/dist/index.d.ts +18 -14
  12. package/dist/index.js +19 -17
  13. package/dist/internal/asn1/asn1.d.ts +3 -6
  14. package/dist/internal/asn1/asn1.js +355 -44
  15. package/dist/internal/asn1/asn1.js.map +1 -1
  16. package/dist/internal/asn1/ber.js +146 -0
  17. package/dist/internal/asn1/ber.js.map +1 -0
  18. package/dist/internal/asn1/decode-refusal.js +29 -0
  19. package/dist/internal/asn1/decode-refusal.js.map +1 -0
  20. package/dist/internal/asn1/der.d.ts +42 -43
  21. package/dist/internal/asn1/der.js +148 -56
  22. package/dist/internal/asn1/der.js.map +1 -1
  23. package/dist/internal/asn1/oids.js +90 -54
  24. package/dist/internal/asn1/oids.js.map +1 -1
  25. package/dist/internal/asn1/oids2.js +1 -2
  26. package/dist/internal/asn1/oids2.js.map +1 -1
  27. package/dist/internal/crypto/algorithm-names.js +5 -2
  28. package/dist/internal/crypto/algorithm-names.js.map +1 -1
  29. package/dist/internal/crypto/ecdsa.js +13 -8
  30. package/dist/internal/crypto/ecdsa.js.map +1 -1
  31. package/dist/internal/crypto/hash.js +1 -2
  32. package/dist/internal/crypto/hash.js.map +1 -1
  33. package/dist/internal/crypto/pbes2.d.ts +51 -0
  34. package/dist/internal/crypto/pbes2.js +86 -34
  35. package/dist/internal/crypto/pbes2.js.map +1 -1
  36. package/dist/internal/crypto/rsa-pss.js +48 -44
  37. package/dist/internal/crypto/rsa-pss.js.map +1 -1
  38. package/dist/internal/crypto/sig-verify.d.ts +28 -0
  39. package/dist/internal/crypto/sig-verify.js +111 -62
  40. package/dist/internal/crypto/sig-verify.js.map +1 -1
  41. package/dist/internal/crypto/signing.d.ts +1 -4
  42. package/dist/internal/crypto/signing.js +28 -29
  43. package/dist/internal/crypto/signing.js.map +1 -1
  44. package/dist/internal/crypto/webcrypto.js +1 -2
  45. package/dist/internal/crypto/webcrypto.js.map +1 -1
  46. package/dist/internal/shared/base64.js +8 -3
  47. package/dist/internal/shared/base64.js.map +1 -1
  48. package/dist/internal/shared/dn.d.ts +13 -0
  49. package/dist/internal/shared/dn.js +101 -48
  50. package/dist/internal/shared/dn.js.map +1 -1
  51. package/dist/internal/shared/idna-tables.js +7217 -0
  52. package/dist/internal/shared/idna-tables.js.map +1 -0
  53. package/dist/internal/shared/idna.js +296 -0
  54. package/dist/internal/shared/idna.js.map +1 -0
  55. package/dist/internal/shared/ip.d.ts +66 -0
  56. package/dist/internal/shared/ip.js +19 -3
  57. package/dist/internal/shared/ip.js.map +1 -1
  58. package/dist/internal/shared/mailbox.js +26 -0
  59. package/dist/internal/shared/mailbox.js.map +1 -0
  60. package/dist/internal/shared/punycode.js +101 -0
  61. package/dist/internal/shared/punycode.js.map +1 -0
  62. package/dist/internal/shared/rfc3454-tables.js +1 -2
  63. package/dist/internal/shared/rfc3454-tables.js.map +1 -1
  64. package/dist/internal/shared/rfc4518-tables.js +119 -0
  65. package/dist/internal/shared/rfc4518-tables.js.map +1 -0
  66. package/dist/internal/shared/uri-host.js +102 -0
  67. package/dist/internal/shared/uri-host.js.map +1 -0
  68. package/dist/internal/verify/name-constraints-engine.js +246 -131
  69. package/dist/internal/verify/name-constraints-engine.js.map +1 -1
  70. package/dist/internal/verify/policy-engine.js +6 -21
  71. package/dist/internal/verify/policy-engine.js.map +1 -1
  72. package/dist/internal/verify/verify-path.d.ts +4 -0
  73. package/dist/internal/verify/verify-path.js +264 -128
  74. package/dist/internal/verify/verify-path.js.map +1 -1
  75. package/dist/internal/x509/directory-name.js +23 -0
  76. package/dist/internal/x509/directory-name.js.map +1 -0
  77. package/dist/internal/x509/extension-bits.js +15 -13
  78. package/dist/internal/x509/extension-bits.js.map +1 -1
  79. package/dist/internal/x509/extension-errors.d.ts +3 -0
  80. package/dist/internal/x509/extension-errors.js +19 -0
  81. package/dist/internal/x509/extension-errors.js.map +1 -0
  82. package/dist/internal/x509/extension-registry.js +157 -81
  83. package/dist/internal/x509/extension-registry.js.map +1 -1
  84. package/dist/internal/x509/general-name-profile.js +129 -0
  85. package/dist/internal/x509/general-name-profile.js.map +1 -0
  86. package/dist/internal/x509/general-name-tags.js +27 -0
  87. package/dist/internal/x509/general-name-tags.js.map +1 -0
  88. package/dist/internal/x509/general-name.js +183 -0
  89. package/dist/internal/x509/general-name.js.map +1 -0
  90. package/dist/internal/x509/name-fields.js +21 -12
  91. package/dist/internal/x509/name-fields.js.map +1 -1
  92. package/dist/internal/x509/or-address.js +217 -0
  93. package/dist/internal/x509/or-address.js.map +1 -0
  94. package/dist/keys/keys.d.ts +124 -95
  95. package/dist/keys/keys.js +362 -214
  96. package/dist/keys/keys.js.map +1 -1
  97. package/dist/keys.d.ts +3 -2
  98. package/dist/keys.js +3 -2
  99. package/dist/pem/pem.d.ts +17 -19
  100. package/dist/pem/pem.js +122 -41
  101. package/dist/pem/pem.js.map +1 -1
  102. package/dist/pem.js +1 -2
  103. package/dist/pkcs/pfx.d.ts +57 -32
  104. package/dist/pkcs/pfx.js +209 -173
  105. package/dist/pkcs/pfx.js.map +1 -1
  106. package/dist/pkcs/pkcs12-mac.d.ts +104 -27
  107. package/dist/pkcs/pkcs12-mac.js +266 -79
  108. package/dist/pkcs/pkcs12-mac.js.map +1 -1
  109. package/dist/pkcs/pkcs7.d.ts +123 -53
  110. package/dist/pkcs/pkcs7.js +314 -238
  111. package/dist/pkcs/pkcs7.js.map +1 -1
  112. package/dist/pkcs.d.ts +5 -4
  113. package/dist/result/result.d.ts +43 -28
  114. package/dist/result/result.js +27 -14
  115. package/dist/result/result.js.map +1 -1
  116. package/dist/result.d.ts +2 -2
  117. package/dist/result.js +1 -2
  118. package/dist/revocation/chain.d.ts +101 -23
  119. package/dist/revocation/chain.js +456 -206
  120. package/dist/revocation/chain.js.map +1 -1
  121. package/dist/revocation/crl.d.ts +140 -65
  122. package/dist/revocation/crl.js +691 -391
  123. package/dist/revocation/crl.js.map +1 -1
  124. package/dist/revocation/ocsp.d.ts +145 -69
  125. package/dist/revocation/ocsp.js +347 -297
  126. package/dist/revocation/ocsp.js.map +1 -1
  127. package/dist/revocation/revocation.d.ts +48 -36
  128. package/dist/revocation/revocation.js +112 -63
  129. package/dist/revocation/revocation.js.map +1 -1
  130. package/dist/revocation.d.ts +5 -5
  131. package/dist/revocation.js +5 -5
  132. package/dist/verify/identity.d.ts +18 -20
  133. package/dist/verify/identity.js +120 -90
  134. package/dist/verify/identity.js.map +1 -1
  135. package/dist/verify/name-constraints.d.ts +1 -4
  136. package/dist/verify/policy.d.ts +15 -8
  137. package/dist/verify/verify.d.ts +86 -46
  138. package/dist/verify/verify.js +309 -143
  139. package/dist/verify/verify.js.map +1 -1
  140. package/dist/verify.d.ts +3 -2
  141. package/dist/verify.js +4 -3
  142. package/dist/x509/certificate.d.ts +50 -28
  143. package/dist/x509/certificate.js +69 -36
  144. package/dist/x509/certificate.js.map +1 -1
  145. package/dist/x509/csr.d.ts +9 -8
  146. package/dist/x509/csr.js +10 -11
  147. package/dist/x509/csr.js.map +1 -1
  148. package/dist/x509/extensions.d.ts +207 -82
  149. package/dist/x509/extensions.js +561 -128
  150. package/dist/x509/extensions.js.map +1 -1
  151. package/dist/x509/fingerprint.d.ts +4 -7
  152. package/dist/x509/fingerprint.js +1 -2
  153. package/dist/x509/fingerprint.js.map +1 -1
  154. package/dist/x509/name-text.d.ts +7 -9
  155. package/dist/x509/name-text.js +20 -4
  156. package/dist/x509/name-text.js.map +1 -1
  157. package/dist/x509/name.d.ts +15 -14
  158. package/dist/x509/name.js +23 -19
  159. package/dist/x509/name.js.map +1 -1
  160. package/dist/x509/parse.d.ts +165 -64
  161. package/dist/x509/parse.js +444 -459
  162. package/dist/x509/parse.js.map +1 -1
  163. package/dist/x509.d.ts +8 -5
  164. package/dist/x509.js +10 -8
  165. package/package.json +90 -65
@@ -1,4 +1,4 @@
1
- //#region src/result/result.ts
1
+ // src/result/result.ts
2
2
  /** Wraps a value in a success result (`{ ok: true, value }`). */
3
3
  function successResult(e) {
4
4
  return {
@@ -17,22 +17,21 @@ function makeResultError(t) {
17
17
  [e]: !0
18
18
  });
19
19
  }
20
- /** Type guard: was `value` thrown by {@link unwrap}? Narrows to {@link ResultError}. */
20
+ /** Type guard: was {@linkcode value} thrown by {@link unwrap}? Narrows to {@link ResultError}. */
21
21
  function isResultError(t) {
22
22
  return t instanceof Error && e in t;
23
23
  }
24
24
  /**
25
- * Explicit escape hatch: returns the success value, or throws a
26
- * {@link ResultError} carrying the structured failure.
25
+ * Explicit escape hatch: returns the success value, or throws a {@link ResultError} carrying the structured failure.
27
26
  *
28
- * Use when you have already validated the input (or prefer exceptions) and the
29
- * Result ceremony is noise. Accepts any of the library's `*Result` types.
27
+ * Use when you have already validated the input (or prefer exceptions) and the Result ceremony is noise.
28
+ * Accepts any of the library's `*Result` types.
30
29
  */
31
30
  function unwrap(e) {
32
31
  if (e.ok) return e.value;
33
32
  throw makeResultError(e.error);
34
33
  }
35
- /** Returns the success value, or `fallback` when the result is a failure. */
34
+ /** Returns the success value, or {@linkcode fallback} when the result is a failure. */
36
35
  function unwrapOr(e, t) {
37
36
  return e.ok ? e.value : t;
38
37
  }
@@ -44,12 +43,11 @@ const t = [
44
43
  SyntaxError
45
44
  ];
46
45
  /**
47
- * Rethrows `error` if it is an invariant/programmer error (`TypeError`,
48
- * `RangeError`, `ReferenceError`, `SyntaxError`); otherwise returns.
46
+ * Rethrows {@link error} if it is an invariant/programmer error ({@link TypeError}, {@link RangeError},
47
+ * {@link ReferenceError}, {@link SyntaxError}); otherwise returns.
49
48
  *
50
- * Boundary wrappers that turn an expected failure into a `Result` should call
51
- * this first, so a genuine crash is never masked as a clean parse/decode
52
- * failure (AGENTS.md: throw only for invariants).
49
+ * Boundary wrappers that turn an expected failure into a `Result` should call this first, so a genuine crash
50
+ * is never masked as a clean parse/decode failure.
53
51
  */
54
52
  function rethrowIfInvariant(e) {
55
53
  if (t.some((t) => e instanceof t)) throw e;
@@ -62,6 +60,16 @@ function micro509Error(e, t, n) {
62
60
  ...n === void 0 ? {} : { details: n }
63
61
  };
64
62
  }
63
+ /**
64
+ * Throws a {@link ResultError} carrying a typed {@link Micro509Error}.
65
+ *
66
+ * The direct-throw counterpart to {@link unwrap}, for builders that reject
67
+ * invalid construction input. Callers branch on `error.code` via
68
+ * {@link isResultError} instead of matching message strings.
69
+ */
70
+ function throwMicro509Error(e, t, n) {
71
+ throw makeResultError(micro509Error(e, t, n));
72
+ }
65
73
  /** Constructs an {@link IndexedMicro509Error} payload with an optional collection index. */
66
74
  function indexedMicro509Error(e, t, n, r) {
67
75
  return {
@@ -107,7 +115,12 @@ function indexedErrorResult(e) {
107
115
  ...e.index === void 0 ? {} : { index: e.index }
108
116
  };
109
117
  }
110
- //#endregion
111
- export { errorResult, failureResult, indexedErrorResult, indexedMicro509Error, isResultError, micro509Error, rethrowIfInvariant, successResult, unwrap, unwrapOr };
118
+ /**
119
+ * Codes a parse boundary returns for input it refuses without calling it
120
+ * malformed: `unsupported` for a construct micro509 does not decode, and
121
+ * `limit_exceeded` for an implementation limit of micro509's own.
122
+ */
123
+ const n = ["unsupported", "limit_exceeded"];
124
+ export { n as DECODE_REFUSAL_CODES, errorResult, failureResult, indexedErrorResult, indexedMicro509Error, isResultError, micro509Error, rethrowIfInvariant, successResult, throwMicro509Error, unwrap, unwrapOr };
112
125
 
113
126
  //# sourceMappingURL=result.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"result.js","names":[],"sources":["../../src/result/result.ts"],"sourcesContent":["/**\n * Internal result helper types and constructors shared by low-level modules.\n *\n * Mirrors the public result model without depending on the public barrel.\n *\n * @module\n */\n\n/**\n * Discriminated `ok` union: either `{ ok: true; value }` or `{ ok: false; error }`.\n *\n * Every fallible public API in micro509 returns a specialization of this type.\n */\nexport type Result<TValue, TError> =\n\t| {\n\t\t\t/** Operation succeeded. */\n\t\t\treadonly ok: true;\n\t\t\t/** Successful payload. */\n\t\t\treadonly value: TValue;\n\t }\n\t| {\n\t\t\t/** Operation failed. */\n\t\t\treadonly ok: false;\n\t\t\t/** Structured error payload. */\n\t\t\treadonly error: TError;\n\t };\n\n/** Failed result with a flattened code/message/details surface for ergonomic matching. */\nexport interface ErrorResult<\n\tTCode extends string,\n\tTDetails,\n\tTError extends Micro509Error<TCode, TDetails>,\n> {\n\t/** Always `false` for failures. */\n\treadonly ok: false;\n\t/** Structured error payload. */\n\treadonly error: TError;\n\t/** Machine-readable failure reason, mirrored from `error.code`. */\n\treadonly code: TCode;\n\t/** Human-readable diagnostic, mirrored from `error.message`. */\n\treadonly message: string;\n\t/** Optional structured context for the failure. */\n\treadonly details?: TDetails;\n}\n\n/** Like {@link ErrorResult} but also carries an index into the collection that was being processed. */\nexport interface IndexedErrorResult<\n\tTCode extends string,\n\tTDetails,\n\tTError extends IndexedMicro509Error<TCode, TDetails>,\n> extends ErrorResult<TCode, TDetails, TError> {\n\t/** Zero-based position of the failing item in the input collection. */\n\treadonly index?: number;\n}\n\n/** Base error shape carried by all failure results in the library. */\nexport interface Micro509Error<TCode extends string, TDetails = Record<never, never>> {\n\t/** Machine-readable failure reason (e.g. `'malformed'`, `'expired'`). */\n\treadonly code: TCode;\n\t/** Human-readable diagnostic message. */\n\treadonly message: string;\n\t/** Optional structured context for the failure. */\n\treadonly details?: TDetails;\n}\n\n/** Like {@link Micro509Error} but includes a positional index for collection-processing APIs. */\nexport interface IndexedMicro509Error<TCode extends string, TDetails = Record<never, never>>\n\textends Micro509Error<TCode, TDetails> {\n\t/** Zero-based position of the failing item in the input collection. */\n\treadonly index?: number;\n}\n\n/** Wraps a value in a success result (`{ ok: true, value }`). */\nexport function successResult<TValue>(value: TValue): {\n\treadonly ok: true;\n\treadonly value: TValue;\n} {\n\treturn { ok: true, value };\n}\n\n/**\n * Error thrown by {@link unwrap} when a result is a failure.\n *\n * Carries the structured {@link Micro509Error} payload so callers using the\n * throwing escape hatch still get the machine-readable `code` and any details.\n */\nexport interface ResultError<\n\tTError extends Micro509Error<string, unknown> = Micro509Error<string, unknown>,\n> extends Error {\n\t/** Machine-readable failure reason, mirrored from `error.code`. */\n\treadonly code: TError['code'];\n\t/** The structured error payload that produced this exception. */\n\treadonly error: TError;\n}\n\n/** Module-private brand so {@link isResultError} cannot be fooled by look-alike objects. */\nconst resultErrorBrand = Symbol('micro509.ResultError');\n\n/** Builds a {@link ResultError}: a branded `Error` (no class) carrying the structured failure. */\nfunction makeResultError<TError extends Micro509Error<string, unknown>>(\n\terror: TError,\n): ResultError<TError> {\n\treturn Object.assign(new Error(`${error.code}: ${error.message}`), {\n\t\tname: 'ResultError',\n\t\tcode: error.code,\n\t\terror,\n\t\t[resultErrorBrand]: true,\n\t});\n}\n\n/** Type guard: was `value` thrown by {@link unwrap}? Narrows to {@link ResultError}. */\nexport function isResultError(value: unknown): value is ResultError {\n\treturn value instanceof Error && resultErrorBrand in value;\n}\n\n/** A minimal fallible-result shape: `{ ok: true, value }` or `{ ok: false, error }`. */\nexport type UnwrappableResult<TValue, TError> =\n\t| { readonly ok: true; readonly value: TValue }\n\t| { readonly ok: false; readonly error: TError };\n\n/**\n * Explicit escape hatch: returns the success value, or throws a\n * {@link ResultError} carrying the structured failure.\n *\n * Use when you have already validated the input (or prefer exceptions) and the\n * Result ceremony is noise. Accepts any of the library's `*Result` types.\n */\nexport function unwrap<TValue, TError extends Micro509Error<string, unknown>>(\n\tresult: UnwrappableResult<TValue, TError>,\n): TValue {\n\tif (result.ok) {\n\t\treturn result.value;\n\t}\n\tthrow makeResultError(result.error);\n}\n\n/** Returns the success value, or `fallback` when the result is a failure. */\nexport function unwrapOr<TValue>(\n\tresult: UnwrappableResult<TValue, unknown>,\n\tfallback: TValue,\n): TValue {\n\treturn result.ok ? result.value : fallback;\n}\n\n/** JS error types that signal a programmer bug / broken invariant rather than malformed input. */\nconst invariantErrorTypes = [TypeError, RangeError, ReferenceError, SyntaxError] as const;\n\n/**\n * Rethrows `error` if it is an invariant/programmer error (`TypeError`,\n * `RangeError`, `ReferenceError`, `SyntaxError`); otherwise returns.\n *\n * Boundary wrappers that turn an expected failure into a `Result` should call\n * this first, so a genuine crash is never masked as a clean parse/decode\n * failure (AGENTS.md: throw only for invariants).\n */\nexport function rethrowIfInvariant(error: unknown): void {\n\tif (invariantErrorTypes.some((type) => error instanceof type)) {\n\t\tthrow error;\n\t}\n}\n\n/** Constructs a {@link Micro509Error} payload. */\nexport function micro509Error<TCode extends string, TDetails = Record<never, never>>(\n\tcode: TCode,\n\tmessage: string,\n\tdetails?: TDetails,\n): Micro509Error<TCode, TDetails> {\n\treturn {\n\t\tcode,\n\t\tmessage,\n\t\t...(details === undefined ? {} : { details }),\n\t};\n}\n\n/** Constructs an {@link IndexedMicro509Error} payload with an optional collection index. */\nexport function indexedMicro509Error<TCode extends string, TDetails = Record<never, never>>(\n\tcode: TCode,\n\tmessage: string,\n\tindex?: number,\n\tdetails?: TDetails,\n): IndexedMicro509Error<TCode, TDetails> {\n\treturn {\n\t\tcode,\n\t\tmessage,\n\t\t...(index === undefined ? {} : { index }),\n\t\t...(details === undefined ? {} : { details }),\n\t};\n}\n\n/** Wraps a {@link Micro509Error} in a flattened {@link ErrorResult}. */\nexport function errorResult<\n\tTCode extends string,\n\tTDetails,\n\tTError extends Micro509Error<TCode, TDetails>,\n>(error: TError): ErrorResult<TCode, TDetails, TError> {\n\treturn {\n\t\tok: false,\n\t\terror,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\t...(error.details === undefined ? {} : { details: error.details }),\n\t};\n}\n\n/**\n * Builds a flattened failure result in one step.\n *\n * Single source of truth for the `{ ok: false, error, code, message }` shape:\n * modules should construct failures with this instead of hand-rolling the\n * object literal. The `error` payload carries the redundant `ok: false`\n * discriminant so it matches the per-operation `*Failure` interfaces\n * (`interface XFailure extends Micro509Error<…> { ok: false }`).\n */\nexport function failureResult<TCode extends string, TDetails = Record<never, never>>(\n\tcode: TCode,\n\tmessage: string,\n\tdetails?: TDetails,\n): ErrorResult<TCode, TDetails, Micro509Error<TCode, TDetails> & { readonly ok: false }> {\n\treturn errorResult({ ok: false, ...micro509Error(code, message, details) });\n}\n\n/** Wraps an {@link IndexedMicro509Error} in a flattened {@link IndexedErrorResult}. */\nexport function indexedErrorResult<\n\tTCode extends string,\n\tTDetails,\n\tTError extends IndexedMicro509Error<TCode, TDetails>,\n>(error: TError): IndexedErrorResult<TCode, TDetails, TError> {\n\treturn {\n\t\tok: false,\n\t\terror,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\t...(error.details === undefined ? {} : { details: error.details }),\n\t\t...(error.index === undefined ? {} : { index: error.index }),\n\t};\n}\n"],"mappings":";;AAyEA,SAAgB,cAAsB,GAGpC;CACD,OAAO;EAAE,IAAI;EAAM;CAAM;AAC1B;;AAkBA,MAAM,IAAmB,OAAO,sBAAsB;;AAGtD,SAAS,gBACR,GACsB;CACtB,OAAO,OAAO,OAAO,gBAAI,MAAM,GAAG,EAAM,KAAK,IAAI,EAAM,SAAS,GAAG;EAClE,MAAM;EACN,MAAM,EAAM;EACZ;GACC,IAAmB;CACrB,CAAC;AACF;;AAGA,SAAgB,cAAc,GAAsC;CACnE,OAAO,aAAiB,SAAS,KAAoB;AACtD;;;;;;;;AAcA,SAAgB,OACf,GACS;CACT,IAAI,EAAO,IACV,OAAO,EAAO;CAEf,MAAM,gBAAgB,EAAO,KAAK;AACnC;;AAGA,SAAgB,SACf,GACA,GACS;CACT,OAAO,EAAO,KAAK,EAAO,QAAQ;AACnC;;AAGA,MAAM,IAAsB;CAAC;CAAW;CAAY;CAAgB;AAAW;;;;;;;;;AAU/E,SAAgB,mBAAmB,GAAsB;CACxD,IAAI,EAAoB,MAAM,MAAS,aAAiB,CAAI,GAC3D,MAAM;AAER;;AAGA,SAAgB,cACf,GACA,GACA,GACiC;CACjC,OAAO;EACN;EACA;EACA,GAAI,MAAY,KAAA,IAAY,CAAC,IAAI,EAAE,WAAQ;CAC5C;AACD;;AAGA,SAAgB,qBACf,GACA,GACA,GACA,GACwC;CACxC,OAAO;EACN;EACA;EACA,GAAI,MAAU,KAAA,IAAY,CAAC,IAAI,EAAE,SAAM;EACvC,GAAI,MAAY,KAAA,IAAY,CAAC,IAAI,EAAE,WAAQ;CAC5C;AACD;;AAGA,SAAgB,YAId,GAAqD;CACtD,OAAO;EACN,IAAI;EACJ;EACA,MAAM,EAAM;EACZ,SAAS,EAAM;EACf,GAAI,EAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,EAAM,QAAQ;CACjE;AACD;;;;;;;;;;AAWA,SAAgB,cACf,GACA,GACA,GACwF;CACxF,OAAO,YAAY;EAAE,IAAI;EAAO,GAAG,cAAc,GAAM,GAAS,CAAO;CAAE,CAAC;AAC3E;;AAGA,SAAgB,mBAId,GAA4D;CAC7D,OAAO;EACN,IAAI;EACJ;EACA,MAAM,EAAM;EACZ,SAAS,EAAM;EACf,GAAI,EAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,EAAM,QAAQ;EAChE,GAAI,EAAM,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,EAAM,MAAM;CAC3D;AACD"}
1
+ {"version":3,"file":"result.js","names":["resultErrorBrand","error","value","result","fallback","invariantErrorTypes","type","details","code","message","index","DECODE_REFUSAL_CODES"],"sources":["../../src/result/result.ts"],"sourcesContent":["/**\n * Internal result helper types and constructors shared by low-level modules.\n *\n * Mirrors the public result model without depending on the public barrel.\n *\n * @module\n */\n\n/**\n * Discriminated `ok` union: either `{ ok: true; value }` or `{ ok: false; error }`.\n *\n * Every fallible public API in micro509 returns a specialization of this type.\n */\nexport type Result<TValue, TError> =\n\t| {\n\t\t\t/** Operation succeeded. */\n\t\t\treadonly ok: true;\n\t\t\t/** Successful payload. */\n\t\t\treadonly value: TValue;\n\t }\n\t| {\n\t\t\t/** Operation failed. */\n\t\t\treadonly ok: false;\n\t\t\t/** Structured error payload. */\n\t\t\treadonly error: TError;\n\t };\n\n/** Failed result with a flattened code/message/details surface for ergonomic matching. */\nexport interface ErrorResult<\n\tTCode extends string,\n\tTDetails,\n\tTError extends Micro509Error<TCode, TDetails>,\n> {\n\t/** Always `false` for failures. */\n\treadonly ok: false;\n\t/** Structured error payload. */\n\treadonly error: TError;\n\t/** Machine-readable failure reason, mirrored from `error.code`. */\n\treadonly code: TCode;\n\t/** Human-readable diagnostic, mirrored from `error.message`. */\n\treadonly message: string;\n\t/** Optional structured context for the failure. */\n\treadonly details?: TDetails;\n}\n\n/** Like {@link ErrorResult} but also carries an index into the collection that was being processed. */\nexport interface IndexedErrorResult<\n\tTCode extends string,\n\tTDetails,\n\tTError extends IndexedMicro509Error<TCode, TDetails>,\n> extends ErrorResult<TCode, TDetails, TError> {\n\t/** Zero-based position of the failing item in the input collection. */\n\treadonly index?: number;\n}\n\n/** Base error shape carried by all failure results in the library. */\nexport interface Micro509Error<TCode extends string, TDetails = Record<never, never>> {\n\t/** Machine-readable failure reason (e.g. `'malformed'`, `'expired'`). */\n\treadonly code: TCode;\n\t/** Human-readable diagnostic message. */\n\treadonly message: string;\n\t/** Optional structured context for the failure. */\n\treadonly details?: TDetails;\n}\n\n/** Like {@link Micro509Error} but includes a positional index for collection-processing APIs. */\nexport interface IndexedMicro509Error<TCode extends string, TDetails = Record<never, never>>\n\textends Micro509Error<TCode, TDetails> {\n\t/** Zero-based position of the failing item in the input collection. */\n\treadonly index?: number;\n}\n\n/** Wraps a value in a success result (`{ ok: true, value }`). */\nexport function successResult<TValue>(value: TValue): {\n\treadonly ok: true;\n\treadonly value: TValue;\n} {\n\treturn { ok: true, value };\n}\n\n/**\n * Exception form of a {@link Micro509Error}: a branded {@link Error} carrying the structured\n * {@linkcode code}, `message`, and any `details`.\n *\n * Thrown by {@link unwrap} for a failed result and by {@link throwMicro509Error} when a builder\n * rejects invalid construction input. Detect with {@link isResultError}.\n */\nexport interface ResultError<\n\tTError extends Micro509Error<string, unknown> = Micro509Error<string, unknown>,\n> extends Error {\n\t/** Machine-readable failure reason, mirrored from `error.code`. */\n\treadonly code: TError['code'];\n\t/** The structured error payload that produced this exception. */\n\treadonly error: TError;\n}\n\n/** Module-private brand so {@link isResultError} cannot be fooled by look-alike objects. */\nconst resultErrorBrand = Symbol('micro509.ResultError');\n\n/** Builds a {@link ResultError}: a branded `Error` (no class) carrying the structured failure. */\nfunction makeResultError<TError extends Micro509Error<string, unknown>>(\n\terror: TError,\n): ResultError<TError> {\n\treturn Object.assign(new Error(`${error.code}: ${error.message}`), {\n\t\tname: 'ResultError',\n\t\tcode: error.code,\n\t\terror,\n\t\t[resultErrorBrand]: true,\n\t});\n}\n\n/** Type guard: was {@linkcode value} thrown by {@link unwrap}? Narrows to {@link ResultError}. */\nexport function isResultError(value: unknown): value is ResultError {\n\treturn value instanceof Error && resultErrorBrand in value;\n}\n\n/** A minimal fallible-result shape: `{ ok: true, value }` or `{ ok: false, error }`. */\nexport type UnwrappableResult<TValue, TError> =\n\t| { readonly ok: true; readonly value: TValue }\n\t| { readonly ok: false; readonly error: TError };\n\n/**\n * Explicit escape hatch: returns the success value, or throws a {@link ResultError} carrying the structured failure.\n *\n * Use when you have already validated the input (or prefer exceptions) and the Result ceremony is noise.\n * Accepts any of the library's `*Result` types.\n */\nexport function unwrap<TValue, TError extends Micro509Error<string, unknown>>(\n\tresult: UnwrappableResult<TValue, TError>,\n): TValue {\n\tif (result.ok) {\n\t\treturn result.value;\n\t}\n\tthrow makeResultError(result.error);\n}\n\n/** Returns the success value, or {@linkcode fallback} when the result is a failure. */\nexport function unwrapOr<TValue>(\n\tresult: UnwrappableResult<TValue, unknown>,\n\tfallback: TValue,\n): TValue {\n\treturn result.ok ? result.value : fallback;\n}\n\n/** JS error types that signal a programmer bug / broken invariant rather than malformed input. */\nconst invariantErrorTypes = [TypeError, RangeError, ReferenceError, SyntaxError] as const;\n\n/**\n * Rethrows {@link error} if it is an invariant/programmer error ({@link TypeError}, {@link RangeError},\n * {@link ReferenceError}, {@link SyntaxError}); otherwise returns.\n *\n * Boundary wrappers that turn an expected failure into a `Result` should call this first, so a genuine crash\n * is never masked as a clean parse/decode failure.\n */\nexport function rethrowIfInvariant(error: unknown): void {\n\tif (invariantErrorTypes.some((type) => error instanceof type)) {\n\t\tthrow error;\n\t}\n}\n\n/** Constructs a {@link Micro509Error} payload. */\nexport function micro509Error<TCode extends string, TDetails = Record<never, never>>(\n\tcode: TCode,\n\tmessage: string,\n\tdetails?: TDetails,\n): Micro509Error<TCode, TDetails> {\n\treturn {\n\t\tcode,\n\t\tmessage,\n\t\t...(details === undefined ? {} : { details }),\n\t};\n}\n\n/**\n * Throws a {@link ResultError} carrying a typed {@link Micro509Error}.\n *\n * The direct-throw counterpart to {@link unwrap}, for builders that reject\n * invalid construction input. Callers branch on `error.code` via\n * {@link isResultError} instead of matching message strings.\n */\nexport function throwMicro509Error<TCode extends string, TDetails = Record<never, never>>(\n\tcode: TCode,\n\tmessage: string,\n\tdetails?: TDetails,\n): never {\n\tthrow makeResultError(micro509Error(code, message, details));\n}\n\n/** Constructs an {@link IndexedMicro509Error} payload with an optional collection index. */\nexport function indexedMicro509Error<TCode extends string, TDetails = Record<never, never>>(\n\tcode: TCode,\n\tmessage: string,\n\tindex?: number,\n\tdetails?: TDetails,\n): IndexedMicro509Error<TCode, TDetails> {\n\treturn {\n\t\tcode,\n\t\tmessage,\n\t\t...(index === undefined ? {} : { index }),\n\t\t...(details === undefined ? {} : { details }),\n\t};\n}\n\n/** Wraps a {@link Micro509Error} in a flattened {@link ErrorResult}. */\nexport function errorResult<\n\tTCode extends string,\n\tTDetails,\n\tTError extends Micro509Error<TCode, TDetails>,\n>(error: TError): ErrorResult<TCode, TDetails, TError> {\n\treturn {\n\t\tok: false,\n\t\terror,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\t...(error.details === undefined ? {} : { details: error.details }),\n\t};\n}\n\n/**\n * Builds a flattened failure result in one step.\n *\n * Single source of truth for the `{ ok: false, error, code, message }` shape:\n * modules should construct failures with this instead of hand-rolling the\n * object literal. The `error` payload carries the redundant `ok: false`\n * discriminant so it matches the per-operation `*Failure` interfaces\n * (`interface XFailure extends Micro509Error<…> { ok: false }`).\n */\nexport function failureResult<TCode extends string, TDetails = Record<never, never>>(\n\tcode: TCode,\n\tmessage: string,\n\tdetails?: TDetails,\n): ErrorResult<TCode, TDetails, Micro509Error<TCode, TDetails> & { readonly ok: false }> {\n\treturn errorResult({ ok: false, ...micro509Error(code, message, details) });\n}\n\n/** Wraps an {@link IndexedMicro509Error} in a flattened {@link IndexedErrorResult}. */\nexport function indexedErrorResult<\n\tTCode extends string,\n\tTDetails,\n\tTError extends IndexedMicro509Error<TCode, TDetails>,\n>(error: TError): IndexedErrorResult<TCode, TDetails, TError> {\n\treturn {\n\t\tok: false,\n\t\terror,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\t...(error.details === undefined ? {} : { details: error.details }),\n\t\t...(error.index === undefined ? {} : { index: error.index }),\n\t};\n}\n\n/**\n * Codes a parse boundary returns for input it refuses without calling it\n * malformed: `unsupported` for a construct micro509 does not decode, and\n * `limit_exceeded` for an implementation limit of micro509's own.\n */\nexport const DECODE_REFUSAL_CODES = ['unsupported', 'limit_exceeded'] as const;\n\n/** One of {@linkcode DECODE_REFUSAL_CODES}. */\nexport type DecodeRefusalCode = (typeof DECODE_REFUSAL_CODES)[number];\n\n/** The codes a parse boundary returns for input it cannot decode: `malformed` and every {@linkcode DecodeRefusalCode}. */\nexport type DecodeFailureCode = 'malformed' | DecodeRefusalCode;\n"],"mappings":";;AAyEA,SAAgB,cAAsB,GAGpC;CACD,OAAO;EAAE,IAAI;EAAM;CAAM;AAC1B;;AAmBA,MAAMA,IAAmB,OAAO,sBAAsB;;AAGtD,SAAS,gBACR,GACsB;CACtB,OAAO,OAAO,OAAO,gBAAI,MAAM,GAAGC,EAAM,KAAK,IAAIA,EAAM,SAAS,GAAG;EAClE,MAAM;EACN,MAAMA,EAAM;EACZ;GACCD,IAAmB;CACrB,CAAC;AACF;;AAGA,SAAgB,cAAc,GAAsC;CACnE,OAAOE,aAAiB,SAASF,KAAoBE;AACtD;;;;;;;AAaA,SAAgB,OACf,GACS;CACT,IAAIC,EAAO,IACV,OAAOA,EAAO;CAEf,MAAM,gBAAgBA,EAAO,KAAK;AACnC;;AAGA,SAAgB,SACf,GACA,GACS;CACT,OAAOA,EAAO,KAAKA,EAAO,QAAQC;AACnC;;AAGA,MAAMC,IAAsB;CAAC;CAAW;CAAY;CAAgB;AAAW;;;;;;;;AAS/E,SAAgB,mBAAmB,GAAsB;CACxD,IAAIA,EAAoB,MAAM,MAASJ,aAAiBK,CAAI,GAC3D,MAAML;AAER;;AAGA,SAAgB,cACf,GACA,GACA,GACiC;CACjC,OAAO;EACN;EACA;EACA,GAAIM,MAAY,KAAA,IAAY,CAAC,IAAI,EAAE,WAAQ;CAC5C;AACD;;;;;;;;AASA,SAAgB,mBACf,GACA,GACA,GACQ;CACR,MAAM,gBAAgB,cAAcC,GAAMC,GAASF,CAAO,CAAC;AAC5D;;AAGA,SAAgB,qBACf,GACA,GACA,GACA,GACwC;CACxC,OAAO;EACN;EACA;EACA,GAAIG,MAAU,KAAA,IAAY,CAAC,IAAI,EAAE,SAAM;EACvC,GAAIH,MAAY,KAAA,IAAY,CAAC,IAAI,EAAE,WAAQ;CAC5C;AACD;;AAGA,SAAgB,YAId,GAAqD;CACtD,OAAO;EACN,IAAI;EACJ;EACA,MAAMN,EAAM;EACZ,SAASA,EAAM;EACf,GAAIA,EAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAASA,EAAM,QAAQ;CACjE;AACD;;;;;;;;;;AAWA,SAAgB,cACf,GACA,GACA,GACwF;CACxF,OAAO,YAAY;EAAE,IAAI;EAAO,GAAG,cAAcO,GAAMC,GAASF,CAAO;CAAE,CAAC;AAC3E;;AAGA,SAAgB,mBAId,GAA4D;CAC7D,OAAO;EACN,IAAI;EACJ;EACA,MAAMN,EAAM;EACZ,SAASA,EAAM;EACf,GAAIA,EAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAASA,EAAM,QAAQ;EAChE,GAAIA,EAAM,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAOA,EAAM,MAAM;CAC3D;AACD;;;;;;AAOA,MAAaU,IAAuB,CAAC,eAAe,gBAAgB"}
package/dist/result.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { ErrorResult, IndexedErrorResult, IndexedMicro509Error, Micro509Error, Result, ResultError, UnwrappableResult, errorResult, failureResult, indexedErrorResult, indexedMicro509Error, isResultError, micro509Error, successResult, unwrap, unwrapOr } from "./result/result.js";
2
- export { type ErrorResult, type IndexedErrorResult, type IndexedMicro509Error, type Micro509Error, type Result, type ResultError, type UnwrappableResult, errorResult, failureResult, indexedErrorResult, indexedMicro509Error, isResultError, micro509Error, successResult, unwrap, unwrapOr };
1
+ import { DECODE_REFUSAL_CODES, DecodeFailureCode, DecodeRefusalCode, ErrorResult, IndexedErrorResult, IndexedMicro509Error, Micro509Error, Result, ResultError, UnwrappableResult, errorResult, failureResult, indexedErrorResult, indexedMicro509Error, isResultError, micro509Error, rethrowIfInvariant, successResult, unwrap, unwrapOr } from "./result/result.js";
2
+ export { DECODE_REFUSAL_CODES, type DecodeFailureCode, type DecodeRefusalCode, type ErrorResult, type IndexedErrorResult, type IndexedMicro509Error, type Micro509Error, type Result, type ResultError, type UnwrappableResult, errorResult, failureResult, indexedErrorResult, indexedMicro509Error, isResultError, micro509Error, rethrowIfInvariant, successResult, unwrap, unwrapOr };
package/dist/result.js CHANGED
@@ -1,2 +1 @@
1
- import { errorResult as e, failureResult as t, indexedErrorResult as n, indexedMicro509Error as r, isResultError as i, micro509Error as a, successResult as o, unwrap as s, unwrapOr as c } from "./result/result.js";
2
- export { e as errorResult, t as failureResult, n as indexedErrorResult, r as indexedMicro509Error, i as isResultError, a as micro509Error, o as successResult, s as unwrap, c as unwrapOr };
1
+ export { DECODE_REFUSAL_CODES, errorResult, failureResult, indexedErrorResult, indexedMicro509Error, isResultError, micro509Error, rethrowIfInvariant, successResult, unwrap, unwrapOr } from "./result/result.js";
@@ -1,22 +1,29 @@
1
+ import { DecodeFailureCode } from "../result/result.js";
1
2
  import { ParsedCertificate } from "../x509/parse.js";
2
- import { CrlSource, RevocationReason } from "./crl.js";
3
- import { OcspResponderRevocationPolicy } from "./ocsp.js";
3
+ import { CrlSource, ParsedRevocationReason, UnrecognizedReasonCodePolicy } from "./crl.js";
4
+ import { OcspResponderRevocationPolicy, ValidateOcspResponseInput } from "./ocsp.js";
4
5
  import { RevocationCertificateSource } from "./revocation.js";
5
- //#region src/revocation/chain.d.ts
6
6
  /**
7
7
  * OCSP response in any supported format.
8
8
  *
9
9
  * Accepts PEM string or DER bytes. Used for
10
10
  * {@linkcode CheckChainRevocationInput.ocspResponses}.
11
11
  */
12
- type OcspResponseSource = string | Uint8Array;
12
+ export type OcspResponseSource = string | Uint8Array;
13
+ /** A locally trusted OCSP responder bound to the CA scope it may serve. */
14
+ export interface TrustedOcspResponder {
15
+ /** Certificate of the CA for whose certificates the responder is trusted. */
16
+ readonly issuerCertificate: RevocationCertificateSource;
17
+ /** Responder certificate trusted within that issuer's scope. */
18
+ readonly responderCertificate: RevocationCertificateSource;
19
+ }
13
20
  /**
14
21
  * Revocation checking policy for {@linkcode checkChainRevocation}.
15
22
  *
16
23
  * Controls how indeterminate results (missing evidence, expired CRLs) affect
17
24
  * the final {@linkcode CheckChainRevocationValue.decision | decision}.
18
25
  */
19
- interface RevocationPolicy {
26
+ export interface RevocationPolicy {
20
27
  /**
21
28
  * How to handle indeterminate status.
22
29
  *
@@ -49,9 +56,40 @@ interface RevocationPolicy {
49
56
  * evidence. Defaults to `'honor-nocheck'`.
50
57
  */
51
58
  readonly ocspResponderRevocation?: OcspResponderRevocationPolicy;
59
+ /**
60
+ * Maximum age of a CRL's `thisUpdate` at the evaluation time, in
61
+ * milliseconds. An older CRL yields no evidence even when it carries no
62
+ * `nextUpdate`. Applies to CRLs for chain certificates, CRL signers and
63
+ * delegated OCSP responders. Unbounded by default, in which case a CRL
64
+ * without `nextUpdate` yields no evidence. RFC 5280 §3.3 leaves the
65
+ * required recency of revocation data to local policy.
66
+ */
67
+ readonly crlMaxAgeMs?: number;
68
+ /**
69
+ * Clock-skew tolerance in milliseconds for CRL and OCSP `thisUpdate`/
70
+ * `nextUpdate` checks. It also widens `crlMaxAgeMs` by the same amount.
71
+ * Defaults to `0`.
72
+ */
73
+ readonly clockSkewMs?: number;
74
+ /**
75
+ * OCSP client profile for every OCSP response. See
76
+ * {@linkcode ValidateOcspResponseInput.profile}. `'rfc9919'` turns a
77
+ * response without `nextUpdate` into `ocsp_next_update_missing`. Defaults
78
+ * to `'rfc6960'`.
79
+ */
80
+ readonly ocspProfile?: ValidateOcspResponseInput["profile"];
81
+ /**
82
+ * Treatment of CRL entries and OCSP responses whose CRLReason is
83
+ * unrecognized, including the CRLs for CRL signers and delegated OCSP
84
+ * responders. See {@linkcode UnrecognizedReasonCodePolicy}. `'reject'`
85
+ * makes that evidence yield `crl_reason_code_unrecognized` or
86
+ * `ocsp_reason_code_unrecognized`, which outranks a `good` verdict from
87
+ * other evidence. Defaults to `'revoked'`.
88
+ */
89
+ readonly unrecognizedReasonCode?: UnrecognizedReasonCodePolicy;
52
90
  }
53
91
  /** Input for {@linkcode checkChainRevocation}. */
54
- interface CheckChainRevocationInput {
92
+ export interface CheckChainRevocationInput {
55
93
  /** Validated certificate chain (leaf first, root last). */
56
94
  readonly chain: readonly ParsedCertificate[];
57
95
  /** CRLs to evaluate. */
@@ -62,10 +100,11 @@ interface CheckChainRevocationInput {
62
100
  readonly extraCertificates?: readonly RevocationCertificateSource[];
63
101
  /**
64
102
  * Explicitly trusted OCSP responder certificates (RFC 6960 §4.2.2.2
65
- * criterion 1). A response signed by one of these is accepted without
66
- * delegated-responder issuance, EKU, and revocation checks.
103
+ * criterion 1), each bound to the issuing CA for which it is authorized.
104
+ * A response signed by a matching responder is accepted without delegated-
105
+ * responder issuance, EKU, and revocation checks only in that issuer scope.
67
106
  */
68
- readonly trustedOcspResponders?: readonly RevocationCertificateSource[];
107
+ readonly trustedOcspResponders?: readonly TrustedOcspResponder[];
69
108
  /** Evaluation time. Defaults to `new Date()`. */
70
109
  readonly at?: Date;
71
110
  /** Revocation policy. */
@@ -82,18 +121,27 @@ interface CheckChainRevocationInput {
82
121
  * `reason_scope_mismatch`, `indirect_crl_scope_mismatch`, `reason_coverage_incomplete`
83
122
  * - **Signer trust**: `crl_signer_not_found`, `crl_signer_not_authorized`,
84
123
  * `crl_signer_revoked`, `crl_signer_indeterminate`, and OCSP equivalents
85
- * - **Freshness**: `crl_expired`, `ocsp_response_expired`
124
+ * - **Freshness**: `crl_expired`, `ocsp_response_expired`,
125
+ * `ocsp_next_update_missing`
126
+ * - **Delta CRL**: `delta_crl_unusable` when an authenticated, current delta
127
+ * CRL cannot settle the status, `delta_crl_retry_limit_exceeded` when delta
128
+ * CRL candidates remain after the attempt limit. Either one outranks a
129
+ * `good` verdict from other evidence.
130
+ * - **Reason code**: `crl_reason_code_unrecognized` and
131
+ * `ocsp_reason_code_unrecognized` when evidence revokes the certificate with
132
+ * an unrecognized CRLReason under `unrecognizedReasonCode: 'reject'`. Either
133
+ * one outranks a `good` verdict from other evidence.
86
134
  */
87
- declare const REVOCATION_INDETERMINATE_REASONS: readonly ["no_applicable_crl", "no_applicable_ocsp", "distribution_point_mismatch", "issuer_name_mismatch", "reason_scope_mismatch", "indirect_crl_scope_mismatch", "reason_coverage_incomplete", "crl_signer_not_found", "crl_signer_not_authorized", "crl_signer_revoked", "crl_signer_indeterminate", "ocsp_responder_not_found", "ocsp_responder_not_authorized", "ocsp_responder_revoked", "ocsp_responder_indeterminate", "crl_expired", "ocsp_response_expired", "ocsp_status_unknown"];
135
+ export declare const REVOCATION_INDETERMINATE_REASONS: readonly ["no_applicable_crl", "no_applicable_ocsp", "distribution_point_mismatch", "issuer_name_mismatch", "reason_scope_mismatch", "indirect_crl_scope_mismatch", "reason_coverage_incomplete", "crl_signer_not_found", "crl_signer_not_authorized", "crl_signer_revoked", "crl_signer_indeterminate", "ocsp_responder_not_found", "ocsp_responder_not_authorized", "ocsp_responder_revoked", "ocsp_responder_indeterminate", "crl_expired", "ocsp_response_expired", "ocsp_next_update_missing", "ocsp_status_unknown", "delta_crl_unusable", "delta_crl_retry_limit_exceeded", "crl_reason_code_unrecognized", "ocsp_reason_code_unrecognized"];
88
136
  /** See the doc comment above {@linkcode REVOCATION_INDETERMINATE_REASONS}. */
89
- type RevocationIndeterminateReason = (typeof REVOCATION_INDETERMINATE_REASONS)[number];
137
+ export type RevocationIndeterminateReason = (typeof REVOCATION_INDETERMINATE_REASONS)[number];
90
138
  /**
91
139
  * Identifies the source of revocation evidence.
92
140
  *
93
141
  * Included in {@linkcode CertificateRevocationStatus}'s `source` when status is
94
142
  * `'good'` or `'revoked'` to indicate which CRL or OCSP response provided the answer.
95
143
  */
96
- interface RevocationSource {
144
+ export interface RevocationSource {
97
145
  /** Whether evidence came from a CRL or OCSP response. */
98
146
  readonly kind: "crl" | "ocsp";
99
147
  /** Certificate that signed the evidence (CRL issuer or OCSP responder). */
@@ -113,7 +161,7 @@ interface RevocationSource {
113
161
  * One entry per certificate in {@linkcode CheckChainRevocationValue.certificates}.
114
162
  * The trust anchor is excluded (never checked for revocation).
115
163
  */
116
- type CertificateRevocationStatus = {
164
+ export type CertificateRevocationStatus = {
117
165
  /** The certificate that was evaluated. */
118
166
  readonly certificate: ParsedCertificate;
119
167
  /** Evidence confirms the certificate is not revoked. */
@@ -136,7 +184,7 @@ type CertificateRevocationStatus = {
136
184
  /** When the certificate was revoked. */
137
185
  readonly revocationDate: Date;
138
186
  /** RFC 5280 CRLReason code, if provided by the CRL/OCSP response. */
139
- readonly reason?: RevocationReason;
187
+ readonly reason?: ParsedRevocationReason;
140
188
  };
141
189
  /** Never present on a `revoked` verdict. */
142
190
  readonly indeterminateReasons?: undefined;
@@ -151,6 +199,22 @@ type CertificateRevocationStatus = {
151
199
  readonly source?: undefined;
152
200
  /** Never present on an `indeterminate` verdict. */
153
201
  readonly revocationInfo?: undefined;
202
+ } | {
203
+ /** The certificate that was evaluated. */
204
+ readonly certificate: ParsedCertificate;
205
+ /** Revocation checking does not apply to the certificate (RFC 9608 §4). */
206
+ readonly status: "skipped";
207
+ /**
208
+ * The extension that exempts the certificate: `'no_rev_avail'` for
209
+ * noRevAvail (RFC 9608 §2) or `'ocsp_nocheck'` for id-pkix-ocsp-nocheck.
210
+ */
211
+ readonly skipReason: "no_rev_avail" | "ocsp_nocheck";
212
+ /** Never present on a `skipped` verdict. */
213
+ readonly source?: undefined;
214
+ /** Never present on a `skipped` verdict. */
215
+ readonly indeterminateReasons?: undefined;
216
+ /** Never present on a `skipped` verdict. */
217
+ readonly revocationInfo?: undefined;
154
218
  };
155
219
  /**
156
220
  * Errors encountered while processing revocation evidence.
@@ -161,9 +225,22 @@ type CertificateRevocationStatus = {
161
225
  *
162
226
  * Collected in {@linkcode CheckChainRevocationValue.executionErrors}.
163
227
  */
164
- interface RevocationExecutionError {
228
+ export type RevocationExecutionError = RevocationParseError | RevocationProcessingError;
229
+ /** Revocation evidence that did not parse. */
230
+ export interface RevocationParseError {
231
+ /** Error category. */
232
+ readonly kind: "parse_error";
233
+ /** `malformed`, or the refusal for evidence micro509 does not decode. */
234
+ readonly code: DecodeFailureCode;
235
+ /** Human-readable error description. */
236
+ readonly message: string;
237
+ /** Which evidence caused the error (e.g., CRL issuer DN). */
238
+ readonly evidenceIdentifier?: string;
239
+ }
240
+ /** Revocation evidence that parsed but could not be processed. */
241
+ export interface RevocationProcessingError {
165
242
  /** Error category. */
166
- readonly kind: "parse_error" | "unsupported_extension" | "internal_error";
243
+ readonly kind: "unsupported_extension" | "internal_error";
167
244
  /** Human-readable error description. */
168
245
  readonly message: string;
169
246
  /** Which evidence caused the error (e.g., CRL issuer DN). */
@@ -176,7 +253,7 @@ interface RevocationExecutionError {
176
253
  * {@linkcode checkChainRevocation}. Contains both the policy decision and
177
254
  * detailed per-certificate findings for debugging.
178
255
  */
179
- interface CheckChainRevocationValue {
256
+ export interface CheckChainRevocationValue {
180
257
  /**
181
258
  * Final policy decision based on {@linkcode RevocationPolicy}.
182
259
  *
@@ -197,7 +274,7 @@ interface CheckChainRevocationValue {
197
274
  readonly executionErrors?: readonly RevocationExecutionError[];
198
275
  }
199
276
  /** Result type for {@linkcode checkChainRevocation}. */
200
- type CheckChainRevocationResult = {
277
+ export type CheckChainRevocationResult = {
201
278
  readonly ok: true;
202
279
  readonly value: CheckChainRevocationValue;
203
280
  };
@@ -205,7 +282,9 @@ type CheckChainRevocationResult = {
205
282
  * Checks revocation status for all certificates in a validated chain.
206
283
  *
207
284
  * Evaluates CRL and OCSP evidence against each certificate (except the trust
208
- * anchor), applies the revocation policy, and returns a unified decision.
285
+ * anchor), applies the revocation policy, and returns a unified decision. A
286
+ * certificate carrying noRevAvail or id-pkix-ocsp-nocheck is reported as
287
+ * `skipped` without consulting evidence (RFC 9608 §4).
209
288
  *
210
289
  * @example
211
290
  * ```ts
@@ -220,7 +299,6 @@ type CheckChainRevocationResult = {
220
299
  * }
221
300
  * ```
222
301
  */
223
- declare function checkChainRevocation(input: CheckChainRevocationInput): Promise<CheckChainRevocationResult>;
224
- //#endregion
225
- export { CertificateRevocationStatus, CheckChainRevocationInput, CheckChainRevocationResult, CheckChainRevocationValue, type CrlSource, OcspResponseSource, REVOCATION_INDETERMINATE_REASONS, RevocationExecutionError, RevocationIndeterminateReason, RevocationPolicy, RevocationSource, checkChainRevocation };
302
+ export declare function checkChainRevocation(input: CheckChainRevocationInput): Promise<CheckChainRevocationResult>;
303
+ export type { CrlSource };
226
304
  //# sourceMappingURL=chain.d.ts.map