@push.rocks/smartproxy 19.0.0 → 19.2.2

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/readme.hints.md CHANGED
@@ -4,6 +4,12 @@
4
4
  - Package: `@push.rocks/smartproxy` – high-performance proxy supporting HTTP(S), TCP, WebSocket, and ACME integration.
5
5
  - Written in TypeScript, compiled output in `dist_ts/`, uses ESM with NodeNext resolution.
6
6
 
7
+ ## Important: ACME Configuration in v19.0.0
8
+ - **Breaking Change**: ACME configuration must be placed within individual route TLS settings, not at the top level
9
+ - Route-level ACME config is the ONLY way to enable SmartAcme initialization
10
+ - SmartCertManager requires email in route config for certificate acquisition
11
+ - Top-level ACME configuration is ignored in v19.0.0
12
+
7
13
  ## Repository Structure
8
14
  - `ts/` – TypeScript source files:
9
15
  - `index.ts` exports main modules.
@@ -57,8 +63,32 @@
57
63
  - CLI entrypoint (`cli.js`) supports command-line usage (ACME, proxy controls).
58
64
  - ACME and certificate handling via `Port80Handler` and `helpers.certificates.ts`.
59
65
 
66
+ ## ACME/Certificate Configuration Example (v19.0.0)
67
+ ```typescript
68
+ const proxy = new SmartProxy({
69
+ routes: [{
70
+ name: 'example.com',
71
+ match: { domains: 'example.com', ports: 443 },
72
+ action: {
73
+ type: 'forward',
74
+ target: { host: 'localhost', port: 8080 },
75
+ tls: {
76
+ mode: 'terminate',
77
+ certificate: 'auto',
78
+ acme: { // ACME config MUST be here, not at top level
79
+ email: 'ssl@example.com',
80
+ useProduction: false,
81
+ challengePort: 80
82
+ }
83
+ }
84
+ }
85
+ }]
86
+ });
87
+ ```
88
+
60
89
  ## TODOs / Considerations
61
90
  - Ensure import extensions in source match build outputs (`.ts` vs `.js`).
62
91
  - Update `plugins.ts` when adding new dependencies.
63
92
  - Maintain test coverage for new routing or proxy features.
64
- - Keep `ts/` and `dist_ts/` in sync after refactors.
93
+ - Keep `ts/` and `dist_ts/` in sync after refactors.
94
+ - Consider implementing top-level ACME config support for backward compatibility
package/readme.md CHANGED
@@ -134,6 +134,14 @@ import {
134
134
 
135
135
  // Create a new SmartProxy instance with route-based configuration
136
136
  const proxy = new SmartProxy({
137
+ // Global ACME settings for all routes with certificate: 'auto'
138
+ acme: {
139
+ email: 'ssl@example.com', // Required for Let's Encrypt
140
+ useProduction: false, // Use staging by default
141
+ renewThresholdDays: 30, // Renew 30 days before expiry
142
+ port: 80 // Port for HTTP-01 challenges
143
+ },
144
+
137
145
  // Define all your routing rules in a single array
138
146
  routes: [
139
147
  // Basic HTTP route - forward traffic from port 80 to internal service
@@ -141,7 +149,7 @@ const proxy = new SmartProxy({
141
149
 
142
150
  // HTTPS route with TLS termination and automatic certificates
143
151
  createHttpsTerminateRoute('secure.example.com', { host: 'localhost', port: 8080 }, {
144
- certificate: 'auto' // Use Let's Encrypt
152
+ certificate: 'auto' // Uses global ACME settings
145
153
  }),
146
154
 
147
155
  // HTTPS passthrough for legacy systems
@@ -350,6 +358,66 @@ interface IRouteAction {
350
358
  }
351
359
  ```
352
360
 
361
+ ### ACME/Let's Encrypt Configuration
362
+
363
+ SmartProxy supports automatic certificate provisioning and renewal with Let's Encrypt. ACME can be configured globally or per-route.
364
+
365
+ #### Global ACME Configuration
366
+ Set default ACME settings for all routes with `certificate: 'auto'`:
367
+
368
+ ```typescript
369
+ const proxy = new SmartProxy({
370
+ // Global ACME configuration
371
+ acme: {
372
+ email: 'ssl@example.com', // Required - Let's Encrypt account email
373
+ useProduction: false, // Use staging (false) or production (true)
374
+ renewThresholdDays: 30, // Renew certificates 30 days before expiry
375
+ port: 80, // Port for HTTP-01 challenges
376
+ certificateStore: './certs', // Directory to store certificates
377
+ autoRenew: true, // Enable automatic renewal
378
+ renewCheckIntervalHours: 24 // Check for renewals every 24 hours
379
+ },
380
+
381
+ routes: [
382
+ // This route will use the global ACME settings
383
+ {
384
+ name: 'website',
385
+ match: { ports: 443, domains: 'example.com' },
386
+ action: {
387
+ type: 'forward',
388
+ target: { host: 'localhost', port: 8080 },
389
+ tls: {
390
+ mode: 'terminate',
391
+ certificate: 'auto' // Uses global ACME configuration
392
+ }
393
+ }
394
+ }
395
+ ]
396
+ });
397
+ ```
398
+
399
+ #### Route-Specific ACME Configuration
400
+ Override global settings for specific routes:
401
+
402
+ ```typescript
403
+ {
404
+ name: 'api',
405
+ match: { ports: 443, domains: 'api.example.com' },
406
+ action: {
407
+ type: 'forward',
408
+ target: { host: 'localhost', port: 3000 },
409
+ tls: {
410
+ mode: 'terminate',
411
+ certificate: 'auto',
412
+ acme: {
413
+ email: 'api-ssl@example.com', // Different email for this route
414
+ useProduction: true, // Use production while global uses staging
415
+ renewBeforeDays: 60 // Route-specific renewal threshold
416
+ }
417
+ }
418
+ }
419
+ }
420
+
353
421
  **Forward Action:**
354
422
  When `type: 'forward'`, the traffic is forwarded to the specified target:
355
423
  ```typescript