UNPKG

@stacksjs/tlsx

Version:

A TLS/HTTPS library with automation.

61 lines 2.75 kB
import crypto from 'node:crypto'; import type { CertDetails } from '../types'; /** * Gets a certificate from a PEM string or a path to a certificate file. * @param certPemOrPath - The certificate in PEM format or the path to the certificate file. * @returns The X509Certificate object. */ export declare function getCertificateFromCertPemOrPath(certPemOrPath: string): crypto.X509Certificate; /** * Checks if a certificate is valid for a given domain. * @param certPemOrPath - The certificate in PEM format or the path to the certificate file. * @param domain - The domain to check. * @returns True if the certificate is valid for the domain, false otherwise. */ export declare function isCertValidForDomain(certPemOrPath: string, domain: string): boolean; /** * Parses and extracts details from a certificate. * @param certPemOrPath - The certificate in PEM format or the path to the certificate file. * @returns An object containing certificate details. */ export declare function parseCertDetails(certPemOrPath: string): CertDetails; /** * Checks if a certificate is expired. * @param certPemOrPath - The certificate in PEM format or the path to the certificate file. * @returns True if the certificate is expired, false otherwise. */ export declare function isCertExpired(certPemOrPath: string): boolean; /** * Checks if a certificate will expire soon. * @param certPemOrPath - The certificate in PEM format or the path to the certificate file. * @param daysThreshold - Number of days to consider as "soon". Default is 30. * @returns True if the certificate will expire within the threshold, false otherwise. */ export declare function willCertExpireSoon(certPemOrPath: string, daysThreshold?: any): boolean; /** * Validate a certificate * @param certificatePath Path to the certificate file * @param caCertificatePath Path to the CA certificate file * @param verbose Enable verbose logging * @returns Certificate validation result */ export declare function validateCertificate(certificatePath: string, caCertificatePath?: string, verbose?: boolean): CertificateValidationResult; /** * Checks if a certificate is compatible with modern browsers * @param certificatePath Path to the certificate file * @param verbose Enable verbose logging * @returns Browser compatibility validation result with specific issues, if any */ export declare function validateBrowserCompatibility(certificatePath: string, verbose?: boolean): { compatible: boolean, issues: string[] }; export declare interface CertificateValidationResult { valid: boolean expired: boolean notYetValid: boolean issuerValid: boolean domains: string[] validFrom: Date validTo: Date issuer: string subject: string message?: string }