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
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { ErrorResult, Micro509Error } from "../result/result.js";
|
|
1
|
+
import { DecodeFailureCode, DecodeRefusalCode, ErrorResult, Micro509Error } from "../result/result.js";
|
|
2
2
|
import { ParsedCertificate, ParsedName } from "../x509/parse.js";
|
|
3
|
-
import { CrlSource } from "./crl.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type OcspHashAlgorithm = "SHA-1" | "SHA-256";
|
|
3
|
+
import { CrlSource, UnrecognizedReasonCodePolicy } from "./crl.js";
|
|
4
|
+
/** Hash algorithm used to compute OCSP CertID fields. RFC 9919 §3.1.1 requires SHA-256 for conforming clients; RFC 6960 defines no default. */
|
|
5
|
+
export type OcspHashAlgorithm = "SHA-1" | "SHA-256";
|
|
7
6
|
/** PEM string, DER bytes, or already-parsed certificate. */
|
|
8
|
-
type OcspCertificateSource = string | Uint8Array | ParsedCertificate;
|
|
7
|
+
export type OcspCertificateSource = string | Uint8Array | ParsedCertificate;
|
|
9
8
|
/** PEM string, DER bytes, or already-parsed OCSP request. */
|
|
10
|
-
type OcspRequestSource = string | Uint8Array | ParsedOcspRequest;
|
|
9
|
+
export type OcspRequestSource = string | Uint8Array | ParsedOcspRequest;
|
|
11
10
|
/**
|
|
12
11
|
* One certificate whose status to query in an OCSP request.
|
|
13
12
|
* Used as an element of {@linkcode CreateOcspRequestInput.requests}.
|
|
14
13
|
*/
|
|
15
|
-
interface CreateOcspRequestItemInput {
|
|
14
|
+
export interface CreateOcspRequestItemInput {
|
|
16
15
|
/** Certificate whose revocation status is being queried. */
|
|
17
16
|
readonly certificate: OcspCertificateSource;
|
|
18
17
|
/** Issuer of `certificate` — needed to compute the CertID hash. */
|
|
@@ -21,10 +20,10 @@ interface CreateOcspRequestItemInput {
|
|
|
21
20
|
/**
|
|
22
21
|
* Input for {@linkcode createOcspRequest}.
|
|
23
22
|
*/
|
|
24
|
-
interface CreateOcspRequestInput {
|
|
23
|
+
export interface CreateOcspRequestInput {
|
|
25
24
|
/** One or more certificates to query (batched into a single OCSP request). */
|
|
26
25
|
readonly requests: readonly CreateOcspRequestItemInput[];
|
|
27
|
-
/** Hash algorithm for CertID computation. Defaults to `'SHA-
|
|
26
|
+
/** Hash algorithm for CertID computation. Defaults to `'SHA-256'`. */
|
|
28
27
|
readonly hashAlgorithm?: OcspHashAlgorithm;
|
|
29
28
|
/** Random nonce for replay protection. Omit to skip the nonce extension. */
|
|
30
29
|
readonly nonce?: Uint8Array;
|
|
@@ -32,7 +31,7 @@ interface CreateOcspRequestInput {
|
|
|
32
31
|
/**
|
|
33
32
|
* Encoded OCSP request in multiple serialisation formats, returned by {@linkcode createOcspRequest}.
|
|
34
33
|
*/
|
|
35
|
-
interface OcspRequestMaterial {
|
|
34
|
+
export interface OcspRequestMaterial {
|
|
36
35
|
/** Raw DER bytes. */
|
|
37
36
|
readonly der: Uint8Array;
|
|
38
37
|
/** PEM-encoded request (`-----BEGIN OCSP REQUEST-----`). */
|
|
@@ -44,7 +43,7 @@ interface OcspRequestMaterial {
|
|
|
44
43
|
* Decoded OCSP CertID — identifies a certificate by hashed issuer name,
|
|
45
44
|
* hashed issuer key, and serial number.
|
|
46
45
|
*/
|
|
47
|
-
interface ParsedOcspCertId {
|
|
46
|
+
export interface ParsedOcspCertId {
|
|
48
47
|
/** OID of the hash algorithm used for the name and key hashes. */
|
|
49
48
|
readonly hashAlgorithmOid: string;
|
|
50
49
|
/** Human-readable hash algorithm name (e.g. `"SHA-256"`). */
|
|
@@ -59,7 +58,7 @@ interface ParsedOcspCertId {
|
|
|
59
58
|
/**
|
|
60
59
|
* Decoded OCSP request, returned by {@linkcode parseOcspRequestDer} / {@linkcode parseOcspRequestPem}.
|
|
61
60
|
*/
|
|
62
|
-
interface ParsedOcspRequest {
|
|
61
|
+
export interface ParsedOcspRequest {
|
|
63
62
|
/** Original DER bytes when this object came from {@linkcode parseOcspRequestDer} or PEM parsing. */
|
|
64
63
|
readonly der?: Uint8Array;
|
|
65
64
|
/** CertIDs of the certificates being queried. */
|
|
@@ -68,31 +67,51 @@ interface ParsedOcspRequest {
|
|
|
68
67
|
readonly nonce?: string;
|
|
69
68
|
}
|
|
70
69
|
/** RFC 6960 certificate status reported by the responder for a single CertID. */
|
|
71
|
-
type OcspCertStatus = "good" | "revoked" | "unknown";
|
|
70
|
+
export type OcspCertStatus = "good" | "revoked" | "unknown";
|
|
72
71
|
/** RFC 6960 overall response status — anything other than `'successful'` means the response body is absent or unusable. */
|
|
73
|
-
type OcspResponseStatus = "successful" | "malformedRequest" | "internalError" | "tryLater" | "sigRequired" | "unauthorized";
|
|
72
|
+
export type OcspResponseStatus = "successful" | "malformedRequest" | "internalError" | "tryLater" | "sigRequired" | "unauthorized";
|
|
74
73
|
/**
|
|
75
74
|
* Status of one certificate inside an OCSP BasicResponse.
|
|
76
75
|
*/
|
|
77
|
-
|
|
76
|
+
export type ParsedOcspSingleResponse = {
|
|
78
77
|
/** Which certificate this status applies to. */
|
|
79
78
|
readonly certId: ParsedOcspCertId;
|
|
80
|
-
/** Responder's verdict: `good`, `revoked`, or `unknown`. */
|
|
81
|
-
readonly certStatus: OcspCertStatus;
|
|
82
79
|
/** Start of the validity window for this status assertion. */
|
|
83
80
|
readonly thisUpdate: Date;
|
|
84
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Time at or before which newer status information will be available.
|
|
83
|
+
* Absent when the responder indicates that newer revocation information is
|
|
84
|
+
* available all the time (RFC 6960 §4.2.2.1).
|
|
85
|
+
*/
|
|
85
86
|
readonly nextUpdate?: Date;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
} & ParsedOcspCertStatus;
|
|
88
|
+
/**
|
|
89
|
+
* RFC 6960 §4.2.1 `CertStatus ::= CHOICE { good [0] NULL, revoked [1] RevokedInfo,
|
|
90
|
+
* unknown [2] UnknownInfo }`.
|
|
91
|
+
*
|
|
92
|
+
* Only `revoked` carries data, so `RevokedInfo`'s fields exist only on that
|
|
93
|
+
* alternative. `revocationReasonCode` stays optional because `revocationReason`
|
|
94
|
+
* is OPTIONAL within `RevokedInfo`.
|
|
95
|
+
*/
|
|
96
|
+
export type ParsedOcspCertStatus = {
|
|
97
|
+
/** Responder asserts the certificate is not revoked. */
|
|
98
|
+
readonly certStatus: "good";
|
|
99
|
+
} | {
|
|
100
|
+
/** Responder asserts the certificate is revoked. */
|
|
101
|
+
readonly certStatus: "revoked";
|
|
102
|
+
/** `RevokedInfo.revocationTime`. */
|
|
103
|
+
readonly revokedAt: Date;
|
|
104
|
+
/** `RevokedInfo.revocationReason` CRLReason value, when present. */
|
|
105
|
+
readonly revocationReasonCode?: bigint;
|
|
106
|
+
} | {
|
|
107
|
+
/** Responder has no record of the certificate. */
|
|
108
|
+
readonly certStatus: "unknown";
|
|
109
|
+
};
|
|
91
110
|
/**
|
|
92
111
|
* How the OCSP responder identifies itself — either by distinguished name or
|
|
93
112
|
* by SHA-1 hash of its public key.
|
|
94
113
|
*/
|
|
95
|
-
type ParsedOcspResponderId = {
|
|
114
|
+
export type ParsedOcspResponderId = {
|
|
96
115
|
/** Responder identified by its certificate subject name. */
|
|
97
116
|
readonly type: "byName";
|
|
98
117
|
/** Parsed distinguished name of the responder. */
|
|
@@ -108,7 +127,7 @@ type ParsedOcspResponderId = {
|
|
|
108
127
|
*
|
|
109
128
|
* When `responseStatus` is not `'successful'`, most fields are absent.
|
|
110
129
|
*/
|
|
111
|
-
interface ParsedOcspResponse {
|
|
130
|
+
export interface ParsedOcspResponse {
|
|
112
131
|
/** Original DER bytes when this object came from {@linkcode parseOcspResponseDer} or PEM parsing. */
|
|
113
132
|
readonly der?: Uint8Array;
|
|
114
133
|
/** Overall response status. Only `'successful'` carries a BasicOCSPResponse body. */
|
|
@@ -121,6 +140,8 @@ interface ParsedOcspResponse {
|
|
|
121
140
|
readonly responderId?: ParsedOcspResponderId;
|
|
122
141
|
/** OID of the algorithm used to sign this response. */
|
|
123
142
|
readonly signatureAlgorithmOid?: string;
|
|
143
|
+
/** DER-encoded `parameters` field of the signature AlgorithmIdentifier. */
|
|
144
|
+
readonly signatureAlgorithmParametersDer?: Uint8Array;
|
|
124
145
|
/** Human-readable signature algorithm name. */
|
|
125
146
|
readonly signatureAlgorithmName?: string;
|
|
126
147
|
/** Raw signature bytes. */
|
|
@@ -138,22 +159,49 @@ interface ParsedOcspResponse {
|
|
|
138
159
|
* One certificate's status entry for {@linkcode CreateOcspResponseInput.responses}.
|
|
139
160
|
* Extends {@linkcode CreateOcspRequestItemInput} with status and timing fields.
|
|
140
161
|
*/
|
|
141
|
-
|
|
142
|
-
/** Status to assert for this certificate. */
|
|
143
|
-
readonly certStatus: OcspCertStatus;
|
|
162
|
+
export type CreateOcspSingleResponseInput = CreateOcspRequestItemInput & {
|
|
144
163
|
/** Start of the validity window for this status assertion. Defaults to `new Date()`. */
|
|
145
164
|
readonly thisUpdate?: Date;
|
|
146
|
-
/**
|
|
165
|
+
/**
|
|
166
|
+
* Time at or before which newer status information will be available.
|
|
167
|
+
* When omitted, the response indicates that newer information is available
|
|
168
|
+
* all the time (RFC 6960 §4.2.2.1), and RFC 9919 clients reject it.
|
|
169
|
+
*/
|
|
147
170
|
readonly nextUpdate?: Date;
|
|
148
|
-
|
|
171
|
+
} & CreateOcspCertStatusInput;
|
|
172
|
+
/**
|
|
173
|
+
* Status to assert for one certificate, mirroring RFC 6960 §4.2.1 `CertStatus`.
|
|
174
|
+
*
|
|
175
|
+
* `RevokedInfo`'s fields are reachable only under `'revoked'`.
|
|
176
|
+
*/
|
|
177
|
+
export type CreateOcspCertStatusInput = {
|
|
178
|
+
/** Assert the certificate is not revoked. */
|
|
179
|
+
readonly certStatus: "good";
|
|
180
|
+
/** Unavailable unless `certStatus` is `'revoked'`. */
|
|
181
|
+
readonly revokedAt?: never;
|
|
182
|
+
/** Unavailable unless `certStatus` is `'revoked'`. */
|
|
183
|
+
readonly revocationReasonCode?: never;
|
|
184
|
+
} | {
|
|
185
|
+
/** Assert the certificate is revoked. */
|
|
186
|
+
readonly certStatus: "revoked";
|
|
187
|
+
/** `RevokedInfo.revocationTime`. Defaults to `thisUpdate`. */
|
|
149
188
|
readonly revokedAt?: Date;
|
|
150
|
-
/** CRLReason integer code
|
|
189
|
+
/** `RevokedInfo.revocationReason` CRLReason integer code. */
|
|
151
190
|
readonly revocationReasonCode?: number;
|
|
152
|
-
}
|
|
191
|
+
} | {
|
|
192
|
+
/** Assert no record of the certificate exists. */
|
|
193
|
+
readonly certStatus: "unknown";
|
|
194
|
+
/** Unavailable unless `certStatus` is `'revoked'`. */
|
|
195
|
+
readonly revokedAt?: never;
|
|
196
|
+
/** Unavailable unless `certStatus` is `'revoked'`. */
|
|
197
|
+
readonly revocationReasonCode?: never;
|
|
198
|
+
};
|
|
199
|
+
/** Machine-readable reason an OCSP encoder rejected its construction input. */
|
|
200
|
+
export type OcspEncoderErrorCode = "invalid_date" | "invalid_revocation_reason_code" | "signer_certificate_key_mismatch";
|
|
153
201
|
/**
|
|
154
202
|
* Input for {@linkcode createOcspResponse}.
|
|
155
203
|
*/
|
|
156
|
-
interface CreateOcspResponseInput {
|
|
204
|
+
export interface CreateOcspResponseInput {
|
|
157
205
|
/** Private key used to sign the response. Algorithm is inferred from the key. */
|
|
158
206
|
readonly signerPrivateKey: CryptoKey;
|
|
159
207
|
/** Certificate of the OCSP responder — used to build the responder ID (by key hash). */
|
|
@@ -164,7 +212,7 @@ interface CreateOcspResponseInput {
|
|
|
164
212
|
readonly producedAt?: Date;
|
|
165
213
|
/** Nonce to echo back for replay protection. */
|
|
166
214
|
readonly nonce?: Uint8Array;
|
|
167
|
-
/** Hash algorithm for CertID computation. Defaults to `'SHA-
|
|
215
|
+
/** Hash algorithm for CertID computation. Defaults to `'SHA-256'`. */
|
|
168
216
|
readonly hashAlgorithm?: OcspHashAlgorithm;
|
|
169
217
|
/** Extra certificates to embed in the response (e.g. the responder's issuer chain). */
|
|
170
218
|
readonly includedCertificates?: readonly OcspCertificateSource[];
|
|
@@ -172,7 +220,7 @@ interface CreateOcspResponseInput {
|
|
|
172
220
|
/**
|
|
173
221
|
* Encoded OCSP response in multiple serialisation formats, returned by {@linkcode createOcspResponse}.
|
|
174
222
|
*/
|
|
175
|
-
interface OcspResponseMaterial {
|
|
223
|
+
export interface OcspResponseMaterial {
|
|
176
224
|
/** Raw DER bytes. */
|
|
177
225
|
readonly der: Uint8Array;
|
|
178
226
|
/** PEM-encoded response (`-----BEGIN OCSP RESPONSE-----`). */
|
|
@@ -180,8 +228,12 @@ interface OcspResponseMaterial {
|
|
|
180
228
|
/** Base64-encoded DER (no PEM armour). */
|
|
181
229
|
readonly base64: string;
|
|
182
230
|
}
|
|
183
|
-
/**
|
|
184
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Failure detail when OCSP response signature verification fails. `unsupported`
|
|
233
|
+
* and `limit_exceeded` report a response or signer certificate micro509 cannot
|
|
234
|
+
* decode (see {@linkcode ParseOcspResponseErrorCode}).
|
|
235
|
+
*/
|
|
236
|
+
export interface VerifyOcspResponseSignatureFailure extends Micro509Error<"signature_invalid" | DecodeRefusalCode> {
|
|
185
237
|
/** Always `false` for failures. */
|
|
186
238
|
readonly ok: false;
|
|
187
239
|
}
|
|
@@ -190,11 +242,11 @@ interface VerifyOcspResponseSignatureFailure extends Micro509Error<"signature_in
|
|
|
190
242
|
*
|
|
191
243
|
* On success, `value` is the parsed response whose signature has been verified.
|
|
192
244
|
*/
|
|
193
|
-
type VerifyOcspResponseSignatureResult = {
|
|
245
|
+
export type VerifyOcspResponseSignatureResult = {
|
|
194
246
|
readonly ok: true;
|
|
195
247
|
/** Parsed response with a verified signature. */
|
|
196
248
|
readonly value: ParsedOcspResponse;
|
|
197
|
-
} | ErrorResult<"signature_invalid", Record<never, never>, VerifyOcspResponseSignatureFailure>;
|
|
249
|
+
} | ErrorResult<"signature_invalid" | DecodeRefusalCode, Record<never, never>, VerifyOcspResponseSignatureFailure>;
|
|
198
250
|
/**
|
|
199
251
|
* Revocation policy for delegated OCSP responder certificates (RFC 6960 §4.2.2.2.1).
|
|
200
252
|
*
|
|
@@ -207,11 +259,11 @@ type VerifyOcspResponseSignatureResult = {
|
|
|
207
259
|
* show the responder is not revoked, otherwise the response is rejected.
|
|
208
260
|
* - `'skip'`: no responder revocation checking.
|
|
209
261
|
*/
|
|
210
|
-
type OcspResponderRevocationPolicy = "honor-nocheck" | "require-evidence" | "skip";
|
|
262
|
+
export type OcspResponderRevocationPolicy = "honor-nocheck" | "require-evidence" | "skip";
|
|
211
263
|
/**
|
|
212
264
|
* Input for {@linkcode validateOcspResponse}.
|
|
213
265
|
*/
|
|
214
|
-
interface ValidateOcspResponseInput {
|
|
266
|
+
export interface ValidateOcspResponseInput {
|
|
215
267
|
/** The OCSP response to validate. */
|
|
216
268
|
readonly response: string | Uint8Array | ParsedOcspResponse;
|
|
217
269
|
/** Certificate of the CA that issued the target certificate. */
|
|
@@ -237,22 +289,47 @@ interface ValidateOcspResponseInput {
|
|
|
237
289
|
readonly responderRevocationPolicy?: OcspResponderRevocationPolicy;
|
|
238
290
|
/** CRLs used as revocation evidence for delegated responder certificates. */
|
|
239
291
|
readonly responderRevocationCrls?: readonly CrlSource[];
|
|
292
|
+
/**
|
|
293
|
+
* Maximum age of each `responderRevocationCrls` entry's `thisUpdate` at
|
|
294
|
+
* `at`, in milliseconds. An older CRL yields no evidence. Unbounded by
|
|
295
|
+
* default, in which case a CRL without `nextUpdate` yields no evidence.
|
|
296
|
+
* Throws `RangeError` when negative or not finite.
|
|
297
|
+
*/
|
|
298
|
+
readonly responderRevocationCrlMaxAgeMs?: number;
|
|
299
|
+
/**
|
|
300
|
+
* Treatment of a `responderRevocationCrls` entry that revokes the responder
|
|
301
|
+
* with an unrecognized CRLReason. See {@linkcode UnrecognizedReasonCodePolicy}.
|
|
302
|
+
* `'reject'` blocks validation with `responder_revocation_unknown`, even when
|
|
303
|
+
* another CRL provides good coverage. Defaults to `'revoked'`.
|
|
304
|
+
*/
|
|
305
|
+
readonly responderRevocationUnrecognizedReasonCode?: UnrecognizedReasonCodePolicy;
|
|
240
306
|
/** Evaluation time for freshness checks and delegated responder chain validation. Defaults to `new Date()`. */
|
|
241
307
|
readonly at?: Date;
|
|
242
|
-
/**
|
|
308
|
+
/**
|
|
309
|
+
* Clock-skew tolerance in milliseconds for `thisUpdate`/`nextUpdate`/`producedAt`,
|
|
310
|
+
* including those of `responderRevocationCrls`. It also widens
|
|
311
|
+
* `responderRevocationCrlMaxAgeMs`.
|
|
312
|
+
*/
|
|
243
313
|
readonly clockSkewMs?: number;
|
|
314
|
+
/**
|
|
315
|
+
* OCSP client profile to enforce. Defaults to `'rfc6960'`, which accepts a
|
|
316
|
+
* response without `nextUpdate` (RFC 6960 §4.2.2.1). `'rfc9919'` applies the
|
|
317
|
+
* RFC 9919 §5 client rule and fails with `next_update_missing` when any
|
|
318
|
+
* single response omits `nextUpdate`.
|
|
319
|
+
*/
|
|
320
|
+
readonly profile?: "rfc6960" | "rfc9919";
|
|
244
321
|
}
|
|
245
322
|
/** Failure codes produced by {@linkcode validateOcspResponse}. */
|
|
246
|
-
type ValidateOcspResponseErrorCode = "response_status_invalid" | "signature_invalid" | "responder_id_mismatch" | "nonce_mismatch" | "request_mismatch" | "issuer_mismatch" | "responder_chain_invalid" | "ocsp_signing_missing" | "responder_revoked" | "responder_revocation_unknown" | "stale_response";
|
|
323
|
+
export type ValidateOcspResponseErrorCode = "next_update_missing" | "response_status_invalid" | "signature_invalid" | "responder_id_mismatch" | "nonce_mismatch" | "request_mismatch" | "issuer_mismatch" | "responder_chain_invalid" | "ocsp_signing_missing" | "responder_revoked" | "responder_revocation_unknown" | "stale_response" | DecodeRefusalCode;
|
|
247
324
|
/**
|
|
248
325
|
* Failure detail for {@linkcode validateOcspResponse}.
|
|
249
326
|
*
|
|
250
|
-
* Possible codes: `response_status_invalid`, `signature_invalid`,
|
|
327
|
+
* Possible codes: `next_update_missing`, `response_status_invalid`, `signature_invalid`,
|
|
251
328
|
* `responder_id_mismatch`, `nonce_mismatch`, `request_mismatch`,
|
|
252
329
|
* `issuer_mismatch`, `responder_chain_invalid`, `ocsp_signing_missing`,
|
|
253
330
|
* `responder_revoked`, `responder_revocation_unknown`, `stale_response`.
|
|
254
331
|
*/
|
|
255
|
-
interface ValidateOcspResponseFailure extends Micro509Error<ValidateOcspResponseErrorCode> {
|
|
332
|
+
export interface ValidateOcspResponseFailure extends Micro509Error<ValidateOcspResponseErrorCode> {
|
|
256
333
|
/** Always `false` for failures. */
|
|
257
334
|
readonly ok: false;
|
|
258
335
|
}
|
|
@@ -263,7 +340,7 @@ interface ValidateOcspResponseFailure extends Micro509Error<ValidateOcspResponse
|
|
|
263
340
|
* authorization (including responder revocation policy), freshness, nonce,
|
|
264
341
|
* and request-coverage checks.
|
|
265
342
|
*/
|
|
266
|
-
type ValidateOcspResponseResult = {
|
|
343
|
+
export type ValidateOcspResponseResult = {
|
|
267
344
|
readonly ok: true;
|
|
268
345
|
/** Fully validated OCSP response. */
|
|
269
346
|
readonly value: ParsedOcspResponse;
|
|
@@ -284,51 +361,51 @@ type ValidateOcspResponseResult = {
|
|
|
284
361
|
* // POST req.der to the OCSP responder URI
|
|
285
362
|
* ```
|
|
286
363
|
*/
|
|
287
|
-
declare function createOcspRequest(input: CreateOcspRequestInput): Promise<OcspRequestMaterial>;
|
|
364
|
+
export declare function createOcspRequest(input: CreateOcspRequestInput): Promise<OcspRequestMaterial>;
|
|
288
365
|
/** Machine-readable failure reason for the OCSP request parsers. */
|
|
289
|
-
type ParseOcspRequestErrorCode =
|
|
366
|
+
export type ParseOcspRequestErrorCode = DecodeFailureCode;
|
|
290
367
|
/** Structured failure payload for OCSP request parsing. */
|
|
291
|
-
interface ParseOcspRequestFailure extends Micro509Error<ParseOcspRequestErrorCode> {
|
|
368
|
+
export interface ParseOcspRequestFailure extends Micro509Error<ParseOcspRequestErrorCode> {
|
|
292
369
|
/** Always `false` for failures. */
|
|
293
370
|
readonly ok: false;
|
|
294
371
|
}
|
|
295
372
|
/** Success-or-failure result from {@linkcode parseOcspRequestDer} / {@linkcode parseOcspRequestPem}. */
|
|
296
|
-
type ParseOcspRequestResult = {
|
|
373
|
+
export type ParseOcspRequestResult = {
|
|
297
374
|
readonly ok: true;
|
|
298
375
|
readonly value: ParsedOcspRequest;
|
|
299
376
|
} | ErrorResult<ParseOcspRequestErrorCode, Record<never, never>, ParseOcspRequestFailure>;
|
|
300
377
|
/** Throwing core for {@linkcode parseOcspRequestDer}. */
|
|
301
|
-
declare function parseOcspRequestDerOrThrow(der: Uint8Array): ParsedOcspRequest;
|
|
378
|
+
export declare function parseOcspRequestDerOrThrow(der: Uint8Array): ParsedOcspRequest;
|
|
302
379
|
/** Decodes a PEM-encoded OCSP request (`-----BEGIN OCSP REQUEST-----`). */
|
|
303
|
-
declare function parseOcspRequestPemOrThrow(pem: string): ParsedOcspRequest;
|
|
380
|
+
export declare function parseOcspRequestPemOrThrow(pem: string): ParsedOcspRequest;
|
|
304
381
|
/**
|
|
305
382
|
* Decodes a DER-encoded OCSP request into a structured {@linkcode ParsedOcspRequest}.
|
|
306
383
|
*
|
|
307
384
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
308
385
|
* throwing form use {@linkcode parseOcspRequestDerOrThrow}.
|
|
309
386
|
*/
|
|
310
|
-
declare function parseOcspRequestDer(der: Uint8Array): ParseOcspRequestResult;
|
|
387
|
+
export declare function parseOcspRequestDer(der: Uint8Array): ParseOcspRequestResult;
|
|
311
388
|
/**
|
|
312
389
|
* Decodes a PEM-encoded OCSP request (`-----BEGIN OCSP REQUEST-----`).
|
|
313
390
|
*
|
|
314
391
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
315
392
|
* throwing form use {@linkcode parseOcspRequestPemOrThrow}.
|
|
316
393
|
*/
|
|
317
|
-
declare function parseOcspRequestPem(pem: string): ParseOcspRequestResult;
|
|
318
|
-
/** Machine-readable failure reason for the OCSP response parsers. */
|
|
319
|
-
type ParseOcspResponseErrorCode =
|
|
394
|
+
export declare function parseOcspRequestPem(pem: string): ParseOcspRequestResult;
|
|
395
|
+
/** Machine-readable failure reason for the OCSP response parsers, with the codes of {@linkcode ParseOcspRequestErrorCode}. */
|
|
396
|
+
export type ParseOcspResponseErrorCode = ParseOcspRequestErrorCode;
|
|
320
397
|
/** Structured failure payload for OCSP response parsing. */
|
|
321
|
-
interface ParseOcspResponseFailure extends Micro509Error<ParseOcspResponseErrorCode> {
|
|
398
|
+
export interface ParseOcspResponseFailure extends Micro509Error<ParseOcspResponseErrorCode> {
|
|
322
399
|
/** Always `false` for failures. */
|
|
323
400
|
readonly ok: false;
|
|
324
401
|
}
|
|
325
402
|
/** Success-or-failure result from {@linkcode parseOcspResponseDer} / {@linkcode parseOcspResponsePem}. */
|
|
326
|
-
type ParseOcspResponseResult = {
|
|
403
|
+
export type ParseOcspResponseResult = {
|
|
327
404
|
readonly ok: true;
|
|
328
405
|
readonly value: ParsedOcspResponse;
|
|
329
406
|
} | ErrorResult<ParseOcspResponseErrorCode, Record<never, never>, ParseOcspResponseFailure>;
|
|
330
407
|
/** Throwing core for {@linkcode parseOcspResponseDer}. */
|
|
331
|
-
declare function parseOcspResponseDerOrThrow(der: Uint8Array): ParsedOcspResponse;
|
|
408
|
+
export declare function parseOcspResponseDerOrThrow(der: Uint8Array): ParsedOcspResponse;
|
|
332
409
|
/**
|
|
333
410
|
* Decodes a PEM-encoded OCSP response (`-----BEGIN OCSP RESPONSE-----`).
|
|
334
411
|
*
|
|
@@ -344,21 +421,21 @@ declare function parseOcspResponseDerOrThrow(der: Uint8Array): ParsedOcspRespons
|
|
|
344
421
|
* }
|
|
345
422
|
* ```
|
|
346
423
|
*/
|
|
347
|
-
declare function parseOcspResponsePemOrThrow(pem: string): ParsedOcspResponse;
|
|
424
|
+
export declare function parseOcspResponsePemOrThrow(pem: string): ParsedOcspResponse;
|
|
348
425
|
/**
|
|
349
426
|
* Decodes a DER-encoded OCSP response into a structured {@linkcode ParsedOcspResponse}.
|
|
350
427
|
*
|
|
351
428
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
352
429
|
* throwing form use {@linkcode parseOcspResponseDerOrThrow}.
|
|
353
430
|
*/
|
|
354
|
-
declare function parseOcspResponseDer(der: Uint8Array): ParseOcspResponseResult;
|
|
431
|
+
export declare function parseOcspResponseDer(der: Uint8Array): ParseOcspResponseResult;
|
|
355
432
|
/**
|
|
356
433
|
* Decodes a PEM-encoded OCSP response (`-----BEGIN OCSP RESPONSE-----`).
|
|
357
434
|
*
|
|
358
435
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
359
436
|
* throwing form use {@linkcode parseOcspResponsePemOrThrow}.
|
|
360
437
|
*/
|
|
361
|
-
declare function parseOcspResponsePem(pem: string): ParseOcspResponseResult;
|
|
438
|
+
export declare function parseOcspResponsePem(pem: string): ParseOcspResponseResult;
|
|
362
439
|
/**
|
|
363
440
|
* Signs and encodes an OCSP BasicResponse with a `successful` status.
|
|
364
441
|
*
|
|
@@ -386,14 +463,14 @@ declare function parseOcspResponsePem(pem: string): ParseOcspResponseResult;
|
|
|
386
463
|
* // resp.der, resp.pem, resp.base64
|
|
387
464
|
* ```
|
|
388
465
|
*/
|
|
389
|
-
declare function createOcspResponse(input: CreateOcspResponseInput): Promise<OcspResponseMaterial>;
|
|
466
|
+
export declare function createOcspResponse(input: CreateOcspResponseInput): Promise<OcspResponseMaterial>;
|
|
390
467
|
/**
|
|
391
468
|
* Verifies the OCSP response signature against the given signer certificate.
|
|
392
469
|
*
|
|
393
470
|
* Does **not** check responder binding, freshness, or nonce — use
|
|
394
471
|
* {@linkcode validateOcspResponse} for full validation.
|
|
395
472
|
*/
|
|
396
|
-
declare function verifyOcspResponseSignature(response: string | Uint8Array | ParsedOcspResponse, signerCertificate: OcspCertificateSource): Promise<VerifyOcspResponseSignatureResult>;
|
|
473
|
+
export declare function verifyOcspResponseSignature(response: string | Uint8Array | ParsedOcspResponse, signerCertificate: OcspCertificateSource): Promise<VerifyOcspResponseSignatureResult>;
|
|
397
474
|
/**
|
|
398
475
|
* Full OCSP response validation: response status check, signature verification,
|
|
399
476
|
* responder ID binding (byName or byKeyHash), delegated-responder chain and
|
|
@@ -415,13 +492,12 @@ declare function verifyOcspResponseSignature(response: string | Uint8Array | Par
|
|
|
415
492
|
* }
|
|
416
493
|
* ```
|
|
417
494
|
*/
|
|
418
|
-
declare function validateOcspResponse(input: ValidateOcspResponseInput): Promise<ValidateOcspResponseResult>;
|
|
495
|
+
export declare function validateOcspResponse(input: ValidateOcspResponseInput): Promise<ValidateOcspResponseResult>;
|
|
419
496
|
/**
|
|
420
497
|
* Reports whether a certificate carries the `id-pkix-ocsp-nocheck` extension
|
|
421
498
|
* (RFC 6960 §4.2.2.2.1) — the CA's assertion that relying parties may trust
|
|
422
499
|
* this OCSP responder certificate for its lifetime without revocation checks.
|
|
500
|
+
* An extension whose value is not the NULL that §4.2.2.2.1 requires does not count.
|
|
423
501
|
*/
|
|
424
|
-
declare function hasOcspNoCheckExtension(certificate: OcspCertificateSource): boolean;
|
|
425
|
-
//#endregion
|
|
426
|
-
export { CreateOcspRequestInput, CreateOcspRequestItemInput, CreateOcspResponseInput, CreateOcspSingleResponseInput, OcspCertStatus, OcspCertificateSource, OcspHashAlgorithm, OcspRequestMaterial, OcspRequestSource, OcspResponderRevocationPolicy, OcspResponseMaterial, OcspResponseStatus, ParseOcspRequestErrorCode, ParseOcspRequestFailure, ParseOcspRequestResult, ParseOcspResponseErrorCode, ParseOcspResponseFailure, ParseOcspResponseResult, ParsedOcspCertId, ParsedOcspRequest, ParsedOcspResponderId, ParsedOcspResponse, ParsedOcspSingleResponse, ValidateOcspResponseErrorCode, ValidateOcspResponseFailure, ValidateOcspResponseInput, ValidateOcspResponseResult, VerifyOcspResponseSignatureFailure, VerifyOcspResponseSignatureResult, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, validateOcspResponse, verifyOcspResponseSignature };
|
|
502
|
+
export declare function hasOcspNoCheckExtension(certificate: OcspCertificateSource): boolean;
|
|
427
503
|
//# sourceMappingURL=ocsp.d.ts.map
|