micro509 0.6.0 → 0.7.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.
Files changed (64) hide show
  1. package/dist/index.d.ts +13 -14
  2. package/dist/index.js +1 -1
  3. package/dist/internal/crypto/pbes2.d.ts +6 -6
  4. package/dist/internal/crypto/pbes2.js +1 -1
  5. package/dist/internal/crypto/pbes2.js.map +1 -1
  6. package/dist/internal/verify/name-constraints-engine.js.map +1 -1
  7. package/dist/internal/x509/extension-bits.js.map +1 -1
  8. package/dist/keys/keys.d.ts +15 -15
  9. package/dist/keys/keys.js +1 -1
  10. package/dist/keys/keys.js.map +1 -1
  11. package/dist/keys.d.ts +2 -3
  12. package/dist/pem/pem.d.ts +57 -6
  13. package/dist/pem/pem.js +5 -5
  14. package/dist/pem/pem.js.map +1 -1
  15. package/dist/pem.d.ts +2 -2
  16. package/dist/pem.js +1 -1
  17. package/dist/pkcs/pfx.d.ts +4 -4
  18. package/dist/pkcs/pfx.js +1 -1
  19. package/dist/pkcs/pfx.js.map +1 -1
  20. package/dist/pkcs/pkcs12-mac.d.ts +29 -5
  21. package/dist/pkcs/pkcs12-mac.js +1 -1
  22. package/dist/pkcs/pkcs12-mac.js.map +1 -1
  23. package/dist/pkcs/pkcs7.d.ts +36 -50
  24. package/dist/pkcs/pkcs7.js +1 -1
  25. package/dist/pkcs/pkcs7.js.map +1 -1
  26. package/dist/pkcs.d.ts +3 -4
  27. package/dist/pkcs.js +1 -1
  28. package/dist/result/result.d.ts +3 -12
  29. package/dist/result/result.js.map +1 -1
  30. package/dist/result.d.ts +2 -2
  31. package/dist/result.js +1 -1
  32. package/dist/revocation/chain.d.ts +35 -34
  33. package/dist/revocation/chain.js +1 -1
  34. package/dist/revocation/chain.js.map +1 -1
  35. package/dist/revocation/crl.d.ts +40 -15
  36. package/dist/revocation/crl.js +1 -1
  37. package/dist/revocation/crl.js.map +1 -1
  38. package/dist/revocation/ocsp.d.ts +63 -13
  39. package/dist/revocation/ocsp.js +1 -1
  40. package/dist/revocation/ocsp.js.map +1 -1
  41. package/dist/revocation/revocation.d.ts +21 -19
  42. package/dist/revocation/revocation.js +1 -1
  43. package/dist/revocation/revocation.js.map +1 -1
  44. package/dist/revocation.d.ts +7 -5
  45. package/dist/revocation.js +1 -1
  46. package/dist/verify/identity.d.ts +4 -10
  47. package/dist/verify/identity.js +1 -1
  48. package/dist/verify/identity.js.map +1 -1
  49. package/dist/verify/verify.d.ts +9 -9
  50. package/dist/verify/verify.js +1 -1
  51. package/dist/verify/verify.js.map +1 -1
  52. package/dist/verify.d.ts +2 -2
  53. package/dist/x509/certificate.d.ts +2 -2
  54. package/dist/x509/certificate.js.map +1 -1
  55. package/dist/x509/csr.d.ts +2 -2
  56. package/dist/x509/csr.js.map +1 -1
  57. package/dist/x509/extensions.d.ts +21 -6
  58. package/dist/x509/extensions.js.map +1 -1
  59. package/dist/x509/parse.d.ts +3 -4
  60. package/dist/x509/parse.js +1 -1
  61. package/dist/x509/parse.js.map +1 -1
  62. package/dist/x509.d.ts +3 -4
  63. package/package.json +3 -1
  64. package/dist/internal/x509/extension-bits.d.ts +0 -18
@@ -2,6 +2,20 @@ import { NameAttribute, NameFieldKey, RelativeDistinguishedNameInput } from "./n
2
2
 
3
3
  //#region src/x509/extensions.d.ts
4
4
  /**
5
+ * A decoded BIT STRING flag set.
6
+ *
7
+ * `flags` contains the recognized flag values with any non-zero padding bits
8
+ * masked out. `nonZeroPadding` is `true` when the original BIT STRING encoding
9
+ * had non-zero bits in positions that DER (X.690 §11.2.2) requires to be zero.
10
+ * Verification layers can use this signal to reject non-conformant encodings.
11
+ */
12
+ interface ParsedBitFlags<T extends string> {
13
+ /** Decoded flag values, padding bits masked. */
14
+ readonly flags: readonly T[];
15
+ /** `true` when the original encoding had non-zero padding bits (DER violation). */
16
+ readonly nonZeroPadding: boolean;
17
+ }
18
+ /**
5
19
  * RFC 5280 §4.2.1.3 Key Usage bit flag.
6
20
  *
7
21
  * Each value corresponds to one bit in the KeyUsage BIT STRING.
@@ -126,12 +140,13 @@ type IssuingDistributionPoint = IssuingDistributionPointBase | IssuingDistributi
126
140
  * A certificate with `ca: true` may issue other certificates; `pathLength`
127
141
  * limits how many additional CAs may appear below it in the chain.
128
142
  */
129
- interface BasicConstraints {
130
- /** Whether this certificate belongs to a CA. End-entity certs set this to `false`. */
131
- readonly ca: boolean;
132
- /** Maximum number of intermediate CA certificates allowed below this CA. Only valid when `ca` is `true`. */
143
+ type BasicConstraints = {
144
+ /** End-entity certificate: not a CA. */readonly ca: false; /** Never present on end-entity certificates. */
145
+ readonly pathLength?: undefined;
146
+ } | {
147
+ /** CA certificate: may issue other certificates. */readonly ca: true; /** Maximum number of intermediate CA certificates allowed below this CA. */
133
148
  readonly pathLength?: number;
134
- }
149
+ };
135
150
  /** A single certificate policy: an OID plus optional qualifiers. */
