import * as fs from 'fs'; import * as path from 'path'; import type { IAcmeOptions } from '../models/certificate-types.js'; import { ensureCertificateDirectory } from '../utils/certificate-helpers.js'; // We'll need to update this import when we move the Port80Handler import { Port80Handler } from '../../http/port80/port80-handler.js'; /** * Factory to create a Port80Handler with common setup. * Ensures the certificate store directory exists and instantiates the handler. * @param options Port80Handler configuration options * @returns A new Port80Handler instance */ export function buildPort80Handler( options: IAcmeOptions ): Port80Handler { if (options.certificateStore) { ensureCertificateDirectory(options.certificateStore); console.log(`Ensured certificate store directory: ${options.certificateStore}`); } return new Port80Handler(options); } /** * Creates default ACME options with sensible defaults * @param email Account email for ACME provider * @param certificateStore Path to store certificates * @param useProduction Whether to use production ACME servers * @returns Configured ACME options */ export function createDefaultAcmeOptions( email: string, certificateStore: string, useProduction: boolean = false ): IAcmeOptions { return { accountEmail: email, enabled: true, port: 80, useProduction, httpsRedirectPort: 443, renewThresholdDays: 30, renewCheckIntervalHours: 24, autoRenew: true, certificateStore, skipConfiguredCerts: false }; }