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
Http01HandlerOptions
toHttp01WebrootOptions
. - Rename class
Http01Handler
toHttp01Webroot
. - Remove the legacy alias; rename the handler directly.
- In
ts/handlers/index.ts
:- Export
Http01Webroot
under its new name. - Remove any
Http01Handler
export. - Update existing tests (e.g.,
test.handlers-http01.ts
) to importHttp01Webroot
instead 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/:token
fromreq.url
. - If token exists, respond with the key authorization and status 200.
- If missing and
next
provided, callnext()
, otherwise respond 404.
- Parse
- Implement
- Export
Http01MemoryHandler
ints/handlers/index.ts
.
3. Write tests for Http01MemoryHandler
- Create
test/test.handlers-http01-memory.ts
:- Use
tap
andexpect
to:prepare()
a challenge.- Invoke
handleRequest()
with a fakereq
/res
to confirm 200 and correct body. cleanup()
the challenge.- Confirm
handleRequest()
now yields 404.
- Use
4. Update documentation
- Add examples in
readme.md
showing how to use bothHttp01Webroot
and the newHttp01MemoryHandler
:- Sample code for Express integration using
handleRequest
.
- Sample code for Express integration using
5. Build and test
- Run
pnpm build
andpnpm test
, ensuring existing tests are updated forHttp01Webroot
and new tests pass.
Please review and let me know if this plan makes sense before proceeding with implementation.