136
151
  interface PolicyInformation {
137
152
  /** Dotted-decimal OID of the policy (e.g. `"2.23.140.1.2.1"` for DV). */
@@ -546,5 +561,5 @@ declare function getAuthorityInfoAccessMethodOid(method: AuthorityInfoAccessMeth
546
561
  */
547
562
  declare function parseAuthorityInfoAccessMethodOid(oid: string): AuthorityInfoAccessMethod;
548
563
  //#endregion
549
- export { AuthorityInfoAccessMethod, AuthorityInformationAccess, BasicConstraints, CertificateExtensionsInput, CertificatePolicies, CpsPolicyQualifierInfo, CustomAuthorityInfoAccessMethod, CustomExtendedKeyUsage, CustomExtension, CustomPolicyQualifierInfo, DistributionPoint, DistributionPointName, DistributionPointReason, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, IssuingDistributionPoint, IssuingDistributionPointBase, IssuingDistributionPointForAttributeCerts, IssuingDistributionPointForCaCerts, IssuingDistributionPointForUserCerts, KeyUsage, KnownAuthorityInfoAccessMethod, KnownExtendedKeyUsage, NameConstraintForm, NameConstraints, ParsedNameConstraintForm, PolicyConstraints, PolicyInformation, PolicyMapping, PolicyMappings, PolicyNoticeReference, PolicyQualifierInfo, SubjectAltName, UnsupportedNameConstraintForm, UserNoticePolicyQualifierInfo, buildCertificateExtensions, buildRequestedExtensions, encodeAuthorityInfoAccess, encodeBasicConstraints, encodeCertificatePolicies, encodeCrlDistributionPoints, encodeExtendedKeyUsage, encodeExtension, encodeInhibitAnyPolicy, encodeKeyUsage, encodeNameConstraints, encodePolicyConstraints, encodePolicyMappings, encodeSubjectAltName, getAuthorityInfoAccessMethodOid, getExtendedKeyUsageOid, parseAuthorityInfoAccessMethodOid, parseExtendedKeyUsageOid };
564
+ export { AuthorityInfoAccessMethod, AuthorityInformationAccess, BasicConstraints, CertificateExtensionsInput, CertificatePolicies, CpsPolicyQualifierInfo, CustomAuthorityInfoAccessMethod, CustomExtendedKeyUsage, CustomExtension, CustomPolicyQualifierInfo, DistributionPoint, DistributionPointName, DistributionPointReason, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, IssuingDistributionPoint, IssuingDistributionPointBase, IssuingDistributionPointForAttributeCerts, IssuingDistributionPointForCaCerts, IssuingDistributionPointForUserCerts, KeyUsage, KnownAuthorityInfoAccessMethod, KnownExtendedKeyUsage, NameConstraintForm, NameConstraints, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyInformation, PolicyMapping, PolicyMappings, PolicyNoticeReference, PolicyQualifierInfo, SubjectAltName, UnsupportedNameConstraintForm, UserNoticePolicyQualifierInfo, buildCertificateExtensions, buildRequestedExtensions, encodeAuthorityInfoAccess, encodeBasicConstraints, encodeCertificatePolicies, encodeCrlDistributionPoints, encodeExtendedKeyUsage, encodeExtension, encodeInhibitAnyPolicy, encodeKeyUsage, encodeNameConstraints, encodePolicyConstraints, encodePolicyMappings, encodeSubjectAltName, getAuthorityInfoAccessMethodOid, getExtendedKeyUsageOid, parseAuthorityInfoAccessMethodOid, parseExtendedKeyUsageOid };
550
565
  //# sourceMappingURL=extensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.js","names":["_exhaustive"],"sources":["../../src/x509/extensions.ts"],"sourcesContent":["/**\n * Typed certificate and CSR extension model plus ASN.1 encoder helpers.\n *\n * Defines input types for every supported X.509v3 extension (RFC 5280) and\n * the DER encoders consumed by certificate and CSR builder flows.\n *\n * @module\n */\n\nimport { hexToBytes } from '#micro509/internal/asn1/asn1.ts';\nimport {\n\tbool,\n\tconcatBytes,\n\tDEFAULT_MAX_DER_DEPTH,\n\texplicitContext,\n\tia5String,\n\timplicitConstructedContext,\n\timplicitPrimitiveContext,\n\tintegerFromNumber,\n\tobjectIdentifier,\n\toctetString,\n\treadElement,\n\treadRootElement,\n\treadSequenceChildren,\n\tsequence,\n\ttlv,\n\tutf8String,\n} from '#micro509/internal/asn1/der.ts';\nimport { OIDS } from '#micro509/internal/asn1/oids.ts';\nimport { sha1 } from '#micro509/internal/crypto/hash.ts';\nimport { parseIpAddressToBytes } from '#micro509/internal/shared/ip.ts';\nimport {\n\tencodeDistributionPointReasonFlagsContent,\n\tencodeKeyUsageExtension,\n} from '#micro509/internal/x509/extension-bits.ts';\nimport type {\n\tExtensionDefinition,\n\tExtensionRegistryContext,\n} from '#micro509/internal/x509/extension-registry.ts';\nimport {\n\tAUTHORITY_INFO_ACCESS_EXTENSION_DEFINITION,\n\tAUTHORITY_KEY_IDENTIFIER_EXTENSION_DEFINITION,\n\tBASIC_CONSTRAINTS_EXTENSION_DEFINITION,\n\tCERTIFICATE_POLICIES_EXTENSION_DEFINITION,\n\tCRL_DISTRIBUTION_POINTS_EXTENSION_DEFINITION,\n\tEXTENDED_KEY_USAGE_EXTENSION_DEFINITION,\n\tgetExtensionDefinition,\n\tINHIBIT_ANY_POLICY_EXTENSION_DEFINITION,\n\tKEY_USAGE_EXTENSION_DEFINITION,\n\tNAME_CONSTRAINTS_EXTENSION_DEFINITION,\n\tPOLICY_CONSTRAINTS_EXTENSION_DEFINITION,\n\tPOLICY_MAPPINGS_EXTENSION_DEFINITION,\n\tSUBJECT_ALT_NAME_EXTENSION_DEFINITION,\n\tSUBJECT_KEY_IDENTIFIER_EXTENSION_DEFINITION,\n} from '#micro509/internal/x509/extension-registry.ts';\nimport type { RelativeDistinguishedNameInput } from './name.ts';\nimport { encodeRelativeDistinguishedName } from './name.ts';\n\nexport type { NameAttribute, NameFieldKey, RelativeDistinguishedNameInput } from './name.ts';\n\n/**\n * RFC 5280 §4.2.1.3 Key Usage bit flag.\n *\n * Each value corresponds to one bit in the KeyUsage BIT STRING.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.3 RFC 5280 §4.2.1.3}\n */\nexport type KeyUsage =\n\t| 'digitalSignature'\n\t| 'nonRepudiation'\n\t| 'keyEncipherment'\n\t| 'dataEncipherment'\n\t| 'keyAgreement'\n\t| 'keyCertSign'\n\t| 'cRLSign'\n\t| 'encipherOnly'\n\t| 'decipherOnly';\n\n/**\n * RFC 5280 §4.2.1.6 Subject Alternative Name / GeneralName.\n *\n * Discriminated union keyed on `type`.\n *\n * The `'unknown'` variant preserves unrecognized {@linkcode GeneralName} tags for round-trip fidelity.\n */\nexport type SubjectAltName =\n\t| {\n\t\t\t/** DNS hostname (dNSName [2]). */\n\t\t\treadonly type: 'dns';\n\t\t\t/** Fully-qualified domain name, e.g. `\"example.com\"`. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** IP address (iPAddress [7]). */\n\t\t\treadonly type: 'ip';\n\t\t\t/** Dotted-decimal IPv4 or colon-hex IPv6 string. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** Email address (rfc822Name [1]). */\n\t\t\treadonly type: 'email';\n\t\t\t/** RFC 822 mailbox, e.g. `\"admin@example.com\"`. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** URI (uniformResourceIdentifier [6]). */\n\t\t\treadonly type: 'uri';\n\t\t\t/** Absolute URI string. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** SRV-ID otherName (id-on-dnsSRV). */\n\t\t\treadonly type: 'srv';\n\t\t\t/** SRV service name, e.g. `\"_imaps.example.com\"`. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** X.500 directory name (directoryName [4]). */\n\t\t\treadonly type: 'directoryName';\n\t\t\t/** Hex-encoded DER of the Name SEQUENCE. */\n\t\t\treadonly derHex: string;\n\t }\n\t| {\n\t\t\t/** Unrecognized {@linkcode GeneralName} tag, preserved as raw bytes. */\n\t\t\treadonly type: 'unknown';\n\t\t\t/** ASN.1 context tag number. */\n\t\t\treadonly tag: number;\n\t\t\t/** Raw content bytes of the element. */\n\t\t\treadonly value: Uint8Array;\n\t };\n\n/** Alias for {@linkcode SubjectAltName} — used where RFC 5280 says \"GeneralName\". */\nexport type GeneralName = SubjectAltName;\n\n/**\n * Revocation reason flags for CRL Distribution Points and Issuing Distribution Points\n * (RFC 5280 §4.2.1.13, §5.2.5).\n */\nexport type DistributionPointReason =\n\t| 'keyCompromise'\n\t| 'cACompromise'\n\t| 'affiliationChanged'\n\t| 'superseded'\n\t| 'cessationOfOperation'\n\t| 'certificateHold'\n\t| 'privilegeWithdrawn'\n\t| 'aACompromise';\n\n/**\n * Name component of a CRL Distribution Point (RFC 5280 §4.2.1.13).\n *\n * Supply exactly one of `fullName` or `relativeName`.\n */\nexport interface DistributionPointName {\n\t/** Absolute {@linkcode GeneralName}(s) identifying the distribution point (usually a URI). */\n\treadonly fullName?: readonly GeneralName[];\n\t/** Name relative to the issuer's DN; mutually exclusive with `fullName`. */\n\treadonly relativeName?: RelativeDistinguishedNameInput;\n}\n\n/**\n * Input for a single CRL Distribution Point (RFC 5280 §4.2.1.13).\n *\n * At least one of `distributionPoint` or `crlIssuer` must be provided.\n * The union enforces this constraint at the type level.\n */\nexport type DistributionPoint =\n\t| {\n\t\t\t/** Where to fetch the CRL (fullName or relativeName). */\n\t\t\treadonly distributionPoint: DistributionPointName;\n\t\t\t/** Revocation reason subset. Absent means all reasons. */\n\t\t\treadonly reasons?: readonly DistributionPointReason[];\n\t\t\t/** Entity that signed the CRL, when different from the cert issuer. */\n\t\t\treadonly crlIssuer?: readonly GeneralName[];\n\t }\n\t| {\n\t\t\t/** Where to fetch the CRL. Optional when `crlIssuer` is present. */\n\t\t\treadonly distributionPoint?: DistributionPointName;\n\t\t\t/** Revocation reason subset. Absent means all reasons. */\n\t\t\treadonly reasons?: readonly DistributionPointReason[];\n\t\t\t/** Entity that signed the CRL. Required when `distributionPoint` is absent. */\n\t\t\treadonly crlIssuer: readonly GeneralName[];\n\t };\n\n/** Base shape for Issuing Distribution Point (RFC 5280 §5.2.5) — no scope restriction. */\nexport interface IssuingDistributionPointBase {\n\t/** Where to fetch this CRL. */\n\treadonly distributionPoint?: DistributionPointName;\n\t/** Limits the CRL to these revocation reasons. Absent means all reasons. */\n\treadonly onlySomeReasons?: readonly DistributionPointReason[];\n\t/** When true, the CRL may contain entries from other CAs. Default false. */\n\treadonly indirectCrl?: boolean;\n\t/** Must be absent or false in this variant (no user-cert-only restriction). */\n\treadonly onlyContainsUserCerts?: false;\n\t/** Must be absent or false in this variant (no CA-cert-only restriction). */\n\treadonly onlyContainsCACerts?: false;\n\t/** When true, the CRL only covers attribute certificates. Default false. */\n\treadonly onlyContainsAttributeCerts?: boolean;\n}\n\n/** IDP scoped to end-entity (user) certificates only. Mutually exclusive with CA / attribute scopes. */\nexport interface IssuingDistributionPointForUserCerts\n\textends Omit<IssuingDistributionPointBase, 'onlyContainsUserCerts'> {\n\t/** This variant only covers end-entity certificates. */\n\treadonly onlyContainsUserCerts: true;\n\t/** Must be absent or false when the CRL is not CA-only. */\n\treadonly onlyContainsCACerts?: false;\n\t/** Must be absent or false when the CRL is not attribute-cert-only. */\n\treadonly onlyContainsAttributeCerts?: false;\n}\n\n/** IDP scoped to CA certificates only. Mutually exclusive with user / attribute scopes. */\nexport interface IssuingDistributionPointForCaCerts\n\textends Omit<IssuingDistributionPointBase, 'onlyContainsCACerts'> {\n\t/** Must be absent or false when the CRL is not user-cert-only. */\n\treadonly onlyContainsUserCerts?: false;\n\t/** This variant only covers CA certificates. */\n\treadonly onlyContainsCACerts: true;\n\t/** Must be absent or false when the CRL is not attribute-cert-only. */\n\treadonly onlyContainsAttributeCerts?: false;\n}\n\n/** IDP scoped to attribute certificates only. Mutually exclusive with user / CA scopes. */\nexport interface IssuingDistributionPointForAttributeCerts\n\textends Omit<IssuingDistributionPointBase, 'onlyContainsAttributeCerts'> {\n\t/** Must be absent or false when the CRL is not user-cert-only. */\n\treadonly onlyContainsUserCerts?: false;\n\t/** Must be absent or false when the CRL is not CA-only. */\n\treadonly onlyContainsCACerts?: false;\n\t/** This variant only covers attribute certificates. */\n\treadonly onlyContainsAttributeCerts: true;\n}\n\n/**\n * Input for the Issuing Distribution Point CRL extension (RFC 5280 §5.2.5).\n *\n * The union enforces that at most one of the `onlyContains*` flags is true.\n */\nexport type IssuingDistributionPoint =\n\t| IssuingDistributionPointBase\n\t| IssuingDistributionPointForUserCerts\n\t| IssuingDistributionPointForCaCerts\n\t| IssuingDistributionPointForAttributeCerts;\n\n/**\n * RFC 5280 §4.2.1.9 Basic Constraints.\n *\n * A certificate with `ca: true` may issue other certificates; `pathLength`\n * limits how many additional CAs may appear below it in the chain.\n */\nexport interface BasicConstraints {\n\t/** Whether this certificate belongs to a CA. End-entity certs set this to `false`. */\n\treadonly ca: boolean;\n\t/** Maximum number of intermediate CA certificates allowed below this CA. Only valid when `ca` is `true`. */\n\treadonly pathLength?: number;\n}\n\n/** A single certificate policy: an OID plus optional qualifiers. */\nexport interface PolicyInformation {\n\t/** Dotted-decimal OID of the policy (e.g. `\"2.23.140.1.2.1\"` for DV). */\n\treadonly policyIdentifier: string;\n\t/** Optional CPS URIs or user notices attached to this policy. */\n\treadonly policyQualifiers?: readonly PolicyQualifierInfo[];\n}\n\n/** RFC 5280 §4.2.1.4 — array of policy OIDs with optional qualifiers. */\nexport type CertificatePolicies = readonly {\n\t/** Dotted-decimal OID of the policy (e.g. `\"2.23.140.1.2.1\"` for DV). */\n\treadonly policyIdentifier: string;\n\t/** Optional CPS URIs or user notices attached to this policy. */\n\treadonly policyQualifiers?: readonly (\n\t\t| {\n\t\t\t\treadonly type: 'cps';\n\t\t\t\treadonly uri: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'userNotice';\n\t\t\t\treadonly noticeRef?: {\n\t\t\t\t\treadonly organization: string;\n\t\t\t\t\treadonly noticeNumbers: readonly number[];\n\t\t\t\t};\n\t\t\t\treadonly explicitText?: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'oid';\n\t\t\t\treadonly oid: string;\n\t\t\t\treadonly qualifierDer: Uint8Array;\n\t\t }\n\t)[];\n}[];\n\n/** CPS (Certification Practice Statement) URI policy qualifier. */\nexport interface CpsPolicyQualifierInfo {\n\t/** Discriminant for the `'cps'` qualifier variant. */\n\treadonly type: 'cps';\n\t/** URL of the Certification Practice Statement document. */\n\treadonly uri: string;\n}\n\n/** Reference to a numbered notice within an organization's practice statement. */\nexport interface PolicyNoticeReference {\n\t/** Organization name that published the notice. */\n\treadonly organization: string;\n\t/** One-based notice numbers within that organization's documentation. */\n\treadonly noticeNumbers: readonly number[];\n}\n\n/** UserNotice policy qualifier — human-readable notice text and/or a notice reference. */\nexport interface UserNoticePolicyQualifierInfo {\n\t/** Discriminant for the `'userNotice'` qualifier variant. */\n\treadonly type: 'userNotice';\n\t/** Pointer to a numbered notice in an organization's practice statement. */\n\treadonly noticeRef?: PolicyNoticeReference;\n\t/** Free-form text to display to relying parties. */\n\treadonly explicitText?: string;\n}\n\n/** Opaque policy qualifier identified by a custom OID, carried as raw DER. */\nexport interface CustomPolicyQualifierInfo {\n\t/** Discriminant for the custom-OID qualifier variant. */\n\treadonly type: 'oid';\n\t/** Dotted-decimal OID of the qualifier. */\n\treadonly oid: string;\n\t/** DER-encoded qualifier payload. */\n\treadonly qualifierDer: Uint8Array;\n}\n\n/** Discriminated union of all supported policy qualifier types. */\nexport type PolicyQualifierInfo =\n\t| CpsPolicyQualifierInfo\n\t| UserNoticePolicyQualifierInfo\n\t| CustomPolicyQualifierInfo;\n\n/** Maps a policy OID in the issuer's domain to an equivalent OID in the subject's domain. */\nexport interface PolicyMapping {\n\t/** Policy OID as defined by the issuing CA. Must not be anyPolicy. */\n\treadonly issuerDomainPolicy: string;\n\t/** Equivalent policy OID in the subject CA's domain. Must not be anyPolicy. */\n\treadonly subjectDomainPolicy: string;\n}\n\n/** RFC 5280 §4.2.1.5 — array of issuer-to-subject policy OID pairs. */\nexport type PolicyMappings = readonly {\n\t/** Policy OID as defined by the issuing CA. Must not be anyPolicy. */\n\treadonly issuerDomainPolicy: string;\n\t/** Equivalent policy OID in the subject CA's domain. Must not be anyPolicy. */\n\treadonly subjectDomainPolicy: string;\n}[];\n\n/**\n * RFC 5280 §4.2.1.11 Policy Constraints.\n *\n * At least one field must be present. Values are certificate-count\n * thresholds measured from the current certificate toward the end entity.\n */\nexport interface PolicyConstraints {\n\t/** After this many certificates, an acceptable policy must be in the path. */\n\treadonly requireExplicitPolicy?: number;\n\t/** After this many certificates, policy mapping is no longer allowed. */\n\treadonly inhibitPolicyMapping?: number;\n}\n\n/**\n * RFC 5280 §4.2.1.14 Inhibit anyPolicy.\n *\n * After `skipCerts` additional certificates in the path, the special\n * anyPolicy OID is no longer considered a match.\n */\nexport interface InhibitAnyPolicy {\n\t/** Number of additional certificates before anyPolicy stops being valid. */\n\treadonly skipCerts: number;\n}\n\n/**\n * Input for `createCertificate`, `createSelfSignedCertificate`,\n * and `createCertificateSigningRequest`.\n *\n * Every field is optional. Omitted extensions are not encoded. Built-in\n * extensions (SKI, AKI, basicConstraints defaults) are handled automatically\n * by the builder.\n */\nexport interface CertificateExtensionsInput {\n\t/** Subject Alternative Names (dns, ip, email, uri, srv, directoryName). */\n\treadonly subjectAltNames?: readonly SubjectAltName[];\n\t/** Key Usage flags (digitalSignature, keyCertSign, etc.). */\n\treadonly keyUsage?: readonly KeyUsage[];\n\t/** Basic Constraints (CA flag + optional pathLength). Defaults to `{ ca: false }` for certs. */\n\treadonly basicConstraints?: BasicConstraints;\n\t/** Extended Key Usage purposes (serverAuth, clientAuth, etc.). */\n\treadonly extendedKeyUsage?: readonly ExtendedKeyUsage[];\n\t/** Name Constraints — permitted and/or excluded subtrees. */\n\treadonly nameConstraints?: NameConstraints;\n\t/** Certificate Policies with optional qualifiers. */\n\treadonly certificatePolicies?: CertificatePolicies;\n\t/** Policy Mappings between issuer and subject policy domains. */\n\treadonly policyMappings?: PolicyMappings;\n\t/** Policy Constraints (requireExplicitPolicy / inhibitPolicyMapping thresholds). */\n\treadonly policyConstraints?: PolicyConstraints;\n\t/** Inhibit anyPolicy skip-certs threshold. */\n\treadonly inhibitAnyPolicy?: InhibitAnyPolicy;\n\t/** Authority Information Access — OCSP responder and CA issuer URIs. */\n\treadonly authorityInfoAccess?: readonly AuthorityInformationAccess[];\n\t/** CRL Distribution Points — where to check revocation status. */\n\treadonly crlDistributionPoints?: readonly DistributionPoint[];\n\t/** Arbitrary extensions not covered by the built-in fields. */\n\treadonly customExtensions?: readonly CustomExtension[];\n}\n\n/** An extension not covered by the typed fields in {@linkcode CertificateExtensionsInput}. */\nexport interface CustomExtension {\n\t/** Dotted-decimal OID of the extension. */\n\treadonly oid: string;\n\t/** Pre-encoded DER content for the extnValue OCTET STRING. */\n\treadonly value: Uint8Array;\n\t/** Whether the extension is critical. Default `false`. */\n\treadonly critical?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Name constraints (RFC 5280 §4.2.1.10)\n// ---------------------------------------------------------------------------\n\n/**\n * A name form used as a constraint base in namEConstraints.\n * Distinct from {@linkcode SubjectAltName} because IP constraints carry\n * address + mask bytes (8 for IPv4, 32 for IPv6) rather than bare addresses.\n */\nexport type NameConstraintForm =\n\t| {\n\t\t\t/** DNS domain constraint (dNSName [2]). */\n\t\t\treadonly type: 'dns';\n\t\t\t/** Domain suffix, e.g. `\".example.com\"` or `\"example.com\"`. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** Email constraint (rfc822Name [1]). */\n\t\t\treadonly type: 'email';\n\t\t\t/** Email domain or full address pattern. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** URI constraint (uniformResourceIdentifier [6]). */\n\t\t\treadonly type: 'uri';\n\t\t\t/** Host or domain component of a URI. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** IP range constraint (iPAddress [7]). */\n\t\t\treadonly type: 'ip';\n\t\t\t/** Network address bytes (4 for IPv4, 16 for IPv6). */\n\t\t\treadonly addressBytes: Uint8Array;\n\t\t\t/** Subnet mask bytes (same length as addressBytes). */\n\t\t\treadonly maskBytes: Uint8Array;\n\t }\n\t| {\n\t\t\t/** Directory name constraint (directoryName [4]). */\n\t\t\treadonly type: 'directoryName';\n\t\t\t/** Hex-encoded DER of the Name SEQUENCE. */\n\t\t\treadonly derHex: string;\n\t };\n\n/**\n * Name constraint forms parsed from DER but not supported for encoding or\n * validation. Preserved for diagnostic round-tripping.\n */\nexport type UnsupportedNameConstraintForm =\n\t| {\n\t\t\t/** otherName [0] — raw bytes. */\n\t\t\treadonly type: 'otherName';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\t/** x400Address [3] — raw bytes. */\n\t\t\treadonly type: 'x400Address';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\t/** ediPartyName [5] — raw bytes. */\n\t\t\treadonly type: 'ediPartyName';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\t/** registeredID [8] — decoded OID string. */\n\t\t\treadonly type: 'registeredID';\n\t\t\treadonly value: string;\n\t };\n\n/** Union of supported and unsupported name constraint forms as produced by parsing. */\nexport type ParsedNameConstraintForm =\n\t| {\n\t\t\treadonly type: 'dns';\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\treadonly type: 'email';\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\treadonly type: 'uri';\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\treadonly type: 'ip';\n\t\t\treadonly addressBytes: Uint8Array;\n\t\t\treadonly maskBytes: Uint8Array;\n\t }\n\t| {\n\t\t\treadonly type: 'directoryName';\n\t\t\treadonly derHex: string;\n\t }\n\t| {\n\t\t\treadonly type: 'otherName';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\treadonly type: 'x400Address';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\treadonly type: 'ediPartyName';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\treadonly type: 'registeredID';\n\t\t\treadonly value: string;\n\t };\n\n/** A single subtree entry in a Name Constraints permitted/excluded list. */\nexport interface GeneralSubtree<\n\tTForm extends ParsedNameConstraintForm =\n\t\t| {\n\t\t\t\treadonly type: 'dns';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'email';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'uri';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'ip';\n\t\t\t\treadonly addressBytes: Uint8Array;\n\t\t\t\treadonly maskBytes: Uint8Array;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'directoryName';\n\t\t\t\treadonly derHex: string;\n\t\t },\n> {\n\t/** The name form that defines this constraint boundary. */\n\treadonly base: TForm;\n}\n\n/**\n * RFC 5280 §4.2.1.10 Name Constraints.\n *\n * A CA certificate may restrict the namespace of all subject names in\n * subsequent certificates in the path.\n */\nexport interface NameConstraints<\n\tTForm extends ParsedNameConstraintForm =\n\t\t| {\n\t\t\t\treadonly type: 'dns';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'email';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'uri';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'ip';\n\t\t\t\treadonly addressBytes: Uint8Array;\n\t\t\t\treadonly maskBytes: Uint8Array;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'directoryName';\n\t\t\t\treadonly derHex: string;\n\t\t },\n> {\n\t/** Names that MUST fall within these subtrees to be valid. */\n\treadonly permittedSubtrees?: readonly GeneralSubtree<TForm>[];\n\t/** Names that MUST NOT fall within these subtrees. Takes precedence over permitted. */\n\treadonly excludedSubtrees?: readonly GeneralSubtree<TForm>[];\n}\n\n/** Well-known AIA access methods: OCSP responder or CA issuer certificate. */\nexport type KnownAuthorityInfoAccessMethod = 'ocsp' | 'caIssuers';\n\n/** AIA access method identified by a custom OID not in the well-known set. */\nexport interface CustomAuthorityInfoAccessMethod {\n\t/** Discriminant for the custom-OID access method variant. */\n\treadonly type: 'oid';\n\t/** Dotted-decimal OID of the access method. */\n\treadonly value: string;\n}\n\n/** AIA access method — either a well-known string or a custom OID. */\nexport type AuthorityInfoAccessMethod =\n\t| KnownAuthorityInfoAccessMethod\n\t| CustomAuthorityInfoAccessMethod;\n\n/** A single entry in the Authority Information Access extension (RFC 5280 §4.2.2.1). */\nexport interface AuthorityInformationAccess {\n\t/** Access method (`'ocsp'`, `'caIssuers'`, or custom OID). */\n\treadonly method:\n\t\t| 'ocsp'\n\t\t| 'caIssuers'\n\t\t| {\n\t\t\t\treadonly type: 'oid';\n\t\t\t\treadonly value: string;\n\t\t };\n\t/** URI where the resource can be fetched. */\n\treadonly uri: string;\n}\n\n/** Well-known Extended Key Usage purpose strings (RFC 5280 §4.2.1.12). */\nexport type KnownExtendedKeyUsage =\n\t| 'serverAuth'\n\t| 'clientAuth'\n\t| 'codeSigning'\n\t| 'emailProtection'\n\t| 'timeStamping'\n\t| 'ocspSigning';\n\n/** Extended Key Usage purpose identified by a custom OID. */\nexport interface CustomExtendedKeyUsage {\n\t/** Discriminant for the custom-OID EKU variant. */\n\treadonly type: 'oid';\n\t/** Dotted-decimal OID of the usage purpose. */\n\treadonly value: string;\n}\n\n/** Extended Key Usage — either a well-known purpose string or a custom OID. */\nexport type ExtendedKeyUsage =\n\t| 'serverAuth'\n\t| 'clientAuth'\n\t| 'codeSigning'\n\t| 'emailProtection'\n\t| 'timeStamping'\n\t| 'ocspSigning'\n\t| {\n\t\t\treadonly type: 'oid';\n\t\t\treadonly value: string;\n\t };\n\n/** Map from well-known EKU names to their dotted-decimal OIDs. */\nconst EXTENDED_KEY_USAGE_OIDS: Record<KnownExtendedKeyUsage, string> = {\n\tserverAuth: OIDS.serverAuth,\n\tclientAuth: OIDS.clientAuth,\n\tcodeSigning: OIDS.codeSigning,\n\temailProtection: OIDS.emailProtection,\n\ttimeStamping: OIDS.timeStamping,\n\tocspSigning: OIDS.ocspSigning,\n};\n\n/** Map from well-known AIA method names to their dotted-decimal OIDs. */\nconst AUTHORITY_INFO_ACCESS_METHOD_OIDS: Record<KnownAuthorityInfoAccessMethod, string> = {\n\tocsp: OIDS.ocspAccessMethod,\n\tcaIssuers: OIDS.caIssuersAccessMethod,\n};\n\n/**\n * Build the v3 extensions block for a certificate.\n *\n * Automatically adds SKI, AKI (when issuer key is available), and\n * basicConstraints (defaults to `{ ca: false }`). Additional extensions\n * come from the caller's {@linkcode CertificateExtensionsInput}.\n *\n * @param subjectPublicKeyInfo DER-encoded SPKI of the subject.\n * @param issuerPublicKeyInfo DER-encoded SPKI of the issuer, or `undefined` for self-signed.\n * @param input Optional extension configuration.\n * @param subjectIsEmpty Whether the certificate subject DN is empty. When `true`, the\n * subjectAltName extension is marked critical per RFC 5280 §4.2.1.6.\n * @returns Array of DER-encoded Extension SEQUENCEs.\n */\nexport function buildCertificateExtensions(\n\tsubjectPublicKeyInfo: Uint8Array,\n\tissuerPublicKeyInfo: Uint8Array | undefined,\n\tinput: CertificateExtensionsInput | undefined,\n\tsubjectIsEmpty = false,\n): Uint8Array[] {\n\tconst extensions: Uint8Array[] = [];\n\tconst seen = new Set<string>();\n\tconst basicConstraints = input?.basicConstraints ?? { ca: false };\n\tpushKnownExtension(extensions, seen, BASIC_CONSTRAINTS_EXTENSION_DEFINITION, basicConstraints);\n\tpushKnownExtension(\n\t\textensions,\n\t\tseen,\n\t\tSUBJECT_KEY_IDENTIFIER_EXTENSION_DEFINITION,\n\t\tbuildSubjectKeyIdentifier(subjectPublicKeyInfo),\n\t);\n\tif (issuerPublicKeyInfo !== undefined) {\n\t\tpushKnownExtension(\n\t\t\textensions,\n\t\t\tseen,\n\t\t\tAUTHORITY_KEY_IDENTIFIER_EXTENSION_DEFINITION,\n\t\t\tbuildSubjectKeyIdentifier(issuerPublicKeyInfo),\n\t\t);\n\t}\n\tappendConfiguredExtensions(extensions, seen, input, 'certificate', {\n\t\tincludeBasicConstraints: false,\n\t\tsubjectIsEmpty,\n\t});\n\treturn extensions;\n}\n\n/**\n * Build the extensions for a CSR's extensionRequest attribute.\n *\n * Unlike {@linkcode buildCertificateExtensions}, SKI/AKI are not auto-generated.\n *\n * @param input Optional extension configuration.\n * @returns Array of DER-encoded Extension SEQUENCEs.\n */\nexport function buildRequestedExtensions(\n\tinput: CertificateExtensionsInput | undefined,\n): Uint8Array[] {\n\tconst extensions: Uint8Array[] = [];\n\tconst seen = new Set<string>();\n\tappendConfiguredExtensions(extensions, seen, input, 'csr', { includeBasicConstraints: true });\n\treturn extensions;\n}\n\n/** Encode and push each configured extension from the input, enforcing no duplicates. */\nfunction appendConfiguredExtensions(\n\tencoded: Uint8Array[],\n\tseen: Set<string>,\n\tinput: CertificateExtensionsInput | undefined,\n\tcontext: ExtensionRegistryContext,\n\toptions: {\n\t\treadonly includeBasicConstraints: boolean;\n\t\t/** When true, SAN is marked critical per RFC 5280 §4.2.1.6. */\n\t\treadonly subjectIsEmpty?: boolean;\n\t},\n): void {\n\tif (input === undefined) {\n\t\treturn;\n\t}\n\tif (options.includeBasicConstraints && input.basicConstraints !== undefined) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tBASIC_CONSTRAINTS_EXTENSION_DEFINITION,\n\t\t\tinput.basicConstraints,\n\t\t);\n\t}\n\tif (input.keyUsage !== undefined && input.keyUsage.length > 0) {\n\t\tpushKnownExtension(encoded, seen, KEY_USAGE_EXTENSION_DEFINITION, input.keyUsage);\n\t}\n\tif (input.subjectAltNames !== undefined && input.subjectAltNames.length > 0) {\n\t\t// RFC 5280 §4.2.1.6: SAN MUST be critical when subject DN is empty.\n\t\tconst sanCritical = options.subjectIsEmpty === true ? true : undefined;\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tSUBJECT_ALT_NAME_EXTENSION_DEFINITION,\n\t\t\tinput.subjectAltNames,\n\t\t\tsanCritical,\n\t\t);\n\t}\n\tif (input.extendedKeyUsage !== undefined && input.extendedKeyUsage.length > 0) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tEXTENDED_KEY_USAGE_EXTENSION_DEFINITION,\n\t\t\tinput.extendedKeyUsage,\n\t\t);\n\t}\n\tif (input.nameConstraints !== undefined) {\n\t\tpushKnownExtension(encoded, seen, NAME_CONSTRAINTS_EXTENSION_DEFINITION, input.nameConstraints);\n\t}\n\tif (input.certificatePolicies !== undefined && input.certificatePolicies.length > 0) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tCERTIFICATE_POLICIES_EXTENSION_DEFINITION,\n\t\t\tinput.certificatePolicies,\n\t\t);\n\t}\n\tif (input.policyMappings !== undefined && input.policyMappings.length > 0) {\n\t\tpushKnownExtension(encoded, seen, POLICY_MAPPINGS_EXTENSION_DEFINITION, input.policyMappings);\n\t}\n\tif (input.policyConstraints !== undefined) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tPOLICY_CONSTRAINTS_EXTENSION_DEFINITION,\n\t\t\tinput.policyConstraints,\n\t\t);\n\t}\n\tif (input.inhibitAnyPolicy !== undefined) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tINHIBIT_ANY_POLICY_EXTENSION_DEFINITION,\n\t\t\tinput.inhibitAnyPolicy,\n\t\t);\n\t}\n\tif (input.authorityInfoAccess !== undefined && input.authorityInfoAccess.length > 0) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tAUTHORITY_INFO_ACCESS_EXTENSION_DEFINITION,\n\t\t\tinput.authorityInfoAccess,\n\t\t);\n\t}\n\tif (input.crlDistributionPoints !== undefined && input.crlDistributionPoints.length > 0) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tCRL_DISTRIBUTION_POINTS_EXTENSION_DEFINITION,\n\t\t\tinput.crlDistributionPoints,\n\t\t);\n\t}\n\tif (input.customExtensions !== undefined) {\n\t\tfor (const extension of input.customExtensions) {\n\t\t\tconst knownDefinition = getExtensionDefinition(extension.oid);\n\t\t\tif (knownDefinition !== undefined && !knownDefinition.contexts.includes(context)) {\n\t\t\t\tthrow new Error(`Extension ${extension.oid} is not supported in ${context} context`);\n\t\t\t}\n\t\t\tpushExtension(\n\t\t\t\tencoded,\n\t\t\t\tseen,\n\t\t\t\textension.oid,\n\t\t\t\tnew Uint8Array(extension.value),\n\t\t\t\textension.critical ?? false,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Encode a known extension via its registry definition and push it. */\nfunction pushKnownExtension<TParsed, TInput>(\n\tencoded: Uint8Array[],\n\tseen: Set<string>,\n\tdefinition: ExtensionDefinition<TParsed, TInput>,\n\tvalue: TInput,\n\tcritical = definition.defaultCritical,\n): void {\n\tpushExtension(encoded, seen, definition.oid, definition.encode(value), critical);\n}\n\n/**\n * Encode a single X.509 Extension SEQUENCE (OID + optional critical BOOLEAN + OCTET STRING).\n *\n * @param oid Dotted-decimal extension OID.\n * @param extnValue DER-encoded extension payload.\n * @param critical Whether to mark the extension as critical. Default `false`.\n */\nexport function encodeExtension(oid: string, extnValue: Uint8Array, critical = false): Uint8Array {\n\tconst fields = [objectIdentifier(oid)];\n\tif (critical) {\n\t\tfields.push(bool(true));\n\t}\n\tfields.push(octetString(extnValue));\n\treturn sequence(fields);\n}\n\n/**\n * DER-encode a {@linkcode BasicConstraints} value.\n *\n * @param input CA flag and optional pathLength.\n * @returns DER SEQUENCE suitable for wrapping in an Extension OCTET STRING.\n */\nexport function encodeBasicConstraints(input: BasicConstraints): Uint8Array {\n\tconst fields: Uint8Array[] = [];\n\tif (input.ca) {\n\t\tfields.push(bool(true));\n\t}\n\tif (input.pathLength !== undefined) {\n\t\tif (!input.ca) {\n\t\t\tthrow new Error('pathLength requires ca=true');\n\t\t}\n\t\tfields.push(integerFromNumber(input.pathLength));\n\t}\n\treturn sequence(fields);\n}\n\n/**\n * DER-encode a Key Usage BIT STRING from an array of {@linkcode KeyUsage} flags.\n *\n * @param usages Flags to set in the bit string.\n */\nexport function encodeKeyUsage(usages: readonly KeyUsage[]): Uint8Array {\n\treturn encodeKeyUsageExtension(usages);\n}\n\n/**\n * DER-encode a single {@linkcode SubjectAltName} GeneralName element.\n *\n * @param value The SAN entry to encode.\n */\nexport function encodeSubjectAltName(value: SubjectAltName): Uint8Array {\n\tswitch (value.type) {\n\t\tcase 'dns':\n\t\t\treturn implicitPrimitiveContext(2, new TextEncoder().encode(value.value));\n\t\tcase 'email':\n\t\t\treturn implicitPrimitiveContext(1, new TextEncoder().encode(value.value));\n\t\tcase 'uri':\n\t\t\treturn implicitPrimitiveContext(6, new TextEncoder().encode(value.value));\n\t\tcase 'srv':\n\t\t\treturn implicitConstructedContext(\n\t\t\t\t0,\n\t\t\t\tsequence([objectIdentifier(OIDS.idOnDnsSrv), explicitContext(0, ia5String(value.value))]),\n\t\t\t);\n\t\tcase 'ip':\n\t\t\treturn implicitPrimitiveContext(7, encodeIpAddress(value.value));\n\t\tcase 'directoryName':\n\t\t\treturn implicitConstructedContext(4, extractDirectoryNameContent(value.derHex));\n\t\tcase 'unknown':\n\t\t\treturn tlv(value.tag, value.value);\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = value;\n\t\t\tthrow new Error(`Unhandled SubjectAltName type: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n\n/**\n * DER-encode an Extended Key Usage SEQUENCE OF OIDs.\n *\n * @param usages EKU purposes to encode.\n */\nexport function encodeExtendedKeyUsage(usages: readonly ExtendedKeyUsage[]): Uint8Array {\n\treturn sequence(usages.map((usage) => objectIdentifier(getExtendedKeyUsageOid(usage))));\n}\n\n/**\n * DER-encode an Authority Information Access SEQUENCE.\n *\n * @param entries AIA entries (OCSP, caIssuers, or custom) to encode.\n */\nexport function encodeAuthorityInfoAccess(\n\tentries: readonly AuthorityInformationAccess[],\n): Uint8Array {\n\treturn sequence(\n\t\tentries.map((entry) =>\n\t\t\tsequence([\n\t\t\t\tobjectIdentifier(getAuthorityInfoAccessMethodOid(entry.method)),\n\t\t\t\timplicitPrimitiveContext(6, new TextEncoder().encode(entry.uri)),\n\t\t\t]),\n\t\t),\n\t);\n}\n\n/**\n * DER-encode a CRL Distribution Points SEQUENCE.\n *\n * @param points Distribution points to encode.\n */\nexport function encodeCrlDistributionPoints(points: readonly DistributionPoint[]): Uint8Array {\n\treturn sequence(points.map((point) => sequence(encodeDistributionPoint(point))));\n}\n\n/**\n * DER-encode a Name Constraints extension value.\n *\n * @param constraints Permitted and/or excluded subtrees.\n */\nexport function encodeNameConstraints(constraints: NameConstraints): Uint8Array {\n\tconst parts: Uint8Array[] = [];\n\tif (constraints.permittedSubtrees !== undefined && constraints.permittedSubtrees.length > 0) {\n\t\tparts.push(\n\t\t\timplicitConstructedContext(\n\t\t\t\t0,\n\t\t\t\tconcatBytes(constraints.permittedSubtrees.map(encodeGeneralSubtree)),\n\t\t\t),\n\t\t);\n\t}\n\tif (constraints.excludedSubtrees !== undefined && constraints.excludedSubtrees.length > 0) {\n\t\tparts.push(\n\t\t\timplicitConstructedContext(\n\t\t\t\t1,\n\t\t\t\tconcatBytes(constraints.excludedSubtrees.map(encodeGeneralSubtree)),\n\t\t\t),\n\t\t);\n\t}\n\treturn sequence(parts);\n}\n\n/**\n * DER-encode a Certificate Policies extension value.\n *\n * @param policies Non-empty array of policy information entries.\n */\nexport function encodeCertificatePolicies(policies: CertificatePolicies): Uint8Array {\n\tif (policies.length === 0) {\n\t\tthrow new Error('certificatePolicies must not be empty');\n\t}\n\treturn sequence(policies.map(encodePolicyInformation));\n}\n\n/**\n * DER-encode a Policy Mappings extension value.\n *\n * @param mappings Non-empty array of issuer-to-subject policy pairs. Neither OID may be anyPolicy.\n */\nexport function encodePolicyMappings(mappings: PolicyMappings): Uint8Array {\n\tif (mappings.length === 0) {\n\t\tthrow new Error('policyMappings must not be empty');\n\t}\n\treturn sequence(\n\t\tmappings.map((mapping) => {\n\t\t\tvalidatePolicyOid(mapping.issuerDomainPolicy);\n\t\t\tvalidatePolicyOid(mapping.subjectDomainPolicy);\n\t\t\tif (\n\t\t\t\tmapping.issuerDomainPolicy === OIDS.anyPolicy ||\n\t\t\t\tmapping.subjectDomainPolicy === OIDS.anyPolicy\n\t\t\t) {\n\t\t\t\tthrow new Error('policyMappings must not use anyPolicy');\n\t\t\t}\n\t\t\treturn sequence([\n\t\t\t\tobjectIdentifier(mapping.issuerDomainPolicy),\n\t\t\t\tobjectIdentifier(mapping.subjectDomainPolicy),\n\t\t\t]);\n\t\t}),\n\t);\n}\n\n/**\n * DER-encode a Policy Constraints extension value.\n *\n * @param constraints At least one of `requireExplicitPolicy` or `inhibitPolicyMapping` must be set.\n */\nexport function encodePolicyConstraints(constraints: PolicyConstraints): Uint8Array {\n\tconst fields: Uint8Array[] = [];\n\tif (constraints.requireExplicitPolicy !== undefined) {\n\t\tfields.push(\n\t\t\timplicitPrimitiveContext(0, encodeIntegerContent(constraints.requireExplicitPolicy)),\n\t\t);\n\t}\n\tif (constraints.inhibitPolicyMapping !== undefined) {\n\t\tfields.push(\n\t\t\timplicitPrimitiveContext(1, encodeIntegerContent(constraints.inhibitPolicyMapping)),\n\t\t);\n\t}\n\tif (fields.length === 0) {\n\t\tthrow new Error('policyConstraints must set requireExplicitPolicy or inhibitPolicyMapping');\n\t}\n\treturn sequence(fields);\n}\n\n/**\n * DER-encode an Inhibit anyPolicy extension value (single INTEGER).\n *\n * @param input The skipCerts threshold.\n */\nexport function encodeInhibitAnyPolicy(input: InhibitAnyPolicy): Uint8Array {\n\treturn integerFromNumber(input.skipCerts);\n}\n\n/** DER-encode a single PolicyInformation SEQUENCE. */\nfunction encodePolicyInformation(policy: PolicyInformation): Uint8Array {\n\tvalidatePolicyOid(policy.policyIdentifier);\n\tconst fields = [objectIdentifier(policy.policyIdentifier)];\n\tif (policy.policyQualifiers !== undefined && policy.policyQualifiers.length > 0) {\n\t\tfields.push(sequence(policy.policyQualifiers.map(encodePolicyQualifierInfo)));\n\t}\n\treturn sequence(fields);\n}\n\n/** DER-encode a single PolicyQualifierInfo SEQUENCE. */\nfunction encodePolicyQualifierInfo(qualifier: PolicyQualifierInfo): Uint8Array {\n\tswitch (qualifier.type) {\n\t\tcase 'cps':\n\t\t\treturn sequence([objectIdentifier(OIDS.cpsPolicyQualifier), ia5String(qualifier.uri)]);\n\t\tcase 'userNotice':\n\t\t\treturn sequence([\n\t\t\t\tobjectIdentifier(OIDS.userNoticePolicyQualifier),\n\t\t\t\tencodeUserNoticePolicyQualifierInfo(qualifier),\n\t\t\t]);\n\t\tcase 'oid':\n\t\t\tvalidateOid(qualifier.oid);\n\t\t\treturn sequence([objectIdentifier(qualifier.oid), new Uint8Array(qualifier.qualifierDer)]);\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = qualifier;\n\t\t\tthrow new Error(`Unhandled PolicyQualifierInfo type: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n\n/** DER-encode a UserNotice qualifier SEQUENCE. */\nfunction encodeUserNoticePolicyQualifierInfo(qualifier: UserNoticePolicyQualifierInfo): Uint8Array {\n\tconst fields: Uint8Array[] = [];\n\tif (qualifier.noticeRef !== undefined) {\n\t\tfields.push(encodePolicyNoticeReference(qualifier.noticeRef));\n\t}\n\tif (qualifier.explicitText !== undefined) {\n\t\tfields.push(utf8String(qualifier.explicitText));\n\t}\n\treturn sequence(fields);\n}\n\n/** DER-encode a NoticeReference SEQUENCE. */\nfunction encodePolicyNoticeReference(reference: PolicyNoticeReference): Uint8Array {\n\treturn sequence([\n\t\tutf8String(reference.organization),\n\t\tsequence(reference.noticeNumbers.map((noticeNumber) => integerFromNumber(noticeNumber))),\n\t]);\n}\n\n/** Encode an INTEGER and return only the content bytes (no TLV wrapper). */\nfunction encodeIntegerContent(value: number): Uint8Array {\n\treturn readElement(integerFromNumber(value)).value;\n}\n\n/** DER-encode a GeneralSubtree SEQUENCE (base name only; min/max omitted per RFC 5280). */\nfunction encodeGeneralSubtree(subtree: GeneralSubtree): Uint8Array {\n\treturn sequence([encodeNameConstraintForm(subtree.base)]);\n}\n\n/** DER-encode the fields of a single DistributionPoint. */\nfunction encodeDistributionPoint(point: DistributionPoint): Uint8Array[] {\n\tif (point.crlIssuer !== undefined && point.crlIssuer.length === 0) {\n\t\tthrow new Error('DistributionPoint crlIssuer must not be empty');\n\t}\n\tif (point.distributionPoint === undefined && point.crlIssuer === undefined) {\n\t\tthrow new Error('DistributionPoint must contain distributionPoint or crlIssuer');\n\t}\n\tconst fields: Uint8Array[] = [];\n\tif (point.distributionPoint !== undefined) {\n\t\tfields.push(\n\t\t\timplicitConstructedContext(0, encodeDistributionPointName(point.distributionPoint)),\n\t\t);\n\t}\n\tif (point.reasons !== undefined && point.reasons.length > 0) {\n\t\tfields.push(\n\t\t\timplicitPrimitiveContext(1, encodeDistributionPointReasonFlagsContent(point.reasons)),\n\t\t);\n\t}\n\tif (point.crlIssuer !== undefined && point.crlIssuer.length > 0) {\n\t\tfields.push(\n\t\t\timplicitConstructedContext(2, concatBytes(point.crlIssuer.map(encodeSubjectAltName))),\n\t\t);\n\t}\n\treturn fields;\n}\n\n/** DER-encode a DistributionPointName (fullName or relativeName). */\nfunction encodeDistributionPointName(name: DistributionPointName): Uint8Array {\n\tif (name.fullName !== undefined && name.relativeName !== undefined) {\n\t\tthrow new Error('DistributionPointName cannot contain both fullName and relativeName');\n\t}\n\tif (name.fullName !== undefined) {\n\t\tif (name.fullName.length === 0) {\n\t\t\tthrow new Error('DistributionPointName fullName must not be empty');\n\t\t}\n\t\treturn implicitConstructedContext(0, concatBytes(name.fullName.map(encodeSubjectAltName)));\n\t}\n\tif (name.relativeName !== undefined) {\n\t\tconst relativeName = encodeRelativeDistinguishedName(name.relativeName);\n\t\tconst relativeNameElement = readElement(relativeName);\n\t\treturn implicitConstructedContext(\n\t\t\t1,\n\t\t\trelativeName.slice(relativeNameElement.start, relativeNameElement.end),\n\t\t);\n\t}\n\tthrow new Error('DistributionPointName must contain fullName or relativeName');\n}\n\n/** DER-encode a NameConstraintForm as an implicit-tagged {@linkcode GeneralName}. */\nfunction encodeNameConstraintForm(form: NameConstraintForm): Uint8Array {\n\tswitch (form.type) {\n\t\tcase 'dns':\n\t\t\treturn implicitPrimitiveContext(2, new TextEncoder().encode(form.value));\n\t\tcase 'email':\n\t\t\treturn implicitPrimitiveContext(1, new TextEncoder().encode(form.value));\n\t\tcase 'uri':\n\t\t\treturn implicitPrimitiveContext(6, new TextEncoder().encode(form.value));\n\t\tcase 'ip':\n\t\t\treturn implicitPrimitiveContext(7, concatBytes([form.addressBytes, form.maskBytes]));\n\t\tcase 'directoryName':\n\t\t\treturn implicitConstructedContext(4, extractDirectoryNameContent(form.derHex));\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = form;\n\t\t\tthrow new Error(`Unhandled NameConstraintForm type: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n\n/** Extract the content bytes from a hex-encoded DER SEQUENCE (strips the outer TLV). */\nfunction extractDirectoryNameContent(derHex: string): Uint8Array {\n\tconst element = readRootElement(hexToBytes(derHex), { maxDepth: DEFAULT_MAX_DER_DEPTH });\n\tif (element.tag !== 0x30) {\n\t\tthrow new Error('directoryName derHex must encode a DER SEQUENCE');\n\t}\n\treturn new Uint8Array(element.value);\n}\n\n/**\n * Resolve an {@linkcode ExtendedKeyUsage} to its dotted-decimal OID.\n *\n * @param usage Well-known string or custom OID object.\n */\nexport function getExtendedKeyUsageOid(usage: ExtendedKeyUsage): string {\n\tif (typeof usage === 'string') {\n\t\treturn EXTENDED_KEY_USAGE_OIDS[usage];\n\t}\n\tvalidateOid(usage.value);\n\treturn usage.value;\n}\n\n/**\n * Map a dotted-decimal OID to an {@linkcode ExtendedKeyUsage} value.\n *\n * Returns a well-known string for recognized OIDs, or `{ type: 'oid', value }` otherwise.\n */\nexport function parseExtendedKeyUsageOid(oid: string): ExtendedKeyUsage {\n\tswitch (oid) {\n\t\tcase OIDS.serverAuth:\n\t\t\treturn 'serverAuth';\n\t\tcase OIDS.clientAuth:\n\t\t\treturn 'clientAuth';\n\t\tcase OIDS.codeSigning:\n\t\t\treturn 'codeSigning';\n\t\tcase OIDS.emailProtection:\n\t\t\treturn 'emailProtection';\n\t\tcase OIDS.timeStamping:\n\t\t\treturn 'timeStamping';\n\t\tcase OIDS.ocspSigning:\n\t\t\treturn 'ocspSigning';\n\t}\n\treturn { type: 'oid', value: oid };\n}\n\n/**\n * Resolve an {@linkcode AuthorityInfoAccessMethod} to its dotted-decimal OID.\n *\n * @param method Well-known string or custom OID object.\n */\nexport function getAuthorityInfoAccessMethodOid(method: AuthorityInfoAccessMethod): string {\n\tif (typeof method === 'string') {\n\t\treturn AUTHORITY_INFO_ACCESS_METHOD_OIDS[method];\n\t}\n\tvalidateOid(method.value);\n\treturn method.value;\n}\n\n/**\n * Map a dotted-decimal OID to an {@linkcode AuthorityInfoAccessMethod} value.\n *\n * Returns `'ocsp'` or `'caIssuers'` for recognized OIDs, or `{ type: 'oid', value }` otherwise.\n */\nexport function parseAuthorityInfoAccessMethodOid(oid: string): AuthorityInfoAccessMethod {\n\tswitch (oid) {\n\t\tcase OIDS.ocspAccessMethod:\n\t\t\treturn 'ocsp';\n\t\tcase OIDS.caIssuersAccessMethod:\n\t\t\treturn 'caIssuers';\n\t}\n\treturn { type: 'oid', value: oid };\n}\n\n/** Parse a dotted-decimal/colon-hex IP string to raw address bytes. */\nfunction encodeIpAddress(input: string): Uint8Array {\n\treturn parseIpAddressToBytes(input);\n}\n\n/** @internal Compute the SKI as SHA-1 of the subjectPublicKey BIT STRING content. */\nexport function buildSubjectKeyIdentifier(subjectPublicKeyInfo: Uint8Array): Uint8Array {\n\tconst topLevel = readSequenceChildren(subjectPublicKeyInfo);\n\tconst subjectPublicKey = topLevel[1];\n\tif (subjectPublicKey === undefined || subjectPublicKey.tag !== 0x03) {\n\t\tthrow new Error('SPKI missing subject public key bit string');\n\t}\n\tconst publicKeyBytes = subjectPublicKey.value.slice(1);\n\treturn sha1(publicKeyBytes);\n}\n\n/** Throw if the string is not a valid dotted-decimal OID. */\nfunction validateOid(oid: string): void {\n\tif (!/^\\d+(?:\\.\\d+)+$/.test(oid)) {\n\t\tthrow new Error(`Invalid OID: ${oid}`);\n\t}\n}\n\n/** Validate that a policy OID is syntactically valid. */\nfunction validatePolicyOid(oid: string): void {\n\tvalidateOid(oid);\n}\n\n/** Encode and push an extension, rejecting duplicate OIDs. */\nfunction pushExtension(\n\tencoded: Uint8Array[],\n\tseen: Set<string>,\n\toid: string,\n\tvalue: Uint8Array,\n\tcritical = false,\n): void {\n\tvalidateOid(oid);\n\tif (seen.has(oid)) {\n\t\tthrow new Error(`Duplicate extension OID: ${oid}`);\n\t}\n\tseen.add(oid);\n\tencoded.push(encodeExtension(oid, value, critical));\n}\n"],"mappings":"83CA6oBA,MAAM,EAAiE,CACtE,WAAY,EAAK,WACjB,WAAY,EAAK,WACjB,YAAa,EAAK,YAClB,gBAAiB,EAAK,gBACtB,aAAc,EAAK,aACnB,YAAa,EAAK,WACnB,EAGM,EAAoF,CACzF,KAAM,EAAK,iBACX,UAAW,EAAK,qBACjB,EAgBA,SAAgB,EACf,EACA,EACA,EACA,EAAiB,GACF,CACf,IAAM,EAA2B,CAAC,EAC5B,EAAO,IAAI,IAqBjB,OAnBA,EAAmB,EAAY,EAAM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B,CAGA,SAAS,EAAY,EAAmB,CACvC,GAAI,CAAC,kBAAkB,KAAK,CAAG,EAC9B,MAAU,MAAM,gBAAgB,GAAK,CAEvC,CAGA,SAAS,EAAkB,EAAmB,CAC7C,EAAY,CAAG,CAChB,CAGA,SAAS,EACR,EACA,EACA,EACA,EACA,EAAW,GACJ,CAEP,GADA,EAAY,CAAG,EACX,EAAK,IAAI,CAAG,EACf,MAAU,MAAM,4BAA4B,GAAK,EAElD,EAAK,IAAI,CAAG,EACZ,EAAQ,KAAK,EAAgB,EAAK,EAAO,CAAQ,CAAC,CACnD"}
1
+ {"version":3,"file":"extensions.js","names":["_exhaustive"],"sources":["../../src/x509/extensions.ts"],"sourcesContent":["/**\n * Typed certificate and CSR extension model plus ASN.1 encoder helpers.\n *\n * Defines input types for every supported X.509v3 extension (RFC 5280) and\n * the DER encoders consumed by certificate and CSR builder flows.\n *\n * @module\n */\n\nimport { hexToBytes } from '#micro509/internal/asn1/asn1.ts';\nimport {\n\tbool,\n\tconcatBytes,\n\tDEFAULT_MAX_DER_DEPTH,\n\texplicitContext,\n\tia5String,\n\timplicitConstructedContext,\n\timplicitPrimitiveContext,\n\tintegerFromNumber,\n\tobjectIdentifier,\n\toctetString,\n\treadElement,\n\treadRootElement,\n\treadSequenceChildren,\n\tsequence,\n\ttlv,\n\tutf8String,\n} from '#micro509/internal/asn1/der.ts';\nimport { OIDS } from '#micro509/internal/asn1/oids.ts';\nimport { sha1 } from '#micro509/internal/crypto/hash.ts';\nimport { parseIpAddressToBytes } from '#micro509/internal/shared/ip.ts';\nimport {\n\tencodeDistributionPointReasonFlagsContent,\n\tencodeKeyUsageExtension,\n} from '#micro509/internal/x509/extension-bits.ts';\nimport type {\n\tExtensionDefinition,\n\tExtensionRegistryContext,\n} from '#micro509/internal/x509/extension-registry.ts';\nimport {\n\tAUTHORITY_INFO_ACCESS_EXTENSION_DEFINITION,\n\tAUTHORITY_KEY_IDENTIFIER_EXTENSION_DEFINITION,\n\tBASIC_CONSTRAINTS_EXTENSION_DEFINITION,\n\tCERTIFICATE_POLICIES_EXTENSION_DEFINITION,\n\tCRL_DISTRIBUTION_POINTS_EXTENSION_DEFINITION,\n\tEXTENDED_KEY_USAGE_EXTENSION_DEFINITION,\n\tgetExtensionDefinition,\n\tINHIBIT_ANY_POLICY_EXTENSION_DEFINITION,\n\tKEY_USAGE_EXTENSION_DEFINITION,\n\tNAME_CONSTRAINTS_EXTENSION_DEFINITION,\n\tPOLICY_CONSTRAINTS_EXTENSION_DEFINITION,\n\tPOLICY_MAPPINGS_EXTENSION_DEFINITION,\n\tSUBJECT_ALT_NAME_EXTENSION_DEFINITION,\n\tSUBJECT_KEY_IDENTIFIER_EXTENSION_DEFINITION,\n} from '#micro509/internal/x509/extension-registry.ts';\nimport type { RelativeDistinguishedNameInput } from './name.ts';\nimport { encodeRelativeDistinguishedName } from './name.ts';\n\nexport type { NameAttribute, NameFieldKey, RelativeDistinguishedNameInput } from './name.ts';\n\n/**\n * A decoded BIT STRING flag set.\n *\n * `flags` contains the recognized flag values with any non-zero padding bits\n * masked out. `nonZeroPadding` is `true` when the original BIT STRING encoding\n * had non-zero bits in positions that DER (X.690 §11.2.2) requires to be zero.\n * Verification layers can use this signal to reject non-conformant encodings.\n */\nexport interface ParsedBitFlags<T extends string> {\n\t/** Decoded flag values, padding bits masked. */\n\treadonly flags: readonly T[];\n\t/** `true` when the original encoding had non-zero padding bits (DER violation). */\n\treadonly nonZeroPadding: boolean;\n}\n\n/**\n * RFC 5280 §4.2.1.3 Key Usage bit flag.\n *\n * Each value corresponds to one bit in the KeyUsage BIT STRING.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.3 RFC 5280 §4.2.1.3}\n */\nexport type KeyUsage =\n\t| 'digitalSignature'\n\t| 'nonRepudiation'\n\t| 'keyEncipherment'\n\t| 'dataEncipherment'\n\t| 'keyAgreement'\n\t| 'keyCertSign'\n\t| 'cRLSign'\n\t| 'encipherOnly'\n\t| 'decipherOnly';\n\n/**\n * RFC 5280 §4.2.1.6 Subject Alternative Name / GeneralName.\n *\n * Discriminated union keyed on `type`.\n *\n * The `'unknown'` variant preserves unrecognized {@linkcode GeneralName} tags for round-trip fidelity.\n */\nexport type SubjectAltName =\n\t| {\n\t\t\t/** DNS hostname (dNSName [2]). */\n\t\t\treadonly type: 'dns';\n\t\t\t/** Fully-qualified domain name, e.g. `\"example.com\"`. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** IP address (iPAddress [7]). */\n\t\t\treadonly type: 'ip';\n\t\t\t/** Dotted-decimal IPv4 or colon-hex IPv6 string. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** Email address (rfc822Name [1]). */\n\t\t\treadonly type: 'email';\n\t\t\t/** RFC 822 mailbox, e.g. `\"admin@example.com\"`. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** URI (uniformResourceIdentifier [6]). */\n\t\t\treadonly type: 'uri';\n\t\t\t/** Absolute URI string. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** SRV-ID otherName (id-on-dnsSRV). */\n\t\t\treadonly type: 'srv';\n\t\t\t/** SRV service name, e.g. `\"_imaps.example.com\"`. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** X.500 directory name (directoryName [4]). */\n\t\t\treadonly type: 'directoryName';\n\t\t\t/** Hex-encoded DER of the Name SEQUENCE. */\n\t\t\treadonly derHex: string;\n\t }\n\t| {\n\t\t\t/** Unrecognized {@linkcode GeneralName} tag, preserved as raw bytes. */\n\t\t\treadonly type: 'unknown';\n\t\t\t/** ASN.1 context tag number. */\n\t\t\treadonly tag: number;\n\t\t\t/** Raw content bytes of the element. */\n\t\t\treadonly value: Uint8Array;\n\t };\n\n/** Alias for {@linkcode SubjectAltName} — used where RFC 5280 says \"GeneralName\". */\nexport type GeneralName = SubjectAltName;\n\n/**\n * Revocation reason flags for CRL Distribution Points and Issuing Distribution Points\n * (RFC 5280 §4.2.1.13, §5.2.5).\n */\nexport type DistributionPointReason =\n\t| 'keyCompromise'\n\t| 'cACompromise'\n\t| 'affiliationChanged'\n\t| 'superseded'\n\t| 'cessationOfOperation'\n\t| 'certificateHold'\n\t| 'privilegeWithdrawn'\n\t| 'aACompromise';\n\n/**\n * Name component of a CRL Distribution Point (RFC 5280 §4.2.1.13).\n *\n * Supply exactly one of `fullName` or `relativeName`.\n */\nexport interface DistributionPointName {\n\t/** Absolute {@linkcode GeneralName}(s) identifying the distribution point (usually a URI). */\n\treadonly fullName?: readonly GeneralName[];\n\t/** Name relative to the issuer's DN; mutually exclusive with `fullName`. */\n\treadonly relativeName?: RelativeDistinguishedNameInput;\n}\n\n/**\n * Input for a single CRL Distribution Point (RFC 5280 §4.2.1.13).\n *\n * At least one of `distributionPoint` or `crlIssuer` must be provided.\n * The union enforces this constraint at the type level.\n */\nexport type DistributionPoint =\n\t| {\n\t\t\t/** Where to fetch the CRL (fullName or relativeName). */\n\t\t\treadonly distributionPoint: DistributionPointName;\n\t\t\t/** Revocation reason subset. Absent means all reasons. */\n\t\t\treadonly reasons?: readonly DistributionPointReason[];\n\t\t\t/** Entity that signed the CRL, when different from the cert issuer. */\n\t\t\treadonly crlIssuer?: readonly GeneralName[];\n\t }\n\t| {\n\t\t\t/** Where to fetch the CRL. Optional when `crlIssuer` is present. */\n\t\t\treadonly distributionPoint?: DistributionPointName;\n\t\t\t/** Revocation reason subset. Absent means all reasons. */\n\t\t\treadonly reasons?: readonly DistributionPointReason[];\n\t\t\t/** Entity that signed the CRL. Required when `distributionPoint` is absent. */\n\t\t\treadonly crlIssuer: readonly GeneralName[];\n\t };\n\n/** Base shape for Issuing Distribution Point (RFC 5280 §5.2.5) — no scope restriction. */\nexport interface IssuingDistributionPointBase {\n\t/** Where to fetch this CRL. */\n\treadonly distributionPoint?: DistributionPointName;\n\t/** Limits the CRL to these revocation reasons. Absent means all reasons. */\n\treadonly onlySomeReasons?: readonly DistributionPointReason[];\n\t/** When true, the CRL may contain entries from other CAs. Default false. */\n\treadonly indirectCrl?: boolean;\n\t/** Must be absent or false in this variant (no user-cert-only restriction). */\n\treadonly onlyContainsUserCerts?: false;\n\t/** Must be absent or false in this variant (no CA-cert-only restriction). */\n\treadonly onlyContainsCACerts?: false;\n\t/** When true, the CRL only covers attribute certificates. Default false. */\n\treadonly onlyContainsAttributeCerts?: boolean;\n}\n\n/** IDP scoped to end-entity (user) certificates only. Mutually exclusive with CA / attribute scopes. */\nexport interface IssuingDistributionPointForUserCerts\n\textends Omit<IssuingDistributionPointBase, 'onlyContainsUserCerts'> {\n\t/** This variant only covers end-entity certificates. */\n\treadonly onlyContainsUserCerts: true;\n\t/** Must be absent or false when the CRL is not CA-only. */\n\treadonly onlyContainsCACerts?: false;\n\t/** Must be absent or false when the CRL is not attribute-cert-only. */\n\treadonly onlyContainsAttributeCerts?: false;\n}\n\n/** IDP scoped to CA certificates only. Mutually exclusive with user / attribute scopes. */\nexport interface IssuingDistributionPointForCaCerts\n\textends Omit<IssuingDistributionPointBase, 'onlyContainsCACerts'> {\n\t/** Must be absent or false when the CRL is not user-cert-only. */\n\treadonly onlyContainsUserCerts?: false;\n\t/** This variant only covers CA certificates. */\n\treadonly onlyContainsCACerts: true;\n\t/** Must be absent or false when the CRL is not attribute-cert-only. */\n\treadonly onlyContainsAttributeCerts?: false;\n}\n\n/** IDP scoped to attribute certificates only. Mutually exclusive with user / CA scopes. */\nexport interface IssuingDistributionPointForAttributeCerts\n\textends Omit<IssuingDistributionPointBase, 'onlyContainsAttributeCerts'> {\n\t/** Must be absent or false when the CRL is not user-cert-only. */\n\treadonly onlyContainsUserCerts?: false;\n\t/** Must be absent or false when the CRL is not CA-only. */\n\treadonly onlyContainsCACerts?: false;\n\t/** This variant only covers attribute certificates. */\n\treadonly onlyContainsAttributeCerts: true;\n}\n\n/**\n * Input for the Issuing Distribution Point CRL extension (RFC 5280 §5.2.5).\n *\n * The union enforces that at most one of the `onlyContains*` flags is true.\n */\nexport type IssuingDistributionPoint =\n\t| IssuingDistributionPointBase\n\t| IssuingDistributionPointForUserCerts\n\t| IssuingDistributionPointForCaCerts\n\t| IssuingDistributionPointForAttributeCerts;\n\n/**\n * RFC 5280 §4.2.1.9 Basic Constraints.\n *\n * A certificate with `ca: true` may issue other certificates; `pathLength`\n * limits how many additional CAs may appear below it in the chain.\n */\nexport type BasicConstraints =\n\t| {\n\t\t\t/** End-entity certificate: not a CA. */\n\t\t\treadonly ca: false;\n\t\t\t/** Never present on end-entity certificates. */\n\t\t\treadonly pathLength?: undefined;\n\t }\n\t| {\n\t\t\t/** CA certificate: may issue other certificates. */\n\t\t\treadonly ca: true;\n\t\t\t/** Maximum number of intermediate CA certificates allowed below this CA. */\n\t\t\treadonly pathLength?: number;\n\t };\n\n/** A single certificate policy: an OID plus optional qualifiers. */\nexport interface PolicyInformation {\n\t/** Dotted-decimal OID of the policy (e.g. `\"2.23.140.1.2.1\"` for DV). */\n\treadonly policyIdentifier: string;\n\t/** Optional CPS URIs or user notices attached to this policy. */\n\treadonly policyQualifiers?: readonly PolicyQualifierInfo[];\n}\n\n/** RFC 5280 §4.2.1.4 — array of policy OIDs with optional qualifiers. */\nexport type CertificatePolicies = readonly {\n\t/** Dotted-decimal OID of the policy (e.g. `\"2.23.140.1.2.1\"` for DV). */\n\treadonly policyIdentifier: string;\n\t/** Optional CPS URIs or user notices attached to this policy. */\n\treadonly policyQualifiers?: readonly (\n\t\t| {\n\t\t\t\treadonly type: 'cps';\n\t\t\t\treadonly uri: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'userNotice';\n\t\t\t\treadonly noticeRef?: {\n\t\t\t\t\treadonly organization: string;\n\t\t\t\t\treadonly noticeNumbers: readonly number[];\n\t\t\t\t};\n\t\t\t\treadonly explicitText?: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'oid';\n\t\t\t\treadonly oid: string;\n\t\t\t\treadonly qualifierDer: Uint8Array;\n\t\t }\n\t)[];\n}[];\n\n/** CPS (Certification Practice Statement) URI policy qualifier. */\nexport interface CpsPolicyQualifierInfo {\n\t/** Discriminant for the `'cps'` qualifier variant. */\n\treadonly type: 'cps';\n\t/** URL of the Certification Practice Statement document. */\n\treadonly uri: string;\n}\n\n/** Reference to a numbered notice within an organization's practice statement. */\nexport interface PolicyNoticeReference {\n\t/** Organization name that published the notice. */\n\treadonly organization: string;\n\t/** One-based notice numbers within that organization's documentation. */\n\treadonly noticeNumbers: readonly number[];\n}\n\n/** UserNotice policy qualifier — human-readable notice text and/or a notice reference. */\nexport interface UserNoticePolicyQualifierInfo {\n\t/** Discriminant for the `'userNotice'` qualifier variant. */\n\treadonly type: 'userNotice';\n\t/** Pointer to a numbered notice in an organization's practice statement. */\n\treadonly noticeRef?: PolicyNoticeReference;\n\t/** Free-form text to display to relying parties. */\n\treadonly explicitText?: string;\n}\n\n/** Opaque policy qualifier identified by a custom OID, carried as raw DER. */\nexport interface CustomPolicyQualifierInfo {\n\t/** Discriminant for the custom-OID qualifier variant. */\n\treadonly type: 'oid';\n\t/** Dotted-decimal OID of the qualifier. */\n\treadonly oid: string;\n\t/** DER-encoded qualifier payload. */\n\treadonly qualifierDer: Uint8Array;\n}\n\n/** Discriminated union of all supported policy qualifier types. */\nexport type PolicyQualifierInfo =\n\t| CpsPolicyQualifierInfo\n\t| UserNoticePolicyQualifierInfo\n\t| CustomPolicyQualifierInfo;\n\n/** Maps a policy OID in the issuer's domain to an equivalent OID in the subject's domain. */\nexport interface PolicyMapping {\n\t/** Policy OID as defined by the issuing CA. Must not be anyPolicy. */\n\treadonly issuerDomainPolicy: string;\n\t/** Equivalent policy OID in the subject CA's domain. Must not be anyPolicy. */\n\treadonly subjectDomainPolicy: string;\n}\n\n/** RFC 5280 §4.2.1.5 — array of issuer-to-subject policy OID pairs. */\nexport type PolicyMappings = readonly {\n\t/** Policy OID as defined by the issuing CA. Must not be anyPolicy. */\n\treadonly issuerDomainPolicy: string;\n\t/** Equivalent policy OID in the subject CA's domain. Must not be anyPolicy. */\n\treadonly subjectDomainPolicy: string;\n}[];\n\n/**\n * RFC 5280 §4.2.1.11 Policy Constraints.\n *\n * At least one field must be present. Values are certificate-count\n * thresholds measured from the current certificate toward the end entity.\n */\nexport interface PolicyConstraints {\n\t/** After this many certificates, an acceptable policy must be in the path. */\n\treadonly requireExplicitPolicy?: number;\n\t/** After this many certificates, policy mapping is no longer allowed. */\n\treadonly inhibitPolicyMapping?: number;\n}\n\n/**\n * RFC 5280 §4.2.1.14 Inhibit anyPolicy.\n *\n * After `skipCerts` additional certificates in the path, the special\n * anyPolicy OID is no longer considered a match.\n */\nexport interface InhibitAnyPolicy {\n\t/** Number of additional certificates before anyPolicy stops being valid. */\n\treadonly skipCerts: number;\n}\n\n/**\n * Input for `createCertificate`, `createSelfSignedCertificate`,\n * and `createCertificateSigningRequest`.\n *\n * Every field is optional. Omitted extensions are not encoded. Built-in\n * extensions (SKI, AKI, basicConstraints defaults) are handled automatically\n * by the builder.\n */\nexport interface CertificateExtensionsInput {\n\t/** Subject Alternative Names (dns, ip, email, uri, srv, directoryName). */\n\treadonly subjectAltNames?: readonly SubjectAltName[];\n\t/** Key Usage flags (digitalSignature, keyCertSign, etc.). */\n\treadonly keyUsage?: readonly KeyUsage[];\n\t/** Basic Constraints (CA flag + optional pathLength). Defaults to `{ ca: false }` for certs. */\n\treadonly basicConstraints?: BasicConstraints;\n\t/** Extended Key Usage purposes (serverAuth, clientAuth, etc.). */\n\treadonly extendedKeyUsage?: readonly ExtendedKeyUsage[];\n\t/** Name Constraints — permitted and/or excluded subtrees. */\n\treadonly nameConstraints?: NameConstraints;\n\t/** Certificate Policies with optional qualifiers. */\n\treadonly certificatePolicies?: CertificatePolicies;\n\t/** Policy Mappings between issuer and subject policy domains. */\n\treadonly policyMappings?: PolicyMappings;\n\t/** Policy Constraints (requireExplicitPolicy / inhibitPolicyMapping thresholds). */\n\treadonly policyConstraints?: PolicyConstraints;\n\t/** Inhibit anyPolicy skip-certs threshold. */\n\treadonly inhibitAnyPolicy?: InhibitAnyPolicy;\n\t/** Authority Information Access — OCSP responder and CA issuer URIs. */\n\treadonly authorityInfoAccess?: readonly AuthorityInformationAccess[];\n\t/** CRL Distribution Points — where to check revocation status. */\n\treadonly crlDistributionPoints?: readonly DistributionPoint[];\n\t/** Arbitrary extensions not covered by the built-in fields. */\n\treadonly customExtensions?: readonly CustomExtension[];\n}\n\n/** An extension not covered by the typed fields in {@linkcode CertificateExtensionsInput}. */\nexport interface CustomExtension {\n\t/** Dotted-decimal OID of the extension. */\n\treadonly oid: string;\n\t/** Pre-encoded DER content for the extnValue OCTET STRING. */\n\treadonly value: Uint8Array;\n\t/** Whether the extension is critical. Default `false`. */\n\treadonly critical?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Name constraints (RFC 5280 §4.2.1.10)\n// ---------------------------------------------------------------------------\n\n/**\n * A name form used as a constraint base in namEConstraints.\n * Distinct from {@linkcode SubjectAltName} because IP constraints carry\n * address + mask bytes (8 for IPv4, 32 for IPv6) rather than bare addresses.\n */\nexport type NameConstraintForm =\n\t| {\n\t\t\t/** DNS domain constraint (dNSName [2]). */\n\t\t\treadonly type: 'dns';\n\t\t\t/** Domain suffix, e.g. `\".example.com\"` or `\"example.com\"`. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** Email constraint (rfc822Name [1]). */\n\t\t\treadonly type: 'email';\n\t\t\t/** Email domain or full address pattern. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** URI constraint (uniformResourceIdentifier [6]). */\n\t\t\treadonly type: 'uri';\n\t\t\t/** Host or domain component of a URI. */\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\t/** IP range constraint (iPAddress [7]). */\n\t\t\treadonly type: 'ip';\n\t\t\t/** Network address bytes (4 for IPv4, 16 for IPv6). */\n\t\t\treadonly addressBytes: Uint8Array;\n\t\t\t/** Subnet mask bytes (same length as addressBytes). */\n\t\t\treadonly maskBytes: Uint8Array;\n\t }\n\t| {\n\t\t\t/** Directory name constraint (directoryName [4]). */\n\t\t\treadonly type: 'directoryName';\n\t\t\t/** Hex-encoded DER of the Name SEQUENCE. */\n\t\t\treadonly derHex: string;\n\t };\n\n/**\n * Name constraint forms parsed from DER but not supported for encoding or\n * validation. Preserved for diagnostic round-tripping.\n */\nexport type UnsupportedNameConstraintForm =\n\t| {\n\t\t\t/** otherName [0] — raw bytes. */\n\t\t\treadonly type: 'otherName';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\t/** x400Address [3] — raw bytes. */\n\t\t\treadonly type: 'x400Address';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\t/** ediPartyName [5] — raw bytes. */\n\t\t\treadonly type: 'ediPartyName';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\t/** registeredID [8] — decoded OID string. */\n\t\t\treadonly type: 'registeredID';\n\t\t\treadonly value: string;\n\t };\n\n/** Union of supported and unsupported name constraint forms as produced by parsing. */\nexport type ParsedNameConstraintForm =\n\t| {\n\t\t\treadonly type: 'dns';\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\treadonly type: 'email';\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\treadonly type: 'uri';\n\t\t\treadonly value: string;\n\t }\n\t| {\n\t\t\treadonly type: 'ip';\n\t\t\treadonly addressBytes: Uint8Array;\n\t\t\treadonly maskBytes: Uint8Array;\n\t }\n\t| {\n\t\t\treadonly type: 'directoryName';\n\t\t\treadonly derHex: string;\n\t }\n\t| {\n\t\t\treadonly type: 'otherName';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\treadonly type: 'x400Address';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\treadonly type: 'ediPartyName';\n\t\t\treadonly value: Uint8Array;\n\t }\n\t| {\n\t\t\treadonly type: 'registeredID';\n\t\t\treadonly value: string;\n\t };\n\n/** A single subtree entry in a Name Constraints permitted/excluded list. */\nexport interface GeneralSubtree<\n\tTForm extends ParsedNameConstraintForm =\n\t\t| {\n\t\t\t\treadonly type: 'dns';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'email';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'uri';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'ip';\n\t\t\t\treadonly addressBytes: Uint8Array;\n\t\t\t\treadonly maskBytes: Uint8Array;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'directoryName';\n\t\t\t\treadonly derHex: string;\n\t\t },\n> {\n\t/** The name form that defines this constraint boundary. */\n\treadonly base: TForm;\n}\n\n/**\n * RFC 5280 §4.2.1.10 Name Constraints.\n *\n * A CA certificate may restrict the namespace of all subject names in\n * subsequent certificates in the path.\n */\nexport interface NameConstraints<\n\tTForm extends ParsedNameConstraintForm =\n\t\t| {\n\t\t\t\treadonly type: 'dns';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'email';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'uri';\n\t\t\t\treadonly value: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'ip';\n\t\t\t\treadonly addressBytes: Uint8Array;\n\t\t\t\treadonly maskBytes: Uint8Array;\n\t\t }\n\t\t| {\n\t\t\t\treadonly type: 'directoryName';\n\t\t\t\treadonly derHex: string;\n\t\t },\n> {\n\t/** Names that MUST fall within these subtrees to be valid. */\n\treadonly permittedSubtrees?: readonly GeneralSubtree<TForm>[];\n\t/** Names that MUST NOT fall within these subtrees. Takes precedence over permitted. */\n\treadonly excludedSubtrees?: readonly GeneralSubtree<TForm>[];\n}\n\n/** Well-known AIA access methods: OCSP responder or CA issuer certificate. */\nexport type KnownAuthorityInfoAccessMethod = 'ocsp' | 'caIssuers';\n\n/** AIA access method identified by a custom OID not in the well-known set. */\nexport interface CustomAuthorityInfoAccessMethod {\n\t/** Discriminant for the custom-OID access method variant. */\n\treadonly type: 'oid';\n\t/** Dotted-decimal OID of the access method. */\n\treadonly value: string;\n}\n\n/** AIA access method — either a well-known string or a custom OID. */\nexport type AuthorityInfoAccessMethod =\n\t| KnownAuthorityInfoAccessMethod\n\t| CustomAuthorityInfoAccessMethod;\n\n/** A single entry in the Authority Information Access extension (RFC 5280 §4.2.2.1). */\nexport interface AuthorityInformationAccess {\n\t/** Access method (`'ocsp'`, `'caIssuers'`, or custom OID). */\n\treadonly method:\n\t\t| 'ocsp'\n\t\t| 'caIssuers'\n\t\t| {\n\t\t\t\treadonly type: 'oid';\n\t\t\t\treadonly value: string;\n\t\t };\n\t/** URI where the resource can be fetched. */\n\treadonly uri: string;\n}\n\n/** Well-known Extended Key Usage purpose strings (RFC 5280 §4.2.1.12). */\nexport type KnownExtendedKeyUsage =\n\t| 'serverAuth'\n\t| 'clientAuth'\n\t| 'codeSigning'\n\t| 'emailProtection'\n\t| 'timeStamping'\n\t| 'ocspSigning';\n\n/** Extended Key Usage purpose identified by a custom OID. */\nexport interface CustomExtendedKeyUsage {\n\t/** Discriminant for the custom-OID EKU variant. */\n\treadonly type: 'oid';\n\t/** Dotted-decimal OID of the usage purpose. */\n\treadonly value: string;\n}\n\n/** Extended Key Usage — either a well-known purpose string or a custom OID. */\nexport type ExtendedKeyUsage =\n\t| 'serverAuth'\n\t| 'clientAuth'\n\t| 'codeSigning'\n\t| 'emailProtection'\n\t| 'timeStamping'\n\t| 'ocspSigning'\n\t| {\n\t\t\treadonly type: 'oid';\n\t\t\treadonly value: string;\n\t };\n\n/** Map from well-known EKU names to their dotted-decimal OIDs. */\nconst EXTENDED_KEY_USAGE_OIDS: Record<KnownExtendedKeyUsage, string> = {\n\tserverAuth: OIDS.serverAuth,\n\tclientAuth: OIDS.clientAuth,\n\tcodeSigning: OIDS.codeSigning,\n\temailProtection: OIDS.emailProtection,\n\ttimeStamping: OIDS.timeStamping,\n\tocspSigning: OIDS.ocspSigning,\n};\n\n/** Map from well-known AIA method names to their dotted-decimal OIDs. */\nconst AUTHORITY_INFO_ACCESS_METHOD_OIDS: Record<KnownAuthorityInfoAccessMethod, string> = {\n\tocsp: OIDS.ocspAccessMethod,\n\tcaIssuers: OIDS.caIssuersAccessMethod,\n};\n\n/**\n * Build the v3 extensions block for a certificate.\n *\n * Automatically adds SKI, AKI (when issuer key is available), and\n * basicConstraints (defaults to `{ ca: false }`). Additional extensions\n * come from the caller's {@linkcode CertificateExtensionsInput}.\n *\n * @param subjectPublicKeyInfo DER-encoded SPKI of the subject.\n * @param issuerPublicKeyInfo DER-encoded SPKI of the issuer, or `undefined` for self-signed.\n * @param input Optional extension configuration.\n * @param subjectIsEmpty Whether the certificate subject DN is empty. When `true`, the\n * subjectAltName extension is marked critical per RFC 5280 §4.2.1.6.\n * @returns Array of DER-encoded Extension SEQUENCEs.\n */\nexport function buildCertificateExtensions(\n\tsubjectPublicKeyInfo: Uint8Array,\n\tissuerPublicKeyInfo: Uint8Array | undefined,\n\tinput: CertificateExtensionsInput | undefined,\n\tsubjectIsEmpty = false,\n): Uint8Array[] {\n\tconst extensions: Uint8Array[] = [];\n\tconst seen = new Set<string>();\n\tconst basicConstraints = input?.basicConstraints ?? { ca: false };\n\tpushKnownExtension(extensions, seen, BASIC_CONSTRAINTS_EXTENSION_DEFINITION, basicConstraints);\n\tpushKnownExtension(\n\t\textensions,\n\t\tseen,\n\t\tSUBJECT_KEY_IDENTIFIER_EXTENSION_DEFINITION,\n\t\tbuildSubjectKeyIdentifier(subjectPublicKeyInfo),\n\t);\n\tif (issuerPublicKeyInfo !== undefined) {\n\t\tpushKnownExtension(\n\t\t\textensions,\n\t\t\tseen,\n\t\t\tAUTHORITY_KEY_IDENTIFIER_EXTENSION_DEFINITION,\n\t\t\tbuildSubjectKeyIdentifier(issuerPublicKeyInfo),\n\t\t);\n\t}\n\tappendConfiguredExtensions(extensions, seen, input, 'certificate', {\n\t\tincludeBasicConstraints: false,\n\t\tsubjectIsEmpty,\n\t});\n\treturn extensions;\n}\n\n/**\n * Build the extensions for a CSR's extensionRequest attribute.\n *\n * Unlike {@linkcode buildCertificateExtensions}, SKI/AKI are not auto-generated.\n *\n * @param input Optional extension configuration.\n * @returns Array of DER-encoded Extension SEQUENCEs.\n */\nexport function buildRequestedExtensions(\n\tinput: CertificateExtensionsInput | undefined,\n): Uint8Array[] {\n\tconst extensions: Uint8Array[] = [];\n\tconst seen = new Set<string>();\n\tappendConfiguredExtensions(extensions, seen, input, 'csr', { includeBasicConstraints: true });\n\treturn extensions;\n}\n\n/** Encode and push each configured extension from the input, enforcing no duplicates. */\nfunction appendConfiguredExtensions(\n\tencoded: Uint8Array[],\n\tseen: Set<string>,\n\tinput: CertificateExtensionsInput | undefined,\n\tcontext: ExtensionRegistryContext,\n\toptions: {\n\t\treadonly includeBasicConstraints: boolean;\n\t\t/** When true, SAN is marked critical per RFC 5280 §4.2.1.6. */\n\t\treadonly subjectIsEmpty?: boolean;\n\t},\n): void {\n\tif (input === undefined) {\n\t\treturn;\n\t}\n\tif (options.includeBasicConstraints && input.basicConstraints !== undefined) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tBASIC_CONSTRAINTS_EXTENSION_DEFINITION,\n\t\t\tinput.basicConstraints,\n\t\t);\n\t}\n\tif (input.keyUsage !== undefined && input.keyUsage.length > 0) {\n\t\tpushKnownExtension(encoded, seen, KEY_USAGE_EXTENSION_DEFINITION, input.keyUsage);\n\t}\n\tif (input.subjectAltNames !== undefined && input.subjectAltNames.length > 0) {\n\t\t// RFC 5280 §4.2.1.6: SAN MUST be critical when subject DN is empty.\n\t\tconst sanCritical = options.subjectIsEmpty === true ? true : undefined;\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tSUBJECT_ALT_NAME_EXTENSION_DEFINITION,\n\t\t\tinput.subjectAltNames,\n\t\t\tsanCritical,\n\t\t);\n\t}\n\tif (input.extendedKeyUsage !== undefined && input.extendedKeyUsage.length > 0) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tEXTENDED_KEY_USAGE_EXTENSION_DEFINITION,\n\t\t\tinput.extendedKeyUsage,\n\t\t);\n\t}\n\tif (input.nameConstraints !== undefined) {\n\t\tpushKnownExtension(encoded, seen, NAME_CONSTRAINTS_EXTENSION_DEFINITION, input.nameConstraints);\n\t}\n\tif (input.certificatePolicies !== undefined && input.certificatePolicies.length > 0) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tCERTIFICATE_POLICIES_EXTENSION_DEFINITION,\n\t\t\tinput.certificatePolicies,\n\t\t);\n\t}\n\tif (input.policyMappings !== undefined && input.policyMappings.length > 0) {\n\t\tpushKnownExtension(encoded, seen, POLICY_MAPPINGS_EXTENSION_DEFINITION, input.policyMappings);\n\t}\n\tif (input.policyConstraints !== undefined) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tPOLICY_CONSTRAINTS_EXTENSION_DEFINITION,\n\t\t\tinput.policyConstraints,\n\t\t);\n\t}\n\tif (input.inhibitAnyPolicy !== undefined) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tINHIBIT_ANY_POLICY_EXTENSION_DEFINITION,\n\t\t\tinput.inhibitAnyPolicy,\n\t\t);\n\t}\n\tif (input.authorityInfoAccess !== undefined && input.authorityInfoAccess.length > 0) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tAUTHORITY_INFO_ACCESS_EXTENSION_DEFINITION,\n\t\t\tinput.authorityInfoAccess,\n\t\t);\n\t}\n\tif (input.crlDistributionPoints !== undefined && input.crlDistributionPoints.length > 0) {\n\t\tpushKnownExtension(\n\t\t\tencoded,\n\t\t\tseen,\n\t\t\tCRL_DISTRIBUTION_POINTS_EXTENSION_DEFINITION,\n\t\t\tinput.crlDistributionPoints,\n\t\t);\n\t}\n\tif (input.customExtensions !== undefined) {\n\t\tfor (const extension of input.customExtensions) {\n\t\t\tconst knownDefinition = getExtensionDefinition(extension.oid);\n\t\t\tif (knownDefinition !== undefined && !knownDefinition.contexts.includes(context)) {\n\t\t\t\tthrow new Error(`Extension ${extension.oid} is not supported in ${context} context`);\n\t\t\t}\n\t\t\tpushExtension(\n\t\t\t\tencoded,\n\t\t\t\tseen,\n\t\t\t\textension.oid,\n\t\t\t\tnew Uint8Array(extension.value),\n\t\t\t\textension.critical ?? false,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Encode a known extension via its registry definition and push it. */\nfunction pushKnownExtension<TParsed, TInput>(\n\tencoded: Uint8Array[],\n\tseen: Set<string>,\n\tdefinition: ExtensionDefinition<TParsed, TInput>,\n\tvalue: TInput,\n\tcritical = definition.defaultCritical,\n): void {\n\tpushExtension(encoded, seen, definition.oid, definition.encode(value), critical);\n}\n\n/**\n * Encode a single X.509 Extension SEQUENCE (OID + optional critical BOOLEAN + OCTET STRING).\n *\n * @param oid Dotted-decimal extension OID.\n * @param extnValue DER-encoded extension payload.\n * @param critical Whether to mark the extension as critical. Default `false`.\n */\nexport function encodeExtension(oid: string, extnValue: Uint8Array, critical = false): Uint8Array {\n\tconst fields = [objectIdentifier(oid)];\n\tif (critical) {\n\t\tfields.push(bool(true));\n\t}\n\tfields.push(octetString(extnValue));\n\treturn sequence(fields);\n}\n\n/**\n * DER-encode a {@linkcode BasicConstraints} value.\n *\n * @param input CA flag and optional pathLength.\n * @returns DER SEQUENCE suitable for wrapping in an Extension OCTET STRING.\n */\nexport function encodeBasicConstraints(input: BasicConstraints): Uint8Array {\n\tconst fields: Uint8Array[] = [];\n\tif (input.ca) {\n\t\tfields.push(bool(true));\n\t}\n\tif (input.pathLength !== undefined) {\n\t\tif (!input.ca) {\n\t\t\tthrow new Error('pathLength requires ca=true');\n\t\t}\n\t\tfields.push(integerFromNumber(input.pathLength));\n\t}\n\treturn sequence(fields);\n}\n\n/**\n * DER-encode a Key Usage BIT STRING from an array of {@linkcode KeyUsage} flags.\n *\n * @param usages Flags to set in the bit string.\n */\nexport function encodeKeyUsage(usages: readonly KeyUsage[]): Uint8Array {\n\treturn encodeKeyUsageExtension(usages);\n}\n\n/**\n * DER-encode a single {@linkcode SubjectAltName} GeneralName element.\n *\n * @param value The SAN entry to encode.\n */\nexport function encodeSubjectAltName(value: SubjectAltName): Uint8Array {\n\tswitch (value.type) {\n\t\tcase 'dns':\n\t\t\treturn implicitPrimitiveContext(2, new TextEncoder().encode(value.value));\n\t\tcase 'email':\n\t\t\treturn implicitPrimitiveContext(1, new TextEncoder().encode(value.value));\n\t\tcase 'uri':\n\t\t\treturn implicitPrimitiveContext(6, new TextEncoder().encode(value.value));\n\t\tcase 'srv':\n\t\t\treturn implicitConstructedContext(\n\t\t\t\t0,\n\t\t\t\tsequence([objectIdentifier(OIDS.idOnDnsSrv), explicitContext(0, ia5String(value.value))]),\n\t\t\t);\n\t\tcase 'ip':\n\t\t\treturn implicitPrimitiveContext(7, encodeIpAddress(value.value));\n\t\tcase 'directoryName':\n\t\t\treturn implicitConstructedContext(4, extractDirectoryNameContent(value.derHex));\n\t\tcase 'unknown':\n\t\t\treturn tlv(value.tag, value.value);\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = value;\n\t\t\tthrow new Error(`Unhandled SubjectAltName type: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n\n/**\n * DER-encode an Extended Key Usage SEQUENCE OF OIDs.\n *\n * @param usages EKU purposes to encode.\n */\nexport function encodeExtendedKeyUsage(usages: readonly ExtendedKeyUsage[]): Uint8Array {\n\treturn sequence(usages.map((usage) => objectIdentifier(getExtendedKeyUsageOid(usage))));\n}\n\n/**\n * DER-encode an Authority Information Access SEQUENCE.\n *\n * @param entries AIA entries (OCSP, caIssuers, or custom) to encode.\n */\nexport function encodeAuthorityInfoAccess(\n\tentries: readonly AuthorityInformationAccess[],\n): Uint8Array {\n\treturn sequence(\n\t\tentries.map((entry) =>\n\t\t\tsequence([\n\t\t\t\tobjectIdentifier(getAuthorityInfoAccessMethodOid(entry.method)),\n\t\t\t\timplicitPrimitiveContext(6, new TextEncoder().encode(entry.uri)),\n\t\t\t]),\n\t\t),\n\t);\n}\n\n/**\n * DER-encode a CRL Distribution Points SEQUENCE.\n *\n * @param points Distribution points to encode.\n */\nexport function encodeCrlDistributionPoints(points: readonly DistributionPoint[]): Uint8Array {\n\treturn sequence(points.map((point) => sequence(encodeDistributionPoint(point))));\n}\n\n/**\n * DER-encode a Name Constraints extension value.\n *\n * @param constraints Permitted and/or excluded subtrees.\n */\nexport function encodeNameConstraints(constraints: NameConstraints): Uint8Array {\n\tconst parts: Uint8Array[] = [];\n\tif (constraints.permittedSubtrees !== undefined && constraints.permittedSubtrees.length > 0) {\n\t\tparts.push(\n\t\t\timplicitConstructedContext(\n\t\t\t\t0,\n\t\t\t\tconcatBytes(constraints.permittedSubtrees.map(encodeGeneralSubtree)),\n\t\t\t),\n\t\t);\n\t}\n\tif (constraints.excludedSubtrees !== undefined && constraints.excludedSubtrees.length > 0) {\n\t\tparts.push(\n\t\t\timplicitConstructedContext(\n\t\t\t\t1,\n\t\t\t\tconcatBytes(constraints.excludedSubtrees.map(encodeGeneralSubtree)),\n\t\t\t),\n\t\t);\n\t}\n\treturn sequence(parts);\n}\n\n/**\n * DER-encode a Certificate Policies extension value.\n *\n * @param policies Non-empty array of policy information entries.\n */\nexport function encodeCertificatePolicies(policies: CertificatePolicies): Uint8Array {\n\tif (policies.length === 0) {\n\t\tthrow new Error('certificatePolicies must not be empty');\n\t}\n\treturn sequence(policies.map(encodePolicyInformation));\n}\n\n/**\n * DER-encode a Policy Mappings extension value.\n *\n * @param mappings Non-empty array of issuer-to-subject policy pairs. Neither OID may be anyPolicy.\n */\nexport function encodePolicyMappings(mappings: PolicyMappings): Uint8Array {\n\tif (mappings.length === 0) {\n\t\tthrow new Error('policyMappings must not be empty');\n\t}\n\treturn sequence(\n\t\tmappings.map((mapping) => {\n\t\t\tvalidatePolicyOid(mapping.issuerDomainPolicy);\n\t\t\tvalidatePolicyOid(mapping.subjectDomainPolicy);\n\t\t\tif (\n\t\t\t\tmapping.issuerDomainPolicy === OIDS.anyPolicy ||\n\t\t\t\tmapping.subjectDomainPolicy === OIDS.anyPolicy\n\t\t\t) {\n\t\t\t\tthrow new Error('policyMappings must not use anyPolicy');\n\t\t\t}\n\t\t\treturn sequence([\n\t\t\t\tobjectIdentifier(mapping.issuerDomainPolicy),\n\t\t\t\tobjectIdentifier(mapping.subjectDomainPolicy),\n\t\t\t]);\n\t\t}),\n\t);\n}\n\n/**\n * DER-encode a Policy Constraints extension value.\n *\n * @param constraints At least one of `requireExplicitPolicy` or `inhibitPolicyMapping` must be set.\n */\nexport function encodePolicyConstraints(constraints: PolicyConstraints): Uint8Array {\n\tconst fields: Uint8Array[] = [];\n\tif (constraints.requireExplicitPolicy !== undefined) {\n\t\tfields.push(\n\t\t\timplicitPrimitiveContext(0, encodeIntegerContent(constraints.requireExplicitPolicy)),\n\t\t);\n\t}\n\tif (constraints.inhibitPolicyMapping !== undefined) {\n\t\tfields.push(\n\t\t\timplicitPrimitiveContext(1, encodeIntegerContent(constraints.inhibitPolicyMapping)),\n\t\t);\n\t}\n\tif (fields.length === 0) {\n\t\tthrow new Error('policyConstraints must set requireExplicitPolicy or inhibitPolicyMapping');\n\t}\n\treturn sequence(fields);\n}\n\n/**\n * DER-encode an Inhibit anyPolicy extension value (single INTEGER).\n *\n * @param input The skipCerts threshold.\n */\nexport function encodeInhibitAnyPolicy(input: InhibitAnyPolicy): Uint8Array {\n\treturn integerFromNumber(input.skipCerts);\n}\n\n/** DER-encode a single PolicyInformation SEQUENCE. */\nfunction encodePolicyInformation(policy: PolicyInformation): Uint8Array {\n\tvalidatePolicyOid(policy.policyIdentifier);\n\tconst fields = [objectIdentifier(policy.policyIdentifier)];\n\tif (policy.policyQualifiers !== undefined && policy.policyQualifiers.length > 0) {\n\t\tfields.push(sequence(policy.policyQualifiers.map(encodePolicyQualifierInfo)));\n\t}\n\treturn sequence(fields);\n}\n\n/** DER-encode a single PolicyQualifierInfo SEQUENCE. */\nfunction encodePolicyQualifierInfo(qualifier: PolicyQualifierInfo): Uint8Array {\n\tswitch (qualifier.type) {\n\t\tcase 'cps':\n\t\t\treturn sequence([objectIdentifier(OIDS.cpsPolicyQualifier), ia5String(qualifier.uri)]);\n\t\tcase 'userNotice':\n\t\t\treturn sequence([\n\t\t\t\tobjectIdentifier(OIDS.userNoticePolicyQualifier),\n\t\t\t\tencodeUserNoticePolicyQualifierInfo(qualifier),\n\t\t\t]);\n\t\tcase 'oid':\n\t\t\tvalidateOid(qualifier.oid);\n\t\t\treturn sequence([objectIdentifier(qualifier.oid), new Uint8Array(qualifier.qualifierDer)]);\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = qualifier;\n\t\t\tthrow new Error(`Unhandled PolicyQualifierInfo type: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n\n/** DER-encode a UserNotice qualifier SEQUENCE. */\nfunction encodeUserNoticePolicyQualifierInfo(qualifier: UserNoticePolicyQualifierInfo): Uint8Array {\n\tconst fields: Uint8Array[] = [];\n\tif (qualifier.noticeRef !== undefined) {\n\t\tfields.push(encodePolicyNoticeReference(qualifier.noticeRef));\n\t}\n\tif (qualifier.explicitText !== undefined) {\n\t\tfields.push(utf8String(qualifier.explicitText));\n\t}\n\treturn sequence(fields);\n}\n\n/** DER-encode a NoticeReference SEQUENCE. */\nfunction encodePolicyNoticeReference(reference: PolicyNoticeReference): Uint8Array {\n\treturn sequence([\n\t\tutf8String(reference.organization),\n\t\tsequence(reference.noticeNumbers.map((noticeNumber) => integerFromNumber(noticeNumber))),\n\t]);\n}\n\n/** Encode an INTEGER and return only the content bytes (no TLV wrapper). */\nfunction encodeIntegerContent(value: number): Uint8Array {\n\treturn readElement(integerFromNumber(value)).value;\n}\n\n/** DER-encode a GeneralSubtree SEQUENCE (base name only; min/max omitted per RFC 5280). */\nfunction encodeGeneralSubtree(subtree: GeneralSubtree): Uint8Array {\n\treturn sequence([encodeNameConstraintForm(subtree.base)]);\n}\n\n/** DER-encode the fields of a single DistributionPoint. */\nfunction encodeDistributionPoint(point: DistributionPoint): Uint8Array[] {\n\tif (point.crlIssuer !== undefined && point.crlIssuer.length === 0) {\n\t\tthrow new Error('DistributionPoint crlIssuer must not be empty');\n\t}\n\tif (point.distributionPoint === undefined && point.crlIssuer === undefined) {\n\t\tthrow new Error('DistributionPoint must contain distributionPoint or crlIssuer');\n\t}\n\tconst fields: Uint8Array[] = [];\n\tif (point.distributionPoint !== undefined) {\n\t\tfields.push(\n\t\t\timplicitConstructedContext(0, encodeDistributionPointName(point.distributionPoint)),\n\t\t);\n\t}\n\tif (point.reasons !== undefined && point.reasons.length > 0) {\n\t\tfields.push(\n\t\t\timplicitPrimitiveContext(1, encodeDistributionPointReasonFlagsContent(point.reasons)),\n\t\t);\n\t}\n\tif (point.crlIssuer !== undefined && point.crlIssuer.length > 0) {\n\t\tfields.push(\n\t\t\timplicitConstructedContext(2, concatBytes(point.crlIssuer.map(encodeSubjectAltName))),\n\t\t);\n\t}\n\treturn fields;\n}\n\n/** DER-encode a DistributionPointName (fullName or relativeName). */\nfunction encodeDistributionPointName(name: DistributionPointName): Uint8Array {\n\tif (name.fullName !== undefined && name.relativeName !== undefined) {\n\t\tthrow new Error('DistributionPointName cannot contain both fullName and relativeName');\n\t}\n\tif (name.fullName !== undefined) {\n\t\tif (name.fullName.length === 0) {\n\t\t\tthrow new Error('DistributionPointName fullName must not be empty');\n\t\t}\n\t\treturn implicitConstructedContext(0, concatBytes(name.fullName.map(encodeSubjectAltName)));\n\t}\n\tif (name.relativeName !== undefined) {\n\t\tconst relativeName = encodeRelativeDistinguishedName(name.relativeName);\n\t\tconst relativeNameElement = readElement(relativeName);\n\t\treturn implicitConstructedContext(\n\t\t\t1,\n\t\t\trelativeName.slice(relativeNameElement.start, relativeNameElement.end),\n\t\t);\n\t}\n\tthrow new Error('DistributionPointName must contain fullName or relativeName');\n}\n\n/** DER-encode a NameConstraintForm as an implicit-tagged {@linkcode GeneralName}. */\nfunction encodeNameConstraintForm(form: NameConstraintForm): Uint8Array {\n\tswitch (form.type) {\n\t\tcase 'dns':\n\t\t\treturn implicitPrimitiveContext(2, new TextEncoder().encode(form.value));\n\t\tcase 'email':\n\t\t\treturn implicitPrimitiveContext(1, new TextEncoder().encode(form.value));\n\t\tcase 'uri':\n\t\t\treturn implicitPrimitiveContext(6, new TextEncoder().encode(form.value));\n\t\tcase 'ip':\n\t\t\treturn implicitPrimitiveContext(7, concatBytes([form.addressBytes, form.maskBytes]));\n\t\tcase 'directoryName':\n\t\t\treturn implicitConstructedContext(4, extractDirectoryNameContent(form.derHex));\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = form;\n\t\t\tthrow new Error(`Unhandled NameConstraintForm type: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n\n/** Extract the content bytes from a hex-encoded DER SEQUENCE (strips the outer TLV). */\nfunction extractDirectoryNameContent(derHex: string): Uint8Array {\n\tconst element = readRootElement(hexToBytes(derHex), { maxDepth: DEFAULT_MAX_DER_DEPTH });\n\tif (element.tag !== 0x30) {\n\t\tthrow new Error('directoryName derHex must encode a DER SEQUENCE');\n\t}\n\treturn new Uint8Array(element.value);\n}\n\n/**\n * Resolve an {@linkcode ExtendedKeyUsage} to its dotted-decimal OID.\n *\n * @param usage Well-known string or custom OID object.\n */\nexport function getExtendedKeyUsageOid(usage: ExtendedKeyUsage): string {\n\tif (typeof usage === 'string') {\n\t\treturn EXTENDED_KEY_USAGE_OIDS[usage];\n\t}\n\tvalidateOid(usage.value);\n\treturn usage.value;\n}\n\n/**\n * Map a dotted-decimal OID to an {@linkcode ExtendedKeyUsage} value.\n *\n * Returns a well-known string for recognized OIDs, or `{ type: 'oid', value }` otherwise.\n */\nexport function parseExtendedKeyUsageOid(oid: string): ExtendedKeyUsage {\n\tswitch (oid) {\n\t\tcase OIDS.serverAuth:\n\t\t\treturn 'serverAuth';\n\t\tcase OIDS.clientAuth:\n\t\t\treturn 'clientAuth';\n\t\tcase OIDS.codeSigning:\n\t\t\treturn 'codeSigning';\n\t\tcase OIDS.emailProtection:\n\t\t\treturn 'emailProtection';\n\t\tcase OIDS.timeStamping:\n\t\t\treturn 'timeStamping';\n\t\tcase OIDS.ocspSigning:\n\t\t\treturn 'ocspSigning';\n\t}\n\treturn { type: 'oid', value: oid };\n}\n\n/**\n * Resolve an {@linkcode AuthorityInfoAccessMethod} to its dotted-decimal OID.\n *\n * @param method Well-known string or custom OID object.\n */\nexport function getAuthorityInfoAccessMethodOid(method: AuthorityInfoAccessMethod): string {\n\tif (typeof method === 'string') {\n\t\treturn AUTHORITY_INFO_ACCESS_METHOD_OIDS[method];\n\t}\n\tvalidateOid(method.value);\n\treturn method.value;\n}\n\n/**\n * Map a dotted-decimal OID to an {@linkcode AuthorityInfoAccessMethod} value.\n *\n * Returns `'ocsp'` or `'caIssuers'` for recognized OIDs, or `{ type: 'oid', value }` otherwise.\n */\nexport function parseAuthorityInfoAccessMethodOid(oid: string): AuthorityInfoAccessMethod {\n\tswitch (oid) {\n\t\tcase OIDS.ocspAccessMethod:\n\t\t\treturn 'ocsp';\n\t\tcase OIDS.caIssuersAccessMethod:\n\t\t\treturn 'caIssuers';\n\t}\n\treturn { type: 'oid', value: oid };\n}\n\n/** Parse a dotted-decimal/colon-hex IP string to raw address bytes. */\nfunction encodeIpAddress(input: string): Uint8Array {\n\treturn parseIpAddressToBytes(input);\n}\n\n/** @internal Compute the SKI as SHA-1 of the subjectPublicKey BIT STRING content. */\nexport function buildSubjectKeyIdentifier(subjectPublicKeyInfo: Uint8Array): Uint8Array {\n\tconst topLevel = readSequenceChildren(subjectPublicKeyInfo);\n\tconst subjectPublicKey = topLevel[1];\n\tif (subjectPublicKey === undefined || subjectPublicKey.tag !== 0x03) {\n\t\tthrow new Error('SPKI missing subject public key bit string');\n\t}\n\tconst publicKeyBytes = subjectPublicKey.value.slice(1);\n\treturn sha1(publicKeyBytes);\n}\n\n/** Throw if the string is not a valid dotted-decimal OID. */\nfunction validateOid(oid: string): void {\n\tif (!/^\\d+(?:\\.\\d+)+$/.test(oid)) {\n\t\tthrow new Error(`Invalid OID: ${oid}`);\n\t}\n}\n\n/** Validate that a policy OID is syntactically valid. */\nfunction validatePolicyOid(oid: string): void {\n\tvalidateOid(oid);\n}\n\n/** Encode and push an extension, rejecting duplicate OIDs. */\nfunction pushExtension(\n\tencoded: Uint8Array[],\n\tseen: Set<string>,\n\toid: string,\n\tvalue: Uint8Array,\n\tcritical = false,\n): void {\n\tvalidateOid(oid);\n\tif (seen.has(oid)) {\n\t\tthrow new Error(`Duplicate extension OID: ${oid}`);\n\t}\n\tseen.add(oid);\n\tencoded.push(encodeExtension(oid, value, critical));\n}\n"],"mappings":"83CAmqBA,MAAM,EAAiE,CACtE,WAAY,EAAK,WACjB,WAAY,EAAK,WACjB,YAAa,EAAK,YAClB,gBAAiB,EAAK,gBACtB,aAAc,EAAK,aACnB,YAAa,EAAK,WACnB,EAGM,EAAoF,CACzF,KAAM,EAAK,iBACX,UAAW,EAAK,qBACjB,EAgBA,SAAgB,EACf,EACA,EACA,EACA,EAAiB,GACF,CACf,IAAM,EAA2B,CAAC,EAC5B,EAAO,IAAI,IAqBjB,OAnBA,EAAmB,EAAY,EAAM,EADZ,GAAO,kBAAoB,CAAE,GAAI,EAAM,CAC6B,EAC7F,EACC,EACA,EACA,EACA,EAA0B,CAAoB,CAC/C,EACI,IAAwB,IAAA,IAC3B,EACC,EACA,EACA,GACA,EAA0B,CAAmB,CAC9C,EAED,EAA2B,EAAY,EAAM,EAAO,cAAe,CAClE,wBAAyB,GACzB,gBACD,CAAC,EACM,CACR,CAUA,SAAgB,EACf,EACe,CACf,IAAM,EAA2B,CAAC,EAGlC,OADA,EAA2B,EAAY,IADtB,IAC4B,EAAO,MAAO,CAAE,wBAAyB,EAAK,CAAC,EACrF,CACR,CAGA,SAAS,EACR,EACA,EACA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orResult, Micro509Error } from "../result/result.js";
2
2
  import { NameFieldKey } from "./name.js";
3
- import { AuthorityInformationAccess, BasicConstraints, CertificatePolicies, DistributionPointReason, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, KeyUsage, NameConstraints, ParsedNameConstraintForm, PolicyConstraints, PolicyMappings, SubjectAltName } from "./extensions.js";
4
- import { ParsedBitFlags } from "../internal/x509/extension-bits.js";
3
+ import { AuthorityInformationAccess, BasicConstraints, CertificatePolicies, DistributionPointReason, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, KeyUsage, NameConstraints, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyMappings, SubjectAltName } from "./extensions.js";
5
4
 
6
5
  //#region src/x509/parse.d.ts
7
6
  /** Machine-readable failure reason for {@linkcode parseCertificateDer} / {@linkcode parseCertificatePem}. */
@@ -60,7 +59,7 @@ interface ParsedName {
60
59
  /** Flat list of every attribute across all RDNs, in encounter order. */
61
60
  readonly attributes: readonly ParsedNameAttribute[];
62
61
  /** First-occurrence map of well-known fields (CN, O, OU, etc.) for quick lookups. */
63
- readonly values: Partial<Record<NameFieldKey, string>>;
62
+ readonly values: Readonly<Partial<Record<NameFieldKey, string>>>;
64
63
  }
65
64
  /** A single RelativeDistinguishedName SET from an X.501 Name. */
66
65
  interface ParsedRelativeDistinguishedName {
@@ -69,7 +68,7 @@ interface ParsedRelativeDistinguishedName {
69
68
  /** Attributes within this RDN (usually one, but multi-valued RDNs are legal). */
70
69
  readonly attributes: readonly ParsedNameAttribute[];
71
70
  /** First-occurrence map of well-known fields within this RDN. */
72
- readonly values: Partial<Record<NameFieldKey, string>>;
71
+ readonly values: Readonly<Partial<Record<NameFieldKey, string>>>;
73
72
  }
74
73
  /**
75
74
  * The name component of a CRL Distribution Point (RFC 5280 §4.2.1.13).
@@ -1,2 +1,2 @@
1
- import{encodeLength as e,readElement as t,readRootElement as n,readSequenceChildren as r}from"../internal/asn1/der.js";import{childrenOf as i,decodeBoolean as a,decodeIntegerNumber as o,decodeNonNegativeIntegerNumber as s,decodeObjectIdentifier as c,decodeString as l,extractBitStringValue as u,parseTime as d,requireElement as f,toHex as p}from"../internal/asn1/asn1.js";import{OIDS as m}from"../internal/asn1/oids.js";import{pemDecode as h,splitPemBlocks as g}from"../pem/pem.js";import{failureResult as _,rethrowIfInvariant as v,successResult as y}from"../result/result.js";import{describePublicKeyAlgorithm as b,describeSignatureAlgorithm as x}from"../internal/crypto/algorithm-names.js";import{decodeIpAddress as S}from"../internal/shared/ip.js";import{parseDistributionPointReasonFlagsContent as C,parseKeyUsageExtension as w}from"../internal/x509/extension-bits.js";import{nameFieldKeyFromOid as T}from"../internal/x509/name-fields.js";import{parseAuthorityInfoAccessMethodOid as E,parseExtendedKeyUsageOid as D}from"./extensions.js";import{decodeAndApplyKnownExtension as O}from"../internal/x509/extension-registry.js";const k=new TextDecoder;function A(e){return e}function j(e){return e}function M(e,t){let n=r(e,{maxDepth:64});if(n.length!==3)throw Error(`Malformed Certificate`);let a=f(n[0],`TBSCertificate`),s=f(n[1],`signatureAlgorithm`),c=f(n[2],`signatureValue`),l=i(e,a),d=0,m=1,h=l[d];if(h?.tag===160){let t=i(e,h),n=f(t[0],`version INTEGER`);if(t.length!==1||n.tag!==2)throw Error(`version must use INTEGER`);if(m=o(n.value)+1,m<1||m>3)throw Error(`Unsupported certificate version: ${String(m)}`);d+=1}let g=f(l[d],`serialNumber`);if(g.tag!==2)throw Error(`serialNumber must use INTEGER`);let _=f(l[d+1],`TBSCertificate signature`),v=f(l[d+2],`issuer`),y=f(l[d+3],`validity`),S=f(l[d+4],`subject`),C=f(l[d+5],`subjectPublicKeyInfo`),w=d+6,T=l[w];if(T?.tag===129){if(m<2)throw Error(`issuerUniqueID requires certificate version 2 or 3`);$(T.value,`issuerUniqueID`),w+=1}let E=l[w];if(E?.tag===130){if(m<2)throw Error(`subjectUniqueID requires certificate version 2 or 3`);$(E.value,`subjectUniqueID`),w+=1}let D=l[w]?.tag===163?l[w]:void 0;if(D!==void 0){if(m!==3)throw Error(`extensions require certificate version 3`);w+=1}if(w!==l.length)throw Error(`Unsupported TBSCertificate field tag: ${String(f(l[w],`TBSCertificate field`).tag)}`);let O=se(e,D),k=le(e,y),A=K(e,C),j=q(e,_),M=q(e,s);ue(j,M);let N=t?.decoders===void 0?void 0:B(O.all,t.decoders),P=t?.decoderMap===void 0?void 0:V(O.all,t.decoderMap);return{der:new Uint8Array(e),version:m,serialNumberHex:p(g.value),tbsCertificateDer:e.slice(a.start-a.headerLength,a.end),subjectPublicKeyInfoDer:e.slice(C.start-C.headerLength,C.end),signatureValue:u(c),issuer:U(e,v),subject:U(e,S),notBefore:k.notBefore,notAfter:k.notAfter,signatureAlgorithmOid:M.oid,signatureAlgorithmName:x(M.oid,M.parametersDer),...M.parametersDer===void 0?{}:{signatureAlgorithmParametersDer:M.parametersDer},publicKeyAlgorithmOid:A.oid,publicKeyAlgorithmName:b(A.oid,A.parametersOid),...A.parametersDer===void 0?{}:{publicKeyAlgorithmParametersDer:A.parametersDer},...A.parametersOid===void 0?{}:{publicKeyParametersOid:A.parametersOid},extensions:O.all,...O.basicConstraints===void 0?{}:{basicConstraints:O.basicConstraints},...O.keyUsage===void 0?{}:{keyUsage:O.keyUsage},...O.extendedKeyUsage===void 0?{}:{extendedKeyUsage:O.extendedKeyUsage},...O.subjectAltNames===void 0?{}:{subjectAltNames:O.subjectAltNames},...O.nameConstraints===void 0?{}:{nameConstraints:O.nameConstraints},...O.certificatePolicies===void 0?{}:{certificatePolicies:O.certificatePolicies},...O.policyMappings===void 0?{}:{policyMappings:O.policyMappings},...O.policyConstraints===void 0?{}:{policyConstraints:O.policyConstraints},...O.inhibitAnyPolicy===void 0?{}:{inhibitAnyPolicy:O.inhibitAnyPolicy},...O.authorityInfoAccess===void 0?{}:{authorityInfoAccess:O.authorityInfoAccess},...O.crlDistributionPoints===void 0?{}:{crlDistributionPoints:O.crlDistributionPoints},...N===void 0?{}:{decodedExtensions:N},...P===void 0?{}:{decodedExtensionMap:P},...O.subjectKeyIdentifier===void 0?{}:{subjectKeyIdentifier:O.subjectKeyIdentifier},...O.authorityKeyIdentifier===void 0?{}:{authorityKeyIdentifier:O.authorityKeyIdentifier}}}function N(e,t){try{return y(M(e,t))}catch(e){return v(e),_(`malformed`,e instanceof Error?e.message:`Malformed certificate`)}}function P(e,t){return M(h(`CERTIFICATE`,e),t)}function ee(e,t){try{return y(P(e,t))}catch(e){return v(e),_(`malformed`,e instanceof Error?e.message:`Malformed certificate`)}}function te(e,t){return typeof e==`string`?I(e,t):[M(new Uint8Array(e),t)]}function ne(e,t){return typeof e==`string`?P(e,t):ae(e)?e:M(new Uint8Array(e),t)}function re(e,t){return I(e,t)}function F(e,t){let n=r(e,{maxDepth:64});if(n.length!==3)throw Error(`Malformed CertificationRequest`);let a=f(n[0],`CertificationRequestInfo`),s=f(n[1],`signatureAlgorithm`),c=f(n[2],`signatureValue`),l=i(e,a);if(l.length<3||l.length>4)throw Error(`Malformed CertificationRequestInfo`);let d=f(l[0],`version`);if(d.tag!==2)throw Error(`version must use INTEGER`);let p=o(d.value)+1;if(p!==1)throw Error(`Unsupported CertificationRequestInfo version: ${String(p)}`);let m=f(l[1],`subject`),h=f(l[2],`subjectPublicKeyInfo`),g=l[3];if(g!==void 0&&g.tag!==160)throw Error(`CertificationRequestInfo attributes must use [0]`);let _=ce(e,g),v=K(e,h),y=q(e,s),S=t?.decoders===void 0?void 0:B(_.all,t.decoders),C=t?.decoderMap===void 0?void 0:V(_.all,t.decoderMap);return{version:p,certificationRequestInfoDer:e.slice(a.start-a.headerLength,a.end),subjectPublicKeyInfoDer:e.slice(h.start-h.headerLength,h.end),signatureValue:u(c),subject:U(e,m),signatureAlgorithmOid:y.oid,signatureAlgorithmName:x(y.oid,y.parametersDer),...y.parametersDer===void 0?{}:{signatureAlgorithmParametersDer:y.parametersDer},publicKeyAlgorithmOid:v.oid,publicKeyAlgorithmName:b(v.oid,v.parametersOid),...v.parametersDer===void 0?{}:{publicKeyAlgorithmParametersDer:v.parametersDer},...v.parametersOid===void 0?{}:{publicKeyParametersOid:v.parametersOid},requestedExtensions:_.all,..._.basicConstraints===void 0?{}:{basicConstraints:_.basicConstraints},..._.keyUsage===void 0?{}:{keyUsage:_.keyUsage},..._.extendedKeyUsage===void 0?{}:{extendedKeyUsage:_.extendedKeyUsage},..._.subjectAltNames===void 0?{}:{subjectAltNames:_.subjectAltNames},..._.nameConstraints===void 0?{}:{nameConstraints:_.nameConstraints},..._.certificatePolicies===void 0?{}:{certificatePolicies:_.certificatePolicies},..._.policyMappings===void 0?{}:{policyMappings:_.policyMappings},..._.policyConstraints===void 0?{}:{policyConstraints:_.policyConstraints},..._.inhibitAnyPolicy===void 0?{}:{inhibitAnyPolicy:_.inhibitAnyPolicy},..._.authorityInfoAccess===void 0?{}:{authorityInfoAccess:_.authorityInfoAccess},..._.crlDistributionPoints===void 0?{}:{crlDistributionPoints:_.crlDistributionPoints},...S===void 0?{}:{decodedExtensions:S},...C===void 0?{}:{decodedExtensionMap:C}}}function ie(e,t){try{return y(F(e,t))}catch(e){return v(e),_(`malformed`,e instanceof Error?e.message:`Malformed certificate signing request`)}}function I(e,t){return g(e).filter(e=>e.label===`CERTIFICATE`).map(e=>M(e.bytes,t))}function ae(e){return`subjectPublicKeyInfoDer`in e}function L(e,t){return F(h(`CERTIFICATE REQUEST`,e),t)}function oe(e,t){try{return y(L(e,t))}catch(e){return v(e),_(`malformed`,e instanceof Error?e.message:`Malformed certificate signing request`)}}function R(e,t){return e.find(e=>e.oid===t)}function z(e,t){let n=R(e,t.oid);if(n!==void 0)return t.decode(n)}function B(e,t){let n=[];for(let r of t){let t=R(e,r.oid);t!==void 0&&n.push({oid:t.oid,critical:t.critical,value:r.decode(t)})}return n}function V(e,t){let n={};for(let r in t){let i=t[r];if(i===void 0)continue;let a=R(e,i.oid);a!==void 0&&(n={...n,[r]:{oid:a.oid,critical:a.critical,value:i.decode(a)}})}return n}function se(e,t){return t===void 0?{all:[]}:H(e,f(i(e,t)[0],`extensions sequence`),`certificate`)}function ce(e,t){if(t===void 0)return{all:[]};if(t.tag!==160)throw Error(`CertificationRequestInfo attributes must use [0]`);let n;for(let r of i(e,t)){let t=i(e,r);if(t.length!==2)throw Error(`Malformed CSR attribute`);if(c(f(t[0],`attribute OID`).value)!==m.extensionRequest)continue;if(n!==void 0)throw Error(`extensionRequest attribute must not repeat`);let a=f(t[1],`attribute values`);if(a.tag!==49)throw Error(`extensionRequest attribute values must use SET`);let o=i(e,a);if(o.length!==1)throw Error(`extensionRequest attribute must contain exactly one value`);n=H(e,f(o[0],`requested extensions`),`csr`)}return n??{all:[]}}function H(e,t,n){let r=[],o={},s=new Set;for(let l of i(e,t)){let t=i(e,l);if(t.length<2||t.length>3)throw Error(`Malformed Extension`);let u=c(f(t[0],`extension OID`).value);if(s.has(u))throw Error(`Duplicate extension OID: ${u}`);s.add(u);let d=1,m=!1,h=t[d];h?.tag===1&&(m=a(h.value),d+=1);let g=f(t[d],`extension value`);if(g.tag!==4||d!==t.length-1)throw Error(`Extension value must use OCTET STRING`);r.push({oid:u,critical:m,valueDer:new Uint8Array(g.value),valueHex:p(g.value)}),O(n,u,o,g.value)}return{all:r,...o}}function U(e,t){let n=[],r=[],a={};for(let o of i(e,t)){let t=G(e,o);n.push(t);for(let e of t.attributes)r.push(e),e.key!==void 0&&a[e.key]===void 0&&(a[e.key]=e.value)}return{derHex:p(e.slice(t.start-t.headerLength,t.end)),rdns:n,attributes:r,values:a}}function W(e,t){return G(e,t)}function G(e,t){let n=[],r={};for(let a of i(e,t)){let t=i(e,a),o=c(f(t[0],`name OID`).value),s=f(t[1],`name value`),u=T(o),d=l(s.tag,s.value),p=u===void 0?{oid:o,valueTag:s.tag,value:d}:{oid:o,key:u,valueTag:s.tag,value:d};n.push(p),u!==void 0&&r[u]===void 0&&(r[u]=d)}return{derHex:p(e.slice(t.start-t.headerLength,t.end)),attributes:n,values:r}}function le(e,t){let n=i(e,t);return{notBefore:d(f(n[0],`notBefore`)),notAfter:d(f(n[1],`notAfter`))}}function K(e,t){if(t.tag!==48)throw Error(`SubjectPublicKeyInfo must use SEQUENCE`);let n=i(e,t);if(n.length!==2)throw Error(`SubjectPublicKeyInfo must contain algorithm and subjectPublicKey`);let r=f(n[0],`SPKI algorithm`);if(r.tag!==48)throw Error(`SubjectPublicKeyInfo algorithm must use SEQUENCE`);let a=q(e,r);return u(f(n[1],`subjectPublicKey BIT STRING`)),a}function q(e,t){let n=i(e,t);if(n.length===0||n.length>2)throw Error(`Malformed AlgorithmIdentifier`);let r=c(f(n[0],`algorithm OID`).value),a=n[1];if(a===void 0)return{oid:r};let o=e.slice(a.start-a.headerLength,a.end);return a?.tag===6?{oid:r,parametersDer:o,parametersOid:c(a.value)}:{oid:r,parametersDer:o}}function ue(e,t){if(e.oid!==t.oid||!de(e.parametersDer,t.parametersDer))throw Error(`Certificate signatureAlgorithm must match TBSCertificate signature`)}function de(e,t){if(e===void 0||t===void 0)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function fe(e){let t=n(e,{maxDepth:64});if(t.tag!==48)throw Error(`basicConstraints must use SEQUENCE`);let r=i(e,t),o=!1,c,l=!1,u=!1;for(let e of r){if(e.tag===1){if(l)throw Error(`basicConstraints cA must not repeat`);if(u)throw Error(`basicConstraints cA must precede pathLength`);l=!0,o=a(e.value);continue}if(e.tag===2){if(u)throw Error(`basicConstraints pathLength must not repeat`);u=!0,c=s(e.value,`basicConstraints pathLength`);continue}throw Error(`Unsupported basicConstraints field tag: ${String(e.tag)}`)}if(c!==void 0&&o!==!0)throw Error(`basicConstraints pathLength requires cA = true`);return c===void 0?{ca:o}:{ca:o,pathLength:c}}function pe(e){return w(e)}function me(e){return i(e,f(n(e,{maxDepth:64}),`extendedKeyUsage sequence`)).map(e=>D(c(e.value)))}function he(e){let t=i(e,f(n(e,{maxDepth:64}),`certificatePolicies sequence`));if(t.length===0)throw Error(`certificatePolicies must not be empty`);return t.map(t=>J(e,t))}function J(e,t){let n=i(e,t),r=c(f(n[0],`policyIdentifier`).value),a=n[1];if(n.length>2)throw Error(`policyInformation has unexpected trailing fields`);if(a===void 0)return{policyIdentifier:r};let o=i(e,a);if(o.length===0)throw Error(`policyQualifiers must not be empty`);return{policyIdentifier:r,policyQualifiers:o.map(t=>ge(e,t))}}function ge(e,t){let n=i(e,t),r=c(f(n[0],`policyQualifierId`).value),a=f(n[1],`policyQualifier`);if(n.length>2)throw Error(`policyQualifierInfo has unexpected trailing fields`);if(r===m.cpsPolicyQualifier){if(a.tag!==22)throw Error(`cps policy qualifier must use IA5String`);return{type:`cps`,uri:l(a.tag,a.value)}}return r===m.userNoticePolicyQualifier?{type:`userNotice`,..._e(e,a)}:{type:`oid`,oid:r,qualifierDer:e.slice(a.start-a.headerLength,a.end)}}function _e(e,t){let n=i(e,t),r,a;for(let t of n){if(t.tag===48){if(r!==void 0)throw Error(`userNotice must not contain multiple noticeRef values`);r=ve(e,t);continue}if(a!==void 0)throw Error(`userNotice must not contain multiple explicitText values`);a=Q(t)}return{...r===void 0?{}:{noticeRef:r},...a===void 0?{}:{explicitText:a}}}function ve(e,t){if(t.tag!==48)throw Error(`noticeRef must use SEQUENCE`);let n=i(e,t),r=Q(f(n[0],`noticeRef organization`)),a=f(n[1],`noticeRef noticeNumbers`);if(n.length>2)throw Error(`noticeRef has unexpected trailing fields`);return{organization:r,noticeNumbers:ye(e,a)}}function ye(e,t){if(t.tag!==48)throw Error(`noticeRef noticeNumbers must use SEQUENCE`);let n=i(e,t);if(n.length===0)throw Error(`noticeRef noticeNumbers must not be empty`);return n.map(e=>{if(e.tag!==2)throw Error(`noticeRef noticeNumber must use INTEGER`);return s(e.value,`noticeRef noticeNumber`)})}function be(e){let t=i(e,f(n(e,{maxDepth:64}),`policyMappings sequence`));if(t.length===0)throw Error(`policyMappings must not be empty`);return t.map(t=>{let n=i(e,t),r=c(f(n[0],`policyMappings issuerDomainPolicy`).value),a=c(f(n[1],`policyMappings subjectDomainPolicy`).value);if(n.length>2)throw Error(`policyMappings entry has unexpected trailing fields`);if(r===m.anyPolicy||a===m.anyPolicy)throw Error(`policyMappings must not use anyPolicy`);return{issuerDomainPolicy:r,subjectDomainPolicy:a}})}function xe(e){let t=f(n(e,{maxDepth:64}),`policyConstraints sequence`),r,a;for(let n of i(e,t)){if(n.tag===128){if(r!==void 0)throw Error(`policyConstraints must not repeat requireExplicitPolicy`);r=s(n.value,`policyConstraints requireExplicitPolicy`);continue}if(n.tag===129){if(a!==void 0)throw Error(`policyConstraints must not repeat inhibitPolicyMapping`);a=s(n.value,`policyConstraints inhibitPolicyMapping`);continue}throw Error(`Unsupported policyConstraints field tag: ${n.tag}`)}if(r===void 0&&a===void 0)throw Error(`policyConstraints must set requireExplicitPolicy or inhibitPolicyMapping`);return{...r===void 0?{}:{requireExplicitPolicy:r},...a===void 0?{}:{inhibitPolicyMapping:a}}}function Se(e){let t=f(n(e,{maxDepth:64}),`inhibitAnyPolicy integer`);if(t.tag!==2)throw Error(`inhibitAnyPolicy must be an INTEGER`);return{skipCerts:s(t.value,`inhibitAnyPolicy skipCerts`)}}function Ce(e){return i(e,f(n(e,{maxDepth:64}),`subjectAltName sequence`)).map(t=>Y(e,t))}function we(e){let t=f(n(e,{maxDepth:64}),`authorityInfoAccess sequence`);if(t.tag!==48)throw Error(`authorityInfoAccess must use SEQUENCE`);let r=i(e,t);if(r.length===0)throw Error(`authorityInfoAccess must not be empty`);return r.map(t=>{if(t.tag!==48)throw Error(`authorityInfoAccess entry must use SEQUENCE`);let n=i(e,t);if(n.length!==2)throw Error(`authorityInfoAccess entry must contain method and location only`);let r=f(n[0],`authorityInfoAccess method`),a=f(n[1],`authorityInfoAccess location`);if(r.tag!==6)throw Error(`authorityInfoAccess method must use OBJECT IDENTIFIER`);if(a.tag!==134)throw Error(`Unsupported authorityInfoAccess location tag: ${a.tag}`);return{method:E(c(r.value)),uri:k.decode(a.value)}})}function Te(e){let t=f(n(e,{maxDepth:64}),`CRLDistributionPoints sequence`);if(t.tag!==48)throw Error(`CRLDistributionPoints must use SEQUENCE`);let r=i(e,t);if(r.length===0)throw Error(`CRLDistributionPoints must not be empty`);let a=[];for(let t of r)a.push(Ee(e,t));return a}function Ee(e,t){if(t.tag!==48)throw Error(`DistributionPoint must use SEQUENCE`);let n,r,a;for(let o of i(e,t))if(o.tag===160){if(n!==void 0)throw Error(`DistributionPoint distributionPoint must not repeat`);n=De(e,o)}else if(o.tag===129){if(r!==void 0)throw Error(`DistributionPoint reasons must not repeat`);r=C(o.value)}else if(o.tag===162){if(a!==void 0)throw Error(`DistributionPoint crlIssuer must not repeat`);a=Oe(e,o)}else throw Error(`Unsupported DistributionPoint field tag: ${String(o.tag)}`);if(n===void 0&&a===void 0)throw Error(`DistributionPoint must include distributionPoint or crlIssuer`);return{...n===void 0?{}:{distributionPoint:n},...r===void 0?{}:{reasons:r},...a===void 0?{}:{crlIssuer:a}}}function De(e,t){let n=i(e,t);if(n.length!==1)throw Error(`distributionPointName must contain exactly one choice`);let r=f(n[0],`distributionPointName`);if(r.tag===160){let t=i(e,r);if(t.length===0)throw Error(`distributionPointName fullName must not be empty`);for(let e of t)if((e.tag&192)!=128)throw Error(`distributionPointName fullName must contain GeneralName entries`);return{fullName:t.map(t=>Y(e,t))}}if(r.tag===161)return{relativeName:W(e,r)};throw Error(`Unsupported distributionPointName tag: ${r.tag}`)}function Oe(e,t){let n=i(e,t);if(n.length===0)throw Error(`GeneralNames must not be empty`);for(let e of n)if((e.tag&192)!=128)throw Error(`GeneralNames must contain GeneralName entries`);return n.map(t=>Y(e,t))}function Y(e,t){switch(t.tag){case 160:{let n=ke(e,t);return n===void 0?{type:`unknown`,tag:t.tag,value:e.slice(t.start,t.end)}:n}case 129:return{type:`email`,value:k.decode(t.value)};case 130:return{type:`dns`,value:k.decode(t.value)};case 134:return{type:`uri`,value:k.decode(t.value)};case 135:return{type:`ip`,value:S(t.value)};case 164:return{type:`directoryName`,derHex:p(Z(t,e))};default:return{type:`unknown`,tag:t.tag,value:e.slice(t.start,t.end)}}}function ke(e,t){let n=i(e,t);if(n.length!==1)throw Error(`otherName must contain exactly one SEQUENCE`);let r=i(e,f(n[0],`otherName sequence`));if(r.length!==2)throw Error(`otherName must contain exactly type-id and value`);let a=f(r[0],`otherName type-id`),o=f(r[1],`otherName value`);if(c(a.value)!==m.idOnDnsSrv)return;if(o.tag!==160)throw Error(`SRV-ID otherName value must use explicit [0]`);let s=i(e,o);if(s.length!==1)throw Error(`SRV-ID otherName value must contain exactly one IA5String`);let u=f(s[0],`SRV-ID IA5String`);if(u.tag!==22)throw Error(`SRV-ID otherName value must be an IA5String`);return{type:`srv`,value:l(u.tag,u.value)}}function Ae(e){let t=f(n(e,{maxDepth:64,allowOpaqueConstructedTags:[160,163,165]}),`nameConstraints sequence`);if(t.tag!==48)throw Error(`nameConstraints must use SEQUENCE`);let r,a;for(let n of i(e,t))if(n.tag===160){if(r!==void 0)throw Error(`nameConstraints permittedSubtrees must not repeat`);r=X(e,n)}else if(n.tag===161){if(a!==void 0)throw Error(`nameConstraints excludedSubtrees must not repeat`);a=X(e,n)}else throw Error(`Unsupported nameConstraints field tag: ${String(n.tag)}`);return{...r===void 0?{}:{permittedSubtrees:r},...a===void 0?{}:{excludedSubtrees:a}}}function X(e,t){let n=[],r=i(e,t);if(r.length===0)throw Error(`name constraints GeneralSubtrees must not be empty`);for(let t of r){if(t.tag!==48)throw Error(`name constraints GeneralSubtree must use SEQUENCE`);let r=i(e,t),a=r[0];if(a===void 0)throw Error(`name constraints GeneralSubtree base is required`);let o=!1;for(let e=1;e<r.length;e+=1){let t=r[e];if(t!==void 0)if(t.tag===128){if(o)throw Error(`name constraints GeneralSubtree minimum must not repeat`);if(o=!0,s(t.value,`name constraints GeneralSubtree minimum`)!==0)throw Error(`name constraints GeneralSubtree minimum must be 0`)}else if(t.tag===129)throw Error(`name constraints GeneralSubtree maximum is not supported`);else throw Error(`Unsupported name constraints GeneralSubtree field tag: ${String(t.tag)}`)}let c=je(e,a);c!==void 0&&n.push({base:c})}return n}function je(e,t){switch(t.tag){case 160:return{type:`otherName`,value:new Uint8Array(t.value)};case 129:return{type:`email`,value:k.decode(t.value)};case 130:return{type:`dns`,value:k.decode(t.value)};case 163:return{type:`x400Address`,value:new Uint8Array(t.value)};case 134:return{type:`uri`,value:k.decode(t.value)};case 135:if(t.value.length===8)return{type:`ip`,addressBytes:t.value.slice(0,4),maskBytes:t.value.slice(4,8)};if(t.value.length===32)return{type:`ip`,addressBytes:t.value.slice(0,16),maskBytes:t.value.slice(16,32)};throw Error(`Invalid IP name constraint: expected 8 (IPv4) or 32 (IPv6) bytes, got ${String(t.value.length)}`);case 164:return{type:`directoryName`,derHex:p(Z(t,e))};case 165:return{type:`ediPartyName`,value:new Uint8Array(t.value)};case 136:return{type:`registeredID`,value:c(t.value)}}throw Error(`Unsupported name constraint GeneralName tag: ${String(t.tag)}`)}function Z(t,n){if(t.value.length>0&&t.value[0]===48)return new Uint8Array(t.value);let r=e(t.value.length),i=new Uint8Array(1+r.length+t.value.length);return i[0]=48,i.set(r,1),i.set(t.value,1+r.length),i}function Q(e){switch(e.tag){case 12:case 22:case 26:return k.decode(e.value);case 30:return Me(e.value);default:throw Error(`Unsupported DisplayText tag: ${e.tag}`)}}function Me(e){if(e.length%2!=0)throw Error(`Invalid BMPString length`);let t=``;for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];if(r===void 0||i===void 0)throw Error(`Invalid BMPString content`);t+=String.fromCharCode(r<<8|i)}return t}function Ne(e){let n=f(t(e,0),`authorityKeyIdentifier sequence`);if(n.end!==e.length)throw Error(`Trailing data after DER element`);let r,a=!1,o=!1,s=-1,c=n.start;for(;c<n.end;){let l=t(e,c);if(l.end>n.end)throw Error(`DER child exceeds parent length`);if(l.tag===128){if(r!==void 0)throw Error(`authorityKeyIdentifier keyIdentifier must not repeat`);if(s>=0)throw Error(`authorityKeyIdentifier fields must preserve DER order`);r=p(l.value),s=0}else if(l.tag===161){if(a)throw Error(`authorityKeyIdentifier authorityCertIssuer must not repeat`);if(s>=1)throw Error(`authorityKeyIdentifier fields must preserve DER order`);let t=i(e,l);if(t.length===0)throw Error(`authorityKeyIdentifier authorityCertIssuer must contain GeneralName entries`);for(let n of t){if((n.tag&192)!=128)throw Error(`authorityKeyIdentifier authorityCertIssuer must contain GeneralName entries`);Y(e,n)}a=!0,s=1}else if(l.tag===130){if(o)throw Error(`authorityKeyIdentifier authorityCertSerialNumber must not repeat`);if(s>=2||!a)throw Error(`authorityKeyIdentifier fields must preserve DER order`);Pe(l.value,`authorityKeyIdentifier authorityCertSerialNumber`),o=!0,s=2}else throw Error(`Unsupported authorityKeyIdentifier field tag: ${String(l.tag)}`);c=l.end}if(c!==n.end)throw Error(`Malformed DER sequence`);if(a!==o)throw Error(`authorityKeyIdentifier authorityCertIssuer and authorityCertSerialNumber must appear together`);return r}function Pe(e,t){let n=e[0];if(n===void 0)throw Error(`${t} must not be empty`);if(n&128)throw Error(`${t} must be non-negative`);if(e.length>1&&n===0&&!((e[1]??0)&128))throw Error(`${t} must use minimal encoding`)}function $(e,t){let n=e[0];if(n===void 0||n>7)throw Error(`${t} must use BIT STRING encoding`);let r=e.slice(1);if(r.length===0){if(n!==0)throw Error(`${t} must use BIT STRING encoding`);return}if(n===0)return;let i=r[r.length-1];if(i===void 0)throw Error(`${t} must use BIT STRING encoding`);if(i&(1<<n)-1)throw Error(`${t} BIT STRING must not set padding bits`)}export{z as decodeExtension,V as decodeExtensionMap,B as decodeExtensions,A as defineExtensionDecoder,j as defineExtensionDecoderMap,R as findExtension,we as parseAuthorityInfoAccess,Ne as parseAuthorityKeyIdentifier,fe as parseBasicConstraints,re as parseCertificateChainPem,N as parseCertificateDer,M as parseCertificateDerOrThrow,ne as parseCertificateFromSource,ee as parseCertificatePem,P as parseCertificatePemOrThrow,he as parseCertificatePolicies,ie as parseCertificateSigningRequestDer,F as parseCertificateSigningRequestDerOrThrow,oe as parseCertificateSigningRequestPem,L as parseCertificateSigningRequestPemOrThrow,te as parseCertificatesFromSource,Te as parseCrlDistributionPoints,me as parseExtendedKeyUsage,Se as parseInhibitAnyPolicy,pe as parseKeyUsage,Ae as parseNameConstraints,xe as parsePolicyConstraints,be as parsePolicyMappings,Ce as parseSubjectAltNames};
1
+ import{encodeLength as e,readElement as t,readRootElement as n,readSequenceChildren as r}from"../internal/asn1/der.js";import{childrenOf as i,decodeBoolean as a,decodeIntegerNumber as o,decodeNonNegativeIntegerNumber as s,decodeObjectIdentifier as c,decodeString as l,extractBitStringValue as u,parseTime as d,requireElement as f,toHex as p}from"../internal/asn1/asn1.js";import{OIDS as m}from"../internal/asn1/oids.js";import{failureResult as h,rethrowIfInvariant as g,successResult as _}from"../result/result.js";import{pemDecodeOrThrow as v,splitPemBlocksOrThrow as y}from"../pem/pem.js";import{describePublicKeyAlgorithm as b,describeSignatureAlgorithm as x}from"../internal/crypto/algorithm-names.js";import{decodeIpAddress as S}from"../internal/shared/ip.js";import{parseDistributionPointReasonFlagsContent as C,parseKeyUsageExtension as w}from"../internal/x509/extension-bits.js";import{nameFieldKeyFromOid as T}from"../internal/x509/name-fields.js";import{parseAuthorityInfoAccessMethodOid as E,parseExtendedKeyUsageOid as D}from"./extensions.js";import{decodeAndApplyKnownExtension as O}from"../internal/x509/extension-registry.js";const k=new TextDecoder;function A(e){return e}function j(e){return e}function M(e,t){let n=r(e,{maxDepth:64});if(n.length!==3)throw Error(`Malformed Certificate`);let a=f(n[0],`TBSCertificate`),s=f(n[1],`signatureAlgorithm`),c=f(n[2],`signatureValue`),l=i(e,a),d=0,m=1,h=l[d];if(h?.tag===160){let t=i(e,h),n=f(t[0],`version INTEGER`);if(t.length!==1||n.tag!==2)throw Error(`version must use INTEGER`);if(m=o(n.value)+1,m<1||m>3)throw Error(`Unsupported certificate version: ${String(m)}`);d+=1}let g=f(l[d],`serialNumber`);if(g.tag!==2)throw Error(`serialNumber must use INTEGER`);let _=f(l[d+1],`TBSCertificate signature`),v=f(l[d+2],`issuer`),y=f(l[d+3],`validity`),S=f(l[d+4],`subject`),C=f(l[d+5],`subjectPublicKeyInfo`),w=d+6,T=l[w];if(T?.tag===129){if(m<2)throw Error(`issuerUniqueID requires certificate version 2 or 3`);$(T.value,`issuerUniqueID`),w+=1}let E=l[w];if(E?.tag===130){if(m<2)throw Error(`subjectUniqueID requires certificate version 2 or 3`);$(E.value,`subjectUniqueID`),w+=1}let D=l[w]?.tag===163?l[w]:void 0;if(D!==void 0){if(m!==3)throw Error(`extensions require certificate version 3`);w+=1}if(w!==l.length)throw Error(`Unsupported TBSCertificate field tag: ${String(f(l[w],`TBSCertificate field`).tag)}`);let O=se(e,D),k=le(e,y),A=K(e,C),j=q(e,_),M=q(e,s);ue(j,M);let N=t?.decoders===void 0?void 0:B(O.all,t.decoders),P=t?.decoderMap===void 0?void 0:V(O.all,t.decoderMap);return{der:new Uint8Array(e),version:m,serialNumberHex:p(g.value),tbsCertificateDer:e.slice(a.start-a.headerLength,a.end),subjectPublicKeyInfoDer:e.slice(C.start-C.headerLength,C.end),signatureValue:u(c),issuer:U(e,v),subject:U(e,S),notBefore:k.notBefore,notAfter:k.notAfter,signatureAlgorithmOid:M.oid,signatureAlgorithmName:x(M.oid,M.parametersDer),...M.parametersDer===void 0?{}:{signatureAlgorithmParametersDer:M.parametersDer},publicKeyAlgorithmOid:A.oid,publicKeyAlgorithmName:b(A.oid,A.parametersOid),...A.parametersDer===void 0?{}:{publicKeyAlgorithmParametersDer:A.parametersDer},...A.parametersOid===void 0?{}:{publicKeyParametersOid:A.parametersOid},extensions:O.all,...O.basicConstraints===void 0?{}:{basicConstraints:O.basicConstraints},...O.keyUsage===void 0?{}:{keyUsage:O.keyUsage},...O.extendedKeyUsage===void 0?{}:{extendedKeyUsage:O.extendedKeyUsage},...O.subjectAltNames===void 0?{}:{subjectAltNames:O.subjectAltNames},...O.nameConstraints===void 0?{}:{nameConstraints:O.nameConstraints},...O.certificatePolicies===void 0?{}:{certificatePolicies:O.certificatePolicies},...O.policyMappings===void 0?{}:{policyMappings:O.policyMappings},...O.policyConstraints===void 0?{}:{policyConstraints:O.policyConstraints},...O.inhibitAnyPolicy===void 0?{}:{inhibitAnyPolicy:O.inhibitAnyPolicy},...O.authorityInfoAccess===void 0?{}:{authorityInfoAccess:O.authorityInfoAccess},...O.crlDistributionPoints===void 0?{}:{crlDistributionPoints:O.crlDistributionPoints},...N===void 0?{}:{decodedExtensions:N},...P===void 0?{}:{decodedExtensionMap:P},...O.subjectKeyIdentifier===void 0?{}:{subjectKeyIdentifier:O.subjectKeyIdentifier},...O.authorityKeyIdentifier===void 0?{}:{authorityKeyIdentifier:O.authorityKeyIdentifier}}}function N(e,t){try{return _(M(e,t))}catch(e){return g(e),h(`malformed`,e instanceof Error?e.message:`Malformed certificate`)}}function P(e,t){return M(v(`CERTIFICATE`,e),t)}function ee(e,t){try{return _(P(e,t))}catch(e){return g(e),h(`malformed`,e instanceof Error?e.message:`Malformed certificate`)}}function te(e,t){return typeof e==`string`?I(e,t):[M(new Uint8Array(e),t)]}function ne(e,t){return typeof e==`string`?P(e,t):ae(e)?e:M(new Uint8Array(e),t)}function re(e,t){return I(e,t)}function F(e,t){let n=r(e,{maxDepth:64});if(n.length!==3)throw Error(`Malformed CertificationRequest`);let a=f(n[0],`CertificationRequestInfo`),s=f(n[1],`signatureAlgorithm`),c=f(n[2],`signatureValue`),l=i(e,a);if(l.length<3||l.length>4)throw Error(`Malformed CertificationRequestInfo`);let d=f(l[0],`version`);if(d.tag!==2)throw Error(`version must use INTEGER`);let p=o(d.value)+1;if(p!==1)throw Error(`Unsupported CertificationRequestInfo version: ${String(p)}`);let m=f(l[1],`subject`),h=f(l[2],`subjectPublicKeyInfo`),g=l[3];if(g!==void 0&&g.tag!==160)throw Error(`CertificationRequestInfo attributes must use [0]`);let _=ce(e,g),v=K(e,h),y=q(e,s),S=t?.decoders===void 0?void 0:B(_.all,t.decoders),C=t?.decoderMap===void 0?void 0:V(_.all,t.decoderMap);return{version:p,certificationRequestInfoDer:e.slice(a.start-a.headerLength,a.end),subjectPublicKeyInfoDer:e.slice(h.start-h.headerLength,h.end),signatureValue:u(c),subject:U(e,m),signatureAlgorithmOid:y.oid,signatureAlgorithmName:x(y.oid,y.parametersDer),...y.parametersDer===void 0?{}:{signatureAlgorithmParametersDer:y.parametersDer},publicKeyAlgorithmOid:v.oid,publicKeyAlgorithmName:b(v.oid,v.parametersOid),...v.parametersDer===void 0?{}:{publicKeyAlgorithmParametersDer:v.parametersDer},...v.parametersOid===void 0?{}:{publicKeyParametersOid:v.parametersOid},requestedExtensions:_.all,..._.basicConstraints===void 0?{}:{basicConstraints:_.basicConstraints},..._.keyUsage===void 0?{}:{keyUsage:_.keyUsage},..._.extendedKeyUsage===void 0?{}:{extendedKeyUsage:_.extendedKeyUsage},..._.subjectAltNames===void 0?{}:{subjectAltNames:_.subjectAltNames},..._.nameConstraints===void 0?{}:{nameConstraints:_.nameConstraints},..._.certificatePolicies===void 0?{}:{certificatePolicies:_.certificatePolicies},..._.policyMappings===void 0?{}:{policyMappings:_.policyMappings},..._.policyConstraints===void 0?{}:{policyConstraints:_.policyConstraints},..._.inhibitAnyPolicy===void 0?{}:{inhibitAnyPolicy:_.inhibitAnyPolicy},..._.authorityInfoAccess===void 0?{}:{authorityInfoAccess:_.authorityInfoAccess},..._.crlDistributionPoints===void 0?{}:{crlDistributionPoints:_.crlDistributionPoints},...S===void 0?{}:{decodedExtensions:S},...C===void 0?{}:{decodedExtensionMap:C}}}function ie(e,t){try{return _(F(e,t))}catch(e){return g(e),h(`malformed`,e instanceof Error?e.message:`Malformed certificate signing request`)}}function I(e,t){return y(e).filter(e=>e.label===`CERTIFICATE`).map(e=>M(e.bytes,t))}function ae(e){return`subjectPublicKeyInfoDer`in e}function L(e,t){return F(v(`CERTIFICATE REQUEST`,e),t)}function oe(e,t){try{return _(L(e,t))}catch(e){return g(e),h(`malformed`,e instanceof Error?e.message:`Malformed certificate signing request`)}}function R(e,t){return e.find(e=>e.oid===t)}function z(e,t){let n=R(e,t.oid);if(n!==void 0)return t.decode(n)}function B(e,t){let n=[];for(let r of t){let t=R(e,r.oid);t!==void 0&&n.push({oid:t.oid,critical:t.critical,value:r.decode(t)})}return n}function V(e,t){let n={};for(let r in t){let i=t[r];if(i===void 0)continue;let a=R(e,i.oid);a!==void 0&&(n={...n,[r]:{oid:a.oid,critical:a.critical,value:i.decode(a)}})}return n}function se(e,t){return t===void 0?{all:[]}:H(e,f(i(e,t)[0],`extensions sequence`),`certificate`)}function ce(e,t){if(t===void 0)return{all:[]};if(t.tag!==160)throw Error(`CertificationRequestInfo attributes must use [0]`);let n;for(let r of i(e,t)){let t=i(e,r);if(t.length!==2)throw Error(`Malformed CSR attribute`);if(c(f(t[0],`attribute OID`).value)!==m.extensionRequest)continue;if(n!==void 0)throw Error(`extensionRequest attribute must not repeat`);let a=f(t[1],`attribute values`);if(a.tag!==49)throw Error(`extensionRequest attribute values must use SET`);let o=i(e,a);if(o.length!==1)throw Error(`extensionRequest attribute must contain exactly one value`);n=H(e,f(o[0],`requested extensions`),`csr`)}return n??{all:[]}}function H(e,t,n){let r=[],o={},s=new Set;for(let l of i(e,t)){let t=i(e,l);if(t.length<2||t.length>3)throw Error(`Malformed Extension`);let u=c(f(t[0],`extension OID`).value);if(s.has(u))throw Error(`Duplicate extension OID: ${u}`);s.add(u);let d=1,m=!1,h=t[d];h?.tag===1&&(m=a(h.value),d+=1);let g=f(t[d],`extension value`);if(g.tag!==4||d!==t.length-1)throw Error(`Extension value must use OCTET STRING`);r.push({oid:u,critical:m,valueDer:new Uint8Array(g.value),valueHex:p(g.value)}),O(n,u,o,g.value)}return{all:r,...o}}function U(e,t){let n=[],r=[],a={};for(let o of i(e,t)){let t=G(e,o);n.push(t);for(let e of t.attributes)r.push(e),e.key!==void 0&&a[e.key]===void 0&&(a[e.key]=e.value)}return{derHex:p(e.slice(t.start-t.headerLength,t.end)),rdns:n,attributes:r,values:a}}function W(e,t){return G(e,t)}function G(e,t){let n=[],r={};for(let a of i(e,t)){let t=i(e,a),o=c(f(t[0],`name OID`).value),s=f(t[1],`name value`),u=T(o),d=l(s.tag,s.value),p=u===void 0?{oid:o,valueTag:s.tag,value:d}:{oid:o,key:u,valueTag:s.tag,value:d};n.push(p),u!==void 0&&r[u]===void 0&&(r[u]=d)}return{derHex:p(e.slice(t.start-t.headerLength,t.end)),attributes:n,values:r}}function le(e,t){let n=i(e,t);return{notBefore:d(f(n[0],`notBefore`)),notAfter:d(f(n[1],`notAfter`))}}function K(e,t){if(t.tag!==48)throw Error(`SubjectPublicKeyInfo must use SEQUENCE`);let n=i(e,t);if(n.length!==2)throw Error(`SubjectPublicKeyInfo must contain algorithm and subjectPublicKey`);let r=f(n[0],`SPKI algorithm`);if(r.tag!==48)throw Error(`SubjectPublicKeyInfo algorithm must use SEQUENCE`);let a=q(e,r);return u(f(n[1],`subjectPublicKey BIT STRING`)),a}function q(e,t){let n=i(e,t);if(n.length===0||n.length>2)throw Error(`Malformed AlgorithmIdentifier`);let r=c(f(n[0],`algorithm OID`).value),a=n[1];if(a===void 0)return{oid:r};let o=e.slice(a.start-a.headerLength,a.end);return a?.tag===6?{oid:r,parametersDer:o,parametersOid:c(a.value)}:{oid:r,parametersDer:o}}function ue(e,t){if(e.oid!==t.oid||!de(e.parametersDer,t.parametersDer))throw Error(`Certificate signatureAlgorithm must match TBSCertificate signature`)}function de(e,t){if(e===void 0||t===void 0)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function fe(e){let t=n(e,{maxDepth:64});if(t.tag!==48)throw Error(`basicConstraints must use SEQUENCE`);let r=i(e,t),o=!1,c,l=!1,u=!1;for(let e of r){if(e.tag===1){if(l)throw Error(`basicConstraints cA must not repeat`);if(u)throw Error(`basicConstraints cA must precede pathLength`);l=!0,o=a(e.value);continue}if(e.tag===2){if(u)throw Error(`basicConstraints pathLength must not repeat`);u=!0,c=s(e.value,`basicConstraints pathLength`);continue}throw Error(`Unsupported basicConstraints field tag: ${String(e.tag)}`)}if(c!==void 0&&o!==!0)throw Error(`basicConstraints pathLength requires cA = true`);return o?c===void 0?{ca:!0}:{ca:!0,pathLength:c}:{ca:!1}}function pe(e){return w(e)}function me(e){return i(e,f(n(e,{maxDepth:64}),`extendedKeyUsage sequence`)).map(e=>D(c(e.value)))}function he(e){let t=i(e,f(n(e,{maxDepth:64}),`certificatePolicies sequence`));if(t.length===0)throw Error(`certificatePolicies must not be empty`);return t.map(t=>J(e,t))}function J(e,t){let n=i(e,t),r=c(f(n[0],`policyIdentifier`).value),a=n[1];if(n.length>2)throw Error(`policyInformation has unexpected trailing fields`);if(a===void 0)return{policyIdentifier:r};let o=i(e,a);if(o.length===0)throw Error(`policyQualifiers must not be empty`);return{policyIdentifier:r,policyQualifiers:o.map(t=>ge(e,t))}}function ge(e,t){let n=i(e,t),r=c(f(n[0],`policyQualifierId`).value),a=f(n[1],`policyQualifier`);if(n.length>2)throw Error(`policyQualifierInfo has unexpected trailing fields`);if(r===m.cpsPolicyQualifier){if(a.tag!==22)throw Error(`cps policy qualifier must use IA5String`);return{type:`cps`,uri:l(a.tag,a.value)}}return r===m.userNoticePolicyQualifier?{type:`userNotice`,..._e(e,a)}:{type:`oid`,oid:r,qualifierDer:e.slice(a.start-a.headerLength,a.end)}}function _e(e,t){let n=i(e,t),r,a;for(let t of n){if(t.tag===48){if(r!==void 0)throw Error(`userNotice must not contain multiple noticeRef values`);r=ve(e,t);continue}if(a!==void 0)throw Error(`userNotice must not contain multiple explicitText values`);a=Q(t)}return{...r===void 0?{}:{noticeRef:r},...a===void 0?{}:{explicitText:a}}}function ve(e,t){if(t.tag!==48)throw Error(`noticeRef must use SEQUENCE`);let n=i(e,t),r=Q(f(n[0],`noticeRef organization`)),a=f(n[1],`noticeRef noticeNumbers`);if(n.length>2)throw Error(`noticeRef has unexpected trailing fields`);return{organization:r,noticeNumbers:ye(e,a)}}function ye(e,t){if(t.tag!==48)throw Error(`noticeRef noticeNumbers must use SEQUENCE`);let n=i(e,t);if(n.length===0)throw Error(`noticeRef noticeNumbers must not be empty`);return n.map(e=>{if(e.tag!==2)throw Error(`noticeRef noticeNumber must use INTEGER`);return s(e.value,`noticeRef noticeNumber`)})}function be(e){let t=i(e,f(n(e,{maxDepth:64}),`policyMappings sequence`));if(t.length===0)throw Error(`policyMappings must not be empty`);return t.map(t=>{let n=i(e,t),r=c(f(n[0],`policyMappings issuerDomainPolicy`).value),a=c(f(n[1],`policyMappings subjectDomainPolicy`).value);if(n.length>2)throw Error(`policyMappings entry has unexpected trailing fields`);if(r===m.anyPolicy||a===m.anyPolicy)throw Error(`policyMappings must not use anyPolicy`);return{issuerDomainPolicy:r,subjectDomainPolicy:a}})}function xe(e){let t=f(n(e,{maxDepth:64}),`policyConstraints sequence`),r,a;for(let n of i(e,t)){if(n.tag===128){if(r!==void 0)throw Error(`policyConstraints must not repeat requireExplicitPolicy`);r=s(n.value,`policyConstraints requireExplicitPolicy`);continue}if(n.tag===129){if(a!==void 0)throw Error(`policyConstraints must not repeat inhibitPolicyMapping`);a=s(n.value,`policyConstraints inhibitPolicyMapping`);continue}throw Error(`Unsupported policyConstraints field tag: ${n.tag}`)}if(r===void 0&&a===void 0)throw Error(`policyConstraints must set requireExplicitPolicy or inhibitPolicyMapping`);return{...r===void 0?{}:{requireExplicitPolicy:r},...a===void 0?{}:{inhibitPolicyMapping:a}}}function Se(e){let t=f(n(e,{maxDepth:64}),`inhibitAnyPolicy integer`);if(t.tag!==2)throw Error(`inhibitAnyPolicy must be an INTEGER`);return{skipCerts:s(t.value,`inhibitAnyPolicy skipCerts`)}}function Ce(e){return i(e,f(n(e,{maxDepth:64}),`subjectAltName sequence`)).map(t=>Y(e,t))}function we(e){let t=f(n(e,{maxDepth:64}),`authorityInfoAccess sequence`);if(t.tag!==48)throw Error(`authorityInfoAccess must use SEQUENCE`);let r=i(e,t);if(r.length===0)throw Error(`authorityInfoAccess must not be empty`);return r.map(t=>{if(t.tag!==48)throw Error(`authorityInfoAccess entry must use SEQUENCE`);let n=i(e,t);if(n.length!==2)throw Error(`authorityInfoAccess entry must contain method and location only`);let r=f(n[0],`authorityInfoAccess method`),a=f(n[1],`authorityInfoAccess location`);if(r.tag!==6)throw Error(`authorityInfoAccess method must use OBJECT IDENTIFIER`);if(a.tag!==134)throw Error(`Unsupported authorityInfoAccess location tag: ${a.tag}`);return{method:E(c(r.value)),uri:k.decode(a.value)}})}function Te(e){let t=f(n(e,{maxDepth:64}),`CRLDistributionPoints sequence`);if(t.tag!==48)throw Error(`CRLDistributionPoints must use SEQUENCE`);let r=i(e,t);if(r.length===0)throw Error(`CRLDistributionPoints must not be empty`);let a=[];for(let t of r)a.push(Ee(e,t));return a}function Ee(e,t){if(t.tag!==48)throw Error(`DistributionPoint must use SEQUENCE`);let n,r,a;for(let o of i(e,t))if(o.tag===160){if(n!==void 0)throw Error(`DistributionPoint distributionPoint must not repeat`);n=De(e,o)}else if(o.tag===129){if(r!==void 0)throw Error(`DistributionPoint reasons must not repeat`);r=C(o.value)}else if(o.tag===162){if(a!==void 0)throw Error(`DistributionPoint crlIssuer must not repeat`);a=Oe(e,o)}else throw Error(`Unsupported DistributionPoint field tag: ${String(o.tag)}`);if(n===void 0&&a===void 0)throw Error(`DistributionPoint must include distributionPoint or crlIssuer`);return{...n===void 0?{}:{distributionPoint:n},...r===void 0?{}:{reasons:r},...a===void 0?{}:{crlIssuer:a}}}function De(e,t){let n=i(e,t);if(n.length!==1)throw Error(`distributionPointName must contain exactly one choice`);let r=f(n[0],`distributionPointName`);if(r.tag===160){let t=i(e,r);if(t.length===0)throw Error(`distributionPointName fullName must not be empty`);for(let e of t)if((e.tag&192)!=128)throw Error(`distributionPointName fullName must contain GeneralName entries`);return{fullName:t.map(t=>Y(e,t))}}if(r.tag===161)return{relativeName:W(e,r)};throw Error(`Unsupported distributionPointName tag: ${r.tag}`)}function Oe(e,t){let n=i(e,t);if(n.length===0)throw Error(`GeneralNames must not be empty`);for(let e of n)if((e.tag&192)!=128)throw Error(`GeneralNames must contain GeneralName entries`);return n.map(t=>Y(e,t))}function Y(e,t){switch(t.tag){case 160:{let n=ke(e,t);return n===void 0?{type:`unknown`,tag:t.tag,value:e.slice(t.start,t.end)}:n}case 129:return{type:`email`,value:k.decode(t.value)};case 130:return{type:`dns`,value:k.decode(t.value)};case 134:return{type:`uri`,value:k.decode(t.value)};case 135:return{type:`ip`,value:S(t.value)};case 164:return{type:`directoryName`,derHex:p(Z(t,e))};default:return{type:`unknown`,tag:t.tag,value:e.slice(t.start,t.end)}}}function ke(e,t){let n=i(e,t);if(n.length!==1)throw Error(`otherName must contain exactly one SEQUENCE`);let r=i(e,f(n[0],`otherName sequence`));if(r.length!==2)throw Error(`otherName must contain exactly type-id and value`);let a=f(r[0],`otherName type-id`),o=f(r[1],`otherName value`);if(c(a.value)!==m.idOnDnsSrv)return;if(o.tag!==160)throw Error(`SRV-ID otherName value must use explicit [0]`);let s=i(e,o);if(s.length!==1)throw Error(`SRV-ID otherName value must contain exactly one IA5String`);let u=f(s[0],`SRV-ID IA5String`);if(u.tag!==22)throw Error(`SRV-ID otherName value must be an IA5String`);return{type:`srv`,value:l(u.tag,u.value)}}function Ae(e){let t=f(n(e,{maxDepth:64,allowOpaqueConstructedTags:[160,163,165]}),`nameConstraints sequence`);if(t.tag!==48)throw Error(`nameConstraints must use SEQUENCE`);let r,a;for(let n of i(e,t))if(n.tag===160){if(r!==void 0)throw Error(`nameConstraints permittedSubtrees must not repeat`);r=X(e,n)}else if(n.tag===161){if(a!==void 0)throw Error(`nameConstraints excludedSubtrees must not repeat`);a=X(e,n)}else throw Error(`Unsupported nameConstraints field tag: ${String(n.tag)}`);return{...r===void 0?{}:{permittedSubtrees:r},...a===void 0?{}:{excludedSubtrees:a}}}function X(e,t){let n=[],r=i(e,t);if(r.length===0)throw Error(`name constraints GeneralSubtrees must not be empty`);for(let t of r){if(t.tag!==48)throw Error(`name constraints GeneralSubtree must use SEQUENCE`);let r=i(e,t),a=r[0];if(a===void 0)throw Error(`name constraints GeneralSubtree base is required`);let o=!1;for(let e=1;e<r.length;e+=1){let t=r[e];if(t!==void 0)if(t.tag===128){if(o)throw Error(`name constraints GeneralSubtree minimum must not repeat`);if(o=!0,s(t.value,`name constraints GeneralSubtree minimum`)!==0)throw Error(`name constraints GeneralSubtree minimum must be 0`)}else if(t.tag===129)throw Error(`name constraints GeneralSubtree maximum is not supported`);else throw Error(`Unsupported name constraints GeneralSubtree field tag: ${String(t.tag)}`)}let c=je(e,a);c!==void 0&&n.push({base:c})}return n}function je(e,t){switch(t.tag){case 160:return{type:`otherName`,value:new Uint8Array(t.value)};case 129:return{type:`email`,value:k.decode(t.value)};case 130:return{type:`dns`,value:k.decode(t.value)};case 163:return{type:`x400Address`,value:new Uint8Array(t.value)};case 134:return{type:`uri`,value:k.decode(t.value)};case 135:if(t.value.length===8)return{type:`ip`,addressBytes:t.value.slice(0,4),maskBytes:t.value.slice(4,8)};if(t.value.length===32)return{type:`ip`,addressBytes:t.value.slice(0,16),maskBytes:t.value.slice(16,32)};throw Error(`Invalid IP name constraint: expected 8 (IPv4) or 32 (IPv6) bytes, got ${String(t.value.length)}`);case 164:return{type:`directoryName`,derHex:p(Z(t,e))};case 165:return{type:`ediPartyName`,value:new Uint8Array(t.value)};case 136:return{type:`registeredID`,value:c(t.value)}}throw Error(`Unsupported name constraint GeneralName tag: ${String(t.tag)}`)}function Z(t,n){if(t.value.length>0&&t.value[0]===48)return new Uint8Array(t.value);let r=e(t.value.length),i=new Uint8Array(1+r.length+t.value.length);return i[0]=48,i.set(r,1),i.set(t.value,1+r.length),i}function Q(e){switch(e.tag){case 12:case 22:case 26:return k.decode(e.value);case 30:return Me(e.value);default:throw Error(`Unsupported DisplayText tag: ${e.tag}`)}}function Me(e){if(e.length%2!=0)throw Error(`Invalid BMPString length`);let t=``;for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];if(r===void 0||i===void 0)throw Error(`Invalid BMPString content`);t+=String.fromCharCode(r<<8|i)}return t}function Ne(e){let n=f(t(e,0),`authorityKeyIdentifier sequence`);if(n.end!==e.length)throw Error(`Trailing data after DER element`);let r,a=!1,o=!1,s=-1,c=n.start;for(;c<n.end;){let l=t(e,c);if(l.end>n.end)throw Error(`DER child exceeds parent length`);if(l.tag===128){if(r!==void 0)throw Error(`authorityKeyIdentifier keyIdentifier must not repeat`);if(s>=0)throw Error(`authorityKeyIdentifier fields must preserve DER order`);r=p(l.value),s=0}else if(l.tag===161){if(a)throw Error(`authorityKeyIdentifier authorityCertIssuer must not repeat`);if(s>=1)throw Error(`authorityKeyIdentifier fields must preserve DER order`);let t=i(e,l);if(t.length===0)throw Error(`authorityKeyIdentifier authorityCertIssuer must contain GeneralName entries`);for(let n of t){if((n.tag&192)!=128)throw Error(`authorityKeyIdentifier authorityCertIssuer must contain GeneralName entries`);Y(e,n)}a=!0,s=1}else if(l.tag===130){if(o)throw Error(`authorityKeyIdentifier authorityCertSerialNumber must not repeat`);if(s>=2||!a)throw Error(`authorityKeyIdentifier fields must preserve DER order`);Pe(l.value,`authorityKeyIdentifier authorityCertSerialNumber`),o=!0,s=2}else throw Error(`Unsupported authorityKeyIdentifier field tag: ${String(l.tag)}`);c=l.end}if(c!==n.end)throw Error(`Malformed DER sequence`);if(a!==o)throw Error(`authorityKeyIdentifier authorityCertIssuer and authorityCertSerialNumber must appear together`);return r}function Pe(e,t){let n=e[0];if(n===void 0)throw Error(`${t} must not be empty`);if(n&128)throw Error(`${t} must be non-negative`);if(e.length>1&&n===0&&!((e[1]??0)&128))throw Error(`${t} must use minimal encoding`)}function $(e,t){let n=e[0];if(n===void 0||n>7)throw Error(`${t} must use BIT STRING encoding`);let r=e.slice(1);if(r.length===0){if(n!==0)throw Error(`${t} must use BIT STRING encoding`);return}if(n===0)return;let i=r[r.length-1];if(i===void 0)throw Error(`${t} must use BIT STRING encoding`);if(i&(1<<n)-1)throw Error(`${t} BIT STRING must not set padding bits`)}export{z as decodeExtension,V as decodeExtensionMap,B as decodeExtensions,A as defineExtensionDecoder,j as defineExtensionDecoderMap,R as findExtension,we as parseAuthorityInfoAccess,Ne as parseAuthorityKeyIdentifier,fe as parseBasicConstraints,re as parseCertificateChainPem,N as parseCertificateDer,M as parseCertificateDerOrThrow,ne as parseCertificateFromSource,ee as parseCertificatePem,P as parseCertificatePemOrThrow,he as parseCertificatePolicies,ie as parseCertificateSigningRequestDer,F as parseCertificateSigningRequestDerOrThrow,oe as parseCertificateSigningRequestPem,L as parseCertificateSigningRequestPemOrThrow,te as parseCertificatesFromSource,Te as parseCrlDistributionPoints,me as parseExtendedKeyUsage,Se as parseInhibitAnyPolicy,pe as parseKeyUsage,Ae as parseNameConstraints,xe as parsePolicyConstraints,be as parsePolicyMappings,Ce as parseSubjectAltNames};
2
2
  //# sourceMappingURL=parse.js.map