micro509 0.7.2 → 0.9.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 (109) hide show
  1. package/dist/index.d.ts +5 -5
  2. package/dist/index.js +15 -1
  3. package/dist/internal/asn1/asn1.js +280 -2
  4. package/dist/internal/asn1/der.js +378 -2
  5. package/dist/internal/asn1/oids.js +103 -2
  6. package/dist/internal/crypto/algorithm-names.js +58 -2
  7. package/dist/internal/crypto/ecdsa.js +68 -2
  8. package/dist/internal/crypto/hash.js +286 -2
  9. package/dist/internal/crypto/pbes2.js +213 -2
  10. package/dist/internal/crypto/rsa-pss.js +184 -2
  11. package/dist/internal/crypto/sig-verify.js +192 -2
  12. package/dist/internal/crypto/signing.d.ts +1 -2
  13. package/dist/internal/crypto/signing.js +123 -2
  14. package/dist/internal/crypto/webcrypto.js +14 -2
  15. package/dist/internal/shared/base64.js +16 -2
  16. package/dist/internal/shared/dn.js +84 -2
  17. package/dist/internal/shared/ip.js +164 -2
  18. package/dist/internal/verify/name-constraints-engine.js +450 -2
  19. package/dist/internal/verify/policy-engine.js +382 -2
  20. package/dist/internal/verify/verify-path.js +298 -2
  21. package/dist/internal/x509/extension-bits.js +132 -2
  22. package/dist/internal/x509/extension-registry.js +229 -2
  23. package/dist/internal/x509/name-fields.js +93 -2
  24. package/dist/keys/keys.d.ts +380 -13
  25. package/dist/keys/keys.js +1247 -5
  26. package/dist/keys.d.ts +2 -2
  27. package/dist/keys.js +2 -1
  28. package/dist/pem/pem.d.ts +2 -2
  29. package/dist/pem/pem.js +172 -6
  30. package/dist/pem.js +2 -1
  31. package/dist/pkcs/pfx.d.ts +4 -5
  32. package/dist/pkcs/pfx.js +395 -2
  33. package/dist/pkcs/pkcs12-mac.d.ts +2 -2
  34. package/dist/pkcs/pkcs12-mac.js +175 -2
  35. package/dist/pkcs/pkcs7.d.ts +1 -2
  36. package/dist/pkcs/pkcs7.js +653 -2
  37. package/dist/pkcs.d.ts +2 -2
  38. package/dist/pkcs.js +4 -1
  39. package/dist/result/result.d.ts +1 -2
  40. package/dist/result/result.js +111 -2
  41. package/dist/result.js +2 -1
  42. package/dist/revocation/chain.d.ts +4 -5
  43. package/dist/revocation/chain.js +536 -2
  44. package/dist/revocation/crl.d.ts +2 -2
  45. package/dist/revocation/crl.js +1119 -2
  46. package/dist/revocation/ocsp.d.ts +5 -4
  47. package/dist/revocation/ocsp.js +958 -2
  48. package/dist/revocation/revocation.d.ts +1 -2
  49. package/dist/revocation/revocation.js +261 -2
  50. package/dist/revocation.d.ts +2 -2
  51. package/dist/revocation.js +5 -1
  52. package/dist/verify/identity.d.ts +1 -2
  53. package/dist/verify/identity.js +270 -2
  54. package/dist/verify/name-constraints.d.ts +1 -2
  55. package/dist/verify/policy.d.ts +1 -2
  56. package/dist/verify/verify.d.ts +1 -2
  57. package/dist/verify/verify.js +764 -2
  58. package/dist/verify.js +3 -1
  59. package/dist/x509/certificate.d.ts +1 -2
  60. package/dist/x509/certificate.js +151 -2
  61. package/dist/x509/csr.d.ts +1 -2
  62. package/dist/x509/csr.js +71 -2
  63. package/dist/x509/extensions.d.ts +1 -2
  64. package/dist/x509/extensions.js +387 -2
  65. package/dist/x509/name.d.ts +1 -2
  66. package/dist/x509/name.js +173 -2
  67. package/dist/x509/parse.d.ts +84 -2
  68. package/dist/x509/parse.js +1090 -2
  69. package/dist/x509.d.ts +2 -2
  70. package/dist/x509.js +6 -1
  71. package/package.json +74 -34
  72. package/dist/internal/asn1/asn1.js.map +0 -1
  73. package/dist/internal/asn1/der.js.map +0 -1
  74. package/dist/internal/asn1/oids.js.map +0 -1
  75. package/dist/internal/crypto/algorithm-names.js.map +0 -1
  76. package/dist/internal/crypto/ecdsa.js.map +0 -1
  77. package/dist/internal/crypto/hash.js.map +0 -1
  78. package/dist/internal/crypto/pbes2.d.ts +0 -23
  79. package/dist/internal/crypto/pbes2.js.map +0 -1
  80. package/dist/internal/crypto/rsa-pss.js.map +0 -1
  81. package/dist/internal/crypto/sig-verify.js.map +0 -1
  82. package/dist/internal/crypto/signing.js.map +0 -1
  83. package/dist/internal/crypto/webcrypto.js.map +0 -1
  84. package/dist/internal/shared/base64.js.map +0 -1
  85. package/dist/internal/shared/dn.js.map +0 -1
  86. package/dist/internal/shared/ip.js.map +0 -1
  87. package/dist/internal/verify/name-constraints-engine.js.map +0 -1
  88. package/dist/internal/verify/policy-engine.js.map +0 -1
  89. package/dist/internal/verify/verify-path.js.map +0 -1
  90. package/dist/internal/x509/extension-bits.js.map +0 -1
  91. package/dist/internal/x509/extension-registry.js.map +0 -1
  92. package/dist/internal/x509/name-fields.js.map +0 -1
  93. package/dist/keys/keys.js.map +0 -1
  94. package/dist/pem/pem.js.map +0 -1
  95. package/dist/pkcs/pfx.js.map +0 -1
  96. package/dist/pkcs/pkcs12-mac.js.map +0 -1
  97. package/dist/pkcs/pkcs7.js.map +0 -1
  98. package/dist/result/result.js.map +0 -1
  99. package/dist/revocation/chain.js.map +0 -1
  100. package/dist/revocation/crl.js.map +0 -1
  101. package/dist/revocation/ocsp.js.map +0 -1
  102. package/dist/revocation/revocation.js.map +0 -1
  103. package/dist/verify/identity.js.map +0 -1
  104. package/dist/verify/verify.js.map +0 -1
  105. package/dist/x509/certificate.js.map +0 -1
  106. package/dist/x509/csr.js.map +0 -1
  107. package/dist/x509/extensions.js.map +0 -1
  108. package/dist/x509/name.js.map +0 -1
  109. package/dist/x509/parse.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { ErrorResult, IndexedErrorResult, IndexedMicro509Error, Micro509Error, Result, ResultError, isResultError, unwrap, unwrapOr } from "./result/result.js";
