@push.rocks/smartproxy 21.1.7 → 22.6.0

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.
Files changed (155) hide show
  1. package/changelog.md +109 -0
  2. package/dist_rust/rustproxy +0 -0
  3. package/dist_ts/00_commitinfo_data.js +1 -1
  4. package/dist_ts/core/utils/shared-security-manager.d.ts +17 -0
  5. package/dist_ts/core/utils/shared-security-manager.js +66 -1
  6. package/dist_ts/index.d.ts +1 -5
  7. package/dist_ts/index.js +3 -9
  8. package/dist_ts/protocols/common/fragment-handler.js +5 -1
  9. package/dist_ts/proxies/http-proxy/default-certificates.d.ts +54 -0
  10. package/dist_ts/proxies/http-proxy/default-certificates.js +127 -0
  11. package/dist_ts/proxies/http-proxy/http-proxy.d.ts +1 -1
  12. package/dist_ts/proxies/http-proxy/http-proxy.js +9 -14
  13. package/dist_ts/proxies/http-proxy/index.d.ts +5 -1
  14. package/dist_ts/proxies/http-proxy/index.js +6 -2
  15. package/dist_ts/proxies/http-proxy/security-manager.d.ts +4 -12
  16. package/dist_ts/proxies/http-proxy/security-manager.js +66 -99
  17. package/dist_ts/proxies/index.d.ts +1 -5
  18. package/dist_ts/proxies/index.js +2 -6
  19. package/dist_ts/proxies/nftables-proxy/index.d.ts +1 -0
  20. package/dist_ts/proxies/nftables-proxy/index.js +2 -1
  21. package/dist_ts/proxies/nftables-proxy/nftables-proxy.d.ts +4 -26
  22. package/dist_ts/proxies/nftables-proxy/nftables-proxy.js +84 -236
  23. package/dist_ts/proxies/nftables-proxy/utils/index.d.ts +9 -0
  24. package/dist_ts/proxies/nftables-proxy/utils/index.js +12 -0
  25. package/dist_ts/proxies/nftables-proxy/utils/nft-command-executor.d.ts +66 -0
  26. package/dist_ts/proxies/nftables-proxy/utils/nft-command-executor.js +131 -0
  27. package/dist_ts/proxies/nftables-proxy/utils/nft-port-spec-normalizer.d.ts +39 -0
  28. package/dist_ts/proxies/nftables-proxy/utils/nft-port-spec-normalizer.js +112 -0
  29. package/dist_ts/proxies/nftables-proxy/utils/nft-rule-validator.d.ts +59 -0
  30. package/dist_ts/proxies/nftables-proxy/utils/nft-rule-validator.js +130 -0
  31. package/dist_ts/proxies/smart-proxy/certificate-manager.js +4 -3
  32. package/dist_ts/proxies/smart-proxy/connection-manager.d.ts +13 -2
  33. package/dist_ts/proxies/smart-proxy/connection-manager.js +16 -6
  34. package/dist_ts/proxies/smart-proxy/http-proxy-bridge.js +35 -10
  35. package/dist_ts/proxies/smart-proxy/index.d.ts +5 -10
  36. package/dist_ts/proxies/smart-proxy/index.js +7 -13
  37. package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +5 -3
  38. package/dist_ts/proxies/smart-proxy/route-connection-handler.d.ts +17 -0
  39. package/dist_ts/proxies/smart-proxy/route-connection-handler.js +72 -9
  40. package/dist_ts/proxies/smart-proxy/route-preprocessor.d.ts +37 -0
  41. package/dist_ts/proxies/smart-proxy/route-preprocessor.js +103 -0
  42. package/dist_ts/proxies/smart-proxy/rust-binary-locator.d.ts +23 -0
  43. package/dist_ts/proxies/smart-proxy/rust-binary-locator.js +104 -0
  44. package/dist_ts/proxies/smart-proxy/rust-metrics-adapter.d.ts +74 -0
  45. package/dist_ts/proxies/smart-proxy/rust-metrics-adapter.js +146 -0
  46. package/dist_ts/proxies/smart-proxy/rust-proxy-bridge.d.ts +49 -0
  47. package/dist_ts/proxies/smart-proxy/rust-proxy-bridge.js +259 -0
  48. package/dist_ts/proxies/smart-proxy/security-manager.d.ts +14 -12
  49. package/dist_ts/proxies/smart-proxy/security-manager.js +80 -74
  50. package/dist_ts/proxies/smart-proxy/smart-proxy.d.ts +39 -157
  51. package/dist_ts/proxies/smart-proxy/smart-proxy.js +224 -622
  52. package/dist_ts/proxies/smart-proxy/socket-handler-server.d.ts +45 -0
  53. package/dist_ts/proxies/smart-proxy/socket-handler-server.js +253 -0
  54. package/dist_ts/proxies/smart-proxy/tls-manager.d.ts +2 -9
  55. package/dist_ts/proxies/smart-proxy/tls-manager.js +3 -26
  56. package/dist_ts/proxies/smart-proxy/utils/index.d.ts +1 -1
  57. package/dist_ts/proxies/smart-proxy/utils/index.js +3 -4
  58. package/dist_ts/proxies/smart-proxy/utils/route-helpers/api-helpers.d.ts +49 -0
  59. package/dist_ts/proxies/smart-proxy/utils/route-helpers/api-helpers.js +108 -0
  60. package/dist_ts/proxies/smart-proxy/utils/route-helpers/dynamic-helpers.d.ts +57 -0
  61. package/dist_ts/proxies/smart-proxy/utils/route-helpers/dynamic-helpers.js +89 -0
  62. package/dist_ts/proxies/smart-proxy/utils/route-helpers/http-helpers.d.ts +17 -0
  63. package/dist_ts/proxies/smart-proxy/utils/route-helpers/http-helpers.js +32 -0
  64. package/dist_ts/proxies/smart-proxy/utils/route-helpers/https-helpers.d.ts +68 -0
  65. package/dist_ts/proxies/smart-proxy/utils/route-helpers/https-helpers.js +117 -0
  66. package/dist_ts/proxies/smart-proxy/utils/route-helpers/index.d.ts +17 -0
  67. package/dist_ts/proxies/smart-proxy/utils/route-helpers/index.js +27 -0
  68. package/dist_ts/proxies/smart-proxy/utils/route-helpers/load-balancer-helpers.d.ts +63 -0
  69. package/dist_ts/proxies/smart-proxy/utils/route-helpers/load-balancer-helpers.js +105 -0
  70. package/dist_ts/proxies/smart-proxy/utils/route-helpers/nftables-helpers.d.ts +83 -0
  71. package/dist_ts/proxies/smart-proxy/utils/route-helpers/nftables-helpers.js +126 -0
  72. package/dist_ts/proxies/smart-proxy/utils/route-helpers/security-helpers.d.ts +47 -0
  73. package/dist_ts/proxies/smart-proxy/utils/route-helpers/security-helpers.js +66 -0
  74. package/dist_ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.d.ts +70 -0
  75. package/dist_ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.js +287 -0
  76. package/dist_ts/proxies/smart-proxy/utils/route-helpers/websocket-helpers.d.ts +46 -0
  77. package/dist_ts/proxies/smart-proxy/utils/route-helpers/websocket-helpers.js +67 -0
  78. package/dist_ts/proxies/smart-proxy/utils/route-helpers.d.ts +4 -457
  79. package/dist_ts/proxies/smart-proxy/utils/route-helpers.js +6 -950
  80. package/dist_ts/proxies/smart-proxy/utils/route-utils.js +2 -2
  81. package/dist_ts/proxies/smart-proxy/utils/route-validator.d.ts +67 -1
  82. package/dist_ts/proxies/smart-proxy/utils/route-validator.js +251 -3
  83. package/dist_ts/routing/index.d.ts +1 -1
  84. package/dist_ts/routing/index.js +3 -3
  85. package/dist_ts/routing/models/http-types.d.ts +119 -4
  86. package/dist_ts/routing/models/http-types.js +93 -5
  87. package/npmextra.json +12 -6
  88. package/package.json +34 -24
  89. package/readme.hints.md +184 -1
  90. package/readme.md +580 -266
  91. package/ts/00_commitinfo_data.ts +1 -1
  92. package/ts/core/utils/shared-security-manager.ts +98 -13
  93. package/ts/index.ts +4 -12
  94. package/ts/protocols/common/fragment-handler.ts +4 -0
  95. package/ts/proxies/index.ts +1 -9
  96. package/ts/proxies/nftables-proxy/index.ts +1 -0
  97. package/ts/proxies/nftables-proxy/nftables-proxy.ts +116 -290
  98. package/ts/proxies/nftables-proxy/utils/index.ts +38 -0
  99. package/ts/proxies/nftables-proxy/utils/nft-command-executor.ts +162 -0
  100. package/ts/proxies/nftables-proxy/utils/nft-port-spec-normalizer.ts +125 -0
  101. package/ts/proxies/nftables-proxy/utils/nft-rule-validator.ts +156 -0
  102. package/ts/proxies/smart-proxy/index.ts +6 -13
  103. package/ts/proxies/smart-proxy/models/interfaces.ts +6 -5
  104. package/ts/proxies/smart-proxy/route-preprocessor.ts +122 -0
  105. package/ts/proxies/smart-proxy/rust-binary-locator.ts +112 -0
  106. package/ts/proxies/smart-proxy/rust-metrics-adapter.ts +161 -0
  107. package/ts/proxies/smart-proxy/rust-proxy-bridge.ts +310 -0
  108. package/ts/proxies/smart-proxy/smart-proxy.ts +282 -800
  109. package/ts/proxies/smart-proxy/socket-handler-server.ts +279 -0
  110. package/ts/proxies/smart-proxy/utils/index.ts +3 -5
  111. package/ts/proxies/smart-proxy/utils/route-helpers/api-helpers.ts +144 -0
  112. package/ts/proxies/smart-proxy/utils/route-helpers/dynamic-helpers.ts +124 -0
  113. package/ts/proxies/smart-proxy/utils/route-helpers/http-helpers.ts +40 -0
  114. package/ts/proxies/smart-proxy/utils/route-helpers/https-helpers.ts +163 -0
  115. package/ts/proxies/smart-proxy/utils/route-helpers/index.ts +62 -0
  116. package/ts/proxies/smart-proxy/utils/route-helpers/load-balancer-helpers.ts +154 -0
  117. package/ts/proxies/smart-proxy/utils/route-helpers/nftables-helpers.ts +202 -0
  118. package/ts/proxies/smart-proxy/utils/route-helpers/security-helpers.ts +96 -0
  119. package/ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.ts +337 -0
  120. package/ts/proxies/smart-proxy/utils/route-helpers/websocket-helpers.ts +98 -0
  121. package/ts/proxies/smart-proxy/utils/route-helpers.ts +5 -1302
  122. package/ts/proxies/smart-proxy/utils/route-utils.ts +1 -1
  123. package/ts/proxies/smart-proxy/utils/route-validator.ts +274 -4
  124. package/ts/routing/index.ts +2 -2
  125. package/ts/routing/models/http-types.ts +147 -4
  126. package/ts/proxies/http-proxy/certificate-manager.ts +0 -244
  127. package/ts/proxies/http-proxy/connection-pool.ts +0 -228
  128. package/ts/proxies/http-proxy/context-creator.ts +0 -145
  129. package/ts/proxies/http-proxy/function-cache.ts +0 -279
  130. package/ts/proxies/http-proxy/handlers/index.ts +0 -5
  131. package/ts/proxies/http-proxy/http-proxy.ts +0 -675
  132. package/ts/proxies/http-proxy/http-request-handler.ts +0 -331
  133. package/ts/proxies/http-proxy/http2-request-handler.ts +0 -255
  134. package/ts/proxies/http-proxy/index.ts +0 -13
  135. package/ts/proxies/http-proxy/models/http-types.ts +0 -148
  136. package/ts/proxies/http-proxy/models/index.ts +0 -5
  137. package/ts/proxies/http-proxy/models/types.ts +0 -125
  138. package/ts/proxies/http-proxy/request-handler.ts +0 -878
  139. package/ts/proxies/http-proxy/security-manager.ts +0 -433
  140. package/ts/proxies/http-proxy/websocket-handler.ts +0 -581
  141. package/ts/proxies/smart-proxy/acme-state-manager.ts +0 -112
  142. package/ts/proxies/smart-proxy/cert-store.ts +0 -92
  143. package/ts/proxies/smart-proxy/certificate-manager.ts +0 -894
  144. package/ts/proxies/smart-proxy/connection-manager.ts +0 -796
  145. package/ts/proxies/smart-proxy/http-proxy-bridge.ts +0 -187
  146. package/ts/proxies/smart-proxy/metrics-collector.ts +0 -453
  147. package/ts/proxies/smart-proxy/nftables-manager.ts +0 -271
  148. package/ts/proxies/smart-proxy/port-manager.ts +0 -358
  149. package/ts/proxies/smart-proxy/route-connection-handler.ts +0 -1640
  150. package/ts/proxies/smart-proxy/route-orchestrator.ts +0 -297
  151. package/ts/proxies/smart-proxy/security-manager.ts +0 -257
  152. package/ts/proxies/smart-proxy/throughput-tracker.ts +0 -138
  153. package/ts/proxies/smart-proxy/timeout-manager.ts +0 -196
  154. package/ts/proxies/smart-proxy/tls-manager.ts +0 -207
  155. package/ts/proxies/smart-proxy/utils/route-validators.ts +0 -283
