micro509 0.14.0 → 0.16.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 (164) hide show
  1. package/CHANGELOG.md +2119 -0
  2. package/README.md +105 -225
  3. package/dist/crypto/crypto.d.ts +42 -11
  4. package/dist/crypto/crypto.js +53 -22
  5. package/dist/crypto/crypto.js.map +1 -1
  6. package/dist/crypto.d.ts +2 -2
  7. package/dist/crypto.js +1 -2
  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 +11 -11
  12. package/dist/index.js +19 -19
  13. package/dist/internal/asn1/asn1.d.ts +3 -6
  14. package/dist/internal/asn1/asn1.js +343 -43
  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 +38 -41
  21. package/dist/internal/asn1/der.js +131 -52
  22. package/dist/internal/asn1/der.js.map +1 -1
  23. package/dist/internal/asn1/oids.js +83 -53
  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 +1 -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 +24 -11
  34. package/dist/internal/crypto/pbes2.js +79 -26
  35. package/dist/internal/crypto/pbes2.js.map +1 -1
  36. package/dist/internal/crypto/rsa-pss.js +46 -44
  37. package/dist/internal/crypto/rsa-pss.js.map +1 -1
  38. package/dist/internal/crypto/sig-verify.d.ts +4 -7
  39. package/dist/internal/crypto/sig-verify.js +107 -60
  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 +1 -2
  47. package/dist/internal/shared/base64.js.map +1 -1
  48. package/dist/internal/shared/dn.d.ts +3 -6
  49. package/dist/internal/shared/dn.js +99 -53
  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 +4 -7
  56. package/dist/internal/shared/ip.js +1 -2
  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/spki-distrust.js +23 -0
  73. package/dist/internal/verify/spki-distrust.js.map +1 -0
  74. package/dist/internal/verify/verify-path.d.ts +1 -4
  75. package/dist/internal/verify/verify-path.js +282 -129
  76. package/dist/internal/verify/verify-path.js.map +1 -1
  77. package/dist/internal/x509/directory-name.js +1 -2
  78. package/dist/internal/x509/directory-name.js.map +1 -1
  79. package/dist/internal/x509/extension-bits.js +2 -3
  80. package/dist/internal/x509/extension-bits.js.map +1 -1
  81. package/dist/internal/x509/extension-errors.d.ts +1 -4
  82. package/dist/internal/x509/extension-errors.js +1 -2
  83. package/dist/internal/x509/extension-errors.js.map +1 -1
  84. package/dist/internal/x509/extension-registry.js +107 -89
  85. package/dist/internal/x509/extension-registry.js.map +1 -1
  86. package/dist/internal/x509/general-name-profile.js +129 -0
  87. package/dist/internal/x509/general-name-profile.js.map +1 -0
  88. package/dist/internal/x509/general-name-tags.js +1 -2
  89. package/dist/internal/x509/general-name-tags.js.map +1 -1
  90. package/dist/internal/x509/general-name.js +128 -42
  91. package/dist/internal/x509/general-name.js.map +1 -1
  92. package/dist/internal/x509/name-fields.js +1 -2
  93. package/dist/internal/x509/name-fields.js.map +1 -1
  94. package/dist/internal/x509/or-address.js +217 -0
  95. package/dist/internal/x509/or-address.js.map +1 -0
  96. package/dist/keys/keys.d.ts +122 -104
  97. package/dist/keys/keys.js +211 -204
  98. package/dist/keys/keys.js.map +1 -1
  99. package/dist/keys.d.ts +3 -3
  100. package/dist/pem/pem.d.ts +14 -17
  101. package/dist/pem/pem.js +16 -17
  102. package/dist/pem/pem.js.map +1 -1
  103. package/dist/pem.js +1 -2
  104. package/dist/pkcs/pfx.d.ts +57 -32
  105. package/dist/pkcs/pfx.js +209 -173
  106. package/dist/pkcs/pfx.js.map +1 -1
  107. package/dist/pkcs/pkcs12-mac.d.ts +104 -27
  108. package/dist/pkcs/pkcs12-mac.js +266 -79
  109. package/dist/pkcs/pkcs12-mac.js.map +1 -1
  110. package/dist/pkcs/pkcs7.d.ts +43 -37
  111. package/dist/pkcs/pkcs7.js +218 -217
  112. package/dist/pkcs/pkcs7.js.map +1 -1
  113. package/dist/pkcs.d.ts +4 -3
  114. package/dist/result/result.d.ts +27 -20
  115. package/dist/result/result.js +8 -3
  116. package/dist/result/result.js.map +1 -1
  117. package/dist/result.d.ts +2 -2
  118. package/dist/result.js +1 -2
  119. package/dist/revocation/chain.d.ts +101 -23
  120. package/dist/revocation/chain.js +436 -182
  121. package/dist/revocation/chain.js.map +1 -1
  122. package/dist/revocation/crl.d.ts +131 -67
  123. package/dist/revocation/crl.js +443 -327
  124. package/dist/revocation/crl.js.map +1 -1
  125. package/dist/revocation/ocsp.d.ts +94 -59
  126. package/dist/revocation/ocsp.js +331 -293
  127. package/dist/revocation/ocsp.js.map +1 -1
  128. package/dist/revocation/revocation.d.ts +47 -35
  129. package/dist/revocation/revocation.js +88 -57
  130. package/dist/revocation/revocation.js.map +1 -1
  131. package/dist/revocation.d.ts +3 -3
  132. package/dist/verify/identity.d.ts +16 -19
  133. package/dist/verify/identity.js +118 -89
  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 +9 -7
  137. package/dist/verify/verify.d.ts +115 -46
  138. package/dist/verify/verify.js +373 -183
  139. package/dist/verify/verify.js.map +1 -1
  140. package/dist/verify.d.ts +2 -2
  141. package/dist/x509/certificate.d.ts +20 -21
  142. package/dist/x509/certificate.js +62 -46
  143. package/dist/x509/certificate.js.map +1 -1
  144. package/dist/x509/csr.d.ts +5 -7
  145. package/dist/x509/csr.js +10 -11
  146. package/dist/x509/csr.js.map +1 -1
  147. package/dist/x509/extensions.d.ts +154 -66
  148. package/dist/x509/extensions.js +317 -151
  149. package/dist/x509/extensions.js.map +1 -1
  150. package/dist/x509/fingerprint.d.ts +15 -7
  151. package/dist/x509/fingerprint.js +20 -3
  152. package/dist/x509/fingerprint.js.map +1 -1
  153. package/dist/x509/name-text.d.ts +7 -9
  154. package/dist/x509/name-text.js +18 -4
  155. package/dist/x509/name-text.js.map +1 -1
  156. package/dist/x509/name.d.ts +9 -11
  157. package/dist/x509/name.js +18 -19
  158. package/dist/x509/name.js.map +1 -1
  159. package/dist/x509/parse.d.ts +84 -69
  160. package/dist/x509/parse.js +421 -400
  161. package/dist/x509/parse.js.map +1 -1
  162. package/dist/x509.d.ts +3 -3
  163. package/dist/x509.js +3 -3
  164. package/package.json +76 -59
