@push.rocks/smartproxy
Version:
A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.
78 lines (77 loc) • 2.5 kB
TypeScript
import * as plugins from '../plugins.js';
import { type INetworkProxyOptions, type ICertificateEntry } from './classes.np.types.js';
import { Port80Handler } from '../port80handler/classes.port80handler.js';
/**
* Manages SSL certificates for NetworkProxy including ACME integration
*/
export declare class CertificateManager {
private options;
private defaultCertificates;
private certificateCache;
private port80Handler;
private externalPort80Handler;
private certificateStoreDir;
private logger;
private httpsServer;
constructor(options: INetworkProxyOptions);
/**
* Loads default certificates from the filesystem
*/
loadDefaultCertificates(): void;
/**
* Set the HTTPS server reference for context updates
*/
setHttpsServer(server: plugins.https.Server): void;
/**
* Get default certificates
*/
getDefaultCertificates(): {
key: string;
cert: string;
};
/**
* Sets an external Port80Handler for certificate management
*/
setExternalPort80Handler(handler: Port80Handler): void;
/**
* Handle newly issued or renewed certificates from Port80Handler
*/
private handleCertificateIssued;
/**
* Handle certificate issuance failures
*/
private handleCertificateFailed;
/**
* Saves certificate and private key to the filesystem
*/
private saveCertificateToStore;
/**
* Handles SNI (Server Name Indication) for TLS connections
* Used by the HTTPS server to select the correct certificate for each domain
*/
handleSNI(domain: string, cb: (err: Error | null, ctx: plugins.tls.SecureContext) => void): void;
/**
* Updates certificate in cache
*/
updateCertificateCache(domain: string, certificate: string, privateKey: string, expiryDate?: Date): void;
/**
* Gets a certificate for a domain
*/
getCertificate(domain: string): ICertificateEntry | undefined;
/**
* Requests a new certificate for a domain
*/
requestCertificate(domain: string): Promise<boolean>;
/**
* Registers domains with Port80Handler for ACME certificate management
*/
registerDomainsWithPort80Handler(domains: string[]): void;
/**
* Initialize internal Port80Handler
*/
initializePort80Handler(): Promise<Port80Handler | null>;
/**
* Stop the Port80Handler if it was internally created
*/
stopPort80Handler(): Promise<void>;
}