@push.rocks/smartacme 6.0.1 → 6.1.1

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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartacme',
6
- version: '6.0.1',
6
+ version: '6.1.1',
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartacme",
3
- "version": "6.0.1",
3
+ "version": "6.1.1",
4
4
  "private": false,
5
5
  "description": "A TypeScript-based ACME client for LetsEncrypt certificate management with a focus on simplicity and power.",
6
6
  "main": "dist_ts/index.js",
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
 
@@ -239,7 +307,7 @@ This comprehensive guide ensures you can set up, manage, and test ACME certifica
239
307
 
240
308
  ## License and Legal Information
241
309
 
242
- This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
310
+ This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license.md](license.md) file within this repository.
243
311
 
244
312
  **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
245
313
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartacme',
6
- version: '6.0.1',
6
+ version: '6.1.1',
7
7
  description: 'A TypeScript-based ACME client for LetsEncrypt certificate management with a focus on simplicity and power.'
8
8
  }