micro509 0.13.0 → 0.14.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/README.md +78 -30
- package/dist/crypto/crypto.d.ts +73 -0
- package/dist/crypto/crypto.js +74 -0
- package/dist/crypto/crypto.js.map +1 -0
- package/dist/crypto.d.ts +4 -0
- package/dist/crypto.js +2 -0
- package/dist/der/der.d.ts +1 -1
- package/dist/index.d.ts +13 -9
- package/dist/index.js +17 -15
- package/dist/internal/asn1/asn1.js +21 -10
- package/dist/internal/asn1/asn1.js.map +1 -1
- package/dist/internal/asn1/der.d.ts +4 -2
- package/dist/internal/asn1/der.js +18 -5
- package/dist/internal/asn1/der.js.map +1 -1
- package/dist/internal/asn1/oids.js +7 -1
- package/dist/internal/crypto/algorithm-names.js +4 -0
- package/dist/internal/crypto/algorithm-names.js.map +1 -1
- package/dist/internal/crypto/pbes2.d.ts +38 -0
- package/dist/internal/crypto/pbes2.js +9 -10
- package/dist/internal/crypto/pbes2.js.map +1 -1
- package/dist/internal/crypto/rsa-pss.js +2 -0
- package/dist/internal/crypto/rsa-pss.js.map +1 -1
- package/dist/internal/crypto/sig-verify.d.ts +31 -0
- package/dist/internal/crypto/sig-verify.js +10 -8
- package/dist/internal/crypto/sig-verify.js.map +1 -1
- package/dist/internal/shared/base64.js +7 -1
- package/dist/internal/shared/base64.js.map +1 -1
- package/dist/internal/shared/dn.d.ts +16 -0
- package/dist/internal/shared/dn.js +13 -6
- package/dist/internal/shared/dn.js.map +1 -1
- package/dist/internal/shared/ip.d.ts +69 -0
- package/dist/internal/shared/ip.js +18 -1
- package/dist/internal/shared/ip.js.map +1 -1
- package/dist/internal/verify/verify-path.d.ts +7 -0
- package/dist/internal/verify/verify-path.js +36 -36
- package/dist/internal/x509/directory-name.js +24 -0
- package/dist/internal/x509/directory-name.js.map +1 -0
- package/dist/internal/x509/extension-bits.js +13 -10
- package/dist/internal/x509/extension-bits.js.map +1 -1
- package/dist/internal/x509/extension-errors.d.ts +6 -0
- package/dist/internal/x509/extension-errors.js +20 -0
- package/dist/internal/x509/extension-errors.js.map +1 -0
- package/dist/internal/x509/extension-registry.js +113 -55
- package/dist/internal/x509/extension-registry.js.map +1 -1
- package/dist/internal/x509/general-name-tags.js +28 -0
- package/dist/internal/x509/general-name-tags.js.map +1 -0
- package/dist/internal/x509/general-name.js +97 -0
- package/dist/internal/x509/general-name.js.map +1 -0
- package/dist/internal/x509/name-fields.js +20 -10
- package/dist/internal/x509/name-fields.js.map +1 -1
- package/dist/keys/keys.d.ts +16 -2
- package/dist/keys/keys.js +311 -170
- 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 +3 -2
- package/dist/pem/pem.js +112 -30
- package/dist/pem/pem.js.map +1 -1
- package/dist/pkcs/pkcs12-mac.js +3 -3
- package/dist/pkcs/pkcs12-mac.js.map +1 -1
- package/dist/pkcs/pkcs7.d.ts +85 -21
- package/dist/pkcs/pkcs7.js +261 -186
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +2 -2
- package/dist/result/result.d.ts +18 -10
- package/dist/result/result.js +20 -12
- package/dist/result/result.js.map +1 -1
- package/dist/result.d.ts +2 -2
- package/dist/result.js +2 -2
- package/dist/revocation/chain.js +77 -81
- package/dist/revocation/chain.js.map +1 -1
- package/dist/revocation/crl.d.ts +13 -2
- package/dist/revocation/crl.js +415 -236
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +58 -17
- package/dist/revocation/ocsp.js +185 -173
- package/dist/revocation/ocsp.js.map +1 -1
- package/dist/revocation/revocation.d.ts +4 -4
- package/dist/revocation/revocation.js +48 -30
- package/dist/revocation/revocation.js.map +1 -1
- package/dist/revocation.d.ts +4 -4
- package/dist/revocation.js +5 -5
- package/dist/verify/identity.d.ts +2 -1
- package/dist/verify/identity.js +2 -1
- package/dist/verify/identity.js.map +1 -1
- package/dist/verify/policy.d.ts +6 -1
- package/dist/verify/verify.d.ts +4 -2
- package/dist/verify/verify.js +32 -14
- package/dist/verify/verify.js.map +1 -1
- package/dist/verify.d.ts +2 -1
- package/dist/verify.js +4 -3
- package/dist/x509/certificate.d.ts +36 -13
- package/dist/x509/certificate.js +36 -19
- package/dist/x509/certificate.js.map +1 -1
- package/dist/x509/csr.d.ts +6 -3
- package/dist/x509/extensions.d.ts +58 -21
- package/dist/x509/extensions.js +384 -117
- package/dist/x509/extensions.js.map +1 -1
- package/dist/x509/name-text.js +2 -0
- package/dist/x509/name-text.js.map +1 -1
- package/dist/x509/name.d.ts +8 -5
- package/dist/x509/name.js +17 -12
- package/dist/x509/name.js.map +1 -1
- package/dist/x509/parse.d.ts +104 -18
- package/dist/x509/parse.js +127 -163
- package/dist/x509/parse.js.map +1 -1
- package/dist/x509.d.ts +8 -5
- package/dist/x509.js +10 -8
- package/package.json +28 -20
|
@@ -2,7 +2,7 @@ import { ErrorResult, Micro509Error } from "../result/result.js";
|
|
|
2
2
|
import { ParsedCertificate, ParsedName } from "../x509/parse.js";
|
|
3
3
|
import { CrlSource } from "./crl.js";
|
|
4
4
|
//#region src/revocation/ocsp.d.ts
|
|
5
|
-
/** Hash algorithm used to compute OCSP CertID fields. SHA-
|
|
5
|
+
/** Hash algorithm used to compute OCSP CertID fields. RFC 9919 §3.1.1 requires SHA-256 for conforming clients; RFC 6960 defines no default. */
|
|
6
6
|
type OcspHashAlgorithm = "SHA-1" | "SHA-256";
|
|
7
7
|
/** PEM string, DER bytes, or already-parsed certificate. */
|
|
8
8
|
type OcspCertificateSource = string | Uint8Array | ParsedCertificate;
|
|
@@ -24,7 +24,7 @@ interface CreateOcspRequestItemInput {
|
|
|
24
24
|
interface CreateOcspRequestInput {
|
|
25
25
|
/** One or more certificates to query (batched into a single OCSP request). */
|
|
26
26
|
readonly requests: readonly CreateOcspRequestItemInput[];
|
|
27
|
-
/** Hash algorithm for CertID computation. Defaults to `'SHA-
|
|
27
|
+
/** Hash algorithm for CertID computation. Defaults to `'SHA-256'`. */
|
|
28
28
|
readonly hashAlgorithm?: OcspHashAlgorithm;
|
|
29
29
|
/** Random nonce for replay protection. Omit to skip the nonce extension. */
|
|
30
30
|
readonly nonce?: Uint8Array;
|
|
@@ -74,20 +74,36 @@ type OcspResponseStatus = "successful" | "malformedRequest" | "internalError" |
|
|
|
74
74
|
/**
|
|
75
75
|
* Status of one certificate inside an OCSP BasicResponse.
|
|
76
76
|
*/
|
|
77
|
-
|
|
77
|
+
type ParsedOcspSingleResponse = {
|
|
78
78
|
/** Which certificate this status applies to. */
|
|
79
79
|
readonly certId: ParsedOcspCertId;
|
|
80
|
-
/** Responder's verdict: `good`, `revoked`, or `unknown`. */
|
|
81
|
-
readonly certStatus: OcspCertStatus;
|
|
82
80
|
/** Start of the validity window for this status assertion. */
|
|
83
81
|
readonly thisUpdate: Date;
|
|
84
82
|
/** End of the validity window. Absent if the responder does not commit to a schedule. */
|
|
85
83
|
readonly nextUpdate?: Date;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
} & ParsedOcspCertStatus;
|
|
85
|
+
/**
|
|
86
|
+
* RFC 6960 §4.2.1 `CertStatus ::= CHOICE { good [0] NULL, revoked [1] RevokedInfo,
|
|
87
|
+
* unknown [2] UnknownInfo }`.
|
|
88
|
+
*
|
|
89
|
+
* Only `revoked` carries data, so `RevokedInfo`'s fields exist only on that
|
|
90
|
+
* alternative. `revocationReasonCode` stays optional because `revocationReason`
|
|
91
|
+
* is OPTIONAL within `RevokedInfo`.
|
|
92
|
+
*/
|
|
93
|
+
type ParsedOcspCertStatus = {
|
|
94
|
+
/** Responder asserts the certificate is not revoked. */
|
|
95
|
+
readonly certStatus: "good";
|
|
96
|
+
} | {
|
|
97
|
+
/** Responder asserts the certificate is revoked. */
|
|
98
|
+
readonly certStatus: "revoked";
|
|
99
|
+
/** `RevokedInfo.revocationTime`. */
|
|
100
|
+
readonly revokedAt: Date;
|
|
101
|
+
/** `RevokedInfo.revocationReason` CRLReason integer, when present. */
|
|
89
102
|
readonly revocationReasonCode?: number;
|
|
90
|
-
}
|
|
103
|
+
} | {
|
|
104
|
+
/** Responder has no record of the certificate. */
|
|
105
|
+
readonly certStatus: "unknown";
|
|
106
|
+
};
|
|
91
107
|
/**
|
|
92
108
|
* How the OCSP responder identifies itself — either by distinguished name or
|
|
93
109
|
* by SHA-1 hash of its public key.
|
|
@@ -121,6 +137,8 @@ interface ParsedOcspResponse {
|
|
|
121
137
|
readonly responderId?: ParsedOcspResponderId;
|
|
122
138
|
/** OID of the algorithm used to sign this response. */
|
|
123
139
|
readonly signatureAlgorithmOid?: string;
|
|
140
|
+
/** DER-encoded `parameters` field of the signature AlgorithmIdentifier. */
|
|
141
|
+
readonly signatureAlgorithmParametersDer?: Uint8Array;
|
|
124
142
|
/** Human-readable signature algorithm name. */
|
|
125
143
|
readonly signatureAlgorithmName?: string;
|
|
126
144
|
/** Raw signature bytes. */
|
|
@@ -138,18 +156,41 @@ interface ParsedOcspResponse {
|
|
|
138
156
|
* One certificate's status entry for {@linkcode CreateOcspResponseInput.responses}.
|
|
139
157
|
* Extends {@linkcode CreateOcspRequestItemInput} with status and timing fields.
|
|
140
158
|
*/
|
|
141
|
-
|
|
142
|
-
/** Status to assert for this certificate. */
|
|
143
|
-
readonly certStatus: OcspCertStatus;
|
|
159
|
+
type CreateOcspSingleResponseInput = CreateOcspRequestItemInput & {
|
|
144
160
|
/** Start of the validity window for this status assertion. Defaults to `new Date()`. */
|
|
145
161
|
readonly thisUpdate?: Date;
|
|
146
162
|
/** End of the validity window. Omit for open-ended assertions. */
|
|
147
163
|
readonly nextUpdate?: Date;
|
|
148
|
-
|
|
164
|
+
} & CreateOcspCertStatusInput;
|
|
165
|
+
/**
|
|
166
|
+
* Status to assert for one certificate, mirroring RFC 6960 §4.2.1 `CertStatus`.
|
|
167
|
+
*
|
|
168
|
+
* `RevokedInfo`'s fields are reachable only under `'revoked'`.
|
|
169
|
+
*/
|
|
170
|
+
type CreateOcspCertStatusInput = {
|
|
171
|
+
/** Assert the certificate is not revoked. */
|
|
172
|
+
readonly certStatus: "good";
|
|
173
|
+
/** Unavailable unless `certStatus` is `'revoked'`. */
|
|
174
|
+
readonly revokedAt?: never;
|
|
175
|
+
/** Unavailable unless `certStatus` is `'revoked'`. */
|
|
176
|
+
readonly revocationReasonCode?: never;
|
|
177
|
+
} | {
|
|
178
|
+
/** Assert the certificate is revoked. */
|
|
179
|
+
readonly certStatus: "revoked";
|
|
180
|
+
/** `RevokedInfo.revocationTime`. Defaults to `thisUpdate`. */
|
|
149
181
|
readonly revokedAt?: Date;
|
|
150
|
-
/** CRLReason integer code
|
|
182
|
+
/** `RevokedInfo.revocationReason` CRLReason integer code. */
|
|
151
183
|
readonly revocationReasonCode?: number;
|
|
152
|
-
}
|
|
184
|
+
} | {
|
|
185
|
+
/** Assert no record of the certificate exists. */
|
|
186
|
+
readonly certStatus: "unknown";
|
|
187
|
+
/** Unavailable unless `certStatus` is `'revoked'`. */
|
|
188
|
+
readonly revokedAt?: never;
|
|
189
|
+
/** Unavailable unless `certStatus` is `'revoked'`. */
|
|
190
|
+
readonly revocationReasonCode?: never;
|
|
191
|
+
};
|
|
192
|
+
/** Machine-readable reason an OCSP encoder rejected its construction input. */
|
|
193
|
+
type OcspEncoderErrorCode = "signer_certificate_key_mismatch";
|
|
153
194
|
/**
|
|
154
195
|
* Input for {@linkcode createOcspResponse}.
|
|
155
196
|
*/
|
|
@@ -164,7 +205,7 @@ interface CreateOcspResponseInput {
|
|
|
164
205
|
readonly producedAt?: Date;
|
|
165
206
|
/** Nonce to echo back for replay protection. */
|
|
166
207
|
readonly nonce?: Uint8Array;
|
|
167
|
-
/** Hash algorithm for CertID computation. Defaults to `'SHA-
|
|
208
|
+
/** Hash algorithm for CertID computation. Defaults to `'SHA-256'`. */
|
|
168
209
|
readonly hashAlgorithm?: OcspHashAlgorithm;
|
|
169
210
|
/** Extra certificates to embed in the response (e.g. the responder's issuer chain). */
|
|
170
211
|
readonly includedCertificates?: readonly OcspCertificateSource[];
|
|
@@ -423,5 +464,5 @@ declare function validateOcspResponse(input: ValidateOcspResponseInput): Promise
|
|
|
423
464
|
*/
|
|
424
465
|
declare function hasOcspNoCheckExtension(certificate: OcspCertificateSource): boolean;
|
|
425
466
|
//#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 };
|
|
467
|
+
export { CreateOcspCertStatusInput, CreateOcspRequestInput, CreateOcspRequestItemInput, CreateOcspResponseInput, CreateOcspSingleResponseInput, OcspCertStatus, OcspCertificateSource, OcspEncoderErrorCode, OcspHashAlgorithm, OcspRequestMaterial, OcspRequestSource, OcspResponderRevocationPolicy, OcspResponseMaterial, OcspResponseStatus, ParseOcspRequestErrorCode, ParseOcspRequestFailure, ParseOcspRequestResult, ParseOcspResponseErrorCode, ParseOcspResponseFailure, ParseOcspResponseResult, ParsedOcspCertId, ParsedOcspCertStatus, ParsedOcspRequest, ParsedOcspResponderId, ParsedOcspResponse, ParsedOcspSingleResponse, ValidateOcspResponseErrorCode, ValidateOcspResponseFailure, ValidateOcspResponseInput, ValidateOcspResponseResult, VerifyOcspResponseSignatureFailure, VerifyOcspResponseSignatureResult, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, validateOcspResponse, verifyOcspResponseSignature };
|
|
427
468
|
//# sourceMappingURL=ocsp.d.ts.map
|