@push.rocks/smartacme 6.1.3 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/handlers/Http01Handler.d.ts +3 -3
- package/dist_ts/handlers/Http01Handler.js +1 -1
- package/dist_ts/handlers/Http01MemoryHandler.d.ts +26 -0
- package/dist_ts/handlers/Http01MemoryHandler.js +51 -0
- package/dist_ts/handlers/index.d.ts +2 -1
- package/dist_ts/handlers/index.js +3 -2
- package/package.json +1 -1
- package/readme.md +19 -6
- package/readme.plan.md +44 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/handlers/Http01Handler.ts +3 -3
- package/ts/handlers/Http01MemoryHandler.ts +67 -0
- package/ts/handlers/index.ts +2 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartacme',
|
|
6
|
-
version: '6.
|
|
6
|
+
version: '6.2.0',
|
|
7
7
|
description: 'A TypeScript-based ACME client for LetsEncrypt certificate management with a focus on simplicity and power.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx1QkFBdUI7SUFDN0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLDZHQUE2RztDQUMzSCxDQUFBIn0=
|
|
@@ -3,20 +3,20 @@ import type { IChallengeHandler } from './IChallengeHandler.js';
|
|
|
3
3
|
* HTTP-01 ACME challenge handler using file-system webroot.
|
|
4
4
|
* Writes and removes the challenge file under <webroot>/.well-known/acme-challenge/.
|
|
5
5
|
*/
|
|
6
|
-
export interface
|
|
6
|
+
export interface Http01WebrootOptions {
|
|
7
7
|
/**
|
|
8
8
|
* Directory that serves HTTP requests for /.well-known/acme-challenge
|
|
9
9
|
*/
|
|
10
10
|
webroot: string;
|
|
11
11
|
}
|
|
12
|
-
export declare class
|
|
12
|
+
export declare class Http01Webroot implements IChallengeHandler<{
|
|
13
13
|
type: string;
|
|
14
14
|
token: string;
|
|
15
15
|
keyAuthorization: string;
|
|
16
16
|
webPath: string;
|
|
17
17
|
}> {
|
|
18
18
|
private webroot;
|
|
19
|
-
constructor(options:
|
|
19
|
+
constructor(options: Http01WebrootOptions);
|
|
20
20
|
getSupportedTypes(): string[];
|
|
21
21
|
prepare(ch: {
|
|
22
22
|
token: string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IChallengeHandler } from './IChallengeHandler.js';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP-01 ACME challenge handler using in-memory storage.
|
|
4
|
+
* Stores challenge tokens and key authorizations in memory
|
|
5
|
+
* and serves them via handleRequest for arbitrary HTTP servers.
|
|
6
|
+
*/
|
|
7
|
+
export interface Http01MemoryHandlerChallenge {
|
|
8
|
+
type: string;
|
|
9
|
+
token: string;
|
|
10
|
+
keyAuthorization: string;
|
|
11
|
+
webPath: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class Http01MemoryHandler implements IChallengeHandler<Http01MemoryHandlerChallenge> {
|
|
14
|
+
private store;
|
|
15
|
+
getSupportedTypes(): string[];
|
|
16
|
+
prepare(ch: Http01MemoryHandlerChallenge): Promise<void>;
|
|
17
|
+
verify(_ch: Http01MemoryHandlerChallenge): Promise<void>;
|
|
18
|
+
cleanup(ch: Http01MemoryHandlerChallenge): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* HTTP request handler for serving ACME HTTP-01 challenges.
|
|
21
|
+
* @param req HTTP request object (should have url property)
|
|
22
|
+
* @param res HTTP response object
|
|
23
|
+
* @param next Optional next() callback for Express-style fallthrough
|
|
24
|
+
*/
|
|
25
|
+
handleRequest(req: any, res: any, next?: () => void): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export class Http01MemoryHandler {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.store = new Map();
|
|
4
|
+
}
|
|
5
|
+
getSupportedTypes() {
|
|
6
|
+
return ['http-01'];
|
|
7
|
+
}
|
|
8
|
+
async prepare(ch) {
|
|
9
|
+
this.store.set(ch.token, ch.keyAuthorization);
|
|
10
|
+
}
|
|
11
|
+
async verify(_ch) {
|
|
12
|
+
// No-op
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
async cleanup(ch) {
|
|
16
|
+
this.store.delete(ch.token);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* HTTP request handler for serving ACME HTTP-01 challenges.
|
|
20
|
+
* @param req HTTP request object (should have url property)
|
|
21
|
+
* @param res HTTP response object
|
|
22
|
+
* @param next Optional next() callback for Express-style fallthrough
|
|
23
|
+
*/
|
|
24
|
+
handleRequest(req, res, next) {
|
|
25
|
+
const url = req.url || '';
|
|
26
|
+
const prefix = '/.well-known/acme-challenge/';
|
|
27
|
+
if (!url.startsWith(prefix)) {
|
|
28
|
+
if (next) {
|
|
29
|
+
return next();
|
|
30
|
+
}
|
|
31
|
+
res.statusCode = 404;
|
|
32
|
+
return res.end();
|
|
33
|
+
}
|
|
34
|
+
const token = url.slice(prefix.length);
|
|
35
|
+
const keyAuth = this.store.get(token);
|
|
36
|
+
if (keyAuth !== undefined) {
|
|
37
|
+
if (typeof res.status === 'function' && typeof res.send === 'function') {
|
|
38
|
+
return res.status(200).send(keyAuth);
|
|
39
|
+
}
|
|
40
|
+
res.statusCode = 200;
|
|
41
|
+
res.setHeader('content-type', 'text/plain');
|
|
42
|
+
return res.end(keyAuth);
|
|
43
|
+
}
|
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UcsQ0FBQztRQUNyQixPQUFPLEdBQUcsQ0FBQyxHQUFHLEVBQUUsQ0FBQztJQUNuQixDQUFDO0NBQ0YifQ==
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { IChallengeHandler } from './IChallengeHandler.js';
|
|
2
2
|
export { Dns01Handler } from './Dns01Handler.js';
|
|
3
|
-
export {
|
|
3
|
+
export { Http01Webroot } from './Http01Handler.js';
|
|
4
|
+
export { Http01MemoryHandler } from './Http01MemoryHandler.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Removed legacy handler adapter
|
|
2
2
|
export { Dns01Handler } from './Dns01Handler.js';
|
|
3
|
-
export {
|
|
4
|
-
|
|
3
|
+
export { Http01Webroot } from './Http01Handler.js';
|
|
4
|
+
export { Http01MemoryHandler } from './Http01MemoryHandler.js';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9oYW5kbGVycy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxpQ0FBaUM7QUFDakMsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ2pELE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNuRCxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQyJ9
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -61,7 +61,7 @@ const smartAcmeInstance = new SmartAcme({
|
|
|
61
61
|
retryOptions: {}, // optional retry/backoff settings
|
|
62
62
|
challengeHandlers: [
|
|
63
63
|
new Dns01Handler(cfAccount),
|
|
64
|
-
// you can add more handlers, e.g.
|
|
64
|
+
// you can add more handlers, e.g. Http01Webroot
|
|
65
65
|
],
|
|
66
66
|
challengePriority: ['dns-01'], // optional ordering of challenge types
|
|
67
67
|
});
|
|
@@ -143,7 +143,7 @@ async function main() {
|
|
|
143
143
|
|
|
144
144
|
## Built-in Challenge Handlers
|
|
145
145
|
|
|
146
|
-
This module includes
|
|
146
|
+
This module includes three out-of-the-box ACME challenge handlers:
|
|
147
147
|
|
|
148
148
|
- **Dns01Handler**
|
|
149
149
|
- Uses a Cloudflare account (from `@apiclient.xyz/cloudflare`) and Smartdns client to set and remove DNS TXT records, then wait for propagation.
|
|
@@ -158,18 +158,31 @@ async function main() {
|
|
|
158
158
|
const dnsHandler = new Dns01Handler(cfAccount);
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
- **
|
|
161
|
+
- **Http01Webroot**
|
|
162
162
|
- Writes ACME HTTP-01 challenge files under a file-system webroot (`/.well-known/acme-challenge/`), and removes them on cleanup.
|
|
163
163
|
- Import path:
|
|
164
164
|
```typescript
|
|
165
|
-
import {
|
|
165
|
+
import { Http01Webroot } from '@push.rocks/smartacme/ts/handlers/Http01Handler.js';
|
|
166
166
|
```
|
|
167
167
|
- Example:
|
|
168
168
|
```typescript
|
|
169
|
-
const httpHandler = new
|
|
169
|
+
const httpHandler = new Http01Webroot({ webroot: '/var/www/html' });
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
- **Http01MemoryHandler**
|
|
173
|
+
- In-memory HTTP-01 challenge handler that stores and serves ACME tokens without disk I/O.
|
|
174
|
+
- Import path:
|
|
175
|
+
```typescript
|
|
176
|
+
import { Http01MemoryHandler } from '@push.rocks/smartacme/ts/handlers/Http01MemoryHandler.js';
|
|
177
|
+
```
|
|
178
|
+
- Example (Express integration):
|
|
179
|
+
```typescript
|
|
180
|
+
import { Http01MemoryHandler } from '@push.rocks/smartacme/ts/handlers/Http01MemoryHandler.js';
|
|
181
|
+
const memoryHandler = new Http01MemoryHandler();
|
|
182
|
+
app.use((req, res, next) => memoryHandler.handleRequest(req, res, next));
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
All handlers implement the `IChallengeHandler<T>` interface and can be combined in the `challengeHandlers` array.
|
|
173
186
|
|
|
174
187
|
## Creating Custom Handlers
|
|
175
188
|
|
package/readme.plan.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Plan: Diskless HTTP-01 Handler and Renaming Existing Handler
|
|
2
|
+
|
|
3
|
+
This plan outlines steps to rename the existing filesystem-based HTTP-01 handler to `Http01Webroot`
|
|
4
|
+
and introduce a new diskless (in-memory) HTTP-01 handler for integration with arbitrary HTTP servers
|
|
5
|
+
(e.g., Express).
|
|
6
|
+
|
|
7
|
+
## 1. Rename existing handler to Http01Webroot
|
|
8
|
+
- In `ts/handlers/Http01Handler.ts`:
|
|
9
|
+
- Rename `Http01HandlerOptions` to `Http01WebrootOptions`.
|
|
10
|
+
- Rename class `Http01Handler` to `Http01Webroot`.
|
|
11
|
+
- Remove the legacy alias; rename the handler directly.
|
|
12
|
+
- In `ts/handlers/index.ts`:
|
|
13
|
+
- Export `Http01Webroot` under its new name.
|
|
14
|
+
- Remove any `Http01Handler` export.
|
|
15
|
+
- Update existing tests (e.g., `test.handlers-http01.ts`) to import `Http01Webroot` instead of `Http01Handler`.
|
|
16
|
+
|
|
17
|
+
## 2. Add new diskless (in-memory) HTTP-01 handler
|
|
18
|
+
- Create `ts/handlers/Http01MemoryHandler.ts`:
|
|
19
|
+
- Implement `IChallengeHandler<{ token: string; keyAuthorization: string; webPath: string }>`, storing challenges in a private `Map<string, string>`.
|
|
20
|
+
- `prepare()`: add token→keyAuthorization mapping.
|
|
21
|
+
- `verify()`: no-op.
|
|
22
|
+
- `cleanup()`: remove mapping.
|
|
23
|
+
- Add `handleRequest(req, res, next?)` method:
|
|
24
|
+
- Parse `/.well-known/acme-challenge/:token` from `req.url`.
|
|
25
|
+
- If token exists, respond with the key authorization and status 200.
|
|
26
|
+
- If missing and `next` provided, call `next()`, otherwise respond 404.
|
|
27
|
+
- Export `Http01MemoryHandler` in `ts/handlers/index.ts`.
|
|
28
|
+
|
|
29
|
+
## 3. Write tests for Http01MemoryHandler
|
|
30
|
+
- Create `test/test.handlers-http01-memory.ts`:
|
|
31
|
+
- Use `tap` and `expect` to:
|
|
32
|
+
1. `prepare()` a challenge.
|
|
33
|
+
2. Invoke `handleRequest()` with a fake `req`/`res` to confirm 200 and correct body.
|
|
34
|
+
3. `cleanup()` the challenge.
|
|
35
|
+
4. Confirm `handleRequest()` now yields 404.
|
|
36
|
+
|
|
37
|
+
## 4. Update documentation
|
|
38
|
+
- Add examples in `readme.md` showing how to use both `Http01Webroot` and the new `Http01MemoryHandler`:
|
|
39
|
+
- Sample code for Express integration using `handleRequest`.
|
|
40
|
+
|
|
41
|
+
## 5. Build and test
|
|
42
|
+
- Run `pnpm build` and `pnpm test`, ensuring existing tests are updated for `Http01Webroot` and new tests pass.
|
|
43
|
+
|
|
44
|
+
Please review and let me know if this plan makes sense before proceeding with implementation.
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -6,14 +6,14 @@ import type { IChallengeHandler } from './IChallengeHandler.js';
|
|
|
6
6
|
* HTTP-01 ACME challenge handler using file-system webroot.
|
|
7
7
|
* Writes and removes the challenge file under <webroot>/.well-known/acme-challenge/.
|
|
8
8
|
*/
|
|
9
|
-
export interface
|
|
9
|
+
export interface Http01WebrootOptions {
|
|
10
10
|
/**
|
|
11
11
|
* Directory that serves HTTP requests for /.well-known/acme-challenge
|
|
12
12
|
*/
|
|
13
13
|
webroot: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export class
|
|
16
|
+
export class Http01Webroot implements IChallengeHandler<{
|
|
17
17
|
type: string;
|
|
18
18
|
token: string;
|
|
19
19
|
keyAuthorization: string;
|
|
@@ -21,7 +21,7 @@ export class Http01Handler implements IChallengeHandler<{
|
|
|
21
21
|
}> {
|
|
22
22
|
private webroot: string;
|
|
23
23
|
|
|
24
|
-
constructor(options:
|
|
24
|
+
constructor(options: Http01WebrootOptions) {
|
|
25
25
|
this.webroot = options.webroot;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { IChallengeHandler } from './IChallengeHandler.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HTTP-01 ACME challenge handler using in-memory storage.
|
|
5
|
+
* Stores challenge tokens and key authorizations in memory
|
|
6
|
+
* and serves them via handleRequest for arbitrary HTTP servers.
|
|
7
|
+
*/
|
|
8
|
+
export interface Http01MemoryHandlerChallenge {
|
|
9
|
+
type: string;
|
|
10
|
+
token: string;
|
|
11
|
+
keyAuthorization: string;
|
|
12
|
+
webPath: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class Http01MemoryHandler implements IChallengeHandler<Http01MemoryHandlerChallenge> {
|
|
16
|
+
private store: Map<string, string> = new Map();
|
|
17
|
+
|
|
18
|
+
public getSupportedTypes(): string[] {
|
|
19
|
+
return ['http-01'];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public async prepare(ch: Http01MemoryHandlerChallenge): Promise<void> {
|
|
23
|
+
this.store.set(ch.token, ch.keyAuthorization);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public async verify(_ch: Http01MemoryHandlerChallenge): Promise<void> {
|
|
27
|
+
// No-op
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public async cleanup(ch: Http01MemoryHandlerChallenge): Promise<void> {
|
|
32
|
+
this.store.delete(ch.token);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* HTTP request handler for serving ACME HTTP-01 challenges.
|
|
37
|
+
* @param req HTTP request object (should have url property)
|
|
38
|
+
* @param res HTTP response object
|
|
39
|
+
* @param next Optional next() callback for Express-style fallthrough
|
|
40
|
+
*/
|
|
41
|
+
public handleRequest(req: any, res: any, next?: () => void): void {
|
|
42
|
+
const url = req.url || '';
|
|
43
|
+
const prefix = '/.well-known/acme-challenge/';
|
|
44
|
+
if (!url.startsWith(prefix)) {
|
|
45
|
+
if (next) {
|
|
46
|
+
return next();
|
|
47
|
+
}
|
|
48
|
+
res.statusCode = 404;
|
|
49
|
+
return res.end();
|
|
50
|
+
}
|
|
51
|
+
const token = url.slice(prefix.length);
|
|
52
|
+
const keyAuth = this.store.get(token);
|
|
53
|
+
if (keyAuth !== undefined) {
|
|
54
|
+
if (typeof res.status === 'function' && typeof res.send === 'function') {
|
|
55
|
+
return res.status(200).send(keyAuth);
|
|
56
|
+
}
|
|
57
|
+
res.statusCode = 200;
|
|
58
|
+
res.setHeader('content-type', 'text/plain');
|
|
59
|
+
return res.end(keyAuth);
|
|
60
|
+
}
|
|
61
|
+
if (next) {
|
|
62
|
+
return next();
|
|
63
|
+
}
|
|
64
|
+
res.statusCode = 404;
|
|
65
|
+
return res.end();
|
|
66
|
+
}
|
|
67
|
+
}
|
package/ts/handlers/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { IChallengeHandler } from './IChallengeHandler.js';
|
|
2
2
|
// Removed legacy handler adapter
|
|
3
3
|
export { Dns01Handler } from './Dns01Handler.js';
|
|
4
|
-
export {
|
|
4
|
+
export { Http01Webroot } from './Http01Handler.js';
|
|
5
|
+
export { Http01MemoryHandler } from './Http01MemoryHandler.js';
|