@@ -1,7 +1,95 @@
1
1
  /**
2
- * This file re-exports HTTP types from the HttpProxy module
3
- * for backward compatibility. All HTTP types are now consolidated
4
- * in the HttpProxy module.
2
+ * HTTP types for routing module.
3
+ * These were previously in http-proxy and are now self-contained here.
5
4
  */
6
- export * from '../../proxies/http-proxy/models/http-types.js';
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC10eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3RzL3JvdXRpbmcvbW9kZWxzL2h0dHAtdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7R0FJRztBQUNILGNBQWMsK0NBQStDLENBQUMifQ==
5
+ import * as plugins from '../../plugins.js';
6
+ import { HttpStatus as ProtocolHttpStatus, getStatusText as getProtocolStatusText } from '../../protocols/http/index.js';
7
+ /**
8
+ * HTTP-specific event types
9
+ */
10
+ export var HttpEvents;
11
+ (function (HttpEvents) {
12
+ HttpEvents["REQUEST_RECEIVED"] = "request-received";
13
+ HttpEvents["REQUEST_FORWARDED"] = "request-forwarded";
14
+ HttpEvents["REQUEST_HANDLED"] = "request-handled";
15
+ HttpEvents["REQUEST_ERROR"] = "request-error";
16
+ })(HttpEvents || (HttpEvents = {}));
17
+ // Re-export for backward compatibility with subset of commonly used codes
18
+ export const HttpStatus = {
19
+ OK: ProtocolHttpStatus.OK,
20
+ MOVED_PERMANENTLY: ProtocolHttpStatus.MOVED_PERMANENTLY,
21
+ FOUND: ProtocolHttpStatus.FOUND,
22
+ TEMPORARY_REDIRECT: ProtocolHttpStatus.TEMPORARY_REDIRECT,
23
+ PERMANENT_REDIRECT: ProtocolHttpStatus.PERMANENT_REDIRECT,
24
+ BAD_REQUEST: ProtocolHttpStatus.BAD_REQUEST,
25
+ UNAUTHORIZED: ProtocolHttpStatus.UNAUTHORIZED,
26
+ FORBIDDEN: ProtocolHttpStatus.FORBIDDEN,
27
+ NOT_FOUND: ProtocolHttpStatus.NOT_FOUND,
28
+ METHOD_NOT_ALLOWED: ProtocolHttpStatus.METHOD_NOT_ALLOWED,
29
+ REQUEST_TIMEOUT: ProtocolHttpStatus.REQUEST_TIMEOUT,
30
+ TOO_MANY_REQUESTS: ProtocolHttpStatus.TOO_MANY_REQUESTS,
31
+ INTERNAL_SERVER_ERROR: ProtocolHttpStatus.INTERNAL_SERVER_ERROR,
32
+ NOT_IMPLEMENTED: ProtocolHttpStatus.NOT_IMPLEMENTED,
33
+ BAD_GATEWAY: ProtocolHttpStatus.BAD_GATEWAY,
34
+ SERVICE_UNAVAILABLE: ProtocolHttpStatus.SERVICE_UNAVAILABLE,
35
+ GATEWAY_TIMEOUT: ProtocolHttpStatus.GATEWAY_TIMEOUT,
36
+ };
37
+ /**
38
+ * Base error class for HTTP-related errors
39
+ */
40
+ export class HttpError extends Error {
41
+ constructor(message, statusCode = HttpStatus.INTERNAL_SERVER_ERROR) {
42
+ super(message);
43
+ this.statusCode = statusCode;
44
+ this.name = 'HttpError';
45
+ }
46
+ }
47
+ /**
48
+ * Error related to certificate operations
49
+ */
50
+ export class CertificateError extends HttpError {
51
+ constructor(message, domain, isRenewal = false) {
52
+ super(`${message} for domain ${domain}${isRenewal ? ' (renewal)' : ''}`, HttpStatus.INTERNAL_SERVER_ERROR);
53
+ this.domain = domain;
54
+ this.isRenewal = isRenewal;
55
+ this.name = 'CertificateError';
56
+ }
57
+ }
58
+ /**
59
+ * Error related to server operations
60
+ */
61
+ export class ServerError extends HttpError {
62
+ constructor(message, code, statusCode = HttpStatus.INTERNAL_SERVER_ERROR) {
63
+ super(message, statusCode);
64
+ this.code = code;
65
+ this.name = 'ServerError';
66
+ }
67
+ }
68
+ /**
69
+ * Error for bad requests
70
+ */
71
+ export class BadRequestError extends HttpError {
72
+ constructor(message) {
73
+ super(message, HttpStatus.BAD_REQUEST);
74
+ this.name = 'BadRequestError';
75
+ }
76
+ }
77
+ /**
78
+ * Error for not found resources
79
+ */
80
+ export class NotFoundError extends HttpError {
81
+ constructor(message = 'Resource not found') {
82
+ super(message, HttpStatus.NOT_FOUND);
83
+ this.name = 'NotFoundError';
84
+ }
85
+ }
86
+ /**
87
+ * Helper function to get HTTP status text
88
+ */
89
+ export function getStatusText(status) {
90
+ return getProtocolStatusText(status);
91
+ }
92
+ // Backward compatibility exports
93
+ export { HttpError as Port80HandlerError };
94
+ export { CertificateError as CertError };
95
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC10eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3RzL3JvdXRpbmcvbW9kZWxzL2h0dHAtdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHO0FBQ0gsT0FBTyxLQUFLLE9BQU8sTUFBTSxrQkFBa0IsQ0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Q0FBUztRQUV4RCxJQUFJLENBQUMsSUFBSSxHQUFHLGFBQWEsQ0FBQztJQUM1QixDQUFDO0NBQ0Y7QUFFRDs7R0FFRztBQUNILE1BQU0sT0FBTyxlQUFnQixTQUFRLFNBQVM7SUFDNUMsWUFBWSxPQUFlO1FBQ3pCLEtBQUssQ0FBQyxPQUFPLEVBQUUsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQ3ZDLElBQUksQ0FBQyxJQUFJLEdBQUcsaUJBQWlCLENBQUM7SUFDaEMsQ0FBQztDQUNGO0FBRUQ7O0dBRUc7QUFDSCxNQUFNLE9BQU8sYUFBYyxTQUFRLFNBQVM7SUFDMUMsWUFBWSxVQUFrQixvQkFBb0I7UUFDaEQsS0FBSyxDQUFDLE9BQU8sRUFBRSxVQUFVLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDckMsSUFBSSxDQUFDLElBQUksR0FBRyxlQUFlLENBQUM7SUFDOUIsQ0FBQztDQUNGO0FBOEJEOztHQUVHO0FBQ0gsTUFBTSxVQUFVLGFBQWEsQ0FBQyxNQUFjO0lBQzFDLE9BQU8scUJBQXFCLENBQUMsTUFBNEIsQ0FBQyxDQUFDO0FBQzdELENBQUM7QUFxQkQsaUNBQWlDO0FBQ2pDLE9BQU8sRUFBRSxTQUFTLElBQUksa0JBQWtCLEVBQUUsQ0FBQztBQUMzQyxPQUFPLEVBQUUsZ0JBQWdCLElBQUksU0FBUyxFQUFFLENBQUMifQ==
package/npmextra.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "gitzone": {
2
+ "@git.zone/cli": {
3
3
  "projectType": "npm",
4
4
  "module": {
5
5
  "githost": "code.foss.global",
@@ -26,13 +26,19 @@
26
26
  "server",
27
27
  "network security"
28
28
  ]
29
+ },
30
+ "release": {
31
+ "registries": [
32
+ "https://verdaccio.lossless.digital",
33
+ "https://registry.npmjs.org"
34
+ ],
35
+ "accessLevel": "public"
29
36
  }
30
37
  },
