smartproxy/readme.plan.md

2.4 KiB

Plan: Integrate @push.rocks/smartacme into Port80Handler

  • read the complete README of @push.rocks/smartacme and understand the API.
  • Add imports to ts/plugins.ts:
    • import * as smartacme from '@push.rocks/smartacme';
    • export { smartacme };
  • In Port80Handler.start():
    • Instantiate SmartAcme and use the in memory certmanager.
    • use the DisklessHttp01Handler implemented in classes.port80handler.ts
    • Call await smartAcme.start() before binding HTTP server.
  • Replace old ACME flow in obtainCertificate() to use await smartAcme.getCertificateForDomain(domain) and process returned cert object. Remove old code.
  • Update handleRequest() to let DisklessHttp01Handler serve challenges.
  • Remove legacy methods: getAcmeClient(), handleAcmeChallenge(), processAuthorizations(), and related token bookkeeping in domainInfo.

Plan: Certificate Provider Hook & Observable Emission

  • Extend IPortProxySettings (ts/smartproxy/classes.pp.interfaces.ts):
    • Define type ISmartProxyCertProvisionObject = tsclass.network.ICert | 'http01'`.
    • Add optional certProvider?: (domain: string) => Promise<ISmartProxyCertProvisionObject>.
  • Enhance SmartProxy (ts/smartproxy/classes.smartproxy.ts):
    • Import EventEmitter and change class signature to export class SmartProxy extends EventEmitter.
    • Call super() in constructor.
    • In initializePort80Handler and updateDomainConfigs, for each non-wildcard domain:
      • Invoke certProvider(domain) if provided, defaulting to 'http01'.
      • If result is 'http01', register domain with Port80Handler for ACME challenges.
      • If static cert returned, bypass Port80Handler, apply via NetworkProxyBridge
    • Subscribe to Port80HandlerEvents.CERTIFICATE_ISSUED and CERTIFICATE_RENEWED and re-emit on SmartProxy as 'certificate' events (include domain, publicKey, privateKey, expiryDate, source: 'http01', isRenewal flag).
  • Extend NetworkProxyBridge (ts/smartproxy/classes.pp.networkproxybridge.ts):
    • Add public method applyExternalCertificate(data: ICertificateData): void to forward static certs into NetworkProxy.
  • Define SmartProxy 'certificate' event interface in TypeScript and update documentation.
  • Update README with usage examples showing certProvider callback and listening for 'certificate' events.