2.4 KiB
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 useawait 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 toexport class SmartProxy extends EventEmitter
. - Call
super()
in constructor. - In
initializePort80Handler
andupdateDomainConfigs
, for each non-wildcard domain:- Invoke
certProvider(domain)
if provided, defaulting to'http01'
. - If result is
'http01'
, register domain withPort80Handler
for ACME challenges. - If static cert returned, bypass
Port80Handler
, apply viaNetworkProxyBridge
- Invoke
- Subscribe to
Port80HandlerEvents.CERTIFICATE_ISSUED
andCERTIFICATE_RENEWED
and re-emit onSmartProxy
as'certificate'
events (includedomain
,publicKey
,privateKey
,expiryDate
,source: 'http01'
,isRenewal
flag).
- Import
- Extend NetworkProxyBridge (ts/smartproxy/classes.pp.networkproxybridge.ts):
- Add public method
applyExternalCertificate(data: ICertificateData): void
to forward static certs intoNetworkProxy
.
- Add public method
- Define
SmartProxy
'certificate'
event interface in TypeScript and update documentation. - Update README with usage examples showing
certProvider
callback and listening for'certificate'
events.