@api-client/core 0.18.11 → 0.18.13

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 (264) hide show
  1. package/build/src/browser.d.ts +0 -3
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +0 -3
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/index.d.ts +2 -5
  6. package/build/src/index.d.ts.map +1 -1
  7. package/build/src/index.js +2 -5
  8. package/build/src/index.js.map +1 -1
  9. package/build/src/lib/logging/DefaultLogger.d.ts +14 -0
  10. package/build/src/lib/logging/DefaultLogger.d.ts.map +1 -1
  11. package/build/src/lib/logging/DefaultLogger.js +27 -0
  12. package/build/src/lib/logging/DefaultLogger.js.map +1 -1
  13. package/build/src/lib/logging/index.d.ts +4 -0
  14. package/build/src/lib/logging/index.d.ts.map +1 -0
  15. package/build/src/lib/logging/index.js +10 -0
  16. package/build/src/lib/logging/index.js.map +1 -0
  17. package/build/src/modeling/DomainModel.d.ts.map +1 -1
  18. package/build/src/modeling/DomainModel.js +11 -4
  19. package/build/src/modeling/DomainModel.js.map +1 -1
  20. package/build/src/models/ClientCertificate.d.ts +1 -1
  21. package/build/src/models/ClientCertificate.js.map +1 -1
  22. package/build/src/models/RequestConfig.d.ts +1 -1
  23. package/build/src/models/RequestConfig.js.map +1 -1
  24. package/build/src/models/SerializableError.d.ts +1 -1
  25. package/build/src/models/SerializableError.d.ts.map +1 -1
  26. package/build/src/models/SerializableError.js.map +1 -1
  27. package/build/src/proxy/RequestProxy.d.ts.map +1 -1
  28. package/build/src/proxy/RequestProxy.js +2 -2
  29. package/build/src/proxy/RequestProxy.js.map +1 -1
  30. package/build/src/runtime/http-engine/CoreEngine.d.ts +218 -139
  31. package/build/src/runtime/http-engine/CoreEngine.d.ts.map +1 -1
  32. package/build/src/runtime/http-engine/CoreEngine.js +716 -870
  33. package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
  34. package/build/src/runtime/http-engine/PayloadSupport.d.ts.map +1 -1
  35. package/build/src/runtime/http-engine/PayloadSupport.js +2 -1
  36. package/build/src/runtime/http-engine/PayloadSupport.js.map +1 -1
  37. package/build/src/runtime/http-engine/auth/AuthManager.d.ts +73 -0
  38. package/build/src/runtime/http-engine/auth/AuthManager.d.ts.map +1 -0
  39. package/build/src/runtime/http-engine/auth/AuthManager.js +186 -0
  40. package/build/src/runtime/http-engine/auth/AuthManager.js.map +1 -0
  41. package/build/src/runtime/http-engine/auth/index.d.ts +2 -0
  42. package/build/src/runtime/http-engine/auth/index.d.ts.map +1 -0
  43. package/build/src/runtime/http-engine/auth/index.js +2 -0
  44. package/build/src/runtime/http-engine/auth/index.js.map +1 -0
  45. package/build/src/runtime/http-engine/certificates/CertificateManager.d.ts +11 -0
  46. package/build/src/runtime/http-engine/certificates/CertificateManager.d.ts.map +1 -0
  47. package/build/src/runtime/http-engine/certificates/CertificateManager.js +76 -0
  48. package/build/src/runtime/http-engine/certificates/CertificateManager.js.map +1 -0
  49. package/build/src/runtime/http-engine/certificates/index.d.ts +2 -0
  50. package/build/src/runtime/http-engine/certificates/index.d.ts.map +1 -0
  51. package/build/src/runtime/http-engine/certificates/index.js +2 -0
  52. package/build/src/runtime/http-engine/certificates/index.js.map +1 -0
  53. package/build/src/runtime/http-engine/compression/CompressionManager.d.ts +25 -0
  54. package/build/src/runtime/http-engine/compression/CompressionManager.d.ts.map +1 -0
  55. package/build/src/runtime/http-engine/compression/CompressionManager.js +89 -0
  56. package/build/src/runtime/http-engine/compression/CompressionManager.js.map +1 -0
  57. package/build/src/runtime/http-engine/compression/index.d.ts +2 -0
  58. package/build/src/runtime/http-engine/compression/index.d.ts.map +1 -0
  59. package/build/src/runtime/http-engine/compression/index.js +2 -0
  60. package/build/src/runtime/http-engine/compression/index.js.map +1 -0
  61. package/build/src/runtime/http-engine/connections/ConnectionManager.d.ts +57 -0
  62. package/build/src/runtime/http-engine/connections/ConnectionManager.d.ts.map +1 -0
  63. package/build/src/runtime/http-engine/connections/ConnectionManager.js +78 -0
  64. package/build/src/runtime/http-engine/connections/ConnectionManager.js.map +1 -0
  65. package/build/src/runtime/http-engine/connections/DigestAuthHandler.d.ts +70 -0
  66. package/build/src/runtime/http-engine/connections/DigestAuthHandler.d.ts.map +1 -0
  67. package/build/src/runtime/http-engine/connections/DigestAuthHandler.js +184 -0
  68. package/build/src/runtime/http-engine/connections/DigestAuthHandler.js.map +1 -0
  69. package/build/src/runtime/http-engine/connections/DirectConnection.d.ts +22 -0
  70. package/build/src/runtime/http-engine/connections/DirectConnection.d.ts.map +1 -0
  71. package/build/src/runtime/http-engine/connections/DirectConnection.js +105 -0
  72. package/build/src/runtime/http-engine/connections/DirectConnection.js.map +1 -0
  73. package/build/src/runtime/http-engine/connections/ProxyAuthHandler.d.ts +60 -0
  74. package/build/src/runtime/http-engine/connections/ProxyAuthHandler.d.ts.map +1 -0
  75. package/build/src/runtime/http-engine/connections/ProxyAuthHandler.js +138 -0
  76. package/build/src/runtime/http-engine/connections/ProxyAuthHandler.js.map +1 -0
  77. package/build/src/runtime/http-engine/connections/ProxyConnection.d.ts +14 -0
  78. package/build/src/runtime/http-engine/connections/ProxyConnection.d.ts.map +1 -0
  79. package/build/src/runtime/http-engine/connections/ProxyConnection.js +47 -0
  80. package/build/src/runtime/http-engine/connections/ProxyConnection.js.map +1 -0
  81. package/build/src/runtime/http-engine/connections/TunnelConnection.d.ts +13 -0
  82. package/build/src/runtime/http-engine/connections/TunnelConnection.d.ts.map +1 -0
  83. package/build/src/runtime/http-engine/connections/TunnelConnection.js +175 -0
  84. package/build/src/runtime/http-engine/connections/TunnelConnection.js.map +1 -0
  85. package/build/src/runtime/http-engine/connections/index.d.ts +7 -0
  86. package/build/src/runtime/http-engine/connections/index.d.ts.map +1 -0
  87. package/build/src/runtime/http-engine/connections/index.js +7 -0
  88. package/build/src/runtime/http-engine/connections/index.js.map +1 -0
  89. package/build/src/runtime/http-engine/constants.d.ts +69 -0
  90. package/build/src/runtime/http-engine/constants.d.ts.map +1 -0
  91. package/build/src/runtime/http-engine/constants.js +90 -0
  92. package/build/src/runtime/http-engine/constants.js.map +1 -0
  93. package/build/src/runtime/http-engine/cookies/CookieProcessor.d.ts +5 -0
  94. package/build/src/runtime/http-engine/cookies/CookieProcessor.d.ts.map +1 -0
  95. package/build/src/runtime/http-engine/cookies/CookieProcessor.js +20 -0
  96. package/build/src/runtime/http-engine/cookies/CookieProcessor.js.map +1 -0
  97. package/build/src/runtime/http-engine/cookies/index.d.ts +2 -0
  98. package/build/src/runtime/http-engine/cookies/index.d.ts.map +1 -0
  99. package/build/src/runtime/http-engine/cookies/index.js +2 -0
  100. package/build/src/runtime/http-engine/cookies/index.js.map +1 -0
  101. package/build/src/runtime/http-engine/errors/HttpEngineErrors.d.ts +156 -0
  102. package/build/src/runtime/http-engine/errors/HttpEngineErrors.d.ts.map +1 -0
  103. package/build/src/runtime/http-engine/errors/HttpEngineErrors.js +227 -0
  104. package/build/src/runtime/http-engine/errors/HttpEngineErrors.js.map +1 -0
  105. package/build/src/runtime/http-engine/errors/index.d.ts +2 -0
  106. package/build/src/runtime/http-engine/errors/index.d.ts.map +1 -0
  107. package/build/src/runtime/http-engine/errors/index.js +2 -0
  108. package/build/src/runtime/http-engine/errors/index.js.map +1 -0
  109. package/build/src/runtime/http-engine/message/MessageBuilder.d.ts +66 -0
  110. package/build/src/runtime/http-engine/message/MessageBuilder.d.ts.map +1 -0
  111. package/build/src/runtime/http-engine/message/MessageBuilder.js +161 -0
  112. package/build/src/runtime/http-engine/message/MessageBuilder.js.map +1 -0
  113. package/build/src/runtime/http-engine/message/MessageProcessor.d.ts +27 -0
  114. package/build/src/runtime/http-engine/message/MessageProcessor.d.ts.map +1 -0
  115. package/build/src/runtime/http-engine/message/MessageProcessor.js +51 -0
  116. package/build/src/runtime/http-engine/message/MessageProcessor.js.map +1 -0
  117. package/build/src/runtime/http-engine/message/index.d.ts +3 -0
  118. package/build/src/runtime/http-engine/message/index.d.ts.map +1 -0
  119. package/build/src/runtime/http-engine/message/index.js +3 -0
  120. package/build/src/runtime/http-engine/message/index.js.map +1 -0
  121. package/build/src/runtime/http-engine/ntlm/NtlmAuth.d.ts +2 -8
  122. package/build/src/runtime/http-engine/ntlm/NtlmAuth.d.ts.map +1 -1
  123. package/build/src/runtime/http-engine/ntlm/NtlmAuth.js +11 -5
  124. package/build/src/runtime/http-engine/ntlm/NtlmAuth.js.map +1 -1
  125. package/build/src/runtime/http-engine/ntlm/NtlmMessage.js +6 -6
  126. package/build/src/runtime/http-engine/ntlm/NtlmMessage.js.map +1 -1
  127. package/build/src/runtime/http-engine/parsers/BodyParser.d.ts +39 -0
  128. package/build/src/runtime/http-engine/parsers/BodyParser.d.ts.map +1 -0
  129. package/build/src/runtime/http-engine/parsers/BodyParser.js +145 -0
  130. package/build/src/runtime/http-engine/parsers/BodyParser.js.map +1 -0
  131. package/build/src/runtime/http-engine/parsers/HeadersParser.d.ts +29 -0
  132. package/build/src/runtime/http-engine/parsers/HeadersParser.d.ts.map +1 -0
  133. package/build/src/runtime/http-engine/parsers/HeadersParser.js +88 -0
  134. package/build/src/runtime/http-engine/parsers/HeadersParser.js.map +1 -0
  135. package/build/src/runtime/http-engine/parsers/HttpResponseParser.d.ts +91 -0
  136. package/build/src/runtime/http-engine/parsers/HttpResponseParser.d.ts.map +1 -0
  137. package/build/src/runtime/http-engine/parsers/HttpResponseParser.js +236 -0
  138. package/build/src/runtime/http-engine/parsers/HttpResponseParser.js.map +1 -0
  139. package/build/src/runtime/http-engine/parsers/StatusParser.d.ts +20 -0
  140. package/build/src/runtime/http-engine/parsers/StatusParser.d.ts.map +1 -0
  141. package/build/src/runtime/http-engine/parsers/StatusParser.js +51 -0
  142. package/build/src/runtime/http-engine/parsers/StatusParser.js.map +1 -0
  143. package/build/src/runtime/http-engine/parsers/index.d.ts +5 -0
  144. package/build/src/runtime/http-engine/parsers/index.d.ts.map +1 -0
  145. package/build/src/runtime/http-engine/parsers/index.js +5 -0
  146. package/build/src/runtime/http-engine/parsers/index.js.map +1 -0
  147. package/build/src/runtime/http-engine/response/ResponseProcessor.d.ts +22 -0
  148. package/build/src/runtime/http-engine/response/ResponseProcessor.d.ts.map +1 -0
  149. package/build/src/runtime/http-engine/response/ResponseProcessor.js +25 -0
  150. package/build/src/runtime/http-engine/response/ResponseProcessor.js.map +1 -0
  151. package/build/src/runtime/http-engine/response/index.d.ts +2 -0
  152. package/build/src/runtime/http-engine/response/index.d.ts.map +1 -0
  153. package/build/src/runtime/http-engine/response/index.js +2 -0
  154. package/build/src/runtime/http-engine/response/index.js.map +1 -0
  155. package/build/src/runtime/http-engine/statistics/StatisticsProcessor.d.ts +7 -0
  156. package/build/src/runtime/http-engine/statistics/StatisticsProcessor.d.ts.map +1 -0
  157. package/build/src/runtime/http-engine/statistics/StatisticsProcessor.js +40 -0
  158. package/build/src/runtime/http-engine/statistics/StatisticsProcessor.js.map +1 -0
  159. package/build/src/runtime/http-engine/statistics/index.d.ts +2 -0
  160. package/build/src/runtime/http-engine/statistics/index.d.ts.map +1 -0
  161. package/build/src/runtime/http-engine/statistics/index.js +2 -0
  162. package/build/src/runtime/http-engine/statistics/index.js.map +1 -0
  163. package/build/src/runtime/http-engine/url/UrlProcessor.d.ts +24 -0
  164. package/build/src/runtime/http-engine/url/UrlProcessor.d.ts.map +1 -0
  165. package/build/src/runtime/http-engine/url/UrlProcessor.js +50 -0
  166. package/build/src/runtime/http-engine/url/UrlProcessor.js.map +1 -0
  167. package/build/src/runtime/http-engine/url/index.d.ts +2 -0
  168. package/build/src/runtime/http-engine/url/index.d.ts.map +1 -0
  169. package/build/src/runtime/http-engine/url/index.js +2 -0
  170. package/build/src/runtime/http-engine/url/index.js.map +1 -0
  171. package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +3 -3
  172. package/build/src/runtime/http-runner/HttpRequestRunner.d.ts.map +1 -1
  173. package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -1
  174. package/build/src/runtime/node/InteropInterfaces.d.ts +3 -3
  175. package/build/src/runtime/node/InteropInterfaces.d.ts.map +1 -1
  176. package/build/src/runtime/node/InteropInterfaces.js.map +1 -1
  177. package/build/src/runtime/node/ProjectRequestRunner.d.ts +2 -2
  178. package/build/src/runtime/node/ProjectRequestRunner.d.ts.map +1 -1
  179. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  180. package/build/src/runtime/node/ProjectRunner.d.ts.map +1 -1
  181. package/build/src/runtime/node/ProjectRunner.js +2 -2
  182. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  183. package/build/tsconfig.tsbuildinfo +1 -1
  184. package/data/models/example-generator-api.json +24 -24
  185. package/package.json +2 -2
  186. package/src/lib/logging/DefaultLogger.ts +32 -0
  187. package/src/modeling/DomainModel.ts +11 -4
  188. package/src/models/ClientCertificate.ts +1 -1
  189. package/src/models/RequestConfig.ts +1 -1
  190. package/src/models/SerializableError.ts +1 -1
  191. package/src/proxy/RequestProxy.ts +2 -2
  192. package/src/runtime/http-engine/CoreEngine.ts +858 -893
  193. package/src/runtime/http-engine/PayloadSupport.ts +2 -1
  194. package/src/runtime/http-engine/auth/AuthManager.ts +242 -0
  195. package/src/runtime/http-engine/certificates/CertificateManager.ts +74 -0
  196. package/src/runtime/http-engine/compression/CompressionManager.ts +99 -0
  197. package/src/runtime/http-engine/connections/ConnectionManager.ts +123 -0
  198. package/src/runtime/http-engine/connections/DigestAuthHandler.ts +238 -0
  199. package/src/runtime/http-engine/connections/DirectConnection.ts +134 -0
  200. package/src/runtime/http-engine/connections/ProxyAuthHandler.ts +179 -0
  201. package/src/runtime/http-engine/connections/ProxyConnection.ts +55 -0
  202. package/src/runtime/http-engine/connections/TunnelConnection.ts +192 -0
  203. package/src/runtime/http-engine/constants.ts +103 -0
  204. package/src/runtime/http-engine/cookies/CookieProcessor.ts +25 -0
  205. package/src/runtime/http-engine/errors/HttpEngineErrors.ts +319 -0
  206. package/src/runtime/http-engine/message/MessageBuilder.ts +201 -0
  207. package/src/runtime/http-engine/message/MessageProcessor.ts +73 -0
  208. package/src/runtime/http-engine/ntlm/NtlmAuth.ts +16 -13
  209. package/src/runtime/http-engine/ntlm/NtlmMessage.ts +6 -6
  210. package/src/runtime/http-engine/parsers/BodyParser.ts +171 -0
  211. package/src/runtime/http-engine/parsers/HeadersParser.ts +103 -0
  212. package/src/runtime/http-engine/parsers/HttpResponseParser.ts +280 -0
  213. package/src/runtime/http-engine/parsers/StatusParser.ts +69 -0
  214. package/src/runtime/http-engine/response/ResponseProcessor.ts +46 -0
  215. package/src/runtime/http-engine/statistics/StatisticsProcessor.ts +52 -0
  216. package/src/runtime/http-engine/url/UrlProcessor.ts +55 -0
  217. package/src/runtime/http-runner/HttpRequestRunner.ts +3 -3
  218. package/src/runtime/node/InteropInterfaces.ts +3 -3
  219. package/src/runtime/node/ProjectRequestRunner.ts +2 -2
  220. package/src/runtime/node/ProjectRunner.ts +2 -2
  221. package/tests/servers/ProxyServer.ts +32 -19
  222. package/tests/servers/express-routes/ApiEndpoint.ts +24 -0
  223. package/tests/servers/express-routes/BasicAuthRoute.ts +36 -0
  224. package/tests/servers/express-routes/BearerAuthRoute.ts +35 -0
  225. package/tests/servers/express-routes/NTLMRoute.ts +2 -3
  226. package/tests/servers/express-routes/PostApi.ts +15 -2
  227. package/tests/servers/express-routes/RedirectsApi.ts +12 -1
  228. package/tests/servers/express-routes/ResponsesApi.ts +1 -1
  229. package/tests/servers/express-routes/StreamApi.ts +19 -0
  230. package/tests/servers/oauth2mock/ServerMock.js +1 -1
  231. package/tests/unit/modeling/domain_model_entities.spec.ts +306 -1
  232. package/tests/unit/runtime/http-engine/HttpResponseParser.spec.ts +337 -0
  233. package/tests/unit/runtime/http-engine/abort.spec.ts +4 -5
  234. package/tests/unit/runtime/http-engine/auth.spec.ts +7 -58
  235. package/tests/unit/runtime/http-engine/certificates/CertificateManager.spec.ts +482 -0
  236. package/tests/unit/runtime/http-engine/certificates.spec.ts +2 -2
  237. package/tests/unit/runtime/http-engine/compression/CompressionManager.spec.ts +498 -0
  238. package/tests/unit/runtime/http-engine/compression.spec.ts +3 -72
  239. package/tests/unit/runtime/http-engine/connections/ConnectionManager.spec.ts +379 -0
  240. package/tests/unit/runtime/http-engine/connections/DigestAuthHandler.spec.ts +164 -0
  241. package/tests/unit/runtime/http-engine/core_engine.spec.ts +561 -0
  242. package/tests/unit/runtime/http-engine/engine_statuses.spec.ts +2 -2
  243. package/tests/unit/runtime/http-engine/events.spec.ts +2 -2
  244. package/tests/unit/runtime/http-engine/headers.spec.ts +2 -88
  245. package/tests/unit/runtime/http-engine/hosts.spec.ts +2 -2
  246. package/tests/unit/runtime/http-engine/http-get.spec.ts +2 -2
  247. package/tests/unit/runtime/http-engine/http-post.spec.ts +2 -2
  248. package/tests/unit/runtime/http-engine/logger.spec.ts +0 -8
  249. package/tests/unit/runtime/http-engine/message.spec.ts +2 -194
  250. package/tests/unit/runtime/http-engine/params.spec.ts +4 -4
  251. package/tests/unit/runtime/http-engine/proxy.spec.ts +15 -14
  252. package/tests/unit/runtime/http-engine/redirects.spec.ts +2 -2
  253. package/tests/unit/runtime/http-engine/responses.spec.ts +170 -277
  254. package/tests/unit/runtime/http-engine/timeout.spec.ts +3 -3
  255. package/tests/unit/runtime/http-engine/timings.spec.ts +2 -2
  256. package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +25 -28
  257. package/tests/unit/runtime/runners/project_runner.spec.ts +2 -2
  258. package/tests/unit/runtime/runners/request_runner.spec.ts +2 -2
  259. package/build/src/runtime/http-engine/HttpEngine.d.ts +0 -311
  260. package/build/src/runtime/http-engine/HttpEngine.d.ts.map +0 -1
  261. package/build/src/runtime/http-engine/HttpEngine.js +0 -802
  262. package/build/src/runtime/http-engine/HttpEngine.js.map +0 -1
  263. package/src/runtime/http-engine/HttpEngine.ts +0 -952
  264. package/tests/unit/runtime/http-engine/connecting.spec.ts +0 -140
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProxyConnection.js","sourceRoot":"","sources":["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;YAC5C,GAAG,IAAI,CAAC,OAAO;YACf,IAAI;YACJ,IAAI;YACJ,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO;SAC1C,CAAC,CAAA;QAEF,IAAI,CAAC;YACH,OAAO,MAAM,gBAAgB,CAAC,OAAO,EAAE,CAAA;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAkC,CAAA;YAC9C,MAAM,IAAI,iBAAiB,CAAC,+BAA+B,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QAC9G,CAAC;IACH,CAAC;CACF","sourcesContent":["import net from 'net'\nimport { URL } from 'url'\nimport { ProxyConnectionOptions } from './ConnectionManager.js'\nimport { DirectConnection } from './DirectConnection.js'\nimport { SerializableError } from '../../../models/SerializableError.js'\n\n/**\n * Handles HTTP requests through a proxy server\n */\nexport class ProxyConnection {\n private options: ProxyConnectionOptions\n\n constructor(options: ProxyConnectionOptions) {\n this.options = options\n }\n\n /**\n * Establish a connection to the proxy server\n */\n async connect(): Promise<net.Socket> {\n const { proxy, proxyIsSsl, logger } = this.options\n\n logger.debug('Proxying an HTTP request...')\n\n if (!proxy) {\n throw new Error('No proxy configuration found.')\n }\n\n let proxyUrl = proxy\n if (proxyIsSsl && !proxyUrl.startsWith('https:')) {\n proxyUrl = `https://${proxyUrl}`\n } else if (!proxyIsSsl && !proxyUrl.startsWith('http:')) {\n proxyUrl = `http://${proxyUrl}`\n }\n\n const proxyUri = new URL(proxyUrl)\n const port = Number(proxyUri.port || (proxyIsSsl ? 443 : 80))\n const host = proxyUri.hostname\n\n // Create a direct connection to the proxy\n const directConnection = new DirectConnection({\n ...this.options,\n host,\n port,\n protocol: proxyIsSsl ? 'https:' : 'http:',\n })\n\n try {\n return await directConnection.connect()\n } catch (error) {\n const err = error as Error & { code?: string }\n throw new SerializableError(`Failed to connect to proxy: ${err.message}`, err.code ? Number(err.code) : 112)\n }\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import net from 'net';
2
+ import { TunnelConnectionOptions } from './ConnectionManager.js';
3
+ /**
4
+ * Handles HTTPS tunneling through an HTTP proxy
5
+ */
6
+ export declare class TunnelConnection {
7
+ private options;
8
+ private authHandler;
9
+ constructor(options: TunnelConnectionOptions);
10
+ connect(): Promise<net.Socket>;
11
+ private handleProxyAuthentication;
12
+ }
13
+ //# sourceMappingURL=TunnelConnection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TunnelConnection.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/connections/TunnelConnection.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAKrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAKhE;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,WAAW,CAAkB;gBAEzB,OAAO,EAAE,uBAAuB;IAStC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;YA8ItB,yBAAyB;CAuBxC"}
@@ -0,0 +1,175 @@
1
+ import tls from 'tls';
2
+ import https from 'https';
3
+ import http from 'http';
4
+ import { URL } from 'url';
5
+ import { Headers } from '../../../lib/headers/Headers.js';
6
+ import { ProxyAuthHandler } from './ProxyAuthHandler.js';
7
+ import { HttpEngineErrorFactory } from '../errors/index.js';
8
+ /**
9
+ * Handles HTTPS tunneling through an HTTP proxy
10
+ */
11
+ export class TunnelConnection {
12
+ options;
13
+ authHandler;
14
+ constructor(options) {
15
+ this.options = options;
16
+ this.authHandler = new ProxyAuthHandler({
17
+ proxyUsername: options.proxyUsername,
18
+ proxyPassword: options.proxyPassword,
19
+ logger: options.logger,
20
+ });
21
+ }
22
+ async connect() {
23
+ const { proxy, proxyIsSsl, targetHost, targetPort, logger, stats } = this.options;
24
+ logger.debug('Creating a tunnel through the proxy...');
25
+ if (!proxy) {
26
+ throw HttpEngineErrorFactory.proxyConfigError('No proxy configuration found.');
27
+ }
28
+ let proxyUrl = proxy;
29
+ if (proxyIsSsl && !proxyUrl.startsWith('https:')) {
30
+ proxyUrl = `https://${proxyUrl}`;
31
+ }
32
+ else if (!proxyIsSsl && !proxyUrl.startsWith('http:')) {
33
+ proxyUrl = `http://${proxyUrl}`;
34
+ }
35
+ const proxyUri = new URL(proxyUrl);
36
+ const proxyPort = proxyUri.port || (proxyIsSsl ? 443 : 80);
37
+ const authority = `${targetHost}:${targetPort}`;
38
+ const connectOptions = {
39
+ host: proxyUri.hostname,
40
+ port: proxyPort,
41
+ method: 'CONNECT',
42
+ path: authority,
43
+ headers: {
44
+ host: authority,
45
+ },
46
+ };
47
+ if (proxyIsSsl) {
48
+ connectOptions.rejectUnauthorized = false;
49
+ // @ts-expect-error This is correct!
50
+ connectOptions.requestOCSP = false;
51
+ }
52
+ const lib = proxyIsSsl ? https : http;
53
+ return new Promise((resolve, reject) => {
54
+ stats.connectionTime = Date.now();
55
+ try {
56
+ // Add proxy authorization if available
57
+ const auth = this.authHandler.generateAuthHeader();
58
+ if (auth) {
59
+ logger.debug('Adding proxy authorization.');
60
+ connectOptions.headers['proxy-authorization'] = auth;
61
+ }
62
+ logger.debug('Creating proxy tunnel...');
63
+ const connectRequest = lib.request(connectOptions);
64
+ logger.silly('Proxy tunnel created.');
65
+ connectRequest.once('socket', (socket) => {
66
+ logger.debug('Proxy tunnel socket created.');
67
+ socket.on('lookup', () => {
68
+ logger.debug('Proxy tunnel lookup.');
69
+ stats.lookupTime = Date.now();
70
+ });
71
+ });
72
+ connectRequest.on('error', (err) => {
73
+ logger.error('Error establishing proxy tunnel:', err);
74
+ reject(HttpEngineErrorFactory.proxyError(`Failed to establish proxy tunnel: ${err.message}`, err.code ? Number(err.code) : 111));
75
+ });
76
+ connectRequest.on('connect', async (res, socket, head) => {
77
+ const time = Date.now();
78
+ logger.debug('Proxy tunnel connected.');
79
+ stats.connectedTime = time;
80
+ stats.secureStartTime = time;
81
+ if (typeof stats.lookupTime === 'undefined') {
82
+ stats.lookupTime = time;
83
+ }
84
+ if (res.statusCode === 401) {
85
+ // Handle proxy authentication required
86
+ logger.debug('Proxy tunnel not authorized. Closing.');
87
+ connectRequest.destroy();
88
+ reject(HttpEngineErrorFactory.proxyAuthRequired(res, head));
89
+ return;
90
+ }
91
+ else if (res.statusCode === 407) {
92
+ // Handle proxy authentication
93
+ logger.debug('Proxy tunnel authentication required. Trying to authenticate...');
94
+ try {
95
+ const retryResult = await this.handleProxyAuthentication(res);
96
+ if (retryResult) {
97
+ // Authentication succeeded and we should retry
98
+ connectRequest.destroy();
99
+ socket.destroy();
100
+ // Retry the connection with new authentication
101
+ try {
102
+ const retrySocket = await this.connect();
103
+ resolve(retrySocket);
104
+ }
105
+ catch (retryError) {
106
+ reject(retryError);
107
+ }
108
+ return;
109
+ }
110
+ else {
111
+ // Authentication failed
112
+ logger.warn('Proxy authentication failed. Closing connection.');
113
+ connectRequest.destroy();
114
+ reject(HttpEngineErrorFactory.proxyAuthFailed());
115
+ return;
116
+ }
117
+ }
118
+ catch (error) {
119
+ logger.warn('Error handling proxy authentication:', error);
120
+ connectRequest.destroy();
121
+ reject(error);
122
+ }
123
+ return;
124
+ }
125
+ else if (res.statusCode !== 200) {
126
+ logger.debug(`The proxy tunnel ended with ${res.statusCode} status code. Erroring request.`);
127
+ connectRequest.destroy();
128
+ const errorMessage = res.statusMessage || `Proxy tunnel establishment failed with status code ${res.statusCode}`;
129
+ const e = HttpEngineErrorFactory.proxyError(errorMessage, res.statusCode);
130
+ reject(e);
131
+ return;
132
+ }
133
+ logger.debug('Established a proxy tunnel.');
134
+ logger.debug('Upgrading connection to SSL...');
135
+ const tlsSocket = tls.connect({ socket, rejectUnauthorized: false }, () => {
136
+ logger.debug('Connection upgraded to SSL.');
137
+ resolve(tlsSocket);
138
+ });
139
+ tlsSocket.once('secureConnect', () => {
140
+ stats.secureConnectedTime = Date.now();
141
+ });
142
+ });
143
+ connectRequest.end();
144
+ }
145
+ catch (error) {
146
+ reject(error);
147
+ }
148
+ });
149
+ }
150
+ async handleProxyAuthentication(res) {
151
+ if (res.statusCode === 407) {
152
+ const headers = new Headers(res.headers);
153
+ const authHeader = headers.get('proxy-authenticate');
154
+ if (authHeader) {
155
+ try {
156
+ const authResponse = this.authHandler.handleChallenge(authHeader);
157
+ if (authResponse) {
158
+ this.options.logger.debug('Generated proxy authentication response');
159
+ this.authHandler.markAuthenticated();
160
+ return true; // Indicate successful authentication
161
+ }
162
+ }
163
+ catch (error) {
164
+ this.options.logger.error('Failed to handle proxy authentication:', error);
165
+ throw error;
166
+ }
167
+ }
168
+ else {
169
+ throw HttpEngineErrorFactory.proxyError('Proxy authentication required but no challenge provided', 407);
170
+ }
171
+ }
172
+ return false; // Indicate failed authentication
173
+ }
174
+ }
175
+ //# sourceMappingURL=TunnelConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TunnelConnection.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/connections/TunnelConnection.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAE3D;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAAyB;IAChC,WAAW,CAAkB;IAErC,YAAY,OAAgC;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC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,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAA;oBAC1E,MAAM,KAAK,CAAA;gBACb,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,sBAAsB,CAAC,UAAU,CAAC,yDAAyD,EAAE,GAAG,CAAC,CAAA;YACzG,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA,CAAC,iCAAiC;IAChD,CAAC;CACF","sourcesContent":["import net from 'net'\nimport tls from 'tls'\nimport https from 'https'\nimport http from 'http'\nimport { URL } from 'url'\nimport { TunnelConnectionOptions } from './ConnectionManager.js'\nimport { Headers } from '../../../lib/headers/Headers.js'\nimport { ProxyAuthHandler } from './ProxyAuthHandler.js'\nimport { HttpEngineErrorFactory } from '../errors/index.js'\n\n/**\n * Handles HTTPS tunneling through an HTTP proxy\n */\nexport class TunnelConnection {\n private options: TunnelConnectionOptions\n private authHandler: ProxyAuthHandler\n\n constructor(options: TunnelConnectionOptions) {\n this.options = options\n this.authHandler = new ProxyAuthHandler({\n proxyUsername: options.proxyUsername,\n proxyPassword: options.proxyPassword,\n logger: options.logger,\n })\n }\n\n async connect(): Promise<net.Socket> {\n const { proxy, proxyIsSsl, targetHost, targetPort, logger, stats } = this.options\n\n logger.debug('Creating a tunnel through the proxy...')\n\n if (!proxy) {\n throw HttpEngineErrorFactory.proxyConfigError('No proxy configuration found.')\n }\n\n let proxyUrl = proxy\n if (proxyIsSsl && !proxyUrl.startsWith('https:')) {\n proxyUrl = `https://${proxyUrl}`\n } else if (!proxyIsSsl && !proxyUrl.startsWith('http:')) {\n proxyUrl = `http://${proxyUrl}`\n }\n\n const proxyUri = new URL(proxyUrl)\n const proxyPort = proxyUri.port || (proxyIsSsl ? 443 : 80)\n const authority = `${targetHost}:${targetPort}`\n\n const connectOptions: https.RequestOptions = {\n host: proxyUri.hostname,\n port: proxyPort,\n method: 'CONNECT',\n path: authority,\n headers: {\n host: authority,\n },\n }\n\n if (proxyIsSsl) {\n connectOptions.rejectUnauthorized = false\n // @ts-expect-error This is correct!\n connectOptions.requestOCSP = false\n }\n\n const lib = proxyIsSsl ? https : http\n\n return new Promise((resolve, reject) => {\n stats.connectionTime = Date.now()\n try {\n // Add proxy authorization if available\n const auth = this.authHandler.generateAuthHeader()\n if (auth) {\n logger.debug('Adding proxy authorization.')\n ;(connectOptions.headers as http.OutgoingHttpHeaders)['proxy-authorization'] = auth\n }\n logger.debug('Creating proxy tunnel...')\n const connectRequest = lib.request(connectOptions)\n logger.silly('Proxy tunnel created.')\n connectRequest.once('socket', (socket: net.Socket) => {\n logger.debug('Proxy tunnel socket created.')\n socket.on('lookup', () => {\n logger.debug('Proxy tunnel lookup.')\n stats.lookupTime = Date.now()\n })\n })\n\n connectRequest.on('error', (err) => {\n logger.error('Error establishing proxy tunnel:', err)\n reject(\n HttpEngineErrorFactory.proxyError(\n `Failed to establish proxy tunnel: ${err.message}`,\n (err as Error & { code: string }).code ? Number((err as Error & { code: string }).code) : 111\n )\n )\n })\n\n connectRequest.on('connect', async (res: http.IncomingMessage, socket: net.Socket, head: Buffer) => {\n const time = Date.now()\n logger.debug('Proxy tunnel connected.')\n stats.connectedTime = time\n stats.secureStartTime = time\n if (typeof stats.lookupTime === 'undefined') {\n stats.lookupTime = time\n }\n\n if (res.statusCode === 401) {\n // Handle proxy authentication required\n logger.debug('Proxy tunnel not authorized. Closing.')\n connectRequest.destroy()\n reject(HttpEngineErrorFactory.proxyAuthRequired(res, head))\n return\n } else if (res.statusCode === 407) {\n // Handle proxy authentication\n logger.debug('Proxy tunnel authentication required. Trying to authenticate...')\n try {\n const retryResult = await this.handleProxyAuthentication(res)\n if (retryResult) {\n // Authentication succeeded and we should retry\n connectRequest.destroy()\n socket.destroy()\n\n // Retry the connection with new authentication\n try {\n const retrySocket = await this.connect()\n resolve(retrySocket)\n } catch (retryError) {\n reject(retryError)\n }\n return\n } else {\n // Authentication failed\n logger.warn('Proxy authentication failed. Closing connection.')\n connectRequest.destroy()\n reject(HttpEngineErrorFactory.proxyAuthFailed())\n return\n }\n } catch (error) {\n logger.warn('Error handling proxy authentication:', error)\n connectRequest.destroy()\n reject(error)\n }\n return\n } else if (res.statusCode !== 200) {\n logger.debug(`The proxy tunnel ended with ${res.statusCode} status code. Erroring request.`)\n connectRequest.destroy()\n const errorMessage =\n res.statusMessage || `Proxy tunnel establishment failed with status code ${res.statusCode}`\n const e = HttpEngineErrorFactory.proxyError(errorMessage, res.statusCode)\n reject(e)\n return\n }\n\n logger.debug('Established a proxy tunnel.')\n logger.debug('Upgrading connection to SSL...')\n const tlsSocket = tls.connect({ socket, rejectUnauthorized: false }, () => {\n logger.debug('Connection upgraded to SSL.')\n resolve(tlsSocket)\n })\n tlsSocket.once('secureConnect', () => {\n stats.secureConnectedTime = Date.now()\n })\n })\n\n connectRequest.end()\n } catch (error) {\n reject(error)\n }\n })\n }\n\n private async handleProxyAuthentication(res: http.IncomingMessage): Promise<boolean> {\n if (res.statusCode === 407) {\n const headers = new Headers(res.headers)\n const authHeader = headers.get('proxy-authenticate')\n\n if (authHeader) {\n try {\n const authResponse = this.authHandler.handleChallenge(authHeader)\n if (authResponse) {\n this.options.logger.debug('Generated proxy authentication response')\n this.authHandler.markAuthenticated()\n return true // Indicate successful authentication\n }\n } catch (error) {\n this.options.logger.error('Failed to handle proxy authentication:', error)\n throw error\n }\n } else {\n throw HttpEngineErrorFactory.proxyError('Proxy authentication required but no challenge provided', 407)\n }\n }\n return false // Indicate failed authentication\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export { ConnectionManager, type ConnectionOptions, type ProxyConnectionOptions, type TunnelConnectionOptions, } from './ConnectionManager.js';
2
+ export { DirectConnection } from './DirectConnection.js';
3
+ export { ProxyConnection } from './ProxyConnection.js';
4
+ export { TunnelConnection } from './TunnelConnection.js';
5
+ export { ProxyAuthHandler, type ProxyAuthOptions, type ProxyAuthChallenge } from './ProxyAuthHandler.js';
6
+ export { DigestAuthHandler, type DigestChallenge, type DigestResponse } from './DigestAuthHandler.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/connections/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACxG,OAAO,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAA"}
@@ -0,0 +1,7 @@
1
+ export { ConnectionManager, } from './ConnectionManager.js';
2
+ export { DirectConnection } from './DirectConnection.js';
3
+ export { ProxyConnection } from './ProxyConnection.js';
4
+ export { TunnelConnection } from './TunnelConnection.js';
5
+ export { ProxyAuthHandler } from './ProxyAuthHandler.js';
6
+ export { DigestAuthHandler } from './DigestAuthHandler.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/connections/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAIlB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAkD,MAAM,uBAAuB,CAAA;AACxG,OAAO,EAAE,iBAAiB,EAA6C,MAAM,wBAAwB,CAAA","sourcesContent":["export {\n ConnectionManager,\n type ConnectionOptions,\n type ProxyConnectionOptions,\n type TunnelConnectionOptions,\n} from './ConnectionManager.js'\nexport { DirectConnection } from './DirectConnection.js'\nexport { ProxyConnection } from './ProxyConnection.js'\nexport { TunnelConnection } from './TunnelConnection.js'\nexport { ProxyAuthHandler, type ProxyAuthOptions, type ProxyAuthChallenge } from './ProxyAuthHandler.js'\nexport { DigestAuthHandler, type DigestChallenge, type DigestResponse } from './DigestAuthHandler.js'\n"]}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * HTTP constants used throughout the HTTP engine
3
+ */
4
+ export declare const REDIRECT_START = 300;
5
+ export declare const REDIRECT_END = 399;
6
+ export declare const CLIENT_ERROR_START = 400;
7
+ export declare const CLIENT_ERROR_END = 499;
8
+ export declare const SERVER_ERROR_START = 500;
9
+ export declare const SERVER_ERROR_END = 599;
10
+ export declare const STATUS_OK = 200;
11
+ export declare const STATUS_MOVED_PERMANENTLY = 301;
12
+ export declare const STATUS_FOUND = 302;
13
+ export declare const STATUS_SEE_OTHER = 303;
14
+ export declare const STATUS_NOT_MODIFIED = 304;
15
+ export declare const STATUS_USE_PROXY = 305;
16
+ export declare const STATUS_TEMPORARY_REDIRECT = 307;
17
+ export declare const STATUS_PERMANENT_REDIRECT = 308;
18
+ export declare const STATUS_UNAUTHORIZED = 401;
19
+ export declare const STATUS_PROXY_AUTHENTICATION_REQUIRED = 407;
20
+ export declare const METHOD_GET = "GET";
21
+ export declare const METHOD_HEAD = "HEAD";
22
+ export declare const METHOD_POST = "POST";
23
+ export declare const METHOD_PUT = "PUT";
24
+ export declare const METHOD_DELETE = "DELETE";
25
+ export declare const METHOD_PATCH = "PATCH";
26
+ export declare const METHOD_OPTIONS = "OPTIONS";
27
+ export declare const METHOD_TRACE = "TRACE";
28
+ export declare const METHOD_CONNECT = "CONNECT";
29
+ export declare const HEADER_HOST = "host";
30
+ export declare const HEADER_AUTHORIZATION = "authorization";
31
+ export declare const HEADER_PROXY_AUTHORIZATION = "proxy-authorization";
32
+ export declare const HEADER_CONNECTION = "connection";
33
+ export declare const HEADER_CONTENT_LENGTH = "content-length";
34
+ export declare const HEADER_TRANSFER_ENCODING = "transfer-encoding";
35
+ export declare const HEADER_WWW_AUTHENTICATE = "www-authenticate";
36
+ export declare const HEADER_PROXY_AUTHENTICATE = "proxy-authenticate";
37
+ export declare const KEEP_ALIVE = "keep-alive";
38
+ export declare const CHUNKED = "chunked";
39
+ export declare const HTTP_VERSION = "HTTP/1.1";
40
+ export declare const CRLF = "\r\n";
41
+ export declare const CRLF_BUFFER: Buffer<ArrayBuffer>;
42
+ export declare const DEFAULT_TIMEOUT = 30000;
43
+ export declare const DEFAULT_CONNECT_TIMEOUT = 10000;
44
+ export declare const CHUNK_SIZE_HEX_BASE = 16;
45
+ export declare const MAX_CHUNK_SIZE = 16777216;
46
+ export declare const NTLM_PREFIX = "NTLM ";
47
+ export declare const BASIC_PREFIX = "Basic ";
48
+ export declare const DIGEST_PREFIX = "Digest ";
49
+ /**
50
+ * Check if a status code indicates a redirect
51
+ */
52
+ export declare function isRedirect(status: number): boolean;
53
+ /**
54
+ * Check if a status code indicates a client error
55
+ */
56
+ export declare function isClientError(status: number): boolean;
57
+ /**
58
+ * Check if a status code indicates a server error
59
+ */
60
+ export declare function isServerError(status: number): boolean;
61
+ /**
62
+ * Check if a method should not have a body
63
+ */
64
+ export declare function isMethodWithoutBody(method: string): boolean;
65
+ /**
66
+ * Check if a method is safe (should not have side effects)
67
+ */
68
+ export declare function isSafeMethod(method: string): boolean;
69
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/runtime/http-engine/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,cAAc,MAAM,CAAA;AACjC,eAAO,MAAM,YAAY,MAAM,CAAA;AAC/B,eAAO,MAAM,kBAAkB,MAAM,CAAA;AACrC,eAA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O,MAAM,YAAY,aAAa,CAAA;AAGtC,eAAO,MAAM,IAAI,SAAS,CAAA;AAC1B,eAAO,MAAM,WAAW,qBAAgC,CAAA;AAGxD,eAAO,MAAM,eAAe,QAAQ,CAAA;AACpC,eAAO,MAAM,uBAAuB,QAAQ,CAAA;AAG5C,eAAO,MAAM,mBAAmB,KAAK,CAAA;AACrC,eAAO,MAAM,cAAc,WAAY,CAAA;AAGvC,eAAO,MAAM,WAAW,UAAU,CAAA;AAClC,eAAO,MAAM,YAAY,WAAW,CAAA;AACpC,eAAO,MAAM,aAAa,YAAY,CAAA;AAEtC;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAG3D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGpD"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * HTTP constants used throughout the HTTP engine
3
+ */
4
+ // HTTP Status Code Ranges
5
+ export const REDIRECT_START = 300;
6
+ export const REDIRECT_END = 399;
7
+ export const CLIENT_ERROR_START = 400;
8
+ export const CLIENT_ERROR_END = 499;
9
+ export const SERVER_ERROR_START = 500;
10
+ export const SERVER_ERROR_END = 599;
11
+ // Specific Status Codes
12
+ export const STATUS_OK = 200;
13
+ export const STATUS_MOVED_PERMANENTLY = 301;
14
+ export const STATUS_FOUND = 302;
15
+ export const STATUS_SEE_OTHER = 303;
16
+ export const STATUS_NOT_MODIFIED = 304;
17
+ export const STATUS_USE_PROXY = 305;
18
+ export const STATUS_TEMPORARY_REDIRECT = 307;
19
+ export const STATUS_PERMANENT_REDIRECT = 308;
20
+ export const STATUS_UNAUTHORIZED = 401;
21
+ export const STATUS_PROXY_AUTHENTICATION_REQUIRED = 407;
22
+ // HTTP Methods
23
+ export const METHOD_GET = 'GET';
24
+ export const METHOD_HEAD = 'HEAD';
25
+ export const METHOD_POST = 'POST';
26
+ export const METHOD_PUT = 'PUT';
27
+ export const METHOD_DELETE = 'DELETE';
28
+ export const METHOD_PATCH = 'PATCH';
29
+ export const METHOD_OPTIONS = 'OPTIONS';
30
+ export const METHOD_TRACE = 'TRACE';
31
+ export const METHOD_CONNECT = 'CONNECT';
32
+ // HTTP Headers
33
+ export const HEADER_HOST = 'host';
34
+ export const HEADER_AUTHORIZATION = 'authorization';
35
+ export const HEADER_PROXY_AUTHORIZATION = 'proxy-authorization';
36
+ export const HEADER_CONNECTION = 'connection';
37
+ export const HEADER_CONTENT_LENGTH = 'content-length';
38
+ export const HEADER_TRANSFER_ENCODING = 'transfer-encoding';
39
+ export const HEADER_WWW_AUTHENTICATE = 'www-authenticate';
40
+ export const HEADER_PROXY_AUTHENTICATE = 'proxy-authenticate';
41
+ // HTTP Values
42
+ export const KEEP_ALIVE = 'keep-alive';
43
+ export const CHUNKED = 'chunked';
44
+ export const HTTP_VERSION = 'HTTP/1.1';
45
+ // Buffer Constants
46
+ export const CRLF = '\r\n';
47
+ export const CRLF_BUFFER = Buffer.from([13, 10, 13, 10]); // \r\n\r\n
48
+ // Timeout Constants
49
+ export const DEFAULT_TIMEOUT = 30000; // 30 seconds
50
+ export const DEFAULT_CONNECT_TIMEOUT = 10000; // 10 seconds
51
+ // Chunked Transfer Constants
52
+ export const CHUNK_SIZE_HEX_BASE = 16;
53
+ export const MAX_CHUNK_SIZE = 0x1000000; // 16MB
54
+ // Authentication Constants
55
+ export const NTLM_PREFIX = 'NTLM ';
56
+ export const BASIC_PREFIX = 'Basic ';
57
+ export const DIGEST_PREFIX = 'Digest ';
58
+ /**
59
+ * Check if a status code indicates a redirect
60
+ */
61
+ export function isRedirect(status) {
62
+ return status >= REDIRECT_START && status <= REDIRECT_END;
63
+ }
64
+ /**
65
+ * Check if a status code indicates a client error
66
+ */
67
+ export function isClientError(status) {
68
+ return status >= CLIENT_ERROR_START && status <= CLIENT_ERROR_END;
69
+ }
70
+ /**
71
+ * Check if a status code indicates a server error
72
+ */
73
+ export function isServerError(status) {
74
+ return status >= SERVER_ERROR_START && status <= SERVER_ERROR_END;
75
+ }
76
+ /**
77
+ * Check if a method should not have a body
78
+ */
79
+ export function isMethodWithoutBody(method) {
80
+ const upperMethod = method.toUpperCase();
81
+ return upperMethod === METHOD_GET || upperMethod === METHOD_HEAD;
82
+ }
83
+ /**
84
+ * Check if a method is safe (should not have side effects)
85
+ */
86
+ export function isSafeMethod(method) {
87
+ const upperMethod = method.toUpperCase();
88
+ return upperMethod === METHOD_GET || upperMethod === METHOD_HEAD || upperMethod === METHOD_OPTIONS;
89
+ }
90
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/runtime/http-engine/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0BAA0B;AAC1B,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAC/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAEnC,wBAAwB;AACxB,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;AAC5B,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAC/B,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AACnC,MAAM,CAAC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AI,WAAW,KAAK,WAAW,CAAA;AAClE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;IACxC,OAAO,WAAW,KAAK,UAAU,IAAI,WAAW,KAAK,WAAW,IAAI,WAAW,KAAK,cAAc,CAAA;AACpG,CAAC","sourcesContent":["/**\n * HTTP constants used throughout the HTTP engine\n */\n\n// HTTP Status Code Ranges\nexport const REDIRECT_START = 300\nexport const REDIRECT_END = 399\nexport const CLIENT_ERROR_START = 400\nexport const CLIENT_ERROR_END = 499\nexport const SERVER_ERROR_START = 500\nexport const SERVER_ERROR_END = 599\n\n// Specific Status Codes\nexport const STATUS_OK = 200\nexport const STATUS_MOVED_PERMANENTLY = 301\nexport const STATUS_FOUND = 302\nexport const STATUS_SEE_OTHER = 303\nexport const STATUS_NOT_MODIFIED = 304\nexport const STATUS_USE_PROXY = 305\nexport const STATUS_TEMPORARY_REDIRECT = 307\nexport const STATUS_PERMANENT_REDIRECT = 308\nexport const STATUS_UNAUTHORIZED = 401\nexport const STATUS_PROXY_AUTHENTICATION_REQUIRED = 407\n\n// HTTP Methods\nexport const METHOD_GET = 'GET'\nexport const METHOD_HEAD = 'HEAD'\nexport const METHOD_POST = 'POST'\nexport const METHOD_PUT = 'PUT'\nexport const METHOD_DELETE = 'DELETE'\nexport const METHOD_PATCH = 'PATCH'\nexport const METHOD_OPTIONS = 'OPTIONS'\nexport const METHOD_TRACE = 'TRACE'\nexport const METHOD_CONNECT = 'CONNECT'\n\n// HTTP Headers\nexport const HEADER_HOST = 'host'\nexport const HEADER_AUTHORIZATION = 'authorization'\nexport const HEADER_PROXY_AUTHORIZATION = 'proxy-authorization'\nexport const HEADER_CONNECTION = 'connection'\nexport const HEADER_CONTENT_LENGTH = 'content-length'\nexport const HEADER_TRANSFER_ENCODING = 'transfer-encoding'\nexport const HEADER_WWW_AUTHENTICATE = 'www-authenticate'\nexport const HEADER_PROXY_AUTHENTICATE = 'proxy-authenticate'\n\n// HTTP Values\nexport const KEEP_ALIVE = 'keep-alive'\nexport const CHUNKED = 'chunked'\nexport const HTTP_VERSION = 'HTTP/1.1'\n\n// Buffer Constants\nexport const CRLF = '\\r\\n'\nexport const CRLF_BUFFER = Buffer.from([13, 10, 13, 10]) // \\r\\n\\r\\n\n\n// Timeout Constants\nexport const DEFAULT_TIMEOUT = 30000 // 30 seconds\nexport const DEFAULT_CONNECT_TIMEOUT = 10000 // 10 seconds\n\n// Chunked Transfer Constants\nexport const CHUNK_SIZE_HEX_BASE = 16\nexport const MAX_CHUNK_SIZE = 0x1000000 // 16MB\n\n// Authentication Constants\nexport const NTLM_PREFIX = 'NTLM '\nexport const BASIC_PREFIX = 'Basic '\nexport const DIGEST_PREFIX = 'Digest '\n\n/**\n * Check if a status code indicates a redirect\n */\nexport function isRedirect(status: number): boolean {\n return status >= REDIRECT_START && status <= REDIRECT_END\n}\n\n/**\n * Check if a status code indicates a client error\n */\nexport function isClientError(status: number): boolean {\n return status >= CLIENT_ERROR_START && status <= CLIENT_ERROR_END\n}\n\n/**\n * Check if a status code indicates a server error\n */\nexport function isServerError(status: number): boolean {\n return status >= SERVER_ERROR_START && status <= SERVER_ERROR_END\n}\n\n/**\n * Check if a method should not have a body\n */\nexport function isMethodWithoutBody(method: string): boolean {\n const upperMethod = method.toUpperCase()\n return upperMethod === METHOD_GET || upperMethod === METHOD_HEAD\n}\n\n/**\n * Check if a method is safe (should not have side effects)\n */\nexport function isSafeMethod(method: string): boolean {\n const upperMethod = method.toUpperCase()\n return upperMethod === METHOD_GET || upperMethod === METHOD_HEAD || upperMethod === METHOD_OPTIONS\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Handles cookie exchange when redirecting the request.
3
+ */
4
+ export declare function processRedirectCookies(responseCookies: string, location: string, requestUrl: string, requestHeaders: string): string;
5
+ //# sourceMappingURL=CookieProcessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CookieProcessor.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/cookies/CookieProcessor.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,MAAM,CAaR"}
@@ -0,0 +1,20 @@
1
+ import { Headers } from '../../../lib/headers/Headers.js';
2
+ import { CookieParser } from '../../../cookies/CookieParser.js';
3
+ /**
4
+ * Handles cookie exchange when redirecting the request.
5
+ */
6
+ export function processRedirectCookies(responseCookies, location, requestUrl, requestHeaders) {
7
+ const received = CookieParser.parse(requestUrl, responseCookies);
8
+ const forwardCookies = CookieParser.filterCookies(received, location);
9
+ const headers = new Headers(requestHeaders);
10
+ headers.delete('cookie');
11
+ if (forwardCookies.length) {
12
+ const parts = [];
13
+ forwardCookies.forEach((cookie) => {
14
+ parts.push(cookie.toString());
15
+ });
16
+ headers.set('cookie', parts.join('; '));
17
+ }
18
+ return headers.toString();
19
+ }
20
+ //# sourceMappingURL=CookieProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CookieProcessor.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/cookies/CookieProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAE/D;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,eAAuB,EACvB,QAAgB,EAChB,UAAkB,EAClB,cAAsB;IAEtB,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE,eAAe,CAAC,CAAA;IAChE,MAAM,cAAc,GAAG,YAAY,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACrE,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC,CAAA;IAC3C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACxB,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAa,EAAE,CAAA;QAC1B,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAChC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC/B,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACzC,CAAC;IACD,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAA;AAC3B,CAAC","sourcesContent":["import { Headers } from '../../../lib/headers/Headers.js'\nimport { CookieParser } from '../../../cookies/CookieParser.js'\n\n/**\n * Handles cookie exchange when redirecting the request.\n */\nexport function processRedirectCookies(\n responseCookies: string,\n location: string,\n requestUrl: string,\n requestHeaders: string\n): string {\n const received = CookieParser.parse(requestUrl, responseCookies)\n const forwardCookies = CookieParser.filterCookies(received, location)\n const headers = new Headers(requestHeaders)\n headers.delete('cookie')\n if (forwardCookies.length) {\n const parts: string[] = []\n forwardCookies.forEach((cookie) => {\n parts.push(cookie.toString())\n })\n headers.set('cookie', parts.join('; '))\n }\n return headers.toString()\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { processRedirectCookies } from './CookieProcessor.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/cookies/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { processRedirectCookies } from './CookieProcessor.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/cookies/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA","sourcesContent":["export { processRedirectCookies } from './CookieProcessor.js'\n"]}