2.5 KiB
2.5 KiB
Refactor: Introduce a Unified CertProvisioner for Certificate Lifecycle
-
Ensure Port80Handler is challenge-only:
- Remove any internal scheduling and deprecated ACME flows (
getAcmeClient,processAuthorizations,handleAcmeChallenge) from Port80Handler. - Remove legacy ACME options (
renewThresholdDays,renewCheckIntervalHours,mongoDescriptor, etc.) fromIPort80HandlerOptions. - Retain only methods for HTTP-01 challenge and direct renewals (
obtainCertificate,renewCertificate,getDomainCertificateStatus).
- Remove any internal scheduling and deprecated ACME flows (
-
Clean up deprecated
acmeconfiguration:- Remove the
acmeproperty fromIPortProxySettingsand all legacy references in code.
- Remove the
-
Implement
CertProvisionercomponent:- Create class
ts/smartproxy/classes.pp.certprovisioner.ts. - Constructor accepts:
domainConfigs: IDomainConfig[]port80Handler: Port80HandlernetworkProxyBridge: NetworkProxyBridge- optional
certProvider: (domain) => Promise<ICert | 'http01'> renewThresholdDays,renewCheckIntervalHours,autoRenewsettings.
- Responsibilities:
- Initial provisioning: static vs HTTP-01.
- Subscribe to Port80Handler events (CERTIFICATE_ISSUED/RENEWED) and to static cert updates.
- Re-emit unified
'certificate'events to SmartProxy. - Central scheduling of renewals via
@push.rocks/taskbuffer.
- Create class
-
Refactor SmartProxy:
- Remove existing scheduling / renewal logic.
- Instantiate
CertProvisionerinstart(), delegate cert workflows entirely. - Forward CertProvisioner events to SmartProxy’s
'certificate'listener.
-
CertProvisioner lifecycle methods:
start(): provision all domains, start scheduler.stop(): stop scheduler.requestCertificate(domain): on-demand provisioning.
-
Handle static certificate auto-refresh:
- In the renewal scheduler, for domains with static certs, re-call
certProvider(domain)near expiry. - Apply returned cert via
networkProxyBridge.applyExternalCertificate().
- In the renewal scheduler, for domains with static certs, re-call
-
Tests:
- Unit tests for
CertProvisioner, mocking Port80Handler andcertProvider:- Validate initial provisioning and dynamic/static flows.
- Validate scheduling triggers correct renewals.
- Integration tests:
- Use actual in-memory Port80Handler with short intervals to verify renewals and event emission.
- Unit tests for
-
Documentation:
- Add code-level TS doc for
CertProvisionerAPI (options, methods, events). - Update root
README.mdand architecture diagrams to showCertProvisionerrole.
- Add code-level TS doc for