micro509 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -4
- package/dist/index.js +15 -15
- package/dist/internal/asn1/asn1.js +145 -186
- package/dist/internal/asn1/asn1.js.map +1 -0
- package/dist/internal/asn1/der.js +210 -227
- package/dist/internal/asn1/der.js.map +1 -0
- package/dist/internal/asn1/oids.js +297 -101
- package/dist/internal/asn1/oids.js.map +1 -0
- package/dist/internal/asn1/oids2.js +69 -0
- package/dist/internal/asn1/oids2.js.map +1 -0
- package/dist/internal/crypto/algorithm-names.js +37 -35
- package/dist/internal/crypto/algorithm-names.js.map +1 -0
- package/dist/internal/crypto/ecdsa.js +25 -28
- package/dist/internal/crypto/ecdsa.js.map +1 -0
- package/dist/internal/crypto/hash.js +56 -117
- package/dist/internal/crypto/hash.js.map +1 -0
- package/dist/internal/crypto/pbes2.js +122 -133
- package/dist/internal/crypto/pbes2.js.map +1 -0
- package/dist/internal/crypto/rsa-pss.js +118 -124
- package/dist/internal/crypto/rsa-pss.js.map +1 -0
- package/dist/internal/crypto/sig-verify.js +87 -99
- package/dist/internal/crypto/sig-verify.js.map +1 -0
- package/dist/internal/crypto/signing.d.ts +12 -8
- package/dist/internal/crypto/signing.js +53 -55
- package/dist/internal/crypto/signing.js.map +1 -0
- package/dist/internal/crypto/webcrypto.js +5 -3
- package/dist/internal/crypto/webcrypto.js.map +1 -0
- package/dist/internal/shared/base64.js +10 -9
- package/dist/internal/shared/base64.js.map +1 -0
- package/dist/internal/shared/dn.js +50 -57
- package/dist/internal/shared/dn.js.map +1 -0
- package/dist/internal/shared/ip.js +43 -53
- package/dist/internal/shared/ip.js.map +1 -0
- package/dist/internal/verify/name-constraints-engine.js +211 -239
- package/dist/internal/verify/name-constraints-engine.js.map +1 -0
- package/dist/internal/verify/policy-engine.js +228 -247
- package/dist/internal/verify/policy-engine.js.map +1 -0
- package/dist/internal/verify/verify-path.js +213 -228
- package/dist/internal/verify/verify-path.js.map +1 -0
- package/dist/internal/x509/extension-bits.js +62 -59
- package/dist/internal/x509/extension-bits.js.map +1 -0
- package/dist/internal/x509/extension-registry.js +133 -164
- package/dist/internal/x509/extension-registry.js.map +1 -0
- package/dist/internal/x509/name-fields.js +35 -41
- package/dist/internal/x509/name-fields.js.map +1 -0
- package/dist/keys/keys.d.ts +626 -447
- package/dist/keys/keys.js +652 -404
- package/dist/keys/keys.js.map +1 -0
- package/dist/keys.d.ts +2 -2
- package/dist/keys.js +2 -2
- package/dist/pem/pem.d.ts +46 -46
- package/dist/pem/pem.js +62 -81
- package/dist/pem/pem.js.map +1 -0
- package/dist/pem.js +2 -2
- package/dist/pkcs/pfx.d.ts +96 -80
- package/dist/pkcs/pfx.js +191 -231
- package/dist/pkcs/pfx.js.map +1 -0
- package/dist/pkcs/pkcs12-mac.d.ts +20 -18
- package/dist/pkcs/pkcs12-mac.js +90 -111
- package/dist/pkcs/pkcs12-mac.js.map +1 -0
- package/dist/pkcs/pkcs7.d.ts +118 -69
- package/dist/pkcs/pkcs7.js +401 -443
- package/dist/pkcs/pkcs7.js.map +1 -0
- package/dist/pkcs.d.ts +2 -2
- package/dist/pkcs.js +4 -4
- package/dist/result/result.d.ts +37 -32
- package/dist/result/result.js +46 -44
- package/dist/result/result.js.map +1 -0
- package/dist/result.js +2 -2
- package/dist/revocation/chain.d.ts +138 -119
- package/dist/revocation/chain.js +248 -281
- package/dist/revocation/chain.js.map +1 -0
- package/dist/revocation/crl.d.ts +125 -123
- package/dist/revocation/crl.js +653 -745
- package/dist/revocation/crl.js.map +1 -0
- package/dist/revocation/ocsp.d.ts +183 -177
- package/dist/revocation/ocsp.js +581 -638
- package/dist/revocation/ocsp.js.map +1 -0
- package/dist/revocation/revocation.d.ts +26 -26
- package/dist/revocation/revocation.js +104 -125
- package/dist/revocation/revocation.js.map +1 -0
- package/dist/revocation.js +5 -5
- package/dist/verify/identity.d.ts +42 -42
- package/dist/verify/identity.js +158 -167
- package/dist/verify/identity.js.map +1 -0
- package/dist/verify/name-constraints.d.ts +7 -7
- package/dist/verify/policy.d.ts +10 -10
- package/dist/verify/verify.d.ts +163 -163
- package/dist/verify/verify.js +396 -392
- package/dist/verify/verify.js.map +1 -0
- package/dist/verify.js +3 -3
- package/dist/x509/certificate.d.ts +117 -117
- package/dist/x509/certificate.js +51 -60
- package/dist/x509/certificate.js.map +1 -0
- package/dist/x509/csr.d.ts +25 -25
- package/dist/x509/csr.js +26 -30
- package/dist/x509/csr.js.map +1 -0
- package/dist/x509/extensions.d.ts +228 -184
- package/dist/x509/extensions.js +175 -200
- package/dist/x509/extensions.js.map +1 -0
- package/dist/x509/name.d.ts +94 -93
- package/dist/x509/name.js +30 -29
- package/dist/x509/name.js.map +1 -0
- package/dist/x509/parse.d.ts +185 -185
- package/dist/x509/parse.js +638 -676
- package/dist/x509/parse.js.map +1 -0
- package/dist/x509.js +6 -6
- package/package.json +79 -41
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, derivePublicKey, 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";
|
|
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
|
+
import { ParsePkcs12MacDataErrorCode, ParsePkcs12MacDataFailure, ParsePkcs12MacDataResult, ParsedPkcs12MacData, Pkcs12MacOptions } from "./pkcs/pkcs12-mac.js";
|
|
4
5
|
import { NameAttribute, NameFieldKey, NameInput, NameObject, RelativeDistinguishedNameInput } from "./x509/name.js";
|
|
5
6
|
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
7
|
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
|
-
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, ParsedPkcs7SignerInfoBase, 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, VerifyPkcs7SignedDataErrorCode, VerifyPkcs7SignedDataFailure, VerifyPkcs7SignedDataOptions, 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 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 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, derivePublicKey, 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 };
|
|
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 VerifyPkcs7SignedDataErrorCode, type VerifyPkcs7SignedDataFailure, type VerifyPkcs7SignedDataOptions, 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,15 +1,15 @@
|
|
|
1
|
-
import { isResultError, unwrap, unwrapOr } from "./result/result.js";
|
|
2
|
-
import { categorizePemBlocks, categorizePemBlocksOrThrow, pemDecode, pemDecodeOrThrow, pemEncode, splitPemBlocks, splitPemBlocksOrThrow } from "./pem/pem.js";
|
|
3
|
-
import { derivePublicKey, 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
|
|
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 {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
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, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, 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
|
+
import { isResultError as e, unwrap as t, unwrapOr as n } from "./result/result.js";
|
|
2
|
+
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";
|
|
3
|
+
import { decryptRsaOaep as u, decryptRsaOaepOrThrow as d, derivePublicKey as f, encryptRsaOaep as p, encryptRsaOaepOrThrow as m, exportBinaryBase64 as h, exportEncryptedPkcs1Pem as g, exportEncryptedPkcs8Der as _, exportEncryptedPkcs8Pem as v, exportEncryptedSec1Pem as y, exportPkcs1Der as b, exportPkcs1Pem as x, exportPkcs8Der as S, exportPkcs8Pem as C, exportPrivateJwk as w, exportPublicJwk as T, exportSec1Der as E, exportSec1Pem as D, exportSpkiDer as O, exportSpkiPem as k, generateKeyPair as A, importEncryptedPkcs1Pem as j, importEncryptedPkcs1PemOrThrow as M, importEncryptedPkcs8Der as N, importEncryptedPkcs8DerOrThrow as P, importEncryptedPkcs8Pem as F, importEncryptedPkcs8PemOrThrow as I, importEncryptedSec1Pem as L, importEncryptedSec1PemOrThrow as R, importPkcs1Der as z, importPkcs1DerOrThrow as B, importPkcs1Pem as V, importPkcs1PemOrThrow as H, importPkcs8Base64 as U, importPkcs8Base64OrThrow as W, importPkcs8Der as G, importPkcs8DerOrThrow as K, importPkcs8Pem as q, importPkcs8PemOrThrow as J, importPrivateJwk as Y, importPrivateJwkOrThrow as X, importPublicJwk as Z, importPublicJwkOrThrow as Q, importSec1Der as $, importSec1DerOrThrow as ee, importSec1Pem as te, importSec1PemOrThrow as ne, importSpkiBase64 as re, importSpkiBase64OrThrow as ie, importSpkiDer as ae, importSpkiDerOrThrow as oe, importSpkiPem as se, importSpkiPemOrThrow as ce } from "./keys/keys.js";
|
|
4
|
+
import { decodeExtension as le, decodeExtensionMap as ue, decodeExtensions as de, defineExtensionDecoder as fe, defineExtensionDecoderMap as pe, findExtension as me, getSubjectPublicKey as he, getSubjectPublicKeyOrThrow as ge, parseCertificateChainPem as _e, parseCertificateDer as ve, parseCertificateDerOrThrow as ye, parseCertificatePem as be, parseCertificatePemOrThrow as xe, parseCertificateSigningRequestDer as Se, parseCertificateSigningRequestDerOrThrow as Ce, parseCertificateSigningRequestPem as we, parseCertificateSigningRequestPemOrThrow as Te } from "./x509/parse.js";
|
|
5
|
+
import { createPfx as Ee, parsePfxDer as De, parsePfxPem as Oe } from "./pkcs/pfx.js";
|
|
6
|
+
import { createPkcs7CertBag as ke, createPkcs7SignedData as Ae, parsePkcs7CertBagDer as je, parsePkcs7CertBagPem as Me, parsePkcs7SignedDataDer as Ne, parsePkcs7SignedDataPem as Pe, verifyPkcs7SignedData as Fe } from "./pkcs/pkcs7.js";
|
|
7
|
+
import { checkCertificateRevocationAgainstCrl as Ie, createCertificateRevocationList as Le, isCertificateRevoked as Re, parseCertificateRevocationListDer as ze, parseCertificateRevocationListDerOrThrow as Be, parseCertificateRevocationListPem as Ve, parseCertificateRevocationListPemOrThrow as He, validateCertificateRevocationList as Ue, verifyCertificateRevocationListSignature as We } from "./revocation/crl.js";
|
|
8
|
+
import { matchCertificateServiceIdentity as Ge, matchServiceIdentity as Ke } from "./verify/identity.js";
|
|
9
|
+
import { VERIFY_ERROR_CODES as qe, buildCandidatePath as Je, checkExtendedKeyUsage as Ye, trustAnchorFromCertificate as Xe, validateCandidatePath as Ze, validateForCa as Qe, validateForCodeSigning as $e, validateForTlsClient as et, validateForTlsServer as tt, verifyCertificateChain as nt, verifyCertificateSigningRequest as rt } from "./verify/verify.js";
|
|
10
|
+
import { createOcspRequest as it, createOcspResponse as at, hasOcspNoCheckExtension as ot, parseOcspRequestDer as st, parseOcspRequestDerOrThrow as ct, parseOcspRequestPem as lt, parseOcspRequestPemOrThrow as ut, parseOcspResponseDer as dt, parseOcspResponseDerOrThrow as ft, parseOcspResponsePem as pt, parseOcspResponsePemOrThrow as mt, validateOcspResponse as ht, verifyOcspResponseSignature as gt } from "./revocation/ocsp.js";
|
|
11
|
+
import { REVOCATION_INDETERMINATE_REASONS as _t, checkChainRevocation as vt } from "./revocation/chain.js";
|
|
12
|
+
import { REVOCATION_INDETERMINATE_REASON_CODES as yt, checkCertificateRevocation as bt, getCertificateOcspResponderUris as xt, resolveOcspResponderCandidates as St } from "./revocation/revocation.js";
|
|
13
|
+
import { createCertificate as Ct, createSelfSignedCertificate as wt } from "./x509/certificate.js";
|
|
14
|
+
import { createCertificateSigningRequest as Tt } from "./x509/csr.js";
|
|
15
|
+
export { _t as REVOCATION_INDETERMINATE_REASONS, yt as REVOCATION_INDETERMINATE_REASON_CODES, qe as VERIFY_ERROR_CODES, Je as buildCandidatePath, r as categorizePemBlocks, i as categorizePemBlocksOrThrow, bt as checkCertificateRevocation, Ie as checkCertificateRevocationAgainstCrl, vt as checkChainRevocation, Ye as checkExtendedKeyUsage, Ct as createCertificate, Le as createCertificateRevocationList, Tt as createCertificateSigningRequest, it as createOcspRequest, at as createOcspResponse, Ee as createPfx, ke as createPkcs7CertBag, Ae as createPkcs7SignedData, wt as createSelfSignedCertificate, le as decodeExtension, ue as decodeExtensionMap, de as decodeExtensions, u as decryptRsaOaep, d as decryptRsaOaepOrThrow, fe as defineExtensionDecoder, pe as defineExtensionDecoderMap, f as derivePublicKey, p as encryptRsaOaep, m as encryptRsaOaepOrThrow, h as exportBinaryBase64, g as exportEncryptedPkcs1Pem, _ as exportEncryptedPkcs8Der, v as exportEncryptedPkcs8Pem, y as exportEncryptedSec1Pem, b as exportPkcs1Der, x as exportPkcs1Pem, S as exportPkcs8Der, C as exportPkcs8Pem, w as exportPrivateJwk, T as exportPublicJwk, E as exportSec1Der, D as exportSec1Pem, O as exportSpkiDer, k as exportSpkiPem, me as findExtension, A as generateKeyPair, xt as getCertificateOcspResponderUris, he as getSubjectPublicKey, ge as getSubjectPublicKeyOrThrow, ot as hasOcspNoCheckExtension, j as importEncryptedPkcs1Pem, M as importEncryptedPkcs1PemOrThrow, N as importEncryptedPkcs8Der, P as importEncryptedPkcs8DerOrThrow, F as importEncryptedPkcs8Pem, I as importEncryptedPkcs8PemOrThrow, L as importEncryptedSec1Pem, R as importEncryptedSec1PemOrThrow, z as importPkcs1Der, B as importPkcs1DerOrThrow, V as importPkcs1Pem, H as importPkcs1PemOrThrow, U as importPkcs8Base64, W as importPkcs8Base64OrThrow, G as importPkcs8Der, K as importPkcs8DerOrThrow, q as importPkcs8Pem, J as importPkcs8PemOrThrow, Y as importPrivateJwk, X as importPrivateJwkOrThrow, Z as importPublicJwk, Q as importPublicJwkOrThrow, $ as importSec1Der, ee as importSec1DerOrThrow, te as importSec1Pem, ne as importSec1PemOrThrow, re as importSpkiBase64, ie as importSpkiBase64OrThrow, ae as importSpkiDer, oe as importSpkiDerOrThrow, se as importSpkiPem, ce as importSpkiPemOrThrow, Re as isCertificateRevoked, e as isResultError, Ge as matchCertificateServiceIdentity, Ke as matchServiceIdentity, _e as parseCertificateChainPem, ve as parseCertificateDer, ye as parseCertificateDerOrThrow, be as parseCertificatePem, xe as parseCertificatePemOrThrow, ze as parseCertificateRevocationListDer, Be as parseCertificateRevocationListDerOrThrow, Ve as parseCertificateRevocationListPem, He as parseCertificateRevocationListPemOrThrow, Se as parseCertificateSigningRequestDer, Ce as parseCertificateSigningRequestDerOrThrow, we as parseCertificateSigningRequestPem, Te as parseCertificateSigningRequestPemOrThrow, st as parseOcspRequestDer, ct as parseOcspRequestDerOrThrow, lt as parseOcspRequestPem, ut as parseOcspRequestPemOrThrow, dt as parseOcspResponseDer, ft as parseOcspResponseDerOrThrow, pt as parseOcspResponsePem, mt as parseOcspResponsePemOrThrow, De as parsePfxDer, Oe as parsePfxPem, je as parsePkcs7CertBagDer, Me as parsePkcs7CertBagPem, Ne as parsePkcs7SignedDataDer, Pe as parsePkcs7SignedDataPem, a as pemDecode, o as pemDecodeOrThrow, s as pemEncode, St as resolveOcspResponderCandidates, c as splitPemBlocks, l as splitPemBlocksOrThrow, Xe as trustAnchorFromCertificate, t as unwrap, n as unwrapOr, Ze as validateCandidatePath, Ue as validateCertificateRevocationList, Qe as validateForCa, $e as validateForCodeSigning, et as validateForTlsClient, tt as validateForTlsServer, ht as validateOcspResponse, nt as verifyCertificateChain, We as verifyCertificateRevocationListSignature, rt as verifyCertificateSigningRequest, gt as verifyOcspResponseSignature, Fe as verifyPkcs7SignedData };
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import { readElement } from "./der.js";
|
|
1
|
+
import { readElement as e } from "./der.js";
|
|
2
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
3
|
/** Shared UTF-8 text decoder for ASN.1 string types. */
|
|
12
|
-
const
|
|
13
|
-
const PRINTABLE_STRING_PATTERN = /^[A-Za-z0-9 '()+,\-./:=?]*$/u;
|
|
4
|
+
const t = new TextDecoder("utf-8", { fatal: !0 }), n = /^[A-Za-z0-9 '()+,\-./:=?]*$/u;
|
|
14
5
|
/**
|
|
15
6
|
* Decodes a DER-encoded OBJECT IDENTIFIER value into its dotted-decimal string
|
|
16
7
|
* form (e.g. `"1.2.840.113549.1.1.1"`).
|
|
@@ -18,30 +9,26 @@ const PRINTABLE_STRING_PATTERN = /^[A-Za-z0-9 '()+,\-./:=?]*$/u;
|
|
|
18
9
|
* Throws on empty input, truncated multi-byte sub-identifiers, or incomplete
|
|
19
10
|
* continuation octets.
|
|
20
11
|
*/
|
|
21
|
-
function decodeObjectIdentifier(
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const subidentifier = decodeOidSubidentifier(bytes, offset);
|
|
28
|
-
values.push(subidentifier.value);
|
|
29
|
-
offset = subidentifier.nextOffset;
|
|
12
|
+
function decodeObjectIdentifier(e) {
|
|
13
|
+
if (e.length === 0) throw Error("OID is empty");
|
|
14
|
+
let t = decodeOidSubidentifier(e, 0), n = t.nextOffset, r = t.value < 40 ? [0, t.value] : t.value < 80 ? [1, t.value - 40] : [2, t.value - 80];
|
|
15
|
+
for (; n < e.length;) {
|
|
16
|
+
let t = decodeOidSubidentifier(e, n);
|
|
17
|
+
r.push(t.value), n = t.nextOffset;
|
|
30
18
|
}
|
|
31
|
-
return
|
|
19
|
+
return r.join(".");
|
|
32
20
|
}
|
|
33
21
|
/** Converts raw bytes to a lowercase hex string with no separator. */
|
|
34
|
-
function toHex(
|
|
35
|
-
return Array.from(
|
|
22
|
+
function toHex(e) {
|
|
23
|
+
return Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
36
24
|
}
|
|
37
25
|
/**
|
|
38
26
|
* Copies a `Uint8Array` into a standalone `ArrayBuffer` suitable for
|
|
39
27
|
* Web Crypto operations that require a non-shared backing buffer.
|
|
40
28
|
*/
|
|
41
|
-
function toArrayBuffer(
|
|
42
|
-
|
|
43
|
-
new Uint8Array(
|
|
44
|
-
return out;
|
|
29
|
+
function toArrayBuffer(e) {
|
|
30
|
+
let t = new ArrayBuffer(e.length);
|
|
31
|
+
return new Uint8Array(t).set(e), t;
|
|
45
32
|
}
|
|
46
33
|
/**
|
|
47
34
|
* Iterates through all direct child TLV elements inside a constructed
|
|
@@ -50,17 +37,15 @@ function toArrayBuffer(bytes) {
|
|
|
50
37
|
* Throws if any child overflows the parent boundary or if there is
|
|
51
38
|
* leftover data between the last child and the parent end offset.
|
|
52
39
|
*/
|
|
53
|
-
function childrenOf(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
children.push(child);
|
|
60
|
-
offset = child.end;
|
|
40
|
+
function childrenOf(t, n) {
|
|
41
|
+
let r = [], i = n.start;
|
|
42
|
+
for (; i < n.end;) {
|
|
43
|
+
let a = e(t, i);
|
|
44
|
+
if (a.end > n.end) throw Error("DER child exceeds parent length");
|
|
45
|
+
r.push(a), i = a.end;
|
|
61
46
|
}
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
47
|
+
if (i !== n.end) throw Error("Malformed DER container");
|
|
48
|
+
return r;
|
|
64
49
|
}
|
|
65
50
|
/**
|
|
66
51
|
* Asserts that a value is not `undefined`, returning it narrowed.
|
|
@@ -68,9 +53,9 @@ function childrenOf(source, parent) {
|
|
|
68
53
|
*
|
|
69
54
|
* @param label Human-readable field name included in the error message on failure.
|
|
70
55
|
*/
|
|
71
|
-
function requireElement(
|
|
72
|
-
if (
|
|
73
|
-
return
|
|
56
|
+
function requireElement(e, t) {
|
|
57
|
+
if (e === void 0) throw Error(`Missing ${t}`);
|
|
58
|
+
return e;
|
|
74
59
|
}
|
|
75
60
|
/**
|
|
76
61
|
* Strips the leading "unused bits" octet from a BIT STRING element,
|
|
@@ -78,12 +63,12 @@ function requireElement(value, label) {
|
|
|
78
63
|
*
|
|
79
64
|
* Used to extract signature values and public keys from their BIT STRING wrapper.
|
|
80
65
|
*/
|
|
81
|
-
function extractBitStringValue(
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
if (
|
|
86
|
-
return
|
|
66
|
+
function extractBitStringValue(e) {
|
|
67
|
+
if (e.tag !== 3) throw Error("Expected BIT STRING");
|
|
68
|
+
let t = e.value[0];
|
|
69
|
+
if (t === void 0 || t > 7) throw Error("Invalid BIT STRING");
|
|
70
|
+
if (t !== 0) throw Error("BIT STRING must have zero unused bits");
|
|
71
|
+
return e.value.slice(1);
|
|
87
72
|
}
|
|
88
73
|
/**
|
|
89
74
|
* Parses a {@linkcode DerElement} with tag UTCTime (`0x17`) or GeneralizedTime (`0x18`)
|
|
@@ -92,48 +77,35 @@ function extractBitStringValue(element) {
|
|
|
92
77
|
* For UTCTime, the two-digit year is interpreted per RFC 5280: values >= 50 map
|
|
93
78
|
* to 19xx, values < 50 map to 20xx. Throws on unrecognized time tags.
|
|
94
79
|
*/
|
|
95
|
-
function parseTime(
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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");
|
|
80
|
+
function parseTime(e) {
|
|
81
|
+
if (e.tag === 23) {
|
|
82
|
+
let t = decodeUtf8Text(e.value, "UTCTime"), n = /^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/.exec(t);
|
|
83
|
+
if (n === null) throw Error("Invalid UTCTime");
|
|
84
|
+
let r = requireElement(n[1], "UTCTime year"), i = requireElement(n[2], "UTCTime month"), a = requireElement(n[3], "UTCTime day"), o = requireElement(n[4], "UTCTime hour"), s = requireElement(n[5], "UTCTime minute"), c = requireElement(n[6], "UTCTime second"), l = Number.parseInt(r, 10);
|
|
85
|
+
return buildStrictUtcDate(l >= 50 ? 1900 + l : 2e3 + l, i, a, o, s, c, "UTCTime");
|
|
108
86
|
}
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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");
|
|
87
|
+
if (e.tag === 24) {
|
|
88
|
+
let t = decodeUtf8Text(e.value, "GeneralizedTime"), n = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/.exec(t);
|
|
89
|
+
if (n === null) throw Error("Invalid GeneralizedTime");
|
|
90
|
+
let r = requireElement(n[1], "GeneralizedTime year"), i = requireElement(n[2], "GeneralizedTime month"), a = requireElement(n[3], "GeneralizedTime day"), o = requireElement(n[4], "GeneralizedTime hour"), s = requireElement(n[5], "GeneralizedTime minute"), c = requireElement(n[6], "GeneralizedTime second");
|
|
91
|
+
return buildStrictUtcDate(Number.parseInt(r, 10), i, a, o, s, c, "GeneralizedTime");
|
|
120
92
|
}
|
|
121
|
-
throw
|
|
93
|
+
throw Error(`Unsupported time tag: ${e.tag}`);
|
|
122
94
|
}
|
|
123
95
|
/**
|
|
124
96
|
* Decodes a big-endian unsigned byte sequence into a JavaScript `number`.
|
|
125
97
|
* Throws if the value exceeds 6 bytes (48 bits), which is the safe-integer
|
|
126
98
|
* boundary for lossless arithmetic.
|
|
127
99
|
*/
|
|
128
|
-
function decodeIntegerNumber(
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
if (
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
134
|
-
let
|
|
135
|
-
for (
|
|
136
|
-
return
|
|
100
|
+
function decodeIntegerNumber(e) {
|
|
101
|
+
let t = e[0];
|
|
102
|
+
if (t === void 0) throw Error("INTEGER is empty");
|
|
103
|
+
if (t & 128) throw Error("INTEGER must be non-negative");
|
|
104
|
+
if (e.length > 1 && t === 0 && !((e[1] ?? 0) & 128)) throw Error("INTEGER must use minimal encoding");
|
|
105
|
+
if (e.length > 6) throw Error(`Integer too large for safe number (${e.length} bytes)`);
|
|
106
|
+
let n = 0;
|
|
107
|
+
for (let t of e) n = n * 256 + t;
|
|
108
|
+
return n;
|
|
137
109
|
}
|
|
138
110
|
/**
|
|
139
111
|
* Like {@linkcode decodeIntegerNumber}, but optionally rewrites thrown error
|
|
@@ -141,19 +113,17 @@ function decodeIntegerNumber(bytes) {
|
|
|
141
113
|
*
|
|
142
114
|
* @param label Field name for error messages (defaults to `"INTEGER"`).
|
|
143
115
|
*/
|
|
144
|
-
function decodeNonNegativeIntegerNumber(
|
|
145
|
-
if (
|
|
116
|
+
function decodeNonNegativeIntegerNumber(e, t = "INTEGER") {
|
|
117
|
+
if (t === "INTEGER") return decodeIntegerNumber(e);
|
|
146
118
|
try {
|
|
147
|
-
return decodeIntegerNumber(
|
|
148
|
-
} catch (
|
|
149
|
-
if (!(
|
|
150
|
-
switch (
|
|
151
|
-
case "INTEGER is empty": throw
|
|
152
|
-
case "INTEGER must be non-negative": throw
|
|
153
|
-
case "INTEGER must use minimal encoding": throw
|
|
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;
|
|
119
|
+
return decodeIntegerNumber(e);
|
|
120
|
+
} catch (n) {
|
|
121
|
+
if (!(n instanceof Error)) throw n;
|
|
122
|
+
switch (n.message) {
|
|
123
|
+
case "INTEGER is empty": throw Error(`${t} is empty`);
|
|
124
|
+
case "INTEGER must be non-negative": throw Error(`${t} must be non-negative`);
|
|
125
|
+
case "INTEGER must use minimal encoding": throw Error(`${t} must use minimal encoding`);
|
|
126
|
+
default: throw n.message.startsWith("Integer too large for safe number") ? Error(`${t} too large for safe number (${e.length} bytes)`) : n;
|
|
157
127
|
}
|
|
158
128
|
}
|
|
159
129
|
}
|
|
@@ -161,51 +131,43 @@ function decodeNonNegativeIntegerNumber(bytes, label = "INTEGER") {
|
|
|
161
131
|
* Converts a hex string (even or odd length) to a `Uint8Array`.
|
|
162
132
|
* Odd-length strings are left-padded with a zero nibble.
|
|
163
133
|
*/
|
|
164
|
-
function hexToBytes(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
out[index] = Number.parseInt(chunk, 16);
|
|
134
|
+
function hexToBytes(e) {
|
|
135
|
+
let t = e.length % 2 == 0 ? e : `0${e}`, n = new Uint8Array(t.length / 2);
|
|
136
|
+
for (let e = 0; e < n.length; e += 1) {
|
|
137
|
+
let r = t.slice(e * 2, e * 2 + 2);
|
|
138
|
+
if (!/^[0-9a-fA-F]{2}$/.test(r)) throw Error(`Invalid hex byte: ${r}`);
|
|
139
|
+
n[e] = Number.parseInt(r, 16);
|
|
171
140
|
}
|
|
172
|
-
return
|
|
141
|
+
return n;
|
|
173
142
|
}
|
|
174
143
|
/** Decodes a DER BOOLEAN value: any non-zero first byte is `true`. */
|
|
175
|
-
function decodeBoolean(
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
return
|
|
180
|
-
}
|
|
181
|
-
function buildStrictUtcDate(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
|
144
|
+
function decodeBoolean(e) {
|
|
145
|
+
if (e.length !== 1) throw Error("BOOLEAN must contain exactly one octet");
|
|
146
|
+
let t = e[0];
|
|
147
|
+
if (t !== 0 && t !== 255) throw Error("BOOLEAN must use DER encoding");
|
|
148
|
+
return t === 255;
|
|
149
|
+
}
|
|
150
|
+
function buildStrictUtcDate(e, t, n, r, i, a, o) {
|
|
151
|
+
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));
|
|
152
|
+
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}`);
|
|
153
|
+
return f;
|
|
154
|
+
}
|
|
155
|
+
function decodeOidSubidentifier(e, t) {
|
|
156
|
+
let n = e[t];
|
|
157
|
+
if (n === void 0) throw Error("Malformed OID");
|
|
158
|
+
if (n === 128) throw Error("Malformed OID: non-minimal base-128 encoding");
|
|
159
|
+
let r = 0, i = t;
|
|
160
|
+
for (; i < e.length; i += 1) {
|
|
161
|
+
let t = e[i];
|
|
162
|
+
if (t === void 0) throw Error("Malformed OID");
|
|
163
|
+
let n = t & 127;
|
|
164
|
+
if (r > Math.floor((2 ** 53 - 1 - n) / 128)) throw Error("Malformed OID: overflow/non-minimal or too-large subidentifier");
|
|
165
|
+
if (r = r * 128 + n, !(t & 128)) return {
|
|
166
|
+
value: r,
|
|
167
|
+
nextOffset: i + 1
|
|
206
168
|
};
|
|
207
169
|
}
|
|
208
|
-
throw
|
|
170
|
+
throw Error("Malformed OID: incomplete continuation");
|
|
209
171
|
}
|
|
210
172
|
/**
|
|
211
173
|
* Decodes a DER string element by tag. Supports UTF8String (`0x0c`),
|
|
@@ -213,68 +175,65 @@ function decodeOidSubidentifier(bytes, start) {
|
|
|
213
175
|
* and BMPString (`0x1e`).
|
|
214
176
|
* Throws on unsupported string tags.
|
|
215
177
|
*/
|
|
216
|
-
function decodeString(
|
|
217
|
-
switch (
|
|
218
|
-
case 12: return decodeUtf8Text(
|
|
219
|
-
case 19: return decodePrintableString(
|
|
220
|
-
case 22: return decodeIa5String(
|
|
221
|
-
case 20: throw
|
|
222
|
-
case 28: return decodeUniversalString(
|
|
223
|
-
case 30: return decodeBmpString(
|
|
224
|
-
default: throw
|
|
178
|
+
function decodeString(e, t) {
|
|
179
|
+
switch (e) {
|
|
180
|
+
case 12: return decodeUtf8Text(t, "UTF8String");
|
|
181
|
+
case 19: return decodePrintableString(t);
|
|
182
|
+
case 22: return decodeIa5String(t);
|
|
183
|
+
case 20: throw Error("Unsupported string tag: 20 (TeletexString)");
|
|
184
|
+
case 28: return decodeUniversalString(t);
|
|
185
|
+
case 30: return decodeBmpString(t);
|
|
186
|
+
default: throw Error(`Unsupported string tag: ${e}`);
|
|
225
187
|
}
|
|
226
188
|
}
|
|
227
|
-
function decodeUtf8Text(
|
|
189
|
+
function decodeUtf8Text(e, n) {
|
|
228
190
|
try {
|
|
229
|
-
return
|
|
230
|
-
} catch (
|
|
231
|
-
|
|
232
|
-
throw error;
|
|
191
|
+
return t.decode(e);
|
|
192
|
+
} catch (e) {
|
|
193
|
+
throw e instanceof Error ? Error(`Invalid ${n}: invalid UTF-8`, { cause: e }) : e;
|
|
233
194
|
}
|
|
234
195
|
}
|
|
235
|
-
function decodeAsciiString(
|
|
236
|
-
let
|
|
237
|
-
for (
|
|
238
|
-
if (
|
|
239
|
-
|
|
196
|
+
function decodeAsciiString(e, t) {
|
|
197
|
+
let n = "";
|
|
198
|
+
for (let r of e) {
|
|
199
|
+
if (r > 127) throw Error(`Invalid ${t}: contains non-ASCII bytes`);
|
|
200
|
+
n += String.fromCharCode(r);
|
|
240
201
|
}
|
|
241
|
-
return
|
|
242
|
-
}
|
|
243
|
-
function decodeIa5String(
|
|
244
|
-
return decodeAsciiString(
|
|
245
|
-
}
|
|
246
|
-
function decodePrintableString(
|
|
247
|
-
|
|
248
|
-
if (!
|
|
249
|
-
return
|
|
250
|
-
}
|
|
251
|
-
function decodeBmpString(
|
|
252
|
-
if (
|
|
253
|
-
let
|
|
254
|
-
for (let
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
value += String.fromCharCode(codeUnit);
|
|
202
|
+
return n;
|
|
203
|
+
}
|
|
204
|
+
function decodeIa5String(e) {
|
|
205
|
+
return decodeAsciiString(e, "IA5String");
|
|
206
|
+
}
|
|
207
|
+
function decodePrintableString(e) {
|
|
208
|
+
let t = decodeAsciiString(e, "PrintableString");
|
|
209
|
+
if (!n.test(t)) throw Error("Invalid PrintableString: contains characters outside the allowed set");
|
|
210
|
+
return t;
|
|
211
|
+
}
|
|
212
|
+
function decodeBmpString(e) {
|
|
213
|
+
if (e.length % 2 != 0) throw Error("Invalid BMPString length");
|
|
214
|
+
let t = "";
|
|
215
|
+
for (let n = 0; n < e.length; n += 2) {
|
|
216
|
+
let r = e[n], i = e[n + 1];
|
|
217
|
+
if (r === void 0 || i === void 0) throw Error("Invalid BMPString content");
|
|
218
|
+
let a = r << 8 | i;
|
|
219
|
+
if (a >= 55296 && a <= 57343) throw Error("Invalid BMPString code point");
|
|
220
|
+
t += String.fromCharCode(a);
|
|
261
221
|
}
|
|
262
|
-
return
|
|
263
|
-
}
|
|
264
|
-
function decodeUniversalString(
|
|
265
|
-
if (
|
|
266
|
-
let
|
|
267
|
-
for (let
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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);
|
|
222
|
+
return t;
|
|
223
|
+
}
|
|
224
|
+
function decodeUniversalString(e) {
|
|
225
|
+
if (e.length % 4 != 0) throw Error("Invalid UniversalString length");
|
|
226
|
+
let t = "";
|
|
227
|
+
for (let n = 0; n < e.length; n += 4) {
|
|
228
|
+
let r = e[n], i = e[n + 1], a = e[n + 2], o = e[n + 3];
|
|
229
|
+
if (r === void 0 || i === void 0 || a === void 0 || o === void 0) throw Error("Invalid UniversalString content");
|
|
230
|
+
let s = ((r * 256 + i) * 256 + a) * 256 + o;
|
|
231
|
+
if (s > 1114111 || s >= 55296 && s <= 57343) throw Error("Invalid UniversalString code point");
|
|
232
|
+
t += String.fromCodePoint(s);
|
|
276
233
|
}
|
|
277
|
-
return
|
|
234
|
+
return t;
|
|
278
235
|
}
|
|
279
236
|
//#endregion
|
|
280
237
|
export { childrenOf, decodeBoolean, decodeIntegerNumber, decodeNonNegativeIntegerNumber, decodeObjectIdentifier, decodeString, extractBitStringValue, hexToBytes, parseTime, requireElement, toArrayBuffer, toHex };
|
|
238
|
+
|
|
239
|
+
//# sourceMappingURL=asn1.js.map
|