@push.rocks/smartproxy 12.0.0 → 13.1.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/certificate/acme/acme-factory.d.ts +17 -0
- package/dist_ts/certificate/acme/acme-factory.js +40 -0
- package/dist_ts/certificate/acme/challenge-handler.d.ts +44 -0
- package/dist_ts/certificate/acme/challenge-handler.js +92 -0
- package/dist_ts/certificate/acme/index.d.ts +4 -0
- package/dist_ts/certificate/acme/index.js +5 -0
- package/dist_ts/certificate/events/certificate-events.d.ts +33 -0
- package/dist_ts/certificate/events/certificate-events.js +38 -0
- package/dist_ts/certificate/index.d.ts +24 -0
- package/dist_ts/certificate/index.js +39 -0
- package/dist_ts/certificate/models/certificate-types.d.ts +77 -0
- package/dist_ts/certificate/models/certificate-types.js +2 -0
- package/dist_ts/certificate/providers/cert-provisioner.d.ts +93 -0
- package/dist_ts/certificate/providers/cert-provisioner.js +262 -0
- package/dist_ts/certificate/providers/index.d.ts +4 -0
- package/dist_ts/certificate/providers/index.js +5 -0
- package/dist_ts/certificate/storage/file-storage.d.ts +66 -0
- package/dist_ts/certificate/storage/file-storage.js +194 -0
- package/dist_ts/certificate/storage/index.d.ts +4 -0
- package/dist_ts/certificate/storage/index.js +5 -0
- package/dist_ts/certificate/utils/certificate-helpers.d.ts +17 -0
- package/dist_ts/certificate/utils/certificate-helpers.js +45 -0
- package/dist_ts/common/eventUtils.d.ts +1 -1
- package/dist_ts/common/port80-adapter.d.ts +1 -1
- package/dist_ts/core/events/index.d.ts +4 -0
- package/dist_ts/core/events/index.js +5 -0
- package/dist_ts/core/index.d.ts +6 -0
- package/dist_ts/core/index.js +8 -0
- package/dist_ts/core/models/common-types.d.ts +82 -0
- package/dist_ts/core/models/common-types.js +15 -0
- package/dist_ts/core/models/index.d.ts +4 -0
- package/dist_ts/core/models/index.js +5 -0
- package/dist_ts/core/utils/event-utils.d.ts +15 -0
- package/dist_ts/core/utils/event-utils.js +19 -0
- package/dist_ts/core/utils/index.d.ts +6 -0
- package/dist_ts/core/utils/index.js +7 -0
- package/dist_ts/core/utils/ip-utils.d.ts +53 -0
- package/dist_ts/core/utils/ip-utils.js +153 -0
- package/dist_ts/core/utils/validation-utils.d.ts +61 -0
- package/dist_ts/core/utils/validation-utils.js +149 -0
- package/dist_ts/forwarding/config/domain-config.d.ts +12 -0
- package/dist_ts/forwarding/config/domain-config.js +12 -0
- package/dist_ts/forwarding/config/domain-manager.d.ts +86 -0
- package/dist_ts/forwarding/config/domain-manager.js +242 -0
- package/dist_ts/forwarding/config/forwarding-types.d.ts +104 -0
- package/dist_ts/forwarding/config/forwarding-types.js +50 -0
- package/dist_ts/forwarding/config/index.d.ts +6 -0
- package/dist_ts/forwarding/config/index.js +7 -0
- package/dist_ts/forwarding/factory/forwarding-factory.d.ts +25 -0
- package/dist_ts/forwarding/factory/forwarding-factory.js +138 -0
- package/dist_ts/forwarding/factory/index.d.ts +4 -0
- package/dist_ts/forwarding/factory/index.js +5 -0
- package/dist_ts/forwarding/handlers/base-handler.d.ts +55 -0
- package/dist_ts/forwarding/handlers/base-handler.js +94 -0
- package/dist_ts/forwarding/handlers/http-handler.d.ts +30 -0
- package/dist_ts/forwarding/handlers/http-handler.js +131 -0
- package/dist_ts/forwarding/handlers/https-passthrough-handler.d.ts +29 -0
- package/dist_ts/forwarding/handlers/https-passthrough-handler.js +162 -0
- package/dist_ts/forwarding/handlers/https-terminate-to-http-handler.d.ts +36 -0
- package/dist_ts/forwarding/handlers/https-terminate-to-http-handler.js +229 -0
- package/dist_ts/forwarding/handlers/https-terminate-to-https-handler.d.ts +35 -0
- package/dist_ts/forwarding/handlers/https-terminate-to-https-handler.js +254 -0
- package/dist_ts/forwarding/handlers/index.d.ts +8 -0
- package/dist_ts/forwarding/handlers/index.js +9 -0
- package/dist_ts/forwarding/index.d.ts +19 -0
- package/dist_ts/forwarding/index.js +25 -0
- package/dist_ts/http/index.d.ts +15 -0
- package/dist_ts/http/index.js +20 -0
- package/dist_ts/http/models/http-types.d.ts +81 -0
- package/dist_ts/http/models/http-types.js +62 -0
- package/dist_ts/http/port80/acme-interfaces.d.ts +78 -0
- package/dist_ts/http/port80/acme-interfaces.js +6 -0
- package/dist_ts/http/port80/challenge-responder.d.ts +53 -0
- package/dist_ts/http/port80/challenge-responder.js +203 -0
- package/dist_ts/http/port80/index.d.ts +6 -0
- package/dist_ts/http/port80/index.js +9 -0
- package/dist_ts/http/port80/port80-handler.d.ts +121 -0
- package/dist_ts/http/port80/port80-handler.js +554 -0
- package/dist_ts/http/redirects/index.d.ts +4 -0
- package/dist_ts/http/redirects/index.js +5 -0
- package/dist_ts/http/router/index.d.ts +4 -0
- package/dist_ts/http/router/index.js +5 -0
- package/dist_ts/http/router/proxy-router.d.ts +115 -0
- package/dist_ts/http/router/proxy-router.js +325 -0
- package/dist_ts/index.d.ts +15 -8
- package/dist_ts/index.js +26 -10
- package/dist_ts/networkproxy/classes.np.certificatemanager.js +2 -2
- package/dist_ts/networkproxy/index.d.ts +1 -6
- package/dist_ts/networkproxy/index.js +4 -8
- package/dist_ts/plugins.d.ts +2 -1
- package/dist_ts/plugins.js +3 -2
- package/dist_ts/port80handler/classes.port80handler.d.ts +8 -136
- package/dist_ts/port80handler/classes.port80handler.js +14 -567
- package/dist_ts/proxies/index.d.ts +6 -0
- package/dist_ts/proxies/index.js +8 -0
- package/dist_ts/proxies/network-proxy/certificate-manager.d.ts +77 -0
- package/dist_ts/proxies/network-proxy/certificate-manager.js +373 -0
- package/dist_ts/proxies/network-proxy/connection-pool.d.ts +47 -0
- package/dist_ts/proxies/network-proxy/connection-pool.js +210 -0
- package/dist_ts/proxies/network-proxy/index.d.ts +10 -0
- package/dist_ts/proxies/network-proxy/index.js +12 -0
- package/dist_ts/proxies/network-proxy/models/index.d.ts +4 -0
- package/dist_ts/proxies/network-proxy/models/index.js +5 -0
- package/dist_ts/proxies/network-proxy/models/types.d.ts +80 -0
- package/dist_ts/proxies/network-proxy/models/types.js +35 -0
- package/dist_ts/proxies/network-proxy/network-proxy.d.ts +118 -0
- package/dist_ts/proxies/network-proxy/network-proxy.js +387 -0
- package/dist_ts/proxies/network-proxy/request-handler.d.ts +57 -0
- package/dist_ts/proxies/network-proxy/request-handler.js +394 -0
- package/dist_ts/proxies/network-proxy/websocket-handler.d.ts +38 -0
- package/dist_ts/proxies/network-proxy/websocket-handler.js +188 -0
- package/dist_ts/proxies/nftables-proxy/index.d.ts +5 -0
- package/dist_ts/proxies/nftables-proxy/index.js +6 -0
- package/dist_ts/proxies/nftables-proxy/models/errors.d.ts +15 -0
- package/dist_ts/proxies/nftables-proxy/models/errors.js +28 -0
- package/dist_ts/proxies/nftables-proxy/models/index.d.ts +5 -0
- package/dist_ts/proxies/nftables-proxy/models/index.js +6 -0
- package/dist_ts/proxies/nftables-proxy/models/interfaces.d.ts +75 -0
- package/dist_ts/proxies/nftables-proxy/models/interfaces.js +5 -0
- package/dist_ts/proxies/nftables-proxy/nftables-proxy.d.ts +136 -0
- package/dist_ts/proxies/nftables-proxy/nftables-proxy.js +1516 -0
- package/dist_ts/proxies/smart-proxy/connection-handler.d.ts +39 -0
- package/dist_ts/proxies/smart-proxy/connection-handler.js +894 -0
- package/dist_ts/proxies/smart-proxy/connection-manager.d.ts +78 -0
- package/dist_ts/proxies/smart-proxy/connection-manager.js +378 -0
- package/dist_ts/proxies/smart-proxy/domain-config-manager.d.ts +95 -0
- package/dist_ts/proxies/smart-proxy/domain-config-manager.js +255 -0
- package/dist_ts/proxies/smart-proxy/index.d.ts +13 -0
- package/dist_ts/proxies/smart-proxy/index.js +17 -0
- package/dist_ts/proxies/smart-proxy/models/index.d.ts +4 -0
- package/dist_ts/proxies/smart-proxy/models/index.js +5 -0
- package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +107 -0
- package/dist_ts/proxies/smart-proxy/models/interfaces.js +2 -0
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.d.ts +62 -0
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.js +316 -0
- package/dist_ts/proxies/smart-proxy/port-range-manager.d.ts +56 -0
- package/dist_ts/proxies/smart-proxy/port-range-manager.js +176 -0
- package/dist_ts/proxies/smart-proxy/security-manager.d.ts +64 -0
- package/dist_ts/proxies/smart-proxy/security-manager.js +149 -0
- package/dist_ts/proxies/smart-proxy/smart-proxy.d.ts +63 -0
- package/dist_ts/proxies/smart-proxy/smart-proxy.js +523 -0
- package/dist_ts/proxies/smart-proxy/timeout-manager.d.ts +47 -0
- package/dist_ts/proxies/smart-proxy/timeout-manager.js +154 -0
- package/dist_ts/proxies/smart-proxy/tls-manager.d.ts +57 -0
- package/dist_ts/proxies/smart-proxy/tls-manager.js +132 -0
- package/dist_ts/smartproxy/classes.pp.networkproxybridge.d.ts +2 -2
- package/dist_ts/smartproxy/classes.pp.networkproxybridge.js +1 -1
- package/dist_ts/smartproxy/classes.pp.tlsmanager.js +2 -2
- package/dist_ts/smartproxy/classes.smartproxy.js +3 -3
- package/dist_ts/tls/alerts/index.d.ts +4 -0
- package/dist_ts/tls/alerts/index.js +5 -0
- package/dist_ts/tls/alerts/tls-alert.d.ts +150 -0
- package/dist_ts/tls/alerts/tls-alert.js +226 -0
- package/dist_ts/tls/index.d.ts +18 -0
- package/dist_ts/tls/index.js +27 -0
- package/dist_ts/tls/sni/client-hello-parser.d.ts +100 -0
- package/dist_ts/tls/sni/client-hello-parser.js +463 -0
- package/dist_ts/tls/sni/index.d.ts +4 -0
- package/dist_ts/tls/sni/index.js +5 -0
- package/dist_ts/tls/sni/sni-extraction.d.ts +58 -0
- package/dist_ts/tls/sni/sni-extraction.js +275 -0
- package/dist_ts/tls/sni/sni-handler.d.ts +154 -0
- package/dist_ts/tls/sni/sni-handler.js +191 -0
- package/dist_ts/tls/utils/index.d.ts +4 -0
- package/dist_ts/tls/utils/index.js +5 -0
- package/dist_ts/tls/utils/tls-utils.d.ts +158 -0
- package/dist_ts/tls/utils/tls-utils.js +187 -0
- package/package.json +1 -1
- package/readme.md +89 -21
- package/readme.plan.md +253 -469
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/certificate/acme/acme-factory.ts +48 -0
- package/ts/certificate/acme/challenge-handler.ts +110 -0
- package/ts/certificate/acme/index.ts +3 -0
- package/ts/certificate/events/certificate-events.ts +36 -0
- package/ts/certificate/index.ts +67 -0
- package/ts/certificate/models/certificate-types.ts +88 -0
- package/ts/certificate/providers/cert-provisioner.ts +326 -0
- package/ts/certificate/providers/index.ts +3 -0
- package/ts/certificate/storage/file-storage.ts +234 -0
- package/ts/certificate/storage/index.ts +3 -0
- package/ts/certificate/utils/certificate-helpers.ts +50 -0
- package/ts/common/eventUtils.ts +1 -1
- package/ts/common/port80-adapter.ts +1 -1
- package/ts/core/events/index.ts +3 -0
- package/ts/core/index.ts +8 -0
- package/ts/core/models/common-types.ts +91 -0
- package/ts/core/models/index.ts +5 -0
- package/ts/core/utils/event-utils.ts +34 -0
- package/ts/core/utils/index.ts +7 -0
- package/ts/core/utils/ip-utils.ts +175 -0
- package/ts/core/utils/validation-utils.ts +177 -0
- package/ts/{smartproxy/forwarding → forwarding/config}/domain-config.ts +1 -1
- package/ts/{smartproxy/forwarding → forwarding/config}/domain-manager.ts +8 -8
- package/ts/{smartproxy/types/forwarding.types.ts → forwarding/config/forwarding-types.ts} +6 -6
- package/ts/forwarding/config/index.ts +7 -0
- package/ts/{smartproxy/forwarding/forwarding.factory.ts → forwarding/factory/forwarding-factory.ts} +12 -11
- package/ts/forwarding/factory/index.ts +5 -0
- package/ts/{smartproxy/forwarding/forwarding.handler.ts → forwarding/handlers/base-handler.ts} +2 -2
- package/ts/{smartproxy/forwarding/http.handler.ts → forwarding/handlers/http-handler.ts} +13 -4
- package/ts/{smartproxy/forwarding/https-passthrough.handler.ts → forwarding/handlers/https-passthrough-handler.ts} +13 -4
- package/ts/{smartproxy/forwarding/https-terminate-to-http.handler.ts → forwarding/handlers/https-terminate-to-http-handler.ts} +3 -3
- package/ts/{smartproxy/forwarding/https-terminate-to-https.handler.ts → forwarding/handlers/https-terminate-to-https-handler.ts} +3 -3
- package/ts/forwarding/handlers/index.ts +9 -0
- package/ts/forwarding/index.ts +34 -0
- package/ts/http/index.ts +23 -0
- package/ts/http/models/http-types.ts +105 -0
- package/ts/http/port80/acme-interfaces.ts +85 -0
- package/ts/http/port80/challenge-responder.ts +246 -0
- package/ts/http/port80/index.ts +13 -0
- package/ts/{port80handler/classes.port80handler.ts → http/port80/port80-handler.ts} +164 -161
- package/ts/http/redirects/index.ts +3 -0
- package/ts/http/router/index.ts +5 -0
- package/ts/{classes.router.ts → http/router/proxy-router.ts} +27 -20
- package/ts/index.ts +32 -9
- package/ts/plugins.ts +2 -1
- package/ts/proxies/index.ts +8 -0
- package/ts/{networkproxy/classes.np.certificatemanager.ts → proxies/network-proxy/certificate-manager.ts} +17 -16
- package/ts/{networkproxy/classes.np.connectionpool.ts → proxies/network-proxy/connection-pool.ts} +3 -3
- package/ts/proxies/network-proxy/index.ts +13 -0
- package/ts/proxies/network-proxy/models/index.ts +4 -0
- package/ts/{networkproxy/classes.np.types.ts → proxies/network-proxy/models/types.ts} +7 -11
- package/ts/{networkproxy/classes.np.networkproxy.ts → proxies/network-proxy/network-proxy.ts} +31 -24
- package/ts/{networkproxy/classes.np.requesthandler.ts → proxies/network-proxy/request-handler.ts} +12 -7
- package/ts/{networkproxy/classes.np.websockethandler.ts → proxies/network-proxy/websocket-handler.ts} +6 -6
- package/ts/proxies/nftables-proxy/index.ts +5 -0
- package/ts/proxies/nftables-proxy/models/errors.ts +30 -0
- package/ts/proxies/nftables-proxy/models/index.ts +5 -0
- package/ts/proxies/nftables-proxy/models/interfaces.ts +94 -0
- package/ts/{nfttablesproxy/classes.nftablesproxy.ts → proxies/nftables-proxy/nftables-proxy.ts} +24 -126
- package/ts/{smartproxy/classes.pp.connectionhandler.ts → proxies/smart-proxy/connection-handler.ts} +12 -12
- package/ts/{smartproxy/classes.pp.connectionmanager.ts → proxies/smart-proxy/connection-manager.ts} +8 -8
- package/ts/{smartproxy/classes.pp.domainconfigmanager.ts → proxies/smart-proxy/domain-config-manager.ts} +15 -14
- package/ts/proxies/smart-proxy/index.ts +18 -0
- package/ts/proxies/smart-proxy/models/index.ts +4 -0
- package/ts/{smartproxy/classes.pp.interfaces.ts → proxies/smart-proxy/models/interfaces.ts} +12 -8
- package/ts/{smartproxy/classes.pp.networkproxybridge.ts → proxies/smart-proxy/network-proxy-bridge.ts} +14 -14
- package/ts/{smartproxy/classes.pp.portrangemanager.ts → proxies/smart-proxy/port-range-manager.ts} +1 -1
- package/ts/{smartproxy/classes.pp.securitymanager.ts → proxies/smart-proxy/security-manager.ts} +3 -3
- package/ts/{smartproxy/classes.smartproxy.ts → proxies/smart-proxy/smart-proxy.ts} +29 -24
- package/ts/{smartproxy/classes.pp.timeoutmanager.ts → proxies/smart-proxy/timeout-manager.ts} +3 -3
- package/ts/{smartproxy/classes.pp.tlsmanager.ts → proxies/smart-proxy/tls-manager.ts} +3 -3
- package/ts/tls/alerts/index.ts +3 -0
- package/ts/{smartproxy/classes.pp.tlsalert.ts → tls/alerts/tls-alert.ts} +44 -43
- package/ts/tls/index.ts +33 -0
- package/ts/tls/sni/client-hello-parser.ts +629 -0
- package/ts/tls/sni/index.ts +3 -0
- package/ts/tls/sni/sni-extraction.ts +353 -0
- package/ts/tls/sni/sni-handler.ts +264 -0
- package/ts/tls/utils/index.ts +3 -0
- package/ts/tls/utils/tls-utils.ts +201 -0
- package/ts/common/acmeFactory.ts +0 -23
- package/ts/helpers.certificates.ts +0 -30
- package/ts/networkproxy/index.ts +0 -7
- package/ts/smartproxy/classes.pp.certprovisioner.ts +0 -200
- package/ts/smartproxy/classes.pp.snihandler.ts +0 -1281
- package/ts/smartproxy/forwarding/index.ts +0 -52
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import * as plugins from '../../plugins.js';
|
|
2
|
+
import type { IDomainOptions, IAcmeOptions } from '../models/common-types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Collection of validation utilities for configuration and domain options
|
|
6
|
+
*/
|
|
7
|
+
export class ValidationUtils {
|
|
8
|
+
/**
|
|
9
|
+
* Validates domain configuration options
|
|
10
|
+
*
|
|
11
|
+
* @param domainOptions The domain options to validate
|
|
12
|
+
* @returns An object with validation result and error message if invalid
|
|
13
|
+
*/
|
|
14
|
+
public static validateDomainOptions(domainOptions: IDomainOptions): { isValid: boolean; error?: string } {
|
|
15
|
+
if (!domainOptions) {
|
|
16
|
+
return { isValid: false, error: 'Domain options cannot be null or undefined' };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!domainOptions.domainName) {
|
|
20
|
+
return { isValid: false, error: 'Domain name is required' };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Check domain pattern
|
|
24
|
+
if (!this.isValidDomainName(domainOptions.domainName)) {
|
|
25
|
+
return { isValid: false, error: `Invalid domain name: ${domainOptions.domainName}` };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Validate forward config if provided
|
|
29
|
+
if (domainOptions.forward) {
|
|
30
|
+
if (!domainOptions.forward.ip) {
|
|
31
|
+
return { isValid: false, error: 'Forward IP is required when forward is specified' };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!domainOptions.forward.port) {
|
|
35
|
+
return { isValid: false, error: 'Forward port is required when forward is specified' };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!this.isValidPort(domainOptions.forward.port)) {
|
|
39
|
+
return { isValid: false, error: `Invalid forward port: ${domainOptions.forward.port}` };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Validate ACME forward config if provided
|
|
44
|
+
if (domainOptions.acmeForward) {
|
|
45
|
+
if (!domainOptions.acmeForward.ip) {
|
|
46
|
+
return { isValid: false, error: 'ACME forward IP is required when acmeForward is specified' };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!domainOptions.acmeForward.port) {
|
|
50
|
+
return { isValid: false, error: 'ACME forward port is required when acmeForward is specified' };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!this.isValidPort(domainOptions.acmeForward.port)) {
|
|
54
|
+
return { isValid: false, error: `Invalid ACME forward port: ${domainOptions.acmeForward.port}` };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return { isValid: true };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Validates ACME configuration options
|
|
63
|
+
*
|
|
64
|
+
* @param acmeOptions The ACME options to validate
|
|
65
|
+
* @returns An object with validation result and error message if invalid
|
|
66
|
+
*/
|
|
67
|
+
public static validateAcmeOptions(acmeOptions: IAcmeOptions): { isValid: boolean; error?: string } {
|
|
68
|
+
if (!acmeOptions) {
|
|
69
|
+
return { isValid: false, error: 'ACME options cannot be null or undefined' };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (acmeOptions.enabled) {
|
|
73
|
+
if (!acmeOptions.accountEmail) {
|
|
74
|
+
return { isValid: false, error: 'Account email is required when ACME is enabled' };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!this.isValidEmail(acmeOptions.accountEmail)) {
|
|
78
|
+
return { isValid: false, error: `Invalid email: ${acmeOptions.accountEmail}` };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (acmeOptions.port && !this.isValidPort(acmeOptions.port)) {
|
|
82
|
+
return { isValid: false, error: `Invalid ACME port: ${acmeOptions.port}` };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (acmeOptions.httpsRedirectPort && !this.isValidPort(acmeOptions.httpsRedirectPort)) {
|
|
86
|
+
return { isValid: false, error: `Invalid HTTPS redirect port: ${acmeOptions.httpsRedirectPort}` };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (acmeOptions.renewThresholdDays && acmeOptions.renewThresholdDays < 1) {
|
|
90
|
+
return { isValid: false, error: 'Renew threshold days must be greater than 0' };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (acmeOptions.renewCheckIntervalHours && acmeOptions.renewCheckIntervalHours < 1) {
|
|
94
|
+
return { isValid: false, error: 'Renew check interval hours must be greater than 0' };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return { isValid: true };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Validates a port number
|
|
103
|
+
*
|
|
104
|
+
* @param port The port to validate
|
|
105
|
+
* @returns true if the port is valid, false otherwise
|
|
106
|
+
*/
|
|
107
|
+
public static isValidPort(port: number): boolean {
|
|
108
|
+
return typeof port === 'number' && port > 0 && port <= 65535 && Number.isInteger(port);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Validates a domain name
|
|
113
|
+
*
|
|
114
|
+
* @param domain The domain name to validate
|
|
115
|
+
* @returns true if the domain name is valid, false otherwise
|
|
116
|
+
*/
|
|
117
|
+
public static isValidDomainName(domain: string): boolean {
|
|
118
|
+
if (!domain || typeof domain !== 'string') {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Wildcard domain check (*.example.com)
|
|
123
|
+
if (domain.startsWith('*.')) {
|
|
124
|
+
domain = domain.substring(2);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Simple domain validation pattern
|
|
128
|
+
const domainPattern = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
129
|
+
return domainPattern.test(domain);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Validates an email address
|
|
134
|
+
*
|
|
135
|
+
* @param email The email to validate
|
|
136
|
+
* @returns true if the email is valid, false otherwise
|
|
137
|
+
*/
|
|
138
|
+
public static isValidEmail(email: string): boolean {
|
|
139
|
+
if (!email || typeof email !== 'string') {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Basic email validation pattern
|
|
144
|
+
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
145
|
+
return emailPattern.test(email);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Validates a certificate format (PEM)
|
|
150
|
+
*
|
|
151
|
+
* @param cert The certificate content to validate
|
|
152
|
+
* @returns true if the certificate appears to be in PEM format, false otherwise
|
|
153
|
+
*/
|
|
154
|
+
public static isValidCertificate(cert: string): boolean {
|
|
155
|
+
if (!cert || typeof cert !== 'string') {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return cert.includes('-----BEGIN CERTIFICATE-----') &&
|
|
160
|
+
cert.includes('-----END CERTIFICATE-----');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Validates a private key format (PEM)
|
|
165
|
+
*
|
|
166
|
+
* @param key The private key content to validate
|
|
167
|
+
* @returns true if the key appears to be in PEM format, false otherwise
|
|
168
|
+
*/
|
|
169
|
+
public static isValidPrivateKey(key: string): boolean {
|
|
170
|
+
if (!key || typeof key !== 'string') {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return key.includes('-----BEGIN PRIVATE KEY-----') &&
|
|
175
|
+
key.includes('-----END PRIVATE KEY-----');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
2
|
import type { IDomainConfig } from './domain-config.js';
|
|
3
|
-
import
|
|
4
|
-
import { ForwardingHandlerEvents } from '
|
|
5
|
-
import { ForwardingHandlerFactory } from '
|
|
3
|
+
import { ForwardingHandler } from '../handlers/base-handler.js';
|
|
4
|
+
import { ForwardingHandlerEvents } from './forwarding-types.js';
|
|
5
|
+
import { ForwardingHandlerFactory } from '../factory/forwarding-factory.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Events emitted by the DomainManager
|
|
@@ -22,8 +22,8 @@ export enum DomainManagerEvents {
|
|
|
22
22
|
*/
|
|
23
23
|
export class DomainManager extends plugins.EventEmitter {
|
|
24
24
|
private domainConfigs: IDomainConfig[] = [];
|
|
25
|
-
private domainHandlers: Map<string,
|
|
26
|
-
|
|
25
|
+
private domainHandlers: Map<string, ForwardingHandler> = new Map();
|
|
26
|
+
|
|
27
27
|
/**
|
|
28
28
|
* Create a new DomainManager
|
|
29
29
|
* @param initialDomains Optional initial domain configurations
|
|
@@ -116,7 +116,7 @@ export class DomainManager extends plugins.EventEmitter {
|
|
|
116
116
|
* @param domain The domain to find a handler for
|
|
117
117
|
* @returns The handler or undefined if no match
|
|
118
118
|
*/
|
|
119
|
-
public findHandlerForDomain(domain: string):
|
|
119
|
+
public findHandlerForDomain(domain: string): ForwardingHandler | undefined {
|
|
120
120
|
// Try exact match
|
|
121
121
|
if (this.domainHandlers.has(domain)) {
|
|
122
122
|
return this.domainHandlers.get(domain);
|
|
@@ -221,7 +221,7 @@ export class DomainManager extends plugins.EventEmitter {
|
|
|
221
221
|
* @param handler The handler
|
|
222
222
|
* @param config The domain configuration for this handler
|
|
223
223
|
*/
|
|
224
|
-
private setupHandlerEvents(handler:
|
|
224
|
+
private setupHandlerEvents(handler: ForwardingHandler, config: IDomainConfig): void {
|
|
225
225
|
// Forward relevant events
|
|
226
226
|
handler.on(ForwardingHandlerEvents.CERTIFICATE_NEEDED, (data) => {
|
|
227
227
|
this.emit(DomainManagerEvents.CERTIFICATE_NEEDED, {
|
|
@@ -250,7 +250,7 @@ export class DomainManager extends plugins.EventEmitter {
|
|
|
250
250
|
* @param domain The domain to find a handler for
|
|
251
251
|
* @returns The handler or undefined if no match
|
|
252
252
|
*/
|
|
253
|
-
private findWildcardHandler(domain: string):
|
|
253
|
+
private findWildcardHandler(domain: string): ForwardingHandler | undefined {
|
|
254
254
|
// Exact match already checked in findHandlerForDomain
|
|
255
255
|
|
|
256
256
|
// Try subdomain wildcard (*.example.com)
|
|
@@ -3,7 +3,7 @@ import type * as plugins from '../../plugins.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* The primary forwarding types supported by SmartProxy
|
|
5
5
|
*/
|
|
6
|
-
export type
|
|
6
|
+
export type TForwardingType =
|
|
7
7
|
| 'http-only' // HTTP forwarding only (no HTTPS)
|
|
8
8
|
| 'https-passthrough' // Pass-through TLS traffic (SNI forwarding)
|
|
9
9
|
| 'https-terminate-to-http' // Terminate TLS and forward to HTTP backend
|
|
@@ -41,7 +41,7 @@ export interface IHttpsOptions {
|
|
|
41
41
|
* ACME certificate handling options
|
|
42
42
|
*/
|
|
43
43
|
export interface IAcmeForwardingOptions {
|
|
44
|
-
enabled?: boolean; // Enable ACME certificate provisioning
|
|
44
|
+
enabled?: boolean; // Enable ACME certificate provisioning
|
|
45
45
|
maintenance?: boolean; // Auto-renew certificates
|
|
46
46
|
production?: boolean; // Use production ACME servers
|
|
47
47
|
forwardChallenges?: { // Forward ACME challenges
|
|
@@ -76,16 +76,16 @@ export interface IAdvancedOptions {
|
|
|
76
76
|
*/
|
|
77
77
|
export interface IForwardConfig {
|
|
78
78
|
// Define the primary forwarding type - use-case driven approach
|
|
79
|
-
type:
|
|
80
|
-
|
|
79
|
+
type: TForwardingType;
|
|
80
|
+
|
|
81
81
|
// Target configuration
|
|
82
82
|
target: ITargetConfig;
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
// Protocol options
|
|
85
85
|
http?: IHttpOptions;
|
|
86
86
|
https?: IHttpsOptions;
|
|
87
87
|
acme?: IAcmeForwardingOptions;
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
// Security and advanced options
|
|
90
90
|
security?: ISecurityOptions;
|
|
91
91
|
advanced?: IAdvancedOptions;
|
package/ts/{smartproxy/forwarding/forwarding.factory.ts → forwarding/factory/forwarding-factory.ts}
RENAMED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { IForwardConfig
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { IForwardConfig } from '../config/forwarding-types.js';
|
|
2
|
+
import { ForwardingHandler } from '../handlers/base-handler.js';
|
|
3
|
+
import { HttpForwardingHandler } from '../handlers/http-handler.js';
|
|
4
|
+
import { HttpsPassthroughHandler } from '../handlers/https-passthrough-handler.js';
|
|
5
|
+
import { HttpsTerminateToHttpHandler } from '../handlers/https-terminate-to-http-handler.js';
|
|
6
|
+
import { HttpsTerminateToHttpsHandler } from '../handlers/https-terminate-to-https-handler.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Factory for creating forwarding handlers based on the configuration type
|
|
@@ -13,27 +14,27 @@ export class ForwardingHandlerFactory {
|
|
|
13
14
|
* @param config The forwarding configuration
|
|
14
15
|
* @returns The appropriate forwarding handler
|
|
15
16
|
*/
|
|
16
|
-
public static createHandler(config: IForwardConfig):
|
|
17
|
+
public static createHandler(config: IForwardConfig): ForwardingHandler {
|
|
17
18
|
// Create the appropriate handler based on the forwarding type
|
|
18
19
|
switch (config.type) {
|
|
19
20
|
case 'http-only':
|
|
20
21
|
return new HttpForwardingHandler(config);
|
|
21
|
-
|
|
22
|
+
|
|
22
23
|
case 'https-passthrough':
|
|
23
24
|
return new HttpsPassthroughHandler(config);
|
|
24
|
-
|
|
25
|
+
|
|
25
26
|
case 'https-terminate-to-http':
|
|
26
27
|
return new HttpsTerminateToHttpHandler(config);
|
|
27
|
-
|
|
28
|
+
|
|
28
29
|
case 'https-terminate-to-https':
|
|
29
30
|
return new HttpsTerminateToHttpsHandler(config);
|
|
30
|
-
|
|
31
|
+
|
|
31
32
|
default:
|
|
32
33
|
// Type system should prevent this, but just in case:
|
|
33
34
|
throw new Error(`Unknown forwarding type: ${(config as any).type}`);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
/**
|
|
38
39
|
* Apply default values to a forwarding configuration based on its type
|
|
39
40
|
* @param config The original forwarding configuration
|
package/ts/{smartproxy/forwarding/forwarding.handler.ts → forwarding/handlers/base-handler.ts}
RENAMED
|
@@ -2,8 +2,8 @@ import * as plugins from '../../plugins.js';
|
|
|
2
2
|
import type {
|
|
3
3
|
IForwardConfig,
|
|
4
4
|
IForwardingHandler
|
|
5
|
-
} from '../
|
|
6
|
-
import { ForwardingHandlerEvents } from '../
|
|
5
|
+
} from '../config/forwarding-types.js';
|
|
6
|
+
import { ForwardingHandlerEvents } from '../config/forwarding-types.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Base class for all forwarding handlers
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
|
-
import { ForwardingHandler } from './
|
|
3
|
-
import type { IForwardConfig } from '../
|
|
4
|
-
import { ForwardingHandlerEvents } from '../
|
|
2
|
+
import { ForwardingHandler } from './base-handler.js';
|
|
3
|
+
import type { IForwardConfig } from '../config/forwarding-types.js';
|
|
4
|
+
import { ForwardingHandlerEvents } from '../config/forwarding-types.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Handler for HTTP-only forwarding
|
|
@@ -13,12 +13,21 @@ export class HttpForwardingHandler extends ForwardingHandler {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(config: IForwardConfig) {
|
|
15
15
|
super(config);
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
// Validate that this is an HTTP-only configuration
|
|
18
18
|
if (config.type !== 'http-only') {
|
|
19
19
|
throw new Error(`Invalid configuration type for HttpForwardingHandler: ${config.type}`);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the handler
|
|
25
|
+
* HTTP handler doesn't need special initialization
|
|
26
|
+
*/
|
|
27
|
+
public async initialize(): Promise<void> {
|
|
28
|
+
// Basic initialization from parent class
|
|
29
|
+
await super.initialize();
|
|
30
|
+
}
|
|
22
31
|
|
|
23
32
|
/**
|
|
24
33
|
* Handle a raw socket connection
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
|
-
import { ForwardingHandler } from './
|
|
3
|
-
import type { IForwardConfig } from '../
|
|
4
|
-
import { ForwardingHandlerEvents } from '../
|
|
2
|
+
import { ForwardingHandler } from './base-handler.js';
|
|
3
|
+
import type { IForwardConfig } from '../config/forwarding-types.js';
|
|
4
|
+
import { ForwardingHandlerEvents } from '../config/forwarding-types.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Handler for HTTPS passthrough (SNI forwarding without termination)
|
|
@@ -13,12 +13,21 @@ export class HttpsPassthroughHandler extends ForwardingHandler {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(config: IForwardConfig) {
|
|
15
15
|
super(config);
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
// Validate that this is an HTTPS passthrough configuration
|
|
18
18
|
if (config.type !== 'https-passthrough') {
|
|
19
19
|
throw new Error(`Invalid configuration type for HttpsPassthroughHandler: ${config.type}`);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the handler
|
|
25
|
+
* HTTPS passthrough handler doesn't need special initialization
|
|
26
|
+
*/
|
|
27
|
+
public async initialize(): Promise<void> {
|
|
28
|
+
// Basic initialization from parent class
|
|
29
|
+
await super.initialize();
|
|
30
|
+
}
|
|
22
31
|
|
|
23
32
|
/**
|
|
24
33
|
* Handle a TLS/SSL socket connection by forwarding it without termination
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
|
-
import { ForwardingHandler } from './
|
|
3
|
-
import type { IForwardConfig } from '../
|
|
4
|
-
import { ForwardingHandlerEvents } from '../
|
|
2
|
+
import { ForwardingHandler } from './base-handler.js';
|
|
3
|
+
import type { IForwardConfig } from '../config/forwarding-types.js';
|
|
4
|
+
import { ForwardingHandlerEvents } from '../config/forwarding-types.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Handler for HTTPS termination with HTTP backend
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
|
-
import { ForwardingHandler } from './
|
|
3
|
-
import type { IForwardConfig } from '../
|
|
4
|
-
import { ForwardingHandlerEvents } from '../
|
|
2
|
+
import { ForwardingHandler } from './base-handler.js';
|
|
3
|
+
import type { IForwardConfig } from '../config/forwarding-types.js';
|
|
4
|
+
import { ForwardingHandlerEvents } from '../config/forwarding-types.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Handler for HTTPS termination with HTTPS backend
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forwarding handler implementations
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { ForwardingHandler } from './base-handler.js';
|
|
6
|
+
export { HttpForwardingHandler } from './http-handler.js';
|
|
7
|
+
export { HttpsPassthroughHandler } from './https-passthrough-handler.js';
|
|
8
|
+
export { HttpsTerminateToHttpHandler } from './https-terminate-to-http-handler.js';
|
|
9
|
+
export { HttpsTerminateToHttpsHandler } from './https-terminate-to-https-handler.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forwarding system module
|
|
3
|
+
* Provides a flexible and type-safe way to configure and manage various forwarding strategies
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Export types and configuration
|
|
7
|
+
export * from './config/forwarding-types.js';
|
|
8
|
+
export * from './config/domain-config.js';
|
|
9
|
+
export * from './config/domain-manager.js';
|
|
10
|
+
|
|
11
|
+
// Export handlers
|
|
12
|
+
export { ForwardingHandler } from './handlers/base-handler.js';
|
|
13
|
+
export * from './handlers/http-handler.js';
|
|
14
|
+
export * from './handlers/https-passthrough-handler.js';
|
|
15
|
+
export * from './handlers/https-terminate-to-http-handler.js';
|
|
16
|
+
export * from './handlers/https-terminate-to-https-handler.js';
|
|
17
|
+
|
|
18
|
+
// Export factory
|
|
19
|
+
export * from './factory/forwarding-factory.js';
|
|
20
|
+
|
|
21
|
+
// Helper functions as a convenience object
|
|
22
|
+
import {
|
|
23
|
+
httpOnly,
|
|
24
|
+
tlsTerminateToHttp,
|
|
25
|
+
tlsTerminateToHttps,
|
|
26
|
+
httpsPassthrough
|
|
27
|
+
} from './config/forwarding-types.js';
|
|
28
|
+
|
|
29
|
+
export const helpers = {
|
|
30
|
+
httpOnly,
|
|
31
|
+
tlsTerminateToHttp,
|
|
32
|
+
tlsTerminateToHttps,
|
|
33
|
+
httpsPassthrough
|
|
34
|
+
};
|
package/ts/http/index.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP functionality module
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Export types and models
|
|
6
|
+
export * from './models/http-types.js';
|
|
7
|
+
|
|
8
|
+
// Export submodules
|
|
9
|
+
export * from './port80/index.js';
|
|
10
|
+
export * from './router/index.js';
|
|
11
|
+
export * from './redirects/index.js';
|
|
12
|
+
|
|
13
|
+
// Import the components we need for the namespace
|
|
14
|
+
import { Port80Handler } from './port80/port80-handler.js';
|
|
15
|
+
import { ChallengeResponder } from './port80/challenge-responder.js';
|
|
16
|
+
|
|
17
|
+
// Convenience namespace exports
|
|
18
|
+
export const Http = {
|
|
19
|
+
Port80: {
|
|
20
|
+
Handler: Port80Handler,
|
|
21
|
+
ChallengeResponder: ChallengeResponder
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as plugins from '../../plugins.js';
|
|
2
|
+
import type {
|
|
3
|
+
IForwardConfig,
|
|
4
|
+
IDomainOptions,
|
|
5
|
+
IAcmeOptions
|
|
6
|
+
} from '../../certificate/models/certificate-types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* HTTP-specific event types
|
|
10
|
+
*/
|
|
11
|
+
export enum HttpEvents {
|
|
12
|
+
REQUEST_RECEIVED = 'request-received',
|
|
13
|
+
REQUEST_FORWARDED = 'request-forwarded',
|
|
14
|
+
REQUEST_HANDLED = 'request-handled',
|
|
15
|
+
REQUEST_ERROR = 'request-error',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* HTTP status codes as an enum for better type safety
|
|
20
|
+
*/
|
|
21
|
+
export enum HttpStatus {
|
|
22
|
+
OK = 200,
|
|
23
|
+
MOVED_PERMANENTLY = 301,
|
|
24
|
+
FOUND = 302,
|
|
25
|
+
TEMPORARY_REDIRECT = 307,
|
|
26
|
+
PERMANENT_REDIRECT = 308,
|
|
27
|
+
BAD_REQUEST = 400,
|
|
28
|
+
NOT_FOUND = 404,
|
|
29
|
+
METHOD_NOT_ALLOWED = 405,
|
|
30
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
31
|
+
NOT_IMPLEMENTED = 501,
|
|
32
|
+
SERVICE_UNAVAILABLE = 503,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Represents a domain configuration with certificate status information
|
|
37
|
+
*/
|
|
38
|
+
export interface IDomainCertificate {
|
|
39
|
+
options: IDomainOptions;
|
|
40
|
+
certObtained: boolean;
|
|
41
|
+
obtainingInProgress: boolean;
|
|
42
|
+
certificate?: string;
|
|
43
|
+
privateKey?: string;
|
|
44
|
+
expiryDate?: Date;
|
|
45
|
+
lastRenewalAttempt?: Date;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Base error class for HTTP-related errors
|
|
50
|
+
*/
|
|
51
|
+
export class HttpError extends Error {
|
|
52
|
+
constructor(message: string) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = 'HttpError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Error related to certificate operations
|
|
60
|
+
*/
|
|
61
|
+
export class CertificateError extends HttpError {
|
|
62
|
+
constructor(
|
|
63
|
+
message: string,
|
|
64
|
+
public readonly domain: string,
|
|
65
|
+
public readonly isRenewal: boolean = false
|
|
66
|
+
) {
|
|
67
|
+
super(`${message} for domain ${domain}${isRenewal ? ' (renewal)' : ''}`);
|
|
68
|
+
this.name = 'CertificateError';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Error related to server operations
|
|
74
|
+
*/
|
|
75
|
+
export class ServerError extends HttpError {
|
|
76
|
+
constructor(message: string, public readonly code?: string) {
|
|
77
|
+
super(message);
|
|
78
|
+
this.name = 'ServerError';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Redirect configuration for HTTP requests
|
|
84
|
+
*/
|
|
85
|
+
export interface IRedirectConfig {
|
|
86
|
+
source: string; // Source path or pattern
|
|
87
|
+
destination: string; // Destination URL
|
|
88
|
+
type: HttpStatus; // Redirect status code
|
|
89
|
+
preserveQuery?: boolean; // Whether to preserve query parameters
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* HTTP router configuration
|
|
94
|
+
*/
|
|
95
|
+
export interface IRouterConfig {
|
|
96
|
+
routes: Array<{
|
|
97
|
+
path: string;
|
|
98
|
+
handler: (req: plugins.http.IncomingMessage, res: plugins.http.ServerResponse) => void;
|
|
99
|
+
}>;
|
|
100
|
+
notFoundHandler?: (req: plugins.http.IncomingMessage, res: plugins.http.ServerResponse) => void;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Backward compatibility interfaces
|
|
104
|
+
export { HttpError as Port80HandlerError };
|
|
105
|
+
export { CertificateError as CertError };
|