UNPKG

node-opcua-crypto

Version:
139 lines (132 loc) 5.95 kB
import { C as Certificate, K as KeyObject, P as PrivateKey, d as CertificatePEM, f as PublicKeyPEM, e as PrivateKeyPEM, a as PublicKey, g as CertificateRevocationList } from '../common-DxHkx4Pv.cjs'; import 'node:crypto'; declare function generatePrivateKeyFile(privateKeyFilename: string, modulusLength: 1024 | 2048 | 3072 | 4096): Promise<void>; /** * alternate function to generate PrivateKeyFile, using native * node:crypto. * * This function is slower than generatePrivateKeyFile */ declare function generatePrivateKeyFileAlternate(privateKeyFilename: string, modulusLength: 2048 | 3072 | 4096): Promise<void>; /** * Read a DER or PEM certificate from file. * * **Note:** If the PEM file contains multiple certificate blocks * (e.g. a leaf cert + CA chain), only the **first** certificate * is returned. Use {@link readCertificateChain} to read all * certificates individually. * * @deprecated Use {@link readCertificateChain} instead, which * returns each certificate as a separate DER buffer. */ declare function readCertificate(filename: string): Certificate; /** * Read a PEM or DER certificate file that may contain multiple * certificates (e.g. a leaf cert + CA issuer chain) and return * each certificate as a separate DER `Buffer`. * * - For a DER file, returns a single-element array. * - For a PEM file with N certificate blocks, returns N elements * in the same order they appear in the file (leaf first). */ declare function readCertificateChain(filename: string): Certificate[]; /** * Async version of {@link readCertificateChain}. */ declare function readCertificateChainAsync(filename: string): Promise<Certificate[]>; /** * Async version of {@link readCertificate}. * Uses `fs.promises.readFile` so the event loop is not blocked * during I/O. * * **Note:** If the PEM file contains multiple certificate blocks, * only the first is returned. Use {@link readCertificateChainAsync}. * * @deprecated Use {@link readCertificateChainAsync} instead. */ declare function readCertificateAsync(filename: string): Promise<Certificate>; /** * read a DER or PEM certificate from file */ declare function readPublicKey(filename: string): KeyObject; /** * Async version of {@link readPublicKey}. */ declare function readPublicKeyAsync(filename: string): Promise<KeyObject>; /** * read a DER or PEM certificate from file */ declare function readPrivateKey(filename: string): PrivateKey; /** * Async version of {@link readPrivateKey}. */ declare function readPrivateKeyAsync(filename: string): Promise<PrivateKey>; declare function readCertificatePEM(filename: string): CertificatePEM; /** * Async version of {@link readCertificatePEM}. */ declare function readCertificatePEMAsync(filename: string): Promise<CertificatePEM>; declare function readPublicKeyPEM(filename: string): PublicKeyPEM; /** * Async version of {@link readPublicKeyPEM}. */ declare function readPublicKeyPEMAsync(filename: string): Promise<PublicKeyPEM>; /** * * @deprecated */ declare function readPrivateKeyPEM(filename: string): PrivateKeyPEM; /** * Async version of {@link readPrivateKeyPEM}. * @deprecated */ declare function readPrivateKeyPEMAsync(filename: string): Promise<PrivateKeyPEM>; declare function setCertificateStore(store: string): string; declare function getCertificateStore(): string; /** * * @param filename */ declare function readPrivateRsaKey(filename: string): PrivateKey; declare function readPublicRsaKey(filename: string): PublicKey; declare function readCertificateRevocationList(filename: string): Promise<CertificateRevocationList>; type CertificateSigningRequest = Buffer; declare function readCertificateSigningRequest(filename: string): Promise<CertificateSigningRequest>; /** * Convert one or more DER certificates to a PEM string. * * Accepts a single `Certificate` (DER buffer) or an array. * Returns a multi-block PEM string with each certificate * separated by a newline. */ declare function certificatesToPem(certificates: Certificate | Certificate[]): string; /** * Write one or more DER certificates to a PEM file. * * Each certificate is written as a separate PEM block in the * order provided (typically leaf first, then issuer chain). */ declare function writeCertificateChain(filename: string, certificates: Certificate | Certificate[]): void; /** * Async version of {@link writeCertificateChain}. */ declare function writeCertificateChainAsync(filename: string, certificates: Certificate | Certificate[]): Promise<void>; /** * Convert one or more DER certificates to a single concatenated * DER buffer (OPC UA certificate chain format). * * Accepts a single `Certificate` (DER buffer) or an array. */ declare function certificatesToDer(certificates: Certificate | Certificate[]): Certificate; /** * Write one or more DER certificates to a `.der` file as a * concatenated DER chain (OPC UA binary chain format). * * Order should be leaf first, then issuer chain. */ declare function writeCertificateChainDer(filename: string, certificates: Certificate | Certificate[]): void; /** * Async version of {@link writeCertificateChainDer}. */ declare function writeCertificateChainDerAsync(filename: string, certificates: Certificate | Certificate[]): Promise<void>; export { type CertificateSigningRequest, certificatesToDer, certificatesToPem, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, readCertificate, readCertificateAsync, readCertificateChain, readCertificateChainAsync, readCertificatePEM, readCertificatePEMAsync, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyAsync, readPrivateKeyPEM, readPrivateKeyPEMAsync, readPrivateRsaKey, readPublicKey, readPublicKeyAsync, readPublicKeyPEM, readPublicKeyPEMAsync, readPublicRsaKey, setCertificateStore, writeCertificateChain, writeCertificateChainAsync, writeCertificateChainDer, writeCertificateChainDerAsync };