micro509 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/keys/keys.d.ts +161 -18
- package/dist/keys/keys.js +186 -26
- package/dist/keys.d.ts +2 -2
- package/dist/keys.js +2 -2
- package/dist/revocation/ocsp.d.ts +2 -2
- package/dist/revocation/ocsp.js +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorResult, IndexedErrorResult, IndexedMicro509Error, Micro509Error, Result, ResultError, isResultError, unwrap, unwrapOr } from "./result/result.js";
|
|
2
|
-
import { EcKeyAlgorithmInput, EcNamedCurve, Ed25519KeyAlgorithmInput, EncryptedPkcs8Options, ImportEcKeyInput, ImportEd25519KeyInput, ImportEncryptedKeyErrorCode, ImportEncryptedKeyFailure, ImportEncryptedKeyResult, ImportKeyErrorCode, ImportKeyFailure, ImportKeyResult, ImportRsaKeyInput, KeyAlgorithmInput, KeyPairMaterial, LegacyPemEncryptionOptions, PrivateKeyImportInput, PublicKeyImportInput, RsaHash, RsaKeyAlgorithmInput, RsaScheme, derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
|
|
2
|
+
import { DecryptRsaOaepErrorCode, DecryptRsaOaepFailure, DecryptRsaOaepResult, EcKeyAlgorithmInput, EcNamedCurve, Ed25519KeyAlgorithmInput, EncryptRsaOaepErrorCode, EncryptRsaOaepFailure, EncryptRsaOaepResult, EncryptedPkcs8Options, ImportEcKeyInput, ImportEd25519KeyInput, ImportEncryptedKeyErrorCode, ImportEncryptedKeyFailure, ImportEncryptedKeyResult, ImportKeyErrorCode, ImportKeyFailure, ImportKeyResult, ImportRsaKeyInput, KeyAlgorithmInput, KeyPairMaterial, LegacyPemEncryptionOptions, PrivateKeyImportInput, PublicKeyImportInput, RsaHash, RsaKeyAlgorithmInput, RsaOaepOptions, RsaScheme, RsaSignatureScheme, decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
|
|
3
3
|
import { CategorizePemBlocksResult, CategorizedPemBlocks, PemBlock, PemDecodeResult, PemErrorCode, PemFailure, SplitPemBlocksResult, categorizePemBlocks, categorizePemBlocksOrThrow, pemDecode, pemDecodeOrThrow, pemEncode, splitPemBlocks, splitPemBlocksOrThrow } from "./pem/pem.js";
|
|
4
4
|
import { NameAttribute, NameFieldKey, NameInput, NameObject, RelativeDistinguishedNameInput } from "./x509/name.js";
|
|
5
5
|
import { AuthorityInformationAccess, BasicConstraints, CertificateExtensionsInput, CertificatePolicies, DistributionPoint, DistributionPointName, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, IssuingDistributionPoint, IssuingDistributionPointBase, IssuingDistributionPointForAttributeCerts, IssuingDistributionPointForCaCerts, IssuingDistributionPointForUserCerts, KeyUsage, NameConstraintForm, NameConstraints, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyInformation, PolicyMapping, PolicyMappings, PolicyQualifierInfo, SubjectAltName } from "./x509/extensions.js";
|
|
@@ -17,4 +17,4 @@ import { InitialNameConstraintsInput } from "./verify/name-constraints.js";
|
|
|
17
17
|
import { ConstrainedPolicy, PolicyValidationInput, PolicyValidationOutcome } from "./verify/policy.js";
|
|
18
18
|
import { BuildCandidatePathInput, BuildCandidatePathResult, CandidatePath, CertificateSource, ChainRevocationInput, CsrSource, EkuCheckFailure, EkuCheckPurpose, EkuCheckResult, TrustAnchor, VERIFY_ERROR_CODES, ValidateCandidatePathInput, ValidateCandidatePathResult, ValidateCandidatePathSuccess, ValidateForCaInput, ValidateForCodeSigningInput, ValidateForTlsClientInput, ValidateForTlsServerInput, VerifiedCertificateChain, VerifyCertificateChainInput, VerifyChainFailure, VerifyChainResult, VerifyErrorCode, VerifyFailureDetails, VerifyPurpose, VerifyRequestFailure, VerifyRequestResult, buildCandidatePath, checkExtendedKeyUsage, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest } from "./verify/verify.js";
|
|
19
19
|
import { CreateCsrInput, CsrMaterial, createCertificateSigningRequest } from "./x509/csr.js";
|
|
20
|
-
export { type AuthorityInformationAccess, type BasicConstraints, type BuildCandidatePathInput, type BuildCandidatePathResult, type CandidatePath, type CategorizePemBlocksResult, type CategorizedPemBlocks, type CertificateExtensionsInput, type CertificateMaterial, type CertificatePolicies, type CertificateRevocationListMaterial, type CertificateRevocationStatus, type CertificateSource, type ChainRevocationInput, type CheckCertificateRevocationAgainstCrlErrorCode, type CheckCertificateRevocationAgainstCrlFailure, type CheckCertificateRevocationAgainstCrlFailureDetails, type CheckCertificateRevocationAgainstCrlGoodValue, type CheckCertificateRevocationAgainstCrlInput, type CheckCertificateRevocationAgainstCrlResult, type CheckCertificateRevocationAgainstCrlRevokedValue, type CheckCertificateRevocationAgainstCrlValue, type CheckCertificateRevocationErrorCode, type CheckCertificateRevocationFailureDetails, type CheckCertificateRevocationInput, type CheckCertificateRevocationResult, type CheckCertificateRevocationValue, type CheckChainRevocationInput, type CheckChainRevocationResult, type CheckChainRevocationValue, type ConfiguredOcspResponder, type ConfiguredOcspResponderCertificate, type ConstrainedPolicy, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateInput, type CrlApplicabilityFailureReason, type CrlCertificateSource, type CrlSource, type CsrMaterial, type CsrSource, type DecodedExtensionMap, type DecodedExtensionValue, type DistributionPoint, type DistributionPointName, type DnsServiceIdentityInput, type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EkuCheckFailure, type EkuCheckPurpose, type EkuCheckResult, type EncryptedPkcs8Options, type ErrorResult, type ExtendedKeyUsage, type ExtensionDecoder, type ExtensionDecoderMap, type GeneralName, type GeneralSubtree, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyFailure, type ImportKeyResult, type ImportRsaKeyInput, type IndexedErrorResult, type IndexedMicro509Error, type InhibitAnyPolicy, type InitialNameConstraintsInput, type IpServiceIdentityInput, type IssuingDistributionPoint, type IssuingDistributionPointBase, type IssuingDistributionPointForAttributeCerts, type IssuingDistributionPointForCaCerts, type IssuingDistributionPointForUserCerts, type KeyAlgorithmInput, type KeyPairMaterial, type KeyUsage, type LegacyPemEncryptionOptions, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityFailureDetails, type MatchServiceIdentityFailureResult, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type Micro509Error, type NameAttribute, type NameConstraintForm, type NameConstraints, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspHashAlgorithm, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderRevocationPolicy, type OcspResponderSource, type OcspResponseMaterial, type OcspResponseSource, type OcspResponseStatus, type ParseCertificateErrorCode, type ParseCertificateFailure, type ParseCertificateResult, type ParseCertificateRevocationListErrorCode, type ParseCertificateRevocationListFailure, type ParseCertificateRevocationListResult, type ParseCertificateSigningRequestErrorCode, type ParseCertificateSigningRequestFailure, type ParseCertificateSigningRequestResult, type ParseOcspRequestErrorCode, type ParseOcspRequestFailure, type ParseOcspRequestResult, type ParseOcspResponseErrorCode, type ParseOcspResponseFailure, type ParseOcspResponseResult, type ParseOptions, type ParsePfxErrorCode, type ParsePfxFailure, type ParsePfxOptions, type ParsePfxResult, type ParsePkcs12MacDataErrorCode, type ParsePkcs12MacDataFailure, type ParsePkcs12MacDataResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspRequest, type ParsedOcspResponderId, type ParsedOcspResponse, type ParsedOcspSingleResponse, type ParsedPfx, type ParsedPfxAttribute, type ParsedPfxBag, type ParsedPfxBagAttributes, type ParsedPkcs12MacData, type ParsedPkcs7SignedData, type ParsedPkcs7SignerInfo, type ParsedPkcs7SignerInfoBase, type ParsedRelativeDistinguishedName, type ParsedRevokedCertificate, type PemBlock, type PemDecodeResult, type PemErrorCode, type PemFailure, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncryptionOptions, type PfxMaterial, type PfxPrivateKeyBagInput, type PfxPrivateKeySource, type Pkcs12MacOptions, type Pkcs7CertBagMaterial, type Pkcs7CertificateSource, type Pkcs7SignedDataMaterial, type Pkcs7Signer, type PolicyConstraints, type PolicyInformation, type PolicyMapping, type PolicyMappings, type PolicyQualifierInfo, type PolicyValidationInput, type PolicyValidationOutcome, type PrivateKeyImportInput, type PublicKeyImportInput, REVOCATION_INDETERMINATE_REASONS, REVOCATION_INDETERMINATE_REASON_CODES, type RelativeDistinguishedNameInput, type ResolveOcspResponderCandidatesInput, type Result, type ResultError, type RevocationCertificateSource, type RevocationCheckGoodValue, type RevocationCheckIndeterminateValue, type RevocationCheckRevokedValue, type RevocationCrlEvidenceInput, type RevocationEvidenceInput, type RevocationEvidenceKind, type RevocationExecutionError, type RevocationIndeterminateEvidence, type RevocationIndeterminateReason, type RevocationIndeterminateReasonCode, type RevocationOcspEvidenceInput, type RevocationPolicy, type RevocationReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaScheme, type SelfSignedCertificateResult, type ServiceIdentityInput, type ServiceIdentityType, type SplitPemBlocksResult, type SrvServiceIdentityInput, type SubjectAltName, type TrustAnchor, type UriServiceIdentityInput, VERIFY_ERROR_CODES, type ValidateCandidatePathInput, type ValidateCandidatePathResult, type ValidateCandidatePathSuccess, type ValidateCertificateRevocationListFailure, type ValidateCertificateRevocationListInput, type ValidateCertificateRevocationListResult, type ValidateForCaInput, type ValidateForCodeSigningInput, type ValidateForTlsClientInput, type ValidateForTlsServerInput, type ValidateOcspResponseErrorCode, type ValidateOcspResponseFailure, type ValidateOcspResponseInput, type ValidateOcspResponseResult, type ValidityInput, type VerifiedCertificateChain, type VerifyCertificateChainInput, type VerifyCertificateRevocationListSignatureFailure, type VerifyCertificateRevocationListSignatureResult, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyOcspResponseSignatureFailure, type VerifyOcspResponseSignatureResult, type VerifyPkcs7SignedDataFailure, type VerifyPkcs7SignedDataResult, type VerifyPurpose, type VerifyRequestFailure, type VerifyRequestResult, buildCandidatePath, categorizePemBlocks, categorizePemBlocksOrThrow, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, getSubjectPublicKey, getSubjectPublicKeyOrThrow, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow, isCertificateRevoked, isResultError, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, resolveOcspResponderCandidates, splitPemBlocks, splitPemBlocksOrThrow, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
|
|
20
|
+
export { type AuthorityInformationAccess, type BasicConstraints, type BuildCandidatePathInput, type BuildCandidatePathResult, type CandidatePath, type CategorizePemBlocksResult, type CategorizedPemBlocks, type CertificateExtensionsInput, type CertificateMaterial, type CertificatePolicies, type CertificateRevocationListMaterial, type CertificateRevocationStatus, type CertificateSource, type ChainRevocationInput, type CheckCertificateRevocationAgainstCrlErrorCode, type CheckCertificateRevocationAgainstCrlFailure, type CheckCertificateRevocationAgainstCrlFailureDetails, type CheckCertificateRevocationAgainstCrlGoodValue, type CheckCertificateRevocationAgainstCrlInput, type CheckCertificateRevocationAgainstCrlResult, type CheckCertificateRevocationAgainstCrlRevokedValue, type CheckCertificateRevocationAgainstCrlValue, type CheckCertificateRevocationErrorCode, type CheckCertificateRevocationFailureDetails, type CheckCertificateRevocationInput, type CheckCertificateRevocationResult, type CheckCertificateRevocationValue, type CheckChainRevocationInput, type CheckChainRevocationResult, type CheckChainRevocationValue, type ConfiguredOcspResponder, type ConfiguredOcspResponderCertificate, type ConstrainedPolicy, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateInput, type CrlApplicabilityFailureReason, type CrlCertificateSource, type CrlSource, type CsrMaterial, type CsrSource, type DecodedExtensionMap, type DecodedExtensionValue, type DecryptRsaOaepErrorCode, type DecryptRsaOaepFailure, type DecryptRsaOaepResult, type DistributionPoint, type DistributionPointName, type DnsServiceIdentityInput, type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EkuCheckFailure, type EkuCheckPurpose, type EkuCheckResult, type EncryptRsaOaepErrorCode, type EncryptRsaOaepFailure, type EncryptRsaOaepResult, type EncryptedPkcs8Options, type ErrorResult, type ExtendedKeyUsage, type ExtensionDecoder, type ExtensionDecoderMap, type GeneralName, type GeneralSubtree, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyFailure, type ImportKeyResult, type ImportRsaKeyInput, type IndexedErrorResult, type IndexedMicro509Error, type InhibitAnyPolicy, type InitialNameConstraintsInput, type IpServiceIdentityInput, type IssuingDistributionPoint, type IssuingDistributionPointBase, type IssuingDistributionPointForAttributeCerts, type IssuingDistributionPointForCaCerts, type IssuingDistributionPointForUserCerts, type KeyAlgorithmInput, type KeyPairMaterial, type KeyUsage, type LegacyPemEncryptionOptions, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityFailureDetails, type MatchServiceIdentityFailureResult, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type Micro509Error, type NameAttribute, type NameConstraintForm, type NameConstraints, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspHashAlgorithm, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderRevocationPolicy, type OcspResponderSource, type OcspResponseMaterial, type OcspResponseSource, type OcspResponseStatus, type ParseCertificateErrorCode, type ParseCertificateFailure, type ParseCertificateResult, type ParseCertificateRevocationListErrorCode, type ParseCertificateRevocationListFailure, type ParseCertificateRevocationListResult, type ParseCertificateSigningRequestErrorCode, type ParseCertificateSigningRequestFailure, type ParseCertificateSigningRequestResult, type ParseOcspRequestErrorCode, type ParseOcspRequestFailure, type ParseOcspRequestResult, type ParseOcspResponseErrorCode, type ParseOcspResponseFailure, type ParseOcspResponseResult, type ParseOptions, type ParsePfxErrorCode, type ParsePfxFailure, type ParsePfxOptions, type ParsePfxResult, type ParsePkcs12MacDataErrorCode, type ParsePkcs12MacDataFailure, type ParsePkcs12MacDataResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspRequest, type ParsedOcspResponderId, type ParsedOcspResponse, type ParsedOcspSingleResponse, type ParsedPfx, type ParsedPfxAttribute, type ParsedPfxBag, type ParsedPfxBagAttributes, type ParsedPkcs12MacData, type ParsedPkcs7SignedData, type ParsedPkcs7SignerInfo, type ParsedPkcs7SignerInfoBase, type ParsedRelativeDistinguishedName, type ParsedRevokedCertificate, type PemBlock, type PemDecodeResult, type PemErrorCode, type PemFailure, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncryptionOptions, type PfxMaterial, type PfxPrivateKeyBagInput, type PfxPrivateKeySource, type Pkcs12MacOptions, type Pkcs7CertBagMaterial, type Pkcs7CertificateSource, type Pkcs7SignedDataMaterial, type Pkcs7Signer, type PolicyConstraints, type PolicyInformation, type PolicyMapping, type PolicyMappings, type PolicyQualifierInfo, type PolicyValidationInput, type PolicyValidationOutcome, type PrivateKeyImportInput, type PublicKeyImportInput, REVOCATION_INDETERMINATE_REASONS, REVOCATION_INDETERMINATE_REASON_CODES, type RelativeDistinguishedNameInput, type ResolveOcspResponderCandidatesInput, type Result, type ResultError, type RevocationCertificateSource, type RevocationCheckGoodValue, type RevocationCheckIndeterminateValue, type RevocationCheckRevokedValue, type RevocationCrlEvidenceInput, type RevocationEvidenceInput, type RevocationEvidenceKind, type RevocationExecutionError, type RevocationIndeterminateEvidence, type RevocationIndeterminateReason, type RevocationIndeterminateReasonCode, type RevocationOcspEvidenceInput, type RevocationPolicy, type RevocationReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaOaepOptions, type RsaScheme, type RsaSignatureScheme, type SelfSignedCertificateResult, type ServiceIdentityInput, type ServiceIdentityType, type SplitPemBlocksResult, type SrvServiceIdentityInput, type SubjectAltName, type TrustAnchor, type UriServiceIdentityInput, VERIFY_ERROR_CODES, type ValidateCandidatePathInput, type ValidateCandidatePathResult, type ValidateCandidatePathSuccess, type ValidateCertificateRevocationListFailure, type ValidateCertificateRevocationListInput, type ValidateCertificateRevocationListResult, type ValidateForCaInput, type ValidateForCodeSigningInput, type ValidateForTlsClientInput, type ValidateForTlsServerInput, type ValidateOcspResponseErrorCode, type ValidateOcspResponseFailure, type ValidateOcspResponseInput, type ValidateOcspResponseResult, type ValidityInput, type VerifiedCertificateChain, type VerifyCertificateChainInput, type VerifyCertificateRevocationListSignatureFailure, type VerifyCertificateRevocationListSignatureResult, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyOcspResponseSignatureFailure, type VerifyOcspResponseSignatureResult, type VerifyPkcs7SignedDataFailure, type VerifyPkcs7SignedDataResult, type VerifyPurpose, type VerifyRequestFailure, type VerifyRequestResult, buildCandidatePath, categorizePemBlocks, categorizePemBlocksOrThrow, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, decryptRsaOaep, decryptRsaOaepOrThrow, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, getSubjectPublicKey, getSubjectPublicKeyOrThrow, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow, isCertificateRevoked, isResultError, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, resolveOcspResponderCandidates, splitPemBlocks, splitPemBlocksOrThrow, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isResultError, unwrap, unwrapOr } from "./result/result.js";
|
|
2
2
|
import { categorizePemBlocks, categorizePemBlocksOrThrow, pemDecode, pemDecodeOrThrow, pemEncode, splitPemBlocks, splitPemBlocksOrThrow } from "./pem/pem.js";
|
|
3
|
-
import { derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
|
|
3
|
+
import { decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
|
|
4
4
|
import { decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, findExtension, getSubjectPublicKey, getSubjectPublicKeyOrThrow, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow } from "./x509/parse.js";
|
|
5
5
|
import { createPfx, parsePfxDer, parsePfxPem } from "./pkcs/pfx.js";
|
|
6
6
|
import { createPkcs7CertBag, createPkcs7SignedData, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, verifyPkcs7SignedData } from "./pkcs/pkcs7.js";
|
|
@@ -12,4 +12,4 @@ import { createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOc
|
|
|
12
12
|
import { REVOCATION_INDETERMINATE_REASON_CODES, checkCertificateRevocation, getCertificateOcspResponderUris, resolveOcspResponderCandidates } from "./revocation/revocation.js";
|
|
13
13
|
import { createCertificate, createSelfSignedCertificate } from "./x509/certificate.js";
|
|
14
14
|
import { createCertificateSigningRequest } from "./x509/csr.js";
|
|
15
|
-
export { REVOCATION_INDETERMINATE_REASONS, REVOCATION_INDETERMINATE_REASON_CODES, VERIFY_ERROR_CODES, buildCandidatePath, categorizePemBlocks, categorizePemBlocksOrThrow, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, getSubjectPublicKey, getSubjectPublicKeyOrThrow, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow, isCertificateRevoked, isResultError, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, resolveOcspResponderCandidates, splitPemBlocks, splitPemBlocksOrThrow, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
|
|
15
|
+
export { REVOCATION_INDETERMINATE_REASONS, REVOCATION_INDETERMINATE_REASON_CODES, VERIFY_ERROR_CODES, buildCandidatePath, categorizePemBlocks, categorizePemBlocksOrThrow, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, decryptRsaOaep, decryptRsaOaepOrThrow, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, getSubjectPublicKey, getSubjectPublicKeyOrThrow, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow, isCertificateRevoked, isResultError, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, resolveOcspResponderCandidates, splitPemBlocks, splitPemBlocksOrThrow, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
|
package/dist/keys/keys.d.ts
CHANGED
|
@@ -4,7 +4,12 @@ import { ErrorResult, Micro509Error } from "../result/result.js";
|
|
|
4
4
|
/** Hash algorithm paired with an RSA key. */
|
|
5
5
|
type RsaHash = "SHA-256" | "SHA-384" | "SHA-512";
|
|
6
6
|
/** RSA signature padding scheme. */
|
|
7
|
-
type
|
|
7
|
+
type RsaSignatureScheme = "pkcs1-v1_5" | "pss";
|
|
8
|
+
/**
|
|
9
|
+
* RSA padding scheme: a signature scheme, or `'oaep'` for RSA-OAEP encryption
|
|
10
|
+
* keys (usable with {@linkcode encryptRsaOaep} / {@linkcode decryptRsaOaep}).
|
|
11
|
+
*/
|
|
12
|
+
type RsaScheme = RsaSignatureScheme | "oaep";
|
|
8
13
|
/** NIST elliptic curve for ECDSA keys. */
|
|
9
14
|
type EcNamedCurve = "P-256" | "P-384" | "P-521";
|
|
10
15
|
/** RSA variant of {@linkcode KeyAlgorithmInput}. */
|
|
@@ -15,7 +20,10 @@ interface RsaKeyAlgorithmInput {
|
|
|
15
20
|
readonly modulusLength?: 2048 | 3072 | 4096;
|
|
16
21
|
/** Hash algorithm for the key. Defaults to `'SHA-256'`. */
|
|
17
22
|
readonly hash?: RsaHash;
|
|
18
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Padding scheme. Defaults to `'pkcs1-v1_5'`. Pass `'oaep'` to generate an
|
|
25
|
+
* RSA-OAEP encryption pair (`encrypt`/`decrypt` usages instead of `sign`/`verify`).
|
|
26
|
+
*/
|
|
19
27
|
readonly scheme?: RsaScheme;
|
|
20
28
|
}
|
|
21
29
|
/** ECDSA variant of {@linkcode KeyAlgorithmInput}. */
|
|
@@ -34,9 +42,9 @@ interface Ed25519KeyAlgorithmInput {
|
|
|
34
42
|
type KeyAlgorithmInput = RsaKeyAlgorithmInput | EcKeyAlgorithmInput | Ed25519KeyAlgorithmInput;
|
|
35
43
|
/** Key pair with convenience export helpers. Returned by {@linkcode generateKeyPair}. */
|
|
36
44
|
interface KeyPairMaterial {
|
|
37
|
-
/** The WebCrypto public key (extractable, `verify` usage). */
|
|
45
|
+
/** The WebCrypto public key (extractable, `verify` usage; `encrypt` for RSA-OAEP). */
|
|
38
46
|
readonly publicKey: CryptoKey;
|
|
39
|
-
/** The WebCrypto private key (extractable, `sign` usage). */
|
|
47
|
+
/** The WebCrypto private key (extractable, `sign` usage; `decrypt` for RSA-OAEP). */
|
|
40
48
|
readonly privateKey: CryptoKey;
|
|
41
49
|
/** Export the public key as DER-encoded SubjectPublicKeyInfo. */
|
|
42
50
|
exportSpkiDer(): Promise<Uint8Array>;
|
|
@@ -57,7 +65,10 @@ interface ImportRsaKeyInput {
|
|
|
57
65
|
readonly kind: "rsa";
|
|
58
66
|
/** Hash algorithm. Defaults to `'SHA-256'`. */
|
|
59
67
|
readonly hash?: RsaHash;
|
|
60
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Padding scheme. Defaults to `'pkcs1-v1_5'`. Pass `'oaep'` to import an
|
|
70
|
+
* RSA-OAEP encryption key (`encrypt`/`decrypt` usage instead of `verify`/`sign`).
|
|
71
|
+
*/
|
|
61
72
|
readonly scheme?: RsaScheme;
|
|
62
73
|
}
|
|
63
74
|
/** ECDSA variant of {@linkcode PublicKeyImportInput} / {@linkcode PrivateKeyImportInput}. */
|
|
@@ -140,14 +151,61 @@ type ImportEncryptedKeyResult<T> = {
|
|
|
140
151
|
readonly ok: true;
|
|
141
152
|
readonly value: T;
|
|
142
153
|
} | ErrorResult<ImportEncryptedKeyErrorCode, Record<never, never>, ImportEncryptedKeyFailure>;
|
|
154
|
+
/** Options shared by {@linkcode encryptRsaOaep} and {@linkcode decryptRsaOaep}. */
|
|
155
|
+
interface RsaOaepOptions {
|
|
156
|
+
/**
|
|
157
|
+
* Optional OAEP label bound to the ciphertext. Not encrypted, but decryption
|
|
158
|
+
* fails unless the exact same label is presented. Default: empty.
|
|
159
|
+
*/
|
|
160
|
+
readonly label?: Uint8Array;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Machine-readable failure reason for {@linkcode encryptRsaOaep}.
|
|
164
|
+
*
|
|
165
|
+
* `'invalid_key'` when the key is not an RSA-OAEP public key with `encrypt`
|
|
166
|
+
* usage; `'message_too_long'` when the plaintext exceeds the OAEP capacity of
|
|
167
|
+
* the key (modulus bytes − 2 × hash bytes − 2).
|
|
168
|
+
*/
|
|
169
|
+
type EncryptRsaOaepErrorCode = "invalid_key" | "message_too_long";
|
|
170
|
+
/** Structured failure payload for {@linkcode encryptRsaOaep}. */
|
|
171
|
+
interface EncryptRsaOaepFailure extends Micro509Error<EncryptRsaOaepErrorCode> {
|
|
172
|
+
/** Always `false` for failures. */
|
|
173
|
+
readonly ok: false;
|
|
174
|
+
}
|
|
175
|
+
/** Success-or-failure result returned by {@linkcode encryptRsaOaep}. */
|
|
176
|
+
type EncryptRsaOaepResult = {
|
|
177
|
+
readonly ok: true;
|
|
178
|
+
readonly value: Uint8Array;
|
|
179
|
+
} | ErrorResult<EncryptRsaOaepErrorCode, Record<never, never>, EncryptRsaOaepFailure>;
|
|
180
|
+
/**
|
|
181
|
+
* Machine-readable failure reason for {@linkcode decryptRsaOaep}.
|
|
182
|
+
*
|
|
183
|
+
* `'invalid_key'` when the key is not an RSA-OAEP private key with `decrypt`
|
|
184
|
+
* usage; `'decryption_failed'` for every ciphertext-level failure (wrong key,
|
|
185
|
+
* wrong label, tampered or truncated ciphertext) — OAEP deliberately does not
|
|
186
|
+
* reveal which.
|
|
187
|
+
*/
|
|
188
|
+
type DecryptRsaOaepErrorCode = "invalid_key" | "decryption_failed";
|
|
189
|
+
/** Structured failure payload for {@linkcode decryptRsaOaep}. */
|
|
190
|
+
interface DecryptRsaOaepFailure extends Micro509Error<DecryptRsaOaepErrorCode> {
|
|
191
|
+
/** Always `false` for failures. */
|
|
192
|
+
readonly ok: false;
|
|
193
|
+
}
|
|
194
|
+
/** Success-or-failure result returned by {@linkcode decryptRsaOaep}. */
|
|
195
|
+
type DecryptRsaOaepResult = {
|
|
196
|
+
readonly ok: true;
|
|
197
|
+
readonly value: Uint8Array;
|
|
198
|
+
} | ErrorResult<DecryptRsaOaepErrorCode, Record<never, never>, DecryptRsaOaepFailure>;
|
|
143
199
|
/**
|
|
144
|
-
* Generate an asymmetric key pair for signing and verification
|
|
200
|
+
* Generate an asymmetric key pair for signing and verification, or — with
|
|
201
|
+
* `{ kind: 'rsa', scheme: 'oaep' }` — for RSA-OAEP encryption and decryption.
|
|
145
202
|
*
|
|
146
203
|
* @example
|
|
147
204
|
* ```ts
|
|
148
205
|
* const ecKeys = await generateKeyPair({ kind: 'ecdsa', curve: 'P-384' });
|
|
149
206
|
* const rsaKeys = await generateKeyPair({ kind: 'rsa', modulusLength: 4096 });
|
|
150
207
|
* const edKeys = await generateKeyPair({ kind: 'ed25519' });
|
|
208
|
+
* const oaepKeys = await generateKeyPair({ kind: 'rsa', scheme: 'oaep' });
|
|
151
209
|
*
|
|
152
210
|
* // Default: ECDSA P-256
|
|
153
211
|
* const keys = await generateKeyPair();
|
|
@@ -308,18 +366,19 @@ declare function exportSpkiPem(publicKey: CryptoKey): Promise<string>;
|
|
|
308
366
|
* Derive the matching public key from an imported (or generated) private key.
|
|
309
367
|
*
|
|
310
368
|
* The `import*` functions that read a PKCS#8 / PKCS#1 / SEC 1 / JWK private key
|
|
311
|
-
* return a bare `CryptoKey` with only `sign`
|
|
312
|
-
* public handle. This bridges that gap: it
|
|
313
|
-
* strips the private components, and re-imports
|
|
314
|
-
* usage, so callers can go
|
|
315
|
-
* {@linkcode exportSpkiPem} (e.g. to
|
|
316
|
-
*
|
|
369
|
+
* return a bare `CryptoKey` with only `sign` (or, for RSA-OAEP, `decrypt`)
|
|
370
|
+
* usage — there is no accompanying public handle. This bridges that gap: it
|
|
371
|
+
* exports the private key's JWK, strips the private components, and re-imports
|
|
372
|
+
* the public half with `verify` (RSA-OAEP: `encrypt`) usage, so callers can go
|
|
373
|
+
* straight to {@linkcode exportSpkiDer} / {@linkcode exportSpkiPem} (e.g. to
|
|
374
|
+
* rebuild a self-signed cert or distribute the public key when only the
|
|
375
|
+
* private key is on disk).
|
|
317
376
|
*
|
|
318
377
|
* Supports RSA (`n`/`e`), ECDSA (`x`/`y`), and Ed25519 (`x`). The derived key
|
|
319
378
|
* inherits the private key's algorithm parameters (hash, curve).
|
|
320
379
|
*
|
|
321
380
|
* @param privateKey - An extractable private `CryptoKey`
|
|
322
|
-
* @returns Extractable public `CryptoKey` with `verify` usage
|
|
381
|
+
* @returns Extractable public `CryptoKey` with `verify` (RSA-OAEP: `encrypt`) usage
|
|
323
382
|
*
|
|
324
383
|
* @throws {Error} If the key is not a private key, is non-extractable, or uses
|
|
325
384
|
* an unsupported key type
|
|
@@ -378,7 +437,7 @@ declare function importSpkiDer(der: Uint8Array, algorithm?: PublicKeyImportInput
|
|
|
378
437
|
* const pem = `-----BEGIN PUBLIC KEY-----
|
|
379
438
|
* MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...
|
|
380
439
|
* -----END PUBLIC KEY-----`;
|
|
381
|
-
* const key = await
|
|
440
|
+
* const key = await importSpkiPemOrThrow(pem, { kind: 'ecdsa', curve: 'P-256' });
|
|
382
441
|
* ```
|
|
383
442
|
*
|
|
384
443
|
* @see {@linkcode exportSpkiPem} for the inverse operation
|
|
@@ -428,7 +487,7 @@ declare function importPkcs8Der(der: Uint8Array, algorithm: PrivateKeyImportInpu
|
|
|
428
487
|
*
|
|
429
488
|
* @example
|
|
430
489
|
* ```ts
|
|
431
|
-
* const key = await
|
|
490
|
+
* const key = await importPkcs8PemOrThrow(pemString, { kind: 'ecdsa', curve: 'P-256' });
|
|
432
491
|
* ```
|
|
433
492
|
*/
|
|
434
493
|
declare function importPkcs8PemOrThrow(pem: string, algorithm: PrivateKeyImportInput): Promise<CryptoKey>;
|
|
@@ -463,7 +522,7 @@ declare function importEncryptedPkcs8Der(der: Uint8Array, password: string, algo
|
|
|
463
522
|
*
|
|
464
523
|
* @example
|
|
465
524
|
* ```ts
|
|
466
|
-
* const key = await
|
|
525
|
+
* const key = await importEncryptedPkcs8PemOrThrow(pem, 'secret', { kind: 'rsa' });
|
|
467
526
|
* ```
|
|
468
527
|
*/
|
|
469
528
|
declare function importEncryptedPkcs8PemOrThrow(pem: string, password: string, algorithm: PrivateKeyImportInput): Promise<CryptoKey>;
|
|
@@ -611,7 +670,7 @@ declare function importPublicJwk(jwk: JsonWebKey, algorithm: PublicKeyImportInpu
|
|
|
611
670
|
* @example
|
|
612
671
|
* ```ts
|
|
613
672
|
* const jwk = { kty: 'EC', crv: 'P-256', x: '...', y: '...', d: '...' };
|
|
614
|
-
* const key = await
|
|
673
|
+
* const key = await importPrivateJwkOrThrow(jwk, { kind: 'ecdsa', curve: 'P-256' });
|
|
615
674
|
* ```
|
|
616
675
|
*
|
|
617
676
|
* @see {@linkcode exportPrivateJwk} for the inverse operation
|
|
@@ -623,5 +682,89 @@ declare function importPrivateJwkOrThrow(jwk: JsonWebKey, algorithm: PrivateKeyI
|
|
|
623
682
|
* @see `importPrivateJwkOrThrow` for the throwing variant
|
|
624
683
|
*/
|
|
625
684
|
declare function importPrivateJwk(jwk: JsonWebKey, algorithm: PrivateKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
|
|
685
|
+
/**
|
|
686
|
+
* Encrypt a small message with an RSA-OAEP public key.
|
|
687
|
+
*
|
|
688
|
+
* The key must have been generated or imported with `{ kind: 'rsa', scheme: 'oaep' }`.
|
|
689
|
+
* RSA-OAEP encrypts at most modulus bytes − 2 × hash bytes − 2 per call
|
|
690
|
+
* (190 bytes for a 2048-bit key with SHA-256) — encrypt a symmetric key, not
|
|
691
|
+
* bulk data.
|
|
692
|
+
*
|
|
693
|
+
* @param publicKey - RSA-OAEP public `CryptoKey` with `encrypt` usage
|
|
694
|
+
* @param plaintext - Message bytes, at most the OAEP capacity of the key
|
|
695
|
+
* @param options - Optional OAEP label bound to the ciphertext
|
|
696
|
+
*
|
|
697
|
+
* @throws {Error} If the key is not an RSA-OAEP public encryption key, or the
|
|
698
|
+
* plaintext exceeds the key's OAEP capacity
|
|
699
|
+
*
|
|
700
|
+
* @example
|
|
701
|
+
* ```ts
|
|
702
|
+
* const keys = await generateKeyPair({ kind: 'rsa', scheme: 'oaep' });
|
|
703
|
+
* const ciphertext = await encryptRsaOaepOrThrow(
|
|
704
|
+
* keys.publicKey,
|
|
705
|
+
* new TextEncoder().encode('session key'),
|
|
706
|
+
* );
|
|
707
|
+
* ```
|
|
708
|
+
*
|
|
709
|
+
* @see {@linkcode decryptRsaOaepOrThrow} for the inverse operation
|
|
710
|
+
* @see `encryptRsaOaep` for the Result-returning variant
|
|
711
|
+
*/
|
|
712
|
+
declare function encryptRsaOaepOrThrow(publicKey: CryptoKey, plaintext: Uint8Array, options?: RsaOaepOptions): Promise<Uint8Array>;
|
|
713
|
+
/**
|
|
714
|
+
* Encrypt a small message with an RSA-OAEP public key.
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* ```ts
|
|
718
|
+
* const keys = await generateKeyPair({ kind: 'rsa', scheme: 'oaep' });
|
|
719
|
+
* const encrypted = await encryptRsaOaep(keys.publicKey, plaintext);
|
|
720
|
+
* if (!encrypted.ok) {
|
|
721
|
+
* // encrypted.code: 'invalid_key' | 'message_too_long'
|
|
722
|
+
* throw new Error(encrypted.message);
|
|
723
|
+
* }
|
|
724
|
+
* const ciphertext = encrypted.value;
|
|
725
|
+
* ```
|
|
726
|
+
*
|
|
727
|
+
* @see `encryptRsaOaepOrThrow` for the throwing variant
|
|
728
|
+
*/
|
|
729
|
+
declare function encryptRsaOaep(publicKey: CryptoKey, plaintext: Uint8Array, options?: RsaOaepOptions): Promise<EncryptRsaOaepResult>;
|
|
730
|
+
/**
|
|
731
|
+
* Decrypt an RSA-OAEP ciphertext with the matching private key.
|
|
732
|
+
*
|
|
733
|
+
* The key must have been generated or imported with `{ kind: 'rsa', scheme: 'oaep' }`,
|
|
734
|
+
* and `options.label` must repeat the label used at encryption time (if any).
|
|
735
|
+
*
|
|
736
|
+
* @param privateKey - RSA-OAEP private `CryptoKey` with `decrypt` usage
|
|
737
|
+
* @param ciphertext - Ciphertext produced by {@linkcode encryptRsaOaep} (or any RSA-OAEP encryptor)
|
|
738
|
+
* @param options - OAEP label matching the one bound at encryption
|
|
739
|
+
*
|
|
740
|
+
* @throws {Error} If the key is not an RSA-OAEP private decryption key, or
|
|
741
|
+
* decryption fails — wrong key, wrong label, or corrupted ciphertext (OAEP
|
|
742
|
+
* deliberately does not reveal which)
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```ts
|
|
746
|
+
* const plaintext = await decryptRsaOaepOrThrow(keys.privateKey, ciphertext);
|
|
747
|
+
* ```
|
|
748
|
+
*
|
|
749
|
+
* @see {@linkcode encryptRsaOaepOrThrow} for the inverse operation
|
|
750
|
+
* @see `decryptRsaOaep` for the Result-returning variant
|
|
751
|
+
*/
|
|
752
|
+
declare function decryptRsaOaepOrThrow(privateKey: CryptoKey, ciphertext: Uint8Array, options?: RsaOaepOptions): Promise<Uint8Array>;
|
|
753
|
+
/**
|
|
754
|
+
* Decrypt an RSA-OAEP ciphertext with the matching private key.
|
|
755
|
+
*
|
|
756
|
+
* @example
|
|
757
|
+
* ```ts
|
|
758
|
+
* const decrypted = await decryptRsaOaep(keys.privateKey, ciphertext);
|
|
759
|
+
* if (!decrypted.ok) {
|
|
760
|
+
* // decrypted.code: 'invalid_key' | 'decryption_failed'
|
|
761
|
+
* throw new Error(decrypted.message);
|
|
762
|
+
* }
|
|
763
|
+
* const plaintext = decrypted.value;
|
|
764
|
+
* ```
|
|
765
|
+
*
|
|
766
|
+
* @see `decryptRsaOaepOrThrow` for the throwing variant
|
|
767
|
+
*/
|
|
768
|
+
declare function decryptRsaOaep(privateKey: CryptoKey, ciphertext: Uint8Array, options?: RsaOaepOptions): Promise<DecryptRsaOaepResult>;
|
|
626
769
|
//#endregion
|
|
627
|
-
export { EcKeyAlgorithmInput, EcNamedCurve, Ed25519KeyAlgorithmInput, EncryptedPkcs8Options, ImportEcKeyInput, ImportEd25519KeyInput, ImportEncryptedKeyErrorCode, ImportEncryptedKeyFailure, ImportEncryptedKeyResult, ImportKeyErrorCode, ImportKeyFailure, ImportKeyResult, ImportRsaKeyInput, KeyAlgorithmInput, KeyPairMaterial, LegacyPemEncryptionOptions, PrivateKeyImportInput, PublicKeyImportInput, RsaHash, RsaKeyAlgorithmInput, RsaScheme, derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow };
|
|
770
|
+
export { DecryptRsaOaepErrorCode, DecryptRsaOaepFailure, DecryptRsaOaepResult, EcKeyAlgorithmInput, EcNamedCurve, Ed25519KeyAlgorithmInput, EncryptRsaOaepErrorCode, EncryptRsaOaepFailure, EncryptRsaOaepResult, EncryptedPkcs8Options, ImportEcKeyInput, ImportEd25519KeyInput, ImportEncryptedKeyErrorCode, ImportEncryptedKeyFailure, ImportEncryptedKeyResult, ImportKeyErrorCode, ImportKeyFailure, ImportKeyResult, ImportRsaKeyInput, KeyAlgorithmInput, KeyPairMaterial, LegacyPemEncryptionOptions, PrivateKeyImportInput, PublicKeyImportInput, RsaHash, RsaKeyAlgorithmInput, RsaOaepOptions, RsaScheme, RsaSignatureScheme, decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow };
|
package/dist/keys/keys.js
CHANGED
|
@@ -11,31 +11,34 @@ import { pemDecodeOrThrow, pemEncode } from "../pem/pem.js";
|
|
|
11
11
|
/**
|
|
12
12
|
* WebCrypto key generation plus import/export for PKCS#1, PKCS#8, SEC1, SPKI, and JWK.
|
|
13
13
|
*
|
|
14
|
-
* Supports RSA (PKCS#1v1.5 and
|
|
14
|
+
* Supports RSA (PKCS#1v1.5, PSS, and OAEP), ECDSA (P-256, P-384, P-521), and Ed25519 keys.
|
|
15
15
|
* All functions use the WebCrypto API and return extractable keys.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
|
19
|
-
* import {
|
|
19
|
+
* import { unwrap } from 'micro509';
|
|
20
|
+
* import { generateKeyPair, exportSpkiPem, importSpkiPem } from 'micro509/keys';
|
|
20
21
|
*
|
|
21
22
|
* // Generate and export
|
|
22
23
|
* const keys = await generateKeyPair({ kind: 'ecdsa', curve: 'P-256' });
|
|
23
|
-
* const
|
|
24
|
+
* const publicPem = await exportSpkiPem(keys.publicKey);
|
|
24
25
|
*
|
|
25
|
-
* // Import
|
|
26
|
-
* const publicKey = await importSpkiPem(publicPem, { kind: 'ecdsa', curve: 'P-256' });
|
|
26
|
+
* // Import — Result-returning; unwrap() throws on failure
|
|
27
|
+
* const publicKey = unwrap(await importSpkiPem(publicPem, { kind: 'ecdsa', curve: 'P-256' }));
|
|
27
28
|
* ```
|
|
28
29
|
*
|
|
29
30
|
* @module
|
|
30
31
|
*/
|
|
31
32
|
/**
|
|
32
|
-
* Generate an asymmetric key pair for signing and verification
|
|
33
|
+
* Generate an asymmetric key pair for signing and verification, or — with
|
|
34
|
+
* `{ kind: 'rsa', scheme: 'oaep' }` — for RSA-OAEP encryption and decryption.
|
|
33
35
|
*
|
|
34
36
|
* @example
|
|
35
37
|
* ```ts
|
|
36
38
|
* const ecKeys = await generateKeyPair({ kind: 'ecdsa', curve: 'P-384' });
|
|
37
39
|
* const rsaKeys = await generateKeyPair({ kind: 'rsa', modulusLength: 4096 });
|
|
38
40
|
* const edKeys = await generateKeyPair({ kind: 'ed25519' });
|
|
41
|
+
* const oaepKeys = await generateKeyPair({ kind: 'rsa', scheme: 'oaep' });
|
|
39
42
|
*
|
|
40
43
|
* // Default: ECDSA P-256
|
|
41
44
|
* const keys = await generateKeyPair();
|
|
@@ -46,7 +49,9 @@ async function generateKeyPair(algorithm = {
|
|
|
46
49
|
kind: "ecdsa",
|
|
47
50
|
curve: "P-256"
|
|
48
51
|
}) {
|
|
49
|
-
const
|
|
52
|
+
const subtle = getCrypto().subtle;
|
|
53
|
+
const usages = isRsaOaepInput(algorithm) ? ["encrypt", "decrypt"] : ["sign", "verify"];
|
|
54
|
+
const generated = await subtle.generateKey(toGenerateKeyAlgorithm(algorithm), true, usages);
|
|
50
55
|
if (!("publicKey" in generated) || !("privateKey" in generated)) throw new Error("Expected an asymmetric key pair");
|
|
51
56
|
return wrapKeyPair(generated.publicKey, generated.privateKey);
|
|
52
57
|
}
|
|
@@ -260,18 +265,19 @@ async function exportSpkiPem(publicKey) {
|
|
|
260
265
|
* Derive the matching public key from an imported (or generated) private key.
|
|
261
266
|
*
|
|
262
267
|
* The `import*` functions that read a PKCS#8 / PKCS#1 / SEC 1 / JWK private key
|
|
263
|
-
* return a bare `CryptoKey` with only `sign`
|
|
264
|
-
* public handle. This bridges that gap: it
|
|
265
|
-
* strips the private components, and re-imports
|
|
266
|
-
* usage, so callers can go
|
|
267
|
-
* {@linkcode exportSpkiPem} (e.g. to
|
|
268
|
-
*
|
|
268
|
+
* return a bare `CryptoKey` with only `sign` (or, for RSA-OAEP, `decrypt`)
|
|
269
|
+
* usage — there is no accompanying public handle. This bridges that gap: it
|
|
270
|
+
* exports the private key's JWK, strips the private components, and re-imports
|
|
271
|
+
* the public half with `verify` (RSA-OAEP: `encrypt`) usage, so callers can go
|
|
272
|
+
* straight to {@linkcode exportSpkiDer} / {@linkcode exportSpkiPem} (e.g. to
|
|
273
|
+
* rebuild a self-signed cert or distribute the public key when only the
|
|
274
|
+
* private key is on disk).
|
|
269
275
|
*
|
|
270
276
|
* Supports RSA (`n`/`e`), ECDSA (`x`/`y`), and Ed25519 (`x`). The derived key
|
|
271
277
|
* inherits the private key's algorithm parameters (hash, curve).
|
|
272
278
|
*
|
|
273
279
|
* @param privateKey - An extractable private `CryptoKey`
|
|
274
|
-
* @returns Extractable public `CryptoKey` with `verify` usage
|
|
280
|
+
* @returns Extractable public `CryptoKey` with `verify` (RSA-OAEP: `encrypt`) usage
|
|
275
281
|
*
|
|
276
282
|
* @throws {Error} If the key is not a private key, is non-extractable, or uses
|
|
277
283
|
* an unsupported key type
|
|
@@ -289,8 +295,9 @@ async function derivePublicKey(privateKey) {
|
|
|
289
295
|
if (privateKey.type !== "private") throw new Error("derivePublicKey requires a private CryptoKey");
|
|
290
296
|
if (!privateKey.extractable) throw new Error("Cannot derive public key from a non-extractable private key");
|
|
291
297
|
const subtle = getCrypto().subtle;
|
|
298
|
+
const usage = privateKey.algorithm.name === "RSA-OAEP" ? "encrypt" : "verify";
|
|
292
299
|
const privateJwk = await subtle.exportKey("jwk", privateKey);
|
|
293
|
-
return subtle.importKey("jwk", toPublicJwk(privateJwk), privateKey.algorithm, true, [
|
|
300
|
+
return subtle.importKey("jwk", toPublicJwk(privateJwk, usage), privateKey.algorithm, true, [usage]);
|
|
294
301
|
}
|
|
295
302
|
/**
|
|
296
303
|
* Export a key as raw base64 (no PEM headers).
|
|
@@ -334,7 +341,7 @@ async function importSpkiDerOrThrow(der, algorithm) {
|
|
|
334
341
|
importInput = algorithm;
|
|
335
342
|
}
|
|
336
343
|
try {
|
|
337
|
-
return await getCrypto().subtle.importKey("spki", new Uint8Array(der), toImportAlgorithm(importInput), true,
|
|
344
|
+
return await getCrypto().subtle.importKey("spki", new Uint8Array(der), toImportAlgorithm(importInput), true, publicKeyUsages(importInput));
|
|
338
345
|
} catch {
|
|
339
346
|
throw new Error("Malformed SubjectPublicKeyInfo");
|
|
340
347
|
}
|
|
@@ -374,7 +381,7 @@ function importSpkiDer(der, algorithm) {
|
|
|
374
381
|
* const pem = `-----BEGIN PUBLIC KEY-----
|
|
375
382
|
* MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...
|
|
376
383
|
* -----END PUBLIC KEY-----`;
|
|
377
|
-
* const key = await
|
|
384
|
+
* const key = await importSpkiPemOrThrow(pem, { kind: 'ecdsa', curve: 'P-256' });
|
|
378
385
|
* ```
|
|
379
386
|
*
|
|
380
387
|
* @see {@linkcode exportSpkiPem} for the inverse operation
|
|
@@ -435,7 +442,7 @@ async function importPkcs8DerOrThrow(der, algorithm) {
|
|
|
435
442
|
}
|
|
436
443
|
assertPkcs8MatchesRequestedAlgorithm(parsedPrivateKey, algorithm);
|
|
437
444
|
try {
|
|
438
|
-
return await getCrypto().subtle.importKey("pkcs8", new Uint8Array(der), toImportAlgorithm(algorithm), true,
|
|
445
|
+
return await getCrypto().subtle.importKey("pkcs8", new Uint8Array(der), toImportAlgorithm(algorithm), true, privateKeyUsages(algorithm));
|
|
439
446
|
} catch {
|
|
440
447
|
throw new Error("Malformed PKCS#8 private key");
|
|
441
448
|
}
|
|
@@ -453,7 +460,7 @@ function importPkcs8Der(der, algorithm) {
|
|
|
453
460
|
*
|
|
454
461
|
* @example
|
|
455
462
|
* ```ts
|
|
456
|
-
* const key = await
|
|
463
|
+
* const key = await importPkcs8PemOrThrow(pemString, { kind: 'ecdsa', curve: 'P-256' });
|
|
457
464
|
* ```
|
|
458
465
|
*/
|
|
459
466
|
function importPkcs8PemOrThrow(pem, algorithm) {
|
|
@@ -511,7 +518,7 @@ function importEncryptedPkcs8Der(der, password, algorithm) {
|
|
|
511
518
|
*
|
|
512
519
|
* @example
|
|
513
520
|
* ```ts
|
|
514
|
-
* const key = await
|
|
521
|
+
* const key = await importEncryptedPkcs8PemOrThrow(pem, 'secret', { kind: 'rsa' });
|
|
515
522
|
* ```
|
|
516
523
|
*/
|
|
517
524
|
function importEncryptedPkcs8PemOrThrow(pem, password, algorithm) {
|
|
@@ -688,7 +695,7 @@ function importEncryptedSec1Pem(pem, password, algorithm) {
|
|
|
688
695
|
async function importPublicJwkOrThrow(jwk, algorithm) {
|
|
689
696
|
assertPublicJwkMatchesRequestedAlgorithm(jwk, algorithm);
|
|
690
697
|
try {
|
|
691
|
-
return await getCrypto().subtle.importKey("jwk", jwk, toImportAlgorithm(algorithm), true,
|
|
698
|
+
return await getCrypto().subtle.importKey("jwk", jwk, toImportAlgorithm(algorithm), true, publicKeyUsages(algorithm));
|
|
692
699
|
} catch {
|
|
693
700
|
throw new Error("Malformed public JWK");
|
|
694
701
|
}
|
|
@@ -713,7 +720,7 @@ function importPublicJwk(jwk, algorithm) {
|
|
|
713
720
|
* @example
|
|
714
721
|
* ```ts
|
|
715
722
|
* const jwk = { kty: 'EC', crv: 'P-256', x: '...', y: '...', d: '...' };
|
|
716
|
-
* const key = await
|
|
723
|
+
* const key = await importPrivateJwkOrThrow(jwk, { kind: 'ecdsa', curve: 'P-256' });
|
|
717
724
|
* ```
|
|
718
725
|
*
|
|
719
726
|
* @see {@linkcode exportPrivateJwk} for the inverse operation
|
|
@@ -721,7 +728,7 @@ function importPublicJwk(jwk, algorithm) {
|
|
|
721
728
|
async function importPrivateJwkOrThrow(jwk, algorithm) {
|
|
722
729
|
assertPrivateJwkMatchesRequestedAlgorithm(jwk, algorithm);
|
|
723
730
|
try {
|
|
724
|
-
return await getCrypto().subtle.importKey("jwk", jwk, toImportAlgorithm(algorithm), true,
|
|
731
|
+
return await getCrypto().subtle.importKey("jwk", jwk, toImportAlgorithm(algorithm), true, privateKeyUsages(algorithm));
|
|
725
732
|
} catch {
|
|
726
733
|
throw new Error("Malformed private JWK");
|
|
727
734
|
}
|
|
@@ -734,6 +741,126 @@ async function importPrivateJwkOrThrow(jwk, algorithm) {
|
|
|
734
741
|
function importPrivateJwk(jwk, algorithm) {
|
|
735
742
|
return importResult(() => importPrivateJwkOrThrow(jwk, algorithm));
|
|
736
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* Encrypt a small message with an RSA-OAEP public key.
|
|
746
|
+
*
|
|
747
|
+
* The key must have been generated or imported with `{ kind: 'rsa', scheme: 'oaep' }`.
|
|
748
|
+
* RSA-OAEP encrypts at most modulus bytes − 2 × hash bytes − 2 per call
|
|
749
|
+
* (190 bytes for a 2048-bit key with SHA-256) — encrypt a symmetric key, not
|
|
750
|
+
* bulk data.
|
|
751
|
+
*
|
|
752
|
+
* @param publicKey - RSA-OAEP public `CryptoKey` with `encrypt` usage
|
|
753
|
+
* @param plaintext - Message bytes, at most the OAEP capacity of the key
|
|
754
|
+
* @param options - Optional OAEP label bound to the ciphertext
|
|
755
|
+
*
|
|
756
|
+
* @throws {Error} If the key is not an RSA-OAEP public encryption key, or the
|
|
757
|
+
* plaintext exceeds the key's OAEP capacity
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```ts
|
|
761
|
+
* const keys = await generateKeyPair({ kind: 'rsa', scheme: 'oaep' });
|
|
762
|
+
* const ciphertext = await encryptRsaOaepOrThrow(
|
|
763
|
+
* keys.publicKey,
|
|
764
|
+
* new TextEncoder().encode('session key'),
|
|
765
|
+
* );
|
|
766
|
+
* ```
|
|
767
|
+
*
|
|
768
|
+
* @see {@linkcode decryptRsaOaepOrThrow} for the inverse operation
|
|
769
|
+
* @see `encryptRsaOaep` for the Result-returning variant
|
|
770
|
+
*/
|
|
771
|
+
async function encryptRsaOaepOrThrow(publicKey, plaintext, options = {}) {
|
|
772
|
+
const keyProblem = validateRsaOaepKey(publicKey, "public", "encrypt");
|
|
773
|
+
if (keyProblem !== void 0) throw new Error(keyProblem);
|
|
774
|
+
try {
|
|
775
|
+
return new Uint8Array(await getCrypto().subtle.encrypt(toRsaOaepParams(options), publicKey, toArrayBuffer(plaintext)));
|
|
776
|
+
} catch (error) {
|
|
777
|
+
rethrowIfInvariant(error);
|
|
778
|
+
throw new Error("Plaintext exceeds the RSA-OAEP capacity of the key (modulus bytes − 2 × hash bytes − 2)");
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Encrypt a small message with an RSA-OAEP public key.
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* ```ts
|
|
786
|
+
* const keys = await generateKeyPair({ kind: 'rsa', scheme: 'oaep' });
|
|
787
|
+
* const encrypted = await encryptRsaOaep(keys.publicKey, plaintext);
|
|
788
|
+
* if (!encrypted.ok) {
|
|
789
|
+
* // encrypted.code: 'invalid_key' | 'message_too_long'
|
|
790
|
+
* throw new Error(encrypted.message);
|
|
791
|
+
* }
|
|
792
|
+
* const ciphertext = encrypted.value;
|
|
793
|
+
* ```
|
|
794
|
+
*
|
|
795
|
+
* @see `encryptRsaOaepOrThrow` for the throwing variant
|
|
796
|
+
*/
|
|
797
|
+
async function encryptRsaOaep(publicKey, plaintext, options = {}) {
|
|
798
|
+
const keyProblem = validateRsaOaepKey(publicKey, "public", "encrypt");
|
|
799
|
+
if (keyProblem !== void 0) return failureResult("invalid_key", keyProblem);
|
|
800
|
+
try {
|
|
801
|
+
return successResult(await encryptRsaOaepOrThrow(publicKey, plaintext, options));
|
|
802
|
+
} catch (error) {
|
|
803
|
+
rethrowIfInvariant(error);
|
|
804
|
+
return failureResult("message_too_long", error instanceof Error ? error.message : "Plaintext exceeds the RSA-OAEP capacity");
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Decrypt an RSA-OAEP ciphertext with the matching private key.
|
|
809
|
+
*
|
|
810
|
+
* The key must have been generated or imported with `{ kind: 'rsa', scheme: 'oaep' }`,
|
|
811
|
+
* and `options.label` must repeat the label used at encryption time (if any).
|
|
812
|
+
*
|
|
813
|
+
* @param privateKey - RSA-OAEP private `CryptoKey` with `decrypt` usage
|
|
814
|
+
* @param ciphertext - Ciphertext produced by {@linkcode encryptRsaOaep} (or any RSA-OAEP encryptor)
|
|
815
|
+
* @param options - OAEP label matching the one bound at encryption
|
|
816
|
+
*
|
|
817
|
+
* @throws {Error} If the key is not an RSA-OAEP private decryption key, or
|
|
818
|
+
* decryption fails — wrong key, wrong label, or corrupted ciphertext (OAEP
|
|
819
|
+
* deliberately does not reveal which)
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* ```ts
|
|
823
|
+
* const plaintext = await decryptRsaOaepOrThrow(keys.privateKey, ciphertext);
|
|
824
|
+
* ```
|
|
825
|
+
*
|
|
826
|
+
* @see {@linkcode encryptRsaOaepOrThrow} for the inverse operation
|
|
827
|
+
* @see `decryptRsaOaep` for the Result-returning variant
|
|
828
|
+
*/
|
|
829
|
+
async function decryptRsaOaepOrThrow(privateKey, ciphertext, options = {}) {
|
|
830
|
+
const keyProblem = validateRsaOaepKey(privateKey, "private", "decrypt");
|
|
831
|
+
if (keyProblem !== void 0) throw new Error(keyProblem);
|
|
832
|
+
try {
|
|
833
|
+
return new Uint8Array(await getCrypto().subtle.decrypt(toRsaOaepParams(options), privateKey, toArrayBuffer(ciphertext)));
|
|
834
|
+
} catch (error) {
|
|
835
|
+
rethrowIfInvariant(error);
|
|
836
|
+
throw new Error("RSA-OAEP decryption failed: wrong key, wrong label, or corrupted ciphertext");
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Decrypt an RSA-OAEP ciphertext with the matching private key.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```ts
|
|
844
|
+
* const decrypted = await decryptRsaOaep(keys.privateKey, ciphertext);
|
|
845
|
+
* if (!decrypted.ok) {
|
|
846
|
+
* // decrypted.code: 'invalid_key' | 'decryption_failed'
|
|
847
|
+
* throw new Error(decrypted.message);
|
|
848
|
+
* }
|
|
849
|
+
* const plaintext = decrypted.value;
|
|
850
|
+
* ```
|
|
851
|
+
*
|
|
852
|
+
* @see `decryptRsaOaepOrThrow` for the throwing variant
|
|
853
|
+
*/
|
|
854
|
+
async function decryptRsaOaep(privateKey, ciphertext, options = {}) {
|
|
855
|
+
const keyProblem = validateRsaOaepKey(privateKey, "private", "decrypt");
|
|
856
|
+
if (keyProblem !== void 0) return failureResult("invalid_key", keyProblem);
|
|
857
|
+
try {
|
|
858
|
+
return successResult(await decryptRsaOaepOrThrow(privateKey, ciphertext, options));
|
|
859
|
+
} catch (error) {
|
|
860
|
+
rethrowIfInvariant(error);
|
|
861
|
+
return failureResult("decryption_failed", error instanceof Error ? error.message : "RSA-OAEP decryption failed");
|
|
862
|
+
}
|
|
863
|
+
}
|
|
737
864
|
/** Map a {@linkcode KeyAlgorithmInput} to the WebCrypto `generateKey` algorithm parameter. */
|
|
738
865
|
function toGenerateKeyAlgorithm(algorithm) {
|
|
739
866
|
switch (algorithm.kind) {
|
|
@@ -819,7 +946,7 @@ function wrapSec1InPkcs8(der, curve) {
|
|
|
819
946
|
]);
|
|
820
947
|
}
|
|
821
948
|
/** Project a private JWK onto its public-only members, discarding private key material. */
|
|
822
|
-
function toPublicJwk(jwk) {
|
|
949
|
+
function toPublicJwk(jwk, usage) {
|
|
823
950
|
if (jwk.kty !== "RSA" && jwk.kty !== "EC" && jwk.kty !== "OKP") throw new Error(`Cannot derive public key: unsupported JWK key type ${String(jwk.kty)}`);
|
|
824
951
|
const publicJwk = { ...jwk };
|
|
825
952
|
for (const field of [
|
|
@@ -832,7 +959,7 @@ function toPublicJwk(jwk) {
|
|
|
832
959
|
"oth",
|
|
833
960
|
"k"
|
|
834
961
|
]) delete publicJwk[field];
|
|
835
|
-
publicJwk.key_ops = [
|
|
962
|
+
publicJwk.key_ops = [usage];
|
|
836
963
|
publicJwk.ext = true;
|
|
837
964
|
return publicJwk;
|
|
838
965
|
}
|
|
@@ -857,8 +984,41 @@ function oidToCurve(oid) {
|
|
|
857
984
|
/** Map an {@linkcode RsaScheme} to the WebCrypto algorithm name string. */
|
|
858
985
|
function rsaSchemeToWebCryptoAlgorithmName(scheme) {
|
|
859
986
|
if (scheme === "pss") return "RSA-PSS";
|
|
987
|
+
if (scheme === "oaep") return "RSA-OAEP";
|
|
860
988
|
return "RSASSA-PKCS1-v1_5";
|
|
861
989
|
}
|
|
990
|
+
/** `true` when the algorithm input selects RSA-OAEP, whose keys carry encrypt/decrypt usages. */
|
|
991
|
+
function isRsaOaepInput(algorithm) {
|
|
992
|
+
return algorithm.kind === "rsa" && algorithm.scheme === "oaep";
|
|
993
|
+
}
|
|
994
|
+
/** Key usages for an imported public key: `verify`, or `encrypt` for RSA-OAEP. */
|
|
995
|
+
function publicKeyUsages(algorithm) {
|
|
996
|
+
return isRsaOaepInput(algorithm) ? ["encrypt"] : ["verify"];
|
|
997
|
+
}
|
|
998
|
+
/** Key usages for an imported private key: `sign`, or `decrypt` for RSA-OAEP. */
|
|
999
|
+
function privateKeyUsages(algorithm) {
|
|
1000
|
+
return isRsaOaepInput(algorithm) ? ["decrypt"] : ["sign"];
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Diagnose a key unfit for the given RSA-OAEP operation.
|
|
1004
|
+
*
|
|
1005
|
+
* Returns a human-readable problem description, or `undefined` when the key is
|
|
1006
|
+
* usable — keeping key-level failures (`'invalid_key'`) separable from
|
|
1007
|
+
* ciphertext-level failures before WebCrypto is ever called.
|
|
1008
|
+
*/
|
|
1009
|
+
function validateRsaOaepKey(key, type, usage) {
|
|
1010
|
+
const operation = usage === "encrypt" ? "encryption" : "decryption";
|
|
1011
|
+
if (key.type !== type) return `RSA-OAEP ${operation} requires a ${type} CryptoKey`;
|
|
1012
|
+
if (key.algorithm.name !== "RSA-OAEP") return `RSA-OAEP ${operation} requires an RSA-OAEP key (got ${key.algorithm.name}); generate or import the key with scheme: 'oaep'`;
|
|
1013
|
+
if (!key.usages.includes(usage)) return `RSA-OAEP ${operation} requires a key with '${usage}' usage`;
|
|
1014
|
+
}
|
|
1015
|
+
/** Build the WebCrypto RSA-OAEP params, attaching the optional label. */
|
|
1016
|
+
function toRsaOaepParams(options) {
|
|
1017
|
+
return {
|
|
1018
|
+
name: "RSA-OAEP",
|
|
1019
|
+
...options.label === void 0 ? {} : { label: toArrayBuffer(options.label) }
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
862
1022
|
/** Encrypt DER key material as an OpenSSL-style `Proc-Type: 4,ENCRYPTED` PEM block. */
|
|
863
1023
|
async function encryptTraditionalPem(label, der, options) {
|
|
864
1024
|
const iv = options.iv ?? getCrypto().getRandomValues(/* @__PURE__ */ new Uint8Array(16));
|
|
@@ -1084,4 +1244,4 @@ function assertPrivateJwkMatchesRequestedAlgorithm(jwk, algorithm) {
|
|
|
1084
1244
|
}
|
|
1085
1245
|
}
|
|
1086
1246
|
//#endregion
|
|
1087
|
-
export { derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow };
|
|
1247
|
+
export { decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow };
|
package/dist/keys.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EcKeyAlgorithmInput, EcNamedCurve, Ed25519KeyAlgorithmInput, EncryptedPkcs8Options, ImportEcKeyInput, ImportEd25519KeyInput, ImportEncryptedKeyErrorCode, ImportEncryptedKeyFailure, ImportEncryptedKeyResult, ImportKeyErrorCode, ImportKeyFailure, ImportKeyResult, ImportRsaKeyInput, KeyAlgorithmInput, KeyPairMaterial, LegacyPemEncryptionOptions, PrivateKeyImportInput, PublicKeyImportInput, RsaHash, RsaKeyAlgorithmInput, RsaScheme, derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
|
|
2
|
-
export { type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EncryptedPkcs8Options, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyFailure, type ImportKeyResult, type ImportRsaKeyInput, type KeyAlgorithmInput, type KeyPairMaterial, type LegacyPemEncryptionOptions, type PrivateKeyImportInput, type PublicKeyImportInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaScheme, derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow };
|
|
1
|
+
import { DecryptRsaOaepErrorCode, DecryptRsaOaepFailure, DecryptRsaOaepResult, EcKeyAlgorithmInput, EcNamedCurve, Ed25519KeyAlgorithmInput, EncryptRsaOaepErrorCode, EncryptRsaOaepFailure, EncryptRsaOaepResult, EncryptedPkcs8Options, ImportEcKeyInput, ImportEd25519KeyInput, ImportEncryptedKeyErrorCode, ImportEncryptedKeyFailure, ImportEncryptedKeyResult, ImportKeyErrorCode, ImportKeyFailure, ImportKeyResult, ImportRsaKeyInput, KeyAlgorithmInput, KeyPairMaterial, LegacyPemEncryptionOptions, PrivateKeyImportInput, PublicKeyImportInput, RsaHash, RsaKeyAlgorithmInput, RsaOaepOptions, RsaScheme, RsaSignatureScheme, decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
|
|
2
|
+
export { type DecryptRsaOaepErrorCode, type DecryptRsaOaepFailure, type DecryptRsaOaepResult, type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EncryptRsaOaepErrorCode, type EncryptRsaOaepFailure, type EncryptRsaOaepResult, type EncryptedPkcs8Options, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyFailure, type ImportKeyResult, type ImportRsaKeyInput, type KeyAlgorithmInput, type KeyPairMaterial, type LegacyPemEncryptionOptions, type PrivateKeyImportInput, type PublicKeyImportInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaOaepOptions, type RsaScheme, type RsaSignatureScheme, decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow };
|
package/dist/keys.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
|
|
2
|
-
export { derivePublicKey, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow };
|
|
1
|
+
import { decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow } from "./keys/keys.js";
|
|
2
|
+
export { decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow };
|
|
@@ -329,9 +329,9 @@ declare function parseOcspResponseDerOrThrow(der: Uint8Array): ParsedOcspRespons
|
|
|
329
329
|
*
|
|
330
330
|
* @example
|
|
331
331
|
* ```ts
|
|
332
|
-
* import {
|
|
332
|
+
* import { parseOcspResponsePemOrThrow } from 'micro509';
|
|
333
333
|
*
|
|
334
|
-
* const resp =
|
|
334
|
+
* const resp = parseOcspResponsePemOrThrow(pemString);
|
|
335
335
|
* if (resp.responseStatus === 'successful') {
|
|
336
336
|
* for (const entry of resp.responses ?? []) {
|
|
337
337
|
* console.log(entry.certId.serialNumberHex, entry.certStatus);
|
package/dist/revocation/ocsp.js
CHANGED
|
@@ -190,9 +190,9 @@ function parseOcspResponseDerOrThrow(der) {
|
|
|
190
190
|
*
|
|
191
191
|
* @example
|
|
192
192
|
* ```ts
|
|
193
|
-
* import {
|
|
193
|
+
* import { parseOcspResponsePemOrThrow } from 'micro509';
|
|
194
194
|
*
|
|
195
|
-
* const resp =
|
|
195
|
+
* const resp = parseOcspResponsePemOrThrow(pemString);
|
|
196
196
|
* if (resp.responseStatus === 'successful') {
|
|
197
197
|
* for (const entry of resp.responses ?? []) {
|
|
198
198
|
* console.log(entry.certId.serialNumberHex, entry.certStatus);
|