2.2 KiB
2.2 KiB
Plan: Diskless HTTP-01 Handler and Renaming Existing Handler
This plan outlines steps to rename the existing filesystem-based HTTP-01 handler to Http01Webroot
and introduce a new diskless (in-memory) HTTP-01 handler for integration with arbitrary HTTP servers
(e.g., Express).
1. Rename existing handler to Http01Webroot
- In
ts/handlers/Http01Handler.ts:- Rename
Http01HandlerOptionstoHttp01WebrootOptions. - Rename class
Http01HandlertoHttp01Webroot. - Remove the legacy alias; rename the handler directly.
- In
ts/handlers/index.ts:- Export
Http01Webrootunder its new name. - Remove any
Http01Handlerexport. - Update existing tests (e.g.,
test.handlers-http01.ts) to importHttp01Webrootinstead ofHttp01Handler.
- Export
- Rename
2. Add new diskless (in-memory) HTTP-01 handler
- Create
ts/handlers/Http01MemoryHandler.ts:- Implement
IChallengeHandler<{ token: string; keyAuthorization: string; webPath: string }>, storing challenges in a privateMap<string, string>. prepare(): add token→keyAuthorization mapping.verify(): no-op.cleanup(): remove mapping.- Add
handleRequest(req, res, next?)method:- Parse
/.well-known/acme-challenge/:tokenfromreq.url. - If token exists, respond with the key authorization and status 200.
- If missing and
nextprovided, callnext(), otherwise respond 404.
- Parse
- Implement
- Export
Http01MemoryHandlerints/handlers/index.ts.
3. Write tests for Http01MemoryHandler
- Create
test/test.handlers-http01-memory.ts:- Use
tapandexpectto:prepare()a challenge.- Invoke
handleRequest()with a fakereq/resto confirm 200 and correct body. cleanup()the challenge.- Confirm
handleRequest()now yields 404.
- Use
4. Update documentation
- Add examples in
readme.mdshowing how to use bothHttp01Webrootand the newHttp01MemoryHandler:- Sample code for Express integration using
handleRequest.
- Sample code for Express integration using
5. Build and test
- Run
pnpm buildandpnpm test, ensuring existing tests are updated forHttp01Webrootand new tests pass.
Please review and let me know if this plan makes sense before proceeding with implementation.