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,14 +1,16 @@
|
|
|
1
1
|
import { NameAttribute, NameFieldKey, RelativeDistinguishedNameInput } from "./name.js";
|
|
2
|
-
|
|
2
|
+
import { ExtensionEncoderErrorCode } from "../internal/x509/extension-errors.js";
|
|
3
|
+
import { allOnesMaskForIpAddress, decodeIpAddress, normalizeIpAddress, parseIpAddressToBytes } from "../internal/shared/ip.js";
|
|
3
4
|
/**
|
|
4
5
|
* A decoded BIT STRING flag set.
|
|
5
6
|
*
|
|
6
7
|
* `flags` contains the recognized flag values with any non-zero padding bits
|
|
7
8
|
* masked out. `nonZeroPadding` is `true` when the original BIT STRING encoding
|
|
8
9
|
* had non-zero bits in positions that DER ({@linkcode https://www.itu.int/rec/T-REC-X.690-202102-I/en | X.690 §11.2.1}) requires to be zero.
|
|
9
|
-
*
|
|
10
|
+
* Extension flag decoding rejects such encodings, so parsed extension values
|
|
11
|
+
* always report `false`.
|
|
10
12
|
*/
|
|
11
|
-
interface ParsedBitFlags<T extends string> {
|
|
13
|
+
export interface ParsedBitFlags<T extends string> {
|
|
12
14
|
/** Decoded flag values, padding bits masked. */
|
|
13
15
|
readonly flags: readonly T[];
|
|
14
16
|
/** `true` when the original encoding had non-zero padding bits (DER violation). */
|
|
@@ -21,15 +23,16 @@ interface ParsedBitFlags<T extends string> {
|
|
|
21
23
|
*
|
|
22
24
|
* @see {@link https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.3 RFC 5280 §4.2.1.3}
|
|
23
25
|
*/
|
|
24
|
-
type KeyUsage = "digitalSignature" | "nonRepudiation" | "keyEncipherment" | "dataEncipherment" | "keyAgreement" | "keyCertSign" | "cRLSign" | "encipherOnly" | "decipherOnly";
|
|
26
|
+
export type KeyUsage = "digitalSignature" | "nonRepudiation" | "keyEncipherment" | "dataEncipherment" | "keyAgreement" | "keyCertSign" | "cRLSign" | "encipherOnly" | "decipherOnly";
|
|
25
27
|
/**
|
|
26
28
|
* RFC 5280 §4.2.1.6 Subject Alternative Name / GeneralName.
|
|
27
29
|
*
|
|
28
30
|
* Discriminated union keyed on `type`.
|
|
29
31
|
*
|
|
30
|
-
*
|
|
32
|
+
* Every GeneralName alternative has a typed variant. Parsing never produces
|
|
33
|
+
* `'unknown'`, which remains as raw builder input.
|
|
31
34
|
*/
|
|
32
|
-
type SubjectAltName = {
|
|
35
|
+
export type SubjectAltName = {
|
|
33
36
|
/** DNS hostname (dNSName [2]). */
|
|
34
37
|
readonly type: "dns";
|
|
35
38
|
/** Fully-qualified domain name, e.g. `"example.com"`. */
|
|
@@ -42,7 +45,7 @@ type SubjectAltName = {
|
|
|
42
45
|
} | {
|
|
43
46
|
/** Email address (rfc822Name [1]). */
|
|
44
47
|
readonly type: "email";
|
|
45
|
-
/** RFC
|
|
48
|
+
/** RFC 2821 §4.1.2 Mailbox (`Local-part@Domain`), e.g. `"admin@example.com"`. */
|
|
46
49
|
readonly value: string;
|
|
47
50
|
} | {
|
|
48
51
|
/** URI (uniformResourceIdentifier [6]). */
|
|
@@ -54,13 +57,54 @@ type SubjectAltName = {
|
|
|
54
57
|
readonly type: "srv";
|
|
55
58
|
/** SRV service name, e.g. `"_imaps.example.com"`. */
|
|
56
59
|
readonly value: string;
|
|
60
|
+
} | {
|
|
61
|
+
/** SmtpUTF8Mailbox otherName (id-on-SmtpUTF8Mailbox, RFC 9598 §3). */
|
|
62
|
+
readonly type: "smtpUtf8Mailbox";
|
|
63
|
+
/** Internationalized mailbox whose domain is in A-labels, e.g. `"用户@example.com"`. */
|
|
64
|
+
readonly value: string;
|
|
65
|
+
} | {
|
|
66
|
+
/** User principal name otherName (szOID_NT_PRINCIPAL_NAME, [MS-WCCE] §2.2.2.7.5), a UTF8String. */
|
|
67
|
+
readonly type: "upn";
|
|
68
|
+
/** User principal name, e.g. `"user@example.com"`. */
|
|
69
|
+
readonly value: string;
|
|
70
|
+
} | {
|
|
71
|
+
/** Kerberos principal name otherName (id-pkinit-san, RFC 4556 §3.2.2). */
|
|
72
|
+
readonly type: "krb5PrincipalName";
|
|
73
|
+
/** Kerberos realm, e.g. `"EXAMPLE.COM"`. */
|
|
74
|
+
readonly realm: string;
|
|
75
|
+
/** RFC 4120 §6.2 name type, e.g. `1` for NT-PRINCIPAL. */
|
|
76
|
+
readonly nameType: number;
|
|
77
|
+
/** Principal name components, e.g. `["host", "www.example.com"]`. */
|
|
78
|
+
readonly nameString: readonly string[];
|
|
57
79
|
} | {
|
|
58
80
|
/** X.500 directory name (directoryName [4]). */
|
|
59
81
|
readonly type: "directoryName";
|
|
60
82
|
/** Hex-encoded DER of the Name SEQUENCE. */
|
|
61
83
|
readonly derHex: string;
|
|
62
84
|
} | {
|
|
63
|
-
/**
|
|
85
|
+
/** otherName [0] of a type-id without a dedicated variant, or a UPN or KRB5PrincipalName value that does not fit its variant. */
|
|
86
|
+
readonly type: "otherName";
|
|
87
|
+
/** Dotted-decimal type-id OID. */
|
|
88
|
+
readonly typeId: string;
|
|
89
|
+
/** DER of the single element inside `value [0] EXPLICIT`. */
|
|
90
|
+
readonly value: Uint8Array;
|
|
91
|
+
} | {
|
|
92
|
+
/** X.400 O/R address (x400Address [3]). */
|
|
93
|
+
readonly type: "x400Address";
|
|
94
|
+
/** Content octets of the ORAddress SEQUENCE. */
|
|
95
|
+
readonly value: Uint8Array;
|
|
96
|
+
} | {
|
|
97
|
+
/** EDI party name (ediPartyName [5]). */
|
|
98
|
+
readonly type: "ediPartyName";
|
|
99
|
+
/** Content octets of the EDIPartyName SEQUENCE. */
|
|
100
|
+
readonly value: Uint8Array;
|
|
101
|
+
} | {
|
|
102
|
+
/** Registered identifier (registeredID [8]). */
|
|
103
|
+
readonly type: "registeredID";
|
|
104
|
+
/** Dotted-decimal OID. */
|
|
105
|
+
readonly value: string;
|
|
106
|
+
} | {
|
|
107
|
+
/** Raw {@linkcode GeneralName} builder input, encoded under its wire tag. */
|
|
64
108
|
readonly type: "unknown";
|
|
65
109
|
/** ASN.1 context tag number. */
|
|
66
110
|
readonly tag: number;
|
|
@@ -68,30 +112,35 @@ type SubjectAltName = {
|
|
|
68
112
|
readonly value: Uint8Array;
|
|
69
113
|
};
|
|
70
114
|
/** Alias for {@linkcode SubjectAltName} — used where RFC 5280 says "GeneralName". */
|
|
71
|
-
type GeneralName = SubjectAltName;
|
|
115
|
+
export type GeneralName = SubjectAltName;
|
|
72
116
|
/**
|
|
73
117
|
* Revocation reason flags for CRL Distribution Points and Issuing Distribution Points
|
|
74
118
|
* (RFC 5280 §4.2.1.13, §5.2.5).
|
|
75
119
|
*/
|
|
76
|
-
type DistributionPointReason = "keyCompromise" | "cACompromise" | "affiliationChanged" | "superseded" | "cessationOfOperation" | "certificateHold" | "privilegeWithdrawn" | "aACompromise";
|
|
120
|
+
export type DistributionPointReason = "keyCompromise" | "cACompromise" | "affiliationChanged" | "superseded" | "cessationOfOperation" | "certificateHold" | "privilegeWithdrawn" | "aACompromise";
|
|
77
121
|
/**
|
|
78
|
-
* Name component of a CRL Distribution Point
|
|
79
|
-
*
|
|
80
|
-
*
|
|
122
|
+
* Name component of a CRL Distribution Point, mirroring RFC 5280 §4.2.1.13
|
|
123
|
+
* `DistributionPointName ::= CHOICE { fullName [0] GeneralNames,
|
|
124
|
+
* nameRelativeToCRLIssuer [1] RelativeDistinguishedName }`.
|
|
81
125
|
*/
|
|
82
|
-
|
|
126
|
+
export type DistributionPointName = {
|
|
127
|
+
/** The `fullName [0]` alternative. */
|
|
128
|
+
readonly type: "fullName";
|
|
83
129
|
/** Absolute {@linkcode GeneralName}(s) identifying the distribution point (usually a URI). */
|
|
84
|
-
readonly fullName
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
130
|
+
readonly fullName: readonly GeneralName[];
|
|
131
|
+
} | {
|
|
132
|
+
/** The `nameRelativeToCRLIssuer [1]` alternative. */
|
|
133
|
+
readonly type: "relativeName";
|
|
134
|
+
/** Name relative to the issuer's DN. */
|
|
135
|
+
readonly relativeName: RelativeDistinguishedNameInput;
|
|
136
|
+
};
|
|
88
137
|
/**
|
|
89
138
|
* Input for a single CRL Distribution Point (RFC 5280 §4.2.1.13).
|
|
90
139
|
*
|
|
91
140
|
* At least one of `distributionPoint` or `crlIssuer` must be provided.
|
|
92
141
|
* The union enforces this constraint at the type level.
|
|
93
142
|
*/
|
|
94
|
-
type DistributionPoint = {
|
|
143
|
+
export type DistributionPoint = {
|
|
95
144
|
/** Where to fetch the CRL (fullName or relativeName). */
|
|
96
145
|
readonly distributionPoint: DistributionPointName;
|
|
97
146
|
/** Revocation reason subset. Absent means all reasons. */
|
|
@@ -107,7 +156,7 @@ type DistributionPoint = {
|
|
|
107
156
|
readonly crlIssuer: readonly GeneralName[];
|
|
108
157
|
};
|
|
109
158
|
/** Base shape for Issuing Distribution Point (RFC 5280 §5.2.5) — no scope restriction. */
|
|
110
|
-
interface IssuingDistributionPointBase {
|
|
159
|
+
export interface IssuingDistributionPointBase {
|
|
111
160
|
/** Where to fetch this CRL. */
|
|
112
161
|
readonly distributionPoint?: DistributionPointName;
|
|
113
162
|
/** Limits the CRL to these revocation reasons. Absent means all reasons. */
|
|
@@ -122,7 +171,7 @@ interface IssuingDistributionPointBase {
|
|
|
122
171
|
readonly onlyContainsAttributeCerts?: boolean;
|
|
123
172
|
}
|
|
124
173
|
/** IDP scoped to end-entity (user) certificates only. Mutually exclusive with CA / attribute scopes. */
|
|
125
|
-
interface IssuingDistributionPointForUserCerts extends Omit<IssuingDistributionPointBase, "onlyContainsUserCerts"> {
|
|
174
|
+
export interface IssuingDistributionPointForUserCerts extends Omit<IssuingDistributionPointBase, "onlyContainsUserCerts"> {
|
|
126
175
|
/** This variant only covers end-entity certificates. */
|
|
127
176
|
readonly onlyContainsUserCerts: true;
|
|
128
177
|
/** Must be absent or false when the CRL is not CA-only. */
|
|
@@ -131,7 +180,7 @@ interface IssuingDistributionPointForUserCerts extends Omit<IssuingDistributionP
|
|
|
131
180
|
readonly onlyContainsAttributeCerts?: false;
|
|
132
181
|
}
|
|
133
182
|
/** IDP scoped to CA certificates only. Mutually exclusive with user / attribute scopes. */
|
|
134
|
-
interface IssuingDistributionPointForCaCerts extends Omit<IssuingDistributionPointBase, "onlyContainsCACerts"> {
|
|
183
|
+
export interface IssuingDistributionPointForCaCerts extends Omit<IssuingDistributionPointBase, "onlyContainsCACerts"> {
|
|
135
184
|
/** Must be absent or false when the CRL is not user-cert-only. */
|
|
136
185
|
readonly onlyContainsUserCerts?: false;
|
|
137
186
|
/** This variant only covers CA certificates. */
|
|
@@ -140,7 +189,7 @@ interface IssuingDistributionPointForCaCerts extends Omit<IssuingDistributionPoi
|
|
|
140
189
|
readonly onlyContainsAttributeCerts?: false;
|
|
141
190
|
}
|
|
142
191
|
/** IDP scoped to attribute certificates only. Mutually exclusive with user / CA scopes. */
|
|
143
|
-
interface IssuingDistributionPointForAttributeCerts extends Omit<IssuingDistributionPointBase, "onlyContainsAttributeCerts"> {
|
|
192
|
+
export interface IssuingDistributionPointForAttributeCerts extends Omit<IssuingDistributionPointBase, "onlyContainsAttributeCerts"> {
|
|
144
193
|
/** Must be absent or false when the CRL is not user-cert-only. */
|
|
145
194
|
readonly onlyContainsUserCerts?: false;
|
|
146
195
|
/** Must be absent or false when the CRL is not CA-only. */
|
|
@@ -153,14 +202,14 @@ interface IssuingDistributionPointForAttributeCerts extends Omit<IssuingDistribu
|
|
|
153
202
|
*
|
|
154
203
|
* The union enforces that at most one of the `onlyContains*` flags is true.
|
|
155
204
|
*/
|
|
156
|
-
type IssuingDistributionPoint = IssuingDistributionPointBase | IssuingDistributionPointForUserCerts | IssuingDistributionPointForCaCerts | IssuingDistributionPointForAttributeCerts;
|
|
205
|
+
export type IssuingDistributionPoint = IssuingDistributionPointBase | IssuingDistributionPointForUserCerts | IssuingDistributionPointForCaCerts | IssuingDistributionPointForAttributeCerts;
|
|
157
206
|
/**
|
|
158
207
|
* RFC 5280 §4.2.1.9 Basic Constraints.
|
|
159
208
|
*
|
|
160
209
|
* A certificate with `ca: true` may issue other certificates; `pathLength`
|
|
161
210
|
* limits how many additional CAs may appear below it in the chain.
|
|
162
211
|
*/
|
|
163
|
-
type BasicConstraints = {
|
|
212
|
+
export type BasicConstraints = {
|
|
164
213
|
/** End-entity certificate: not a CA. */
|
|
165
214
|
readonly ca: false;
|
|
166
215
|
/** Never present on end-entity certificates. */
|
|
@@ -172,14 +221,14 @@ type BasicConstraints = {
|
|
|
172
221
|
readonly pathLength?: number;
|
|
173
222
|
};
|
|
174
223
|
/** A single certificate policy: an OID plus optional qualifiers. */
|
|
175
|
-
interface PolicyInformation {
|
|
224
|
+
export interface PolicyInformation {
|
|
176
225
|
/** Dotted-decimal OID of the policy (e.g. `"2.23.140.1.2.1"` for DV). */
|
|
177
226
|
readonly policyIdentifier: string;
|
|
178
227
|
/** Optional CPS URIs or user notices attached to this policy. */
|
|
179
228
|
readonly policyQualifiers?: readonly PolicyQualifierInfo[];
|
|
180
229
|
}
|
|
181
230
|
/** RFC 5280 §4.2.1.4 — array of policy OIDs with optional qualifiers. */
|
|
182
|
-
type CertificatePolicies = readonly {
|
|
231
|
+
export type CertificatePolicies = readonly {
|
|
183
232
|
/** Dotted-decimal OID of the policy (e.g. `"2.23.140.1.2.1"` for DV). */
|
|
184
233
|
readonly policyIdentifier: string;
|
|
185
234
|
/** Optional CPS URIs or user notices attached to this policy. */
|
|
@@ -191,8 +240,13 @@ type CertificatePolicies = readonly {
|
|
|
191
240
|
readonly noticeRef?: {
|
|
192
241
|
readonly organization: string;
|
|
193
242
|
readonly noticeNumbers: readonly number[];
|
|
243
|
+
/** Present when `organization` exceeds 200 characters; the builder emits no such notice. */
|
|
244
|
+
readonly oversizedOrganization?: OversizedDisplayText;
|
|
194
245
|
};
|
|
195
246
|
readonly explicitText?: string;
|
|
247
|
+
readonly explicitTextType?: DisplayTextType;
|
|
248
|
+
/** Present when `explicitText` exceeds 200 characters; the builder emits no such notice. */
|
|
249
|
+
readonly oversizedExplicitText?: OversizedDisplayText;
|
|
196
250
|
} | {
|
|
197
251
|
readonly type: "oid";
|
|
198
252
|
readonly oid: string;
|
|
@@ -200,30 +254,49 @@ type CertificatePolicies = readonly {
|
|
|
200
254
|
})[];
|
|
201
255
|
}[];
|
|
202
256
|
/** CPS (Certification Practice Statement) URI policy qualifier. */
|
|
203
|
-
interface CpsPolicyQualifierInfo {
|
|
257
|
+
export interface CpsPolicyQualifierInfo {
|
|
204
258
|
/** Discriminant for the `'cps'` qualifier variant. */
|
|
205
259
|
readonly type: "cps";
|
|
206
260
|
/** URL of the Certification Practice Statement document. */
|
|
207
261
|
readonly uri: string;
|
|
208
262
|
}
|
|
209
263
|
/** Reference to a numbered notice within an organization's practice statement. */
|
|
210
|
-
interface PolicyNoticeReference {
|
|
264
|
+
export interface PolicyNoticeReference {
|
|
211
265
|
/** Organization name that published the notice. */
|
|
212
266
|
readonly organization: string;
|
|
213
267
|
/** One-based notice numbers within that organization's documentation. */
|
|
214
268
|
readonly noticeNumbers: readonly number[];
|
|
215
269
|
}
|
|
216
270
|
/** UserNotice policy qualifier — human-readable notice text and/or a notice reference. */
|
|
217
|
-
interface UserNoticePolicyQualifierInfo {
|
|
271
|
+
export interface UserNoticePolicyQualifierInfo {
|
|
218
272
|
/** Discriminant for the `'userNotice'` qualifier variant. */
|
|
219
273
|
readonly type: "userNotice";
|
|
220
274
|
/** Pointer to a numbered notice in an organization's practice statement. */
|
|
221
275
|
readonly noticeRef?: PolicyNoticeReference;
|
|
222
276
|
/** Free-form text to display to relying parties. */
|
|
223
277
|
readonly explicitText?: string;
|
|
278
|
+
/**
|
|
279
|
+
* ASN.1 string type carrying `explicitText`. Parsing reports the received
|
|
280
|
+
* type. The builder defaults to `'utf8String'`, accepts `'visibleString'`
|
|
281
|
+
* and `'bmpString'`, and rejects `'ia5String'` (RFC 6818 §3).
|
|
282
|
+
*/
|
|
283
|
+
readonly explicitTextType?: DisplayTextType;
|
|
284
|
+
}
|
|
285
|
+
/** The ASN.1 string types RFC 5280 §4.2.1.4 allows for a DisplayText. */
|
|
286
|
+
export type DisplayTextType = "utf8String" | "ia5String" | "visibleString" | "bmpString";
|
|
287
|
+
/**
|
|
288
|
+
* A user notice `explicitText` or `noticeRef` organization longer than the 200
|
|
289
|
+
* characters RFC 5280 §4.2.1.4 allows a DisplayText. Parsing keeps the text
|
|
290
|
+
* whole and reports its size here.
|
|
291
|
+
*/
|
|
292
|
+
export interface OversizedDisplayText {
|
|
293
|
+
/** Characters the certificate carries. */
|
|
294
|
+
readonly characters: number;
|
|
295
|
+
/** The RFC 5280 §4.2.1.4 upper bound, 200. */
|
|
296
|
+
readonly limit: number;
|
|
224
297
|
}
|
|
225
298
|
/** Opaque policy qualifier identified by a custom OID, carried as raw DER. */
|
|
226
|
-
interface CustomPolicyQualifierInfo {
|
|
299
|
+
export interface CustomPolicyQualifierInfo {
|
|
227
300
|
/** Discriminant for the custom-OID qualifier variant. */
|
|
228
301
|
readonly type: "oid";
|
|
229
302
|
/** Dotted-decimal OID of the qualifier. */
|
|
@@ -232,16 +305,16 @@ interface CustomPolicyQualifierInfo {
|
|
|
232
305
|
readonly qualifierDer: Uint8Array;
|
|
233
306
|
}
|
|
234
307
|
/** Discriminated union of all supported policy qualifier types. */
|
|
235
|
-
type PolicyQualifierInfo = CpsPolicyQualifierInfo | UserNoticePolicyQualifierInfo | CustomPolicyQualifierInfo;
|
|
308
|
+
export type PolicyQualifierInfo = CpsPolicyQualifierInfo | UserNoticePolicyQualifierInfo | CustomPolicyQualifierInfo;
|
|
236
309
|
/** Maps a policy OID in the issuer's domain to an equivalent OID in the subject's domain. */
|
|
237
|
-
interface PolicyMapping {
|
|
310
|
+
export interface PolicyMapping {
|
|
238
311
|
/** Policy OID as defined by the issuing CA. Must not be anyPolicy. */
|
|
239
312
|
readonly issuerDomainPolicy: string;
|
|
240
313
|
/** Equivalent policy OID in the subject CA's domain. Must not be anyPolicy. */
|
|
241
314
|
readonly subjectDomainPolicy: string;
|
|
242
315
|
}
|
|
243
316
|
/** RFC 5280 §4.2.1.5 — array of issuer-to-subject policy OID pairs. */
|
|
244
|
-
type PolicyMappings = readonly {
|
|
317
|
+
export type PolicyMappings = readonly {
|
|
245
318
|
/** Policy OID as defined by the issuing CA. Must not be anyPolicy. */
|
|
246
319
|
readonly issuerDomainPolicy: string;
|
|
247
320
|
/** Equivalent policy OID in the subject CA's domain. Must not be anyPolicy. */
|
|
@@ -253,7 +326,7 @@ type PolicyMappings = readonly {
|
|
|
253
326
|
* At least one field must be present. Values are certificate-count
|
|
254
327
|
* thresholds measured from the current certificate toward the end entity.
|
|
255
328
|
*/
|
|
256
|
-
interface PolicyConstraints {
|
|
329
|
+
export interface PolicyConstraints {
|
|
257
330
|
/** After this many certificates, an acceptable policy must be in the path. */
|
|
258
331
|
readonly requireExplicitPolicy?: number;
|
|
259
332
|
/** After this many certificates, policy mapping is no longer allowed. */
|
|
@@ -262,11 +335,12 @@ interface PolicyConstraints {
|
|
|
262
335
|
/**
|
|
263
336
|
* RFC 5280 §4.2.1.14 Inhibit anyPolicy.
|
|
264
337
|
*
|
|
265
|
-
* After `skipCerts` additional certificates in the path, the
|
|
266
|
-
* anyPolicy OID is no longer considered a match
|
|
338
|
+
* After `skipCerts` additional non-self-issued certificates in the path, the
|
|
339
|
+
* special anyPolicy OID is no longer considered a match, except when it
|
|
340
|
+
* appears in an intermediate self-issued CA certificate.
|
|
267
341
|
*/
|
|
268
|
-
interface InhibitAnyPolicy {
|
|
269
|
-
/** Number of additional certificates before anyPolicy stops being valid. */
|
|
342
|
+
export interface InhibitAnyPolicy {
|
|
343
|
+
/** Number of additional non-self-issued certificates before anyPolicy stops being valid. */
|
|
270
344
|
readonly skipCerts: number;
|
|
271
345
|
}
|
|
272
346
|
/**
|
|
@@ -277,7 +351,7 @@ interface InhibitAnyPolicy {
|
|
|
277
351
|
* extensions (SKI, AKI, basicConstraints defaults) are handled automatically
|
|
278
352
|
* by the builder.
|
|
279
353
|
*/
|
|
280
|
-
interface CertificateExtensionsInput {
|
|
354
|
+
export interface CertificateExtensionsInput {
|
|
281
355
|
/** Subject Alternative Names (dns, ip, email, uri, srv, directoryName). */
|
|
282
356
|
readonly subjectAltNames?: readonly SubjectAltName[];
|
|
283
357
|
/** Key Usage flags (digitalSignature, keyCertSign, etc.). */
|
|
@@ -296,15 +370,21 @@ interface CertificateExtensionsInput {
|
|
|
296
370
|
readonly policyConstraints?: PolicyConstraints;
|
|
297
371
|
/** Inhibit anyPolicy skip-certs threshold. */
|
|
298
372
|
readonly inhibitAnyPolicy?: InhibitAnyPolicy;
|
|
299
|
-
/** Authority Information Access — OCSP responder and CA issuer
|
|
300
|
-
readonly authorityInfoAccess?: readonly
|
|
373
|
+
/** Authority Information Access — OCSP responder and CA issuer locations. */
|
|
374
|
+
readonly authorityInfoAccess?: readonly AuthorityInformationAccessInput[];
|
|
301
375
|
/** CRL Distribution Points — where to check revocation status. */
|
|
302
376
|
readonly crlDistributionPoints?: readonly DistributionPoint[];
|
|
377
|
+
/**
|
|
378
|
+
* Emit No Revocation Available (RFC 9608 §2): the CA publishes no revocation
|
|
379
|
+
* information for this certificate. A certificate carrying it cannot be a CA
|
|
380
|
+
* and cannot point at a CRL or an OCSP responder (RFC 9608 §3).
|
|
381
|
+
*/
|
|
382
|
+
readonly noRevAvail?: boolean;
|
|
303
383
|
/** Arbitrary extensions not covered by the built-in fields. */
|
|
304
384
|
readonly customExtensions?: readonly CustomExtension[];
|
|
305
385
|
}
|
|
306
386
|
/** An extension not covered by the typed fields in {@linkcode CertificateExtensionsInput}. */
|
|
307
|
-
interface CustomExtension {
|
|
387
|
+
export interface CustomExtension {
|
|
308
388
|
/** Dotted-decimal OID of the extension. */
|
|
309
389
|
readonly oid: string;
|
|
310
390
|
/** Pre-encoded DER content for the extnValue OCTET STRING. */
|
|
@@ -317,7 +397,7 @@ interface CustomExtension {
|
|
|
317
397
|
* Distinct from {@linkcode SubjectAltName} because IP constraints carry
|
|
318
398
|
* address + mask bytes (8 for IPv4, 32 for IPv6) rather than bare addresses.
|
|
319
399
|
*/
|
|
320
|
-
type NameConstraintForm = {
|
|
400
|
+
export type NameConstraintForm = {
|
|
321
401
|
/** DNS domain constraint (dNSName [2]). */
|
|
322
402
|
readonly type: "dns";
|
|
323
403
|
/** Domain suffix, e.g. `".example.com"` or `"example.com"`. */
|
|
@@ -344,14 +424,22 @@ type NameConstraintForm = {
|
|
|
344
424
|
readonly type: "directoryName";
|
|
345
425
|
/** Hex-encoded DER of the Name SEQUENCE. */
|
|
346
426
|
readonly derHex: string;
|
|
427
|
+
} | {
|
|
428
|
+
/** SRVName constraint (otherName id-on-dnsSRV, RFC 4985 §4). */
|
|
429
|
+
readonly type: "srv";
|
|
430
|
+
/** `_Service.Name`, `_Service`, or `Name`, e.g. `"_mail.example.com"`. */
|
|
431
|
+
readonly value: string;
|
|
347
432
|
};
|
|
348
433
|
/**
|
|
349
434
|
* Name constraint forms parsed from DER but not supported for encoding or
|
|
350
435
|
* validation. Preserved for diagnostic round-tripping.
|
|
351
436
|
*/
|
|
352
|
-
type UnsupportedNameConstraintForm = {
|
|
353
|
-
/** otherName [0]
|
|
437
|
+
export type UnsupportedNameConstraintForm = {
|
|
438
|
+
/** otherName [0] of a type-id without defined constraint semantics. */
|
|
354
439
|
readonly type: "otherName";
|
|
440
|
+
/** Dotted-decimal type-id OID. */
|
|
441
|
+
readonly typeId: string;
|
|
442
|
+
/** DER of the single element inside `value [0] EXPLICIT`. */
|
|
355
443
|
readonly value: Uint8Array;
|
|
356
444
|
} | {
|
|
357
445
|
/** x400Address [3] — raw bytes. */
|
|
@@ -367,7 +455,7 @@ type UnsupportedNameConstraintForm = {
|
|
|
367
455
|
readonly value: string;
|
|
368
456
|
};
|
|
369
457
|
/** Union of supported and unsupported name constraint forms as produced by parsing. */
|
|
370
|
-
type ParsedNameConstraintForm = {
|
|
458
|
+
export type ParsedNameConstraintForm = {
|
|
371
459
|
readonly type: "dns";
|
|
372
460
|
readonly value: string;
|
|
373
461
|
} | {
|
|
@@ -383,8 +471,12 @@ type ParsedNameConstraintForm = {
|
|
|
383
471
|
} | {
|
|
384
472
|
readonly type: "directoryName";
|
|
385
473
|
readonly derHex: string;
|
|
474
|
+
} | {
|
|
475
|
+
readonly type: "srv";
|
|
476
|
+
readonly value: string;
|
|
386
477
|
} | {
|
|
387
478
|
readonly type: "otherName";
|
|
479
|
+
readonly typeId: string;
|
|
388
480
|
readonly value: Uint8Array;
|
|
389
481
|
} | {
|
|
390
482
|
readonly type: "x400Address";
|
|
@@ -397,7 +489,7 @@ type ParsedNameConstraintForm = {
|
|
|
397
489
|
readonly value: string;
|
|
398
490
|
};
|
|
399
491
|
/** A single subtree entry in a Name Constraints permitted/excluded list. */
|
|
400
|
-
interface GeneralSubtree<TForm extends ParsedNameConstraintForm = {
|
|
492
|
+
export interface GeneralSubtree<TForm extends ParsedNameConstraintForm = {
|
|
401
493
|
readonly type: "dns";
|
|
402
494
|
readonly value: string;
|
|
403
495
|
} | {
|
|
@@ -413,6 +505,9 @@ interface GeneralSubtree<TForm extends ParsedNameConstraintForm = {
|
|
|
413
505
|
} | {
|
|
414
506
|
readonly type: "directoryName";
|
|
415
507
|
readonly derHex: string;
|
|
508
|
+
} | {
|
|
509
|
+
readonly type: "srv";
|
|
510
|
+
readonly value: string;
|
|
416
511
|
}> {
|
|
417
512
|
/** The name form that defines this constraint boundary. */
|
|
418
513
|
readonly base: TForm;
|
|
@@ -423,7 +518,7 @@ interface GeneralSubtree<TForm extends ParsedNameConstraintForm = {
|
|
|
423
518
|
* A CA certificate may restrict the namespace of all subject names in
|
|
424
519
|
* subsequent certificates in the path.
|
|
425
520
|
*/
|
|
426
|
-
interface NameConstraints<TForm extends ParsedNameConstraintForm = {
|
|
521
|
+
export interface NameConstraints<TForm extends ParsedNameConstraintForm = {
|
|
427
522
|
readonly type: "dns";
|
|
428
523
|
readonly value: string;
|
|
429
524
|
} | {
|
|
@@ -439,6 +534,9 @@ interface NameConstraints<TForm extends ParsedNameConstraintForm = {
|
|
|
439
534
|
} | {
|
|
440
535
|
readonly type: "directoryName";
|
|
441
536
|
readonly derHex: string;
|
|
537
|
+
} | {
|
|
538
|
+
readonly type: "srv";
|
|
539
|
+
readonly value: string;
|
|
442
540
|
}> {
|
|
443
541
|
/** Names that MUST fall within these subtrees to be valid. */
|
|
444
542
|
readonly permittedSubtrees?: readonly GeneralSubtree<TForm>[];
|
|
@@ -446,55 +544,76 @@ interface NameConstraints<TForm extends ParsedNameConstraintForm = {
|
|
|
446
544
|
readonly excludedSubtrees?: readonly GeneralSubtree<TForm>[];
|
|
447
545
|
}
|
|
448
546
|
/** Well-known AIA access methods: OCSP responder or CA issuer certificate. */
|
|
449
|
-
type KnownAuthorityInfoAccessMethod = "ocsp" | "caIssuers";
|
|
547
|
+
export type KnownAuthorityInfoAccessMethod = "ocsp" | "caIssuers";
|
|
450
548
|
/** AIA access method identified by a custom OID not in the well-known set. */
|
|
451
|
-
interface CustomAuthorityInfoAccessMethod {
|
|
549
|
+
export interface CustomAuthorityInfoAccessMethod {
|
|
452
550
|
/** Discriminant for the custom-OID access method variant. */
|
|
453
551
|
readonly type: "oid";
|
|
454
552
|
/** Dotted-decimal OID of the access method. */
|
|
455
553
|
readonly value: string;
|
|
456
554
|
}
|
|
457
555
|
/** AIA access method — either a well-known string or a custom OID. */
|
|
458
|
-
type AuthorityInfoAccessMethod = KnownAuthorityInfoAccessMethod | CustomAuthorityInfoAccessMethod;
|
|
556
|
+
export type AuthorityInfoAccessMethod = KnownAuthorityInfoAccessMethod | CustomAuthorityInfoAccessMethod;
|
|
459
557
|
/** A single entry in the Authority Information Access extension (RFC 5280 §4.2.2.1). */
|
|
460
|
-
interface AuthorityInformationAccess {
|
|
558
|
+
export interface AuthorityInformationAccess {
|
|
461
559
|
/** Access method (`'ocsp'`, `'caIssuers'`, or custom OID). */
|
|
462
560
|
readonly method: "ocsp" | "caIssuers" | {
|
|
463
561
|
readonly type: "oid";
|
|
464
562
|
readonly value: string;
|
|
465
563
|
};
|
|
466
|
-
/**
|
|
467
|
-
readonly
|
|
564
|
+
/** accessLocation GeneralName where the resource is available (usually a URI). */
|
|
565
|
+
readonly location: GeneralName;
|
|
468
566
|
}
|
|
567
|
+
/**
|
|
568
|
+
* Builder input for one Authority Information Access entry.
|
|
569
|
+
*
|
|
570
|
+
* Parsed AIA locations stay broad ({@linkcode AuthorityInformationAccess}), but
|
|
571
|
+
* an `'ocsp'` entry must supply a URI location, since RFC 6960 §3.1 defines the
|
|
572
|
+
* `id-ad-ocsp` location as a URI; `directoryName` is defined for `caIssuers`.
|
|
573
|
+
*/
|
|
574
|
+
export type AuthorityInformationAccessInput = {
|
|
575
|
+
/** OCSP responder access method. */
|
|
576
|
+
readonly method: "ocsp";
|
|
577
|
+
/** OCSP responder URI (RFC 6960 §3.1). */
|
|
578
|
+
readonly location: {
|
|
579
|
+
readonly type: "uri";
|
|
580
|
+
readonly value: string;
|
|
581
|
+
};
|
|
582
|
+
} | {
|
|
583
|
+
/** caIssuers or a custom access method. */
|
|
584
|
+
readonly method: "caIssuers" | CustomAuthorityInfoAccessMethod;
|
|
585
|
+
/** Any accessLocation GeneralName. */
|
|
586
|
+
readonly location: GeneralName;
|
|
587
|
+
};
|
|
469
588
|
/** Well-known Extended Key Usage purpose strings (RFC 5280 §4.2.1.12). */
|
|
470
|
-
type KnownExtendedKeyUsage = "serverAuth" | "clientAuth" | "codeSigning" | "emailProtection" | "timeStamping" | "ocspSigning";
|
|
589
|
+
export type KnownExtendedKeyUsage = "serverAuth" | "clientAuth" | "codeSigning" | "emailProtection" | "timeStamping" | "ocspSigning";
|
|
471
590
|
/** Extended Key Usage purpose identified by a custom OID. */
|
|
472
|
-
interface CustomExtendedKeyUsage {
|
|
591
|
+
export interface CustomExtendedKeyUsage {
|
|
473
592
|
/** Discriminant for the custom-OID EKU variant. */
|
|
474
593
|
readonly type: "oid";
|
|
475
594
|
/** Dotted-decimal OID of the usage purpose. */
|
|
476
595
|
readonly value: string;
|
|
477
596
|
}
|
|
478
597
|
/** Extended Key Usage — either a well-known purpose string or a custom OID. */
|
|
479
|
-
type ExtendedKeyUsage = "serverAuth" | "clientAuth" | "codeSigning" | "emailProtection" | "timeStamping" | "ocspSigning" | {
|
|
598
|
+
export type ExtendedKeyUsage = "serverAuth" | "clientAuth" | "codeSigning" | "emailProtection" | "timeStamping" | "ocspSigning" | {
|
|
480
599
|
readonly type: "oid";
|
|
481
600
|
readonly value: string;
|
|
482
601
|
};
|
|
483
602
|
/**
|
|
484
603
|
* Build the v3 extensions block for a certificate.
|
|
485
604
|
*
|
|
486
|
-
* Automatically adds SKI, AKI (when
|
|
605
|
+
* Automatically adds SKI, AKI (when a key identifier is given), and
|
|
487
606
|
* basicConstraints (defaults to `{ ca: false }`). Additional extensions
|
|
488
607
|
* come from the caller's {@linkcode CertificateExtensionsInput}.
|
|
489
608
|
*
|
|
490
609
|
* @param subjectPublicKeyInfo DER-encoded SPKI of the subject.
|
|
491
|
-
* @param
|
|
610
|
+
* @param authorityKeyIdentifier Key identifier for the AKI, or `undefined` to omit it.
|
|
492
611
|
* @param input Optional extension configuration.
|
|
493
|
-
* @param subjectIsEmpty Whether the certificate subject DN is empty. When `true`,
|
|
494
|
-
* subjectAltName extension is marked critical per RFC 5280 §4.2.1.6.
|
|
612
|
+
* @param subjectIsEmpty Whether the certificate subject DN is empty. When `true`, a
|
|
613
|
+
* subjectAltName extension is required and marked critical per RFC 5280 §4.2.1.6.
|
|
495
614
|
* @returns Array of DER-encoded Extension SEQUENCEs.
|
|
496
615
|
*/
|
|
497
|
-
declare function buildCertificateExtensions(subjectPublicKeyInfo: Uint8Array,
|
|
616
|
+
export declare function buildCertificateExtensions(subjectPublicKeyInfo: Uint8Array, authorityKeyIdentifier: Uint8Array | undefined, input: CertificateExtensionsInput | undefined, subjectIsEmpty?: boolean): Uint8Array[];
|
|
498
617
|
/**
|
|
499
618
|
* Build the extensions for a CSR's extensionRequest attribute.
|
|
500
619
|
*
|
|
@@ -503,7 +622,7 @@ declare function buildCertificateExtensions(subjectPublicKeyInfo: Uint8Array, is
|
|
|
503
622
|
* @param input Optional extension configuration.
|
|
504
623
|
* @returns Array of DER-encoded Extension SEQUENCEs.
|
|
505
624
|
*/
|
|
506
|
-
declare function buildRequestedExtensions(input: CertificateExtensionsInput | undefined): Uint8Array[];
|
|
625
|
+
export declare function buildRequestedExtensions(input: CertificateExtensionsInput | undefined): Uint8Array[];
|
|
507
626
|
/**
|
|
508
627
|
* Encode a single X.509 Extension SEQUENCE (OID + optional critical BOOLEAN + OCTET STRING).
|
|
509
628
|
*
|
|
@@ -511,98 +630,104 @@ declare function buildRequestedExtensions(input: CertificateExtensionsInput | un
|
|
|
511
630
|
* @param extnValue DER-encoded extension payload.
|
|
512
631
|
* @param critical Whether to mark the extension as critical. Default `false`.
|
|
513
632
|
*/
|
|
514
|
-
declare function encodeExtension(oid: string, extnValue: Uint8Array, critical?: boolean): Uint8Array;
|
|
633
|
+
export declare function encodeExtension(oid: string, extnValue: Uint8Array, critical?: boolean): Uint8Array;
|
|
515
634
|
/**
|
|
516
635
|
* DER-encode a {@linkcode BasicConstraints} value.
|
|
517
636
|
*
|
|
518
637
|
* @param input CA flag and optional pathLength.
|
|
519
638
|
* @returns DER SEQUENCE suitable for wrapping in an Extension OCTET STRING.
|
|
520
639
|
*/
|
|
521
|
-
declare function encodeBasicConstraints(input: BasicConstraints): Uint8Array;
|
|
640
|
+
export declare function encodeBasicConstraints(input: BasicConstraints): Uint8Array;
|
|
522
641
|
/**
|
|
523
642
|
* DER-encode a Key Usage BIT STRING from an array of {@linkcode KeyUsage} flags.
|
|
524
643
|
*
|
|
525
644
|
* @param usages Flags to set in the bit string.
|
|
526
645
|
*/
|
|
527
|
-
declare function encodeKeyUsage(usages: readonly KeyUsage[]): Uint8Array;
|
|
646
|
+
export declare function encodeKeyUsage(usages: readonly KeyUsage[]): Uint8Array;
|
|
528
647
|
/**
|
|
529
648
|
* DER-encode a single {@linkcode SubjectAltName} GeneralName element.
|
|
530
649
|
*
|
|
531
650
|
* @param value The SAN entry to encode.
|
|
532
651
|
*/
|
|
533
|
-
declare function encodeSubjectAltName(value: SubjectAltName): Uint8Array;
|
|
652
|
+
export declare function encodeSubjectAltName(value: SubjectAltName): Uint8Array;
|
|
534
653
|
/**
|
|
535
654
|
* DER-encode an Extended Key Usage SEQUENCE OF OIDs.
|
|
536
655
|
*
|
|
537
656
|
* @param usages EKU purposes to encode.
|
|
538
657
|
*/
|
|
539
|
-
declare function encodeExtendedKeyUsage(usages: readonly ExtendedKeyUsage[]): Uint8Array;
|
|
658
|
+
export declare function encodeExtendedKeyUsage(usages: readonly ExtendedKeyUsage[]): Uint8Array;
|
|
540
659
|
/**
|
|
541
660
|
* DER-encode an Authority Information Access SEQUENCE.
|
|
542
661
|
*
|
|
543
662
|
* @param entries AIA entries (OCSP, caIssuers, or custom) to encode.
|
|
544
663
|
*/
|
|
545
|
-
declare function encodeAuthorityInfoAccess(entries: readonly
|
|
664
|
+
export declare function encodeAuthorityInfoAccess(entries: readonly AuthorityInformationAccessInput[]): Uint8Array;
|
|
546
665
|
/**
|
|
547
666
|
* DER-encode a CRL Distribution Points SEQUENCE.
|
|
548
667
|
*
|
|
549
668
|
* @param points Distribution points to encode.
|
|
550
669
|
*/
|
|
551
|
-
declare function encodeCrlDistributionPoints(points: readonly DistributionPoint[]): Uint8Array;
|
|
670
|
+
export declare function encodeCrlDistributionPoints(points: readonly DistributionPoint[]): Uint8Array;
|
|
552
671
|
/**
|
|
553
672
|
* DER-encode a Name Constraints extension value.
|
|
554
673
|
*
|
|
555
674
|
* @param constraints Permitted and/or excluded subtrees.
|
|
556
675
|
*/
|
|
557
|
-
declare function encodeNameConstraints(constraints: NameConstraints): Uint8Array;
|
|
676
|
+
export declare function encodeNameConstraints(constraints: NameConstraints): Uint8Array;
|
|
558
677
|
/**
|
|
559
678
|
* DER-encode a Certificate Policies extension value.
|
|
560
679
|
*
|
|
561
680
|
* @param policies Non-empty array of policy information entries.
|
|
562
681
|
*/
|
|
563
|
-
declare function encodeCertificatePolicies(policies: CertificatePolicies): Uint8Array;
|
|
682
|
+
export declare function encodeCertificatePolicies(policies: CertificatePolicies): Uint8Array;
|
|
564
683
|
/**
|
|
565
684
|
* DER-encode a Policy Mappings extension value.
|
|
566
685
|
*
|
|
567
686
|
* @param mappings Non-empty array of issuer-to-subject policy pairs. Neither OID may be anyPolicy.
|
|
568
687
|
*/
|
|
569
|
-
declare function encodePolicyMappings(mappings: PolicyMappings): Uint8Array;
|
|
688
|
+
export declare function encodePolicyMappings(mappings: PolicyMappings): Uint8Array;
|
|
570
689
|
/**
|
|
571
690
|
* DER-encode a Policy Constraints extension value.
|
|
572
691
|
*
|
|
573
692
|
* @param constraints At least one of `requireExplicitPolicy` or `inhibitPolicyMapping` must be set.
|
|
574
693
|
*/
|
|
575
|
-
declare function encodePolicyConstraints(constraints: PolicyConstraints): Uint8Array;
|
|
694
|
+
export declare function encodePolicyConstraints(constraints: PolicyConstraints): Uint8Array;
|
|
576
695
|
/**
|
|
577
696
|
* DER-encode an Inhibit anyPolicy extension value (single INTEGER).
|
|
578
697
|
*
|
|
579
698
|
* @param input The skipCerts threshold.
|
|
580
699
|
*/
|
|
581
|
-
declare function encodeInhibitAnyPolicy(input: InhibitAnyPolicy): Uint8Array;
|
|
700
|
+
export declare function encodeInhibitAnyPolicy(input: InhibitAnyPolicy): Uint8Array;
|
|
582
701
|
/**
|
|
583
702
|
* Resolve an {@linkcode ExtendedKeyUsage} to its dotted-decimal OID.
|
|
584
703
|
*
|
|
585
704
|
* @param usage Well-known string or custom OID object.
|
|
586
705
|
*/
|
|
587
|
-
declare function getExtendedKeyUsageOid(usage: ExtendedKeyUsage): string;
|
|
706
|
+
export declare function getExtendedKeyUsageOid(usage: ExtendedKeyUsage): string;
|
|
588
707
|
/**
|
|
589
708
|
* Map a dotted-decimal OID to an {@linkcode ExtendedKeyUsage} value.
|
|
590
709
|
*
|
|
591
710
|
* Returns a well-known string for recognized OIDs, or `{ type: 'oid', value }` otherwise.
|
|
592
711
|
*/
|
|
593
|
-
declare function parseExtendedKeyUsageOid(oid: string): ExtendedKeyUsage;
|
|
712
|
+
export declare function parseExtendedKeyUsageOid(oid: string): ExtendedKeyUsage;
|
|
594
713
|
/**
|
|
595
714
|
* Resolve an {@linkcode AuthorityInfoAccessMethod} to its dotted-decimal OID.
|
|
596
715
|
*
|
|
597
716
|
* @param method Well-known string or custom OID object.
|
|
598
717
|
*/
|
|
599
|
-
declare function getAuthorityInfoAccessMethodOid(method: AuthorityInfoAccessMethod): string;
|
|
718
|
+
export declare function getAuthorityInfoAccessMethodOid(method: AuthorityInfoAccessMethod): string;
|
|
600
719
|
/**
|
|
601
720
|
* Map a dotted-decimal OID to an {@linkcode AuthorityInfoAccessMethod} value.
|
|
602
721
|
*
|
|
603
722
|
* Returns `'ocsp'` or `'caIssuers'` for recognized OIDs, or `{ type: 'oid', value }` otherwise.
|
|
604
723
|
*/
|
|
605
|
-
declare function parseAuthorityInfoAccessMethodOid(oid: string): AuthorityInfoAccessMethod;
|
|
606
|
-
|
|
607
|
-
|
|
724
|
+
export declare function parseAuthorityInfoAccessMethodOid(oid: string): AuthorityInfoAccessMethod;
|
|
725
|
+
/**
|
|
726
|
+
* Computes a key identifier from a DER `SubjectPublicKeyInfo` using method (1)
|
|
727
|
+
* of RFC 5280 §4.2.1.2: "the 160-bit SHA-1 hash of the value of the BIT STRING
|
|
728
|
+
* subjectPublicKey (excluding the tag, length, and number of unused bits)".
|
|
729
|
+
* A parsed certificate carries the input as `subjectPublicKeyInfoDer`.
|
|
730
|
+
*/
|
|
731
|
+
export declare function buildSubjectKeyIdentifier(subjectPublicKeyInfo: Uint8Array): Uint8Array;
|
|
732
|
+
export { type ExtensionEncoderErrorCode, allOnesMaskForIpAddress, decodeIpAddress, normalizeIpAddress, parseIpAddressToBytes };
|
|
608
733
|
//# sourceMappingURL=extensions.d.ts.map
|