2
- import { EcKeyAlgorithmInput, EcNamedCurve, Ed25519KeyAlgorithmInput, EncryptedPkcs8Options, ImportEcKeyInput, ImportEd25519KeyInput, ImportEncryptedKeyErrorCode, ImportEncryptedKeyFailure, ImportEncryptedKeyResult, ImportKeyErrorCode, ImportKeyFailure, ImportKeyResult, ImportRsaKeyInput, KeyAlgorithmInput, KeyPairMaterial, LegacyPemEncryptionOptions, PrivateKeyImportInput, PublicKeyImportInput, RsaHash, RsaKeyAlgorithmInput, RsaScheme, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs8Der, importEncryptedPkcs8Pem, importEncryptedSec1Pem, importPkcs1Der, importPkcs1Pem, importPkcs8Base64, importPkcs8Der, importPkcs8Pem, importPrivateJwk, importPublicJwk, importSec1Der, importSec1Pem, importSpkiBase64, importSpkiDer, importSpkiPem } from "./keys/keys.js";
2
+ import { DecryptRsaOaepErrorCode, DecryptRsaOaepFailure, DecryptRsaOaepResult, EcKeyAlgorithmInput, EcNamedCurve, Ed25519KeyAlgorithmInput, EncryptRsaOaepErrorCode, EncryptRsaOaepFailure, EncryptRsaOaepResult, EncryptedPkcs8Options, ImportEcKeyInput, ImportEd25519KeyInput, ImportEncryptedKeyErrorCode, ImportEncryptedKeyFailure, ImportEncryptedKeyResult, ImportKeyErrorCode, ImportKeyFailure, ImportKeyResult, ImportRsaKeyInput, KeyAlgorithmInput, KeyPairMaterial, LegacyPemEncryptionOptions, PrivateKeyImportInput, PublicKeyImportInput, RsaHash, RsaKeyAlgorithmInput, RsaOaepOptions, RsaScheme, RsaSignatureScheme, decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
3
3
  import { CategorizePemBlocksResult, CategorizedPemBlocks, PemBlock, PemDecodeResult, PemErrorCode, PemFailure, SplitPemBlocksResult, categorizePemBlocks, categorizePemBlocksOrThrow, pemDecode, pemDecodeOrThrow, pemEncode, splitPemBlocks, splitPemBlocksOrThrow } from "./pem/pem.js";
4
4
  import { NameAttribute, NameFieldKey, NameInput, NameObject, RelativeDistinguishedNameInput } from "./x509/name.js";
5
- import { AuthorityInformationAccess, BasicConstraints, CertificateExtensionsInput, CertificatePolicies, DistributionPoint, DistributionPointName, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, IssuingDistributionPoint, IssuingDistributionPointForAttributeCerts, IssuingDistributionPointForCaCerts, IssuingDistributionPointForUserCerts, KeyUsage, NameConstraintForm, NameConstraints, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyInformation, PolicyMapping, PolicyMappings, PolicyQualifierInfo, SubjectAltName } from "./x509/extensions.js";
6
- import { DecodedExtensionMap, DecodedExtensionValue, ExtensionDecoder, ExtensionDecoderMap, ParseCertificateErrorCode, ParseCertificateFailure, ParseCertificateResult, ParseCertificateSigningRequestErrorCode, ParseCertificateSigningRequestFailure, ParseCertificateSigningRequestResult, ParseOptions, ParsedCertificate, ParsedCertificateSigningRequest, ParsedDistributionPoint, ParsedDistributionPointName, ParsedExtension, ParsedIssuingDistributionPoint, ParsedName, ParsedNameAttribute, ParsedRelativeDistinguishedName, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, findExtension, parseCertificateChainPem, parseCertificateDer, parseCertificatePem, parseCertificateSigningRequestDer, parseCertificateSigningRequestPem } from "./x509/parse.js";
5
+ import { AuthorityInformationAccess, BasicConstraints, CertificateExtensionsInput, CertificatePolicies, DistributionPoint, DistributionPointName, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, IssuingDistributionPoint, IssuingDistributionPointBase, IssuingDistributionPointForAttributeCerts, IssuingDistributionPointForCaCerts, IssuingDistributionPointForUserCerts, KeyUsage, NameConstraintForm, NameConstraints, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyInformation, PolicyMapping, PolicyMappings, PolicyQualifierInfo, SubjectAltName } from "./x509/extensions.js";
6
+ import { DecodedExtensionMap, DecodedExtensionValue, ExtensionDecoder, ExtensionDecoderMap, ParseCertificateErrorCode, ParseCertificateFailure, ParseCertificateResult, ParseCertificateSigningRequestErrorCode, ParseCertificateSigningRequestFailure, ParseCertificateSigningRequestResult, ParseOptions, ParsedCertificate, ParsedCertificateSigningRequest, ParsedDistributionPoint, ParsedDistributionPointName, ParsedExtension, ParsedIssuingDistributionPoint, ParsedName, ParsedNameAttribute, ParsedRelativeDistinguishedName, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, findExtension, getSubjectPublicKey, getSubjectPublicKeyOrThrow, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow } from "./x509/parse.js";
7
7
  import { ParsePkcs12MacDataErrorCode, ParsePkcs12MacDataFailure, ParsePkcs12MacDataResult, ParsedPkcs12MacData, Pkcs12MacOptions } from "./pkcs/pkcs12-mac.js";
8
8
  import { CreatePfxErrorCode, CreatePfxFailure, CreatePfxInput, CreatePfxResult, ParsePfxErrorCode, ParsePfxFailure, ParsePfxOptions, ParsePfxResult, ParsedPfx, ParsedPfxAttribute, ParsedPfxBag, ParsedPfxBagAttributes, PfxBagAttributesInput, PfxCertificateBagInput, PfxCertificateSource, PfxEncryptionOptions, PfxMaterial, PfxPrivateKeyBagInput, PfxPrivateKeySource, createPfx, parsePfxDer, parsePfxPem } from "./pkcs/pfx.js";
9
9
  import { CertificateMaterial, CreateCertificateInput, CreateSelfSignedCertificateInput, SelfSignedCertificateResult, ValidityInput, createCertificate, createSelfSignedCertificate } from "./x509/certificate.js";
10
- import { CreatePkcs7CertBagErrorCode, CreatePkcs7CertBagFailure, CreatePkcs7CertBagResult, CreatePkcs7SignedDataErrorCode, CreatePkcs7SignedDataFailure, CreatePkcs7SignedDataInput, CreatePkcs7SignedDataResult, ParsePkcs7CertBagResult, ParsePkcs7ErrorCode, ParsePkcs7Failure, ParsePkcs7SignedDataResult, ParsedPkcs7SignedData, ParsedPkcs7SignerInfo, Pkcs7CertBagMaterial, Pkcs7CertificateSource, Pkcs7SignedDataMaterial, Pkcs7Signer, VerifyPkcs7SignedDataFailure, VerifyPkcs7SignedDataResult, createPkcs7CertBag, createPkcs7SignedData, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, verifyPkcs7SignedData } from "./pkcs/pkcs7.js";
10
+ import { CreatePkcs7CertBagErrorCode, CreatePkcs7CertBagFailure, CreatePkcs7CertBagResult, CreatePkcs7SignedDataErrorCode, CreatePkcs7SignedDataFailure, CreatePkcs7SignedDataInput, CreatePkcs7SignedDataResult, ParsePkcs7CertBagResult, ParsePkcs7ErrorCode, ParsePkcs7Failure, ParsePkcs7SignedDataResult, ParsedPkcs7SignedData, ParsedPkcs7SignerInfo, ParsedPkcs7SignerInfoBase, Pkcs7CertBagMaterial, Pkcs7CertificateSource, Pkcs7SignedDataMaterial, Pkcs7Signer, VerifyPkcs7SignedDataFailure, VerifyPkcs7SignedDataResult, createPkcs7CertBag, createPkcs7SignedData, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, verifyPkcs7SignedData } from "./pkcs/pkcs7.js";
11
11
  import { CertificateRevocationListMaterial, CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailure, CheckCertificateRevocationAgainstCrlFailureDetails, CheckCertificateRevocationAgainstCrlGoodValue, CheckCertificateRevocationAgainstCrlInput, CheckCertificateRevocationAgainstCrlResult, CheckCertificateRevocationAgainstCrlRevokedValue, CheckCertificateRevocationAgainstCrlValue, CreateCertificateRevocationListInput, CrlApplicabilityFailureReason, CrlCertificateSource, CrlSource, ParseCertificateRevocationListErrorCode, ParseCertificateRevocationListFailure, ParseCertificateRevocationListResult, ParsedCertificateRevocationList, ParsedRevokedCertificate, RevocationReason, RevokedCertificateInput, ValidateCertificateRevocationListFailure, ValidateCertificateRevocationListInput, ValidateCertificateRevocationListResult, VerifyCertificateRevocationListSignatureFailure, VerifyCertificateRevocationListSignatureResult, checkCertificateRevocationAgainstCrl, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, validateCertificateRevocationList, verifyCertificateRevocationListSignature } from "./revocation/crl.js";
12
12
  import { CreateOcspRequestInput, CreateOcspRequestItemInput, CreateOcspResponseInput, CreateOcspSingleResponseInput, OcspCertStatus, OcspCertificateSource, OcspHashAlgorithm, OcspRequestMaterial, OcspRequestSource, OcspResponderRevocationPolicy, OcspResponseMaterial, OcspResponseStatus, ParseOcspRequestErrorCode, ParseOcspRequestFailure, ParseOcspRequestResult, ParseOcspResponseErrorCode, ParseOcspResponseFailure, ParseOcspResponseResult, ParsedOcspCertId, ParsedOcspRequest, ParsedOcspResponderId, ParsedOcspResponse, ParsedOcspSingleResponse, ValidateOcspResponseErrorCode, ValidateOcspResponseFailure, ValidateOcspResponseInput, ValidateOcspResponseResult, VerifyOcspResponseSignatureFailure, VerifyOcspResponseSignatureResult, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, validateOcspResponse, verifyOcspResponseSignature } from "./revocation/ocsp.js";
13
13
  import { CheckCertificateRevocationErrorCode, CheckCertificateRevocationFailureDetails, CheckCertificateRevocationInput, CheckCertificateRevocationResult, CheckCertificateRevocationValue, ConfiguredOcspResponder, ConfiguredOcspResponderCertificate, OcspResponderCandidate, OcspResponderSource, REVOCATION_INDETERMINATE_REASON_CODES, ResolveOcspResponderCandidatesInput, RevocationCertificateSource, RevocationCheckGoodValue, RevocationCheckIndeterminateValue, RevocationCheckRevokedValue, RevocationCrlEvidenceInput, RevocationEvidenceInput, RevocationEvidenceKind, RevocationIndeterminateEvidence, RevocationIndeterminateReasonCode, RevocationOcspEvidenceInput, RevocationStatus, checkCertificateRevocation, getCertificateOcspResponderUris, resolveOcspResponderCandidates } from "./revocation/revocation.js";
@@ -17,4 +17,4 @@ import { InitialNameConstraintsInput } from "./verify/name-constraints.js";
17
17
  import { ConstrainedPolicy, PolicyValidationInput, PolicyValidationOutcome } from "./verify/policy.js";
18
18
  import { BuildCandidatePathInput, BuildCandidatePathResult, CandidatePath, CertificateSource, ChainRevocationInput, CsrSource, EkuCheckFailure, EkuCheckPurpose, EkuCheckResult, TrustAnchor, VERIFY_ERROR_CODES, ValidateCandidatePathInput, ValidateCandidatePathResult, ValidateCandidatePathSuccess, ValidateForCaInput, ValidateForCodeSigningInput, ValidateForTlsClientInput, ValidateForTlsServerInput, VerifiedCertificateChain, VerifyCertificateChainInput, VerifyChainFailure, VerifyChainResult, VerifyErrorCode, VerifyFailureDetails, VerifyPurpose, VerifyRequestFailure, VerifyRequestResult, buildCandidatePath, checkExtendedKeyUsage, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest } from "./verify/verify.js";
19
19
  import { CreateCsrInput, CsrMaterial, createCertificateSigningRequest } from "./x509/csr.js";
20
- export { type AuthorityInformationAccess, type BasicConstraints, type BuildCandidatePathInput, type BuildCandidatePathResult, type CandidatePath, type CategorizePemBlocksResult, type CategorizedPemBlocks, type CertificateExtensionsInput, type CertificateMaterial, type CertificatePolicies, type CertificateRevocationListMaterial, type CertificateRevocationStatus, type CertificateSource, type ChainRevocationInput, type CheckCertificateRevocationAgainstCrlErrorCode, type CheckCertificateRevocationAgainstCrlFailure, type CheckCertificateRevocationAgainstCrlFailureDetails, type CheckCertificateRevocationAgainstCrlGoodValue, type CheckCertificateRevocationAgainstCrlInput, type CheckCertificateRevocationAgainstCrlResult, type CheckCertificateRevocationAgainstCrlRevokedValue, type CheckCertificateRevocationAgainstCrlValue, type CheckCertificateRevocationErrorCode, type CheckCertificateRevocationFailureDetails, type CheckCertificateRevocationInput, type CheckCertificateRevocationResult, type CheckCertificateRevocationValue, type CheckChainRevocationInput, type CheckChainRevocationResult, type CheckChainRevocationValue, type ConfiguredOcspResponder, type ConfiguredOcspResponderCertificate, type ConstrainedPolicy, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateInput, type CrlApplicabilityFailureReason, type CrlCertificateSource, type CrlSource, type CsrMaterial, type CsrSource, type DecodedExtensionMap, type DecodedExtensionValue, type DistributionPoint, type DistributionPointName, type DnsServiceIdentityInput, type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EkuCheckFailure, type EkuCheckPurpose, type EkuCheckResult, type EncryptedPkcs8Options, type ErrorResult, type ExtendedKeyUsage, type ExtensionDecoder, type ExtensionDecoderMap, type GeneralName, type GeneralSubtree, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyFailure, type ImportKeyResult, type ImportRsaKeyInput, type IndexedErrorResult, type IndexedMicro509Error, type InhibitAnyPolicy, type InitialNameConstraintsInput, type IpServiceIdentityInput, type IssuingDistributionPoint, type IssuingDistributionPointForAttributeCerts, type IssuingDistributionPointForCaCerts, type IssuingDistributionPointForUserCerts, type KeyAlgorithmInput, type KeyPairMaterial, type KeyUsage, type LegacyPemEncryptionOptions, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityFailureDetails, type MatchServiceIdentityFailureResult, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type Micro509Error, type NameAttribute, type NameConstraintForm, type NameConstraints, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspHashAlgorithm, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderRevocationPolicy, type OcspResponderSource, type OcspResponseMaterial, type OcspResponseSource, type OcspResponseStatus, type ParseCertificateErrorCode, type ParseCertificateFailure, type ParseCertificateResult, type ParseCertificateRevocationListErrorCode, type ParseCertificateRevocationListFailure, type ParseCertificateRevocationListResult, type ParseCertificateSigningRequestErrorCode, type ParseCertificateSigningRequestFailure, type ParseCertificateSigningRequestResult, type ParseOcspRequestErrorCode, type ParseOcspRequestFailure, type ParseOcspRequestResult, type ParseOcspResponseErrorCode, type ParseOcspResponseFailure, type ParseOcspResponseResult, type ParseOptions, type ParsePfxErrorCode, type ParsePfxFailure, type ParsePfxOptions, type ParsePfxResult, type ParsePkcs12MacDataErrorCode, type ParsePkcs12MacDataFailure, type ParsePkcs12MacDataResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspRequest, type ParsedOcspResponderId, type ParsedOcspResponse, type ParsedOcspSingleResponse, type ParsedPfx, type ParsedPfxAttribute, type ParsedPfxBag, type ParsedPfxBagAttributes, type ParsedPkcs12MacData, type ParsedPkcs7SignedData, type ParsedPkcs7SignerInfo, type ParsedRelativeDistinguishedName, type ParsedRevokedCertificate, type PemBlock, type PemDecodeResult, type PemErrorCode, type PemFailure, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncryptionOptions, type PfxMaterial, type PfxPrivateKeyBagInput, type PfxPrivateKeySource, type Pkcs12MacOptions, type Pkcs7CertBagMaterial, type Pkcs7CertificateSource, type Pkcs7SignedDataMaterial, type Pkcs7Signer, type PolicyConstraints, type PolicyInformation, type PolicyMapping, type PolicyMappings, type PolicyQualifierInfo, type PolicyValidationInput, type PolicyValidationOutcome, type PrivateKeyImportInput, type PublicKeyImportInput, REVOCATION_INDETERMINATE_REASONS, REVOCATION_INDETERMINATE_REASON_CODES, type RelativeDistinguishedNameInput, type ResolveOcspResponderCandidatesInput, type Result, type ResultError, type RevocationCertificateSource, type RevocationCheckGoodValue, type RevocationCheckIndeterminateValue, type RevocationCheckRevokedValue, type RevocationCrlEvidenceInput, type RevocationEvidenceInput, type RevocationEvidenceKind, type RevocationExecutionError, type RevocationIndeterminateEvidence, type RevocationIndeterminateReason, type RevocationIndeterminateReasonCode, type RevocationOcspEvidenceInput, type RevocationPolicy, type RevocationReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaScheme, type SelfSignedCertificateResult, type ServiceIdentityInput, type ServiceIdentityType, type SplitPemBlocksResult, type SrvServiceIdentityInput, type SubjectAltName, type TrustAnchor, type UriServiceIdentityInput, VERIFY_ERROR_CODES, type ValidateCandidatePathInput, type ValidateCandidatePathResult, type ValidateCandidatePathSuccess, type ValidateCertificateRevocationListFailure, type ValidateCertificateRevocationListInput, type ValidateCertificateRevocationListResult, type ValidateForCaInput, type ValidateForCodeSigningInput, type ValidateForTlsClientInput, type ValidateForTlsServerInput, type ValidateOcspResponseErrorCode, type ValidateOcspResponseFailure, type ValidateOcspResponseInput, type ValidateOcspResponseResult, type ValidityInput, type VerifiedCertificateChain, type VerifyCertificateChainInput, type VerifyCertificateRevocationListSignatureFailure, type VerifyCertificateRevocationListSignatureResult, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyOcspResponseSignatureFailure, type VerifyOcspResponseSignatureResult, type VerifyPkcs7SignedDataFailure, type VerifyPkcs7SignedDataResult, type VerifyPurpose, type VerifyRequestFailure, type VerifyRequestResult, buildCandidatePath, categorizePemBlocks, categorizePemBlocksOrThrow, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs8Der, importEncryptedPkcs8Pem, importEncryptedSec1Pem, importPkcs1Der, importPkcs1Pem, importPkcs8Base64, importPkcs8Der, importPkcs8Pem, importPrivateJwk, importPublicJwk, importSec1Der, importSec1Pem, importSpkiBase64, importSpkiDer, importSpkiPem, isCertificateRevoked, isResultError, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateDer, parseCertificatePem, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestPem, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, resolveOcspResponderCandidates, splitPemBlocks, splitPemBlocksOrThrow, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
20
+ export { type AuthorityInformationAccess, type BasicConstraints, type BuildCandidatePathInput, type BuildCandidatePathResult, type CandidatePath, type CategorizePemBlocksResult, type CategorizedPemBlocks, type CertificateExtensionsInput, type CertificateMaterial, type CertificatePolicies, type CertificateRevocationListMaterial, type CertificateRevocationStatus, type CertificateSource, type ChainRevocationInput, type CheckCertificateRevocationAgainstCrlErrorCode, type CheckCertificateRevocationAgainstCrlFailure, type CheckCertificateRevocationAgainstCrlFailureDetails, type CheckCertificateRevocationAgainstCrlGoodValue, type CheckCertificateRevocationAgainstCrlInput, type CheckCertificateRevocationAgainstCrlResult, type CheckCertificateRevocationAgainstCrlRevokedValue, type CheckCertificateRevocationAgainstCrlValue, type CheckCertificateRevocationErrorCode, type CheckCertificateRevocationFailureDetails, type CheckCertificateRevocationInput, type CheckCertificateRevocationResult, type CheckCertificateRevocationValue, type CheckChainRevocationInput, type CheckChainRevocationResult, type CheckChainRevocationValue, type ConfiguredOcspResponder, type ConfiguredOcspResponderCertificate, type ConstrainedPolicy, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateInput, type CrlApplicabilityFailureReason, type CrlCertificateSource, type CrlSource, type CsrMaterial, type CsrSource, type DecodedExtensionMap, type DecodedExtensionValue, type DecryptRsaOaepErrorCode, type DecryptRsaOaepFailure, type DecryptRsaOaepResult, type DistributionPoint, type DistributionPointName, type DnsServiceIdentityInput, type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EkuCheckFailure, type EkuCheckPurpose, type EkuCheckResult, type EncryptRsaOaepErrorCode, type EncryptRsaOaepFailure, type EncryptRsaOaepResult, type EncryptedPkcs8Options, type ErrorResult, type ExtendedKeyUsage, type ExtensionDecoder, type ExtensionDecoderMap, type GeneralName, type GeneralSubtree, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyFailure, type ImportKeyResult, type ImportRsaKeyInput, type IndexedErrorResult, type IndexedMicro509Error, type InhibitAnyPolicy, type InitialNameConstraintsInput, type IpServiceIdentityInput, type IssuingDistributionPoint, type IssuingDistributionPointBase, type IssuingDistributionPointForAttributeCerts, type IssuingDistributionPointForCaCerts, type IssuingDistributionPointForUserCerts, type KeyAlgorithmInput, type KeyPairMaterial, type KeyUsage, type LegacyPemEncryptionOptions, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityFailureDetails, type MatchServiceIdentityFailureResult, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type Micro509Error, type NameAttribute, type NameConstraintForm, type NameConstraints, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspHashAlgorithm, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderRevocationPolicy, type OcspResponderSource, type OcspResponseMaterial, type OcspResponseSource, type OcspResponseStatus, type ParseCertificateErrorCode, type ParseCertificateFailure, type ParseCertificateResult, type ParseCertificateRevocationListErrorCode, type ParseCertificateRevocationListFailure, type ParseCertificateRevocationListResult, type ParseCertificateSigningRequestErrorCode, type ParseCertificateSigningRequestFailure, type ParseCertificateSigningRequestResult, type ParseOcspRequestErrorCode, type ParseOcspRequestFailure, type ParseOcspRequestResult, type ParseOcspResponseErrorCode, type ParseOcspResponseFailure, type ParseOcspResponseResult, type ParseOptions, type ParsePfxErrorCode, type ParsePfxFailure, type ParsePfxOptions, type ParsePfxResult, type ParsePkcs12MacDataErrorCode, type ParsePkcs12MacDataFailure, type ParsePkcs12MacDataResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspRequest, type ParsedOcspResponderId, type ParsedOcspResponse, type ParsedOcspSingleResponse, type ParsedPfx, type ParsedPfxAttribute, type ParsedPfxBag, type ParsedPfxBagAttributes, type ParsedPkcs12MacData, type ParsedPkcs7SignedData, type ParsedPkcs7SignerInfo, type ParsedPkcs7SignerInfoBase, type ParsedRelativeDistinguishedName, type ParsedRevokedCertificate, type PemBlock, type PemDecodeResult, type PemErrorCode, type PemFailure, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncryptionOptions, type PfxMaterial, type PfxPrivateKeyBagInput, type PfxPrivateKeySource, type Pkcs12MacOptions, type Pkcs7CertBagMaterial, type Pkcs7CertificateSource, type Pkcs7SignedDataMaterial, type Pkcs7Signer, type PolicyConstraints, type PolicyInformation, type PolicyMapping, type PolicyMappings, type PolicyQualifierInfo, type PolicyValidationInput, type PolicyValidationOutcome, type PrivateKeyImportInput, type PublicKeyImportInput, REVOCATION_INDETERMINATE_REASONS, REVOCATION_INDETERMINATE_REASON_CODES, type RelativeDistinguishedNameInput, type ResolveOcspResponderCandidatesInput, type Result, type ResultError, type RevocationCertificateSource, type RevocationCheckGoodValue, type RevocationCheckIndeterminateValue, type RevocationCheckRevokedValue, type RevocationCrlEvidenceInput, type RevocationEvidenceInput, type RevocationEvidenceKind, type RevocationExecutionError, type RevocationIndeterminateEvidence, type RevocationIndeterminateReason, type RevocationIndeterminateReasonCode, type RevocationOcspEvidenceInput, type RevocationPolicy, type RevocationReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaOaepOptions, type RsaScheme, type RsaSignatureScheme, type SelfSignedCertificateResult, type ServiceIdentityInput, type ServiceIdentityType, type SplitPemBlocksResult, type SrvServiceIdentityInput, type SubjectAltName, type TrustAnchor, type UriServiceIdentityInput, VERIFY_ERROR_CODES, type ValidateCandidatePathInput, type ValidateCandidatePathResult, type ValidateCandidatePathSuccess, type ValidateCertificateRevocationListFailure, type ValidateCertificateRevocationListInput, type ValidateCertificateRevocationListResult, type ValidateForCaInput, type ValidateForCodeSigningInput, type ValidateForTlsClientInput, type ValidateForTlsServerInput, type ValidateOcspResponseErrorCode, type ValidateOcspResponseFailure, type ValidateOcspResponseInput, type ValidateOcspResponseResult, type ValidityInput, type VerifiedCertificateChain, type VerifyCertificateChainInput, type VerifyCertificateRevocationListSignatureFailure, type VerifyCertificateRevocationListSignatureResult, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyOcspResponseSignatureFailure, type VerifyOcspResponseSignatureResult, type VerifyPkcs7SignedDataFailure, type VerifyPkcs7SignedDataResult, type VerifyPurpose, type VerifyRequestFailure, type VerifyRequestResult, buildCandidatePath, categorizePemBlocks, categorizePemBlocksOrThrow, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, decryptRsaOaep, decryptRsaOaepOrThrow, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, getSubjectPublicKey, getSubjectPublicKeyOrThrow, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow, isCertificateRevoked, isResultError, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, resolveOcspResponderCandidates, splitPemBlocks, splitPemBlocksOrThrow, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
package/dist/index.js CHANGED
@@ -1 +1,15 @@
1
- import{isResultError as e,unwrap as t,unwrapOr as n}from"./result/result.js";import{categorizePemBlocks as r,categorizePemBlocksOrThrow as i,pemDecode as a,pemDecodeOrThrow as o,pemEncode as s,splitPemBlocks as c,splitPemBlocksOrThrow as l}from"./pem/pem.js";import{exportBinaryBase64 as u,exportEncryptedPkcs1Pem as d,exportEncryptedPkcs8Der as f,exportEncryptedPkcs8Pem as p,exportEncryptedSec1Pem as m,exportPkcs1Der as h,exportPkcs1Pem as g,exportPkcs8Der as _,exportPkcs8Pem as v,exportPrivateJwk as y,exportPublicJwk as b,exportSec1Der as x,exportSec1Pem as S,exportSpkiDer as C,exportSpkiPem as w,generateKeyPair as T,importEncryptedPkcs1Pem as E,importEncryptedPkcs8Der as D,importEncryptedPkcs8Pem as O,importEncryptedSec1Pem as k,importPkcs1Der as A,importPkcs1Pem as j,importPkcs8Base64 as M,importPkcs8Der as N,importPkcs8Pem as P,importPrivateJwk as F,importPublicJwk as I,importSec1Der as L,importSec1Pem as R,importSpkiBase64 as z,importSpkiDer as B,importSpkiPem as V}from"./keys/keys.js";import{decodeExtension as H,decodeExtensionMap as U,decodeExtensions as W,defineExtensionDecoder as G,defineExtensionDecoderMap as K,findExtension as q,parseCertificateChainPem as J,parseCertificateDer as Y,parseCertificatePem as X,parseCertificateSigningRequestDer as Z,parseCertificateSigningRequestPem as Q}from"./x509/parse.js";import{createPfx as $,parsePfxDer as ee,parsePfxPem as te}from"./pkcs/pfx.js";import{createPkcs7CertBag as ne,createPkcs7SignedData as re,parsePkcs7CertBagDer as ie,parsePkcs7CertBagPem as ae,parsePkcs7SignedDataDer as oe,parsePkcs7SignedDataPem as se,verifyPkcs7SignedData as ce}from"./pkcs/pkcs7.js";import{checkCertificateRevocationAgainstCrl as le,createCertificateRevocationList as ue,isCertificateRevoked as de,parseCertificateRevocationListDer as fe,parseCertificateRevocationListDerOrThrow as pe,parseCertificateRevocationListPem as me,parseCertificateRevocationListPemOrThrow as he,validateCertificateRevocationList as ge,verifyCertificateRevocationListSignature as _e}from"./revocation/crl.js";import{REVOCATION_INDETERMINATE_REASONS as ve,checkChainRevocation as ye}from"./revocation/chain.js";import{matchCertificateServiceIdentity as be,matchServiceIdentity as xe}from"./verify/identity.js";import{VERIFY_ERROR_CODES as Se,buildCandidatePath as Ce,checkExtendedKeyUsage as we,trustAnchorFromCertificate as Te,validateCandidatePath as Ee,validateForCa as De,validateForCodeSigning as Oe,validateForTlsClient as ke,validateForTlsServer as Ae,verifyCertificateChain as je,verifyCertificateSigningRequest as Me}from"./verify/verify.js";import{createOcspRequest as Ne,createOcspResponse as Pe,hasOcspNoCheckExtension as Fe,parseOcspRequestDer as Ie,parseOcspRequestDerOrThrow as Le,parseOcspRequestPem as Re,parseOcspRequestPemOrThrow as ze,parseOcspResponseDer as Be,parseOcspResponseDerOrThrow as Ve,parseOcspResponsePem as He,parseOcspResponsePemOrThrow as Ue,validateOcspResponse as We,verifyOcspResponseSignature as Ge}from"./revocation/ocsp.js";import{REVOCATION_INDETERMINATE_REASON_CODES as Ke,checkCertificateRevocation as qe,getCertificateOcspResponderUris as Je,resolveOcspResponderCandidates as Ye}from"./revocation/revocation.js";import{createCertificate as Xe,createSelfSignedCertificate as Ze}from"./x509/certificate.js";import{createCertificateSigningRequest as Qe}from"./x509/csr.js";export{ve as REVOCATION_INDETERMINATE_REASONS,Ke as REVOCATION_INDETERMINATE_REASON_CODES,Se as VERIFY_ERROR_CODES,Ce as buildCandidatePath,r as categorizePemBlocks,i as categorizePemBlocksOrThrow,qe as checkCertificateRevocation,le as checkCertificateRevocationAgainstCrl,ye as checkChainRevocation,we as checkExtendedKeyUsage,Xe as createCertificate,ue as createCertificateRevocationList,Qe as createCertificateSigningRequest,Ne as createOcspRequest,Pe as createOcspResponse,$ as createPfx,ne as createPkcs7CertBag,re as createPkcs7SignedData,Ze as createSelfSignedCertificate,H as decodeExtension,U as decodeExtensionMap,W as decodeExtensions,G as defineExtensionDecoder,K as defineExtensionDecoderMap,u as exportBinaryBase64,d as exportEncryptedPkcs1Pem,f as exportEncryptedPkcs8Der,p as exportEncryptedPkcs8Pem,m as exportEncryptedSec1Pem,h as exportPkcs1Der,g as exportPkcs1Pem,_ as exportPkcs8Der,v as exportPkcs8Pem,y as exportPrivateJwk,b as exportPublicJwk,x as exportSec1Der,S as exportSec1Pem,C as exportSpkiDer,w as exportSpkiPem,q as findExtension,T as generateKeyPair,Je as getCertificateOcspResponderUris,Fe as hasOcspNoCheckExtension,E as importEncryptedPkcs1Pem,D as importEncryptedPkcs8Der,O as importEncryptedPkcs8Pem,k as importEncryptedSec1Pem,A as importPkcs1Der,j as importPkcs1Pem,M as importPkcs8Base64,N as importPkcs8Der,P as importPkcs8Pem,F as importPrivateJwk,I as importPublicJwk,L as importSec1Der,R as importSec1Pem,z as importSpkiBase64,B as importSpkiDer,V as importSpkiPem,de as isCertificateRevoked,e as isResultError,be as matchCertificateServiceIdentity,xe as matchServiceIdentity,J as parseCertificateChainPem,Y as parseCertificateDer,X as parseCertificatePem,fe as parseCertificateRevocationListDer,pe as parseCertificateRevocationListDerOrThrow,me as parseCertificateRevocationListPem,he as parseCertificateRevocationListPemOrThrow,Z as parseCertificateSigningRequestDer,Q as parseCertificateSigningRequestPem,Ie as parseOcspRequestDer,Le as parseOcspRequestDerOrThrow,Re as parseOcspRequestPem,ze as parseOcspRequestPemOrThrow,Be as parseOcspResponseDer,Ve as parseOcspResponseDerOrThrow,He as parseOcspResponsePem,Ue as parseOcspResponsePemOrThrow,ee as parsePfxDer,te as parsePfxPem,ie as parsePkcs7CertBagDer,ae as parsePkcs7CertBagPem,oe as parsePkcs7SignedDataDer,se as parsePkcs7SignedDataPem,a as pemDecode,o as pemDecodeOrThrow,s as pemEncode,Ye as resolveOcspResponderCandidates,c as splitPemBlocks,l as splitPemBlocksOrThrow,Te as trustAnchorFromCertificate,t as unwrap,n as unwrapOr,Ee as validateCandidatePath,ge as validateCertificateRevocationList,De as validateForCa,Oe as validateForCodeSigning,ke as validateForTlsClient,Ae as validateForTlsServer,We as validateOcspResponse,je as verifyCertificateChain,_e as verifyCertificateRevocationListSignature,Me as verifyCertificateSigningRequest,Ge as verifyOcspResponseSignature,ce as verifyPkcs7SignedData};
1
+ import { isResultError, unwrap, unwrapOr } from "./result/result.js";
2
+ import { categorizePemBlocks, categorizePemBlocksOrThrow, pemDecode, pemDecodeOrThrow, pemEncode, splitPemBlocks, splitPemBlocksOrThrow } from "./pem/pem.js";
3
+ import { decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
4
+ import { decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, findExtension, getSubjectPublicKey, getSubjectPublicKeyOrThrow, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow } from "./x509/parse.js";
5
+ import { createPfx, parsePfxDer, parsePfxPem } from "./pkcs/pfx.js";
6
+ import { createPkcs7CertBag, createPkcs7SignedData, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, verifyPkcs7SignedData } from "./pkcs/pkcs7.js";
7
+ import { checkCertificateRevocationAgainstCrl, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, validateCertificateRevocationList, verifyCertificateRevocationListSignature } from "./revocation/crl.js";
8
+ import { REVOCATION_INDETERMINATE_REASONS, checkChainRevocation } from "./revocation/chain.js";
9
+ import { matchCertificateServiceIdentity, matchServiceIdentity } from "./verify/identity.js";
10
+ import { VERIFY_ERROR_CODES, buildCandidatePath, checkExtendedKeyUsage, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest } from "./verify/verify.js";
11
+ import { createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, validateOcspResponse, verifyOcspResponseSignature } from "./revocation/ocsp.js";
12
+ import { REVOCATION_INDETERMINATE_REASON_CODES, checkCertificateRevocation, getCertificateOcspResponderUris, resolveOcspResponderCandidates } from "./revocation/revocation.js";
13
+ import { createCertificate, createSelfSignedCertificate } from "./x509/certificate.js";
14
+ import { createCertificateSigningRequest } from "./x509/csr.js";
15
+ export { REVOCATION_INDETERMINATE_REASONS, REVOCATION_INDETERMINATE_REASON_CODES, VERIFY_ERROR_CODES, buildCandidatePath, categorizePemBlocks, categorizePemBlocksOrThrow, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, decryptRsaOaep, decryptRsaOaepOrThrow, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, getSubjectPublicKey, getSubjectPublicKeyOrThrow, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow, isCertificateRevoked, isResultError, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, resolveOcspResponderCandidates, splitPemBlocks, splitPemBlocksOrThrow, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
@@ -1,2 +1,280 @@
1
- import{readElement as e}from"./der.js";const t=new TextDecoder(`utf-8`,{fatal:!0}),n=/^[A-Za-z0-9 '()+,\-./:=?]*$/u;function r(e){if(e.length===0)throw Error(`OID is empty`);let t=h(e,0),n=t.nextOffset,r=t.value<40?[0,t.value]:t.value<80?[1,t.value-40]:[2,t.value-80];for(;n<e.length;){let t=h(e,n);r.push(t.value),n=t.nextOffset}return r.join(`.`)}function i(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function a(e){let t=new ArrayBuffer(e.length);return new Uint8Array(t).set(e),t}function o(t,n){let r=[],i=n.start;for(;i<n.end;){let a=e(t,i);if(a.end>n.end)throw Error(`DER child exceeds parent length`);r.push(a),i=a.end}if(i!==n.end)throw Error(`Malformed DER container`);return r}function s(e,t){if(e===void 0)throw Error(`Missing ${t}`);return e}function c(e){if(e.tag!==3)throw Error(`Expected BIT STRING`);let t=e.value[0];if(t===void 0||t>7)throw Error(`Invalid BIT STRING`);if(t!==0)throw Error(`BIT STRING must have zero unused bits`);return e.value.slice(1)}function l(e){if(e.tag===23){let t=_(e.value,`UTCTime`),n=/^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/.exec(t);if(n===null)throw Error(`Invalid UTCTime`);let r=s(n[1],`UTCTime year`),i=s(n[2],`UTCTime month`),a=s(n[3],`UTCTime day`),o=s(n[4],`UTCTime hour`),c=s(n[5],`UTCTime minute`),l=s(n[6],`UTCTime second`),u=Number.parseInt(r,10);return m(u>=50?1900+u:2e3+u,i,a,o,c,l,`UTCTime`)}if(e.tag===24){let t=_(e.value,`GeneralizedTime`),n=/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/.exec(t);if(n===null)throw Error(`Invalid GeneralizedTime`);let r=s(n[1],`GeneralizedTime year`),i=s(n[2],`GeneralizedTime month`),a=s(n[3],`GeneralizedTime day`),o=s(n[4],`GeneralizedTime hour`),c=s(n[5],`GeneralizedTime minute`),l=s(n[6],`GeneralizedTime second`);return m(Number.parseInt(r,10),i,a,o,c,l,`GeneralizedTime`)}throw Error(`Unsupported time tag: ${e.tag}`)}function u(e){let t=e[0];if(t===void 0)throw Error(`INTEGER is empty`);if(t&128)throw Error(`INTEGER must be non-negative`);if(e.length>1&&t===0&&!((e[1]??0)&128))throw Error(`INTEGER must use minimal encoding`);if(e.length>6)throw Error(`Integer too large for safe number (${e.length} bytes)`);let n=0;for(let t of e)n=n*256+t;return n}function d(e,t=`INTEGER`){if(t===`INTEGER`)return u(e);try{return u(e)}catch(n){if(!(n instanceof Error))throw n;switch(n.message){case`INTEGER is empty`:throw Error(`${t} is empty`);case`INTEGER must be non-negative`:throw Error(`${t} must be non-negative`);case`INTEGER must use minimal encoding`:throw Error(`${t} must use minimal encoding`);default:throw n.message.startsWith(`Integer too large for safe number`)?Error(`${t} too large for safe number (${e.length} bytes)`):n}}}function f(e){let t=e.length%2==0?e:`0${e}`,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e+=1){let r=t.slice(e*2,e*2+2);if(!/^[0-9a-fA-F]{2}$/.test(r))throw Error(`Invalid hex byte: ${r}`);n[e]=Number.parseInt(r,16)}return n}function p(e){if(e.length!==1)throw Error(`BOOLEAN must contain exactly one octet`);let t=e[0];if(t!==0&&t!==255)throw Error(`BOOLEAN must use DER encoding`);return t===255}function m(e,t,n,r,i,a,o){let s=Number.parseInt(t,10),c=Number.parseInt(n,10),l=Number.parseInt(r,10),u=Number.parseInt(i,10),d=Number.parseInt(a,10),f=new Date(Date.UTC(e,s-1,c,l,u,d));if(Number.isNaN(f.getTime())||f.getUTCFullYear()!==e||f.getUTCMonth()!==s-1||f.getUTCDate()!==c||f.getUTCHours()!==l||f.getUTCMinutes()!==u||f.getUTCSeconds()!==d)throw Error(`Invalid ${o}`);return f}function h(e,t){let n=e[t];if(n===void 0)throw Error(`Malformed OID`);if(n===128)throw Error(`Malformed OID: non-minimal base-128 encoding`);let r=0,i=t;for(;i<e.length;i+=1){let t=e[i];if(t===void 0)throw Error(`Malformed OID`);let n=t&127;if(r>Math.floor((2**53-1-n)/128))throw Error(`Malformed OID: overflow/non-minimal or too-large subidentifier`);if(r=r*128+n,!(t&128))return{value:r,nextOffset:i+1}}throw Error(`Malformed OID: incomplete continuation`)}function g(e,t){switch(e){case 12:return _(t,`UTF8String`);case 19:return b(t);case 22:return y(t);case 20:throw Error(`Unsupported string tag: 20 (TeletexString)`);case 28:return S(t);case 30:return x(t);default:throw Error(`Unsupported string tag: ${e}`)}}function _(e,n){try{return t.decode(e)}catch(e){throw e instanceof Error?Error(`Invalid ${n}: invalid UTF-8`,{cause:e}):e}}function v(e,t){let n=``;for(let r of e){if(r>127)throw Error(`Invalid ${t}: contains non-ASCII bytes`);n+=String.fromCharCode(r)}return n}function y(e){return v(e,`IA5String`)}function b(e){let t=v(e,`PrintableString`);if(!n.test(t))throw Error(`Invalid PrintableString: contains characters outside the allowed set`);return t}function x(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`);let a=r<<8|i;if(a>=55296&&a<=57343)throw Error(`Invalid BMPString code point`);t+=String.fromCharCode(a)}return t}function S(e){if(e.length%4!=0)throw Error(`Invalid UniversalString length`);let t=``;for(let n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2],o=e[n+3];if(r===void 0||i===void 0||a===void 0||o===void 0)throw Error(`Invalid UniversalString content`);let s=((r*256+i)*256+a)*256+o;if(s>1114111||s>=55296&&s<=57343)throw Error(`Invalid UniversalString code point`);t+=String.fromCodePoint(s)}return t}export{o as childrenOf,p as decodeBoolean,u as decodeIntegerNumber,d as decodeNonNegativeIntegerNumber,r as decodeObjectIdentifier,g as decodeString,c as extractBitStringValue,f as hexToBytes,l as parseTime,s as requireElement,a as toArrayBuffer,i as toHex};
2
- //# sourceMappingURL=asn1.js.map
1
+ import { readElement } from "./der.js";
2
+ //#region src/internal/asn1/asn1.ts
3
+ /**
4
+ * ASN.1 decoding helpers used by the higher-level DER, parse, and crypto modules.
5
+ *
6
+ * These utilities stay intentionally small and strict so malformed input fails early and
7
+ * higher-level modules can build on one consistent decoding layer.
8
+ *
9
+ * @module
10
+ */
11
+ /** Shared UTF-8 text decoder for ASN.1 string types. */
12
+ const textDecoder = new TextDecoder("utf-8", { fatal: true });
13
+ const PRINTABLE_STRING_PATTERN = /^[A-Za-z0-9 '()+,\-./:=?]*$/u;
14
+ /**
15
+ * Decodes a DER-encoded OBJECT IDENTIFIER value into its dotted-decimal string
16
+ * form (e.g. `"1.2.840.113549.1.1.1"`).
17
+ *
18
+ * Throws on empty input, truncated multi-byte sub-identifiers, or incomplete
19
+ * continuation octets.
20
+ */
21
+ function decodeObjectIdentifier(bytes) {
22
+ if (bytes.length === 0) throw new Error("OID is empty");
23
+ const firstSubidentifier = decodeOidSubidentifier(bytes, 0);
24
+ let offset = firstSubidentifier.nextOffset;
25
+ const values = firstSubidentifier.value < 40 ? [0, firstSubidentifier.value] : firstSubidentifier.value < 80 ? [1, firstSubidentifier.value - 40] : [2, firstSubidentifier.value - 80];
26
+ while (offset < bytes.length) {
27
+ const subidentifier = decodeOidSubidentifier(bytes, offset);
28
+ values.push(subidentifier.value);
29
+ offset = subidentifier.nextOffset;
30
+ }
31
+ return values.join(".");
32
+ }
33
+ /** Converts raw bytes to a lowercase hex string with no separator. */
34
+ function toHex(bytes) {
35
+ return Array.from(bytes, (value) => value.toString(16).padStart(2, "0")).join("");
36
+ }
37
+ /**
38
+ * Copies a `Uint8Array` into a standalone `ArrayBuffer` suitable for
39
+ * Web Crypto operations that require a non-shared backing buffer.
40
+ */
41
+ function toArrayBuffer(bytes) {
42
+ const out = new ArrayBuffer(bytes.length);
43
+ new Uint8Array(out).set(bytes);
44
+ return out;
45
+ }
46
+ /**
47
+ * Iterates through all direct child TLV elements inside a constructed
48
+ * {@linkcode DerElement} (SEQUENCE, SET, or context-tagged container).
49
+ *
50
+ * Throws if any child overflows the parent boundary or if there is
51
+ * leftover data between the last child and the parent end offset.
52
+ */
53
+ function childrenOf(source, parent) {
54
+ const children = [];
55
+ let offset = parent.start;
56
+ while (offset < parent.end) {
57
+ const child = readElement(source, offset);
58
+ if (child.end > parent.end) throw new Error("DER child exceeds parent length");
59
+ children.push(child);
60
+ offset = child.end;
61
+ }
62
+ if (offset !== parent.end) throw new Error("Malformed DER container");
63
+ return children;
64
+ }
65
+ /**
66
+ * Asserts that a value is not `undefined`, returning it narrowed.
67
+ * Used to enforce the presence of mandatory ASN.1 fields during parsing.
68
+ *
69
+ * @param label Human-readable field name included in the error message on failure.
70
+ */
71
+ function requireElement(value, label) {
72
+ if (value === void 0) throw new Error(`Missing ${label}`);
73
+ return value;
74
+ }
75
+ /**
76
+ * Strips the leading "unused bits" octet from a BIT STRING element,
77
+ * returning just the payload bytes. Throws if the tag is not `0x03`.
78
+ *
79
+ * Used to extract signature values and public keys from their BIT STRING wrapper.
80
+ */
81
+ function extractBitStringValue(element) {
82
+ if (element.tag !== 3) throw new Error("Expected BIT STRING");
83
+ const unusedBits = element.value[0];
84
+ if (unusedBits === void 0 || unusedBits > 7) throw new Error("Invalid BIT STRING");
85
+ if (unusedBits !== 0) throw new Error("BIT STRING must have zero unused bits");
86
+ return element.value.slice(1);
87
+ }
88
+ /**
89
+ * Parses a {@linkcode DerElement} with tag UTCTime (`0x17`) or GeneralizedTime (`0x18`)
90
+ * into a `Date`.
91
+ *
92
+ * For UTCTime, the two-digit year is interpreted per RFC 5280: values >= 50 map
93
+ * to 19xx, values < 50 map to 20xx. Throws on unrecognized time tags.
94
+ */
95
+ function parseTime(element) {
96
+ if (element.tag === 23) {
97
+ const value = decodeUtf8Text(element.value, "UTCTime");
98
+ const match = /^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/.exec(value);
99
+ if (match === null) throw new Error("Invalid UTCTime");
100
+ const yearText = requireElement(match[1], "UTCTime year");
101
+ const monthText = requireElement(match[2], "UTCTime month");
102
+ const dayText = requireElement(match[3], "UTCTime day");
103
+ const hourText = requireElement(match[4], "UTCTime hour");
104
+ const minuteText = requireElement(match[5], "UTCTime minute");
105
+ const secondText = requireElement(match[6], "UTCTime second");
106
+ const year = Number.parseInt(yearText, 10);
107
+ return buildStrictUtcDate(year >= 50 ? 1900 + year : 2e3 + year, monthText, dayText, hourText, minuteText, secondText, "UTCTime");
108
+ }
109
+ if (element.tag === 24) {
110
+ const value = decodeUtf8Text(element.value, "GeneralizedTime");
111
+ const match = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/.exec(value);
112
+ if (match === null) throw new Error("Invalid GeneralizedTime");
113
+ const yearText = requireElement(match[1], "GeneralizedTime year");
114
+ const monthText = requireElement(match[2], "GeneralizedTime month");
115
+ const dayText = requireElement(match[3], "GeneralizedTime day");
116
+ const hourText = requireElement(match[4], "GeneralizedTime hour");
117
+ const minuteText = requireElement(match[5], "GeneralizedTime minute");
118
+ const secondText = requireElement(match[6], "GeneralizedTime second");
119
+ return buildStrictUtcDate(Number.parseInt(yearText, 10), monthText, dayText, hourText, minuteText, secondText, "GeneralizedTime");
120
+ }
121
+ throw new Error(`Unsupported time tag: ${element.tag}`);
122
+ }
123
+ /**
124
+ * Decodes a big-endian unsigned byte sequence into a JavaScript `number`.
125
+ * Throws if the value exceeds 6 bytes (48 bits), which is the safe-integer
126
+ * boundary for lossless arithmetic.
127
+ */
128
+ function decodeIntegerNumber(bytes) {
129
+ const first = bytes[0];
130
+ if (first === void 0) throw new Error("INTEGER is empty");
131
+ if ((first & 128) !== 0) throw new Error("INTEGER must be non-negative");
132
+ if (bytes.length > 1 && first === 0 && ((bytes[1] ?? 0) & 128) === 0) throw new Error("INTEGER must use minimal encoding");
133
+ if (bytes.length > 6) throw new Error(`Integer too large for safe number (${bytes.length} bytes)`);
134
+ let value = 0;
135
+ for (const byte of bytes) value = value * 256 + byte;
136
+ return value;
137
+ }
138
+ /**
139
+ * Like {@linkcode decodeIntegerNumber}, but optionally rewrites thrown error
140
+ * messages with a caller-specific field label.
141
+ *
142
+ * @param label Field name for error messages (defaults to `"INTEGER"`).
143
+ */
144
+ function decodeNonNegativeIntegerNumber(bytes, label = "INTEGER") {
145
+ if (label === "INTEGER") return decodeIntegerNumber(bytes);
146
+ try {
147
+ return decodeIntegerNumber(bytes);
148
+ } catch (error) {
149
+ if (!(error instanceof Error)) throw error;
150
+ switch (error.message) {
151
+ case "INTEGER is empty": throw new Error(`${label} is empty`);
152
+ case "INTEGER must be non-negative": throw new Error(`${label} must be non-negative`);
153
+ case "INTEGER must use minimal encoding": throw new Error(`${label} must use minimal encoding`);
154
+ default:
155
+ if (error.message.startsWith("Integer too large for safe number")) throw new Error(`${label} too large for safe number (${bytes.length} bytes)`);
156
+ throw error;
157
+ }
158
+ }
159
+ }
160
+ /**
161
+ * Converts a hex string (even or odd length) to a `Uint8Array`.
162
+ * Odd-length strings are left-padded with a zero nibble.
163
+ */
164
+ function hexToBytes(value) {
165
+ const normalized = value.length % 2 === 0 ? value : `0${value}`;
166
+ const out = new Uint8Array(normalized.length / 2);
167
+ for (let index = 0; index < out.length; index += 1) {
168
+ const chunk = normalized.slice(index * 2, index * 2 + 2);
169
+ if (!/^[0-9a-fA-F]{2}$/.test(chunk)) throw new Error(`Invalid hex byte: ${chunk}`);
170
+ out[index] = Number.parseInt(chunk, 16);
171
+ }
172
+ return out;
173
+ }
174
+ /** Decodes a DER BOOLEAN value: any non-zero first byte is `true`. */
175
+ function decodeBoolean(bytes) {
176
+ if (bytes.length !== 1) throw new Error("BOOLEAN must contain exactly one octet");
177
+ const value = bytes[0];
178
+ if (value !== 0 && value !== 255) throw new Error("BOOLEAN must use DER encoding");
179
+ return value === 255;
180
+ }
181
+ function buildStrictUtcDate(year, monthText, dayText, hourText, minuteText, secondText, label) {
182
+ const month = Number.parseInt(monthText, 10);
183
+ const day = Number.parseInt(dayText, 10);
184
+ const hour = Number.parseInt(hourText, 10);
185
+ const minute = Number.parseInt(minuteText, 10);
186
+ const second = Number.parseInt(secondText, 10);
187
+ const date = new Date(Date.UTC(year, month - 1, day, hour, minute, second));
188
+ if (Number.isNaN(date.getTime()) || date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day || date.getUTCHours() !== hour || date.getUTCMinutes() !== minute || date.getUTCSeconds() !== second) throw new Error(`Invalid ${label}`);
189
+ return date;
190
+ }
191
+ function decodeOidSubidentifier(bytes, start) {
192
+ const first = bytes[start];
193
+ if (first === void 0) throw new Error("Malformed OID");
194
+ if (first === 128) throw new Error("Malformed OID: non-minimal base-128 encoding");
195
+ let value = 0;
196
+ let offset = start;
197
+ for (; offset < bytes.length; offset += 1) {
198
+ const next = bytes[offset];
199
+ if (next === void 0) throw new Error("Malformed OID");
200
+ const digit = next & 127;
201
+ if (value > Math.floor((Number.MAX_SAFE_INTEGER - digit) / 128)) throw new Error("Malformed OID: overflow/non-minimal or too-large subidentifier");
202
+ value = value * 128 + digit;
203
+ if ((next & 128) === 0) return {
204
+ value,
205
+ nextOffset: offset + 1
206
+ };
207
+ }
208
+ throw new Error("Malformed OID: incomplete continuation");
209
+ }
210
+ /**
211
+ * Decodes a DER string element by tag. Supports UTF8String (`0x0c`),
212
+ * PrintableString (`0x13`), IA5String (`0x16`), UniversalString (`0x1c`),
213
+ * and BMPString (`0x1e`).
214
+ * Throws on unsupported string tags.
215
+ */
216
+ function decodeString(tag, bytes) {
217
+ switch (tag) {
218
+ case 12: return decodeUtf8Text(bytes, "UTF8String");
219
+ case 19: return decodePrintableString(bytes);
220
+ case 22: return decodeIa5String(bytes);
221
+ case 20: throw new Error("Unsupported string tag: 20 (TeletexString)");
222
+ case 28: return decodeUniversalString(bytes);
223
+ case 30: return decodeBmpString(bytes);
224
+ default: throw new Error(`Unsupported string tag: ${tag}`);
225
+ }
226
+ }
227
+ function decodeUtf8Text(bytes, label) {
228
+ try {
229
+ return textDecoder.decode(bytes);
230
+ } catch (error) {
231
+ if (error instanceof Error) throw new Error(`Invalid ${label}: invalid UTF-8`, { cause: error });
232
+ throw error;
233
+ }
234
+ }
235
+ function decodeAsciiString(bytes, label) {
236
+ let value = "";
237
+ for (const byte of bytes) {
238
+ if (byte > 127) throw new Error(`Invalid ${label}: contains non-ASCII bytes`);
239
+ value += String.fromCharCode(byte);
240
+ }
241
+ return value;
242
+ }
243
+ function decodeIa5String(bytes) {
244
+ return decodeAsciiString(bytes, "IA5String");
245
+ }
246
+ function decodePrintableString(bytes) {
247
+ const value = decodeAsciiString(bytes, "PrintableString");
248
+ if (!PRINTABLE_STRING_PATTERN.test(value)) throw new Error("Invalid PrintableString: contains characters outside the allowed set");
249
+ return value;
250
+ }
251
+ function decodeBmpString(bytes) {
252
+ if (bytes.length % 2 !== 0) throw new Error("Invalid BMPString length");
253
+ let value = "";
254
+ for (let index = 0; index < bytes.length; index += 2) {
255
+ const left = bytes[index];
256
+ const right = bytes[index + 1];
257
+ if (left === void 0 || right === void 0) throw new Error("Invalid BMPString content");
258
+ const codeUnit = left << 8 | right;
259
+ if (codeUnit >= 55296 && codeUnit <= 57343) throw new Error("Invalid BMPString code point");
260
+ value += String.fromCharCode(codeUnit);
261
+ }
262
+ return value;
263
+ }
264
+ function decodeUniversalString(bytes) {
265
+ if (bytes.length % 4 !== 0) throw new Error("Invalid UniversalString length");
266
+ let value = "";
267
+ for (let index = 0; index < bytes.length; index += 4) {
268
+ const first = bytes[index];
269
+ const second = bytes[index + 1];
270
+ const third = bytes[index + 2];
271
+ const fourth = bytes[index + 3];
272
+ if (first === void 0 || second === void 0 || third === void 0 || fourth === void 0) throw new Error("Invalid UniversalString content");
273
+ const codePoint = ((first * 256 + second) * 256 + third) * 256 + fourth;
274
+ if (codePoint > 1114111 || codePoint >= 55296 && codePoint <= 57343) throw new Error("Invalid UniversalString code point");
275
+ value += String.fromCodePoint(codePoint);
276
+ }
277
+ return value;
278
+ }
279
+ //#endregion
280
+ export { childrenOf, decodeBoolean, decodeIntegerNumber, decodeNonNegativeIntegerNumber, decodeObjectIdentifier, decodeString, extractBitStringValue, hexToBytes, parseTime, requireElement, toArrayBuffer, toHex };