micro509 0.14.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.
- package/CHANGELOG.md +2064 -0
- package/README.md +105 -225
- package/dist/crypto/crypto.d.ts +42 -11
- package/dist/crypto/crypto.js +53 -22
- package/dist/crypto/crypto.js.map +1 -1
- package/dist/crypto.d.ts +2 -2
- package/dist/crypto.js +1 -2
- package/dist/der/der.d.ts +41 -33
- package/dist/der/der.js +26 -24
- package/dist/der/der.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +19 -19
- package/dist/internal/asn1/asn1.d.ts +3 -6
- package/dist/internal/asn1/asn1.js +343 -43
- package/dist/internal/asn1/asn1.js.map +1 -1
- package/dist/internal/asn1/ber.js +146 -0
- package/dist/internal/asn1/ber.js.map +1 -0
- package/dist/internal/asn1/decode-refusal.js +29 -0
- package/dist/internal/asn1/decode-refusal.js.map +1 -0
- package/dist/internal/asn1/der.d.ts +38 -41
- package/dist/internal/asn1/der.js +131 -52
- package/dist/internal/asn1/der.js.map +1 -1
- package/dist/internal/asn1/oids.js +83 -53
- package/dist/internal/asn1/oids.js.map +1 -1
- package/dist/internal/asn1/oids2.js +1 -2
- package/dist/internal/asn1/oids2.js.map +1 -1
- package/dist/internal/crypto/algorithm-names.js +1 -2
- package/dist/internal/crypto/algorithm-names.js.map +1 -1
- package/dist/internal/crypto/ecdsa.js +13 -8
- package/dist/internal/crypto/ecdsa.js.map +1 -1
- package/dist/internal/crypto/hash.js +1 -2
- package/dist/internal/crypto/hash.js.map +1 -1
- package/dist/internal/crypto/pbes2.d.ts +24 -11
- package/dist/internal/crypto/pbes2.js +79 -26
- package/dist/internal/crypto/pbes2.js.map +1 -1
- package/dist/internal/crypto/rsa-pss.js +46 -44
- package/dist/internal/crypto/rsa-pss.js.map +1 -1
- package/dist/internal/crypto/sig-verify.d.ts +4 -7
- package/dist/internal/crypto/sig-verify.js +107 -60
- package/dist/internal/crypto/sig-verify.js.map +1 -1
- package/dist/internal/crypto/signing.d.ts +1 -4
- package/dist/internal/crypto/signing.js +28 -29
- package/dist/internal/crypto/signing.js.map +1 -1
- package/dist/internal/crypto/webcrypto.js +1 -2
- package/dist/internal/crypto/webcrypto.js.map +1 -1
- package/dist/internal/shared/base64.js +1 -2
- package/dist/internal/shared/base64.js.map +1 -1
- package/dist/internal/shared/dn.d.ts +3 -6
- package/dist/internal/shared/dn.js +99 -53
- package/dist/internal/shared/dn.js.map +1 -1
- package/dist/internal/shared/idna-tables.js +7217 -0
- package/dist/internal/shared/idna-tables.js.map +1 -0
- package/dist/internal/shared/idna.js +296 -0
- package/dist/internal/shared/idna.js.map +1 -0
- package/dist/internal/shared/ip.d.ts +4 -7
- package/dist/internal/shared/ip.js +1 -2
- package/dist/internal/shared/ip.js.map +1 -1
- package/dist/internal/shared/mailbox.js +26 -0
- package/dist/internal/shared/mailbox.js.map +1 -0
- package/dist/internal/shared/punycode.js +101 -0
- package/dist/internal/shared/punycode.js.map +1 -0
- package/dist/internal/shared/rfc3454-tables.js +1 -2
- package/dist/internal/shared/rfc3454-tables.js.map +1 -1
- package/dist/internal/shared/rfc4518-tables.js +119 -0
- package/dist/internal/shared/rfc4518-tables.js.map +1 -0
- package/dist/internal/shared/uri-host.js +102 -0
- package/dist/internal/shared/uri-host.js.map +1 -0
- package/dist/internal/verify/name-constraints-engine.js +246 -131
- package/dist/internal/verify/name-constraints-engine.js.map +1 -1
- package/dist/internal/verify/policy-engine.js +6 -21
- package/dist/internal/verify/policy-engine.js.map +1 -1
- package/dist/internal/verify/verify-path.d.ts +1 -4
- package/dist/internal/verify/verify-path.js +267 -131
- package/dist/internal/verify/verify-path.js.map +1 -1
- package/dist/internal/x509/directory-name.js +1 -2
- package/dist/internal/x509/directory-name.js.map +1 -1
- package/dist/internal/x509/extension-bits.js +2 -3
- package/dist/internal/x509/extension-bits.js.map +1 -1
- package/dist/internal/x509/extension-errors.d.ts +1 -4
- package/dist/internal/x509/extension-errors.js +1 -2
- package/dist/internal/x509/extension-errors.js.map +1 -1
- package/dist/internal/x509/extension-registry.js +107 -89
- package/dist/internal/x509/extension-registry.js.map +1 -1
- package/dist/internal/x509/general-name-profile.js +129 -0
- package/dist/internal/x509/general-name-profile.js.map +1 -0
- package/dist/internal/x509/general-name-tags.js +1 -2
- package/dist/internal/x509/general-name-tags.js.map +1 -1
- package/dist/internal/x509/general-name.js +128 -42
- package/dist/internal/x509/general-name.js.map +1 -1
- package/dist/internal/x509/name-fields.js +1 -2
- package/dist/internal/x509/name-fields.js.map +1 -1
- package/dist/internal/x509/or-address.js +217 -0
- package/dist/internal/x509/or-address.js.map +1 -0
- package/dist/keys/keys.d.ts +112 -97
- package/dist/keys/keys.js +211 -204
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys.d.ts +3 -3
- package/dist/pem/pem.d.ts +14 -17
- package/dist/pem/pem.js +16 -17
- package/dist/pem/pem.js.map +1 -1
- package/dist/pem.js +1 -2
- package/dist/pkcs/pfx.d.ts +57 -32
- package/dist/pkcs/pfx.js +209 -173
- package/dist/pkcs/pfx.js.map +1 -1
- package/dist/pkcs/pkcs12-mac.d.ts +104 -27
- package/dist/pkcs/pkcs12-mac.js +266 -79
- package/dist/pkcs/pkcs12-mac.js.map +1 -1
- package/dist/pkcs/pkcs7.d.ts +43 -37
- package/dist/pkcs/pkcs7.js +218 -217
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +4 -3
- package/dist/result/result.d.ts +27 -20
- package/dist/result/result.js +8 -3
- package/dist/result/result.js.map +1 -1
- package/dist/result.d.ts +2 -2
- package/dist/result.js +1 -2
- package/dist/revocation/chain.d.ts +101 -23
- package/dist/revocation/chain.js +436 -182
- package/dist/revocation/chain.js.map +1 -1
- package/dist/revocation/crl.d.ts +131 -67
- package/dist/revocation/crl.js +444 -323
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +94 -59
- package/dist/revocation/ocsp.js +331 -293
- package/dist/revocation/ocsp.js.map +1 -1
- package/dist/revocation/revocation.d.ts +47 -35
- package/dist/revocation/revocation.js +88 -57
- package/dist/revocation/revocation.js.map +1 -1
- package/dist/revocation.d.ts +3 -3
- package/dist/verify/identity.d.ts +16 -19
- package/dist/verify/identity.js +118 -89
- package/dist/verify/identity.js.map +1 -1
- package/dist/verify/name-constraints.d.ts +1 -4
- package/dist/verify/policy.d.ts +9 -7
- package/dist/verify/verify.d.ts +84 -46
- package/dist/verify/verify.js +300 -152
- package/dist/verify/verify.js.map +1 -1
- package/dist/verify.d.ts +2 -2
- package/dist/x509/certificate.d.ts +20 -21
- package/dist/x509/certificate.js +62 -46
- package/dist/x509/certificate.js.map +1 -1
- package/dist/x509/csr.d.ts +5 -7
- package/dist/x509/csr.js +10 -11
- package/dist/x509/csr.js.map +1 -1
- package/dist/x509/extensions.d.ts +154 -66
- package/dist/x509/extensions.js +317 -151
- package/dist/x509/extensions.js.map +1 -1
- package/dist/x509/fingerprint.d.ts +4 -7
- package/dist/x509/fingerprint.js +1 -2
- package/dist/x509/fingerprint.js.map +1 -1
- package/dist/x509/name-text.d.ts +7 -9
- package/dist/x509/name-text.js +18 -4
- package/dist/x509/name-text.js.map +1 -1
- package/dist/x509/name.d.ts +9 -11
- package/dist/x509/name.js +18 -19
- package/dist/x509/name.js.map +1 -1
- package/dist/x509/parse.d.ts +84 -69
- package/dist/x509/parse.js +421 -400
- package/dist/x509/parse.js.map +1 -1
- package/dist/x509.d.ts +2 -2
- package/package.json +76 -59
package/dist/verify/policy.d.ts
CHANGED
|
@@ -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.
|
|
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
|
package/dist/verify/verify.d.ts
CHANGED
|
@@ -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`.
|
|
@@ -71,12 +73,14 @@ interface TrustAnchor {
|
|
|
71
73
|
* - `ec_domain_parameters_missing` — an elliptic curve public key carries no namedCurve domain parameters.
|
|
72
74
|
* - `certificate_revoked` — revocation evidence confirms a chain certificate is revoked.
|
|
73
75
|
* - `revocation_indeterminate` — revocation status could not be determined under a hard-fail policy.
|
|
76
|
+
* - `unsupported` — a certificate source holds a construct micro509 does not decode (see `ParseCertificateErrorCode`).
|
|
77
|
+
* - `limit_exceeded` — a certificate source exceeds a micro509 decoding limit (see `ParseCertificateErrorCode`).
|
|
74
78
|
*/
|
|
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"];
|
|
79
|
+
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", "certificate_revoked", "revocation_indeterminate", "unsupported", "limit_exceeded"];
|
|
76
80
|
/** See the doc comment above {@linkcode VERIFY_ERROR_CODES} for the meaning of each code. */
|
|
77
|
-
type VerifyErrorCode = (typeof VERIFY_ERROR_CODES)[number];
|
|
81
|
+
export type VerifyErrorCode = (typeof VERIFY_ERROR_CODES)[number];
|
|
78
82
|
/** Diagnostic context attached to every {@linkcode VerifyChainFailure}. All fields are optional; presence depends on the error code. */
|
|
79
|
-
interface VerifyFailureDetails {
|
|
83
|
+
export interface VerifyFailureDetails {
|
|
80
84
|
/** CN of the certificate that triggered the failure. */
|
|
81
85
|
readonly subjectCommonName?: string;
|
|
82
86
|
/** CN of the issuer of the offending certificate. */
|
|
@@ -91,14 +95,25 @@ interface VerifyFailureDetails {
|
|
|
91
95
|
readonly presentedIdentifierTypes?: readonly ("dns" | "uri" | "srv")[];
|
|
92
96
|
/** Why the CN-fallback path was not taken. Set on `common_name_fallback_suppressed`. */
|
|
93
97
|
readonly commonNameFallbackReason?: "disabled" | "suppressed_by_presented_identifier" | "common_name_missing" | "common_name_mismatch";
|
|
98
|
+
/** The user notice DisplayText that exceeds 200 characters. Set on `display_text_oversized`. */
|
|
99
|
+
readonly userNoticeField?: "explicitText" | "noticeRefOrganization";
|
|
100
|
+
/** The `intermediates` or `roots` entry that failed to load, which has no chain index. */
|
|
101
|
+
readonly source?: VerifyFailureSource;
|
|
102
|
+
}
|
|
103
|
+
/** An entry of {@linkcode BuildCandidatePathInput.intermediates} or {@linkcode BuildCandidatePathInput.roots}. */
|
|
104
|
+
export interface VerifyFailureSource {
|
|
105
|
+
/** The input array holding the entry. */
|
|
106
|
+
readonly kind: "intermediates" | "roots";
|
|
107
|
+
/** Zero-based position of the entry in that array. */
|
|
108
|
+
readonly position: number;
|
|
94
109
|
}
|
|
95
110
|
/** A chain verification failure with its error code, human message, chain index, and diagnostic details. */
|
|
96
|
-
interface VerifyChainFailure extends IndexedMicro509Error<VerifyErrorCode, VerifyFailureDetails> {
|
|
111
|
+
export interface VerifyChainFailure extends IndexedMicro509Error<VerifyErrorCode, VerifyFailureDetails> {
|
|
97
112
|
/** Always `false` for failures. */
|
|
98
113
|
readonly ok: false;
|
|
99
114
|
}
|
|
100
115
|
/** Input for {@linkcode buildCandidatePath}. */
|
|
101
|
-
interface BuildCandidatePathInput {
|
|
116
|
+
export interface BuildCandidatePathInput {
|
|
102
117
|
/** End-entity certificate to verify. */
|
|
103
118
|
readonly leaf: CertificateSource;
|
|
104
119
|
/** Intermediate CA certificates available for path building. Order does not matter. */
|
|
@@ -109,9 +124,14 @@ interface BuildCandidatePathInput {
|
|
|
109
124
|
readonly trustAnchors?: readonly TrustAnchor[];
|
|
110
125
|
/** Validation time. Defaults to `new Date()`. */
|
|
111
126
|
readonly at?: Date;
|
|
127
|
+
/**
|
|
128
|
+
* Maximum issuer candidates and trust anchors the path search may try before
|
|
129
|
+
* it stops with `path_building_limit_exceeded`. Defaults to `100_000`.
|
|
130
|
+
*/
|
|
131
|
+
readonly maxPathBuildingChecks?: number;
|
|
112
132
|
}
|
|
113
133
|
/** A signature-verified certification path from leaf to root, before constraint validation. */
|
|
114
|
-
interface CandidatePath {
|
|
134
|
+
export interface CandidatePath {
|
|
115
135
|
/** Parsed end-entity certificate. */
|
|
116
136
|
readonly leaf: ParsedCertificate;
|
|
117
137
|
/** Full chain in leaf-to-root order (includes both leaf and root). */
|
|
@@ -126,12 +146,12 @@ interface CandidatePath {
|
|
|
126
146
|
readonly anchorCertificateInChain: boolean;
|
|
127
147
|
}
|
|
128
148
|
/** Result of {@linkcode buildCandidatePath}. On success, contains the {@linkcode CandidatePath}. */
|
|
129
|
-
type BuildCandidatePathResult = {
|
|
149
|
+
export type BuildCandidatePathResult = {
|
|
130
150
|
readonly ok: true;
|
|
131
151
|
readonly value: CandidatePath;
|
|
132
152
|
} | IndexedErrorResult<VerifyErrorCode, VerifyFailureDetails, VerifyChainFailure>;
|
|
133
153
|
/** Input for {@linkcode validateCandidatePath}. */
|
|
134
|
-
interface ValidateCandidatePathInput extends PolicyValidationInput, InitialNameConstraintsInput {
|
|
154
|
+
export interface ValidateCandidatePathInput extends PolicyValidationInput, InitialNameConstraintsInput {
|
|
135
155
|
/** Nested policy validation overrides (takes precedence over flat fields). */
|
|
136
156
|
readonly policy?: PolicyValidationInput;
|
|
137
157
|
/** Nested name constraint overrides (takes precedence over flat fields). */
|
|
@@ -151,32 +171,39 @@ interface ValidateCandidatePathInput extends PolicyValidationInput, InitialNameC
|
|
|
151
171
|
readonly purpose?: VerifyPurpose;
|
|
152
172
|
/** When `true`, allows a self-signed leaf that is also the root. Defaults to `false`. */
|
|
153
173
|
readonly allowSelfSignedLeaf?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* When `true`, rejects a certificate whose user notice `explicitText` or
|
|
176
|
+
* `noticeRef` organization exceeds 200 characters with
|
|
177
|
+
* `display_text_oversized`. Defaults to `false`, and the parsed certificate
|
|
178
|
+
* reports such a value as `oversizedExplicitText` or `oversizedOrganization`.
|
|
179
|
+
*/
|
|
180
|
+
readonly rejectOversizedDisplayText?: boolean;
|
|
154
181
|
}
|
|
155
182
|
/** Success payload from {@linkcode validateCandidatePath}. */
|
|
156
|
-
interface ValidateCandidatePathSuccess {
|
|
183
|
+
export interface ValidateCandidatePathSuccess {
|
|
157
184
|
/** Final RFC 9618-constrained policy outputs for this validated path. */
|
|
158
185
|
readonly policyValidation: PolicyValidationOutcome;
|
|
159
186
|
}
|
|
160
187
|
/** Result of {@linkcode validateCandidatePath}. */
|
|
161
|
-
type ValidateCandidatePathResult = {
|
|
188
|
+
export type ValidateCandidatePathResult = {
|
|
162
189
|
readonly ok: true;
|
|
163
190
|
readonly value: ValidateCandidatePathSuccess;
|
|
164
191
|
} | IndexedErrorResult<VerifyErrorCode, VerifyFailureDetails, VerifyChainFailure>;
|
|
165
192
|
/** Input for chain-level revocation checking in {@linkcode verifyCertificateChain}. */
|
|
166
|
-
interface ChainRevocationInput {
|
|
193
|
+
export interface ChainRevocationInput {
|
|
167
194
|
/** CRLs to evaluate. */
|
|
168
195
|
readonly crls?: readonly CrlSource[];
|
|
169
196
|
/** OCSP responses to evaluate (PEM strings or DER bytes). */
|
|
170
197
|
readonly ocspResponses?: readonly (string | Uint8Array)[];
|
|
171
198
|
/** Extra certs for indirect CRL issuers / delegated OCSP responders. */
|
|
172
199
|
readonly extraCertificates?: readonly RevocationCertificateSource[];
|
|
173
|
-
/**
|
|
174
|
-
readonly trustedOcspResponders?: readonly
|
|
200
|
+
/** Issuer-scoped trusted OCSP responders (RFC 6960 §4.2.2.2 criterion 1). */
|
|
201
|
+
readonly trustedOcspResponders?: readonly TrustedOcspResponder[];
|
|
175
202
|
/** Revocation policy. */
|
|
176
203
|
readonly policy?: RevocationPolicy;
|
|
177
204
|
}
|
|
178
205
|
/** Input for {@linkcode verifyCertificateChain}. Combines path-building, validation, and identity options. */
|
|
179
|
-
interface VerifyCertificateChainInput extends PolicyValidationInput, InitialNameConstraintsInput {
|
|
206
|
+
export interface VerifyCertificateChainInput extends PolicyValidationInput, InitialNameConstraintsInput {
|
|
180
207
|
/** Nested policy validation overrides. */
|
|
181
208
|
readonly policy?: PolicyValidationInput;
|
|
182
209
|
/** Nested name constraint overrides. */
|
|
@@ -191,17 +218,29 @@ interface VerifyCertificateChainInput extends PolicyValidationInput, InitialName
|
|
|
191
218
|
readonly trustAnchors?: readonly TrustAnchor[];
|
|
192
219
|
/** Validation time. Defaults to `new Date()`. */
|
|
193
220
|
readonly at?: Date;
|
|
221
|
+
/**
|
|
222
|
+
* Maximum issuer candidates and trust anchors the path search may try before
|
|
223
|
+
* it stops with `path_building_limit_exceeded`. Defaults to `100_000`.
|
|
224
|
+
*/
|
|
225
|
+
readonly maxPathBuildingChecks?: number;
|
|
194
226
|
/** Leaf purpose constraint to enforce during validation. */
|
|
195
227
|
readonly purpose?: VerifyPurpose;
|
|
196
228
|
/** DNS/IP/URI/SRV identity to match against the leaf's SAN. */
|
|
197
229
|
readonly serviceIdentity?: ServiceIdentityInput;
|
|
198
230
|
/** When `true`, allows a self-signed leaf. Defaults to `false`. */
|
|
199
231
|
readonly allowSelfSignedLeaf?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* When `true`, rejects a certificate whose user notice `explicitText` or
|
|
234
|
+
* `noticeRef` organization exceeds 200 characters with
|
|
235
|
+
* `display_text_oversized`. Defaults to `false`, and the parsed certificate
|
|
236
|
+
* reports such a value as `oversizedExplicitText` or `oversizedOrganization`.
|
|
237
|
+
*/
|
|
238
|
+
readonly rejectOversizedDisplayText?: boolean;
|
|
200
239
|
/** Optional revocation checking. */
|
|
201
240
|
readonly revocation?: ChainRevocationInput;
|
|
202
241
|
}
|
|
203
242
|
/** Fully verified certificate chain returned on success from {@linkcode verifyCertificateChain}. */
|
|
204
|
-
interface VerifiedCertificateChain {
|
|
243
|
+
export interface VerifiedCertificateChain {
|
|
205
244
|
/** Parsed end-entity certificate. */
|
|
206
245
|
readonly leaf: ParsedCertificate;
|
|
207
246
|
/** Full chain in leaf-to-root order. */
|
|
@@ -212,22 +251,22 @@ interface VerifiedCertificateChain {
|
|
|
212
251
|
readonly policyValidation: PolicyValidationOutcome;
|
|
213
252
|
}
|
|
214
253
|
/** Result of {@linkcode verifyCertificateChain}. On success, contains the {@linkcode VerifiedCertificateChain}. */
|
|
215
|
-
type VerifyChainResult = {
|
|
254
|
+
export type VerifyChainResult = {
|
|
216
255
|
readonly ok: true;
|
|
217
256
|
readonly value: VerifiedCertificateChain;
|
|
218
257
|
} | IndexedErrorResult<VerifyErrorCode, VerifyFailureDetails, VerifyChainFailure>;
|
|
219
258
|
/** Failure from {@linkcode verifyCertificateSigningRequest}. */
|
|
220
|
-
interface VerifyRequestFailure extends Micro509Error<"signature_invalid" | "unsupported_signature_algorithm_parameters", VerifyFailureDetails> {
|
|
259
|
+
export interface VerifyRequestFailure extends Micro509Error<"signature_invalid" | "unsupported_signature_algorithm_parameters" | DecodeRefusalCode, VerifyFailureDetails> {
|
|
221
260
|
/** Always `false` for failures. */
|
|
222
261
|
readonly ok: false;
|
|
223
262
|
}
|
|
224
263
|
/** Result of {@linkcode verifyCertificateSigningRequest}. On success, contains the parsed CSR. */
|
|
225
|
-
type VerifyRequestResult = {
|
|
264
|
+
export type VerifyRequestResult = {
|
|
226
265
|
readonly ok: true;
|
|
227
266
|
readonly value: ParsedCertificateSigningRequest;
|
|
228
|
-
} | ErrorResult<"signature_invalid" | "unsupported_signature_algorithm_parameters", VerifyFailureDetails, VerifyRequestFailure>;
|
|
267
|
+
} | ErrorResult<"signature_invalid" | "unsupported_signature_algorithm_parameters" | DecodeRefusalCode, VerifyFailureDetails, VerifyRequestFailure>;
|
|
229
268
|
/** Input for {@linkcode validateForTlsServer}. Enforces `serverAuth` EKU and optional DNS/IP identity matching. */
|
|
230
|
-
interface ValidateForTlsServerInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
|
|
269
|
+
export interface ValidateForTlsServerInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
|
|
231
270
|
/** Nested policy validation overrides. */
|
|
232
271
|
readonly policy?: PolicyValidationInput;
|
|
233
272
|
/** Nested name constraint overrides. */
|
|
@@ -246,21 +285,21 @@ interface ValidateForTlsServerInput extends BuildCandidatePathInput, PolicyValid
|
|
|
246
285
|
readonly serviceIdentity?: ServiceIdentityInput;
|
|
247
286
|
}
|
|
248
287
|
/** Input for {@linkcode validateForTlsClient}. Enforces `clientAuth` EKU. */
|
|
249
|
-
interface ValidateForTlsClientInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
|
|
288
|
+
export interface ValidateForTlsClientInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
|
|
250
289
|
/** Nested policy validation overrides. */
|
|
251
290
|
readonly policy?: PolicyValidationInput;
|
|
252
291
|
/** Nested name constraint overrides. */
|
|
253
292
|
readonly nameConstraints?: InitialNameConstraintsInput;
|
|
254
293
|
}
|
|
255
294
|
/** Input for {@linkcode validateForCodeSigning}. Enforces `codeSigning` EKU. */
|
|
256
|
-
interface ValidateForCodeSigningInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
|
|
295
|
+
export interface ValidateForCodeSigningInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
|
|
257
296
|
/** Nested policy validation overrides. */
|
|
258
297
|
readonly policy?: PolicyValidationInput;
|
|
259
298
|
/** Nested name constraint overrides. */
|
|
260
299
|
readonly nameConstraints?: InitialNameConstraintsInput;
|
|
261
300
|
}
|
|
262
301
|
/** Input for {@linkcode validateForCa}. Enforces `basicConstraints.ca` on the leaf. */
|
|
263
|
-
interface ValidateForCaInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
|
|
302
|
+
export interface ValidateForCaInput extends BuildCandidatePathInput, PolicyValidationInput, InitialNameConstraintsInput {
|
|
264
303
|
/** Nested policy validation overrides. */
|
|
265
304
|
readonly policy?: PolicyValidationInput;
|
|
266
305
|
/** Nested name constraint overrides. */
|
|
@@ -288,12 +327,12 @@ interface ValidateForCaInput extends BuildCandidatePathInput, PolicyValidationIn
|
|
|
288
327
|
* }
|
|
289
328
|
* ```
|
|
290
329
|
*/
|
|
291
|
-
declare function buildCandidatePath(input: BuildCandidatePathInput): Promise<BuildCandidatePathResult>;
|
|
330
|
+
export declare function buildCandidatePath(input: BuildCandidatePathInput): Promise<BuildCandidatePathResult>;
|
|
292
331
|
/**
|
|
293
332
|
* Validates a pre-built certificate chain for time, constraints, policy, and
|
|
294
333
|
* optionally leaf purpose. Wrap the result of {@linkcode buildCandidatePath}.
|
|
295
334
|
*/
|
|
296
|
-
declare function validateCandidatePath(input: ValidateCandidatePathInput): Promise<ValidateCandidatePathResult>;
|
|
335
|
+
export declare function validateCandidatePath(input: ValidateCandidatePathInput): Promise<ValidateCandidatePathResult>;
|
|
297
336
|
/**
|
|
298
337
|
* All-in-one certificate chain verification: builds a candidate path then
|
|
299
338
|
* validates time, constraints, policy, purpose, and optional service identity.
|
|
@@ -317,7 +356,7 @@ declare function validateCandidatePath(input: ValidateCandidatePathInput): Promi
|
|
|
317
356
|
* }
|
|
318
357
|
* ```
|
|
319
358
|
*/
|
|
320
|
-
declare function verifyCertificateChain(input: VerifyCertificateChainInput): Promise<VerifyChainResult>;
|
|
359
|
+
export declare function verifyCertificateChain(input: VerifyCertificateChainInput): Promise<VerifyChainResult>;
|
|
321
360
|
/**
|
|
322
361
|
* Verifies the self-signature of a PKCS#10 certificate signing request.
|
|
323
362
|
*
|
|
@@ -334,7 +373,7 @@ declare function verifyCertificateChain(input: VerifyCertificateChainInput): Pro
|
|
|
334
373
|
* }
|
|
335
374
|
* ```
|
|
336
375
|
*/
|
|
337
|
-
declare function verifyCertificateSigningRequest(input: CsrSource): Promise<VerifyRequestResult>;
|
|
376
|
+
export declare function verifyCertificateSigningRequest(input: CsrSource): Promise<VerifyRequestResult>;
|
|
338
377
|
/**
|
|
339
378
|
* Standalone EKU check against a verified certificate chain.
|
|
340
379
|
* Validates that the leaf has the requested purpose and that
|
|
@@ -350,9 +389,9 @@ declare function verifyCertificateSigningRequest(input: CsrSource): Promise<Veri
|
|
|
350
389
|
* }
|
|
351
390
|
* ```
|
|
352
391
|
*/
|
|
353
|
-
declare function checkExtendedKeyUsage(chain: readonly ParsedCertificate[], purpose: EkuCheckPurpose): EkuCheckResult;
|
|
392
|
+
export declare function checkExtendedKeyUsage(chain: readonly ParsedCertificate[], purpose: EkuCheckPurpose): EkuCheckResult;
|
|
354
393
|
/** Extracts a {@linkcode TrustAnchor} from a parsed certificate, copying the subject, SPKI, and key identifiers. */
|
|
355
|
-
declare function trustAnchorFromCertificate(certificate: ParsedCertificate): TrustAnchor;
|
|
394
|
+
export declare function trustAnchorFromCertificate(certificate: ParsedCertificate): TrustAnchor;
|
|
356
395
|
/**
|
|
357
396
|
* Validates a certificate chain for TLS server use:
|
|
358
397
|
* chain verification + `serverAuth` EKU (leaf + intermediate propagation)
|
|
@@ -372,7 +411,7 @@ declare function trustAnchorFromCertificate(certificate: ParsedCertificate): Tru
|
|
|
372
411
|
* }
|
|
373
412
|
* ```
|
|
374
413
|
*/
|
|
375
|
-
declare function validateForTlsServer(input: ValidateForTlsServerInput): Promise<VerifyChainResult>;
|
|
414
|
+
export declare function validateForTlsServer(input: ValidateForTlsServerInput): Promise<VerifyChainResult>;
|
|
376
415
|
/**
|
|
377
416
|
* Validates a certificate chain for TLS client use:
|
|
378
417
|
* chain verification + `clientAuth` EKU (leaf + intermediate propagation).
|
|
@@ -387,7 +426,7 @@ declare function validateForTlsServer(input: ValidateForTlsServerInput): Promise
|
|
|
387
426
|
* });
|
|
388
427
|
* ```
|
|
389
428
|
*/
|
|
390
|
-
declare function validateForTlsClient(input: ValidateForTlsClientInput): Promise<VerifyChainResult>;
|
|
429
|
+
export declare function validateForTlsClient(input: ValidateForTlsClientInput): Promise<VerifyChainResult>;
|
|
391
430
|
/**
|
|
392
431
|
* Validates a certificate chain for code signing:
|
|
393
432
|
* chain verification + `codeSigning` EKU (leaf + intermediate propagation).
|
|
@@ -402,7 +441,7 @@ declare function validateForTlsClient(input: ValidateForTlsClientInput): Promise
|
|
|
402
441
|
* });
|
|
403
442
|
* ```
|
|
404
443
|
*/
|
|
405
|
-
declare function validateForCodeSigning(input: ValidateForCodeSigningInput): Promise<VerifyChainResult>;
|
|
444
|
+
export declare function validateForCodeSigning(input: ValidateForCodeSigningInput): Promise<VerifyChainResult>;
|
|
406
445
|
/**
|
|
407
446
|
* Validates a certificate chain for CA use:
|
|
408
447
|
* chain verification + `basicConstraints.ca` check on the leaf.
|
|
@@ -417,7 +456,6 @@ declare function validateForCodeSigning(input: ValidateForCodeSigningInput): Pro
|
|
|
417
456
|
* });
|
|
418
457
|
* ```
|
|
419
458
|
*/
|
|
420
|
-
declare function validateForCa(input: ValidateForCaInput): Promise<VerifyChainResult>;
|
|
421
|
-
|
|
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 };
|
|
459
|
+
export declare function validateForCa(input: ValidateForCaInput): Promise<VerifyChainResult>;
|
|
460
|
+
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
461
|
//# sourceMappingURL=verify.d.ts.map
|