micro509 0.17.1 → 0.19.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 +165 -6
- package/dist/crypto/crypto.d.ts +12 -4
- package/dist/crypto/crypto.js +30 -17
- package/dist/crypto/crypto.js.map +1 -1
- package/dist/crypto.d.ts +8 -2
- package/dist/der/der.d.ts +14 -4
- package/dist/der/der.js +19 -19
- package/dist/der/der.js.map +1 -1
- package/dist/der.d.ts +26 -2
- package/dist/der.js +4 -4
- package/dist/index.d.ts +84 -16
- package/dist/index.js +19 -19
- package/dist/internal/asn1/asn1.d.ts +1 -2
- package/dist/internal/asn1/asn1.js +10 -2
- package/dist/internal/asn1/asn1.js.map +1 -1
- package/dist/internal/asn1/ber.js.map +1 -1
- package/dist/internal/asn1/decode-refusal.js.map +1 -1
- package/dist/internal/asn1/der.d.ts +1 -2
- package/dist/internal/asn1/der.js.map +1 -1
- package/dist/internal/asn1/oids.js +71 -353
- package/dist/internal/asn1/oids.js.map +1 -1
- package/dist/internal/asn1/oids.json.js +357 -0
- package/dist/internal/asn1/oids.json.js.map +1 -0
- package/dist/internal/crypto/algorithm-names.js +1 -1
- package/dist/internal/crypto/algorithm-names.js.map +1 -1
- package/dist/internal/crypto/ecdsa.js.map +1 -1
- package/dist/internal/crypto/hash.js.map +1 -1
- package/dist/internal/crypto/pbes2.d.ts +1 -2
- package/dist/internal/crypto/pbes2.js +70 -70
- package/dist/internal/crypto/pbes2.js.map +1 -1
- package/dist/internal/crypto/prime-ec.js +37 -0
- package/dist/internal/crypto/prime-ec.js.map +1 -0
- package/dist/internal/crypto/rsa-pss.js +50 -50
- package/dist/internal/crypto/rsa-pss.js.map +1 -1
- package/dist/internal/crypto/sig-verify.d.ts +41 -2
- package/dist/internal/crypto/sig-verify.js +125 -38
- package/dist/internal/crypto/sig-verify.js.map +1 -1
- package/dist/internal/crypto/signing.d.ts +1 -2
- package/dist/internal/crypto/signing.js +26 -26
- package/dist/internal/crypto/signing.js.map +1 -1
- package/dist/internal/jose/base64url.js.map +1 -1
- package/dist/internal/jose/json-data.js +108 -0
- package/dist/internal/jose/json-data.js.map +1 -0
- package/dist/internal/jose/strict-json.d.ts +1 -2
- package/dist/internal/jose/strict-json.js.map +1 -1
- package/dist/internal/shared/base64.js.map +1 -1
- package/dist/internal/shared/dn.d.ts +1 -2
- package/dist/internal/shared/dn.js +1 -1
- package/dist/internal/shared/dn.js.map +1 -1
- package/dist/internal/shared/idna.js.map +1 -1
- package/dist/internal/shared/ip.d.ts +1 -2
- package/dist/internal/shared/ip.js.map +1 -1
- package/dist/internal/shared/mailbox.js.map +1 -1
- package/dist/internal/shared/punycode.js.map +1 -1
- package/dist/internal/shared/uri-host.js.map +1 -1
- package/dist/internal/verify/name-constraints-engine.js +64 -64
- package/dist/internal/verify/name-constraints-engine.js.map +1 -1
- package/dist/internal/verify/policy-engine.js +1 -1
- package/dist/internal/verify/policy-engine.js.map +1 -1
- package/dist/internal/verify/spki-distrust.js.map +1 -1
- package/dist/internal/verify/verify-path.d.ts +1 -2
- package/dist/internal/verify/verify-path.js +234 -128
- package/dist/internal/verify/verify-path.js.map +1 -1
- package/dist/internal/x509/directory-name.js +10 -10
- package/dist/internal/x509/directory-name.js.map +1 -1
- package/dist/internal/x509/extension-bits.js.map +1 -1
- package/dist/internal/x509/extension-errors.d.ts +1 -2
- package/dist/internal/x509/extension-errors.js.map +1 -1
- package/dist/internal/x509/extension-registry.js +18 -18
- package/dist/internal/x509/extension-registry.js.map +1 -1
- package/dist/internal/x509/general-name-profile.js +9 -9
- package/dist/internal/x509/general-name-profile.js.map +1 -1
- package/dist/internal/x509/general-name.js +32 -32
- package/dist/internal/x509/general-name.js.map +1 -1
- package/dist/internal/x509/name-fields.js +1 -1
- package/dist/internal/x509/name-fields.js.map +1 -1
- package/dist/internal/x509/or-address.js.map +1 -1
- package/dist/jose/base64url.d.ts +4 -0
- package/dist/jose/base64url.js +14 -0
- package/dist/jose/base64url.js.map +1 -0
- package/dist/jose/errors.d.ts +9 -3
- package/dist/jose/errors.js.map +1 -1
- package/dist/jose/jwe.d.ts +64 -0
- package/dist/jose/jwe.js +188 -0
- package/dist/jose/jwe.js.map +1 -0
- package/dist/jose/jwks.d.ts +38 -10
- package/dist/jose/jwks.js +156 -96
- package/dist/jose/jwks.js.map +1 -1
- package/dist/jose/jws.d.ts +8 -6
- package/dist/jose/jws.js +216 -170
- package/dist/jose/jws.js.map +1 -1
- package/dist/jose/jwt.d.ts +8 -2
- package/dist/jose/jwt.js +98 -98
- package/dist/jose/jwt.js.map +1 -1
- package/dist/jose/remote-jwks.d.ts +1 -2
- package/dist/jose/remote-jwks.js +106 -108
- package/dist/jose/remote-jwks.js.map +1 -1
- package/dist/jose.d.ts +15 -4
- package/dist/jose.js +7 -5
- package/dist/kdf/argon2-arithmetic.js.map +1 -1
- package/dist/kdf/argon2-core.js.map +1 -1
- package/dist/kdf/argon2-memory.js.map +1 -1
- package/dist/kdf/argon2-portable.js.map +1 -1
- package/dist/kdf/argon2.d.ts +7 -2
- package/dist/kdf/argon2.js.map +1 -1
- package/dist/kdf.d.ts +6 -0
- package/dist/keys/keys.d.ts +31 -6
- package/dist/keys/keys.js +315 -233
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys.d.ts +11 -2
- package/dist/keys.js +2 -2
- package/dist/pem/pem.d.ts +1 -2
- package/dist/pem/pem.js +40 -25
- package/dist/pem/pem.js.map +1 -1
- package/dist/pem.d.ts +6 -0
- package/dist/pkcs/pfx.d.ts +2 -3
- package/dist/pkcs/pfx.js +142 -142
- package/dist/pkcs/pfx.js.map +1 -1
- package/dist/pkcs/pkcs12-mac.d.ts +1 -2
- package/dist/pkcs/pkcs12-mac.js +122 -122
- package/dist/pkcs/pkcs12-mac.js.map +1 -1
- package/dist/pkcs/pkcs7.d.ts +24 -3
- package/dist/pkcs/pkcs7.js +294 -256
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +10 -1
- package/dist/pkcs.js +4 -4
- package/dist/result/result.d.ts +1 -2
- package/dist/result/result.js.map +1 -1
- package/dist/result.d.ts +6 -0
- package/dist/revocation/chain.d.ts +69 -16
- package/dist/revocation/chain.js +431 -303
- package/dist/revocation/chain.js.map +1 -1
- package/dist/revocation/crl.d.ts +67 -14
- package/dist/revocation/crl.js +656 -366
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +78 -24
- package/dist/revocation/ocsp.js +622 -436
- package/dist/revocation/ocsp.js.map +1 -1
- package/dist/revocation/revocation.d.ts +68 -14
- package/dist/revocation/revocation.js +195 -74
- package/dist/revocation/revocation.js.map +1 -1
- package/dist/revocation.d.ts +14 -5
- package/dist/revocation.js +4 -4
- package/dist/ssh/ssh.d.ts +2 -3
- package/dist/ssh/ssh.js +165 -170
- package/dist/ssh/ssh.js.map +1 -1
- package/dist/ssh/wire.d.ts +1 -2
- package/dist/ssh/wire.js +10 -10
- package/dist/ssh/wire.js.map +1 -1
- package/dist/ssh.d.ts +8 -0
- package/dist/verify/identity.d.ts +3 -4
- package/dist/verify/identity.js +33 -33
- package/dist/verify/identity.js.map +1 -1
- package/dist/verify/name-constraints.d.ts +9 -2
- package/dist/verify/policy.d.ts +9 -2
- package/dist/verify/verify.d.ts +85 -34
- package/dist/verify/verify.js +276 -226
- package/dist/verify/verify.js.map +1 -1
- package/dist/verify.d.ts +12 -2
- package/dist/x509/certificate.d.ts +4 -5
- package/dist/x509/certificate.js +40 -40
- package/dist/x509/certificate.js.map +1 -1
- package/dist/x509/csr.d.ts +3 -4
- package/dist/x509/csr.js +15 -15
- package/dist/x509/csr.js.map +1 -1
- package/dist/x509/extensions.d.ts +1 -2
- package/dist/x509/extensions.js +165 -165
- package/dist/x509/extensions.js.map +1 -1
- package/dist/x509/fingerprint.d.ts +1 -2
- package/dist/x509/fingerprint.js.map +1 -1
- package/dist/x509/name-text.d.ts +1 -2
- package/dist/x509/name-text.js.map +1 -1
- package/dist/x509/name.d.ts +1 -2
- package/dist/x509/name.js +15 -15
- package/dist/x509/name.js.map +1 -1
- package/dist/x509/parse.d.ts +9 -6
- package/dist/x509/parse.js +394 -394
- package/dist/x509/parse.js.map +1 -1
- package/dist/x509.d.ts +17 -4
- package/dist/x509.js +8 -8
- package/package.json +32 -33
- package/dist/internal/asn1/oids2.js +0 -75
- package/dist/internal/asn1/oids2.js.map +0 -1
package/dist/x509/extensions.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { rethrowDecodeRefusal as
|
|
3
|
-
import { bmpString as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { typedOtherName as
|
|
13
|
-
import { checkEdiPartyName as
|
|
14
|
-
import { GENERAL_NAME_WIRE_TAGS as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
1
|
+
import { canonicalizeOid as e, checkStrictDer as t, childrenOf as n, decodeObjectIdentifier as r, hexToBytes as i, toHex as a } from "../internal/asn1/asn1.js";
|
|
2
|
+
import { rethrowDecodeRefusal as o } from "../internal/asn1/decode-refusal.js";
|
|
3
|
+
import { bmpString as s, bool as c, concatBytes as l, explicitContext as u, hasLoneSurrogate as d, ia5Bytes as f, ia5String as p, implicitConstructedContext as m, implicitPrimitiveContext as h, integerFromNumber as g, objectIdentifier as _, octetString as v, readElement as y, readRootElement as b, readSequenceChildren as x, sequence as S, tlv as C, utf8String as w, visibleString as T } from "../internal/asn1/der.js";
|
|
4
|
+
import { OIDS as E } from "../internal/asn1/oids.js";
|
|
5
|
+
import { sha1 as ee } from "../internal/crypto/hash.js";
|
|
6
|
+
import { domainToAscii as te } from "../internal/shared/idna.js";
|
|
7
|
+
import { allOnesMaskForIpAddress as D, decodeIpAddress as O, normalizeIpAddress as k, parseIpAddressToBytes as A } from "../internal/shared/ip.js";
|
|
8
|
+
import { isMailboxDomain as j, isSmtpUtf8LocalPart as M } from "../internal/shared/mailbox.js";
|
|
9
|
+
import { encodeDistributionPointReasonFlagsContent as N, encodeKeyUsageExtension as P } from "../internal/x509/extension-bits.js";
|
|
10
|
+
import { throwExtensionEncoderError as F } from "../internal/x509/extension-errors.js";
|
|
11
|
+
import { AUTHORITY_INFO_ACCESS_EXTENSION_DEFINITION as I, AUTHORITY_KEY_IDENTIFIER_EXTENSION_DEFINITION as L, BASIC_CONSTRAINTS_EXTENSION_DEFINITION as R, CERTIFICATE_POLICIES_EXTENSION_DEFINITION as z, CRL_DISTRIBUTION_POINTS_EXTENSION_DEFINITION as B, EXTENDED_KEY_USAGE_EXTENSION_DEFINITION as V, INHIBIT_ANY_POLICY_EXTENSION_DEFINITION as H, KEY_USAGE_EXTENSION_DEFINITION as U, NAME_CONSTRAINTS_EXTENSION_DEFINITION as W, NO_REV_AVAIL_EXTENSION_DEFINITION as G, POLICY_CONSTRAINTS_EXTENSION_DEFINITION as K, POLICY_MAPPINGS_EXTENSION_DEFINITION as ne, SUBJECT_ALT_NAME_EXTENSION_DEFINITION as q, SUBJECT_KEY_IDENTIFIER_EXTENSION_DEFINITION as J, getExtensionDefinition as Y } from "../internal/x509/extension-registry.js";
|
|
12
|
+
import { typedOtherName as X } from "../internal/x509/general-name.js";
|
|
13
|
+
import { checkEdiPartyName as Z, checkOrAddress as re, normalizeLabelSeparators as ie, parsePresentedSrvName as ae, parseSrvNameRestriction as oe, parseUriNameConstraint as se } from "../internal/x509/general-name-profile.js";
|
|
14
|
+
import { GENERAL_NAME_WIRE_TAGS as Q } from "../internal/x509/general-name-tags.js";
|
|
15
|
+
import { DECODE_REFUSAL_CODES as ce, isResultError as le } from "../result/result.js";
|
|
16
|
+
import { encodeRelativeDistinguishedName as ue } from "./name.js";
|
|
17
17
|
// src/x509/extensions.ts
|
|
18
18
|
/**
|
|
19
19
|
* Typed certificate and CSR extension model plus ASN.1 encoder helpers.
|
|
@@ -25,15 +25,15 @@ import { AUTHORITY_INFO_ACCESS_EXTENSION_DEFINITION as W, AUTHORITY_KEY_IDENTIFI
|
|
|
25
25
|
*/
|
|
26
26
|
/** Map from well-known EKU names to their dotted-decimal OIDs. */
|
|
27
27
|
const de = {
|
|
28
|
-
serverAuth:
|
|
29
|
-
clientAuth:
|
|
30
|
-
codeSigning:
|
|
31
|
-
emailProtection:
|
|
32
|
-
timeStamping:
|
|
33
|
-
ocspSigning:
|
|
28
|
+
serverAuth: E.serverAuth,
|
|
29
|
+
clientAuth: E.clientAuth,
|
|
30
|
+
codeSigning: E.codeSigning,
|
|
31
|
+
emailProtection: E.emailProtection,
|
|
32
|
+
timeStamping: E.timeStamping,
|
|
33
|
+
ocspSigning: E.ocspSigning
|
|
34
34
|
}, fe = {
|
|
35
|
-
ocsp:
|
|
36
|
-
caIssuers:
|
|
35
|
+
ocsp: E.ocspAccessMethod,
|
|
36
|
+
caIssuers: E.caIssuersAccessMethod
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
39
|
* Build the v3 extensions block for a certificate.
|
|
@@ -52,7 +52,7 @@ const de = {
|
|
|
52
52
|
function buildCertificateExtensions(e, t, n, r = !1) {
|
|
53
53
|
assertCustomExtensionsValid(n, "certificate"), r && assertEmptySubjectHasCriticalSubjectAltName(n), assertPathLengthKeyUsage(n), assertSafeCurveKeyUsage(e, n), assertNoRevAvailProfile(n);
|
|
54
54
|
let i = [], a = /* @__PURE__ */ new Set(), o = n?.basicConstraints ?? { ca: !1 };
|
|
55
|
-
return pushKnownExtension(i, a,
|
|
55
|
+
return pushKnownExtension(i, a, R, o), pushKnownExtension(i, a, J, buildSubjectKeyIdentifier(e)), t !== void 0 && pushKnownExtension(i, a, L, t), appendConfiguredExtensions(i, a, n, {
|
|
56
56
|
includeBasicConstraints: !1,
|
|
57
57
|
subjectIsEmpty: r
|
|
58
58
|
}), i;
|
|
@@ -82,7 +82,7 @@ function appendConfiguredExtensions(e, t, n, r) {
|
|
|
82
82
|
function assertPathLengthKeyUsage(e) {
|
|
83
83
|
if (resolveEffectiveBasicConstraints(e)?.pathLength === void 0) return;
|
|
84
84
|
let t = resolveEffectiveKeyUsage(e);
|
|
85
|
-
t !== void 0 && t.length !== 0 && t.includes("keyCertSign") ||
|
|
85
|
+
t !== void 0 && t.length !== 0 && t.includes("keyCertSign") || F("path_length_requires_key_cert_sign", "basicConstraints pathLength requires the keyUsage keyCertSign bit");
|
|
86
86
|
}
|
|
87
87
|
/** RFC 9295 §3: an end-entity id-Ed25519 or id-Ed448 certificate needs one of these. */
|
|
88
88
|
const $ = [
|
|
@@ -125,26 +125,26 @@ function assertSafeCurveKeyUsage(e, t) {
|
|
|
125
125
|
let n = resolveEffectiveKeyUsage(t);
|
|
126
126
|
if (n === void 0 || n.length === 0) return;
|
|
127
127
|
let r = readSubjectKeyAlgorithmOid(e);
|
|
128
|
-
r !== void 0 && (oidEquals(r,
|
|
128
|
+
r !== void 0 && (oidEquals(r, E.x25519) || oidEquals(r, E.x448) ? assertMontgomeryKeyUsage(n) : (oidEquals(r, E.ed25519) || oidEquals(r, E.ed448)) && assertEdwardsKeyUsage(n, resolveEffectiveBasicConstraints(t)?.ca === !0));
|
|
129
129
|
}
|
|
130
130
|
/** The X25519 and X448 half of RFC 9295 §3. */
|
|
131
131
|
function assertMontgomeryKeyUsage(e) {
|
|
132
|
-
e.includes("keyAgreement") ||
|
|
132
|
+
e.includes("keyAgreement") || F("montgomery_key_usage_requires_key_agreement", "keyUsage on an X25519 or X448 certificate must set keyAgreement");
|
|
133
133
|
let t = me.filter((t) => e.includes(t));
|
|
134
|
-
t.length > 0 &&
|
|
134
|
+
t.length > 0 && F("montgomery_key_usage_forbids_signature_bit", `keyUsage on an X25519 or X448 certificate must not set ${t.join(", ")}`), e.includes("encipherOnly") && e.includes("decipherOnly") && F("montgomery_key_usage_forbids_both_cipher_bits", "keyUsage on an X25519 or X448 certificate must not set both encipherOnly and decipherOnly");
|
|
135
135
|
}
|
|
136
136
|
/** The Ed25519 and Ed448 half of RFC 9295 §3. */
|
|
137
137
|
function assertEdwardsKeyUsage(e, t) {
|
|
138
|
-
t ? e.includes("keyCertSign") ||
|
|
138
|
+
t ? e.includes("keyCertSign") || F("edwards_key_usage_requires_key_cert_sign", "keyUsage on an Ed25519 or Ed448 certification authority certificate must set keyCertSign") : $.some((t) => e.includes(t)) || F("edwards_key_usage_requires_signing_bit", `keyUsage on an Ed25519 or Ed448 certificate must set one of ${$.join(", ")}`);
|
|
139
139
|
let n = pe.filter((t) => e.includes(t));
|
|
140
|
-
n.length > 0 &&
|
|
140
|
+
n.length > 0 && F("edwards_key_usage_forbids_agreement_bit", `keyUsage on an Ed25519 or Ed448 certificate must not set ${n.join(", ")}`), !t && e.includes("keyCertSign") && F("edwards_key_usage_forbids_key_cert_sign", "keyUsage on an Ed25519 or Ed448 end-entity certificate must not set keyCertSign");
|
|
141
141
|
}
|
|
142
142
|
/** The algorithm OID of a SubjectPublicKeyInfo, or `undefined` when the field is not an OID. */
|
|
143
143
|
function readSubjectKeyAlgorithmOid(e) {
|
|
144
|
-
let t =
|
|
144
|
+
let t = x(e)[0];
|
|
145
145
|
if (t === void 0 || t.tag !== 48) return;
|
|
146
|
-
let
|
|
147
|
-
return
|
|
146
|
+
let i = n(e, t)[0];
|
|
147
|
+
return i?.tag === 6 ? r(i.value) : void 0;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* RFC 5280 §4.2.1.9: basicConstraints is critical in a CA certificate whose key
|
|
@@ -160,8 +160,8 @@ function readSubjectKeyAlgorithmOid(e) {
|
|
|
160
160
|
* always emitted with the registry default.
|
|
161
161
|
*/
|
|
162
162
|
function assertCaBasicConstraintsCritical(e) {
|
|
163
|
-
let t = e?.customExtensions?.find((e) => oidEquals(e.oid,
|
|
164
|
-
if (t === void 0 || t.critical === !0 || !
|
|
163
|
+
let t = e?.customExtensions?.find((e) => oidEquals(e.oid, E.basicConstraints));
|
|
164
|
+
if (t === void 0 || t.critical === !0 || !R.decode(new Uint8Array(t.value)).ca) return;
|
|
165
165
|
let n = resolveEffectiveKeyUsage(e);
|
|
166
166
|
(n === void 0 || n.length === 0 || n.includes("keyCertSign")) && assertExtensionCriticality("basicConstraints", !0, !1);
|
|
167
167
|
}
|
|
@@ -172,23 +172,23 @@ function assertCaBasicConstraintsCritical(e) {
|
|
|
172
172
|
* participate in the effective view.
|
|
173
173
|
*/
|
|
174
174
|
function assertNoRevAvailProfile(e) {
|
|
175
|
-
(e?.noRevAvail === !0 || findCustomExtensionValue(e,
|
|
175
|
+
(e?.noRevAvail === !0 || findCustomExtensionValue(e, E.noRevAvail) !== void 0) && (resolveEffectiveBasicConstraints(e)?.ca === !0 && throwNoRevAvailConflict("basicConstraints with cA TRUE"), ((e?.crlDistributionPoints?.length ?? 0) > 0 || findCustomExtensionValue(e, E.cRLDistributionPoints) !== void 0) && throwNoRevAvailConflict("cRLDistributionPoints"), findCustomExtensionValue(e, E.freshestCRL) !== void 0 && throwNoRevAvailConflict("freshestCRL"), resolveEffectiveAuthorityInfoAccess(e).some((e) => getAuthorityInfoAccessMethodOid(e.method) === E.ocspAccessMethod) && throwNoRevAvailConflict("an id-ad-ocsp authorityInfoAccess entry"));
|
|
176
176
|
}
|
|
177
177
|
/** The authorityInfoAccess entries the builder will emit: the typed list when non-empty, otherwise a custom-known extension. */
|
|
178
178
|
function resolveEffectiveAuthorityInfoAccess(e) {
|
|
179
179
|
if (e?.authorityInfoAccess !== void 0 && e.authorityInfoAccess.length > 0) return e.authorityInfoAccess;
|
|
180
|
-
let t = findCustomExtensionValue(e,
|
|
181
|
-
return t === void 0 ? [] :
|
|
180
|
+
let t = findCustomExtensionValue(e, E.authorityInfoAccess);
|
|
181
|
+
return t === void 0 ? [] : I.decode(t);
|
|
182
182
|
}
|
|
183
183
|
function throwNoRevAvailConflict(e) {
|
|
184
|
-
|
|
184
|
+
F("no_rev_avail_conflict", `A certificate carrying noRevAvail must not also carry ${e}`);
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
187
|
* RFC 5280 §4.2.1.6: an empty subject DN requires a subjectAltName extension
|
|
188
188
|
* present, marked critical, and carrying at least one non-empty GeneralName.
|
|
189
189
|
*/
|
|
190
190
|
function assertEmptySubjectHasCriticalSubjectAltName(e) {
|
|
191
|
-
e?.subjectAltNames?.some(subjectAltNameHasIdentity) !== !0 && e?.customExtensions?.some((e) => oidEquals(e.oid,
|
|
191
|
+
e?.subjectAltNames?.some(subjectAltNameHasIdentity) !== !0 && e?.customExtensions?.some((e) => oidEquals(e.oid, E.subjectAltName) && e.critical === !0 && customSubjectAltNameHasIdentity(e.value)) !== !0 && F("empty_subject_requires_subject_alt_name", "An empty subject requires a critical subjectAltName extension");
|
|
192
192
|
}
|
|
193
193
|
/**
|
|
194
194
|
* Canonical OID equality: matches even when arcs carry redundant leading zeros.
|
|
@@ -196,8 +196,8 @@ function assertEmptySubjectHasCriticalSubjectAltName(e) {
|
|
|
196
196
|
* Both sides must be encodable. Callers run after `assertCustomExtensionsValid`,
|
|
197
197
|
* which rejects an OID that cannot be canonicalized.
|
|
198
198
|
*/
|
|
199
|
-
function oidEquals(
|
|
200
|
-
return
|
|
199
|
+
function oidEquals(t, n) {
|
|
200
|
+
return t === n || e(t) === e(n);
|
|
201
201
|
}
|
|
202
202
|
/** First customExtensions value whose OID canonically matches `oid`. */
|
|
203
203
|
function findCustomExtensionValue(e, t) {
|
|
@@ -212,8 +212,8 @@ function findCustomExtensionValue(e, t) {
|
|
|
212
212
|
*/
|
|
213
213
|
function assertCustomExtensionsValid(e, t) {
|
|
214
214
|
for (let n of e?.customExtensions ?? []) {
|
|
215
|
-
let e = validateOid(n.oid), r =
|
|
216
|
-
r !== void 0 && (r.contexts.includes(t) ||
|
|
215
|
+
let e = validateOid(n.oid), r = Y(e);
|
|
216
|
+
r !== void 0 && (r.contexts.includes(t) || F("extension_not_supported_in_context", `Extension ${n.oid} is not supported in ${t} context`), assertKnownExtensionPayload(r, new Uint8Array(n.value), n.critical ?? !1, n.oid));
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
@@ -223,25 +223,25 @@ function assertCustomExtensionsValid(e, t) {
|
|
|
223
223
|
* A profile violation already carries its own code and propagates unchanged; a
|
|
224
224
|
* decode failure means the payload is not the DER the OID's schema defines.
|
|
225
225
|
*/
|
|
226
|
-
function assertKnownExtensionPayload(e, n, r
|
|
226
|
+
function assertKnownExtensionPayload(e, t, n, r) {
|
|
227
227
|
try {
|
|
228
|
-
e.assertDerProfile(
|
|
229
|
-
} catch (
|
|
230
|
-
if (t
|
|
231
|
-
|
|
228
|
+
e.assertDerProfile(t, n);
|
|
229
|
+
} catch (t) {
|
|
230
|
+
if (le(t)) throw t;
|
|
231
|
+
F("malformed_known_extension_value", `Custom extension ${r} does not decode as ${e.oid}`);
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
/** Effective basicConstraints across the typed field and any custom-known extension. */
|
|
235
235
|
function resolveEffectiveBasicConstraints(e) {
|
|
236
236
|
if (e?.basicConstraints !== void 0) return e.basicConstraints;
|
|
237
|
-
let t = findCustomExtensionValue(e,
|
|
238
|
-
return t === void 0 ? void 0 :
|
|
237
|
+
let t = findCustomExtensionValue(e, E.basicConstraints);
|
|
238
|
+
return t === void 0 ? void 0 : R.decode(t);
|
|
239
239
|
}
|
|
240
240
|
/** Effective keyUsage flags across the typed field and any custom-known extension. */
|
|
241
241
|
function resolveEffectiveKeyUsage(e) {
|
|
242
242
|
if (e?.keyUsage !== void 0) return e.keyUsage;
|
|
243
|
-
let t = findCustomExtensionValue(e,
|
|
244
|
-
return t === void 0 ? void 0 :
|
|
243
|
+
let t = findCustomExtensionValue(e, E.keyUsage);
|
|
244
|
+
return t === void 0 ? void 0 : U.decode(t).flags;
|
|
245
245
|
}
|
|
246
246
|
/** Whether a typed GeneralName carries a non-empty identity value. */
|
|
247
247
|
function subjectAltNameHasIdentity(e) {
|
|
@@ -253,24 +253,24 @@ function subjectAltNameHasIdentity(e) {
|
|
|
253
253
|
}
|
|
254
254
|
/** Whether a custom subjectAltName value decodes to at least one non-empty GeneralName. */
|
|
255
255
|
function customSubjectAltNameHasIdentity(e) {
|
|
256
|
-
return
|
|
256
|
+
return q.decode(e).some(subjectAltNameHasIdentity);
|
|
257
257
|
}
|
|
258
258
|
function appendConstraintExtensions(e, t, n, r) {
|
|
259
|
-
assertPathLengthKeyUsage(n), assertCaBasicConstraintsCritical(n), r && n.basicConstraints !== void 0 && pushKnownExtension(e, t,
|
|
259
|
+
assertPathLengthKeyUsage(n), assertCaBasicConstraintsCritical(n), r && n.basicConstraints !== void 0 && pushKnownExtension(e, t, R, n.basicConstraints), n.keyUsage !== void 0 && n.keyUsage.length > 0 && pushKnownExtension(e, t, U, n.keyUsage), n.nameConstraints !== void 0 && pushKnownExtension(e, t, W, n.nameConstraints);
|
|
260
260
|
}
|
|
261
261
|
function appendIdentityExtensions(e, t, n, r) {
|
|
262
262
|
if (n.subjectAltNames !== void 0 && n.subjectAltNames.length > 0) {
|
|
263
263
|
let i = r ? !0 : void 0;
|
|
264
|
-
pushKnownExtension(e, t,
|
|
264
|
+
pushKnownExtension(e, t, q, n.subjectAltNames, i);
|
|
265
265
|
}
|
|
266
|
-
n.extendedKeyUsage !== void 0 && n.extendedKeyUsage.length > 0 && pushKnownExtension(e, t,
|
|
266
|
+
n.extendedKeyUsage !== void 0 && n.extendedKeyUsage.length > 0 && pushKnownExtension(e, t, V, n.extendedKeyUsage);
|
|
267
267
|
}
|
|
268
268
|
/** Appends configured certificate-policy extensions while enforcing unique OIDs. */
|
|
269
269
|
function appendPolicyExtensions(e, t, n) {
|
|
270
|
-
n.certificatePolicies !== void 0 && n.certificatePolicies.length > 0 && pushKnownExtension(e, t,
|
|
270
|
+
n.certificatePolicies !== void 0 && n.certificatePolicies.length > 0 && pushKnownExtension(e, t, z, n.certificatePolicies), n.policyMappings !== void 0 && n.policyMappings.length > 0 && pushKnownExtension(e, t, ne, n.policyMappings), n.policyConstraints !== void 0 && pushKnownExtension(e, t, K, n.policyConstraints), n.inhibitAnyPolicy !== void 0 && pushKnownExtension(e, t, H, n.inhibitAnyPolicy);
|
|
271
271
|
}
|
|
272
272
|
function appendAccessExtensions(e, t, n) {
|
|
273
|
-
n.authorityInfoAccess !== void 0 && n.authorityInfoAccess.length > 0 && pushKnownExtension(e, t,
|
|
273
|
+
n.authorityInfoAccess !== void 0 && n.authorityInfoAccess.length > 0 && pushKnownExtension(e, t, I, n.authorityInfoAccess), n.crlDistributionPoints !== void 0 && n.crlDistributionPoints.length > 0 && pushKnownExtension(e, t, B, n.crlDistributionPoints), n.noRevAvail === !0 && pushKnownExtension(e, t, G, !0);
|
|
274
274
|
}
|
|
275
275
|
/** Push each custom extension. Context and payload were checked by `assertCustomExtensionsValid`. */
|
|
276
276
|
function appendCustomExtensions(e, t, n) {
|
|
@@ -289,8 +289,8 @@ function pushKnownExtension(e, t, n, r, i = n.defaultCritical) {
|
|
|
289
289
|
*/
|
|
290
290
|
function encodeExtension(e, t, n = !1) {
|
|
291
291
|
validateOid(e);
|
|
292
|
-
let r = [
|
|
293
|
-
return n && r.push(
|
|
292
|
+
let r = [_(e)];
|
|
293
|
+
return n && r.push(c(!0)), r.push(v(t)), S(r);
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* DER-encode a {@linkcode BasicConstraints} value.
|
|
@@ -300,7 +300,7 @@ function encodeExtension(e, t, n = !1) {
|
|
|
300
300
|
*/
|
|
301
301
|
function encodeBasicConstraints(e) {
|
|
302
302
|
let t = [];
|
|
303
|
-
return e.ca && t.push(
|
|
303
|
+
return e.ca && t.push(c(!0)), e.pathLength !== void 0 && (e.ca || F("path_length_requires_ca", "basicConstraints pathLength requires ca = true"), t.push(g(e.pathLength))), S(t);
|
|
304
304
|
}
|
|
305
305
|
/**
|
|
306
306
|
* DER-encode a Key Usage BIT STRING from an array of {@linkcode KeyUsage} flags.
|
|
@@ -308,18 +308,18 @@ function encodeBasicConstraints(e) {
|
|
|
308
308
|
* @param usages Flags to set in the bit string.
|
|
309
309
|
*/
|
|
310
310
|
function encodeKeyUsage(e) {
|
|
311
|
-
return
|
|
311
|
+
return P(e);
|
|
312
312
|
}
|
|
313
313
|
function encodeIa5Content(e) {
|
|
314
314
|
try {
|
|
315
|
-
return
|
|
315
|
+
return f(e);
|
|
316
316
|
} catch {
|
|
317
|
-
|
|
317
|
+
F("invalid_ia5_string", "Invalid IA5String: contains non-ASCII characters");
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
/** RFC 5280 §4.2.1.6: reject an empty GeneralName string value (empty dNSName, rfc822Name, URI, or SRV name). */
|
|
321
321
|
function requireNonEmptyName(e) {
|
|
322
|
-
return e.length === 0 &&
|
|
322
|
+
return e.length === 0 && F("empty_general_name_value", "GeneralName value must not be empty"), e;
|
|
323
323
|
}
|
|
324
324
|
/**
|
|
325
325
|
* RFC 9598 §3: a SmtpUTF8Mailbox carries no Byte Order Mark, is used only when
|
|
@@ -328,7 +328,7 @@ function requireNonEmptyName(e) {
|
|
|
328
328
|
*/
|
|
329
329
|
function assertSmtpUtf8Mailbox(e) {
|
|
330
330
|
let t = requireNonEmptyName(e).lastIndexOf("@"), n = t > 0 ? e.slice(0, t) : "", r = toAsciiDomain(e.slice(t + 1));
|
|
331
|
-
return (n.length === 0 || e.includes("") || !
|
|
331
|
+
return (n.length === 0 || e.includes("") || !j(r, "registration")) && F("invalid_smtp_utf8_mailbox", "SmtpUTF8Mailbox must be Local-part@Domain with no Byte Order Mark and a domain of lowercase A-labels and NR-LDH labels"), [...n].some((e) => (e.codePointAt(0) ?? 0) > 127) || F("smtp_utf8_mailbox_ascii_local_part", "A mailbox with an ASCII Local-part must use rfc822Name (type email)"), M(n) || F("invalid_smtp_utf8_mailbox", "SmtpUTF8Mailbox Local-part must be an RFC 6531 Dot-string or Quoted-string"), `${n}@${r}`;
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
334
|
* @internal A decoded SAN or IAN entry of a custom extension, which is emitted
|
|
@@ -336,16 +336,16 @@ function assertSmtpUtf8Mailbox(e) {
|
|
|
336
336
|
* stored in A-labels.
|
|
337
337
|
*/
|
|
338
338
|
function assertStoredSubjectAltName(e) {
|
|
339
|
-
encodeSubjectAltName(e), e.type === "smtpUtf8Mailbox" && assertSmtpUtf8Mailbox(e.value) !== e.value &&
|
|
339
|
+
encodeSubjectAltName(e), e.type === "smtpUtf8Mailbox" && assertSmtpUtf8Mailbox(e.value) !== e.value && F("invalid_smtp_utf8_mailbox", "SmtpUTF8Mailbox domain must be stored as lowercase A-labels and NR-LDH labels");
|
|
340
340
|
}
|
|
341
341
|
/** RFC 5891 §4: the domain with each U-label converted to its A-label and each A-label checked. */
|
|
342
342
|
function toAsciiDomain(e) {
|
|
343
|
-
let t =
|
|
344
|
-
return t.ok ? t.value :
|
|
343
|
+
let t = te(e, "registration");
|
|
344
|
+
return t.ok ? t.value : F("invalid_idn", `Domain name is not valid IDNA2008 (${t.reason})`);
|
|
345
345
|
}
|
|
346
346
|
/** RFC 5280 §4.2.1.6 dNSName and rfc822Name domains take the RFC 1034 §3.5 preferred name syntax, which has no trailing root dot. */
|
|
347
347
|
function requireRelativeDomain(e) {
|
|
348
|
-
return e.endsWith(".") &&
|
|
348
|
+
return e.endsWith(".") && F("domain_trailing_dot", "A dNSName or rfc822Name domain must not end in \".\" (RFC 5280 §4.2.1.6)"), e;
|
|
349
349
|
}
|
|
350
350
|
/** A dNSName or dNSName constraint with its leading `*.` or `.` kept and its domain in A-labels. */
|
|
351
351
|
function toAsciiDnsName(e) {
|
|
@@ -357,7 +357,7 @@ function toAsciiDnsName(e) {
|
|
|
357
357
|
* normalized, its `_Service` label kept, and its Name in A-labels.
|
|
358
358
|
*/
|
|
359
359
|
function toAsciiSrvComponents(e) {
|
|
360
|
-
let t =
|
|
360
|
+
let t = ie(e), n = t.indexOf(".");
|
|
361
361
|
if (!t.startsWith("_")) return toAsciiDomain(t);
|
|
362
362
|
if (n < 0) return t;
|
|
363
363
|
let r = t.slice(n + 1);
|
|
@@ -366,43 +366,43 @@ function toAsciiSrvComponents(e) {
|
|
|
366
366
|
/** RFC 4985 §2 and RFC 6335 §5.1: a presented SRVName is `_Service.Name`. */
|
|
367
367
|
function toAsciiSrvName(e) {
|
|
368
368
|
let t = toAsciiSrvComponents(e);
|
|
369
|
-
return
|
|
369
|
+
return ae(t) === void 0 && F("invalid_srv_name", "A SRVName is _Service.Name with an RFC 6335 service and an LDH Name (RFC 4985 §2)"), t;
|
|
370
370
|
}
|
|
371
371
|
/** RFC 4985 §4: a SRVName constraint is `_Service.Name`, `_Service`, or `Name`. */
|
|
372
372
|
function toAsciiSrvNameConstraint(e) {
|
|
373
373
|
let t = toAsciiSrvComponents(e);
|
|
374
|
-
return
|
|
374
|
+
return oe(t) === void 0 && F("invalid_srv_name_constraint", "A SRVName constraint is _Service.Name, _Service, or Name (RFC 4985 §4)"), t;
|
|
375
375
|
}
|
|
376
376
|
/** RFC 4120 §5.2.1 KerberosString content: IA5String characters in a GeneralString, without code-extension controls. */
|
|
377
377
|
function kerberosString(e, t) {
|
|
378
378
|
let outside = (e) => e > 127 || e === 14 || e === 15 || e === 27;
|
|
379
|
-
return [...e].some((e) => outside(e.codePointAt(0) ?? 0)) &&
|
|
379
|
+
return [...e].some((e) => outside(e.codePointAt(0) ?? 0)) && F("invalid_krb5_principal_name", `KRB5PrincipalName ${t} must hold IA5String characters other than SO, SI and ESC (RFC 4120 §5.2.1)`), C(27, new TextEncoder().encode(e));
|
|
380
380
|
}
|
|
381
381
|
/** RFC 4120 §5.2.4 Int32 as a DER-minimal two's-complement INTEGER. */
|
|
382
382
|
function int32(e) {
|
|
383
|
-
(!Number.isInteger(e) || e < -2147483648 || e > 2147483647) &&
|
|
383
|
+
(!Number.isInteger(e) || e < -2147483648 || e > 2147483647) && F("invalid_krb5_principal_name", "KRB5PrincipalName nameType must be an Int32 (RFC 4120 §5.2.4)");
|
|
384
384
|
let t = [], n = e;
|
|
385
385
|
do
|
|
386
386
|
t.unshift(n & 255), n >>= 8;
|
|
387
387
|
while (!(n === 0 && (t[0] ?? 0) < 128) && !(n === -1 && (t[0] ?? 0) >= 128));
|
|
388
|
-
return
|
|
388
|
+
return C(2, Uint8Array.from(t));
|
|
389
389
|
}
|
|
390
390
|
/** RFC 4556 §3.2.2 KRB5PrincipalName in the EXPLICIT tagging of RFC 4120's module. */
|
|
391
391
|
function encodeKrb5PrincipalName(e) {
|
|
392
|
-
return e.realm.includes("\0") &&
|
|
392
|
+
return e.realm.includes("\0") && F("invalid_krb5_principal_name", "KRB5PrincipalName realm must not contain NUL (RFC 4120 §5.2.2)"), S([u(0, kerberosString(e.realm, "realm")), u(1, S([u(0, int32(e.nameType)), u(1, S(e.nameString.map((e) => kerberosString(e, "nameString"))))]))]);
|
|
393
393
|
}
|
|
394
394
|
/** An otherName type-id that has no dedicated {@linkcode SubjectAltName} variant. */
|
|
395
395
|
function validateOtherNameTypeId(e) {
|
|
396
396
|
let t = validateOid(e);
|
|
397
|
-
return (t ===
|
|
397
|
+
return (t === E.idOnDnsSrv || t === E.idOnSmtpUtf8Mailbox) && F("other_name_type_id_has_variant", `otherName type-id ${t} is encoded through its dedicated SubjectAltName variant`), t;
|
|
398
398
|
}
|
|
399
399
|
function requireGeneralNameContent(e, t, n) {
|
|
400
400
|
let r = n(e);
|
|
401
|
-
return r.ok ||
|
|
401
|
+
return r.ok || F("invalid_general_name_content", r.reason === "unsupported" ? `${t} contents use an encoding micro509 cannot validate` : `${t} contents do not match the ${t === "x400Address" ? "ORAddress" : "EDIPartyName"} ASN.1 (RFC 5280)`), e;
|
|
402
402
|
}
|
|
403
403
|
function requireSingleDerElement(e) {
|
|
404
|
-
let
|
|
405
|
-
return
|
|
404
|
+
let n = t(e);
|
|
405
|
+
return n !== "valid" && F("invalid_other_name_value", n === "unsupported" ? "otherName value uses an encoding micro509 cannot validate" : "otherName value must be exactly one DER element"), e;
|
|
406
406
|
}
|
|
407
407
|
/** RFC 9549 §2.5: an rfc822Name or rfc822Name constraint with its host in A-labels. */
|
|
408
408
|
function toAsciiMailbox(e) {
|
|
@@ -416,23 +416,23 @@ function toAsciiMailbox(e) {
|
|
|
416
416
|
*/
|
|
417
417
|
function encodeSubjectAltName(e) {
|
|
418
418
|
switch (e.type) {
|
|
419
|
-
case "dns": return
|
|
420
|
-
case "email": return
|
|
421
|
-
case "uri": return
|
|
422
|
-
case "srv": return
|
|
423
|
-
case "smtpUtf8Mailbox": return
|
|
424
|
-
case "upn": return
|
|
425
|
-
case "krb5PrincipalName": return
|
|
426
|
-
case "ip": return
|
|
427
|
-
case "directoryName": return
|
|
419
|
+
case "dns": return h(2, encodeIa5Content(toAsciiDnsName(requireNonEmptyName(e.value))));
|
|
420
|
+
case "email": return h(1, encodeIa5Content(toAsciiMailbox(requireNonEmptyName(e.value))));
|
|
421
|
+
case "uri": return h(6, encodeIa5Content(requireNonEmptyName(e.value)));
|
|
422
|
+
case "srv": return m(0, l([_(E.idOnDnsSrv), u(0, C(22, encodeIa5Content(toAsciiSrvName(requireNonEmptyName(e.value)))))]));
|
|
423
|
+
case "smtpUtf8Mailbox": return m(0, l([_(E.idOnSmtpUtf8Mailbox), u(0, w(assertSmtpUtf8Mailbox(e.value)))]));
|
|
424
|
+
case "upn": return m(0, l([_(E.ntPrincipalName), u(0, w(requireNonEmptyName(e.value)))]));
|
|
425
|
+
case "krb5PrincipalName": return m(0, l([_(E.idPkinitSan), u(0, encodeKrb5PrincipalName(e))]));
|
|
426
|
+
case "ip": return h(7, encodeIpAddress(e.value));
|
|
427
|
+
case "directoryName": return m(4, readDirectoryNameTlv(e.derHex));
|
|
428
428
|
case "otherName": {
|
|
429
429
|
let t = validateOtherNameTypeId(e.typeId), n = requireSingleDerElement(e.value);
|
|
430
|
-
return
|
|
430
|
+
return X(t, n, b(n)) !== void 0 && F("other_name_type_id_has_variant", `otherName type-id ${t} with this value is encoded through its dedicated SubjectAltName variant`), m(0, l([_(t), u(0, n)]));
|
|
431
431
|
}
|
|
432
|
-
case "x400Address": return requireGeneralNameContent(
|
|
433
|
-
case "ediPartyName": return requireGeneralNameContent(
|
|
434
|
-
case "registeredID": return
|
|
435
|
-
case "unknown": return
|
|
432
|
+
case "x400Address": return requireGeneralNameContent(m(3, e.value), "x400Address", re);
|
|
433
|
+
case "ediPartyName": return requireGeneralNameContent(m(5, e.value), "ediPartyName", Z);
|
|
434
|
+
case "registeredID": return h(8, b(_(validateOid(e.value))).value);
|
|
435
|
+
case "unknown": return Q.has(e.tag) || F("invalid_general_name_tag", `Invalid GeneralName tag: ${e.tag}`), C(e.tag, e.value);
|
|
436
436
|
default: throw Error(`Unhandled SubjectAltName type: ${String(e)}`);
|
|
437
437
|
}
|
|
438
438
|
}
|
|
@@ -442,7 +442,7 @@ function encodeSubjectAltName(e) {
|
|
|
442
442
|
* @param usages EKU purposes to encode.
|
|
443
443
|
*/
|
|
444
444
|
function encodeExtendedKeyUsage(e) {
|
|
445
|
-
return e.length === 0 &&
|
|
445
|
+
return e.length === 0 && F("extended_key_usage_empty", "extendedKeyUsage must not be empty"), S(e.map((e) => _(getExtendedKeyUsageOid(e))));
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
448
|
* DER-encode an Authority Information Access SEQUENCE.
|
|
@@ -450,7 +450,7 @@ function encodeExtendedKeyUsage(e) {
|
|
|
450
450
|
* @param entries AIA entries (OCSP, caIssuers, or custom) to encode.
|
|
451
451
|
*/
|
|
452
452
|
function encodeAuthorityInfoAccess(e) {
|
|
453
|
-
return assertAuthorityInfoAccessProfile(e),
|
|
453
|
+
return assertAuthorityInfoAccessProfile(e), S(e.map((e) => S([_(getAuthorityInfoAccessMethodOid(e.method)), encodeSubjectAltName(e.location)])));
|
|
454
454
|
}
|
|
455
455
|
/**
|
|
456
456
|
* @internal RFC 5280 §4.2.2.1 and RFC 6960 §3.1 rules for Authority Information
|
|
@@ -460,8 +460,8 @@ function encodeAuthorityInfoAccess(e) {
|
|
|
460
460
|
* smuggle a non-URI OCSP location past the input union.
|
|
461
461
|
*/
|
|
462
462
|
function assertAuthorityInfoAccessProfile(e) {
|
|
463
|
-
e.length === 0 &&
|
|
464
|
-
for (let t of e) getAuthorityInfoAccessMethodOid(t.method) ===
|
|
463
|
+
e.length === 0 && F("authority_info_access_empty", "authorityInfoAccess must not be empty");
|
|
464
|
+
for (let t of e) getAuthorityInfoAccessMethodOid(t.method) === E.ocspAccessMethod && t.location.type !== "uri" && F("authority_info_access_ocsp_not_uri", "authorityInfoAccess OCSP location must be a URI");
|
|
465
465
|
}
|
|
466
466
|
/**
|
|
467
467
|
* DER-encode a CRL Distribution Points SEQUENCE.
|
|
@@ -469,7 +469,7 @@ function assertAuthorityInfoAccessProfile(e) {
|
|
|
469
469
|
* @param points Distribution points to encode.
|
|
470
470
|
*/
|
|
471
471
|
function encodeCrlDistributionPoints(e) {
|
|
472
|
-
return assertCrlDistributionPointsProfile(e),
|
|
472
|
+
return assertCrlDistributionPointsProfile(e), S(e.map((e) => S(encodeDistributionPoint(e))));
|
|
473
473
|
}
|
|
474
474
|
/**
|
|
475
475
|
* @internal RFC 5280 §4.2.1.13 profile rules for a CRLDistributionPoints value,
|
|
@@ -480,12 +480,12 @@ function encodeCrlDistributionPoints(e) {
|
|
|
480
480
|
* a decoded point carries the parsed one. The rules only read its presence.
|
|
481
481
|
*/
|
|
482
482
|
function assertCrlDistributionPointsProfile(e) {
|
|
483
|
-
e.length === 0 &&
|
|
483
|
+
e.length === 0 && F("crl_distribution_points_empty", "cRLDistributionPoints must not be empty");
|
|
484
484
|
for (let t of e) assertDistributionPointProfile(t);
|
|
485
485
|
}
|
|
486
486
|
/** RFC 5280 §4.2.1.13 rules for one distribution point. */
|
|
487
487
|
function assertDistributionPointProfile(e) {
|
|
488
|
-
e.crlIssuer !== void 0 && e.crlIssuer.length === 0 &&
|
|
488
|
+
e.crlIssuer !== void 0 && e.crlIssuer.length === 0 && F("distribution_point_crl_issuer_empty", "DistributionPoint crlIssuer must not be empty"), e.distributionPoint === void 0 && e.crlIssuer === void 0 && F("distribution_point_empty", "DistributionPoint must contain distributionPoint or crlIssuer"), assertCrlIssuerDistinguishedNames(e), e.distributionPoint?.type === "fullName" && e.distributionPoint.fullName.length === 0 && F("distribution_point_full_name_empty", "DistributionPointName fullName must not be empty");
|
|
489
489
|
}
|
|
490
490
|
/**
|
|
491
491
|
* DER-encode a Name Constraints extension value.
|
|
@@ -495,7 +495,7 @@ function assertDistributionPointProfile(e) {
|
|
|
495
495
|
function encodeNameConstraints(e) {
|
|
496
496
|
assertNameConstraintsProfile(e);
|
|
497
497
|
let t = [];
|
|
498
|
-
return e.permittedSubtrees !== void 0 && e.permittedSubtrees.length > 0 && t.push(
|
|
498
|
+
return e.permittedSubtrees !== void 0 && e.permittedSubtrees.length > 0 && t.push(m(0, l(e.permittedSubtrees.map(encodeGeneralSubtree)))), e.excludedSubtrees !== void 0 && e.excludedSubtrees.length > 0 && t.push(m(1, l(e.excludedSubtrees.map(encodeGeneralSubtree)))), S(t);
|
|
499
499
|
}
|
|
500
500
|
/**
|
|
501
501
|
* @internal RFC 5280 fixes the criticality of several extensions: nameConstraints
|
|
@@ -508,7 +508,7 @@ function encodeNameConstraints(e) {
|
|
|
508
508
|
* @param critical The criticality the caller asked for.
|
|
509
509
|
*/
|
|
510
510
|
function assertExtensionCriticality(e, t, n) {
|
|
511
|
-
n !== t &&
|
|
511
|
+
n !== t && F(t ? "extension_must_be_critical" : "extension_must_be_non_critical", `The ${e} extension must be marked ${t ? "critical" : "non-critical"}`);
|
|
512
512
|
}
|
|
513
513
|
/**
|
|
514
514
|
* @internal RFC 5280 §4.2.1.10: a nameConstraints extension states at least one
|
|
@@ -516,7 +516,7 @@ function assertExtensionCriticality(e, t, n) {
|
|
|
516
516
|
*/
|
|
517
517
|
function assertNameConstraintsProfile(e) {
|
|
518
518
|
let t = e.permittedSubtrees?.length ?? 0, n = e.excludedSubtrees?.length ?? 0;
|
|
519
|
-
t === 0 && n === 0 &&
|
|
519
|
+
t === 0 && n === 0 && F("name_constraints_empty", "nameConstraints must set permittedSubtrees or excludedSubtrees");
|
|
520
520
|
}
|
|
521
521
|
/**
|
|
522
522
|
* DER-encode a Certificate Policies extension value.
|
|
@@ -524,13 +524,13 @@ function assertNameConstraintsProfile(e) {
|
|
|
524
524
|
* @param policies Non-empty array of policy information entries.
|
|
525
525
|
*/
|
|
526
526
|
function encodeCertificatePolicies(e) {
|
|
527
|
-
e.length === 0 &&
|
|
527
|
+
e.length === 0 && F("certificate_policies_empty", "certificatePolicies must not be empty");
|
|
528
528
|
let t = /* @__PURE__ */ new Set();
|
|
529
529
|
for (let n of e) {
|
|
530
530
|
let e = validatePolicyOid(n.policyIdentifier);
|
|
531
|
-
t.has(e) &&
|
|
531
|
+
t.has(e) && F("duplicate_policy_oid", `Duplicate certificate policy OID: ${n.policyIdentifier}`), t.add(e);
|
|
532
532
|
}
|
|
533
|
-
return
|
|
533
|
+
return S(e.map(encodePolicyInformation));
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
536
|
* DER-encode a Policy Mappings extension value.
|
|
@@ -538,9 +538,9 @@ function encodeCertificatePolicies(e) {
|
|
|
538
538
|
* @param mappings Non-empty array of issuer-to-subject policy pairs. Neither OID may be anyPolicy.
|
|
539
539
|
*/
|
|
540
540
|
function encodePolicyMappings(e) {
|
|
541
|
-
return e.length === 0 &&
|
|
541
|
+
return e.length === 0 && F("policy_mappings_empty", "policyMappings must not be empty"), S(e.map((e) => {
|
|
542
542
|
let t = validatePolicyOid(e.issuerDomainPolicy), n = validatePolicyOid(e.subjectDomainPolicy);
|
|
543
|
-
return (t ===
|
|
543
|
+
return (t === E.anyPolicy || n === E.anyPolicy) && F("policy_mappings_any_policy", "policyMappings must not use anyPolicy"), S([_(e.issuerDomainPolicy), _(e.subjectDomainPolicy)]);
|
|
544
544
|
}));
|
|
545
545
|
}
|
|
546
546
|
/**
|
|
@@ -550,7 +550,7 @@ function encodePolicyMappings(e) {
|
|
|
550
550
|
*/
|
|
551
551
|
function encodePolicyConstraints(e) {
|
|
552
552
|
let t = [];
|
|
553
|
-
return e.requireExplicitPolicy !== void 0 && t.push(
|
|
553
|
+
return e.requireExplicitPolicy !== void 0 && t.push(h(0, encodeIntegerContent(e.requireExplicitPolicy))), e.inhibitPolicyMapping !== void 0 && t.push(h(1, encodeIntegerContent(e.inhibitPolicyMapping))), t.length === 0 && F("policy_constraints_empty", "policyConstraints must set requireExplicitPolicy or inhibitPolicyMapping"), S(t);
|
|
554
554
|
}
|
|
555
555
|
/**
|
|
556
556
|
* DER-encode an Inhibit anyPolicy extension value (single INTEGER).
|
|
@@ -558,36 +558,36 @@ function encodePolicyConstraints(e) {
|
|
|
558
558
|
* @param input The skipCerts threshold.
|
|
559
559
|
*/
|
|
560
560
|
function encodeInhibitAnyPolicy(e) {
|
|
561
|
-
return
|
|
561
|
+
return g(e.skipCerts);
|
|
562
562
|
}
|
|
563
563
|
/** DER-encode a single PolicyInformation SEQUENCE. */
|
|
564
564
|
function encodePolicyInformation(e) {
|
|
565
565
|
validatePolicyOid(e.policyIdentifier);
|
|
566
|
-
let t = [
|
|
567
|
-
return e.policyQualifiers !== void 0 && e.policyQualifiers.length > 0 && t.push(
|
|
566
|
+
let t = [_(e.policyIdentifier)];
|
|
567
|
+
return e.policyQualifiers !== void 0 && e.policyQualifiers.length > 0 && t.push(S(e.policyQualifiers.map(encodePolicyQualifierInfo))), S(t);
|
|
568
568
|
}
|
|
569
569
|
/** DER-encode a single PolicyQualifierInfo SEQUENCE. */
|
|
570
570
|
function encodePolicyQualifierInfo(e) {
|
|
571
571
|
switch (e.type) {
|
|
572
|
-
case "cps": return
|
|
573
|
-
case "userNotice": return
|
|
572
|
+
case "cps": return S([_(E.cpsPolicyQualifier), p(e.uri)]);
|
|
573
|
+
case "userNotice": return S([_(E.userNoticePolicyQualifier), encodeUserNoticePolicyQualifierInfo(e)]);
|
|
574
574
|
case "oid": {
|
|
575
575
|
validateOid(e.oid);
|
|
576
|
-
let t =
|
|
577
|
-
return (n ===
|
|
576
|
+
let t = _(e.oid), n = a(t);
|
|
577
|
+
return (n === a(_(E.cpsPolicyQualifier)) || n === a(_(E.userNoticePolicyQualifier))) && F("reserved_policy_qualifier_oid", "Policy qualifier must use the typed cps or userNotice variant, not a built-in OID"), S([t, new Uint8Array(e.qualifierDer)]);
|
|
578
578
|
}
|
|
579
579
|
default: throw Error(`Unhandled PolicyQualifierInfo type: ${String(e)}`);
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
/** DER-encode a UserNotice qualifier SEQUENCE. */
|
|
583
583
|
function assertDisplayText(e) {
|
|
584
|
-
|
|
584
|
+
d(e) && F("display_text_lone_surrogate", "DisplayText must not hold a lone UTF-16 surrogate");
|
|
585
585
|
let t = [...e].length;
|
|
586
|
-
(t === 0 || t > 200) &&
|
|
586
|
+
(t === 0 || t > 200) && F("display_text_out_of_range", "DisplayText must be 1 to 200 characters");
|
|
587
587
|
}
|
|
588
588
|
function encodeUserNoticePolicyQualifierInfo(e) {
|
|
589
589
|
let t = [];
|
|
590
|
-
return e.noticeRef !== void 0 && t.push(encodePolicyNoticeReference(e.noticeRef)), e.explicitText !== void 0 && (assertDisplayText(e.explicitText), t.push(encodeExplicitText(e.explicitText, e.explicitTextType))),
|
|
590
|
+
return e.noticeRef !== void 0 && t.push(encodePolicyNoticeReference(e.noticeRef)), e.explicitText !== void 0 && (assertDisplayText(e.explicitText), t.push(encodeExplicitText(e.explicitText, e.explicitTextType))), S(t);
|
|
591
591
|
}
|
|
592
592
|
/**
|
|
593
593
|
* RFC 6818 §3, replacing the explicitText paragraph of RFC 5280 §4.2.1.4:
|
|
@@ -596,11 +596,11 @@ function encodeUserNoticePolicyQualifierInfo(e) {
|
|
|
596
596
|
* and BMPString text should be in Unicode normalization form C.
|
|
597
597
|
*/
|
|
598
598
|
function encodeExplicitText(e, t = "utf8String") {
|
|
599
|
-
switch ([...e].some(isControlCharacter) &&
|
|
600
|
-
case "utf8String": return assertNormalizationFormC(e),
|
|
599
|
+
switch ([...e].some(isControlCharacter) && F("display_text_control_character", "explicitText must not contain control characters"), t) {
|
|
600
|
+
case "utf8String": return assertNormalizationFormC(e), w(e);
|
|
601
601
|
case "bmpString": return assertNormalizationFormC(e), encodeBmpDisplayText(e);
|
|
602
602
|
case "visibleString": return encodeVisibleDisplayText(e);
|
|
603
|
-
case "ia5String": return
|
|
603
|
+
case "ia5String": return F("display_text_ia5_string", "explicitText must not be encoded as IA5String");
|
|
604
604
|
default: throw Error(`Unhandled DisplayText type: ${String(t)}`);
|
|
605
605
|
}
|
|
606
606
|
}
|
|
@@ -609,33 +609,33 @@ function isControlCharacter(e) {
|
|
|
609
609
|
return t <= 31 || t >= 127 && t <= 159;
|
|
610
610
|
}
|
|
611
611
|
function assertNormalizationFormC(e) {
|
|
612
|
-
e.normalize("NFC") !== e &&
|
|
612
|
+
e.normalize("NFC") !== e && F("display_text_not_nfc", "explicitText must be in Unicode normalization form C");
|
|
613
613
|
}
|
|
614
614
|
function encodeVisibleDisplayText(e) {
|
|
615
615
|
try {
|
|
616
|
-
return
|
|
616
|
+
return T(e);
|
|
617
617
|
} catch {
|
|
618
|
-
return
|
|
618
|
+
return F("invalid_visible_string", "VisibleString explicitText must be printable ASCII");
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
621
|
function encodeBmpDisplayText(e) {
|
|
622
622
|
try {
|
|
623
|
-
return
|
|
623
|
+
return s(e);
|
|
624
624
|
} catch {
|
|
625
|
-
return
|
|
625
|
+
return F("invalid_bmp_string", "BMPString explicitText must hold Basic Multilingual Plane characters other than surrogates, U+FFFE and U+FFFF");
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
628
|
/** DER-encode a NoticeReference SEQUENCE. */
|
|
629
629
|
function encodePolicyNoticeReference(e) {
|
|
630
|
-
return assertDisplayText(e.organization),
|
|
630
|
+
return assertDisplayText(e.organization), S([w(e.organization), S(e.noticeNumbers.map((e) => g(e)))]);
|
|
631
631
|
}
|
|
632
632
|
/** Encode an INTEGER and return only the content bytes (no TLV wrapper). */
|
|
633
633
|
function encodeIntegerContent(e) {
|
|
634
|
-
return
|
|
634
|
+
return y(g(e)).value;
|
|
635
635
|
}
|
|
636
636
|
/** DER-encode a GeneralSubtree SEQUENCE (base name only; min/max omitted per RFC 5280). */
|
|
637
637
|
function encodeGeneralSubtree(e) {
|
|
638
|
-
return
|
|
638
|
+
return S([encodeNameConstraintForm(e.base)]);
|
|
639
639
|
}
|
|
640
640
|
/**
|
|
641
641
|
* RFC 5280 §4.2.1.13: cRLIssuer, when present, only contains the CRL issuer's
|
|
@@ -646,20 +646,20 @@ function encodeGeneralSubtree(e) {
|
|
|
646
646
|
* arrives through `crlDistributionPoints` or through `customExtensions`.
|
|
647
647
|
*/
|
|
648
648
|
function assertCrlIssuerDistinguishedNames(e) {
|
|
649
|
-
e.crlIssuer !== void 0 && (e.crlIssuer.some((e) => e.type !== "directoryName") &&
|
|
649
|
+
e.crlIssuer !== void 0 && (e.crlIssuer.some((e) => e.type !== "directoryName") && F("distribution_point_crl_issuer_not_directory_name", "DistributionPoint cRLIssuer must only contain directoryName entries"), e.distributionPoint?.type === "relativeName" && e.crlIssuer.length > 1 && F("distribution_point_relative_name_multiple_crl_issuers", "DistributionPointName relativeName requires at most one cRLIssuer distinguished name"));
|
|
650
650
|
}
|
|
651
651
|
/** DER-encode the fields of a single DistributionPoint, already profile-checked. */
|
|
652
652
|
function encodeDistributionPoint(e) {
|
|
653
653
|
let t = [];
|
|
654
|
-
return e.distributionPoint !== void 0 && t.push(
|
|
654
|
+
return e.distributionPoint !== void 0 && t.push(m(0, encodeDistributionPointName(e.distributionPoint))), e.reasons !== void 0 && e.reasons.length > 0 && t.push(h(1, N(e.reasons))), e.crlIssuer !== void 0 && t.push(m(2, l(e.crlIssuer.map(encodeSubjectAltName)))), t;
|
|
655
655
|
}
|
|
656
656
|
/** DER-encode a DistributionPointName (fullName or relativeName). */
|
|
657
657
|
function encodeDistributionPointName(e) {
|
|
658
658
|
switch (e.type) {
|
|
659
|
-
case "fullName": return e.fullName.length === 0 &&
|
|
659
|
+
case "fullName": return e.fullName.length === 0 && F("distribution_point_full_name_empty", "DistributionPointName fullName must not be empty"), m(0, l(e.fullName.map(encodeSubjectAltName)));
|
|
660
660
|
case "relativeName": {
|
|
661
|
-
let t =
|
|
662
|
-
return
|
|
661
|
+
let t = ue(e.relativeName), n = y(t);
|
|
662
|
+
return m(1, t.slice(n.start, n.end));
|
|
663
663
|
}
|
|
664
664
|
default: throw Error(`Unhandled DistributionPointName type: ${String(e)}`);
|
|
665
665
|
}
|
|
@@ -667,22 +667,22 @@ function encodeDistributionPointName(e) {
|
|
|
667
667
|
/** DER-encode a NameConstraintForm as an implicit-tagged {@linkcode GeneralName}. */
|
|
668
668
|
function encodeNameConstraintForm(e) {
|
|
669
669
|
switch (e.type) {
|
|
670
|
-
case "dns": return
|
|
671
|
-
case "email": return e.value.includes("@") &&
|
|
672
|
-
case "uri": return
|
|
670
|
+
case "dns": return h(2, encodeIa5Content(toAsciiDnsName(e.value)));
|
|
671
|
+
case "email": return e.value.includes("@") && F("email_name_constraint_names_mailbox", "An rfc822Name constraint names a host or a domain, not a particular mailbox (RFC 9549 §2.2)"), h(1, encodeIa5Content(toAsciiMailbox(e.value)));
|
|
672
|
+
case "uri": return se(e.value) === void 0 && F("invalid_uri_name_constraint", "A uniformResourceIdentifier constraint is a fully qualified domain name, with a leading period for its subdomains (RFC 5280 §4.2.1.10)"), h(6, encodeIa5Content(e.value));
|
|
673
673
|
case "ip": {
|
|
674
674
|
let t = e.addressBytes.length + e.maskBytes.length;
|
|
675
|
-
return (e.addressBytes.length !== e.maskBytes.length || t !== 8 && t !== 32) &&
|
|
675
|
+
return (e.addressBytes.length !== e.maskBytes.length || t !== 8 && t !== 32) && F("invalid_ip_name_constraint", "IP name constraint must be 8 octets (IPv4) or 32 octets (IPv6)"), h(7, l([e.addressBytes, e.maskBytes]));
|
|
676
676
|
}
|
|
677
|
-
case "directoryName": return
|
|
678
|
-
case "srv": return
|
|
677
|
+
case "directoryName": return m(4, readDirectoryNameTlv(e.derHex));
|
|
678
|
+
case "srv": return m(0, l([_(E.idOnDnsSrv), u(0, C(22, encodeIa5Content(toAsciiSrvNameConstraint(e.value))))]));
|
|
679
679
|
default: throw Error(`Unhandled NameConstraintForm type: ${String(e)}`);
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
682
|
/** Returns the complete Name TLV from a hex-encoded DER SEQUENCE, validating the root tag. */
|
|
683
683
|
function readDirectoryNameTlv(e) {
|
|
684
|
-
let t =
|
|
685
|
-
return n.tag !== 48 &&
|
|
684
|
+
let t = i(e), n = b(t, { maxDepth: 64 });
|
|
685
|
+
return n.tag !== 48 && F("directory_name_not_sequence", "directoryName derHex must encode a DER SEQUENCE"), t.slice(n.start - n.headerLength, n.end);
|
|
686
686
|
}
|
|
687
687
|
/**
|
|
688
688
|
* Resolve an {@linkcode ExtendedKeyUsage} to its dotted-decimal OID.
|
|
@@ -699,12 +699,12 @@ function getExtendedKeyUsageOid(e) {
|
|
|
699
699
|
*/
|
|
700
700
|
function parseExtendedKeyUsageOid(e) {
|
|
701
701
|
switch (e) {
|
|
702
|
-
case
|
|
703
|
-
case
|
|
704
|
-
case
|
|
705
|
-
case
|
|
706
|
-
case
|
|
707
|
-
case
|
|
702
|
+
case E.serverAuth: return "serverAuth";
|
|
703
|
+
case E.clientAuth: return "clientAuth";
|
|
704
|
+
case E.codeSigning: return "codeSigning";
|
|
705
|
+
case E.emailProtection: return "emailProtection";
|
|
706
|
+
case E.timeStamping: return "timeStamping";
|
|
707
|
+
case E.ocspSigning: return "ocspSigning";
|
|
708
708
|
}
|
|
709
709
|
return {
|
|
710
710
|
type: "oid",
|
|
@@ -726,8 +726,8 @@ function getAuthorityInfoAccessMethodOid(e) {
|
|
|
726
726
|
*/
|
|
727
727
|
function parseAuthorityInfoAccessMethodOid(e) {
|
|
728
728
|
switch (e) {
|
|
729
|
-
case
|
|
730
|
-
case
|
|
729
|
+
case E.ocspAccessMethod: return "ocsp";
|
|
730
|
+
case E.caIssuersAccessMethod: return "caIssuers";
|
|
731
731
|
}
|
|
732
732
|
return {
|
|
733
733
|
type: "oid",
|
|
@@ -736,7 +736,7 @@ function parseAuthorityInfoAccessMethodOid(e) {
|
|
|
736
736
|
}
|
|
737
737
|
/** Parse a dotted-decimal/colon-hex IP string to raw address bytes. */
|
|
738
738
|
function encodeIpAddress(e) {
|
|
739
|
-
return
|
|
739
|
+
return A(e);
|
|
740
740
|
}
|
|
741
741
|
/**
|
|
742
742
|
* Computes a key identifier from a DER `SubjectPublicKeyInfo` using method (1)
|
|
@@ -745,10 +745,10 @@ function encodeIpAddress(e) {
|
|
|
745
745
|
* A parsed certificate carries the input as `subjectPublicKeyInfoDer`.
|
|
746
746
|
*/
|
|
747
747
|
function buildSubjectKeyIdentifier(e) {
|
|
748
|
-
let t =
|
|
748
|
+
let t = x(e)[1];
|
|
749
749
|
if (t === void 0 || t.tag !== 3) throw Error("SPKI missing subject public key bit string");
|
|
750
750
|
let n = t.value.slice(1);
|
|
751
|
-
return
|
|
751
|
+
return ee(n);
|
|
752
752
|
}
|
|
753
753
|
/**
|
|
754
754
|
* The key identifier a certificate or CRL issued by `issuer` carries in its
|
|
@@ -757,7 +757,7 @@ function buildSubjectKeyIdentifier(e) {
|
|
|
757
757
|
* has none (§4.2.1.1).
|
|
758
758
|
*/
|
|
759
759
|
function issuerKeyIdentifier(e) {
|
|
760
|
-
return e.subjectKeyIdentifier === void 0 ? buildSubjectKeyIdentifier(e.subjectPublicKeyInfoDer) :
|
|
760
|
+
return e.subjectKeyIdentifier === void 0 ? buildSubjectKeyIdentifier(e.subjectPublicKeyInfoDer) : i(e.subjectKeyIdentifier);
|
|
761
761
|
}
|
|
762
762
|
/**
|
|
763
763
|
* Throw if the string is not an encodable dotted-decimal OID, and return its
|
|
@@ -768,11 +768,11 @@ function issuerKeyIdentifier(e) {
|
|
|
768
768
|
* yet cannot be encoded.
|
|
769
769
|
*/
|
|
770
770
|
function validateOid(t) {
|
|
771
|
-
/^\d+(?:\.\d+)+$/.test(t) ||
|
|
771
|
+
/^\d+(?:\.\d+)+$/.test(t) || F("invalid_oid", `Invalid OID: ${t}`);
|
|
772
772
|
try {
|
|
773
|
-
return
|
|
774
|
-
} catch (
|
|
775
|
-
|
|
773
|
+
return e(t);
|
|
774
|
+
} catch (e) {
|
|
775
|
+
o(e, ce), F("invalid_oid", `Invalid OID: ${t}`);
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
778
|
/** Validate a policy OID and return its canonical spelling. */
|
|
@@ -788,8 +788,8 @@ function validatePolicyOid(e) {
|
|
|
788
788
|
*/
|
|
789
789
|
function pushExtension(e, t, n, r, i = !1) {
|
|
790
790
|
let a = validateOid(n);
|
|
791
|
-
t.has(a) &&
|
|
791
|
+
t.has(a) && F("duplicate_extension_oid", `Duplicate extension OID: ${n}`), t.add(a), e.push(encodeExtension(n, r, i));
|
|
792
792
|
}
|
|
793
|
-
export {
|
|
793
|
+
export { D as allOnesMaskForIpAddress, assertAuthorityInfoAccessProfile, assertCrlDistributionPointsProfile, assertExtensionCriticality, assertNameConstraintsProfile, assertStoredSubjectAltName, buildCertificateExtensions, buildRequestedExtensions, buildSubjectKeyIdentifier, O as decodeIpAddress, encodeAuthorityInfoAccess, encodeBasicConstraints, encodeCertificatePolicies, encodeCrlDistributionPoints, encodeExtendedKeyUsage, encodeExtension, encodeInhibitAnyPolicy, encodeKeyUsage, encodeNameConstraints, encodePolicyConstraints, encodePolicyMappings, encodeSubjectAltName, getAuthorityInfoAccessMethodOid, getExtendedKeyUsageOid, issuerKeyIdentifier, k as normalizeIpAddress, parseAuthorityInfoAccessMethodOid, parseExtendedKeyUsageOid, A as parseIpAddressToBytes };
|
|
794
794
|
|
|
795
795
|
//# sourceMappingURL=extensions.js.map
|