@push.rocks/smartacme 6.0.1 → 6.1.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/package.json +1 -1
- package/readme.md +70 -2
- package/ts/00_commitinfo_data.ts +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartacme',
|
|
6
|
-
version: '6.0
|
|
6
|
+
version: '6.1.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=
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -138,8 +138,76 @@ async function main() {
|
|
|
138
138
|
await smartAcmeInstance.stop();
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
main().catch(console.error);
|
|
142
|
-
```
|
|
141
|
+
main().catch(console.error);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Built-in Challenge Handlers
|
|
145
|
+
|
|
146
|
+
This module includes two out-of-the-box ACME challenge handlers:
|
|
147
|
+
|
|
148
|
+
- **Dns01Handler**
|
|
149
|
+
- Uses a Cloudflare account (from `@apiclient.xyz/cloudflare`) and Smartdns client to set and remove DNS TXT records, then wait for propagation.
|
|
150
|
+
- Import path:
|
|
151
|
+
```typescript
|
|
152
|
+
import { Dns01Handler } from '@push.rocks/smartacme/ts/handlers/Dns01Handler.js';
|
|
153
|
+
```
|
|
154
|
+
- Example:
|
|
155
|
+
```typescript
|
|
156
|
+
import * as cloudflare from '@apiclient.xyz/cloudflare';
|
|
157
|
+
const cfAccount = new cloudflare.CloudflareAccount('CF_TOKEN');
|
|
158
|
+
const dnsHandler = new Dns01Handler(cfAccount);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
- **Http01Handler**
|
|
162
|
+
- Writes ACME HTTP-01 challenge files under a file-system webroot (`/.well-known/acme-challenge/`), and removes them on cleanup.
|
|
163
|
+
- Import path:
|
|
164
|
+
```typescript
|
|
165
|
+
import { Http01Handler } from '@push.rocks/smartacme/ts/handlers/Http01Handler.js';
|
|
166
|
+
```
|
|
167
|
+
- Example:
|
|
168
|
+
```typescript
|
|
169
|
+
const httpHandler = new Http01Handler({ webroot: '/var/www/html' });
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Both handlers implement the `IChallengeHandler<T>` interface and can be combined in the `challengeHandlers` array.
|
|
173
|
+
|
|
174
|
+
## Creating Custom Handlers
|
|
175
|
+
|
|
176
|
+
To support additional challenge types or custom validation flows, implement the `IChallengeHandler<T>` interface:
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import type { IChallengeHandler } from '@push.rocks/smartacme/ts/handlers/IChallengeHandler.js';
|
|
180
|
+
|
|
181
|
+
// Define your custom challenge payload type
|
|
182
|
+
interface MyChallenge { type: string; /* ... */ }
|
|
183
|
+
|
|
184
|
+
class MyCustomHandler implements IChallengeHandler<MyChallenge> {
|
|
185
|
+
getSupportedTypes(): string[] {
|
|
186
|
+
return ['my-01'];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Prepare the challenge (set DNS records, start servers, etc.)
|
|
190
|
+
async prepare(ch: MyChallenge): Promise<void> {
|
|
191
|
+
// preparation logic
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Optional verify step after prepare
|
|
195
|
+
async verify?(ch: MyChallenge): Promise<void> {
|
|
196
|
+
// verification logic
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Cleanup after challenge (remove records, stop servers)
|
|
200
|
+
async cleanup(ch: MyChallenge): Promise<void> {
|
|
201
|
+
// cleanup logic
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Then register your handler:
|
|
206
|
+
const customInstance = new SmartAcme({
|
|
207
|
+
/* other options */,
|
|
208
|
+
challengeHandlers: [ new MyCustomHandler() ],
|
|
209
|
+
challengePriority: ['my-01'],
|
|
210
|
+
});
|
|
143
211
|
|
|
144
212
|
In this example, `Qenv` is used to manage environment variables, and `cloudflare` library is used to handle DNS challenges required by Let's Encrypt ACME protocol. The `setChallenge` and `removeChallenge` methods are essential for automating the DNS challenge process, which is a key part of domain validation.
|
|
145
213
|
|
package/ts/00_commitinfo_data.ts
CHANGED