node-opcua-crypto-web 5.5.0 → 5.6.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.
@@ -26,6 +26,42 @@ type PrivateKey = {
26
26
  hidden: KeyObject;
27
27
  };
28
28
  type PublicKey = KeyObject;
29
+ /**
30
+ * Thrown when a private key is encrypted (PKCS#8 `ENCRYPTED PRIVATE KEY`)
31
+ * and the caller did not supply a passphrase to decrypt it. Reading an
32
+ * encrypted key without a passphrase always fails closed — it never falls
33
+ * back to treating the key as unencrypted or skipping it.
34
+ */
35
+ declare class PrivateKeyPassphraseRequiredError extends Error {
36
+ constructor(message?: string);
37
+ }
38
+ /**
39
+ * PKCS#12 integrity check failed: the password is wrong, or the file has
40
+ * been corrupted or tampered with. Raised on a `MacData` HMAC mismatch and
41
+ * on a bag-decryption failure (both are the observable symptom of a wrong
42
+ * password; PKCS#12 does not let the two be distinguished reliably).
43
+ */
44
+ declare class PfxIntegrityError extends Error {
45
+ constructor(message?: string);
46
+ }
47
+ /**
48
+ * The PKCS#12 file parsed and (where applicable) decrypted correctly, but
49
+ * is not a bundle this API can represent — for example it carries no
50
+ * private key, or no certificate. Distinct from {@link PfxIntegrityError}:
51
+ * the password was fine; the content is what is missing or malformed.
52
+ */
53
+ declare class PfxMalformedError extends Error {
54
+ constructor(message: string);
55
+ }
56
+ /**
57
+ * The PKCS#12 file uses an encryption or digest algorithm this build does
58
+ * not implement (for example the legacy RC2-40 PBE scheme, which neither
59
+ * WebCrypto nor a default Node build exposes). Not a data error — the file
60
+ * may be perfectly valid; it just needs a capability this code lacks.
61
+ */
62
+ declare class Pkcs12UnsupportedAlgorithmError extends Error {
63
+ constructor(message: string);
64
+ }
29
65
  type Nonce = Buffer;
30
66
  type PEM = string;
31
67
  type DER = Buffer;
@@ -469,7 +505,15 @@ declare function verifyCertificateChain(certificateChain: Certificate[]): Promis
469
505
  reason: string;
470
506
  }>;
471
507
 
472
- declare function coercePEMorDerToPrivateKey(privateKeyInDerOrPem: string | Buffer): PrivateKey;
508
+ /**
509
+ * @param privateKeyInDerOrPem
510
+ * @param passphrase — required if the PEM is an encrypted PKCS#8 key
511
+ * (`-----BEGIN ENCRYPTED PRIVATE KEY-----`). Throws
512
+ * {@link PrivateKeyPassphraseRequiredError} if the key is encrypted and
513
+ * no passphrase is supplied. Unencrypted input is unaffected by this
514
+ * parameter.
515
+ */
516
+ declare function coercePEMorDerToPrivateKey(privateKeyInDerOrPem: string | Buffer, passphrase?: string | Buffer): PrivateKey;
473
517
  /**
474
518
  *
475
519
  * @private
@@ -698,4 +742,4 @@ declare const asn1: {
698
742
  readSignatureValueBin: typeof readSignatureValueBin;
699
743
  };
700
744
 
701
- export { type AttributeTypeAndValue, type AuthorityInformationAccess, type AuthorityKeyIdentifier, type BasicConstraints, type Certificate, type CertificateExtension, type CertificateInfo, type CertificateInternals, type CertificatePEM, CertificatePurpose, type CertificateRevocationList, type CertificateRevocationListInfo, type CertificateSerialNumber, type CertificateSigningRequestInfo, type ComputeDerivedKeysOptions, type CreateSelfSignCertificateOptions, type DER, type DERContentType, type DerivedKeys, type DirectoryName, type DistinguishedNameAttribute, type ExtensionRequest, type Extensions, type KeyObject, type Name, type Nonce, type PEM, PaddingAlgorithm, type PrivateKey, type PrivateKeyInternals, type PrivateKeyPEM, type PublicKey, type PublicKeyLength, type PublicKeyPEM, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, type RevokedCertificate, type Signature, Subject, type SubjectAltName, type SubjectOptions, type SubjectPublicKey, type SubjectPublicKeyInfo, type TBSCertList, type TbsCertificate, type Validity, type VerifyChunkSignatureOptions, type VerifyMessageChunkSignatureOptions, type Version, type X509ExtKeyUsage, type X509KeyUsage, type _VerifyStatus, _coercePrivateKey, asn1, certificateMatchesPrivateKey, clearExploreCertificateCache, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createPrivateKeyFromNodeJSCrypto, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreAsn1, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, generateKeyPair, generatePrivateKey, hexDump, identifyDERContent, identifyPemType, isCrlIssuedByCertificate, isKeyObject, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePrivateKeyThumbPrint, makePseudoRandomBuffer, makeSHA1Thumbprint, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readExtension, readNameForCrl, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyCrlIssuedByCertificate, verifyMessageChunkSignature, verify_certificate_der_structure };
745
+ export { type AttributeTypeAndValue, type AuthorityInformationAccess, type AuthorityKeyIdentifier, type BasicConstraints, type Certificate, type CertificateExtension, type CertificateInfo, type CertificateInternals, type CertificatePEM, CertificatePurpose, type CertificateRevocationList, type CertificateRevocationListInfo, type CertificateSerialNumber, type CertificateSigningRequestInfo, type ComputeDerivedKeysOptions, type CreateSelfSignCertificateOptions, type DER, type DERContentType, type DerivedKeys, type DirectoryName, type DistinguishedNameAttribute, type ExtensionRequest, type Extensions, type KeyExportOptions, type KeyObject, type Name, type Nonce, type PEM, PaddingAlgorithm, PfxIntegrityError, PfxMalformedError, Pkcs12UnsupportedAlgorithmError, type PrivateKey, type PrivateKeyInternals, type PrivateKeyPEM, PrivateKeyPassphraseRequiredError, type PublicKey, type PublicKeyLength, type PublicKeyPEM, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, type RevokedCertificate, type Signature, Subject, type SubjectAltName, type SubjectOptions, type SubjectPublicKey, type SubjectPublicKeyInfo, type TBSCertList, type TbsCertificate, type Validity, type VerifyChunkSignatureOptions, type VerifyMessageChunkSignatureOptions, type Version, type X509ExtKeyUsage, type X509KeyUsage, type _VerifyStatus, _coercePrivateKey, asn1, certificateMatchesPrivateKey, clearExploreCertificateCache, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createPrivateKeyFromNodeJSCrypto, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreAsn1, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, generateKeyPair, generatePrivateKey, hexDump, identifyDERContent, identifyPemType, isCrlIssuedByCertificate, isKeyObject, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePrivateKeyThumbPrint, makePseudoRandomBuffer, makeSHA1Thumbprint, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readExtension, readNameForCrl, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyCrlIssuedByCertificate, verifyMessageChunkSignature, verify_certificate_der_structure };