micro509 0.10.0 → 0.11.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 +3 -2
- package/dist/index.js +13 -12
- package/dist/x509/fingerprint.d.ts +55 -0
- package/dist/x509/fingerprint.js +55 -0
- package/dist/x509/fingerprint.js.map +1 -0
- package/dist/x509/parse.d.ts +104 -1
- package/dist/x509/parse.js +153 -30
- package/dist/x509/parse.js.map +1 -1
- package/dist/x509.d.ts +3 -2
- package/dist/x509.js +5 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CategorizePemBlocksResult, CategorizedPemBlocks, PemBlock, PemDecodeRes
|
|
|
4
4
|
import { ParsePkcs12MacDataErrorCode, ParsePkcs12MacDataFailure, ParsePkcs12MacDataResult, ParsedPkcs12MacData, Pkcs12MacOptions } from "./pkcs/pkcs12-mac.js";
|
|
5
5
|
import { NameAttribute, NameFieldKey, NameInput, NameObject, RelativeDistinguishedNameInput } from "./x509/name.js";
|
|
6
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";
|
|
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 { DecodedExtensionMap, DecodedExtensionValue, ExtensionDecoder, ExtensionDecoderMap, MatchCertificatePrivateKeyErrorCode, MatchCertificatePrivateKeyFailure, MatchCertificatePrivateKeyFailureResult, MatchCertificatePrivateKeyResult, MatchCertificatePrivateKeySuccess, ParseCertificateErrorCode, ParseCertificateFailure, ParseCertificateResult, ParseCertificateSigningRequestErrorCode, ParseCertificateSigningRequestFailure, ParseCertificateSigningRequestResult, ParseOptions, ParsedCertificate, ParsedCertificateSigningRequest, ParsedDistributionPoint, ParsedDistributionPointName, ParsedExtension, ParsedIssuingDistributionPoint, ParsedName, ParsedNameAttribute, ParsedRelativeDistinguishedName, certificateMatchesPrivateKey, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, findExtension, getSubjectPublicKey, getSubjectPublicKeyOrThrow, matchCertificatePrivateKey, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow } from "./x509/parse.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
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";
|
|
@@ -17,4 +17,5 @@ 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 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 };
|
|
20
|
+
import { CertificateFingerprint, CertificateFingerprintAlgorithm, CertificateFingerprintSource, certificateFingerprint } from "./x509/fingerprint.js";
|
|
21
|
+
export { type AuthorityInformationAccess, type BasicConstraints, type BuildCandidatePathInput, type BuildCandidatePathResult, type CandidatePath, type CategorizePemBlocksResult, type CategorizedPemBlocks, type CertificateExtensionsInput, type CertificateFingerprint, type CertificateFingerprintAlgorithm, type CertificateFingerprintSource, 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 MatchCertificatePrivateKeyErrorCode, type MatchCertificatePrivateKeyFailure, type MatchCertificatePrivateKeyFailureResult, type MatchCertificatePrivateKeyResult, type MatchCertificatePrivateKeySuccess, 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, certificateFingerprint, certificateMatchesPrivateKey, 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, matchCertificatePrivateKey, 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,16 @@
|
|
|
1
1
|
import { isResultError as e, unwrap as t, unwrapOr as n } from "./result/result.js";
|
|
2
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
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 {
|
|
5
|
-
import { createPfx as
|
|
6
|
-
import { createPkcs7CertBag as
|
|
7
|
-
import { checkCertificateRevocationAgainstCrl as
|
|
8
|
-
import { matchCertificateServiceIdentity as
|
|
9
|
-
import { VERIFY_ERROR_CODES as
|
|
10
|
-
import { createOcspRequest as
|
|
11
|
-
import { REVOCATION_INDETERMINATE_REASONS as
|
|
12
|
-
import { REVOCATION_INDETERMINATE_REASON_CODES as
|
|
13
|
-
import { createCertificate as
|
|
14
|
-
import { createCertificateSigningRequest as
|
|
15
|
-
|
|
4
|
+
import { certificateMatchesPrivateKey as le, decodeExtension as ue, decodeExtensionMap as de, decodeExtensions as fe, defineExtensionDecoder as pe, defineExtensionDecoderMap as me, findExtension as he, getSubjectPublicKey as ge, getSubjectPublicKeyOrThrow as _e, matchCertificatePrivateKey as ve, parseCertificateChainPem as ye, parseCertificateDer as be, parseCertificateDerOrThrow as xe, parseCertificatePem as Se, parseCertificatePemOrThrow as Ce, parseCertificateSigningRequestDer as we, parseCertificateSigningRequestDerOrThrow as Te, parseCertificateSigningRequestPem as Ee, parseCertificateSigningRequestPemOrThrow as De } from "./x509/parse.js";
|
|
5
|
+
import { createPfx as Oe, parsePfxDer as ke, parsePfxPem as Ae } from "./pkcs/pfx.js";
|
|
6
|
+
import { createPkcs7CertBag as je, createPkcs7SignedData as Me, parsePkcs7CertBagDer as Ne, parsePkcs7CertBagPem as Pe, parsePkcs7SignedDataDer as Fe, parsePkcs7SignedDataPem as Ie, verifyPkcs7SignedData as Le } from "./pkcs/pkcs7.js";
|
|
7
|
+
import { checkCertificateRevocationAgainstCrl as Re, createCertificateRevocationList as ze, isCertificateRevoked as Be, parseCertificateRevocationListDer as Ve, parseCertificateRevocationListDerOrThrow as He, parseCertificateRevocationListPem as Ue, parseCertificateRevocationListPemOrThrow as We, validateCertificateRevocationList as Ge, verifyCertificateRevocationListSignature as Ke } from "./revocation/crl.js";
|
|
8
|
+
import { matchCertificateServiceIdentity as qe, matchServiceIdentity as Je } from "./verify/identity.js";
|
|
9
|
+
import { VERIFY_ERROR_CODES as Ye, buildCandidatePath as Xe, checkExtendedKeyUsage as Ze, trustAnchorFromCertificate as Qe, validateCandidatePath as $e, validateForCa as et, validateForCodeSigning as tt, validateForTlsClient as nt, validateForTlsServer as rt, verifyCertificateChain as it, verifyCertificateSigningRequest as at } from "./verify/verify.js";
|
|
10
|
+
import { createOcspRequest as ot, createOcspResponse as st, hasOcspNoCheckExtension as ct, parseOcspRequestDer as lt, parseOcspRequestDerOrThrow as ut, parseOcspRequestPem as dt, parseOcspRequestPemOrThrow as ft, parseOcspResponseDer as pt, parseOcspResponseDerOrThrow as mt, parseOcspResponsePem as ht, parseOcspResponsePemOrThrow as gt, validateOcspResponse as _t, verifyOcspResponseSignature as vt } from "./revocation/ocsp.js";
|
|
11
|
+
import { REVOCATION_INDETERMINATE_REASONS as yt, checkChainRevocation as bt } from "./revocation/chain.js";
|
|
12
|
+
import { REVOCATION_INDETERMINATE_REASON_CODES as xt, checkCertificateRevocation as St, getCertificateOcspResponderUris as Ct, resolveOcspResponderCandidates as wt } from "./revocation/revocation.js";
|
|
13
|
+
import { createCertificate as Tt, createSelfSignedCertificate as Et } from "./x509/certificate.js";
|
|
14
|
+
import { createCertificateSigningRequest as Dt } from "./x509/csr.js";
|
|
15
|
+
import { certificateFingerprint as Ot } from "./x509/fingerprint.js";
|
|
16
|
+
export { yt as REVOCATION_INDETERMINATE_REASONS, xt as REVOCATION_INDETERMINATE_REASON_CODES, Ye as VERIFY_ERROR_CODES, Xe as buildCandidatePath, r as categorizePemBlocks, i as categorizePemBlocksOrThrow, Ot as certificateFingerprint, le as certificateMatchesPrivateKey, St as checkCertificateRevocation, Re as checkCertificateRevocationAgainstCrl, bt as checkChainRevocation, Ze as checkExtendedKeyUsage, Tt as createCertificate, ze as createCertificateRevocationList, Dt as createCertificateSigningRequest, ot as createOcspRequest, st as createOcspResponse, Oe as createPfx, je as createPkcs7CertBag, Me as createPkcs7SignedData, Et as createSelfSignedCertificate, ue as decodeExtension, de as decodeExtensionMap, fe as decodeExtensions, u as decryptRsaOaep, d as decryptRsaOaepOrThrow, pe as defineExtensionDecoder, me 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, he as findExtension, A as generateKeyPair, Ct as getCertificateOcspResponderUris, ge as getSubjectPublicKey, _e as getSubjectPublicKeyOrThrow, ct 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, Be as isCertificateRevoked, e as isResultError, ve as matchCertificatePrivateKey, qe as matchCertificateServiceIdentity, Je as matchServiceIdentity, ye as parseCertificateChainPem, be as parseCertificateDer, xe as parseCertificateDerOrThrow, Se as parseCertificatePem, Ce as parseCertificatePemOrThrow, Ve as parseCertificateRevocationListDer, He as parseCertificateRevocationListDerOrThrow, Ue as parseCertificateRevocationListPem, We as parseCertificateRevocationListPemOrThrow, we as parseCertificateSigningRequestDer, Te as parseCertificateSigningRequestDerOrThrow, Ee as parseCertificateSigningRequestPem, De as parseCertificateSigningRequestPemOrThrow, lt as parseOcspRequestDer, ut as parseOcspRequestDerOrThrow, dt as parseOcspRequestPem, ft as parseOcspRequestPemOrThrow, pt as parseOcspResponseDer, mt as parseOcspResponseDerOrThrow, ht as parseOcspResponsePem, gt as parseOcspResponsePemOrThrow, ke as parsePfxDer, Ae as parsePfxPem, Ne as parsePkcs7CertBagDer, Pe as parsePkcs7CertBagPem, Fe as parsePkcs7SignedDataDer, Ie as parsePkcs7SignedDataPem, a as pemDecode, o as pemDecodeOrThrow, s as pemEncode, wt as resolveOcspResponderCandidates, c as splitPemBlocks, l as splitPemBlocksOrThrow, Qe as trustAnchorFromCertificate, t as unwrap, n as unwrapOr, $e as validateCandidatePath, Ge as validateCertificateRevocationList, et as validateForCa, tt as validateForCodeSigning, nt as validateForTlsClient, rt as validateForTlsServer, _t as validateOcspResponse, it as verifyCertificateChain, Ke as verifyCertificateRevocationListSignature, at as verifyCertificateSigningRequest, vt as verifyOcspResponseSignature, Le as verifyPkcs7SignedData };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ParsedCertificate } from "./parse.js";
|
|
2
|
+
//#region src/x509/fingerprint.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A PEM string, raw DER bytes, or an already-parsed certificate.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the source union accepted by the verification, revocation, and
|
|
7
|
+
* PKCS APIs so a fingerprint can be taken from whatever a caller already holds.
|
|
8
|
+
*/
|
|
9
|
+
type CertificateFingerprintSource = string | Uint8Array | ParsedCertificate;
|
|
10
|
+
/**
|
|
11
|
+
* Digest algorithms supported by {@linkcode certificateFingerprint}.
|
|
12
|
+
*
|
|
13
|
+
* SHA-1 is intentionally included: legacy ecosystems (PGP-adjacent tooling,
|
|
14
|
+
* older certificate pinning) still identify certificates by their SHA-1
|
|
15
|
+
* fingerprint. Prefer SHA-256 for anything new.
|
|
16
|
+
*/
|
|
17
|
+
type CertificateFingerprintAlgorithm = "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
|
|
18
|
+
/** The three rendered forms of a certificate fingerprint. */
|
|
19
|
+
interface CertificateFingerprint {
|
|
20
|
+
/** Raw digest bytes. */
|
|
21
|
+
readonly bytes: Uint8Array;
|
|
22
|
+
/** Lowercase hex, no separators (e.g. `"a1b2c3…"`). */
|
|
23
|
+
readonly hex: string;
|
|
24
|
+
/** Uppercase hex, colon-separated (e.g. `"A1:B2:C3:…"`, `openssl x509 -fingerprint` style). */
|
|
25
|
+
readonly colonHex: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Compute a certificate fingerprint — a hash over the DER encoding.
|
|
29
|
+
*
|
|
30
|
+
* The certificate is parsed (validating the input and, for PEM, decoding it to
|
|
31
|
+
* DER) before hashing, so the digest is always taken over the canonical DER of
|
|
32
|
+
* a well-formed certificate. Malformed input throws, matching the other DER/PEM
|
|
33
|
+
* boundaries in the library.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const fingerprint = await certificateFingerprint(pemString);
|
|
38
|
+
* console.log(fingerprint.colonHex); // "AB:CD:…" — matches `openssl x509 -fingerprint -sha256`
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* // Reuse an already-parsed certificate and request SHA-1.
|
|
44
|
+
* const parsed = parseCertificatePemOrThrow(pemString);
|
|
45
|
+
* const legacy = await certificateFingerprint(parsed, 'SHA-1');
|
|
46
|
+
* console.log(legacy.hex);
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param certificate PEM string, DER bytes, or a {@linkcode ParsedCertificate}.
|
|
50
|
+
* @param algorithm Digest algorithm to use. Defaults to `'SHA-256'`.
|
|
51
|
+
*/
|
|
52
|
+
declare function certificateFingerprint(certificate: CertificateFingerprintSource, algorithm?: CertificateFingerprintAlgorithm): Promise<CertificateFingerprint>;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { CertificateFingerprint, CertificateFingerprintAlgorithm, CertificateFingerprintSource, certificateFingerprint };
|
|
55
|
+
//# sourceMappingURL=fingerprint.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { toArrayBuffer as e, toHex as t } from "../internal/asn1/asn1.js";
|
|
2
|
+
import { getCrypto as n } from "../internal/crypto/webcrypto.js";
|
|
3
|
+
import { parseCertificateFromSource as r } from "./parse.js";
|
|
4
|
+
//#region src/x509/fingerprint.ts
|
|
5
|
+
/**
|
|
6
|
+
* Certificate fingerprints: a cryptographic hash over the DER encoding.
|
|
7
|
+
*
|
|
8
|
+
* This is the identifier that `openssl x509 -fingerprint` and every TLS UI show.
|
|
9
|
+
* The helper accepts the same PEM / DER / parsed-certificate source union as
|
|
10
|
+
* the verification APIs and returns the digest in the forms callers actually
|
|
11
|
+
* paste around: raw bytes, lowercase hex, and uppercase colon-separated hex.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Compute a certificate fingerprint — a hash over the DER encoding.
|
|
17
|
+
*
|
|
18
|
+
* The certificate is parsed (validating the input and, for PEM, decoding it to
|
|
19
|
+
* DER) before hashing, so the digest is always taken over the canonical DER of
|
|
20
|
+
* a well-formed certificate. Malformed input throws, matching the other DER/PEM
|
|
21
|
+
* boundaries in the library.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const fingerprint = await certificateFingerprint(pemString);
|
|
26
|
+
* console.log(fingerprint.colonHex); // "AB:CD:…" — matches `openssl x509 -fingerprint -sha256`
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // Reuse an already-parsed certificate and request SHA-1.
|
|
32
|
+
* const parsed = parseCertificatePemOrThrow(pemString);
|
|
33
|
+
* const legacy = await certificateFingerprint(parsed, 'SHA-1');
|
|
34
|
+
* console.log(legacy.hex);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param certificate PEM string, DER bytes, or a {@linkcode ParsedCertificate}.
|
|
38
|
+
* @param algorithm Digest algorithm to use. Defaults to `'SHA-256'`.
|
|
39
|
+
*/
|
|
40
|
+
async function certificateFingerprint(i, a = "SHA-256") {
|
|
41
|
+
let { der: o } = r(i), s = await n().subtle.digest(a, e(o)), c = new Uint8Array(s);
|
|
42
|
+
return {
|
|
43
|
+
bytes: c,
|
|
44
|
+
hex: t(c),
|
|
45
|
+
colonHex: toColonHex(c)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Renders bytes as uppercase, colon-separated hex (openssl fingerprint style). */
|
|
49
|
+
function toColonHex(e) {
|
|
50
|
+
return Array.from(e, (e) => e.toString(16).padStart(2, "0").toUpperCase()).join(":");
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { certificateFingerprint };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=fingerprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.js","names":[],"sources":["../../src/x509/fingerprint.ts"],"sourcesContent":["/**\n * Certificate fingerprints: a cryptographic hash over the DER encoding.\n *\n * This is the identifier that `openssl x509 -fingerprint` and every TLS UI show.\n * The helper accepts the same PEM / DER / parsed-certificate source union as\n * the verification APIs and returns the digest in the forms callers actually\n * paste around: raw bytes, lowercase hex, and uppercase colon-separated hex.\n *\n * @module\n */\n\nimport { toArrayBuffer, toHex } from '#micro509/internal/asn1/asn1';\nimport { getCrypto } from '#micro509/internal/crypto/webcrypto';\nimport type { ParsedCertificate } from '#micro509/x509/parse';\nimport { parseCertificateFromSource } from '#micro509/x509/parse';\n\n/**\n * A PEM string, raw DER bytes, or an already-parsed certificate.\n *\n * Mirrors the source union accepted by the verification, revocation, and\n * PKCS APIs so a fingerprint can be taken from whatever a caller already holds.\n */\nexport type CertificateFingerprintSource = string | Uint8Array | ParsedCertificate;\n\n/**\n * Digest algorithms supported by {@linkcode certificateFingerprint}.\n *\n * SHA-1 is intentionally included: legacy ecosystems (PGP-adjacent tooling,\n * older certificate pinning) still identify certificates by their SHA-1\n * fingerprint. Prefer SHA-256 for anything new.\n */\nexport type CertificateFingerprintAlgorithm = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';\n\n/** The three rendered forms of a certificate fingerprint. */\nexport interface CertificateFingerprint {\n\t/** Raw digest bytes. */\n\treadonly bytes: Uint8Array;\n\t/** Lowercase hex, no separators (e.g. `\"a1b2c3…\"`). */\n\treadonly hex: string;\n\t/** Uppercase hex, colon-separated (e.g. `\"A1:B2:C3:…\"`, `openssl x509 -fingerprint` style). */\n\treadonly colonHex: string;\n}\n\n/**\n * Compute a certificate fingerprint — a hash over the DER encoding.\n *\n * The certificate is parsed (validating the input and, for PEM, decoding it to\n * DER) before hashing, so the digest is always taken over the canonical DER of\n * a well-formed certificate. Malformed input throws, matching the other DER/PEM\n * boundaries in the library.\n *\n * @example\n * ```ts\n * const fingerprint = await certificateFingerprint(pemString);\n * console.log(fingerprint.colonHex); // \"AB:CD:…\" — matches `openssl x509 -fingerprint -sha256`\n * ```\n *\n * @example\n * ```ts\n * // Reuse an already-parsed certificate and request SHA-1.\n * const parsed = parseCertificatePemOrThrow(pemString);\n * const legacy = await certificateFingerprint(parsed, 'SHA-1');\n * console.log(legacy.hex);\n * ```\n *\n * @param certificate PEM string, DER bytes, or a {@linkcode ParsedCertificate}.\n * @param algorithm Digest algorithm to use. Defaults to `'SHA-256'`.\n */\nexport async function certificateFingerprint(\n\tcertificate: CertificateFingerprintSource,\n\talgorithm: CertificateFingerprintAlgorithm = 'SHA-256',\n): Promise<CertificateFingerprint> {\n\tconst { der } = parseCertificateFromSource(certificate);\n\tconst digest = await getCrypto().subtle.digest(algorithm, toArrayBuffer(der));\n\tconst bytes = new Uint8Array(digest);\n\treturn {\n\t\tbytes,\n\t\thex: toHex(bytes),\n\t\tcolonHex: toColonHex(bytes),\n\t};\n}\n\n/** Renders bytes as uppercase, colon-separated hex (openssl fingerprint style). */\nfunction toColonHex(bytes: Uint8Array): string {\n\treturn Array.from(bytes, (value) => value.toString(16).padStart(2, '0').toUpperCase()).join(':');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,eAAsB,uBACrB,GACA,IAA6C,WACX;CAClC,IAAM,EAAE,WAAQ,EAA2B,CAAW,GAChD,IAAS,MAAM,EAAU,CAAC,CAAC,OAAO,OAAO,GAAW,EAAc,CAAG,CAAC,GACtE,IAAQ,IAAI,WAAW,CAAM;CACnC,OAAO;EACN;EACA,KAAK,EAAM,CAAK;EAChB,UAAU,WAAW,CAAK;CAC3B;AACD;;AAGA,SAAS,WAAW,GAA2B;CAC9C,OAAO,MAAM,KAAK,IAAQ,MAAU,EAAM,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,GAAG;AAChG"}
|
package/dist/x509/parse.d.ts
CHANGED
|
@@ -437,6 +437,109 @@ declare function getSubjectPublicKeyOrThrow<TMap extends ExtensionDecoderMap = R
|
|
|
437
437
|
* @see `getSubjectPublicKeyOrThrow` for the throwing variant
|
|
438
438
|
*/
|
|
439
439
|
declare function getSubjectPublicKey<TMap extends ExtensionDecoderMap = Record<never, never>>(parsed: ParsedCertificate<TMap> | ParsedCertificateSigningRequest<TMap>, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
|
|
440
|
+
/**
|
|
441
|
+
* Check whether a certificate's subject public key belongs to a private key.
|
|
442
|
+
*
|
|
443
|
+
* Confirming that an uploaded private key actually matches the certificate it
|
|
444
|
+
* was submitted with is the first thing a key-intake or issuance endpoint must
|
|
445
|
+
* do. This derives the public half of `privateKey`, exports it as
|
|
446
|
+
* SubjectPublicKeyInfo DER, and compares those bytes against the certificate's
|
|
447
|
+
* own SubjectPublicKeyInfo — the canonical, algorithm-agnostic way to test key
|
|
448
|
+
* ownership. (Comparing JWKs field by field, or signing a probe and verifying
|
|
449
|
+
* it, are both more fragile.)
|
|
450
|
+
*
|
|
451
|
+
* A private key of a different type — e.g. an ECDSA key against an RSA
|
|
452
|
+
* certificate — simply produces different SPKI DER and returns `false`, so
|
|
453
|
+
* callers get a single boolean without branching on the kind of mismatch. Reach
|
|
454
|
+
* for {@linkcode matchCertificatePrivateKey} when you need the reason a match
|
|
455
|
+
* failed (or a typed failure instead of a thrown error) at a trust boundary.
|
|
456
|
+
*
|
|
457
|
+
* The comparison is over the exact DER encoding. A certificate whose
|
|
458
|
+
* SubjectPublicKeyInfo pins RSASSA-PSS parameters (rather than the plain
|
|
459
|
+
* `rsaEncryption` OID that WebCrypto emits) therefore will not match even for
|
|
460
|
+
* the same modulus; such certificates are rare in practice.
|
|
461
|
+
*
|
|
462
|
+
* @param certificate PEM string, DER bytes, or an already-parsed certificate.
|
|
463
|
+
* @param privateKey An extractable private `CryptoKey`.
|
|
464
|
+
* @returns `true` when the private key's public half matches the certificate's
|
|
465
|
+
* subject public key.
|
|
466
|
+
*
|
|
467
|
+
* @throws {Error} If `certificate` is malformed, or `privateKey` is not an
|
|
468
|
+
* extractable private key of a supported type (propagated from
|
|
469
|
+
* {@linkcode derivePublicKey}). Use {@linkcode matchCertificatePrivateKey} for a
|
|
470
|
+
* typed `Result` instead of thrown errors.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```ts
|
|
474
|
+
* const privateKey = await importPkcs8PemOrThrow(keyPem, { kind: 'ecdsa', curve: 'P-256' });
|
|
475
|
+
* if (!(await certificateMatchesPrivateKey(certificatePem, privateKey))) {
|
|
476
|
+
* throw new Error('uploaded key does not match the certificate');
|
|
477
|
+
* }
|
|
478
|
+
* ```
|
|
479
|
+
*
|
|
480
|
+
* @see {@linkcode matchCertificatePrivateKey} for the typed-`Result` variant with a mismatch reason
|
|
481
|
+
* @see {@linkcode getSubjectPublicKeyOrThrow} to obtain the certificate's public key directly
|
|
482
|
+
* @see {@linkcode derivePublicKey} for the private-to-public bridge this builds on
|
|
483
|
+
*/
|
|
484
|
+
declare function certificateMatchesPrivateKey<TMap extends ExtensionDecoderMap = Record<never, never>>(certificate: ParsedCertificate<TMap> | string | Uint8Array, privateKey: CryptoKey): Promise<boolean>;
|
|
485
|
+
/** Machine-readable failure reason for {@linkcode matchCertificatePrivateKey}. */
|
|
486
|
+
type MatchCertificatePrivateKeyErrorCode = "malformed_certificate" | "unsupported_private_key" | "key_type_mismatch" | "key_mismatch";
|
|
487
|
+
/** Structured failure payload for {@linkcode matchCertificatePrivateKey}. */
|
|
488
|
+
interface MatchCertificatePrivateKeyFailure extends Micro509Error<MatchCertificatePrivateKeyErrorCode> {
|
|
489
|
+
/** Always `false` for failures. */
|
|
490
|
+
readonly ok: false;
|
|
491
|
+
}
|
|
492
|
+
/** A successful match: the private key's public half is the certificate's subject public key. */
|
|
493
|
+
interface MatchCertificatePrivateKeySuccess {
|
|
494
|
+
/** Always `true` for success. */
|
|
495
|
+
readonly ok: true;
|
|
496
|
+
/** No payload on success — the match itself is the signal. */
|
|
497
|
+
readonly value: undefined;
|
|
498
|
+
}
|
|
499
|
+
/** Failure branch of {@linkcode MatchCertificatePrivateKeyResult} with structured error details. */
|
|
500
|
+
type MatchCertificatePrivateKeyFailureResult = ErrorResult<MatchCertificatePrivateKeyErrorCode, Record<never, never>, MatchCertificatePrivateKeyFailure>;
|
|
501
|
+
/** Result of {@linkcode matchCertificatePrivateKey}. */
|
|
502
|
+
type MatchCertificatePrivateKeyResult = MatchCertificatePrivateKeySuccess | MatchCertificatePrivateKeyFailureResult;
|
|
503
|
+
/**
|
|
504
|
+
* Check whether a certificate's subject public key belongs to a private key,
|
|
505
|
+
* returning a typed {@linkcode MatchCertificatePrivateKeyResult}.
|
|
506
|
+
*
|
|
507
|
+
* The `Result`-returning companion to {@linkcode certificateMatchesPrivateKey}:
|
|
508
|
+
* where the boolean helper answers only "does it match?" (and throws on bad
|
|
509
|
+
* input), this surfaces the expected failures a key-intake or issuance endpoint
|
|
510
|
+
* meets on untrusted input as typed codes rather than exceptions — matching the
|
|
511
|
+
* house rule of returning `Result` for expected failures and throwing only for
|
|
512
|
+
* invariants. `ok: true` means the key owns the certificate; a failure carries
|
|
513
|
+
* one of:
|
|
514
|
+
*
|
|
515
|
+
* - `malformed_certificate` — `certificate` could not be parsed.
|
|
516
|
+
* - `unsupported_private_key` — `privateKey` is not an extractable private key
|
|
517
|
+
* of a supported type (from {@linkcode derivePublicKey}).
|
|
518
|
+
* - `key_type_mismatch` — the key is a different algorithm than the
|
|
519
|
+
* certificate's subject public key.
|
|
520
|
+
* - `key_mismatch` — the key is the right algorithm but a different key.
|
|
521
|
+
*
|
|
522
|
+
* As with {@linkcode certificateMatchesPrivateKey}, the comparison is over exact
|
|
523
|
+
* SPKI DER, so a certificate pinning RSASSA-PSS parameters reports
|
|
524
|
+
* `key_type_mismatch` against the `rsaEncryption` SPKI WebCrypto emits.
|
|
525
|
+
*
|
|
526
|
+
* @param certificate PEM string, DER bytes, or an already-parsed certificate.
|
|
527
|
+
* @param privateKey An extractable private `CryptoKey`.
|
|
528
|
+
* @returns A success when the key matches, or a typed failure otherwise.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```ts
|
|
532
|
+
* const result = await matchCertificatePrivateKey(certificatePem, privateKey);
|
|
533
|
+
* if (!result.ok) {
|
|
534
|
+
* // result.code is 'malformed_certificate' | 'unsupported_private_key'
|
|
535
|
+
* // | 'key_type_mismatch' | 'key_mismatch'
|
|
536
|
+
* throw new Error(`key does not match certificate: ${result.code}`);
|
|
537
|
+
* }
|
|
538
|
+
* ```
|
|
539
|
+
*
|
|
540
|
+
* @see {@linkcode certificateMatchesPrivateKey} for the plain-boolean variant
|
|
541
|
+
*/
|
|
542
|
+
declare function matchCertificatePrivateKey<TMap extends ExtensionDecoderMap = Record<never, never>>(certificate: ParsedCertificate<TMap> | string | Uint8Array, privateKey: CryptoKey): Promise<MatchCertificatePrivateKeyResult>;
|
|
440
543
|
/**
|
|
441
544
|
* Find a raw extension by OID within a parsed extension list.
|
|
442
545
|
*
|
|
@@ -468,5 +571,5 @@ declare function decodeExtensions(extensions: readonly ParsedExtension[], decode
|
|
|
468
571
|
*/
|
|
469
572
|
declare function decodeExtensionMap<TMap extends ExtensionDecoderMap>(extensions: readonly ParsedExtension[], decoderMap: TMap): DecodedExtensionMap<TMap>;
|
|
470
573
|
//#endregion
|
|
471
|
-
export { DecodedExtensionMap, DecodedExtensionValue, ExtensionDecoder, ExtensionDecoderMap, ParseCertificateErrorCode, ParseCertificateFailure, ParseCertificateResult, ParseCertificateSigningRequestErrorCode, ParseCertificateSigningRequestFailure, ParseCertificateSigningRequestResult, ParseOptions, type ParsedBitFlags, 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 };
|
|
574
|
+
export { DecodedExtensionMap, DecodedExtensionValue, ExtensionDecoder, ExtensionDecoderMap, MatchCertificatePrivateKeyErrorCode, MatchCertificatePrivateKeyFailure, MatchCertificatePrivateKeyFailureResult, MatchCertificatePrivateKeyResult, MatchCertificatePrivateKeySuccess, ParseCertificateErrorCode, ParseCertificateFailure, ParseCertificateResult, ParseCertificateSigningRequestErrorCode, ParseCertificateSigningRequestFailure, ParseCertificateSigningRequestResult, ParseOptions, type ParsedBitFlags, ParsedCertificate, ParsedCertificateSigningRequest, ParsedDistributionPoint, ParsedDistributionPointName, ParsedExtension, ParsedIssuingDistributionPoint, ParsedName, ParsedNameAttribute, ParsedRelativeDistinguishedName, certificateMatchesPrivateKey, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, findExtension, getSubjectPublicKey, getSubjectPublicKeyOrThrow, matchCertificatePrivateKey, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow };
|
|
472
575
|
//# sourceMappingURL=parse.d.ts.map
|