31
- "npmci": {
32
- "npmGlobalTools": [],
33
- "npmAccessLevel": "public"
34
- },
35
- "tsdoc": {
38
+ "@git.zone/tsdoc": {
36
39
  "legal": "\n## License and Legal Information\n\nThis 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. \n\n**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.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
40
+ },
41
+ "@ship.zone/szci": {
42
+ "npmGlobalTools": []
37
43
  }
38
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartproxy",
3
- "version": "21.1.7",
3
+ "version": "22.6.0",
4
4
  "private": false,
5
5
  "description": "A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.",
6
6
  "main": "dist_ts/index.js",
@@ -8,12 +8,19 @@
8
8
  "type": "module",
9
9
  "author": "Lossless GmbH",
10
10
  "license": "MIT",
11
+ "scripts": {
12
+ "test": "(tstest test/**/test*.ts --verbose --timeout 60 --logfile)",
13
+ "build": "(tsbuild tsfolders --allowimplicitany)",
14
+ "format": "(gitzone format)",
15
+ "buildDocs": "tsdoc"
16
+ },
11
17
  "devDependencies": {
12
- "@git.zone/tsbuild": "^2.6.4",
13
- "@git.zone/tsrun": "^1.2.44",
14
- "@git.zone/tstest": "^2.3.1",
15
- "@types/node": "^22.15.29",
16
- "typescript": "^5.8.3",
18
+ "@git.zone/tsbuild": "^3.1.2",
19
+ "@git.zone/tsrun": "^2.0.0",
20
+ "@git.zone/tstest": "^3.1.3",
21
+ "@push.rocks/smartserve": "^1.4.0",
22
+ "@types/node": "^24.10.2",
23
+ "typescript": "^5.9.3",
17
24
  "why-is-node-running": "^3.2.2"
18
25
  },
19
26
  "dependencies": {
@@ -21,20 +28,20 @@
21
28
  "@push.rocks/smartacme": "^8.0.0",
22
29
  "@push.rocks/smartcrypto": "^2.0.4",
23
30
  "@push.rocks/smartdelay": "^3.0.5",
24
- "@push.rocks/smartfile": "^11.2.5",
25
- "@push.rocks/smartlog": "^3.1.8",
26
- "@push.rocks/smartnetwork": "^4.0.2",
31
+ "@push.rocks/smartfile": "^13.1.0",
32
+ "@push.rocks/smartlog": "^3.1.10",
33
+ "@push.rocks/smartnetwork": "^4.4.0",
27
34
  "@push.rocks/smartpromise": "^4.2.3",
28
- "@push.rocks/smartrequest": "^2.1.0",
35
+ "@push.rocks/smartrequest": "^5.0.1",
29
36
  "@push.rocks/smartrx": "^3.0.10",
30
- "@push.rocks/smartstring": "^4.0.15",
31
- "@push.rocks/taskbuffer": "^3.1.7",
32
- "@tsclass/tsclass": "^9.2.0",
33
- "@types/minimatch": "^5.1.2",
37
+ "@push.rocks/smartstring": "^4.1.0",
38
+ "@push.rocks/taskbuffer": "^3.5.0",
39
+ "@tsclass/tsclass": "^9.3.0",
40
+ "@types/minimatch": "^6.0.0",
34
41
  "@types/ws": "^8.18.1",
35
- "minimatch": "^10.0.1",
36
- "pretty-ms": "^9.2.0",
37
- "ws": "^8.18.2"
42
+ "minimatch": "^10.1.1",
43
+ "pretty-ms": "^9.3.0",
44
+ "ws": "^8.18.3"
38
45
  },
39
46
  "files": [
40
47
  "ts/**/*",
@@ -77,10 +84,13 @@
77
84
  "bugs": {
78
85
  "url": "https://code.foss.global/push.rocks/smartproxy/issues"
79
86
  },
80
- "scripts": {
81
- "test": "(tstest test/**/test*.ts --verbose --timeout 60 --logfile)",
82
- "build": "(tsbuild tsfolders --allowimplicitany)",
83
- "format": "(gitzone format)",
84
- "buildDocs": "tsdoc"
85
- }
86
- }
87
+ "pnpm": {
88
+ "overrides": {},
89
+ "onlyBuiltDependencies": [
90
+ "esbuild",
91
+ "mongodb-memory-server",
92
+ "puppeteer"
93
+ ]
94
+ },
95
+ "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
96
+ }
package/readme.hints.md CHANGED
@@ -345,4 +345,187 @@ new SmartProxy({
345
345
  1. Implement proper certificate expiry date extraction using X.509 parsing
346
346
  2. Add support for returning expiry date with custom certificates
347
347
  3. Consider adding validation for custom certificate format
348
- 4. Add events/hooks for certificate provisioning lifecycle
348
+ 4. Add events/hooks for certificate provisioning lifecycle
349
+
350
+ ## HTTPS/TLS Configuration Guide
351
+
352
+ SmartProxy supports three TLS modes for handling HTTPS traffic. Understanding when to use each mode is crucial for correct configuration.
353
+
354
+ ### TLS Mode: Passthrough (SNI Routing)
355
+
356
+ **When to use**: Backend server handles its own TLS certificates.
357
+
358
+ **How it works**:
359
+ 1. Client connects with TLS ClientHello containing SNI (Server Name Indication)
360
+ 2. SmartProxy extracts the SNI hostname without decrypting
361
+ 3. Connection is forwarded to backend as-is (still encrypted)
362
+ 4. Backend server terminates TLS with its own certificate
363
+
364
+ **Configuration**:
365
+ ```typescript
366
+ {
367
+ match: { ports: 443, domains: 'backend.example.com' },
368
+ action: {
369
+ type: 'forward',
370
+ targets: [{ host: 'backend-server', port: 443 }],
371
+ tls: { mode: 'passthrough' }
372
+ }
373
+ }
374
+ ```
375
+
376
+ **Requirements**:
377
+ - Backend must have valid TLS certificate for the domain
378
+ - Client's SNI must be present (session tickets without SNI will be rejected)
379
+ - No HTTP-level inspection possible (encrypted end-to-end)
380
+
381
+ ### TLS Mode: Terminate
382
+
383
+ **When to use**: SmartProxy handles TLS, backend receives plain HTTP.
384
+
385
+ **How it works**:
386
+ 1. Client connects with TLS ClientHello
387
+ 2. SmartProxy terminates TLS (decrypts traffic)
388
+ 3. Decrypted HTTP is forwarded to backend on plain HTTP port
389
+ 4. Backend receives unencrypted traffic
390
+
391
+ **Configuration**:
392
+ ```typescript
393
+ {
394
+ match: { ports: 443, domains: 'api.example.com' },
395
+ action: {
396
+ type: 'forward',
397
+ targets: [{ host: 'localhost', port: 8080 }], // HTTP backend
398
+ tls: {
399
+ mode: 'terminate',
400
+ certificate: 'auto' // Let's Encrypt, or provide { key, cert }
401
+ }
402
+ }
403
+ }
404
+ ```
405
+
406
+ **Requirements**:
407
+ - ACME email configured for auto certificates: `acme: { email: 'admin@example.com' }`
408
+ - Port 80 available for HTTP-01 challenges (or use DNS-01)
409
+ - Backend accessible on HTTP port
410
+
411
+ ### TLS Mode: Terminate and Re-encrypt
412
+
413
+ **When to use**: SmartProxy handles client TLS, but backend also requires TLS.
414
+
415
+ **How it works**:
416
+ 1. Client connects with TLS ClientHello
417
+ 2. SmartProxy terminates client TLS (decrypts)
418
+ 3. SmartProxy creates new TLS connection to backend
419
+ 4. Traffic is re-encrypted for the backend connection
420
+
421
+ **Configuration**:
422
+ ```typescript
423
+ {
424
+ match: { ports: 443, domains: 'secure.example.com' },
425
+ action: {
426
+ type: 'forward',
427
+ targets: [{ host: 'backend-tls', port: 443 }], // HTTPS backend
428
+ tls: {
429
+ mode: 'terminate-and-reencrypt',
430
+ certificate: 'auto'
431
+ }
432
+ }
433
+ }
434
+ ```
435
+
436
+ **Requirements**:
437
+ - Same as 'terminate' mode
438
+ - Backend must have valid TLS (can be self-signed for internal use)
439
+
440
+ ### HttpProxy Integration
441
+
442
+ For TLS termination modes (`terminate` and `terminate-and-reencrypt`), SmartProxy uses an internal HttpProxy component:
443
+
444
+ - HttpProxy listens on an internal port (default: 8443)
445
+ - SmartProxy forwards TLS connections to HttpProxy for termination
446
+ - Client IP is preserved via `CLIENT_IP:` header protocol
447
+ - HTTP/2 and WebSocket are supported after TLS termination
448
+
449
+ **Configuration**:
450
+ ```typescript
451
+ {
452
+ useHttpProxy: [443], // Ports that use HttpProxy for TLS termination
453
+ httpProxyPort: 8443, // Internal HttpProxy port
454
+ acme: {
455
+ email: 'admin@example.com',
456
+ useProduction: true // false for Let's Encrypt staging
457
+ }
458
+ }
459
+ ```
460
+
461
+ ### Common Configuration Patterns
462
+
463
+ **HTTP to HTTPS Redirect**:
464
+ ```typescript
465
+ import { createHttpToHttpsRedirect } from '@push.rocks/smartproxy';
466
+
467
+ const redirectRoute = createHttpToHttpsRedirect(['example.com', 'www.example.com']);
468
+ ```
469
+
470
+ **Complete HTTPS Server (with redirect)**:
471
+ ```typescript
472
+ import { createCompleteHttpsServer } from '@push.rocks/smartproxy';
473
+
474
+ const routes = createCompleteHttpsServer(
475
+ 'example.com',
476
+ { host: 'localhost', port: 8080 },
477
+ { certificate: 'auto' }
478
+ );
479
+ ```
480
+
481
+ **Load Balancer with Health Checks**:
482
+ ```typescript
483
+ import { createLoadBalancerRoute } from '@push.rocks/smartproxy';
484
+
485
+ const lbRoute = createLoadBalancerRoute(
486
+ 'api.example.com',
487
+ [
488
+ { host: 'backend1', port: 8080 },
489
+ { host: 'backend2', port: 8080 },
490
+ { host: 'backend3', port: 8080 }
491
+ ],
492
+ { tls: { mode: 'terminate', certificate: 'auto' } }
493
+ );
494
+ ```
495
+
496
+ ### Smart SNI Requirement (v22.3+)
497
+
498
+ SmartProxy automatically determines when SNI is required for routing. Session tickets (TLS resumption without SNI) are now allowed in more scenarios:
499
+
500
+ **SNI NOT required (session tickets allowed):**
501
+ - Single passthrough route with static target(s) and no domain restriction
502
+ - Single passthrough route with wildcard-only domain (`*` or `['*']`)
503
+ - TLS termination routes (`terminate` or `terminate-and-reencrypt`)
504
+ - Mixed terminate + passthrough routes (termination takes precedence)
505
+
506
+ **SNI IS required (session tickets blocked):**
507
+ - Multiple passthrough routes on the same port (need SNI to pick correct route)
508
+ - Route has dynamic host function (e.g., `host: (ctx) => ctx.domain === 'api.example.com' ? 'api-backend' : 'web-backend'`)
509
+ - Route has specific domain restriction (e.g., `domains: 'api.example.com'` or `domains: '*.example.com'`)
510
+
511
+ This allows simple single-target passthrough setups to work with TLS session resumption, improving performance for clients that reuse connections.
512
+
513
+ ### Troubleshooting
514
+
515
+ **"No SNI detected" errors**:
516
+ - Client is using TLS session resumption without SNI
517
+ - Solution: Configure route for TLS termination (allows session resumption), or ensure you have a single-target passthrough route with no domain restrictions
518
+
519
+ **"HttpProxy not available" errors**:
520
+ - `useHttpProxy` not configured for the port
521
+ - Solution: Add port to `useHttpProxy` array in settings
522
+
523
+ **Certificate provisioning failures**:
524
+ - Port 80 not accessible for HTTP-01 challenges
525
+ - ACME email not configured
526
+ - Solution: Ensure port 80 is available and `acme.email` is set
527
+
528
+ **Connection timeouts to HttpProxy**:
529
+ - CLIENT_IP header parsing timeout (default: 2000ms)
530
+ - Network congestion between SmartProxy and HttpProxy
531
+ - Solution: Check localhost connectivity, increase timeout if needed