/** * Represents the PEM encoded certificate, public key, and private key. */ export interface CertificatePem { cert: string; publicKey: string; privateKey: string; } /** * Represents the information extracted from a certificate. */ export interface CertificateInfo { hSerial: string; sIssuer: string; sSubject: string; sNotBefore: string; sNotAfter: string; issuedOn: Date; expiresOn: Date; } /** * Options for specifying the validity range of a certificate. */ export interface ValidityRangeOptions { validFrom?: Date; validTo?: Date; } /** * Manages the creation and parsing of certificates. */ export declare class CertificateManager { /** * Parses a PEM encoded certificate and extracts its information. * @param certPEM - The PEM encoded certificate string. * @returns An object containing the certificate information. * @example * const certificateManager = new CertificateManager(); * const pem = certificateManager.generatePEM('exampleAddress'); * const certInfo = certificateManager.parsePem(pem.cert); * console.log(certInfo); */ parsePem(certPEM: string): CertificateInfo; /** * Generates a PEM encoded certificate, public key, and private key. * @param address - The address to be used as the certificate's subject and issuer. * @param options - Optional validity range for the certificate. * @returns An object containing the PEM encoded certificate, public key, and private key. * @example * const certificateManager = new CertificateManager(); * const pem = certificateManager.generatePEM('exampleAddress'); * console.log('Certificate:', pem.cert); * console.log('Public Key:', pem.publicKey); * console.log('Private Key:', pem.privateKey); */ generatePEM(address: string, options?: ValidityRangeOptions): CertificatePem; /** * Creates a validity range for a certificate. * @param options - Optional validity range options. * @returns An object containing the notBefore and notAfter date strings. */ private createValidityRange; /** * Converts a Date object to a string in the format YYMMDDHHMMSSZ. * @param date - The date to convert. * @returns The formatted date string. * @example * const certificateManager = new CertificateManager(); * const dateStr = certificateManager.dateToStr(new Date('2024-05-07T12:23:50.000Z')); * console.log(dateStr); // "240507122350Z" */ private dateToStr; /** * Converts a string in the format YYMMDDHHMMSSZ to a Date object. * @param str - The string to convert. * @returns The corresponding Date object. * @example * const certificateManager = new CertificateManager(); * const date = certificateManager.strToDate("240507122350Z"); * console.log(date.toISOString()); // "2024-05-07T12:23:50.000Z" */ private strToDate; }