micro509 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/internal/verify/spki-distrust.js +23 -0
- package/dist/internal/verify/spki-distrust.js.map +1 -0
- package/dist/internal/verify/verify-path.js +77 -60
- package/dist/internal/verify/verify-path.js.map +1 -1
- package/dist/keys/keys.d.ts +11 -8
- package/dist/keys/keys.js.map +1 -1
- package/dist/revocation/crl.js +2 -7
- package/dist/revocation/crl.js.map +1 -1
- package/dist/verify/verify.d.ts +32 -1
- package/dist/verify/verify.js +100 -58
- package/dist/verify/verify.js.map +1 -1
- package/dist/x509/fingerprint.d.ts +11 -0
- package/dist/x509/fingerprint.js +19 -1
- package/dist/x509/fingerprint.js.map +1 -1
- package/dist/x509.d.ts +2 -2
- package/dist/x509.js +3 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,60 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.16.0] - 2026-10-24
|
|
23
|
+
|
|
24
|
+
Block a compromised public key across every certificate that carries it,
|
|
25
|
+
including certificates cross-signed by different CAs. This release adds
|
|
26
|
+
SPKI-based distrust to chain verification, tightens indirect CRL issuer
|
|
27
|
+
matching, and reports the certificate responsible for a revocation failure.
|
|
28
|
+
|
|
29
|
+
It also adds explicit SHA-1 RSA-OAEP imports for legacy Bitwarden envelopes
|
|
30
|
+
and restores individual API reference pages with versioned documentation.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- **Distrust compromised keys across certificate paths.** Supply SHA-256 SPKI
|
|
35
|
+
fingerprints through `distrustedSpkiSha256` to reject a key in a leaf,
|
|
36
|
+
intermediate, or trust anchor with `public_key_distrusted`. The same entry
|
|
37
|
+
covers certificates sharing that key across alternative cross-signed paths.
|
|
38
|
+
`subjectPublicKeyInfoFingerprint` computes the fingerprint from a
|
|
39
|
+
certificate and returns bytes, lowercase hex, and colon-separated hex.
|
|
40
|
+
Applications supply their own distrust list. [#178](https://github.com/kjanat/micro509/pull/178)
|
|
41
|
+
- **Import legacy RSA-OAEP keys.** Explicit RSA-OAEP imports accept
|
|
42
|
+
`hash: 'SHA-1'`, including keys for Bitwarden type 4 organization envelopes.
|
|
43
|
+
SHA-256 is the default. RSA signature imports and key generation accept
|
|
44
|
+
SHA-2 hashes. [#180](https://github.com/kjanat/micro509/issues/180)
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
|
|
48
|
+
- **Browse API documentation by symbol and version.** Functions, types, and
|
|
49
|
+
variables have dedicated pages at `/api/fn/`, `/api/type/`, and `/api/var/`.
|
|
50
|
+
The version switcher links to pages available in each snapshot. Algorithm
|
|
51
|
+
documentation distinguishes certificate parsing, key import, generation,
|
|
52
|
+
and signature verification support.
|
|
53
|
+
[#56](https://github.com/kjanat/micro509/issues/56),
|
|
54
|
+
[#179](https://github.com/kjanat/micro509/pull/179)
|
|
55
|
+
- **Read released and development docs separately.** The site root serves the
|
|
56
|
+
latest release, `/next/` follows master, and `/vX.Y.Z/` provides release
|
|
57
|
+
snapshots. Publishing updates the affected version without rebuilding every
|
|
58
|
+
archive. [#60](https://github.com/kjanat/micro509/issues/60)
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- **Reject incorrect indirect CRL issuer identities.** Every `cRLIssuer` entry
|
|
63
|
+
must be a `directoryName` with the exact DER encoding of the CRL issuer,
|
|
64
|
+
as required by RFC 5280 §4.2.1.13. A matching name alongside a URI or another
|
|
65
|
+
issuer no longer makes the CRL applicable. Equivalent names with different
|
|
66
|
+
DER encodings are also rejected. [#13](https://github.com/kjanat/micro509/issues/13)
|
|
67
|
+
- **Identify the certificate behind revocation failures.** Chain verification
|
|
68
|
+
reports the certificate index for revoked and indeterminate results,
|
|
69
|
+
including failures on intermediate certificates.
|
|
70
|
+
- **Serve the published docs tree in production.** Both build entrypoints
|
|
71
|
+
select the versioned publication. Deployment rejects preview-only output
|
|
72
|
+
and waits for the exact publication identifier and its documentation routes
|
|
73
|
+
to appear on the live site. An older deployment with an identical version
|
|
74
|
+
catalog cannot satisfy that check. [#185](https://github.com/kjanat/micro509/pull/185)
|
|
75
|
+
|
|
22
76
|
## [0.15.0] - 2026-10-23
|
|
23
77
|
|
|
24
78
|
Security fixes for revocation decisions, name constraints and service identity,
|
|
@@ -1901,7 +1955,8 @@ Initial prerelease. API may change before 1.0.
|
|
|
1901
1955
|
- Zero runtime dependencies, WebCrypto-native, tree-shakeable subpath exports;
|
|
1902
1956
|
runs on Node, Bun, Deno, browsers, and Cloudflare Workers.
|
|
1903
1957
|
|
|
1904
|
-
[Unreleased]: https://github.com/kjanat/micro509/compare/v0.
|
|
1958
|
+
[Unreleased]: https://github.com/kjanat/micro509/compare/v0.16.0...HEAD
|
|
1959
|
+
[0.16.0]: https://github.com/kjanat/micro509/compare/v0.15.0...v0.16.0
|
|
1905
1960
|
[0.15.0]: https://github.com/kjanat/micro509/compare/v0.14.0...v0.15.0
|
|
1906
1961
|
[0.14.0]: https://github.com/kjanat/micro509/compare/v0.13.0...v0.14.0
|
|
1907
1962
|
[0.13.0]: https://github.com/kjanat/micro509/compare/v0.12.0...v0.13.0
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,6 @@ import { ConstrainedPolicy, PolicyValidationInput, PolicyValidationOutcome } fro
|
|
|
21
21
|
import { isSelfIssued } from "./internal/verify/verify-path.js";
|
|
22
22
|
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, VerifyFailureSource, VerifyPurpose, VerifyRequestFailure, VerifyRequestResult, buildCandidatePath, checkExtendedKeyUsage, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest } from "./verify/verify.js";
|
|
23
23
|
import { CreateCsrInput, CsrMaterial, createCertificateSigningRequest } from "./x509/csr.js";
|
|
24
|
-
import { CertificateFingerprint, CertificateFingerprintAlgorithm, CertificateFingerprintSource, certificateFingerprint } from "./x509/fingerprint.js";
|
|
24
|
+
import { CertificateFingerprint, CertificateFingerprintAlgorithm, CertificateFingerprintSource, certificateFingerprint, subjectPublicKeyInfoFingerprint } from "./x509/fingerprint.js";
|
|
25
25
|
import { SubjectAltNameTextOptions, distinguishedNameToString, relativeDistinguishedNameToString, subjectAltNameLabel, subjectAltNameToString } from "./x509/name-text.js";
|
|
26
|
-
export { type AuthorityInformationAccess, type AuthorityInformationAccessInput, 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 CreateCertificateErrorCode, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspCertStatusInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs12MacDataErrorCode, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateBase, type CreateSelfSignedCertificateInput, type CrlApplicabilityFailureReason, type CrlCertificateSource, type CrlEncoderErrorCode, type CrlSource, type CsrMaterial, type CsrSource, DECODE_REFUSAL_CODES, type DecodeFailureCode, type DecodeRefusalCode, type DecodedExtensionMap, type DecodedExtensionValue, type DecryptRsaOaepErrorCode, type DecryptRsaOaepFailure, type DecryptRsaOaepResult, type DisplayTextType, 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 ExtensionEncoderErrorCode, type GeneralName, type GeneralSubtree, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyOptions, 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 KdfLimitOptions, 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 NameEncoderErrorCode, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspEncoderErrorCode, type OcspHashAlgorithm, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderRevocationPolicy, type OcspResponderSource, type OcspResponseMaterial, type OcspResponseSource, type OcspResponseStatus, type OversizedDisplayText, type ParseCertificateChainResult, 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 ParsePkcs12MacDataOptions, type ParsePkcs12MacDataResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateChoice, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedIssuingDistributionPointBase, type ParsedIssuingDistributionPointScope, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspCertStatus, 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 ParsedRevocationReason, type ParsedRevokedCertificate, type ParsedSignerIdentifier, type Pbes2Parameters, type PemBlock, type PemDecodeResult, type PemErrorCode, type PemFailure, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncoderErrorCode, 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 RevocationParseError, type RevocationPolicy, type RevocationProcessingError, type RevocationReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaOaepOptions, type RsaScheme, type RsaSignatureScheme, type SelfSignedCertificateResult, type SelfSignedKeySource, type ServiceIdentityInput, type ServiceIdentityType, type SplitPemBlocksResult, type SrvServiceIdentityInput, type SubjectAltName, type SubjectAltNameTextOptions, type TrustAnchor, type TrustedOcspResponder, type UnrecognizedReasonCodePolicy, type UnrecognizedRevocationReason, 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 VerifiedPkcs7Signer, type VerifyCertificateChainInput, type VerifyCertificateRevocationListSignatureFailure, type VerifyCertificateRevocationListSignatureResult, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyFailureSource, 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, compareDistinguishedNames, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, decryptRsaOaep, decryptRsaOaepOrThrow, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, distinguishedNameToString, 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, inspectEncryptedPkcs8Der, isCertificateRevoked, isResultError, isSelfIssued as isSelfIssuedCertificate, matchCertificatePrivateKey, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateChainPemOrThrow, parseCertificateDer, parseCertificateDerOrThrow, parseCertificateFromSource, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseCertificatesFromSource, parseDistinguishedNameDer, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, relativeDistinguishedNameToString, resolveOcspResponderCandidates, revocationReasonFromCode, splitPemBlocks, splitPemBlocksOrThrow, subjectAltNameLabel, subjectAltNameToString, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
|
|
26
|
+
export { type AuthorityInformationAccess, type AuthorityInformationAccessInput, 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 CreateCertificateErrorCode, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspCertStatusInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs12MacDataErrorCode, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateBase, type CreateSelfSignedCertificateInput, type CrlApplicabilityFailureReason, type CrlCertificateSource, type CrlEncoderErrorCode, type CrlSource, type CsrMaterial, type CsrSource, DECODE_REFUSAL_CODES, type DecodeFailureCode, type DecodeRefusalCode, type DecodedExtensionMap, type DecodedExtensionValue, type DecryptRsaOaepErrorCode, type DecryptRsaOaepFailure, type DecryptRsaOaepResult, type DisplayTextType, 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 ExtensionEncoderErrorCode, type GeneralName, type GeneralSubtree, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyOptions, 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 KdfLimitOptions, 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 NameEncoderErrorCode, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspEncoderErrorCode, type OcspHashAlgorithm, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderRevocationPolicy, type OcspResponderSource, type OcspResponseMaterial, type OcspResponseSource, type OcspResponseStatus, type OversizedDisplayText, type ParseCertificateChainResult, 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 ParsePkcs12MacDataOptions, type ParsePkcs12MacDataResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateChoice, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedIssuingDistributionPointBase, type ParsedIssuingDistributionPointScope, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspCertStatus, 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 ParsedRevocationReason, type ParsedRevokedCertificate, type ParsedSignerIdentifier, type Pbes2Parameters, type PemBlock, type PemDecodeResult, type PemErrorCode, type PemFailure, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncoderErrorCode, 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 RevocationParseError, type RevocationPolicy, type RevocationProcessingError, type RevocationReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaOaepOptions, type RsaScheme, type RsaSignatureScheme, type SelfSignedCertificateResult, type SelfSignedKeySource, type ServiceIdentityInput, type ServiceIdentityType, type SplitPemBlocksResult, type SrvServiceIdentityInput, type SubjectAltName, type SubjectAltNameTextOptions, type TrustAnchor, type TrustedOcspResponder, type UnrecognizedReasonCodePolicy, type UnrecognizedRevocationReason, 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 VerifiedPkcs7Signer, type VerifyCertificateChainInput, type VerifyCertificateRevocationListSignatureFailure, type VerifyCertificateRevocationListSignatureResult, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyFailureSource, 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, compareDistinguishedNames, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, decryptRsaOaep, decryptRsaOaepOrThrow, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, distinguishedNameToString, 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, inspectEncryptedPkcs8Der, isCertificateRevoked, isResultError, isSelfIssued as isSelfIssuedCertificate, matchCertificatePrivateKey, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateChainPemOrThrow, parseCertificateDer, parseCertificateDerOrThrow, parseCertificateFromSource, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseCertificatesFromSource, parseDistinguishedNameDer, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, relativeDistinguishedNameToString, resolveOcspResponderCandidates, revocationReasonFromCode, splitPemBlocks, splitPemBlocksOrThrow, subjectAltNameLabel, subjectAltNameToString, subjectPublicKeyInfoFingerprint, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,6 @@ import { REVOCATION_INDETERMINATE_REASONS as Ot, checkChainRevocation as kt } fr
|
|
|
14
14
|
import { REVOCATION_INDETERMINATE_REASON_CODES as At, checkCertificateRevocation as jt, getCertificateOcspResponderUris as Mt, resolveOcspResponderCandidates as Nt } from "./revocation/revocation.js";
|
|
15
15
|
import { createCertificate as Pt, createSelfSignedCertificate as Ft } from "./x509/certificate.js";
|
|
16
16
|
import { createCertificateSigningRequest as It } from "./x509/csr.js";
|
|
17
|
-
import { certificateFingerprint as Lt } from "./x509/fingerprint.js";
|
|
18
|
-
import { distinguishedNameToString as
|
|
19
|
-
export { e as DECODE_REFUSAL_CODES, Ot as REVOCATION_INDETERMINATE_REASONS, At as REVOCATION_INDETERMINATE_REASON_CODES, it as VERIFY_ERROR_CODES, at as buildCandidatePath, i as categorizePemBlocks, a as categorizePemBlocksOrThrow, Lt as certificateFingerprint, fe as certificateMatchesPrivateKey, jt as checkCertificateRevocation, Ge as checkCertificateRevocationAgainstCrl, kt as checkChainRevocation, ot as checkExtendedKeyUsage, de as compareDistinguishedNames, Pt as createCertificate, Ke as createCertificateRevocationList, It as createCertificateSigningRequest, ht as createOcspRequest, gt as createOcspResponse, Fe as createPfx, Re as createPkcs7CertBag, ze as createPkcs7SignedData, Ft as createSelfSignedCertificate, pe as decodeExtension, me as decodeExtensionMap, he as decodeExtensions, d as decryptRsaOaep, f as decryptRsaOaepOrThrow, ge as defineExtensionDecoder, _e as defineExtensionDecoderMap, p as derivePublicKey,
|
|
17
|
+
import { certificateFingerprint as Lt, subjectPublicKeyInfoFingerprint as Rt } from "./x509/fingerprint.js";
|
|
18
|
+
import { distinguishedNameToString as zt, relativeDistinguishedNameToString as Bt, subjectAltNameLabel as Vt, subjectAltNameToString as Ht } from "./x509/name-text.js";
|
|
19
|
+
export { e as DECODE_REFUSAL_CODES, Ot as REVOCATION_INDETERMINATE_REASONS, At as REVOCATION_INDETERMINATE_REASON_CODES, it as VERIFY_ERROR_CODES, at as buildCandidatePath, i as categorizePemBlocks, a as categorizePemBlocksOrThrow, Lt as certificateFingerprint, fe as certificateMatchesPrivateKey, jt as checkCertificateRevocation, Ge as checkCertificateRevocationAgainstCrl, kt as checkChainRevocation, ot as checkExtendedKeyUsage, de as compareDistinguishedNames, Pt as createCertificate, Ke as createCertificateRevocationList, It as createCertificateSigningRequest, ht as createOcspRequest, gt as createOcspResponse, Fe as createPfx, Re as createPkcs7CertBag, ze as createPkcs7SignedData, Ft as createSelfSignedCertificate, pe as decodeExtension, me as decodeExtensionMap, he as decodeExtensions, d as decryptRsaOaep, f as decryptRsaOaepOrThrow, ge as defineExtensionDecoder, _e as defineExtensionDecoderMap, p as derivePublicKey, zt as distinguishedNameToString, m as encryptRsaOaep, h as encryptRsaOaepOrThrow, g as exportBinaryBase64, _ as exportEncryptedPkcs1Pem, v as exportEncryptedPkcs8Der, y as exportEncryptedPkcs8Pem, b as exportEncryptedSec1Pem, x as exportPkcs1Der, S as exportPkcs1Pem, C as exportPkcs8Der, w as exportPkcs8Pem, T as exportPrivateJwk, E as exportPublicJwk, D as exportSec1Der, O as exportSec1Pem, k as exportSpkiDer, A as exportSpkiPem, ve as findExtension, j as generateKeyPair, Mt as getCertificateOcspResponderUris, ye as getSubjectPublicKey, be as getSubjectPublicKeyOrThrow, _t as hasOcspNoCheckExtension, M as importEncryptedPkcs1Pem, N as importEncryptedPkcs1PemOrThrow, P as importEncryptedPkcs8Der, F as importEncryptedPkcs8DerOrThrow, I as importEncryptedPkcs8Pem, L as importEncryptedPkcs8PemOrThrow, R as importEncryptedSec1Pem, z as importEncryptedSec1PemOrThrow, B as importPkcs1Der, V as importPkcs1DerOrThrow, H as importPkcs1Pem, U as importPkcs1PemOrThrow, W as importPkcs8Base64, G as importPkcs8Base64OrThrow, K as importPkcs8Der, q as importPkcs8DerOrThrow, J as importPkcs8Pem, Y as importPkcs8PemOrThrow, X as importPrivateJwk, Z as importPrivateJwkOrThrow, Q as importPublicJwk, $ as importPublicJwkOrThrow, ee as importSec1Der, te as importSec1DerOrThrow, ne as importSec1Pem, re as importSec1PemOrThrow, ie as importSpkiBase64, ae as importSpkiBase64OrThrow, oe as importSpkiDer, se as importSpkiDerOrThrow, ce as importSpkiPem, le as importSpkiPemOrThrow, ue as inspectEncryptedPkcs8Der, qe as isCertificateRevoked, t as isResultError, tt as isSelfIssuedCertificate, xe as matchCertificatePrivateKey, nt as matchCertificateServiceIdentity, rt as matchServiceIdentity, Se as parseCertificateChainPem, Ce as parseCertificateChainPemOrThrow, we as parseCertificateDer, Te as parseCertificateDerOrThrow, Ee as parseCertificateFromSource, De as parseCertificatePem, Oe as parseCertificatePemOrThrow, Je as parseCertificateRevocationListDer, Ye as parseCertificateRevocationListDerOrThrow, Xe as parseCertificateRevocationListPem, Ze as parseCertificateRevocationListPemOrThrow, ke as parseCertificateSigningRequestDer, Ae as parseCertificateSigningRequestDerOrThrow, je as parseCertificateSigningRequestPem, Me as parseCertificateSigningRequestPemOrThrow, Ne as parseCertificatesFromSource, Pe as parseDistinguishedNameDer, vt as parseOcspRequestDer, yt as parseOcspRequestDerOrThrow, bt as parseOcspRequestPem, xt as parseOcspRequestPemOrThrow, St as parseOcspResponseDer, Ct as parseOcspResponseDerOrThrow, wt as parseOcspResponsePem, Tt as parseOcspResponsePemOrThrow, Ie as parsePfxDer, Le as parsePfxPem, Be as parsePkcs7CertBagDer, Ve as parsePkcs7CertBagPem, He as parsePkcs7SignedDataDer, Ue as parsePkcs7SignedDataPem, o as pemDecode, s as pemDecodeOrThrow, c as pemEncode, Bt as relativeDistinguishedNameToString, Nt as resolveOcspResponderCandidates, Qe as revocationReasonFromCode, l as splitPemBlocks, u as splitPemBlocksOrThrow, Vt as subjectAltNameLabel, Ht as subjectAltNameToString, Rt as subjectPublicKeyInfoFingerprint, st as trustAnchorFromCertificate, n as unwrap, r as unwrapOr, ct as validateCandidatePath, $e as validateCertificateRevocationList, lt as validateForCa, ut as validateForCodeSigning, dt as validateForTlsClient, ft as validateForTlsServer, Et as validateOcspResponse, pt as verifyCertificateChain, et as verifyCertificateRevocationListSignature, mt as verifyCertificateSigningRequest, Dt as verifyOcspResponseSignature, We as verifyPkcs7SignedData };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { toArrayBuffer as e, toHex as t } from "../asn1/asn1.js";
|
|
2
|
+
import { getCrypto as n } from "../crypto/webcrypto.js";
|
|
3
|
+
// src/internal/verify/spki-distrust.ts
|
|
4
|
+
/** Caller-supplied SHA-256 SPKI distrust, scoped to one verification operation. */
|
|
5
|
+
/** Validates and snapshots the caller's hashes before any asynchronous work. */
|
|
6
|
+
function createSpkiDistrustCheck(r) {
|
|
7
|
+
let i = /* @__PURE__ */ new Set();
|
|
8
|
+
for (let e of r ?? []) {
|
|
9
|
+
if (typeof e != "string" || !/^[0-9a-fA-F]{64}$/.test(e)) throw RangeError("distrustedSpkiSha256 entries must be 64 hexadecimal characters");
|
|
10
|
+
i.add(e.toLowerCase());
|
|
11
|
+
}
|
|
12
|
+
let a = /* @__PURE__ */ new Map();
|
|
13
|
+
return async (r) => {
|
|
14
|
+
if (i.size === 0) return;
|
|
15
|
+
let o = t(r), s = a.get(o);
|
|
16
|
+
s === void 0 && (s = n().subtle.digest("SHA-256", e(r)).then((e) => t(new Uint8Array(e))), a.set(o, s));
|
|
17
|
+
let c = await s;
|
|
18
|
+
return i.has(c) ? c : void 0;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export { createSpkiDistrustCheck };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=spki-distrust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spki-distrust.js","names":["blocked","hash","hashes","digests","key","toHex","spki","digest","getCrypto","toArrayBuffer","bytes"],"sources":["../../../src/internal/verify/spki-distrust.ts"],"sourcesContent":["/** Caller-supplied SHA-256 SPKI distrust, scoped to one verification operation. */\nimport { toArrayBuffer, toHex } from '#micro509/internal/asn1/asn1';\nimport { getCrypto } from '#micro509/internal/crypto/webcrypto';\n\n/** Validates and snapshots the caller's hashes before any asynchronous work. */\nexport function createSpkiDistrustCheck(\n\thashes: readonly string[] | undefined,\n): (spki: Uint8Array) => Promise<string | undefined> {\n\tconst blocked = new Set<string>();\n\tfor (const hash of hashes ?? []) {\n\t\tif (typeof hash !== 'string' || !/^[0-9a-fA-F]{64}$/.test(hash)) {\n\t\t\tthrow new RangeError('distrustedSpkiSha256 entries must be 64 hexadecimal characters');\n\t\t}\n\t\tblocked.add(hash.toLowerCase());\n\t}\n\tconst digests = new Map<string, Promise<string>>();\n\treturn async (spki) => {\n\t\tif (blocked.size === 0) return undefined;\n\t\tconst key = toHex(spki);\n\t\tlet digest = digests.get(key);\n\t\tif (digest === undefined) {\n\t\t\tdigest = getCrypto()\n\t\t\t\t.subtle.digest('SHA-256', toArrayBuffer(spki))\n\t\t\t\t.then((bytes) => toHex(new Uint8Array(bytes)));\n\t\t\tdigests.set(key, digest);\n\t\t}\n\t\tconst hash = await digest;\n\t\treturn blocked.has(hash) ? hash : undefined;\n\t};\n}\n"],"mappings":";;;;;AAKA,SAAgB,wBACf,GACoD;CACpD,IAAMA,oBAAU,IAAI,IAAY;CAChC,KAAK,IAAMC,KAAQC,KAAU,CAAC,GAAG;EAChC,IAAI,OAAOD,KAAS,YAAY,CAAC,oBAAoB,KAAKA,CAAI,GAC7D,MAAU,WAAW,gEAAgE;EAEtF,EAAQ,IAAIA,EAAK,YAAY,CAAC;CAC/B;CACA,IAAME,oBAAU,IAAI,IAA6B;CACjD,OAAO,OAAO,MAAS;EACtB,IAAIH,EAAQ,SAAS,GAAG;EACxB,IAAMI,IAAMC,EAAMC,CAAI,GAClBC,IAASJ,EAAQ,IAAIC,CAAG;EAC5B,AAAIG,MAAW,KAAA,MACd,IAASC,EAAU,CAAC,CAClB,OAAO,OAAO,WAAWC,EAAcH,CAAI,CAAC,CAAC,CAC7C,MAAM,MAAUD,EAAM,IAAI,WAAWK,CAAK,CAAC,CAAC,GAC9CP,EAAQ,IAAIC,GAAKG,CAAM;EAExB,IAAMN,IAAO,MAAMM;EACnB,OAAOP,EAAQ,IAAIC,CAAI,IAAIA,IAAO,KAAA;CACnC;AACD"}
|
|
@@ -127,84 +127,93 @@ function rebaseDiagnostic(e, t, n) {
|
|
|
127
127
|
* step. Returns the first fully anchored path or the deepest partial path
|
|
128
128
|
* with the best failure encountered.
|
|
129
129
|
*/
|
|
130
|
-
async function buildChainInternal(e, t, r, a, o, l, u = c, d = s) {
|
|
131
|
-
let
|
|
130
|
+
async function buildChainInternal(e, t, r, a, o, l, u = c, d = s, f = () => Promise.resolve(void 0)) {
|
|
131
|
+
let p, m = [...t, ...r], h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), _ = new Set(r.map((e) => fingerprint(e))), v = /* @__PURE__ */ new Map();
|
|
132
132
|
for (let e of a) {
|
|
133
|
-
let t = i(e.subject), n =
|
|
134
|
-
n === void 0 ?
|
|
133
|
+
let t = i(e.subject), n = v.get(t);
|
|
134
|
+
n === void 0 ? v.set(t, [e]) : n.push(e);
|
|
135
135
|
}
|
|
136
|
-
let
|
|
136
|
+
let y = { current: {
|
|
137
137
|
kind: "none",
|
|
138
138
|
path: [e]
|
|
139
|
-
} },
|
|
139
|
+
} }, b = /* @__PURE__ */ new Map(), x = [], S = /* @__PURE__ */ new Map(), C = {
|
|
140
140
|
remaining: d,
|
|
141
141
|
exhausted: !1
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
let n = i(e.subject), r =
|
|
145
|
-
r === void 0 ?
|
|
142
|
+
}, w = /* @__PURE__ */ new Map();
|
|
143
|
+
m.forEach((e, t) => {
|
|
144
|
+
let n = i(e.subject), r = h.get(n);
|
|
145
|
+
r === void 0 ? h.set(n, [e]) : r.push(e), g.set(fingerprint(e), t);
|
|
146
146
|
});
|
|
147
|
-
let
|
|
148
|
-
if (
|
|
149
|
-
let e =
|
|
147
|
+
let T = m.length + 1, E = fingerprint(e), D = await search(e, [e], /* @__PURE__ */ new Set([E]), 0);
|
|
148
|
+
if (D !== void 0) {
|
|
149
|
+
let e = D[D.length - 1];
|
|
150
150
|
return {
|
|
151
|
-
chain:
|
|
151
|
+
chain: D,
|
|
152
152
|
foundTrustedRoot: !0,
|
|
153
|
-
|
|
153
|
+
...p !== void 0 && { trustAnchor: p },
|
|
154
|
+
anchorCertificateInChain: e !== void 0 && _.has(fingerprint(e))
|
|
154
155
|
};
|
|
155
156
|
}
|
|
156
|
-
let
|
|
157
|
-
if (
|
|
158
|
-
chain:
|
|
157
|
+
let O = y.current;
|
|
158
|
+
if (C.exhausted) return {
|
|
159
|
+
chain: O.path,
|
|
159
160
|
foundTrustedRoot: !1,
|
|
160
161
|
failure: l.failure("path_building_limit_exceeded", "path building stopped at its work limit", void 0, l.detail({
|
|
161
162
|
expected: `at most ${d} issuer and trust-anchor checks`,
|
|
162
163
|
actual: "limit reached before a trusted path was found"
|
|
163
164
|
}))
|
|
164
165
|
};
|
|
165
|
-
switch (
|
|
166
|
+
switch (O.kind) {
|
|
166
167
|
case "specific-failure": return {
|
|
167
|
-
chain:
|
|
168
|
+
chain: O.path,
|
|
168
169
|
foundTrustedRoot: !1,
|
|
169
|
-
failure:
|
|
170
|
+
failure: O.failure
|
|
170
171
|
};
|
|
171
172
|
case "missing-issuer": return {
|
|
172
|
-
chain:
|
|
173
|
+
chain: O.path,
|
|
173
174
|
foundTrustedRoot: !1,
|
|
174
|
-
missingIssuerAt:
|
|
175
|
+
missingIssuerAt: O.missingIssuerAt
|
|
175
176
|
};
|
|
176
177
|
case "untrusted-anchor":
|
|
177
178
|
case "none": return {
|
|
178
|
-
chain:
|
|
179
|
+
chain: O.path,
|
|
179
180
|
foundTrustedRoot: !1
|
|
180
181
|
};
|
|
181
|
-
default: throw Error(`unreachable diagnostic ${String(
|
|
182
|
+
default: throw Error(`unreachable diagnostic ${String(O)}`);
|
|
182
183
|
}
|
|
183
184
|
async function search(e, t, n, r) {
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (o !== void 0) {
|
|
192
|
-
consider(rebaseDiagnostic(o.diagnostic, o.nodeIndex, t));
|
|
185
|
+
if (C.exhausted) return;
|
|
186
|
+
let i = await f(e.subjectPublicKeyInfoDer);
|
|
187
|
+
if (i !== void 0) {
|
|
188
|
+
recordFailure(l.failure("public_key_distrusted", "certificate public key is explicitly distrusted", t.length - 1, l.detail({
|
|
189
|
+
subjectCommonName: e.subject.values.commonName,
|
|
190
|
+
actual: i
|
|
191
|
+
})), t);
|
|
193
192
|
return;
|
|
194
193
|
}
|
|
195
|
-
|
|
194
|
+
if (_.has(fingerprint(e))) return t;
|
|
195
|
+
let a = await matchTrustAnchor(e, v, l, t.length - 1, verifyAnchorOnce, chargeBudget, f);
|
|
196
|
+
if (C.exhausted) return;
|
|
197
|
+
if (a.failure !== void 0 && recordFailure(a.failure, t), a.matched) return p = a.anchor, t;
|
|
198
|
+
if (t.length > T) return;
|
|
199
|
+
let o = `${fingerprint(e)}:${r}`, s = b.get(o);
|
|
200
|
+
if (s !== void 0) {
|
|
201
|
+
consider(rebaseDiagnostic(s.diagnostic, s.nodeIndex, t));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
let c = { best: {
|
|
196
205
|
kind: "none",
|
|
197
206
|
path: t
|
|
198
207
|
} };
|
|
199
|
-
|
|
208
|
+
x.push(c);
|
|
200
209
|
try {
|
|
201
210
|
let i = await searchBelow(e, t, n, r);
|
|
202
211
|
if (i !== void 0) return i;
|
|
203
212
|
} finally {
|
|
204
|
-
|
|
213
|
+
x.pop();
|
|
205
214
|
}
|
|
206
|
-
|
|
207
|
-
diagnostic:
|
|
215
|
+
b.set(o, {
|
|
216
|
+
diagnostic: c.best,
|
|
208
217
|
nodeIndex: t.length - 1
|
|
209
218
|
});
|
|
210
219
|
}
|
|
@@ -218,7 +227,7 @@ async function buildChainInternal(e, t, r, a, o, l, u = c, d = s) {
|
|
|
218
227
|
if (n.has(o)) continue;
|
|
219
228
|
let s = await searchIssuerCandidate(e, a, o, t, n, r);
|
|
220
229
|
if (s !== void 0) return s;
|
|
221
|
-
if (
|
|
230
|
+
if (C.exhausted) return;
|
|
222
231
|
}
|
|
223
232
|
i ? consider({
|
|
224
233
|
kind: "none",
|
|
@@ -227,8 +236,8 @@ async function buildChainInternal(e, t, r, a, o, l, u = c, d = s) {
|
|
|
227
236
|
}
|
|
228
237
|
/** Yields the issuer bucket for `current`: AKI matches first, then roots, then input order. */
|
|
229
238
|
function* issuerCandidates(e) {
|
|
230
|
-
let t = i(e.issuer), n =
|
|
231
|
-
n === void 0 && (n = rankBucket(
|
|
239
|
+
let t = i(e.issuer), n = w.get(t);
|
|
240
|
+
n === void 0 && (n = rankBucket(h.get(t) ?? [], g, _), w.set(t, n));
|
|
232
241
|
let r = e.authorityKeyIdentifier;
|
|
233
242
|
if (r === void 0) yield* n.ordered;
|
|
234
243
|
else {
|
|
@@ -256,7 +265,7 @@ async function buildChainInternal(e, t, r, a, o, l, u = c, d = s) {
|
|
|
256
265
|
return c.add(n), await search(t, [...r, t], c, s.nextCaBelowCount);
|
|
257
266
|
}
|
|
258
267
|
function chargeBudget() {
|
|
259
|
-
return
|
|
268
|
+
return C.remaining === 0 ? (C.exhausted = !0, !1) : (--C.remaining, !0);
|
|
260
269
|
}
|
|
261
270
|
function verifySignatureOnce(e, t) {
|
|
262
271
|
return verifyOnce(`c:${fingerprint(e)}:${n(t.subjectPublicKeyInfoDer)}`, () => u.certificate(e, t));
|
|
@@ -267,12 +276,12 @@ async function buildChainInternal(e, t, r, a, o, l, u = c, d = s) {
|
|
|
267
276
|
}
|
|
268
277
|
/** One signature check per distinct certificate-and-key pair for the whole search. */
|
|
269
278
|
function verifyOnce(e, t) {
|
|
270
|
-
let n =
|
|
271
|
-
return n === void 0 && (n = t(),
|
|
279
|
+
let n = S.get(e);
|
|
280
|
+
return n === void 0 && (n = t(), S.set(e, n)), n;
|
|
272
281
|
}
|
|
273
282
|
function consider(e) {
|
|
274
|
-
isMoreSignificant(e,
|
|
275
|
-
for (let t of
|
|
283
|
+
isMoreSignificant(e, y.current) && (y.current = e);
|
|
284
|
+
for (let t of x) isMoreSignificant(e, t.best) && (t.best = e);
|
|
276
285
|
}
|
|
277
286
|
function recordFailure(e, t) {
|
|
278
287
|
consider({
|
|
@@ -375,27 +384,35 @@ function isIssuerOf(e, t) {
|
|
|
375
384
|
return a(t.issuer, e.subject);
|
|
376
385
|
}
|
|
377
386
|
/** Attempts to verify `certificate` against each bare trust anchor whose subject DN matches. */
|
|
378
|
-
async function matchTrustAnchor(e, t, n, r, o, s) {
|
|
379
|
-
let
|
|
380
|
-
if (
|
|
381
|
-
let
|
|
382
|
-
for (let t of
|
|
387
|
+
async function matchTrustAnchor(e, t, n, r, o, s, c) {
|
|
388
|
+
let l = t.get(i(e.issuer));
|
|
389
|
+
if (l === void 0) return { matched: !1 };
|
|
390
|
+
let u;
|
|
391
|
+
for (let t of l) {
|
|
383
392
|
if (!s()) return { matched: !1 };
|
|
384
393
|
if (trustAnchorAkiMismatch(e, t) || !a(e.issuer, t.subject)) continue;
|
|
385
|
-
let i = await
|
|
386
|
-
if (
|
|
394
|
+
let i = await c(t.subjectPublicKeyInfoDer);
|
|
395
|
+
if (i !== void 0) {
|
|
396
|
+
u = n.failure("public_key_distrusted", "bare trust anchor public key is explicitly distrusted", void 0, n.detail({ actual: i }));
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
let l = await o(e, t);
|
|
400
|
+
if (!l.ok) u ??= n.failure(l.code, l.reason, r, n.detail({
|
|
387
401
|
subjectCommonName: e.subject.values.commonName,
|
|
388
|
-
actual:
|
|
389
|
-
}))
|
|
390
|
-
else if (!
|
|
402
|
+
actual: l.reason
|
|
403
|
+
}));
|
|
404
|
+
else if (!l.valid) u === void 0 && (u = n.failure("signature_invalid", "certificate signature does not verify", r, n.detail({
|
|
391
405
|
subjectCommonName: e.subject.values.commonName,
|
|
392
406
|
actual: "certificate signature does not verify"
|
|
393
407
|
})));
|
|
394
|
-
else return {
|
|
408
|
+
else return {
|
|
409
|
+
matched: !0,
|
|
410
|
+
anchor: t
|
|
411
|
+
};
|
|
395
412
|
}
|
|
396
|
-
return
|
|
413
|
+
return u === void 0 ? { matched: !1 } : {
|
|
397
414
|
matched: !1,
|
|
398
|
-
failure:
|
|
415
|
+
failure: u
|
|
399
416
|
};
|
|
400
417
|
}
|
|
401
418
|
function trustAnchorAkiMismatch(e, t) {
|