@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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.networkproxy.d.ts +6 -6
- package/dist_ts/classes.networkproxy.js +56 -39
- package/dist_ts/classes.port80handler.d.ts +89 -13
- package/dist_ts/classes.port80handler.js +312 -116
- package/package.json +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.networkproxy.ts +59 -38
- package/ts/classes.port80handler.ts +402 -123
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Custom error classes for better error handling
|
|
4
4
|
*/
|
|
5
|
-
|
|
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
|
|
55
|
+
* Events emitted by the Port80Handler
|
|
24
56
|
*/
|
|
25
|
-
export declare enum
|
|
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
|
-
*
|
|
75
|
+
* Certificate expiry payload type
|
|
35
76
|
*/
|
|
36
|
-
export
|
|
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
|
|
94
|
+
* Creates a new Port80Handler
|
|
46
95
|
* @param options Configuration options
|
|
47
96
|
*/
|
|
48
|
-
constructor(options?:
|
|
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
|
|
59
|
-
* @param
|
|
107
|
+
* Adds a domain with configuration options
|
|
108
|
+
* @param options Domain configuration options
|
|
60
109
|
*/
|
|
61
|
-
addDomain(
|
|
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
|