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.
- package/CHANGELOG.md +2064 -0
- package/README.md +111 -183
- package/dist/crypto/crypto.d.ts +104 -0
- package/dist/crypto/crypto.js +105 -0
- package/dist/crypto/crypto.js.map +1 -0
- package/dist/crypto.d.ts +4 -0
- package/dist/crypto.js +1 -0
- 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 +18 -14
- package/dist/index.js +19 -17
- package/dist/internal/asn1/asn1.d.ts +3 -6
- package/dist/internal/asn1/asn1.js +355 -44
- 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 +42 -43
- package/dist/internal/asn1/der.js +148 -56
- package/dist/internal/asn1/der.js.map +1 -1
- package/dist/internal/asn1/oids.js +90 -54
- 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 +5 -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 +51 -0
- package/dist/internal/crypto/pbes2.js +86 -34
- package/dist/internal/crypto/pbes2.js.map +1 -1
- package/dist/internal/crypto/rsa-pss.js +48 -44
- package/dist/internal/crypto/rsa-pss.js.map +1 -1
- package/dist/internal/crypto/sig-verify.d.ts +28 -0
- package/dist/internal/crypto/sig-verify.js +111 -62
- 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 +8 -3
- package/dist/internal/shared/base64.js.map +1 -1
- package/dist/internal/shared/dn.d.ts +13 -0
- package/dist/internal/shared/dn.js +101 -48
- 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 +66 -0
- package/dist/internal/shared/ip.js +19 -3
- 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 +4 -0
- package/dist/internal/verify/verify-path.js +264 -128
- package/dist/internal/verify/verify-path.js.map +1 -1
- package/dist/internal/x509/directory-name.js +23 -0
- package/dist/internal/x509/directory-name.js.map +1 -0
- package/dist/internal/x509/extension-bits.js +15 -13
- package/dist/internal/x509/extension-bits.js.map +1 -1
- package/dist/internal/x509/extension-errors.d.ts +3 -0
- package/dist/internal/x509/extension-errors.js +19 -0
- package/dist/internal/x509/extension-errors.js.map +1 -0
- package/dist/internal/x509/extension-registry.js +157 -81
- 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 +27 -0
- package/dist/internal/x509/general-name-tags.js.map +1 -0
- package/dist/internal/x509/general-name.js +183 -0
- package/dist/internal/x509/general-name.js.map +1 -0
- package/dist/internal/x509/name-fields.js +21 -12
- 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 +124 -95
- package/dist/keys/keys.js +362 -214
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys.d.ts +3 -2
- package/dist/keys.js +3 -2
- package/dist/pem/pem.d.ts +17 -19
- package/dist/pem/pem.js +122 -41
- 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 +123 -53
- package/dist/pkcs/pkcs7.js +314 -238
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +5 -4
- package/dist/result/result.d.ts +43 -28
- package/dist/result/result.js +27 -14
- 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 +456 -206
- package/dist/revocation/chain.js.map +1 -1
- package/dist/revocation/crl.d.ts +140 -65
- package/dist/revocation/crl.js +691 -391
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +145 -69
- package/dist/revocation/ocsp.js +347 -297
- package/dist/revocation/ocsp.js.map +1 -1
- package/dist/revocation/revocation.d.ts +48 -36
- package/dist/revocation/revocation.js +112 -63
- package/dist/revocation/revocation.js.map +1 -1
- package/dist/revocation.d.ts +5 -5
- package/dist/revocation.js +5 -5
- package/dist/verify/identity.d.ts +18 -20
- package/dist/verify/identity.js +120 -90
- package/dist/verify/identity.js.map +1 -1
- package/dist/verify/name-constraints.d.ts +1 -4
- package/dist/verify/policy.d.ts +15 -8
- package/dist/verify/verify.d.ts +86 -46
- package/dist/verify/verify.js +309 -143
- package/dist/verify/verify.js.map +1 -1
- package/dist/verify.d.ts +3 -2
- package/dist/verify.js +4 -3
- package/dist/x509/certificate.d.ts +50 -28
- package/dist/x509/certificate.js +69 -36
- package/dist/x509/certificate.js.map +1 -1
- package/dist/x509/csr.d.ts +9 -8
- package/dist/x509/csr.js +10 -11
- package/dist/x509/csr.js.map +1 -1
- package/dist/x509/extensions.d.ts +207 -82
- package/dist/x509/extensions.js +561 -128
- 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 +20 -4
- package/dist/x509/name-text.js.map +1 -1
- package/dist/x509/name.d.ts +15 -14
- package/dist/x509/name.js +23 -19
- package/dist/x509/name.js.map +1 -1
- package/dist/x509/parse.d.ts +165 -64
- package/dist/x509/parse.js +444 -459
- package/dist/x509/parse.js.map +1 -1
- package/dist/x509.d.ts +8 -5
- package/dist/x509.js +10 -8
- package/package.json +90 -65
package/dist/revocation/crl.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { ErrorResult, Micro509Error } from "../result/result.js";
|
|
1
|
+
import { DecodeFailureCode, DecodeRefusalCode, ErrorResult, Micro509Error } from "../result/result.js";
|
|
2
2
|
import { NameInput } from "../x509/name.js";
|
|
3
|
-
import { DistributionPoint, GeneralName, IssuingDistributionPoint } from "../x509/extensions.js";
|
|
3
|
+
import { DistributionPoint, DistributionPointReason, GeneralName, IssuingDistributionPoint } from "../x509/extensions.js";
|
|
4
4
|
import { ParsedCertificate, ParsedDistributionPoint, ParsedIssuingDistributionPoint, ParsedName } from "../x509/parse.js";
|
|
5
|
-
//#region src/revocation/crl.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Single revoked certificate entry for {@linkcode createCertificateRevocationList}.
|
|
8
7
|
*/
|
|
9
|
-
interface RevokedCertificateInput {
|
|
8
|
+
export interface RevokedCertificateInput {
|
|
10
9
|
/** DER-encoded certificate serial number to revoke. */
|
|
11
10
|
readonly serialNumber: Uint8Array;
|
|
12
11
|
/** When the certificate was revoked. Defaults to `thisUpdate` of the CRL. */
|
|
@@ -21,27 +20,57 @@ interface RevokedCertificateInput {
|
|
|
21
20
|
*
|
|
22
21
|
* `removeFromCRL` is used in delta CRLs to un-hold a certificate.
|
|
23
22
|
*/
|
|
24
|
-
type RevocationReason = "unspecified" | "keyCompromise" | "cACompromise" | "affiliationChanged" | "superseded" | "cessationOfOperation" | "certificateHold" | "removeFromCRL" | "privilegeWithdrawn" | "aACompromise";
|
|
23
|
+
export type RevocationReason = "unspecified" | "keyCompromise" | "cACompromise" | "affiliationChanged" | "superseded" | "cessationOfOperation" | "certificateHold" | "removeFromCRL" | "privilegeWithdrawn" | "aACompromise";
|
|
24
|
+
/**
|
|
25
|
+
* A CRLReason code outside the RFC 5280 §5.3.1 enumeration, such as the unused
|
|
26
|
+
* value 7 or X.509 (10/2019) `weakAlgorithmOrKey (11)`.
|
|
27
|
+
*/
|
|
28
|
+
export interface UnrecognizedRevocationReason {
|
|
29
|
+
/** Discriminator for a code with no {@linkcode RevocationReason} name. */
|
|
30
|
+
readonly type: "unrecognized";
|
|
31
|
+
/** The decoded ENUMERATED value. */
|
|
32
|
+
readonly code: bigint;
|
|
33
|
+
}
|
|
34
|
+
/** A decoded CRLReason: a named {@linkcode RevocationReason} or an {@linkcode UnrecognizedRevocationReason}. */
|
|
35
|
+
export type ParsedRevocationReason = RevocationReason | UnrecognizedRevocationReason;
|
|
36
|
+
/**
|
|
37
|
+
* Treatment of revocation evidence whose CRLReason is an
|
|
38
|
+
* {@linkcode UnrecognizedRevocationReason}. RFC 5280 §5.3.1 and Appendix B do
|
|
39
|
+
* not say what a relying party does with such a code.
|
|
40
|
+
*
|
|
41
|
+
* - `'revoked'`: the certificate is revoked, with the code reported (default).
|
|
42
|
+
* A certificate that a CRL or OCSP response revokes is never reported `good`.
|
|
43
|
+
* - `'reject'`: the evidence cannot settle the certificate's status.
|
|
44
|
+
*/
|
|
45
|
+
export type UnrecognizedReasonCodePolicy = "revoked" | "reject";
|
|
25
46
|
/**
|
|
26
47
|
* Input for {@linkcode createCertificateRevocationList}.
|
|
27
48
|
*/
|
|
28
|
-
interface CreateCertificateRevocationListInput {
|
|
49
|
+
export interface CreateCertificateRevocationListInput {
|
|
29
50
|
/** Distinguished name of the CRL issuer (typically the signing CA). */
|
|
30
51
|
readonly issuer: NameInput;
|
|
31
52
|
/** Private key used to sign the CRL. Algorithm is inferred from the key. */
|
|
32
53
|
readonly signerPrivateKey: CryptoKey;
|
|
33
|
-
/**
|
|
34
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Certificate of the CRL issuer. Its subject key identifier becomes the
|
|
56
|
+
* Authority Key Identifier extension (RFC 5280 §5.2.1). An issuer
|
|
57
|
+
* certificate without one yields a key identifier derived from its public key.
|
|
58
|
+
*/
|
|
59
|
+
readonly issuerCertificate: CrlCertificateSource;
|
|
35
60
|
/** Issuance timestamp. Defaults to `new Date()`. */
|
|
36
61
|
readonly thisUpdate?: Date;
|
|
37
|
-
/**
|
|
38
|
-
readonly nextUpdate
|
|
62
|
+
/** Date by which the next CRL will be issued. Must be at least one second later than `thisUpdate`. */
|
|
63
|
+
readonly nextUpdate: Date;
|
|
39
64
|
/** Certificates to list as revoked in this CRL. */
|
|
40
65
|
readonly revokedCertificates?: readonly RevokedCertificateInput[];
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Monotonically-increasing CRL sequence number (CRLNumber extension, RFC 5280
|
|
68
|
+
* §5.2.3): non-negative and at most 20 octets encoded. Pass a `bigint` above
|
|
69
|
+
* `Number.MAX_SAFE_INTEGER`.
|
|
70
|
+
*/
|
|
71
|
+
readonly crlNumber: number | bigint;
|
|
72
|
+
/** If set, marks this CRL as a delta CRL referencing the given base CRL number, bounded like {@linkcode crlNumber}. */
|
|
73
|
+
readonly baseCrlNumber?: number | bigint;
|
|
45
74
|
/** Issuing distribution point extension — scopes this CRL to a subset of certificates. */
|
|
46
75
|
readonly issuingDistributionPoint?: IssuingDistributionPoint;
|
|
47
76
|
/** Freshest CRL distribution points — tells relying parties where to find delta CRLs. */
|
|
@@ -50,7 +79,7 @@ interface CreateCertificateRevocationListInput {
|
|
|
50
79
|
/**
|
|
51
80
|
* Encoded CRL in multiple serialisation formats, returned by {@linkcode createCertificateRevocationList}.
|
|
52
81
|
*/
|
|
53
|
-
interface CertificateRevocationListMaterial {
|
|
82
|
+
export interface CertificateRevocationListMaterial {
|
|
54
83
|
/** Raw DER bytes of the signed CRL. */
|
|
55
84
|
readonly der: Uint8Array;
|
|
56
85
|
/** PEM-encoded CRL (`-----BEGIN X509 CRL-----`). */
|
|
@@ -61,13 +90,13 @@ interface CertificateRevocationListMaterial {
|
|
|
61
90
|
/**
|
|
62
91
|
* A single revoked-certificate entry decoded from a CRL.
|
|
63
92
|
*/
|
|
64
|
-
interface ParsedRevokedCertificate {
|
|
93
|
+
export interface ParsedRevokedCertificate {
|
|
65
94
|
/** Hex-encoded serial number of the revoked certificate. */
|
|
66
95
|
readonly serialNumberHex: string;
|
|
67
96
|
/** When the CA declared this certificate revoked. */
|
|
68
97
|
readonly revocationDate: Date;
|
|
69
98
|
/** RFC 5280 CRLReason, if the entry carries one. */
|
|
70
|
-
readonly reasonCode?:
|
|
99
|
+
readonly reasonCode?: ParsedRevocationReason;
|
|
71
100
|
/** When the key or certificate actually became suspect, if present. */
|
|
72
101
|
readonly invalidityDate?: Date;
|
|
73
102
|
/** Indirect-CRL certificate issuer override (RFC 5280 §5.3.3). */
|
|
@@ -77,7 +106,7 @@ interface ParsedRevokedCertificate {
|
|
|
77
106
|
* Decoded X.509 CRL, returned by {@linkcode parseCertificateRevocationListDer}
|
|
78
107
|
* and {@linkcode parseCertificateRevocationListPem}.
|
|
79
108
|
*/
|
|
80
|
-
interface ParsedCertificateRevocationList {
|
|
109
|
+
export interface ParsedCertificateRevocationList {
|
|
81
110
|
/** Original DER bytes when this object came from {@linkcode parseCertificateRevocationListDer} or PEM parsing. */
|
|
82
111
|
readonly der?: Uint8Array;
|
|
83
112
|
/** CRL version (1 = v1, 2 = v2 with extensions). */
|
|
@@ -88,9 +117,9 @@ interface ParsedCertificateRevocationList {
|
|
|
88
117
|
readonly signatureValue: Uint8Array;
|
|
89
118
|
/** CRL issuer distinguished name. */
|
|
90
119
|
readonly issuer: ParsedName;
|
|
91
|
-
/**
|
|
120
|
+
/** Issue date of this CRL. */
|
|
92
121
|
readonly thisUpdate: Date;
|
|
93
|
-
/**
|
|
122
|
+
/** Date by which the next CRL will be issued. Absent when the encoded CRL omits it. */
|
|
94
123
|
readonly nextUpdate?: Date;
|
|
95
124
|
/** OID of the algorithm used to sign this CRL. */
|
|
96
125
|
readonly signatureAlgorithmOid: string;
|
|
@@ -105,9 +134,9 @@ interface ParsedCertificateRevocationList {
|
|
|
105
134
|
/** Hex-encoded Authority Key Identifier, if the extension is present. */
|
|
106
135
|
readonly authorityKeyIdentifier?: string;
|
|
107
136
|
/** CRLNumber extension value — monotonically increasing sequence number. */
|
|
108
|
-
readonly crlNumber?:
|
|
137
|
+
readonly crlNumber?: bigint;
|
|
109
138
|
/** Delta CRL indicator — present only on delta CRLs, referencing the base CRL number. */
|
|
110
|
-
readonly baseCrlNumber?:
|
|
139
|
+
readonly baseCrlNumber?: bigint;
|
|
111
140
|
/** Issuing distribution point extension — scopes this CRL to a certificate subset. */
|
|
112
141
|
readonly issuingDistributionPoint?: ParsedIssuingDistributionPoint;
|
|
113
142
|
/** Freshest CRL extension — points to delta CRL locations. */
|
|
@@ -116,11 +145,15 @@ interface ParsedCertificateRevocationList {
|
|
|
116
145
|
readonly revokedCertificates: readonly ParsedRevokedCertificate[];
|
|
117
146
|
}
|
|
118
147
|
/** PEM string, DER bytes, or already-parsed CRL. */
|
|
119
|
-
type CrlSource = string | Uint8Array | ParsedCertificateRevocationList;
|
|
148
|
+
export type CrlSource = string | Uint8Array | ParsedCertificateRevocationList;
|
|
120
149
|
/** PEM string, DER bytes, or already-parsed certificate. */
|
|
121
|
-
type CrlCertificateSource = string | Uint8Array | ParsedCertificate;
|
|
122
|
-
/**
|
|
123
|
-
|
|
150
|
+
export type CrlCertificateSource = string | Uint8Array | ParsedCertificate;
|
|
151
|
+
/**
|
|
152
|
+
* Failure detail when CRL signature verification fails. `unsupported` and
|
|
153
|
+
* `limit_exceeded` report a CRL or issuer certificate micro509 cannot decode
|
|
154
|
+
* (see {@linkcode ParseCertificateRevocationListErrorCode}).
|
|
155
|
+
*/
|
|
156
|
+
export interface VerifyCertificateRevocationListSignatureFailure extends Micro509Error<"signature_invalid" | DecodeRefusalCode> {
|
|
124
157
|
/** Always `false` for failures. */
|
|
125
158
|
readonly ok: false;
|
|
126
159
|
}
|
|
@@ -129,30 +162,42 @@ interface VerifyCertificateRevocationListSignatureFailure extends Micro509Error<
|
|
|
129
162
|
*
|
|
130
163
|
* On success, `value` is the parsed CRL whose signature has been verified.
|
|
131
164
|
*/
|
|
132
|
-
type VerifyCertificateRevocationListSignatureResult = {
|
|
165
|
+
export type VerifyCertificateRevocationListSignatureResult = {
|
|
133
166
|
readonly ok: true;
|
|
134
167
|
/** Parsed CRL with a verified signature. */
|
|
135
168
|
readonly value: ParsedCertificateRevocationList;
|
|
136
|
-
} | ErrorResult<"signature_invalid", Record<never, never>, VerifyCertificateRevocationListSignatureFailure>;
|
|
169
|
+
} | ErrorResult<"signature_invalid" | DecodeRefusalCode, Record<never, never>, VerifyCertificateRevocationListSignatureFailure>;
|
|
137
170
|
/**
|
|
138
171
|
* Input for {@linkcode validateCertificateRevocationList}.
|
|
139
172
|
*/
|
|
140
|
-
interface ValidateCertificateRevocationListInput {
|
|
173
|
+
export interface ValidateCertificateRevocationListInput {
|
|
141
174
|
/** The CRL to validate. */
|
|
142
175
|
readonly crl: CrlSource;
|
|
143
176
|
/** Certificate of the CA that should have signed the CRL. */
|
|
144
177
|
readonly issuerCertificate: CrlCertificateSource;
|
|
145
178
|
/** Evaluation time for freshness checks. Defaults to `new Date()`. */
|
|
146
179
|
readonly at?: Date;
|
|
147
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* Tolerance in milliseconds for clock skew when checking `thisUpdate` and
|
|
182
|
+
* `nextUpdate`. It also widens `maxAgeMs` by the same amount.
|
|
183
|
+
*/
|
|
148
184
|
readonly clockSkewMs?: number;
|
|
185
|
+
/**
|
|
186
|
+
* Maximum age of `thisUpdate` at `at`, in milliseconds. A CRL older than
|
|
187
|
+
* this fails with `stale_crl` even when `nextUpdate` is absent or later.
|
|
188
|
+
* Unbounded by default, in which case a CRL without `nextUpdate` fails with
|
|
189
|
+
* `stale_crl`. RFC 5280 §3.3 leaves the required recency of revocation data
|
|
190
|
+
* to local policy.
|
|
191
|
+
*/
|
|
192
|
+
readonly maxAgeMs?: number;
|
|
149
193
|
}
|
|
150
194
|
/**
|
|
151
195
|
* Failure detail for {@linkcode validateCertificateRevocationList}.
|
|
152
196
|
*
|
|
153
|
-
* Possible codes: `signature_invalid`, `issuer_mismatch`, `stale_crl`, `crl_sign_not_permitted
|
|
197
|
+
* Possible codes: `signature_invalid`, `issuer_mismatch`, `stale_crl`, `crl_sign_not_permitted`,
|
|
198
|
+
* and `unsupported` or `limit_exceeded` for a CRL or issuer certificate micro509 cannot decode.
|
|
154
199
|
*/
|
|
155
|
-
interface ValidateCertificateRevocationListFailure extends Micro509Error<"signature_invalid" | "issuer_mismatch" | "stale_crl" | "crl_sign_not_permitted"> {
|
|
200
|
+
export interface ValidateCertificateRevocationListFailure extends Micro509Error<"signature_invalid" | "issuer_mismatch" | "stale_crl" | "crl_sign_not_permitted" | DecodeRefusalCode> {
|
|
156
201
|
/** Always `false` for failures. */
|
|
157
202
|
readonly ok: false;
|
|
158
203
|
}
|
|
@@ -161,51 +206,71 @@ interface ValidateCertificateRevocationListFailure extends Micro509Error<"signat
|
|
|
161
206
|
*
|
|
162
207
|
* On success, the CRL has passed signature, issuer, key-usage, and freshness checks.
|
|
163
208
|
*/
|
|
164
|
-
type ValidateCertificateRevocationListResult = {
|
|
209
|
+
export type ValidateCertificateRevocationListResult = {
|
|
165
210
|
readonly ok: true;
|
|
166
211
|
/** Validated and parsed CRL. */
|
|
167
212
|
readonly value: ParsedCertificateRevocationList;
|
|
168
|
-
} | ErrorResult<"signature_invalid" | "issuer_mismatch" | "stale_crl" | "crl_sign_not_permitted", Record<never, never>, ValidateCertificateRevocationListFailure>;
|
|
213
|
+
} | ErrorResult<"signature_invalid" | "issuer_mismatch" | "stale_crl" | "crl_sign_not_permitted" | DecodeRefusalCode, Record<never, never>, ValidateCertificateRevocationListFailure>;
|
|
169
214
|
/**
|
|
170
215
|
* Input for {@linkcode checkCertificateRevocationAgainstCrl}.
|
|
171
216
|
*/
|
|
172
|
-
interface CheckCertificateRevocationAgainstCrlInput {
|
|
217
|
+
export interface CheckCertificateRevocationAgainstCrlInput {
|
|
173
218
|
/** Certificate whose revocation status to check. */
|
|
174
219
|
readonly certificate: CrlCertificateSource;
|
|
175
220
|
/** Issuer of `certificate` — also expected signer of the CRL. */
|
|
176
221
|
readonly issuerCertificate: CrlCertificateSource;
|
|
177
222
|
/** Complete (base) CRL to check against. */
|
|
178
223
|
readonly crl: CrlSource;
|
|
179
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Optional delta CRL for more recent revocation information. With a delta
|
|
226
|
+
* CRL, the freshness checks and `maxAgeMs` apply to the delta CRL alone,
|
|
227
|
+
* whose `thisUpdate` and `nextUpdate` the constructed CRL takes
|
|
228
|
+
* (RFC 5280 §5.2.4, §6.3.3(a)(1)(i)). A delta CRL without `nextUpdate` is
|
|
229
|
+
* never current and fails with `stale_crl`.
|
|
230
|
+
*/
|
|
180
231
|
readonly deltaCrl?: CrlSource;
|
|
181
232
|
/** Evaluation time. Defaults to `new Date()`. */
|
|
182
233
|
readonly at?: Date;
|
|
183
|
-
/** Clock-skew tolerance in milliseconds for freshness checks. */
|
|
234
|
+
/** Clock-skew tolerance in milliseconds for freshness checks. It also widens `maxAgeMs`. */
|
|
184
235
|
readonly clockSkewMs?: number;
|
|
236
|
+
/** Maximum age of each CRL's `thisUpdate` in milliseconds. See {@linkcode ValidateCertificateRevocationListInput.maxAgeMs}. */
|
|
237
|
+
readonly maxAgeMs?: number;
|
|
238
|
+
/**
|
|
239
|
+
* Treatment of a revoked entry whose CRLReason is unrecognized. `'reject'`
|
|
240
|
+
* fails the check with `reason_code_unrecognized`. Defaults to `'revoked'`.
|
|
241
|
+
*/
|
|
242
|
+
readonly unrecognizedReasonCode?: UnrecognizedReasonCodePolicy;
|
|
185
243
|
}
|
|
186
244
|
/** Error codes that {@linkcode checkCertificateRevocationAgainstCrl} may return. */
|
|
187
|
-
type CheckCertificateRevocationAgainstCrlErrorCode = "signature_invalid" | "issuer_mismatch" | "stale_crl" | "crl_sign_not_permitted" | "non_applicable";
|
|
245
|
+
export type CheckCertificateRevocationAgainstCrlErrorCode = "signature_invalid" | "issuer_mismatch" | "stale_crl" | "crl_sign_not_permitted" | "non_applicable" | "reason_code_unrecognized" | DecodeRefusalCode;
|
|
188
246
|
/** Structured reason why a CRL was deemed non-applicable to a given certificate. */
|
|
189
|
-
type CrlApplicabilityFailureReason = "certificate_scope_mismatch" | "delta_crl_incompatible" | "unsupported_delta_crl" | "distribution_point_mismatch" | "unsupported_indirect_crl" | "issuer_mismatch" | "reasons_mismatch";
|
|
247
|
+
export type CrlApplicabilityFailureReason = "certificate_scope_mismatch" | "delta_crl_incompatible" | "unsupported_delta_crl" | "distribution_point_mismatch" | "unsupported_indirect_crl" | "issuer_mismatch" | "reasons_mismatch";
|
|
190
248
|
/** Structured details attached to a {@linkcode CheckCertificateRevocationAgainstCrlFailure}. */
|
|
191
|
-
interface CheckCertificateRevocationAgainstCrlFailureDetails {
|
|
249
|
+
export interface CheckCertificateRevocationAgainstCrlFailureDetails {
|
|
192
250
|
/** Why the CRL was non-applicable, when the error code is `non_applicable`. */
|
|
193
251
|
readonly reason?: CrlApplicabilityFailureReason;
|
|
194
252
|
}
|
|
195
253
|
/** Failure detail for {@linkcode checkCertificateRevocationAgainstCrl}. */
|
|
196
|
-
interface CheckCertificateRevocationAgainstCrlFailure extends Micro509Error<CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailureDetails> {
|
|
254
|
+
export interface CheckCertificateRevocationAgainstCrlFailure extends Micro509Error<CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailureDetails> {
|
|
197
255
|
/** Always `false` for failures. */
|
|
198
256
|
readonly ok: false;
|
|
199
257
|
}
|
|
200
258
|
/** Success value when the certificate is not found in the CRL. */
|
|
201
|
-
interface CheckCertificateRevocationAgainstCrlGoodValue {
|
|
259
|
+
export interface CheckCertificateRevocationAgainstCrlGoodValue {
|
|
202
260
|
/** Certificate is not revoked. */
|
|
203
261
|
readonly status: "good";
|
|
204
262
|
/** The validated CRL that was checked. */
|
|
205
263
|
readonly crl: ParsedCertificateRevocationList;
|
|
264
|
+
/**
|
|
265
|
+
* Revocation reasons this check covered, the RFC 5280 §6.3.3 (d)
|
|
266
|
+
* interim_reasons_mask: the matched distribution point's reasons intersected
|
|
267
|
+
* with the CRL's `onlySomeReasons`, either alone when the other is absent,
|
|
268
|
+
* or every reason when both are.
|
|
269
|
+
*/
|
|
270
|
+
readonly coveredReasons: readonly DistributionPointReason[];
|
|
206
271
|
}
|
|
207
272
|
/** Success value when the certificate is found as revoked in the CRL. */
|
|
208
|
-
interface CheckCertificateRevocationAgainstCrlRevokedValue {
|
|
273
|
+
export interface CheckCertificateRevocationAgainstCrlRevokedValue {
|
|
209
274
|
/** Certificate is revoked. */
|
|
210
275
|
readonly status: "revoked";
|
|
211
276
|
/** The validated CRL that contained the revocation entry. */
|
|
@@ -213,25 +278,26 @@ interface CheckCertificateRevocationAgainstCrlRevokedValue {
|
|
|
213
278
|
/** When the CA declared this certificate revoked. */
|
|
214
279
|
readonly revocationDate: Date;
|
|
215
280
|
/** CRLReason from the entry, if present. */
|
|
216
|
-
readonly reasonCode?:
|
|
281
|
+
readonly reasonCode?: ParsedRevocationReason;
|
|
217
282
|
}
|
|
218
283
|
/** Discriminated union of `good` and `revoked` outcomes. */
|
|
219
|
-
type CheckCertificateRevocationAgainstCrlValue = CheckCertificateRevocationAgainstCrlGoodValue | CheckCertificateRevocationAgainstCrlRevokedValue;
|
|
284
|
+
export type CheckCertificateRevocationAgainstCrlValue = CheckCertificateRevocationAgainstCrlGoodValue | CheckCertificateRevocationAgainstCrlRevokedValue;
|
|
220
285
|
/**
|
|
221
286
|
* Result of {@linkcode checkCertificateRevocationAgainstCrl}.
|
|
222
287
|
*
|
|
223
288
|
* On success `value.status` is `'good'` or `'revoked'`.
|
|
224
289
|
* On failure the CRL could not be validated or was non-applicable.
|
|
225
290
|
*/
|
|
226
|
-
type CheckCertificateRevocationAgainstCrlResult = {
|
|
291
|
+
export type CheckCertificateRevocationAgainstCrlResult = {
|
|
227
292
|
readonly ok: true;
|
|
228
293
|
readonly value: CheckCertificateRevocationAgainstCrlValue;
|
|
229
294
|
} | ErrorResult<CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailureDetails, CheckCertificateRevocationAgainstCrlFailure>;
|
|
230
295
|
/**
|
|
231
296
|
* Signs and encodes an X.509 v2 CRL.
|
|
232
297
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
298
|
+
* Always embeds the Authority Key Identifier and CRLNumber extensions
|
|
299
|
+
* (RFC 5280 §5.2), plus delta CRL indicator, issuing distribution point and
|
|
300
|
+
* freshest-CRL extensions as configured.
|
|
235
301
|
*
|
|
236
302
|
* @example
|
|
237
303
|
* ```ts
|
|
@@ -240,7 +306,7 @@ type CheckCertificateRevocationAgainstCrlResult = {
|
|
|
240
306
|
* const crl = await createCertificateRevocationList({
|
|
241
307
|
* issuer: { commonName: 'Example CA' },
|
|
242
308
|
* signerPrivateKey: caPrivateKey,
|
|
243
|
-
*
|
|
309
|
+
* issuerCertificate: caCertificatePem,
|
|
244
310
|
* thisUpdate: new Date('2025-01-01'),
|
|
245
311
|
* nextUpdate: new Date('2025-02-01'),
|
|
246
312
|
* crlNumber: 42,
|
|
@@ -251,16 +317,16 @@ type CheckCertificateRevocationAgainstCrlResult = {
|
|
|
251
317
|
* // crl.pem, crl.der, crl.base64
|
|
252
318
|
* ```
|
|
253
319
|
*/
|
|
254
|
-
declare function createCertificateRevocationList(input: CreateCertificateRevocationListInput): Promise<CertificateRevocationListMaterial>;
|
|
320
|
+
export declare function createCertificateRevocationList(input: CreateCertificateRevocationListInput): Promise<CertificateRevocationListMaterial>;
|
|
255
321
|
/** Machine-readable failure reason for the CRL parsers. */
|
|
256
|
-
type ParseCertificateRevocationListErrorCode =
|
|
322
|
+
export type ParseCertificateRevocationListErrorCode = DecodeFailureCode;
|
|
257
323
|
/** Structured failure payload for CRL parsing. */
|
|
258
|
-
interface ParseCertificateRevocationListFailure extends Micro509Error<ParseCertificateRevocationListErrorCode> {
|
|
324
|
+
export interface ParseCertificateRevocationListFailure extends Micro509Error<ParseCertificateRevocationListErrorCode> {
|
|
259
325
|
/** Always `false` for failures. */
|
|
260
326
|
readonly ok: false;
|
|
261
327
|
}
|
|
262
328
|
/** Success-or-failure result from {@linkcode parseCertificateRevocationListDer} / {@linkcode parseCertificateRevocationListPem}. */
|
|
263
|
-
type ParseCertificateRevocationListResult = {
|
|
329
|
+
export type ParseCertificateRevocationListResult = {
|
|
264
330
|
readonly ok: true;
|
|
265
331
|
readonly value: ParsedCertificateRevocationList;
|
|
266
332
|
} | ErrorResult<ParseCertificateRevocationListErrorCode, Record<never, never>, ParseCertificateRevocationListFailure>;
|
|
@@ -270,7 +336,7 @@ type ParseCertificateRevocationListResult = {
|
|
|
270
336
|
* Does not verify the signature — call {@linkcode verifyCertificateRevocationListSignature} or
|
|
271
337
|
* {@linkcode validateCertificateRevocationList} for that.
|
|
272
338
|
*/
|
|
273
|
-
declare function parseCertificateRevocationListDerOrThrow(der: Uint8Array): ParsedCertificateRevocationList;
|
|
339
|
+
export declare function parseCertificateRevocationListDerOrThrow(der: Uint8Array): ParsedCertificateRevocationList;
|
|
274
340
|
/**
|
|
275
341
|
* Decodes a PEM-encoded X.509 CRL (`-----BEGIN X509 CRL-----`).
|
|
276
342
|
*
|
|
@@ -282,7 +348,7 @@ declare function parseCertificateRevocationListDerOrThrow(der: Uint8Array): Pars
|
|
|
282
348
|
* console.log(crl.issuer.values.commonName, crl.revokedCertificates.length);
|
|
283
349
|
* ```
|
|
284
350
|
*/
|
|
285
|
-
declare function parseCertificateRevocationListPemOrThrow(pem: string): ParsedCertificateRevocationList;
|
|
351
|
+
export declare function parseCertificateRevocationListPemOrThrow(pem: string): ParsedCertificateRevocationList;
|
|
286
352
|
/**
|
|
287
353
|
* Decodes a DER-encoded X.509 CRL into a structured {@linkcode ParsedCertificateRevocationList}.
|
|
288
354
|
*
|
|
@@ -291,27 +357,30 @@ declare function parseCertificateRevocationListPemOrThrow(pem: string): ParsedCe
|
|
|
291
357
|
* Does not verify the signature — call {@linkcode verifyCertificateRevocationListSignature} or
|
|
292
358
|
* {@linkcode validateCertificateRevocationList} for that.
|
|
293
359
|
*/
|
|
294
|
-
declare function parseCertificateRevocationListDer(der: Uint8Array): ParseCertificateRevocationListResult;
|
|
360
|
+
export declare function parseCertificateRevocationListDer(der: Uint8Array): ParseCertificateRevocationListResult;
|
|
295
361
|
/**
|
|
296
362
|
* Decodes a PEM-encoded X.509 CRL (`-----BEGIN X509 CRL-----`).
|
|
297
363
|
*
|
|
298
364
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
299
365
|
* throwing form use {@linkcode parseCertificateRevocationListPemOrThrow}.
|
|
300
366
|
*/
|
|
301
|
-
declare function parseCertificateRevocationListPem(pem: string): ParseCertificateRevocationListResult;
|
|
367
|
+
export declare function parseCertificateRevocationListPem(pem: string): ParseCertificateRevocationListResult;
|
|
302
368
|
/**
|
|
303
369
|
* Verifies the CRL signature against the issuer certificate's public key.
|
|
304
370
|
*
|
|
305
371
|
* Does **not** check issuer name match, key-usage, or freshness — use
|
|
306
372
|
* {@linkcode validateCertificateRevocationList} for full validation.
|
|
307
373
|
*/
|
|
308
|
-
declare function verifyCertificateRevocationListSignature(crl: string | Uint8Array, issuerCertificate: string | Uint8Array): Promise<VerifyCertificateRevocationListSignatureResult>;
|
|
374
|
+
export declare function verifyCertificateRevocationListSignature(crl: string | Uint8Array, issuerCertificate: string | Uint8Array): Promise<VerifyCertificateRevocationListSignatureResult>;
|
|
309
375
|
/**
|
|
310
376
|
* Full CRL validation: issuer name match, authority key identifier match,
|
|
311
|
-
*
|
|
312
|
-
*
|
|
377
|
+
* a v3 issuer certificate's key usage must be present and assert cRLSign
|
|
378
|
+
* (RFC 10007 §4), signature verification, `thisUpdate`/`nextUpdate`
|
|
379
|
+
* freshness check (with optional clock-skew tolerance), and the optional
|
|
380
|
+
* `maxAgeMs` bound on `thisUpdate`. A CRL that omits `nextUpdate` fails with
|
|
381
|
+
* `stale_crl` unless `maxAgeMs` is set.
|
|
313
382
|
*/
|
|
314
|
-
declare function validateCertificateRevocationList(input: ValidateCertificateRevocationListInput): Promise<ValidateCertificateRevocationListResult>;
|
|
383
|
+
export declare function validateCertificateRevocationList(input: ValidateCertificateRevocationListInput): Promise<ValidateCertificateRevocationListResult>;
|
|
315
384
|
/**
|
|
316
385
|
* End-to-end revocation check: validates the CRL (and optional delta CRL),
|
|
317
386
|
* verifies applicability via distribution-point and scope matching, then
|
|
@@ -334,12 +403,18 @@ declare function validateCertificateRevocationList(input: ValidateCertificateRev
|
|
|
334
403
|
* }
|
|
335
404
|
* ```
|
|
336
405
|
*/
|
|
337
|
-
declare function checkCertificateRevocationAgainstCrl(input: CheckCertificateRevocationAgainstCrlInput): Promise<CheckCertificateRevocationAgainstCrlResult>;
|
|
406
|
+
export declare function checkCertificateRevocationAgainstCrl(input: CheckCertificateRevocationAgainstCrlInput): Promise<CheckCertificateRevocationAgainstCrlResult>;
|
|
338
407
|
/**
|
|
339
408
|
* Quick serial-number lookup — returns `true` if the serial appears in the
|
|
340
409
|
* CRL's revoked entries. Does **not** validate the CRL or check applicability.
|
|
341
410
|
*/
|
|
342
|
-
declare function isCertificateRevoked(certificateSerialNumber: Uint8Array | string, crl: ParsedCertificateRevocationList): boolean;
|
|
343
|
-
|
|
344
|
-
export
|
|
411
|
+
export declare function isCertificateRevoked(certificateSerialNumber: Uint8Array | string, crl: ParsedCertificateRevocationList): boolean;
|
|
412
|
+
/** Machine-readable reason a CRL encoder rejected its construction input. */
|
|
413
|
+
export type CrlEncoderErrorCode = "crl_number_invalid" | "distribution_point_full_name_empty" | "issuer_certificate_invalid" | "issuer_distinguished_name_empty" | "invalid_date" | "next_update_not_after_this_update";
|
|
414
|
+
/**
|
|
415
|
+
* Maps an integer CRLReason code to its {@linkcode RevocationReason} name, or to
|
|
416
|
+
* an {@linkcode UnrecognizedRevocationReason} carrying a code outside RFC 5280
|
|
417
|
+
* §5.3.1. Returns `undefined` only when `code` is `undefined`.
|
|
418
|
+
*/
|
|
419
|
+
export declare function revocationReasonFromCode(code: bigint | undefined): ParsedRevocationReason | undefined;
|
|
345
420
|
//# sourceMappingURL=crl.d.ts.map
|