@stacksjs/tlsx
Version:
A TLS/HTTPS library with automation.
50 lines • 2.46 kB
TypeScript
import type { CertificateOptions } from './types';
/**
* Reads a certificate from a file.
* @param certPath - Path to the certificate file.
* @returns {string} - The certificate content.
*/
export declare function readCertFromFile(certPath: string): string;
/**
* Lists all certificates in a directory.
* By default, it returns the certificates stored in their default locations on each operating system.
* If no certificates are found in the default paths, it checks the fallback path.
* @param dirPath - Path to the directory. If not provided, the default directory for the OS will be used.
* @returns {string[]} - An array of certificate file paths.
*/
export declare function listCertsInDirectory(dirPath?: string): string[];
export declare function makeNumberPositive(hexString: string): string;
export declare function findFoldersWithFile(rootDir: string, fileName: string): string[];
export declare function debugLog(category: string, message: string, verbose?: boolean): void;
/**
* Executes a shell command and returns the result
* @param command - The shell command to execute
* @param options - Optional execution options
* @param options.cwd - The cwd
* @param options.timeout - The timeout, default: 30000 // 30s
* @returns Promise that resolves with stdout and stderr
* @throws Error if the command fails
*/
export declare function runCommand(command: string, options?: { cwd?: string, timeout?: number }): Promise<CommandResult>;
/**
* Gets the primary domain from options
* @param options Certificate generation options
* @throws Error if no domain is specified
* @returns Primary domain
*/
export declare function getPrimaryDomain(options: CertificateOptions): string;
/**
* Normalizes certificate paths based on basePath and defaults
* @param options Options that may contain file paths
* @param options.basePath Base directory for certificate files, defaults to config.basePath
* @param options.certPath Path to the certificate file, resolved against basePath if relative
* @param options.keyPath Path to the private key file, resolved against basePath if relative
* @param options.caCertPath Path to the CA certificate file, resolved against basePath if relative
* @returns Normalized file paths
*/
export declare function normalizeCertPaths(options: {
basePath?: string
certPath?: string
keyPath?: string
caCertPath?: string
}): { certPath: string, keyPath: string, caCertPath: string, basePath: string };