@push.rocks/smartproxy 4.2.4 → 4.2.6

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.
@@ -1,8 +1,40 @@
1
1
  import * as plugins from './plugins.js';
2
2
  /**
3
- * Configuration options for the ACME Certificate Manager
3
+ * Custom error classes for better error handling
4
4
  */
5
- interface IAcmeCertManagerOptions {
5
+ export declare class Port80HandlerError extends Error {
6
+ constructor(message: string);
7
+ }
8
+ export declare class CertificateError extends Port80HandlerError {
9
+ readonly domain: string;
10
+ readonly isRenewal: boolean;
11
+ constructor(message: string, domain: string, isRenewal?: boolean);
12
+ }
13
+ export declare class ServerError extends Port80HandlerError {
14
+ readonly code?: string;
15
+ constructor(message: string, code?: string);
16
+ }
17
+ /**
18
+ * Domain forwarding configuration
19
+ */
20
+ export interface IForwardConfig {
21
+ ip: string;
22
+ port: number;
23
+ }
24
+ /**
25
+ * Domain configuration options
26
+ */
27
+ export interface IDomainOptions {
28
+ domainName: string;
29
+ sslRedirect: boolean;
30
+ acmeMaintenance: boolean;
31
+ forward?: IForwardConfig;
32
+ acmeForward?: IForwardConfig;
33
+ }
34
+ /**
35
+ * Configuration options for the Port80Handler
36
+ */
37
+ interface IPort80HandlerOptions {
6
38
  port?: number;
7
39
  contactEmail?: string;
8
40
  useProduction?: boolean;
@@ -13,27 +45,44 @@ interface IAcmeCertManagerOptions {
13
45
  /**
14
46
  * Certificate data that can be emitted via events or set from outside
15
47
  */
16
- interface ICertificateData {
48
+ export interface ICertificateData {
17
49
  domain: string;
18
50
  certificate: string;
19
51
  privateKey: string;
20
52
  expiryDate: Date;
21
53
  }
22
54
  /**
23
- * Events emitted by the ACME Certificate Manager
55
+ * Events emitted by the Port80Handler
24
56
  */
25
- export declare enum CertManagerEvents {
57
+ export declare enum Port80HandlerEvents {
26
58
  CERTIFICATE_ISSUED = "certificate-issued",
27
59
  CERTIFICATE_RENEWED = "certificate-renewed",
28
60
  CERTIFICATE_FAILED = "certificate-failed",
29
61
  CERTIFICATE_EXPIRING = "certificate-expiring",
30
62
  MANAGER_STARTED = "manager-started",
31
- MANAGER_STOPPED = "manager-stopped"
63
+ MANAGER_STOPPED = "manager-stopped",
64
+ REQUEST_FORWARDED = "request-forwarded"
65
+ }
66
+ /**
67
+ * Certificate failure payload type
68
+ */
69
+ export interface ICertificateFailure {
70
+ domain: string;
71
+ error: string;
72
+ isRenewal: boolean;
32
73
  }
33
74
  /**
34
- * Improved ACME Certificate Manager with event emission and external certificate management
75
+ * Certificate expiry payload type
35
76
  */
36
- export declare class AcmeCertManager extends plugins.EventEmitter {
77
+ export interface ICertificateExpiring {
78
+ domain: string;
79
+ expiryDate: Date;
80
+ daysRemaining: number;
81
+ }
82
+ /**
83
+ * Port80Handler with ACME certificate management and request forwarding capabilities
84
+ */
85
+ export declare class Port80Handler extends plugins.EventEmitter {
37
86
  private domainCertificates;
38
87
  private server;
39
88
  private acmeClient;
@@ -42,10 +91,10 @@ export declare class AcmeCertManager extends plugins.EventEmitter {
42
91
  private isShuttingDown;
43
92
  private options;
44
93
  /**
45
- * Creates a new ACME Certificate Manager
94
+ * Creates a new Port80Handler
46
95
  * @param options Configuration options
47
96
  */
48
- constructor(options?: IAcmeCertManagerOptions);
97
+ constructor(options?: IPort80HandlerOptions);
49
98
  /**
50
99
  * Starts the HTTP server for ACME challenges
51
100
  */
@@ -55,10 +104,10 @@ export declare class AcmeCertManager extends plugins.EventEmitter {
55
104
  */
56
105
  stop(): Promise<void>;
57
106
  /**
58
- * Adds a domain to be managed for certificates
59
- * @param domain The domain to add
107
+ * Adds a domain with configuration options
108
+ * @param options Domain configuration options
60
109
  */
61
- addDomain(domain: string): void;
110
+ addDomain(options: IDomainOptions): void;
62
111
  /**
63
112
  * Removes a domain from management
64
113
  * @param domain The domain to remove
@@ -88,6 +137,14 @@ export declare class AcmeCertManager extends plugins.EventEmitter {
88
137
  * @param res The HTTP response
89
138
  */
90
139
  private handleRequest;
140
+ /**
141
+ * Forwards an HTTP request to the specified target
142
+ * @param req The original request
143
+ * @param res The response object
144
+ * @param target The forwarding target (IP and port)
145
+ * @param requestType Type of request for logging
146
+ */
147
+ private forwardRequest;
91
148
  /**
92
149
  * Serves the ACME HTTP-01 challenge response
93
150
  * @param req The HTTP request
@@ -101,6 +158,13 @@ export declare class AcmeCertManager extends plugins.EventEmitter {
101
158
  * @param isRenewal Whether this is a renewal attempt
102
159
  */
103
160
  private obtainCertificate;
161
+ /**
162
+ * Process ACME authorizations by verifying and completing challenges
163
+ * @param client ACME client
164
+ * @param domain Domain name
165
+ * @param authorizations Authorizations to process
166
+ */
167
+ private processAuthorizations;
104
168
  /**
105
169
  * Starts the certificate renewal timer
106
170
  */
@@ -109,6 +173,18 @@ export declare class AcmeCertManager extends plugins.EventEmitter {
109
173
  * Checks for certificates that need renewal
110
174
  */
111
175
  private checkForRenewals;
176
+ /**
177
+ * Extract expiry date from certificate using a more robust approach
178
+ * @param certificate Certificate PEM string
179
+ * @param domain Domain for logging
180
+ * @returns Extracted expiry date or default
181
+ */
182
+ private extractExpiryDateFromCertificate;
183
+ /**
184
+ * Get a default expiry date (90 days from now)
185
+ * @returns Default expiry date
186
+ */
187
+ private getDefaultExpiryDate;
112
188
  /**
113
189
  * Emits a certificate event with the certificate data
114
190
  * @param eventType The event type to emit