@@ -1,15 +1,19 @@
1
1
  import { PolicyQualifierInfo } from "../x509/extensions.js";
2
- //#region src/verify/policy.d.ts
3
2
  /**
4
3
  * Input for the policy-validation engine.
5
4
  *
6
5
  * All fields are optional — omitted values produce the most permissive
7
6
  * behavior (accept any policy, allow mappings, allow anyPolicy).
8
7
  */
9
- interface PolicyValidationInput {
8
+ export interface PolicyValidationInput {
10
9
  /**
11
10
  * OIDs the relying party considers acceptable, or `'any'` to accept
12
- * whatever the chain asserts. Default: `'any'`.
11
+ * whatever the chain asserts. A list holding the anyPolicy OID
12
+ * (`2.5.29.32.0`) means `'any'`. A list with a malformed OID matches
13
+ * nothing. Unlike RFC 9618 §5.5, which accepts a path whose
14
+ * user-constrained policy set is empty while explicit policy is not
15
+ * required, validation fails when a supplied list is not satisfied, as the
16
+ * application restriction §5.1 allows. Default: `'any'`.
13
17
  */
14
18
  readonly initialPolicySet?: readonly string[] | "any";
15
19
  /** When `true`, the chain must assert at least one acceptable policy. Default: `false`. */
@@ -20,14 +24,14 @@ interface PolicyValidationInput {
20
24
  readonly inhibitAnyPolicy?: boolean;
21
25
  }
22
26
  /** One policy OID that survives RFC 5280 / RFC 9618 processing. */
23
- interface ConstrainedPolicy {
27
+ export interface ConstrainedPolicy {
24
28
  /** Dotted-decimal OID of the surviving policy. */
25
29
  readonly policyIdentifier: string;
26
30
  /** Qualifier info (CPS URIs, user notices) attached to this policy, if any. */
27
31
  readonly policyQualifiers?: readonly PolicyQualifierInfo[];
28
32
  }
29
33
  /** Final policy outputs exposed by successful path-validation APIs. */
30
- interface PolicyValidationOutcome {
34
+ export interface PolicyValidationOutcome {
31
35
  /** Policies valid under the authority's (CA chain) constraints alone. */
32
36
  readonly authorityConstrainedPolicies: readonly ConstrainedPolicy[];
33
37
  /**
@@ -38,6 +42,4 @@ interface PolicyValidationOutcome {
38
42
  */
39
43
  readonly userConstrainedPolicies: readonly ConstrainedPolicy[];
40
44
  }
41
- //#endregion
42
- export { ConstrainedPolicy, PolicyValidationInput, PolicyValidationOutcome };
43
45
  //# sourceMappingURL=policy.d.ts.map
@@ -1,28 +1,27 @@
1
- import { ErrorResult, IndexedErrorResult, IndexedMicro509Error, Micro509Error } from "../result/result.js";
1
+ import { DecodeRefusalCode, ErrorResult, IndexedErrorResult, IndexedMicro509Error, Micro509Error } from "../result/result.js";
2
2
  import { ParsedCertificate, ParsedCertificateSigningRequest, ParsedName } from "../x509/parse.js";
3
3
  import { CrlSource } from "../revocation/crl.js";
4
4
  import { RevocationCertificateSource } from "../revocation/revocation.js";
5
- import { RevocationPolicy } from "../revocation/chain.js";
5
+ import { RevocationPolicy, TrustedOcspResponder } from "../revocation/chain.js";
6
6
  import { DnsServiceIdentityInput, IpServiceIdentityInput, MatchServiceIdentityErrorCode, MatchServiceIdentityFailure, MatchServiceIdentityFailureDetails, MatchServiceIdentityFailureResult, MatchServiceIdentityInput, MatchServiceIdentityResult, MatchServiceIdentitySuccess, ServiceIdentityInput, ServiceIdentityType, SrvServiceIdentityInput, UriServiceIdentityInput, matchCertificateServiceIdentity, matchServiceIdentity } from "./identity.js";
7
7
  import { InitialNameConstraintsInput } from "./name-constraints.js";
8
8
  import { ConstrainedPolicy, PolicyValidationInput, PolicyValidationOutcome } from "./policy.js";
9
9
  import { isSelfIssued } from "../internal/verify/verify-path.js";
10
- //#region src/verify/verify.d.ts
11
10
  /** PEM string or DER bytes for a certificate. PEM may contain multiple blocks. */
12
- type CertificateSource = string | Uint8Array;
11
+ export type CertificateSource = string | Uint8Array;
13
12
  /** PEM string or DER bytes for a certificate signing request. */
14
- type CsrSource = string | Uint8Array;
13
+ export type CsrSource = string | Uint8Array;
15
14
  /** High-level purpose applied during path validation to enforce leaf constraints. */
16
- type VerifyPurpose = "serverAuth" | "clientAuth" | "ca";
15
+ export type VerifyPurpose = "serverAuth" | "clientAuth" | "ca";
17
16
  /** Extended key usage purpose checked by {@linkcode checkExtendedKeyUsage}. */
18
- type EkuCheckPurpose = "serverAuth" | "clientAuth" | "codeSigning" | "emailProtection" | "timeStamping" | "ocspSigning";
17
+ export type EkuCheckPurpose = "serverAuth" | "clientAuth" | "codeSigning" | "emailProtection" | "timeStamping" | "ocspSigning";
19
18
  /** Result of {@linkcode checkExtendedKeyUsage}. Success carries no value; failure identifies the offending certificate. */
20
- type EkuCheckResult = {
19
+ export type EkuCheckResult = {
21
20
  readonly ok: true;
22
21
  readonly value: undefined;
23
- } | IndexedErrorResult<"leaf_eku_missing" | "intermediate_eku_constraint", Record<never, never>, EkuCheckFailure>;
22
+ } | IndexedErrorResult<"leaf_eku_missing" | "intermediate_eku_constraint" | DecodeRefusalCode, Record<never, never>, EkuCheckFailure>;
24
23
  /** Failure from {@linkcode checkExtendedKeyUsage} with the chain index of the certificate that failed. */
25
- interface EkuCheckFailure extends Micro509Error<"leaf_eku_missing" | "intermediate_eku_constraint"> {
24
+ export interface EkuCheckFailure extends Micro509Error<"leaf_eku_missing" | "intermediate_eku_constraint" | DecodeRefusalCode> {
26
25
  /** Always `false` for failures. */
27
26
  readonly ok: false;
28
27
  /** Zero-based index into the chain of the certificate that lacks the required EKU. */
@@ -33,7 +32,7 @@ interface EkuCheckFailure extends Micro509Error<"leaf_eku_missing" | "intermedia
33
32
  * full certificate. Used when the root CA certificate is unavailable but
34
33
  * its key is known. Build from a certificate with {@linkcode trustAnchorFromCertificate}.
35
34
  */
36
- interface TrustAnchor {
35
+ export interface TrustAnchor {
37
36
  /** Parsed subject distinguished name. Used for semantic issuer matching (RFC 5280 §7.1). */
38
37
  readonly subject: ParsedName;
39
38
  /** DER-encoded SubjectPublicKeyInfo used to verify signatures from this anchor. */
@@ -55,12 +54,15 @@ interface TrustAnchor {
55
54
  * - `ca_required` — an issuer lacks `basicConstraints.ca = true`.
56
55
  * - `key_cert_sign_required` — an issuer has keyUsage but omits `keyCertSign`.
57
56
  * - `path_length_exceeded` — the number of CA certificates below an issuer exceeds its pathLength.
57
+ * - `path_building_limit_exceeded` — candidate-path construction exceeded its bounded work limits.
58
58
  * - `authority_key_identifier_mismatch` — a certificate's AKI does not match the issuer's SKI.
59
59
  * - `extended_key_usage_invalid` — the leaf certificate lacks the required EKU for the requested purpose.
60
60
  * - `subject_alt_name_mismatch` — no SAN entry matches the requested service identity.
61
61
  * - `common_name_fallback_suppressed` — CN fallback was attempted but suppressed (SAN present or disabled).
62
62
  * - `self_signed_leaf_not_allowed` — the leaf is self-signed and `allowSelfSignedLeaf` was not set.
63
63
  * - `unrecognized_critical_extension` — a certificate contains a critical extension the verifier cannot process.
64
+ * - `no_rev_avail_conflict` — a certificate carries noRevAvail alongside a CA basicConstraints, cRLDistributionPoints, freshestCRL, or an id-ad-ocsp authorityInfoAccess entry (RFC 9608 §3).
65
+ * - `display_text_oversized` — under `rejectOversizedDisplayText`, a certificate's user notice `explicitText` or `noticeRef` organization exceeds the 200 characters of RFC 5280 §4.2.1.4.
64
66
  * - `intermediate_eku_constraint` — an intermediate CA's EKU set does not include the required purpose.
65
67
  * - `explicit_policy_required` — `requireExplicitPolicy` was set but no acceptable policy was found.
66
68
  * - `initial_policy_set_not_satisfied` — the chain's policies do not intersect `initialPolicySet`.
@@ -69,14 +71,17 @@ interface TrustAnchor {
69
71
  * - `name_constraints_violated` — a subject name violates a permitted/excluded subtree.
70
72
  * - `unsupported_signature_algorithm_parameters` — the signature algorithm uses unrecognized parameters.
71
73
  * - `ec_domain_parameters_missing` — an elliptic curve public key carries no namedCurve domain parameters.
74
+ * - `public_key_distrusted` — a certificate or bare trust anchor uses an explicitly distrusted SHA-256 SPKI.
72
75
  * - `certificate_revoked` — revocation evidence confirms a chain certificate is revoked.
73
76
  * - `revocation_indeterminate` — revocation status could not be determined under a hard-fail policy.
77
+ * - `unsupported` — a certificate source holds a construct micro509 does not decode (see `ParseCertificateErrorCode`).
78
+ * - `limit_exceeded` — a certificate source exceeds a micro509 decoding limit (see `ParseCertificateErrorCode`).
74
79
  */
75
- declare const VERIFY_ERROR_CODES: readonly ["no_trusted_root", "issuer_not_found", "signature_invalid", "certificate_expired", "ca_required", "key_cert_sign_required", "path_length_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", "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", "certificate_revoked", "revocation_indeterminate"];
80
+ export declare const VERIFY_ERROR_CODES: readonly ["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"];
76
81
  /** See the doc comment above {@linkcode VERIFY_ERROR_CODES} for the meaning of each code. */
77
- type VerifyErrorCode = (typeof VERIFY_ERROR_CODES)[number];
82
+ export type VerifyErrorCode = (typeof VERIFY_ERROR_CODES)[number];
78
83
  /** Diagnostic context attached to every {@linkcode VerifyChainFailure}. All fields are optional; presence depends on the error code. */
79
- interface VerifyFailureDetails {
84
+ export interface VerifyFailureDetails {
80
85
  /** CN of the certificate that triggered the failure. */
81
86
  readonly subjectCommonName?: string;
82
87
  /** CN of the issuer of the offending certificate. */
@@ -91,14 +96,33 @@ interface VerifyFailureDetails {
91
96
  readonly presentedIdentifierTypes?: readonly ("dns" | "uri" | "srv")[];
92
97
  /** Why the CN-fallback path was not taken. Set on `common_name_fallback_suppressed`. */
93
98
  readonly commonNameFallbackReason?: "disabled" | "suppressed_by_presented_identifier" | "common_name_missing" | "common_name_mismatch";
99
+ /** The user notice DisplayText that exceeds 200 characters. Set on `display_text_oversized`. */
100
+ readonly userNoticeField?: "explicitText" | "noticeRefOrganization";
101
+ /** The `intermediates` or `roots` entry that failed to load, which has no chain index. */
102
+ readonly source?: VerifyFailureSource;
103
+ }
104
+ /** An entry of {@linkcode BuildCandidatePathInput.intermediates} or {@linkcode BuildCandidatePathInput.roots}. */
105
+ export interface VerifyFailureSource {
106
+ /** The input array holding the entry. */
107
+ readonly kind: "intermediates" | "roots";
108
+ /** Zero-based position of the entry in that array. */
109
+ readonly position: number;
94
110
  }
95
111
  /** A chain verification failure with its error code, human message, chain index, and diagnostic details. */
96
- interface VerifyChainFailure extends IndexedMicro509Error<VerifyErrorCode, VerifyFailureDetails> {
112
+ export interface VerifyChainFailure extends IndexedMicro509Error<VerifyErrorCode, VerifyFailureDetails> {
97
113
  /** Always `false` for failures. */
98
114
  readonly ok: false;
99
115
  }
100
116
  /** Input for {@linkcode buildCandidatePath}. */
101
- interface BuildCandidatePathInput {
117
+ export interface BuildCandidatePathInput {
118
+ /**
119
+ * SHA-256 hashes of complete DER SubjectPublicKeyInfo values to distrust.
120
+ * Supply 64 hexadecimal characters per hash (case-insensitive, no separators).
121
+ * Defaults to an empty list. Malformed entries throw RangeError.
122
+ * Applies to every path certificate and bare trust anchor, before revocation.
123
+ * A match returns `public_key_distrusted`, with the hash in `details.actual`.
124
+ */
125
+ readonly distrustedSpkiSha256?: readonly string[];
102
126
  /** End-entity certificate to verify. */
103
127
  readonly leaf: CertificateSource;
104
128
  /** Intermediate CA certificates available for path building. Order does not matter. */
@@ -109,9 +133,14 @@ interface BuildCandidatePathInput {
109
133
  readonly trustAnchors?: readonly TrustAnchor[];
110
134
  /** Validation time. Defaults to `new Date()`. */
111
135
  readonly at?: Date;
136
+ /**
137
+ * Maximum issuer candidates and trust anchors the path search may try before
138
+ * it stops with `path_building_limit_exceeded`. Defaults to `100_000`.
139
+ */
140
+ readonly maxPathBuildingChecks?: number;
112
141
  }
113
142
  /** A signature-verified certification path from leaf to root, before constraint validation. */
114
- interface CandidatePath {
143
+ export interface CandidatePath {
115
144
  /** Parsed end-entity certificate. */
116
145
  readonly leaf: ParsedCertificate;
117
146
  /** Full chain in leaf-to-root order (includes both leaf and root). */
@@ -124,14 +153,24 @@ interface CandidatePath {
124
153
  * anchor verified the terminal certificate, which stays a path certificate.
125
154
  */
126
155
  readonly anchorCertificateInChain: boolean;
156
+ /** Selected bare trust anchor, when the path terminates without a root certificate. */
157
+ readonly trustAnchor?: TrustAnchor;
127
158
  }
128
159
  /** Result of {@linkcode buildCandidatePath}. On success, contains the {@linkcode CandidatePath}. */
129
- type BuildCandidatePathResult = {
160
+ export type BuildCandidatePathResult = {
130
161
  readonly ok: true;
131
162
  readonly value: CandidatePath;
132
163
  } | IndexedErrorResult<VerifyErrorCode, VerifyFailureDetails, VerifyChainFailure>;
133
164
  /** Input for {@linkcode validateCandidatePath}. */
134
- interface ValidateCandidatePathInput extends PolicyValidationInput, InitialNameConstraintsInput {
165
+ export interface ValidateCandidatePathInput extends PolicyValidationInput, InitialNameConstraintsInput {
166
+ /**
167
+ * SHA-256 hashes of complete DER SubjectPublicKeyInfo values to distrust.
168
+ * Supply 64 hexadecimal characters per hash (case-insensitive, no separators).
169
+ * Defaults to an empty list. Malformed entries throw RangeError.
170
+ * Applies to every path certificate and bare trust anchor, before revocation.
171
+ * A match returns `public_key_distrusted`, with the hash in `details.actual`.
172
+ */
173
+ readonly distrustedSpkiSha256?: readonly string[];
135
174
  /** Nested policy validation overrides (takes precedence over flat fields). */
136
175
  readonly policy?: PolicyValidationInput;
137
176
  /** Nested name constraint overrides (takes precedence over flat fields). */
@@ -151,32 +190,49 @@ interface ValidateCandidatePathInput extends PolicyValidationInput, InitialNameC
151
190
  readonly purpose?: VerifyPurpose;
152
191
  /** When `true`, allows a self-signed leaf that is also the root. Defaults to `false`. */
153
192
  readonly allowSelfSignedLeaf?: boolean;
193
+ /**
194
+ * When `true`, rejects a certificate whose user notice `explicitText` or
195
+ * `noticeRef` organization exceeds 200 characters with
196
+ * `display_text_oversized`. Defaults to `false`, and the parsed certificate
197
+ * reports such a value as `oversizedExplicitText` or `oversizedOrganization`.
198
+ */
199
+ readonly rejectOversizedDisplayText?: boolean;
200
+ /** Bare anchor returned by buildCandidatePath. Required for distrust checks when anchorCertificateInChain is false. */
201
+ readonly trustAnchor?: TrustAnchor;
154
202
  }
155
203
  /** Success payload from {@linkcode validateCandidatePath}. */
156
- interface ValidateCandidatePathSuccess {
204
+ export interface ValidateCandidatePathSuccess {
157
205
  /** Final RFC 9618-constrained policy outputs for this validated path. */
158
206
  readonly policyValidation: PolicyValidationOutcome;
159
207
  }
160
208
  /** Result of {@linkcode validateCandidatePath}. */
161
- type ValidateCandidatePathResult = {
209
+ export type ValidateCandidatePathResult = {
162
210
  readonly ok: true;
163
211
  readonly value: ValidateCandidatePathSuccess;
164
212
  } | IndexedErrorResult<VerifyErrorCode, VerifyFailureDetails, VerifyChainFailure>;
165
213
  /** Input for chain-level revocation checking in {@linkcode verifyCertificateChain}. */
166
- interface ChainRevocationInput {
214
+ export interface ChainRevocationInput {
167
215
  /** CRLs to evaluate. */
168
216
  readonly crls?: readonly CrlSource[];
169
217
  /** OCSP responses to evaluate (PEM strings or DER bytes). */
170
218
  readonly ocspResponses?: readonly (string | Uint8Array)[];
171
219
  /** Extra certs for indirect CRL issuers / delegated OCSP responders. */
172
220
  readonly extraCertificates?: readonly RevocationCertificateSource[];
173
- /** Explicitly trusted OCSP responder certificates (RFC 6960 §4.2.2.2 criterion 1). */
174
- readonly trustedOcspResponders?: readonly RevocationCertificateSource[];
221
+ /** Issuer-scoped trusted OCSP responders (RFC 6960 §4.2.2.2 criterion 1). */
222
+ readonly trustedOcspResponders?: readonly TrustedOcspResponder[];
175
223
  /** Revocation policy. */
176
224
  readonly policy?: RevocationPolicy;
177
225
  }
178
226
  /** Input for {@linkcode verifyCertificateChain}. Combines path-building, validation, and identity options. */
179
- interface VerifyCertificateChainInput extends PolicyValidationInput, InitialNameConstraintsInput {
227
+ export interface VerifyCertificateChainInput extends PolicyValidationInput, InitialNameConstraintsInput {
228
+ /**
229
+ * SHA-256 hashes of complete DER SubjectPublicKeyInfo values to distrust.
230
+ * Supply 64 hexadecimal characters per hash (case-insensitive, no separators).
231
+ * Defaults to an empty list. Malformed entries throw RangeError.
232
+ * Applies to every path certificate and bare trust anchor, before revocation.
233
+ * A match returns `public_key_distrusted`, with the hash in `details.actual`.
234
+ */
235
+ readonly distrustedSpkiSha256?: readonly string[];
180
236
  /** Nested policy validation overrides. */
181
237
  readonly policy?: PolicyValidationInput;
182
238
  /** Nested name constraint overrides. */
@@ -191,17 +247,29 @@ interface VerifyCertificateChainInput extends PolicyValidationInput, InitialName
191
247
  readonly trustAnchors?: readonly TrustAnchor[];
192
248
  /** Validation time. Defaults to `new Date()`. */
193
249
  readonly at?: Date;
250
+ /**
251
+ * Maximum issuer candidates and trust anchors the path search may try before
252
+ * it stops with `path_building_limit_exceeded`. Defaults to `100_000`.
253
+ */
254
+ readonly maxPathBuildingChecks?: number;
194
255
  /** Leaf purpose constraint to enforce during validation. */
195
256
  readonly purpose?: VerifyPurpose;
196
257
  /** DNS/IP/URI/SRV identity to match against the leaf's SAN. */
197
258
  readonly serviceIdentity?: ServiceIdentityInput;
198
259
  /** When `true`, allows a self-signed leaf. Defaults to `false`. */
199
260
  readonly allowSelfSignedLeaf?: boolean;
261
+ /**
262
+ * When `true`, rejects a certificate whose user notice `explicitText` or
263
+ * `noticeRef` organization exceeds 200 characters with
264
+ * `display_text_oversized`. Defaults to `false`, and the parsed certificate
265
+ * reports such a value as `oversizedExplicitText` or `oversizedOrganization`.
266
+ */
267
+ readonly rejectOversizedDisplayText?: boolean;
200
268
  /** Optional revocation checking. */
201
269
  readonly revocation?: ChainRevocationInput;
202
270
  }
203
271
  /** Fully verified certificate chain returned on success from {@linkcode verifyCertificateChain}. */
204
- interface VerifiedCertificateChain {
272
+ export interface VerifiedCertificateChain {
205
273
  /** Parsed end-entity certificate. */
206
274
  readonly leaf: ParsedCertificate;
207
275
  /** Full chain in leaf-to-root order. */
@@ -210,24 +278,26 @@ interface VerifiedCertificateChain {
210
278
  readonly root: ParsedCertificate;
211
279
  /** Final RFC 5280 §6 / RFC 9618 constrained policy outputs for this validated path. */
212
280
  readonly policyValidation: PolicyValidationOutcome;
281
+ /** Selected bare trust anchor, when the path terminates without a root certificate. */
282
+ readonly trustAnchor?: TrustAnchor;
213
283
  }
214
284
  /** Result of {@linkcode verifyCertificateChain}. On success, contains the {@linkcode VerifiedCertificateChain}. */
215
- type VerifyChainResult = {
285
+ export type VerifyChainResult = {
216
286
  readonly ok: true;
217
287
  readonly value: VerifiedCertificateChain;
218
288
  } | IndexedErrorResult<VerifyErrorCode, VerifyFailureDetails, VerifyChainFailure>;
219
289
  /** Failure from {@linkcode verifyCertificateSigningRequest}. */
220
- interface VerifyRequestFailure extends Micro509Error<"signature_invalid" | "unsupported_signature_algorithm_parameters", VerifyFailureDetails> {
290
+ export interface VerifyRequestFailure extends Micro509Error<"signature_invalid" | "unsupported_signature_algorithm_parameters" | DecodeRefusalCode, VerifyFailureDetails> {
221
291
  /** Always `false` for failures. */
222
292
  readonly ok: false;
223
293
  }
224
294
  /** Result of {@linkcode verifyCertificateSigningRequest}. On success, contains the parsed CSR. */
225
- type VerifyRequestResult = {
295
+ export type VerifyRequestResult = {
226
296
  readonly ok: true;
227
297
  readonly value: ParsedCertificateSigningRequest;
228
- } | ErrorResult<"signature_invalid" | "unsupported_signature_algorithm_parameters", VerifyFailureDetails, VerifyRequestFailure>;
298
+ } | ErrorResult<"signature_invalid" | "unsupported_signature_algorithm_parameters" | DecodeRefusalCode, VerifyFailureDetails, VerifyRequestFailure>;
229
299
  /** Input for {@linkcode validateForTlsServer}. Enforces `serverAuth` EKU and optional DNS/IP identity matching. */
230
- interface ValidateForTlsServerInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
300
+ export interface ValidateForTlsServerInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
231
301
  /** Nested policy validation overrides. */
232
302
  readonly policy?: PolicyValidationInput;
233
303
  /** Nested name constraint overrides. */
@@ -246,21 +316,21 @@ interface ValidateForTlsServerInput extends BuildCandidatePathInput, PolicyValid
246
316
  readonly serviceIdentity?: ServiceIdentityInput;
247
317
  }
248
318
  /** Input for {@linkcode validateForTlsClient}. Enforces `clientAuth` EKU. */
249
- interface ValidateForTlsClientInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
319
+ export interface ValidateForTlsClientInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
250
320
  /** Nested policy validation overrides. */
251
321
  readonly policy?: PolicyValidationInput;
252
322
  /** Nested name constraint overrides. */
253
323
  readonly nameConstraints?: InitialNameConstraintsInput;
254
324
  }
255
325
  /** Input for {@linkcode validateForCodeSigning}. Enforces `codeSigning` EKU. */
256
- interface ValidateForCodeSigningInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
326
+ export interface ValidateForCodeSigningInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
257
327
  /** Nested policy validation overrides. */
258
328
  readonly policy?: PolicyValidationInput;
259
329
  /** Nested name constraint overrides. */
260
330
  readonly nameConstraints?: InitialNameConstraintsInput;
261
331
  }
262
332
  /** Input for {@linkcode validateForCa}. Enforces `basicConstraints.ca` on the leaf. */
263
- interface ValidateForCaInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
333
+ export interface ValidateForCaInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
264
334
  /** Nested policy validation overrides. */
265
335
  readonly policy?: PolicyValidationInput;
266
336
  /** Nested name constraint overrides. */
@@ -288,12 +358,12 @@ interface ValidateForCaInput extends BuildCandidatePathInput, PolicyValidationIn
288
358
  * }
289
359
  * ```
290
360
  */
291
- declare function buildCandidatePath(input: BuildCandidatePathInput): Promise<BuildCandidatePathResult>;
361
+ export declare function buildCandidatePath(input: BuildCandidatePathInput): Promise<BuildCandidatePathResult>;
292
362
  /**
293
363
  * Validates a pre-built certificate chain for time, constraints, policy, and
294
364
  * optionally leaf purpose. Wrap the result of {@linkcode buildCandidatePath}.
295
365
  */
296
- declare function validateCandidatePath(input: ValidateCandidatePathInput): Promise<ValidateCandidatePathResult>;
366
+ export declare function validateCandidatePath(input: ValidateCandidatePathInput): Promise<ValidateCandidatePathResult>;
297
367
  /**
298
368
  * All-in-one certificate chain verification: builds a candidate path then
299
369
  * validates time, constraints, policy, purpose, and optional service identity.
@@ -317,7 +387,7 @@ declare function validateCandidatePath(input: ValidateCandidatePathInput): Promi
317
387
  * }
318
388
  * ```
319
389
  */
320
- declare function verifyCertificateChain(input: VerifyCertificateChainInput): Promise<VerifyChainResult>;
390
+ export declare function verifyCertificateChain(input: VerifyCertificateChainInput): Promise<VerifyChainResult>;
321
391
  /**
322
392
  * Verifies the self-signature of a PKCS#10 certificate signing request.
323
393
  *
@@ -334,7 +404,7 @@ declare function verifyCertificateChain(input: VerifyCertificateChainInput): Pro
334
404
  * }
335
405
  * ```
336
406
  */
337
- declare function verifyCertificateSigningRequest(input: CsrSource): Promise<VerifyRequestResult>;
407
+ export declare function verifyCertificateSigningRequest(input: CsrSource): Promise<VerifyRequestResult>;
338
408
  /**
339
409
  * Standalone EKU check against a verified certificate chain.
340
410
  * Validates that the leaf has the requested purpose and that
@@ -350,9 +420,9 @@ declare function verifyCertificateSigningRequest(input: CsrSource): Promise<Veri
350
420
  * }
351
421
  * ```
352
422
  */
353
- declare function checkExtendedKeyUsage(chain: readonly ParsedCertificate[], purpose: EkuCheckPurpose): EkuCheckResult;
423
+ export declare function checkExtendedKeyUsage(chain: readonly ParsedCertificate[], purpose: EkuCheckPurpose): EkuCheckResult;
354
424
  /** Extracts a {@linkcode TrustAnchor} from a parsed certificate, copying the subject, SPKI, and key identifiers. */
355
- declare function trustAnchorFromCertificate(certificate: ParsedCertificate): TrustAnchor;
425
+ export declare function trustAnchorFromCertificate(certificate: ParsedCertificate): TrustAnchor;
356
426
  /**
357
427
  * Validates a certificate chain for TLS server use:
358
428
  * chain verification + `serverAuth` EKU (leaf + intermediate propagation)
@@ -372,7 +442,7 @@ declare function trustAnchorFromCertificate(certificate: ParsedCertificate): Tru
372
442
  * }
373
443
  * ```
374
444
  */
375
- declare function validateForTlsServer(input: ValidateForTlsServerInput): Promise<VerifyChainResult>;
445
+ export declare function validateForTlsServer(input: ValidateForTlsServerInput): Promise<VerifyChainResult>;
376
446
  /**
377
447
  * Validates a certificate chain for TLS client use:
378
448
  * chain verification + `clientAuth` EKU (leaf + intermediate propagation).
@@ -387,7 +457,7 @@ declare function validateForTlsServer(input: ValidateForTlsServerInput): Promise
387
457
  * });
388
458
  * ```
389
459
  */
390
- declare function validateForTlsClient(input: ValidateForTlsClientInput): Promise<VerifyChainResult>;
460
+ export declare function validateForTlsClient(input: ValidateForTlsClientInput): Promise<VerifyChainResult>;
391
461
  /**
392
462
  * Validates a certificate chain for code signing:
393
463
  * chain verification + `codeSigning` EKU (leaf + intermediate propagation).
@@ -402,7 +472,7 @@ declare function validateForTlsClient(input: ValidateForTlsClientInput): Promise
402
472
  * });
403
473
  * ```
404
474
  */
405
- declare function validateForCodeSigning(input: ValidateForCodeSigningInput): Promise<VerifyChainResult>;
475
+ export declare function validateForCodeSigning(input: ValidateForCodeSigningInput): Promise<VerifyChainResult>;
406
476
  /**
407
477
  * Validates a certificate chain for CA use:
408
478
  * chain verification + `basicConstraints.ca` check on the leaf.
@@ -417,7 +487,6 @@ declare function validateForCodeSigning(input: ValidateForCodeSigningInput): Pro
417
487
  * });
418
488
  * ```
419
489
  */
420
- declare function validateForCa(input: ValidateForCaInput): Promise<VerifyChainResult>;
421
- //#endregion
422
- export { BuildCandidatePathInput, BuildCandidatePathResult, CandidatePath, CertificateSource, ChainRevocationInput, type ConstrainedPolicy, CsrSource, type DnsServiceIdentityInput, EkuCheckFailure, EkuCheckPurpose, EkuCheckResult, type InitialNameConstraintsInput, type IpServiceIdentityInput, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityFailureDetails, type MatchServiceIdentityFailureResult, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type PolicyValidationInput, type PolicyValidationOutcome, type ServiceIdentityInput, type ServiceIdentityType, type SrvServiceIdentityInput, TrustAnchor, type UriServiceIdentityInput, VERIFY_ERROR_CODES, ValidateCandidatePathInput, ValidateCandidatePathResult, ValidateCandidatePathSuccess, ValidateForCaInput, ValidateForCodeSigningInput, ValidateForTlsClientInput, ValidateForTlsServerInput, VerifiedCertificateChain, VerifyCertificateChainInput, VerifyChainFailure, VerifyChainResult, VerifyErrorCode, VerifyFailureDetails, VerifyPurpose, VerifyRequestFailure, VerifyRequestResult, buildCandidatePath, checkExtendedKeyUsage, isSelfIssued as isSelfIssuedCertificate, type matchCertificateServiceIdentity, type matchServiceIdentity, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest };
490
+ export declare function validateForCa(input: ValidateForCaInput): Promise<VerifyChainResult>;
491
+ export { type ConstrainedPolicy, type DnsServiceIdentityInput, type InitialNameConstraintsInput, type IpServiceIdentityInput, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityFailureDetails, type MatchServiceIdentityFailureResult, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type PolicyValidationInput, type PolicyValidationOutcome, type ServiceIdentityInput, type ServiceIdentityType, type SrvServiceIdentityInput, type UriServiceIdentityInput, isSelfIssued as isSelfIssuedCertificate, type matchCertificateServiceIdentity, type matchServiceIdentity };
423
492
  //# sourceMappingURL=verify.d.ts.map