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/x509/parse.d.ts
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
import { ErrorResult, Micro509Error } from "../result/result.js";
|
|
1
|
+
import { DecodeFailureCode, DecodeRefusalCode, ErrorResult, Micro509Error } from "../result/result.js";
|
|
2
2
|
import { ImportKeyResult, PublicKeyImportInput } from "../keys/keys.js";
|
|
3
3
|
import { NameFieldKey } from "./name.js";
|
|
4
4
|
import { AuthorityInformationAccess, BasicConstraints, CertificatePolicies, DistributionPointReason, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, KeyUsage, NameConstraints, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyMappings, SubjectAltName } from "./extensions.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Machine-readable failure reason for {@linkcode parseCertificateDer} / {@linkcode parseCertificatePem}.
|
|
7
|
+
*
|
|
8
|
+
* `malformed` is input that breaks DER, ASN.1 or the RFC 5280 profile.
|
|
9
|
+
* `unsupported` is input the profile may allow but micro509 does not decode: a
|
|
10
|
+
* TeletexString octet outside the X.690 §8.23.5.2 initial state.
|
|
11
|
+
* `limit_exceeded` is an implementation limit: an OBJECT IDENTIFIER
|
|
12
|
+
* sub-identifier encoded in more than 64 octets, a tag number of 2^53 or more,
|
|
13
|
+
* or DER nested deeper than 64 levels.
|
|
14
|
+
*/
|
|
15
|
+
export type ParseCertificateErrorCode = DecodeFailureCode;
|
|
8
16
|
/** Structured failure payload for certificate parsing. */
|
|
9
|
-
interface ParseCertificateFailure extends Micro509Error<ParseCertificateErrorCode> {
|
|
17
|
+
export interface ParseCertificateFailure extends Micro509Error<ParseCertificateErrorCode> {
|
|
10
18
|
/** Always `false` for failures. */
|
|
11
19
|
readonly ok: false;
|
|
12
20
|
}
|
|
13
21
|
/** Success-or-failure result from {@linkcode parseCertificateDer} / {@linkcode parseCertificatePem}. */
|
|
14
|
-
type ParseCertificateResult<TMap extends ExtensionDecoderMap = Record<never, never>> = {
|
|
22
|
+
export type ParseCertificateResult<TMap extends ExtensionDecoderMap = Record<never, never>> = {
|
|
15
23
|
readonly ok: true;
|
|
16
24
|
readonly value: ParsedCertificate<TMap>;
|
|
17
25
|
} | ErrorResult<ParseCertificateErrorCode, Record<never, never>, ParseCertificateFailure>;
|
|
18
|
-
/**
|
|
19
|
-
type
|
|
26
|
+
/** Success-or-failure result from {@linkcode parseCertificateChainPem}. */
|
|
27
|
+
export type ParseCertificateChainResult<TMap extends ExtensionDecoderMap = Record<never, never>> = {
|
|
28
|
+
readonly ok: true;
|
|
29
|
+
readonly value: readonly ParsedCertificate<TMap>[];
|
|
30
|
+
} | ErrorResult<ParseCertificateErrorCode, Record<never, never>, ParseCertificateFailure>;
|
|
31
|
+
/** Machine-readable failure reason for the CSR parsers, with the codes of {@linkcode ParseCertificateErrorCode}. */
|
|
32
|
+
export type ParseCertificateSigningRequestErrorCode = ParseCertificateErrorCode;
|
|
20
33
|
/** Structured failure payload for CSR parsing. */
|
|
21
|
-
interface ParseCertificateSigningRequestFailure extends Micro509Error<ParseCertificateSigningRequestErrorCode> {
|
|
34
|
+
export interface ParseCertificateSigningRequestFailure extends Micro509Error<ParseCertificateSigningRequestErrorCode> {
|
|
22
35
|
/** Always `false` for failures. */
|
|
23
36
|
readonly ok: false;
|
|
24
37
|
}
|
|
@@ -26,7 +39,7 @@ interface ParseCertificateSigningRequestFailure extends Micro509Error<ParseCerti
|
|
|
26
39
|
* Success-or-failure result from {@linkcode parseCertificateSigningRequestDer} /
|
|
27
40
|
* {@linkcode parseCertificateSigningRequestPem}.
|
|
28
41
|
*/
|
|
29
|
-
type ParseCertificateSigningRequestResult<TMap extends ExtensionDecoderMap = Record<never, never>> = {
|
|
42
|
+
export type ParseCertificateSigningRequestResult<TMap extends ExtensionDecoderMap = Record<never, never>> = {
|
|
30
43
|
readonly ok: true;
|
|
31
44
|
readonly value: ParsedCertificateSigningRequest<TMap>;
|
|
32
45
|
} | ErrorResult<ParseCertificateSigningRequestErrorCode, Record<never, never>, ParseCertificateSigningRequestFailure>;
|
|
@@ -37,7 +50,7 @@ type ParseCertificateSigningRequestResult<TMap extends ExtensionDecoderMap = Rec
|
|
|
37
50
|
*
|
|
38
51
|
* @see {@link https://datatracker.ietf.org/doc/html/rfc5280#appendix-A.1 RFC 5280 Appendix A.1}
|
|
39
52
|
*/
|
|
40
|
-
interface ParsedNameAttribute {
|
|
53
|
+
export interface ParsedNameAttribute {
|
|
41
54
|
/** Dotted-decimal OID of the attribute type (e.g. `"2.5.4.3"` for CN). */
|
|
42
55
|
readonly oid: string;
|
|
43
56
|
/** Friendly key when the OID maps to a well-known field (CN, O, etc.). */
|
|
@@ -53,7 +66,7 @@ interface ParsedNameAttribute {
|
|
|
53
66
|
* Provides three views of the same data: ordered RDNs, a flat attribute
|
|
54
67
|
* list, and a convenience key-value map for well-known fields.
|
|
55
68
|
*/
|
|
56
|
-
interface ParsedName {
|
|
69
|
+
export interface ParsedName {
|
|
57
70
|
/** Hex-encoded DER of the complete Name SEQUENCE, usable for byte-exact comparisons. */
|
|
58
71
|
readonly derHex: string;
|
|
59
72
|
/** Ordered list of RelativeDistinguishedNames, preserving multi-valued RDN structure. */
|
|
@@ -64,7 +77,7 @@ interface ParsedName {
|
|
|
64
77
|
readonly values: Readonly<Partial<Record<NameFieldKey, string>>>;
|
|
65
78
|
}
|
|
66
79
|
/** A single RelativeDistinguishedName SET from an X.501 Name. */
|
|
67
|
-
interface ParsedRelativeDistinguishedName {
|
|
80
|
+
export interface ParsedRelativeDistinguishedName {
|
|
68
81
|
/** Hex-encoded DER of this RDN SET element. */
|
|
69
82
|
readonly derHex: string;
|
|
70
83
|
/** Attributes within this RDN (usually one, but multi-valued RDNs are legal). */
|
|
@@ -73,17 +86,23 @@ interface ParsedRelativeDistinguishedName {
|
|
|
73
86
|
readonly values: Readonly<Partial<Record<NameFieldKey, string>>>;
|
|
74
87
|
}
|
|
75
88
|
/**
|
|
76
|
-
* The name component of a CRL Distribution Point
|
|
77
|
-
*
|
|
89
|
+
* The name component of a CRL Distribution Point, mirroring RFC 5280 §4.2.1.13
|
|
90
|
+
* `DistributionPointName ::= CHOICE { fullName [0] GeneralNames,
|
|
91
|
+
* nameRelativeToCRLIssuer [1] RelativeDistinguishedName }`.
|
|
78
92
|
*/
|
|
79
|
-
|
|
93
|
+
export type ParsedDistributionPointName = {
|
|
94
|
+
/** The `fullName [0]` alternative. */
|
|
95
|
+
readonly type: "fullName";
|
|
80
96
|
/** Absolute GeneralName(s) identifying the distribution point. */
|
|
81
|
-
readonly fullName
|
|
97
|
+
readonly fullName: readonly GeneralName[];
|
|
98
|
+
} | {
|
|
99
|
+
/** The `nameRelativeToCRLIssuer [1]` alternative. */
|
|
100
|
+
readonly type: "relativeName";
|
|
82
101
|
/** Name relative to the CRL issuer's distinguished name. */
|
|
83
|
-
readonly relativeName
|
|
84
|
-
}
|
|
102
|
+
readonly relativeName: ParsedRelativeDistinguishedName;
|
|
103
|
+
};
|
|
85
104
|
/** A decoded DistributionPoint from the CRL Distribution Points extension. */
|
|
86
|
-
interface ParsedDistributionPoint {
|
|
105
|
+
export interface ParsedDistributionPoint {
|
|
87
106
|
/** Where to fetch the CRL — a fullName URI or relativeName. */
|
|
88
107
|
readonly distributionPoint?: ParsedDistributionPointName;
|
|
89
108
|
/** Revocation reason subset this distribution point covers. Absent means all reasons. */
|
|
@@ -95,22 +114,55 @@ interface ParsedDistributionPoint {
|
|
|
95
114
|
* Decoded Issuing Distribution Point CRL extension (RFC 5280 §5.2.5).
|
|
96
115
|
* Constrains which certificates a CRL covers (scope, reasons, indirection).
|
|
97
116
|
*/
|
|
98
|
-
|
|
117
|
+
export type ParsedIssuingDistributionPoint = ParsedIssuingDistributionPointBase & ParsedIssuingDistributionPointScope;
|
|
118
|
+
/** Scope-independent fields of a decoded Issuing Distribution Point. */
|
|
119
|
+
export interface ParsedIssuingDistributionPointBase {
|
|
99
120
|
/** Where to fetch this CRL, if specified. */
|
|
100
121
|
readonly distributionPoint?: ParsedDistributionPointName;
|
|
101
|
-
/** When true, this CRL only covers end-entity certificates. Default false. */
|
|
102
|
-
readonly onlyContainsUserCerts?: boolean;
|
|
103
|
-
/** When true, this CRL only covers CA certificates. Default false. */
|
|
104
|
-
readonly onlyContainsCACerts?: boolean;
|
|
105
122
|
/** Limits the CRL to these revocation reasons. Absent means all reasons. */
|
|
106
123
|
readonly onlySomeReasons?: ParsedBitFlags<DistributionPointReason>;
|
|
107
124
|
/** When true, this CRL may contain entries from CAs other than the issuer. Default false. */
|
|
108
125
|
readonly indirectCrl?: boolean;
|
|
109
|
-
/** When true, this CRL only covers attribute certificates. Default false. */
|
|
110
|
-
readonly onlyContainsAttributeCerts?: boolean;
|
|
111
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Which certificate kind a CRL is scoped to. RFC 5280 §5.2.5 allows at most one
|
|
129
|
+
* of `onlyContainsUserCerts`, `onlyContainsCACerts`, and
|
|
130
|
+
* `onlyContainsAttributeCerts` to be TRUE, so the union admits one at a time.
|
|
131
|
+
*
|
|
132
|
+
* A flag is absent when the encoding omitted it and `false` when the encoding
|
|
133
|
+
* carried an explicit FALSE.
|
|
134
|
+
*/
|
|
135
|
+
export type ParsedIssuingDistributionPointScope = {
|
|
136
|
+
/** No scope restriction; this CRL covers every certificate kind. */
|
|
137
|
+
readonly onlyContainsUserCerts?: false;
|
|
138
|
+
/** No scope restriction. */
|
|
139
|
+
readonly onlyContainsCACerts?: false;
|
|
140
|
+
/** No scope restriction. */
|
|
141
|
+
readonly onlyContainsAttributeCerts?: false;
|
|
142
|
+
} | {
|
|
143
|
+
/** This CRL only covers end-entity certificates. */
|
|
144
|
+
readonly onlyContainsUserCerts: true;
|
|
145
|
+
/** Excluded by the user-cert scope. */
|
|
146
|
+
readonly onlyContainsCACerts?: false;
|
|
147
|
+
/** Excluded by the user-cert scope. */
|
|
148
|
+
readonly onlyContainsAttributeCerts?: false;
|
|
149
|
+
} | {
|
|
150
|
+
/** Excluded by the CA-cert scope. */
|
|
151
|
+
readonly onlyContainsUserCerts?: false;
|
|
152
|
+
/** This CRL only covers CA certificates. */
|
|
153
|
+
readonly onlyContainsCACerts: true;
|
|
154
|
+
/** Excluded by the CA-cert scope. */
|
|
155
|
+
readonly onlyContainsAttributeCerts?: false;
|
|
156
|
+
} | {
|
|
157
|
+
/** Excluded by the attribute-cert scope. */
|
|
158
|
+
readonly onlyContainsUserCerts?: false;
|
|
159
|
+
/** Excluded by the attribute-cert scope. */
|
|
160
|
+
readonly onlyContainsCACerts?: false;
|
|
161
|
+
/** This CRL only covers attribute certificates. */
|
|
162
|
+
readonly onlyContainsAttributeCerts: true;
|
|
163
|
+
};
|
|
112
164
|
/** A raw X.509v3 extension before type-specific decoding. */
|
|
113
|
-
interface ParsedExtension {
|
|
165
|
+
export interface ParsedExtension {
|
|
114
166
|
/** Dotted-decimal OID identifying this extension. */
|
|
115
167
|
readonly oid: string;
|
|
116
168
|
/** Whether a validator MUST reject the certificate if it cannot process this extension. */
|
|
@@ -126,7 +178,7 @@ interface ParsedExtension {
|
|
|
126
178
|
* Register with {@linkcode ParseOptions.decoders} or {@linkcode ParseOptions.decoderMap}
|
|
127
179
|
* to decode custom extensions during parsing.
|
|
128
180
|
*/
|
|
129
|
-
interface ExtensionDecoder<TValue> {
|
|
181
|
+
export interface ExtensionDecoder<TValue> {
|
|
130
182
|
/** OID this decoder handles. */
|
|
131
183
|
readonly oid: string;
|
|
132
184
|
/** Decode the raw {@linkcode ParsedExtension} into a typed value. */
|
|
@@ -138,20 +190,20 @@ interface ExtensionDecoder<TValue> {
|
|
|
138
190
|
* @param decoder Decoder definition to return unchanged.
|
|
139
191
|
* @returns The same decoder, properly typed.
|
|
140
192
|
*/
|
|
141
|
-
declare function defineExtensionDecoder<TValue>(decoder: ExtensionDecoder<TValue>): ExtensionDecoder<TValue>;
|
|
193
|
+
export declare function defineExtensionDecoder<TValue>(decoder: ExtensionDecoder<TValue>): ExtensionDecoder<TValue>;
|
|
142
194
|
/**
|
|
143
195
|
* Identity helper that narrows the type of a custom {@linkcode ExtensionDecoderMap} literal.
|
|
144
196
|
*
|
|
145
197
|
* @param decoderMap Map of named decoders to return unchanged.
|
|
146
198
|
* @returns The same map, properly typed.
|
|
147
199
|
*/
|
|
148
|
-
declare function defineExtensionDecoderMap<TMap extends ExtensionDecoderMap>(decoderMap: TMap): TMap;
|
|
200
|
+
export declare function defineExtensionDecoderMap<TMap extends ExtensionDecoderMap>(decoderMap: TMap): TMap;
|
|
149
201
|
/** String-keyed map of {@linkcode ExtensionDecoder}s, used with {@linkcode ParseOptions.decoderMap}. */
|
|
150
|
-
type ExtensionDecoderMap = Record<string, ExtensionDecoder<unknown>>;
|
|
202
|
+
export type ExtensionDecoderMap = Record<string, ExtensionDecoder<unknown>>;
|
|
151
203
|
/** Inferred result type when decoding extensions via an {@linkcode ExtensionDecoderMap}. */
|
|
152
|
-
type DecodedExtensionMap<TMap extends ExtensionDecoderMap> = { [TKey in keyof TMap]?: TMap[TKey] extends ExtensionDecoder<infer TValue> ? DecodedExtensionValue<TValue> : never; };
|
|
204
|
+
export type DecodedExtensionMap<TMap extends ExtensionDecoderMap> = { [TKey in keyof TMap]?: TMap[TKey] extends ExtensionDecoder<infer TValue> ? DecodedExtensionValue<TValue> : never; };
|
|
153
205
|
/** A successfully decoded extension value paired with its OID and criticality. */
|
|
154
|
-
interface DecodedExtensionValue<TValue> {
|
|
206
|
+
export interface DecodedExtensionValue<TValue> {
|
|
155
207
|
/** Dotted-decimal OID of the decoded extension. */
|
|
156
208
|
readonly oid: string;
|
|
157
209
|
/** Whether the extension was marked critical in the certificate. */
|
|
@@ -166,7 +218,7 @@ interface DecodedExtensionValue<TValue> {
|
|
|
166
218
|
* Supply custom extension decoders to have their results included in the parsed output alongside
|
|
167
219
|
* the built-in extensions.
|
|
168
220
|
*/
|
|
169
|
-
interface ParseOptions<TMap extends ExtensionDecoderMap = Record<never, never>> {
|
|
221
|
+
export interface ParseOptions<TMap extends ExtensionDecoderMap = Record<never, never>> {
|
|
170
222
|
/** Array of decoders; decoded values appear in `decodedExtensions`. */
|
|
171
223
|
readonly decoders?: readonly ExtensionDecoder<unknown>[];
|
|
172
224
|
/** Named decoder map; decoded values appear in `decodedExtensionMap` keyed by map key. */
|
|
@@ -179,7 +231,7 @@ interface ParseOptions<TMap extends ExtensionDecoderMap = Record<never, never>>
|
|
|
179
231
|
* typed fields automatically.\
|
|
180
232
|
* Supply {@linkcode ParseOptions} to also decode custom extensions.
|
|
181
233
|
*/
|
|
182
|
-
interface ParsedCertificate<TMap extends ExtensionDecoderMap = Record<never, never>> {
|
|
234
|
+
export interface ParsedCertificate<TMap extends ExtensionDecoderMap = Record<never, never>> {
|
|
183
235
|
/** Complete DER encoding of the certificate (copied from the input). */
|
|
184
236
|
readonly der: Uint8Array;
|
|
185
237
|
/** X.509 version number (1, 2, or 3). Almost always 3. */
|
|
@@ -224,6 +276,8 @@ interface ParsedCertificate<TMap extends ExtensionDecoderMap = Record<never, nev
|
|
|
224
276
|
readonly extendedKeyUsage?: readonly ExtendedKeyUsage[];
|
|
225
277
|
/** Decoded Subject Alternative Names (RFC 5280 §4.2.1.6). */
|
|
226
278
|
readonly subjectAltNames?: readonly SubjectAltName[];
|
|
279
|
+
/** Decoded Issuer Alternative Names (RFC 5280 §4.2.1.7). */
|
|
280
|
+
readonly issuerAltNames?: readonly SubjectAltName[];
|
|
227
281
|
/** Decoded Name Constraints (RFC 5280 §4.2.1.10). */
|
|
228
282
|
readonly nameConstraints?: NameConstraints<ParsedNameConstraintForm>;
|
|
229
283
|
/** Decoded Certificate Policies (RFC 5280 §4.2.1.4). */
|
|
@@ -234,10 +288,12 @@ interface ParsedCertificate<TMap extends ExtensionDecoderMap = Record<never, nev
|
|
|
234
288
|
readonly policyConstraints?: PolicyConstraints;
|
|
235
289
|
/** Decoded Inhibit anyPolicy (RFC 5280 §4.2.1.14). */
|
|
236
290
|
readonly inhibitAnyPolicy?: InhibitAnyPolicy;
|
|
237
|
-
/** Decoded Authority Information Access —
|
|
291
|
+
/** Decoded Authority Information Access — GeneralName access locations (RFC 5280 §4.2.2.1). */
|
|
238
292
|
readonly authorityInfoAccess?: readonly AuthorityInformationAccess[];
|
|
239
293
|
/** Decoded CRL Distribution Points (RFC 5280 §4.2.1.13). */
|
|
240
294
|
readonly crlDistributionPoints?: readonly ParsedDistributionPoint[];
|
|
295
|
+
/** `true` when the certificate carries No Revocation Available (RFC 9608 §2). */
|
|
296
|
+
readonly noRevAvail?: true;
|
|
241
297
|
/** Custom-decoded extensions from {@linkcode ParseOptions.decoders}. */
|
|
242
298
|
readonly decodedExtensions?: readonly DecodedExtensionValue<unknown>[];
|
|
243
299
|
/** Custom-decoded extensions from {@linkcode ParseOptions.decoderMap}, keyed by map key. */
|
|
@@ -253,8 +309,8 @@ interface ParsedCertificate<TMap extends ExtensionDecoderMap = Record<never, nev
|
|
|
253
309
|
* Extension fields mirror {@linkcode ParsedCertificate} but come from the
|
|
254
310
|
* CSR's extensionRequest attribute rather than the v3 extensions block.
|
|
255
311
|
*/
|
|
256
|
-
interface ParsedCertificateSigningRequest<TMap extends ExtensionDecoderMap = Record<never, never>> {
|
|
257
|
-
/** PKCS#10 version
|
|
312
|
+
export interface ParsedCertificateSigningRequest<TMap extends ExtensionDecoderMap = Record<never, never>> {
|
|
313
|
+
/** PKCS#10 version, normalized to the v1 ordinal `1`. The encoded CertificationRequestInfo version INTEGER is `0` (RFC 2986 §4.1). */
|
|
258
314
|
readonly version: number;
|
|
259
315
|
/** DER encoding of the CertificationRequestInfo, used for signature verification. */
|
|
260
316
|
readonly certificationRequestInfoDer: Uint8Array;
|
|
@@ -302,6 +358,8 @@ interface ParsedCertificateSigningRequest<TMap extends ExtensionDecoderMap = Rec
|
|
|
302
358
|
readonly authorityInfoAccess?: readonly AuthorityInformationAccess[];
|
|
303
359
|
/** Decoded CRL Distribution Points from the extensionRequest attribute. */
|
|
304
360
|
readonly crlDistributionPoints?: readonly ParsedDistributionPoint[];
|
|
361
|
+
/** `true` when the extensionRequest attribute carries No Revocation Available (RFC 9608 §2). */
|
|
362
|
+
readonly noRevAvail?: true;
|
|
305
363
|
/** Custom-decoded extensions from {@linkcode ParseOptions.decoders}. */
|
|
306
364
|
readonly decodedExtensions?: readonly DecodedExtensionValue<unknown>[];
|
|
307
365
|
/** Custom-decoded extensions from {@linkcode ParseOptions.decoderMap}. */
|
|
@@ -318,7 +376,7 @@ interface ParsedCertificateSigningRequest<TMap extends ExtensionDecoderMap = Rec
|
|
|
318
376
|
* @param der Raw DER bytes of an X.509 certificate.
|
|
319
377
|
* @param options Custom extension decoders to apply during parsing.
|
|
320
378
|
*/
|
|
321
|
-
declare function parseCertificateDerOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParsedCertificate<TMap>;
|
|
379
|
+
export declare function parseCertificateDerOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParsedCertificate<TMap>;
|
|
322
380
|
/**
|
|
323
381
|
* Decode a DER-encoded X.509 certificate into a {@linkcode ParsedCertificate}.
|
|
324
382
|
*
|
|
@@ -335,7 +393,7 @@ declare function parseCertificateDerOrThrow<TMap extends ExtensionDecoderMap = R
|
|
|
335
393
|
* @param der Raw DER bytes of an X.509 certificate.
|
|
336
394
|
* @param options Custom extension decoders to apply during parsing.
|
|
337
395
|
*/
|
|
338
|
-
declare function parseCertificateDer<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParseCertificateResult<TMap>;
|
|
396
|
+
export declare function parseCertificateDer<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParseCertificateResult<TMap>;
|
|
339
397
|
/**
|
|
340
398
|
* Decode a PEM-encoded X.509 certificate into a {@linkcode ParsedCertificate}.
|
|
341
399
|
*
|
|
@@ -354,7 +412,7 @@ declare function parseCertificateDer<TMap extends ExtensionDecoderMap = Record<n
|
|
|
354
412
|
* @param pem PEM string with a CERTIFICATE block.
|
|
355
413
|
* @param options Custom extension decoders to apply during parsing.
|
|
356
414
|
*/
|
|
357
|
-
declare function parseCertificatePemOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParsedCertificate<TMap>;
|
|
415
|
+
export declare function parseCertificatePemOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParsedCertificate<TMap>;
|
|
358
416
|
/**
|
|
359
417
|
* Decode a PEM-encoded X.509 certificate into a {@linkcode ParsedCertificate}.
|
|
360
418
|
*
|
|
@@ -367,44 +425,58 @@ declare function parseCertificatePemOrThrow<TMap extends ExtensionDecoderMap = R
|
|
|
367
425
|
* @param pem PEM string with a CERTIFICATE block.
|
|
368
426
|
* @param options Custom extension decoders to apply during parsing.
|
|
369
427
|
*/
|
|
370
|
-
declare function parseCertificatePem<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParseCertificateResult<TMap>;
|
|
428
|
+
export declare function parseCertificatePem<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParseCertificateResult<TMap>;
|
|
429
|
+
/** Normalizes a PEM bundle or single DER certificate source into parsed certificates. */
|
|
430
|
+
export declare function parseCertificatesFromSource<TMap extends ExtensionDecoderMap = Record<never, never>>(source: string | Uint8Array, options?: ParseOptions<TMap>): readonly ParsedCertificate<TMap>[];
|
|
431
|
+
/** Normalizes a PEM, DER, or already-parsed certificate source into one parsed certificate. */
|
|
432
|
+
export declare function parseCertificateFromSource<TMap extends ExtensionDecoderMap = Record<never, never>>(source: ParsedCertificate<TMap> | string | Uint8Array, options?: ParseOptions<TMap>): ParsedCertificate<TMap>;
|
|
371
433
|
/**
|
|
372
|
-
* Decode a PEM bundle containing one or more certificates.
|
|
434
|
+
* Decode a PEM bundle containing one or more certificates, throwing on malformed input.
|
|
373
435
|
*
|
|
374
436
|
* Non-CERTIFICATE blocks (e.g. private keys) are silently skipped.
|
|
375
437
|
*
|
|
376
438
|
* @param pemBundle PEM text that may contain multiple CERTIFICATE blocks.
|
|
377
439
|
* @param options Custom extension decoders to apply during parsing.
|
|
378
440
|
*/
|
|
379
|
-
declare function
|
|
441
|
+
export declare function parseCertificateChainPemOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(pemBundle: string, options?: ParseOptions<TMap>): readonly ParsedCertificate<TMap>[];
|
|
442
|
+
/**
|
|
443
|
+
* Decode a PEM bundle containing one or more certificates.
|
|
444
|
+
*
|
|
445
|
+
* Non-CERTIFICATE blocks (e.g. private keys) are silently skipped. Returns a
|
|
446
|
+
* typed `malformed` failure for invalid PEM or certificate DER.
|
|
447
|
+
*
|
|
448
|
+
* @param pemBundle PEM text that may contain multiple CERTIFICATE blocks.
|
|
449
|
+
* @param options Custom extension decoders to apply during parsing.
|
|
450
|
+
*/
|
|
451
|
+
export declare function parseCertificateChainPem<TMap extends ExtensionDecoderMap = Record<never, never>>(pemBundle: string, options?: ParseOptions<TMap>): ParseCertificateChainResult<TMap>;
|
|
380
452
|
/**
|
|
381
453
|
* Decode a DER-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
|
|
382
454
|
*
|
|
383
455
|
* @param der Raw DER bytes of a PKCS#10 certificate signing request.
|
|
384
456
|
* @param options Custom extension decoders to apply during parsing.
|
|
385
457
|
*/
|
|
386
|
-
declare function parseCertificateSigningRequestDerOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParsedCertificateSigningRequest<TMap>;
|
|
458
|
+
export declare function parseCertificateSigningRequestDerOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParsedCertificateSigningRequest<TMap>;
|
|
387
459
|
/**
|
|
388
460
|
* Decode a DER-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
|
|
389
461
|
*
|
|
390
462
|
* @param der Raw DER bytes of a PKCS#10 certificate signing request.
|
|
391
463
|
* @param options Custom extension decoders to apply during parsing.
|
|
392
464
|
*/
|
|
393
|
-
declare function parseCertificateSigningRequestDer<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParseCertificateSigningRequestResult<TMap>;
|
|
465
|
+
export declare function parseCertificateSigningRequestDer<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParseCertificateSigningRequestResult<TMap>;
|
|
394
466
|
/**
|
|
395
467
|
* Decode a PEM-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
|
|
396
468
|
*
|
|
397
469
|
* @param pem PEM string with a CERTIFICATE REQUEST block.
|
|
398
470
|
* @param options Custom extension decoders to apply during parsing.
|
|
399
471
|
*/
|
|
400
|
-
declare function parseCertificateSigningRequestPemOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParsedCertificateSigningRequest<TMap>;
|
|
472
|
+
export declare function parseCertificateSigningRequestPemOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParsedCertificateSigningRequest<TMap>;
|
|
401
473
|
/**
|
|
402
474
|
* Decode a PEM-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
|
|
403
475
|
*
|
|
404
476
|
* @param pem PEM string with a CERTIFICATE REQUEST block.
|
|
405
477
|
* @param options Custom extension decoders to apply during parsing.
|
|
406
478
|
*/
|
|
407
|
-
declare function parseCertificateSigningRequestPem<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParseCertificateSigningRequestResult<TMap>;
|
|
479
|
+
export declare function parseCertificateSigningRequestPem<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParseCertificateSigningRequestResult<TMap>;
|
|
408
480
|
/**
|
|
409
481
|
* Import the subject public key of a parsed certificate or CSR as a WebCrypto `CryptoKey`.
|
|
410
482
|
*
|
|
@@ -433,13 +505,13 @@ declare function parseCertificateSigningRequestPem<TMap extends ExtensionDecoder
|
|
|
433
505
|
*
|
|
434
506
|
* @see {@linkcode getSubjectPublicKey} for the non-throwing variant
|
|
435
507
|
*/
|
|
436
|
-
declare function getSubjectPublicKeyOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(parsed: ParsedCertificate<TMap> | ParsedCertificateSigningRequest<TMap>, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
|
|
508
|
+
export declare function getSubjectPublicKeyOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(parsed: ParsedCertificate<TMap> | ParsedCertificateSigningRequest<TMap>, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
|
|
437
509
|
/**
|
|
438
510
|
* Import the subject public key of a parsed certificate or CSR as a WebCrypto `CryptoKey`.
|
|
439
511
|
*
|
|
440
512
|
* @see `getSubjectPublicKeyOrThrow` for the throwing variant
|
|
441
513
|
*/
|
|
442
|
-
declare function getSubjectPublicKey<TMap extends ExtensionDecoderMap = Record<never, never>>(parsed: ParsedCertificate<TMap> | ParsedCertificateSigningRequest<TMap>, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
|
|
514
|
+
export declare function getSubjectPublicKey<TMap extends ExtensionDecoderMap = Record<never, never>>(parsed: ParsedCertificate<TMap> | ParsedCertificateSigningRequest<TMap>, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
|
|
443
515
|
/**
|
|
444
516
|
* Check whether a certificate's subject public key belongs to a private key.
|
|
445
517
|
*
|
|
@@ -484,25 +556,25 @@ declare function getSubjectPublicKey<TMap extends ExtensionDecoderMap = Record<n
|
|
|
484
556
|
* @see {@linkcode getSubjectPublicKeyOrThrow} to obtain the certificate's public key directly
|
|
485
557
|
* @see {@linkcode derivePublicKey} for the private-to-public bridge this builds on
|
|
486
558
|
*/
|
|
487
|
-
declare function certificateMatchesPrivateKey<TMap extends ExtensionDecoderMap = Record<never, never>>(certificate: ParsedCertificate<TMap> | string | Uint8Array, privateKey: CryptoKey): Promise<boolean>;
|
|
559
|
+
export declare function certificateMatchesPrivateKey<TMap extends ExtensionDecoderMap = Record<never, never>>(certificate: ParsedCertificate<TMap> | string | Uint8Array, privateKey: CryptoKey): Promise<boolean>;
|
|
488
560
|
/** Machine-readable failure reason for {@linkcode matchCertificatePrivateKey}. */
|
|
489
|
-
type MatchCertificatePrivateKeyErrorCode = "malformed_certificate" | "unsupported_private_key" | "key_type_mismatch" | "key_mismatch";
|
|
561
|
+
export type MatchCertificatePrivateKeyErrorCode = "malformed_certificate" | "unsupported_private_key" | "key_type_mismatch" | "key_mismatch" | DecodeRefusalCode;
|
|
490
562
|
/** Structured failure payload for {@linkcode matchCertificatePrivateKey}. */
|
|
491
|
-
interface MatchCertificatePrivateKeyFailure extends Micro509Error<MatchCertificatePrivateKeyErrorCode> {
|
|
563
|
+
export interface MatchCertificatePrivateKeyFailure extends Micro509Error<MatchCertificatePrivateKeyErrorCode> {
|
|
492
564
|
/** Always `false` for failures. */
|
|
493
565
|
readonly ok: false;
|
|
494
566
|
}
|
|
495
567
|
/** A successful match: the private key's public half is the certificate's subject public key. */
|
|
496
|
-
interface MatchCertificatePrivateKeySuccess {
|
|
568
|
+
export interface MatchCertificatePrivateKeySuccess {
|
|
497
569
|
/** Always `true` for success. */
|
|
498
570
|
readonly ok: true;
|
|
499
571
|
/** No payload on success — the match itself is the signal. */
|
|
500
572
|
readonly value: undefined;
|
|
501
573
|
}
|
|
502
574
|
/** Failure branch of {@linkcode MatchCertificatePrivateKeyResult} with structured error details. */
|
|
503
|
-
type MatchCertificatePrivateKeyFailureResult = ErrorResult<MatchCertificatePrivateKeyErrorCode, Record<never, never>, MatchCertificatePrivateKeyFailure>;
|
|
575
|
+
export type MatchCertificatePrivateKeyFailureResult = ErrorResult<MatchCertificatePrivateKeyErrorCode, Record<never, never>, MatchCertificatePrivateKeyFailure>;
|
|
504
576
|
/** Result of {@linkcode matchCertificatePrivateKey}. */
|
|
505
|
-
type MatchCertificatePrivateKeyResult = MatchCertificatePrivateKeySuccess | MatchCertificatePrivateKeyFailureResult;
|
|
577
|
+
export type MatchCertificatePrivateKeyResult = MatchCertificatePrivateKeySuccess | MatchCertificatePrivateKeyFailureResult;
|
|
506
578
|
/**
|
|
507
579
|
* Check whether a certificate's subject public key belongs to a private key,
|
|
508
580
|
* returning a typed {@linkcode MatchCertificatePrivateKeyResult}.
|
|
@@ -516,6 +588,9 @@ type MatchCertificatePrivateKeyResult = MatchCertificatePrivateKeySuccess | Matc
|
|
|
516
588
|
* one of:
|
|
517
589
|
*
|
|
518
590
|
* - `malformed_certificate` — `certificate` could not be parsed.
|
|
591
|
+
* - `unsupported` or `limit_exceeded` — `certificate` holds a construct
|
|
592
|
+
* micro509 does not decode or exceeds a decoding limit (see
|
|
593
|
+
* {@linkcode ParseCertificateErrorCode}).
|
|
519
594
|
* - `unsupported_private_key` — `privateKey` is not an extractable private key
|
|
520
595
|
* of a supported type (from {@linkcode derivePublicKey}).
|
|
521
596
|
* - `key_type_mismatch` — the key is a different algorithm than the
|
|
@@ -536,13 +611,14 @@ type MatchCertificatePrivateKeyResult = MatchCertificatePrivateKeySuccess | Matc
|
|
|
536
611
|
* if (!result.ok) {
|
|
537
612
|
* // result.code is 'malformed_certificate' | 'unsupported_private_key'
|
|
538
613
|
* // | 'key_type_mismatch' | 'key_mismatch'
|
|
614
|
+
* // | 'unsupported' | 'limit_exceeded'
|
|
539
615
|
* throw new Error(`key does not match certificate: ${result.code}`);
|
|
540
616
|
* }
|
|
541
617
|
* ```
|
|
542
618
|
*
|
|
543
619
|
* @see {@linkcode certificateMatchesPrivateKey} for the plain-boolean variant
|
|
544
620
|
*/
|
|
545
|
-
declare function matchCertificatePrivateKey<TMap extends ExtensionDecoderMap = Record<never, never>>(certificate: ParsedCertificate<TMap> | string | Uint8Array, privateKey: CryptoKey): Promise<MatchCertificatePrivateKeyResult>;
|
|
621
|
+
export declare function matchCertificatePrivateKey<TMap extends ExtensionDecoderMap = Record<never, never>>(certificate: ParsedCertificate<TMap> | string | Uint8Array, privateKey: CryptoKey): Promise<MatchCertificatePrivateKeyResult>;
|
|
546
622
|
/**
|
|
547
623
|
* Find a raw extension by OID within a parsed extension list.
|
|
548
624
|
*
|
|
@@ -550,7 +626,7 @@ declare function matchCertificatePrivateKey<TMap extends ExtensionDecoderMap = R
|
|
|
550
626
|
* @param oid Dotted-decimal OID to look up.
|
|
551
627
|
* @returns The matching extension, or `undefined` if not present.
|
|
552
628
|
*/
|
|
553
|
-
declare function findExtension(extensions: readonly ParsedExtension[], oid: string): ParsedExtension | undefined;
|
|
629
|
+
export declare function findExtension(extensions: readonly ParsedExtension[], oid: string): ParsedExtension | undefined;
|
|
554
630
|
/**
|
|
555
631
|
* Decode a single extension using a custom {@linkcode ExtensionDecoder}.
|
|
556
632
|
*
|
|
@@ -558,21 +634,46 @@ declare function findExtension(extensions: readonly ParsedExtension[], oid: stri
|
|
|
558
634
|
* @param decoder Decoder whose OID will be matched.
|
|
559
635
|
* @returns The decoded value, or `undefined` if the extension is absent.
|
|
560
636
|
*/
|
|
561
|
-
declare function decodeExtension<TValue>(extensions: readonly ParsedExtension[], decoder: ExtensionDecoder<TValue>): TValue | undefined;
|
|
637
|
+
export declare function decodeExtension<TValue>(extensions: readonly ParsedExtension[], decoder: ExtensionDecoder<TValue>): TValue | undefined;
|
|
562
638
|
/**
|
|
563
639
|
* Decode all matching extensions using an array of {@linkcode ExtensionDecoder}s.
|
|
564
640
|
*
|
|
565
641
|
* @param extensions Extension list to search.
|
|
566
642
|
* @param decoders Decoders to apply. Only matching OIDs produce output.
|
|
567
643
|
*/
|
|
568
|
-
declare function decodeExtensions(extensions: readonly ParsedExtension[], decoders: readonly ExtensionDecoder<unknown>[]): readonly DecodedExtensionValue<unknown>[];
|
|
644
|
+
export declare function decodeExtensions(extensions: readonly ParsedExtension[], decoders: readonly ExtensionDecoder<unknown>[]): readonly DecodedExtensionValue<unknown>[];
|
|
569
645
|
/**
|
|
570
646
|
* Decode all matching extensions using a named {@linkcode ExtensionDecoderMap}.
|
|
571
647
|
*
|
|
572
648
|
* @param extensions Extension list to search.
|
|
573
649
|
* @param decoderMap Named decoders. Results are keyed by the same map keys.
|
|
574
650
|
*/
|
|
575
|
-
declare function decodeExtensionMap<TMap extends ExtensionDecoderMap>(extensions: readonly ParsedExtension[], decoderMap: TMap): DecodedExtensionMap<TMap>;
|
|
576
|
-
|
|
577
|
-
export
|
|
651
|
+
export declare function decodeExtensionMap<TMap extends ExtensionDecoderMap>(extensions: readonly ParsedExtension[], decoderMap: TMap): DecodedExtensionMap<TMap>;
|
|
652
|
+
/** Decodes the Basic Constraints extension value DER. */
|
|
653
|
+
export declare function parseBasicConstraints(bytes: Uint8Array): BasicConstraints;
|
|
654
|
+
/** Decodes the Key Usage BIT STRING extension value. */
|
|
655
|
+
export declare function parseKeyUsage(bytes: Uint8Array): ParsedBitFlags<KeyUsage>;
|
|
656
|
+
/** Decodes the Extended Key Usage SEQUENCE OF OIDs. */
|
|
657
|
+
export declare function parseExtendedKeyUsage(bytes: Uint8Array): readonly ExtendedKeyUsage[];
|
|
658
|
+
/** Decodes the Certificate Policies extension value. */
|
|
659
|
+
export declare function parseCertificatePolicies(bytes: Uint8Array): CertificatePolicies;
|
|
660
|
+
/** Decodes the Policy Mappings extension value. */
|
|
661
|
+
export declare function parsePolicyMappings(bytes: Uint8Array): PolicyMappings;
|
|
662
|
+
/** Decodes the Policy Constraints extension value. */
|
|
663
|
+
export declare function parsePolicyConstraints(bytes: Uint8Array): PolicyConstraints;
|
|
664
|
+
/** Decodes the Inhibit anyPolicy extension (single INTEGER). */
|
|
665
|
+
export declare function parseInhibitAnyPolicy(bytes: Uint8Array): InhibitAnyPolicy;
|
|
666
|
+
/** Decodes a subjectAltName or issuerAltName SEQUENCE OF GeneralName. */
|
|
667
|
+
export declare function parseSubjectAltNames(bytes: Uint8Array, label?: string): readonly SubjectAltName[];
|
|
668
|
+
/** Decodes a bare DER-encoded X.501 Name, as carried in a `directoryName` GeneralName. */
|
|
669
|
+
export declare function parseDistinguishedNameDer(bytes: Uint8Array): ParsedName;
|
|
670
|
+
/** Decodes the Authority Information Access extension value. */
|
|
671
|
+
export declare function parseAuthorityInfoAccess(bytes: Uint8Array): readonly AuthorityInformationAccess[];
|
|
672
|
+
/** Decodes the CRL Distribution Points extension value. */
|
|
673
|
+
export declare function parseCrlDistributionPoints(bytes: Uint8Array): readonly ParsedDistributionPoint[];
|
|
674
|
+
/** Decodes the Name Constraints extension value. */
|
|
675
|
+
export declare function parseNameConstraints(bytes: Uint8Array): NameConstraints<ParsedNameConstraintForm>;
|
|
676
|
+
/** Decodes the Authority Key Identifier extension, returning the keyIdentifier hex or undefined. */
|
|
677
|
+
export declare function parseAuthorityKeyIdentifier(bytes: Uint8Array): string | undefined;
|
|
678
|
+
export type { ParsedBitFlags };
|
|
578
679
|
//# sourceMappingURL=parse.d.ts.map
|