@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":"AuthManager.js","sourceRoot":"","sources":["../../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AAQ,CAAC,QAAQ,CAAC,CAAA;QACvE,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,GAAG,YAAY,GAAG,KAAK,EAAE,CAAC,CAAA;IAC9D,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,KAAa,EAAE,OAAgB;QAC9C,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,UAAU,KAAK,EAAE,CAAC,CAAA;IACtD,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,KAAwB;QACnC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;IACxB,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAA;IACzB,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC,gBAAgB,IAAI,EAAE,CAAA;QACxF,OAAO,CAAC,CAAC,CAAC,aAAa,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,kBAAkB,CAAA;IACnE,CAAC;CACF","sourcesContent":["import { Headers } from '../../../lib/headers/Headers.js'\nimport { type Logger, type ILogObj } from '../../../lib/logging/index.js'\nimport type { INtlmAuthorization, IAuthorizationSettingsUnion } from '../../../models/Authorization.js'\nimport { NtlmAuth } from '../ntlm/NtlmAuth.js'\nimport type { IRequestAuthState } from '../CoreEngine.js'\nimport { HttpEngineErrorFactory } from '../errors/index.js'\nimport {\n HEADER_AUTHORIZATION,\n HEADER_CONNECTION,\n HEADER_WWW_AUTHENTICATE,\n NTLM_PREFIX,\n KEEP_ALIVE,\n BASIC_PREFIX,\n} from '../constants.js'\n\nexport interface ProxyAuthCredentials {\n proxyUsername?: string\n proxyPassword?: string\n proxyAuthorization?: string\n}\n\nexport interface AuthOptions {\n logger: Logger<ILogObj>\n proxyCredentials?: ProxyAuthCredentials\n}\n\nexport interface AuthorizationConfig {\n type: string\n enabled: boolean\n config?: IAuthorizationSettingsUnion\n}\n\n/**\n * Manages all authentication logic for HTTP requests\n */\nexport class AuthManager {\n private logger: Logger<ILogObj>\n private proxyCredentials?: ProxyAuthCredentials\n private authState?: IRequestAuthState\n\n constructor(options: AuthOptions) {\n this.logger = options.logger\n this.proxyCredentials = options.proxyCredentials\n }\n\n /**\n * Handle all authorization types for request headers.\n * It applied authorization data defined on the request object.\n */\n handleRequestAuthorization(headers: Headers, authorizationConfig?: AuthorizationConfig[], hostname?: string): void {\n if (!authorizationConfig || !Array.isArray(authorizationConfig)) {\n this.logger.debug(`No authorization data on the request. Skipping setting up authorization.`)\n return\n }\n\n const enabled = authorizationConfig.filter((i) => i.enabled)\n if (!enabled.length) {\n this.logger.debug(`No enabled authorization data on the request. Skipping setting up authorization.`)\n return\n }\n\n const ntlm = enabled.find((i) => i.type === 'ntlm')\n if (ntlm && ntlm.config) {\n this.logger.debug(`Found NTLM authorization config.`)\n this.handleNtlmAuth(ntlm.config as unknown as INtlmAuthorization, headers, hostname)\n }\n\n const basic = enabled.find((i) => i.type === 'basic')\n if (basic && basic.config) {\n this.logger.debug(`Found basic authorization config.`)\n const config = basic.config as { username?: string; password?: string }\n if (config.username && config.password) {\n this.handleBasicAuth(config.username, config.password, headers)\n }\n }\n\n const bearer = enabled.find((i) => i.type === 'bearer')\n if (bearer && bearer.config) {\n this.logger.debug(`Found bearer authorization config.`)\n const config = bearer.config as { token?: string }\n if (config.token) {\n this.handleBearerAuth(config.token, headers)\n }\n }\n }\n\n /**\n * Handle NTLM authentication\n */\n handleNtlmAuth(authData: INtlmAuthorization, headers: Headers, hostname?: string): void {\n try {\n const auth = new NtlmAuth(authData)\n if (!this.authState) {\n this.authState = {\n method: 'ntlm',\n state: 0,\n headers: headers.toString(),\n }\n // Use the provided hostname or empty string for Message1\n const msg = auth.createMessage1(hostname || '')\n headers.set(HEADER_AUTHORIZATION, `${NTLM_PREFIX}${msg.toBase64()}`)\n headers.set(HEADER_CONNECTION, KEEP_ALIVE)\n this.logger.debug('Set NTLM message1 header with hostname:', hostname || '')\n } else if (this.authState && this.authState.state === 1) {\n if (!this.authState.challengeHeader) {\n throw new Error('NTLM challenge header is missing')\n }\n // Use the provided hostname or empty string for Message3\n const msg = auth.createMessage3(this.authState.challengeHeader, hostname || '')\n this.authState.state = 2\n headers.set(HEADER_AUTHORIZATION, `${NTLM_PREFIX}${msg.toBase64()}`)\n this.logger.debug('Set NTLM message3 header with hostname:', hostname || '')\n } else {\n this.logger.warn('Invalid NTLM state:', this.authState?.state)\n }\n } catch (error) {\n this.logger.error('NTLM authentication error:', error)\n delete this.authState\n throw HttpEngineErrorFactory.authenticationError(\n `NTLM authentication failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n undefined,\n 'ntlm'\n )\n }\n }\n\n /**\n * Handle NTLM response from server\n */\n handleNtlmResponse(headers: Headers): boolean {\n if (!this.authState) {\n throw HttpEngineErrorFactory.authenticationError('No auth data.', undefined, 'ntlm')\n }\n this.logger.debug('Handling NTLM response.')\n if (this.authState.state === 0) {\n if (headers.has(HEADER_WWW_AUTHENTICATE)) {\n this.authState.state = 1\n const authHeader = headers.get(HEADER_WWW_AUTHENTICATE)\n // Extract just the base64 part after \"NTLM \" prefix\n this.authState.challengeHeader = authHeader?.replace(/^NTLM\\s+/i, '') || ''\n\n if (!this.authState.challengeHeader) {\n this.logger.error('NTLM challenge header is empty after parsing')\n delete this.authState\n return false\n }\n\n this.logger.debug('NTLM challenge header was set:', this.authState.challengeHeader)\n return true // Indicates we need to retry with challenge\n }\n }\n\n // Authentication complete or failed\n this.logger.debug('NTLM authentication complete or failed.')\n delete this.authState\n return false\n }\n\n /**\n * Generate proxy authorization header\n */\n generateProxyAuthHeader(): string | undefined {\n const { proxyUsername, proxyPassword, proxyAuthorization } = this.proxyCredentials || {}\n\n if (!proxyUsername || !proxyPassword) {\n if (!proxyAuthorization) {\n return undefined\n }\n return proxyAuthorization\n }\n\n if (!proxyAuthorization || proxyAuthorization === 'Basic') {\n // Basic authentication\n const token = Buffer.from(`${proxyUsername}:${proxyPassword}`).toString('base64')\n return `${BASIC_PREFIX}${token}`\n }\n\n if (proxyAuthorization === 'Digest') {\n // Note: Digest authentication is handled by ProxyAuthHandler in connections\n // This is just a placeholder for the header format\n this.logger.warn('Digest proxy authentication should be handled by ProxyAuthHandler')\n return undefined\n }\n\n throw HttpEngineErrorFactory.authenticationError(\n `Unsupported proxy authorization type: ${proxyAuthorization}`,\n undefined,\n 'proxy'\n )\n }\n\n /**\n * Handle Basic authentication\n */\n handleBasicAuth(username: string, password: string, headers: Headers): void {\n const token = Buffer.from(`${username}:${password}`).toString('base64')\n headers.set(HEADER_AUTHORIZATION, `${BASIC_PREFIX}${token}`)\n }\n\n /**\n * Handle Bearer token authentication\n */\n handleBearerAuth(token: string, headers: Headers): void {\n headers.set(HEADER_AUTHORIZATION, `Bearer ${token}`)\n }\n\n /**\n * Get current authentication state\n */\n getAuthState(): IRequestAuthState | undefined {\n return this.authState\n }\n\n /**\n * Set authentication state\n */\n setAuthState(state: IRequestAuthState): void {\n this.authState = state\n }\n\n /**\n * Clear authentication state\n */\n clearAuthState(): void {\n delete this.authState\n }\n\n /**\n * Check if authentication is in progress\n */\n isAuthenticating(): boolean {\n return !!this.authState\n }\n\n /**\n * Check if we have credentials for proxy authentication\n */\n hasProxyCredentials(): boolean {\n const { proxyUsername, proxyPassword, proxyAuthorization } = this.proxyCredentials || {}\n return !!(proxyUsername && proxyPassword) || !!proxyAuthorization\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { AuthManager, type ProxyAuthCredentials, type AuthOptions, type AuthorizationConfig } from './AuthManager.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { AuthManager } from './AuthManager.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAyE,MAAM,kBAAkB,CAAA","sourcesContent":["export { AuthManager, type ProxyAuthCredentials, type AuthOptions, type AuthorizationConfig } from './AuthManager.js'\n"]}
@@ -0,0 +1,11 @@
1
+ import tls from 'tls';
2
+ import { HttpCertificate } from '../../../models/ClientCertificate.js';
3
+ /**
4
+ * Adds client certificate to the request configuration options.
5
+ */
6
+ export declare function addClientCertificate(certificate: HttpCertificate | null, options: tls.ConnectionOptions): void;
7
+ /**
8
+ * Checks certificate identity using TLS api.
9
+ */
10
+ export declare function checkServerIdentity(host: string, cert: tls.PeerCertificate | null): Error | undefined;
11
+ //# sourceMappingURL=CertificateManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CertificateManager.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/certificates/CertificateManager.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,eAAe,EAAmB,MAAM,sCAAsC,CAAA;AAEvF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,iBAAiB,GAAG,IAAI,CAsD9G;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,eAAe,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,CAQrG"}
@@ -0,0 +1,76 @@
1
+ import tls from 'tls';
2
+ /**
3
+ * Adds client certificate to the request configuration options.
4
+ */
5
+ export function addClientCertificate(certificate, options) {
6
+ if (!certificate) {
7
+ return;
8
+ }
9
+ const cert = { ...certificate };
10
+ if (cert.type === 'p12') {
11
+ if (!options.pfx) {
12
+ options.pfx = [];
13
+ }
14
+ const struct = {
15
+ buf: Buffer.from(cert.cert.data),
16
+ };
17
+ if (cert.cert.passphrase) {
18
+ struct.passphrase = cert.cert.passphrase;
19
+ }
20
+ if (!Array.isArray(options.pfx)) {
21
+ if (options.pfx) {
22
+ options.pfx = [options.pfx];
23
+ }
24
+ else {
25
+ options.pfx = [];
26
+ }
27
+ }
28
+ options.pfx.push(struct);
29
+ }
30
+ else if (cert.type === 'pem') {
31
+ const typed = cert;
32
+ if (!options.cert) {
33
+ options.cert = [];
34
+ }
35
+ if (!Array.isArray(options.cert)) {
36
+ if (options.cert) {
37
+ options.cert = [options.cert];
38
+ }
39
+ else {
40
+ options.cert = [];
41
+ }
42
+ }
43
+ const added = Buffer.from(typed.cert.data);
44
+ options.cert.push(added);
45
+ if (typed.certKey) {
46
+ if (!Array.isArray(options.key)) {
47
+ if (options.key) {
48
+ options.key = [options.key];
49
+ }
50
+ else {
51
+ options.key = [];
52
+ }
53
+ }
54
+ const struct = {
55
+ pem: Buffer.from(typed.certKey.data),
56
+ };
57
+ if (typed.certKey.passphrase) {
58
+ struct.passphrase = typed.certKey.passphrase;
59
+ }
60
+ options.key.push(struct);
61
+ }
62
+ }
63
+ }
64
+ /**
65
+ * Checks certificate identity using TLS api.
66
+ */
67
+ export function checkServerIdentity(host, cert) {
68
+ if (!cert) {
69
+ return new Error('Certificate is required');
70
+ }
71
+ const err = tls.checkServerIdentity(host, cert);
72
+ if (err) {
73
+ return err;
74
+ }
75
+ }
76
+ //# sourceMappingURL=CertificateManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CertificateManager.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/certificates/Cert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AAG,GAAG,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC/C,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,GAAG,CAAA;IACZ,CAAC;AACH,CAAC","sourcesContent":["import tls from 'tls'\nimport { HttpCertificate, IPemCertificate } from '../../../models/ClientCertificate.js'\n\n/**\n * Adds client certificate to the request configuration options.\n */\nexport function addClientCertificate(certificate: HttpCertificate | null, options: tls.ConnectionOptions): void {\n if (!certificate) {\n return\n }\n const cert = { ...certificate }\n if (cert.type === 'p12') {\n if (!options.pfx) {\n options.pfx = []\n }\n const struct: tls.PxfObject = {\n buf: Buffer.from(cert.cert.data as Buffer),\n }\n if (cert.cert.passphrase) {\n struct.passphrase = cert.cert.passphrase\n }\n if (!Array.isArray(options.pfx)) {\n if (options.pfx) {\n options.pfx = [options.pfx]\n } else {\n options.pfx = []\n }\n }\n options.pfx.push(struct)\n } else if (cert.type === 'pem') {\n const typed = cert as IPemCertificate\n if (!options.cert) {\n options.cert = []\n }\n if (!Array.isArray(options.cert)) {\n if (options.cert) {\n options.cert = [options.cert]\n } else {\n options.cert = []\n }\n }\n const added = Buffer.from(typed.cert.data as Buffer | Uint8Array)\n options.cert.push(added)\n if (typed.certKey) {\n if (!Array.isArray(options.key)) {\n if (options.key) {\n options.key = [options.key]\n } else {\n options.key = []\n }\n }\n const struct: tls.KeyObject = {\n pem: Buffer.from(typed.certKey.data as Buffer | Uint8Array),\n }\n if (typed.certKey.passphrase) {\n struct.passphrase = typed.certKey.passphrase\n }\n options.key.push(struct)\n }\n }\n}\n\n/**\n * Checks certificate identity using TLS api.\n */\nexport function checkServerIdentity(host: string, cert: tls.PeerCertificate | null): Error | undefined {\n if (!cert) {\n return new Error('Certificate is required')\n }\n const err = tls.checkServerIdentity(host, cert)\n if (err) {\n return err\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { addClientCertificate, checkServerIdentity } from './CertificateManager.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/certificates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { addClientCertificate, checkServerIdentity } from './CertificateManager.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/certificates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA","sourcesContent":["export { addClientCertificate, checkServerIdentity } from './CertificateManager.js'\n"]}
@@ -0,0 +1,25 @@
1
+ import { Headers } from '../../../lib/headers/Headers.js';
2
+ import { WithImplicitCoercion } from 'buffer';
3
+ export interface CompressionOptions {
4
+ aborted?: boolean;
5
+ headers?: Headers;
6
+ }
7
+ /**
8
+ * Decompresses received body if `content-encoding` header is set.
9
+ * When multiple encodings are present, they are decoded in reverse order
10
+ * (last applied encoding is decoded first).
11
+ */
12
+ export declare function decompress(body?: Buffer, options?: CompressionOptions): Promise<Buffer | undefined>;
13
+ /**
14
+ * Decompress body with Inflate.
15
+ */
16
+ export declare function inflate(body: WithImplicitCoercion<ArrayLike<number>>): Promise<Buffer>;
17
+ /**
18
+ * Decompress body with ZLib.
19
+ */
20
+ export declare function gunzip(body: WithImplicitCoercion<ArrayLike<number>>): Promise<Buffer>;
21
+ /**
22
+ * Decompress Brotli.
23
+ */
24
+ export declare function brotli(body: WithImplicitCoercion<ArrayLike<number>>): Promise<Buffer>;
25
+ //# sourceMappingURL=CompressionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompressionManager.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/compression/CompressionManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAE7C,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoC7G;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAWtF;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAWrF;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAWrF"}
@@ -0,0 +1,89 @@
1
+ import zlib from 'zlib';
2
+ /**
3
+ * Decompresses received body if `content-encoding` header is set.
4
+ * When multiple encodings are present, they are decoded in reverse order
5
+ * (last applied encoding is decoded first).
6
+ */
7
+ export async function decompress(body, options = {}) {
8
+ const { aborted, headers } = options;
9
+ if (aborted || !headers || !body) {
10
+ return;
11
+ }
12
+ const ce = headers.get('content-encoding');
13
+ if (!ce) {
14
+ return body;
15
+ }
16
+ // Parse encodings from the header - they are listed in the order they were applied
17
+ const encodings = ce
18
+ .split(',')
19
+ .map((enc) => enc.trim().toLowerCase())
20
+ .filter((enc) => enc.length > 0);
21
+ if (encodings.length === 0) {
22
+ return body;
23
+ }
24
+ // Decode in reverse order (last applied encoding first)
25
+ let currentBody = body;
26
+ for (let i = encodings.length - 1; i >= 0; i--) {
27
+ const encoding = encodings[i];
28
+ if (encoding === 'deflate') {
29
+ currentBody = await inflate(currentBody);
30
+ }
31
+ else if (encoding === 'gzip') {
32
+ currentBody = await gunzip(currentBody);
33
+ }
34
+ else if (encoding === 'br' || encoding === 'brotli') {
35
+ currentBody = await brotli(currentBody);
36
+ }
37
+ // If encoding is unknown, we continue with the current body unchanged
38
+ }
39
+ return currentBody;
40
+ }
41
+ /**
42
+ * Decompress body with Inflate.
43
+ */
44
+ export function inflate(body) {
45
+ const buff = Buffer.from(body);
46
+ return new Promise((resolve, reject) => {
47
+ zlib.inflate(buff, (err, buffer) => {
48
+ if (err) {
49
+ reject(new Error(err.message || String(err)));
50
+ }
51
+ else {
52
+ resolve(buffer);
53
+ }
54
+ });
55
+ });
56
+ }
57
+ /**
58
+ * Decompress body with ZLib.
59
+ */
60
+ export function gunzip(body) {
61
+ const buff = Buffer.from(body);
62
+ return new Promise((resolve, reject) => {
63
+ zlib.gunzip(buff, (err, buffer) => {
64
+ if (err) {
65
+ reject(new Error(err.message || String(err)));
66
+ }
67
+ else {
68
+ resolve(buffer);
69
+ }
70
+ });
71
+ });
72
+ }
73
+ /**
74
+ * Decompress Brotli.
75
+ */
76
+ export function brotli(body) {
77
+ const buff = Buffer.from(body);
78
+ return new Promise((resolve, reject) => {
79
+ zlib.brotliDecompress(buff, (err, buffer) => {
80
+ if (err) {
81
+ reject(err);
82
+ }
83
+ else {
84
+ resolve(buffer);
85
+ }
86
+ });
87
+ });
88
+ }
89
+ //# sourceMappingURL=CompressionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompressionManager.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/compression/CompressionManager.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AASvB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAa,EAAE,UAA8B,EAAE;IAC9E,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;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CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,GAAiB,EAAE,MAAc,EAAE,EAAE;YAChE,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,CAAC,GAAG,CAAC,CAAA;YACb,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC,CAAA;YACjB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import zlib from 'zlib'\nimport { Headers } from '../../../lib/headers/Headers.js'\nimport { WithImplicitCoercion } from 'buffer'\n\nexport interface CompressionOptions {\n aborted?: boolean\n headers?: Headers\n}\n\n/**\n * Decompresses received body if `content-encoding` header is set.\n * When multiple encodings are present, they are decoded in reverse order\n * (last applied encoding is decoded first).\n */\nexport async function decompress(body?: Buffer, options: CompressionOptions = {}): Promise<Buffer | undefined> {\n const { aborted, headers } = options\n if (aborted || !headers || !body) {\n return\n }\n const ce = headers.get('content-encoding')\n if (!ce) {\n return body\n }\n\n // Parse encodings from the header - they are listed in the order they were applied\n const encodings = ce\n .split(',')\n .map((enc) => enc.trim().toLowerCase())\n .filter((enc) => enc.length > 0)\n\n if (encodings.length === 0) {\n return body\n }\n\n // Decode in reverse order (last applied encoding first)\n let currentBody = body\n for (let i = encodings.length - 1; i >= 0; i--) {\n const encoding = encodings[i]\n\n if (encoding === 'deflate') {\n currentBody = await inflate(currentBody)\n } else if (encoding === 'gzip') {\n currentBody = await gunzip(currentBody)\n } else if (encoding === 'br' || encoding === 'brotli') {\n currentBody = await brotli(currentBody)\n }\n // If encoding is unknown, we continue with the current body unchanged\n }\n\n return currentBody\n}\n\n/**\n * Decompress body with Inflate.\n */\nexport function inflate(body: WithImplicitCoercion<ArrayLike<number>>): Promise<Buffer> {\n const buff = Buffer.from(body)\n return new Promise((resolve, reject) => {\n zlib.inflate(buff, (err: Error | null, buffer: Buffer) => {\n if (err) {\n reject(new Error(err.message || String(err)))\n } else {\n resolve(buffer)\n }\n })\n })\n}\n\n/**\n * Decompress body with ZLib.\n */\nexport function gunzip(body: WithImplicitCoercion<ArrayLike<number>>): Promise<Buffer> {\n const buff = Buffer.from(body)\n return new Promise((resolve, reject) => {\n zlib.gunzip(buff, (err: Error | null, buffer: Buffer) => {\n if (err) {\n reject(new Error(err.message || String(err)))\n } else {\n resolve(buffer)\n }\n })\n })\n}\n\n/**\n * Decompress Brotli.\n */\nexport function brotli(body: WithImplicitCoercion<ArrayLike<number>>): Promise<Buffer> {\n const buff = Buffer.from(body)\n return new Promise((resolve, reject) => {\n zlib.brotliDecompress(buff, (err: Error | null, buffer: Buffer) => {\n if (err) {\n reject(err)\n } else {\n resolve(buffer)\n }\n })\n })\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { decompress, inflate, gunzip, brotli, type CompressionOptions } from './CompressionManager.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/compression/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { decompress, inflate, gunzip, brotli } from './CompressionManager.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/compression/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAA2B,MAAM,yBAAyB,CAAA","sourcesContent":["export { decompress, inflate, gunzip, brotli, type CompressionOptions } from './CompressionManager.js'\n"]}
@@ -0,0 +1,57 @@
1
+ import net from 'net';
2
+ import { type Logger, type ILogObj } from '../../../lib/logging/index.js';
3
+ import type { RequestStats, HttpEngineOptions } from '../CoreEngine.js';
4
+ import { DirectConnection } from './DirectConnection.js';
5
+ import { ProxyConnection } from './ProxyConnection.js';
6
+ import { TunnelConnection } from './TunnelConnection.js';
7
+ import { HttpCertificate } from '../../../models/ClientCertificate.js';
8
+ export interface ConnectionOptions {
9
+ host: string;
10
+ port: number;
11
+ protocol?: string;
12
+ timeout?: number;
13
+ validateCertificates?: boolean;
14
+ certificates?: HttpCertificate[];
15
+ logger: Logger<ILogObj>;
16
+ stats: RequestStats;
17
+ }
18
+ export interface ProxyConnectionOptions extends ConnectionOptions {
19
+ proxy: string;
20
+ proxyIsSsl: boolean;
21
+ targetUrl: string;
22
+ proxyUsername?: string;
23
+ proxyPassword?: string;
24
+ /**
25
+ * The type of proxy authentication to use.
26
+ */
27
+ proxyAuthorization?: 'Basic';
28
+ }
29
+ export interface TunnelConnectionOptions extends ProxyConnectionOptions {
30
+ targetHost: string;
31
+ targetPort: number;
32
+ }
33
+ /**
34
+ * Manages different types of HTTP connections
35
+ */
36
+ export declare class ConnectionManager {
37
+ private logger;
38
+ private stats;
39
+ constructor(logger: Logger<ILogObj>, stats: RequestStats);
40
+ /**
41
+ * Create a direct connection (HTTP or HTTPS)
42
+ */
43
+ createDirectConnection(options: ConnectionOptions): DirectConnection;
44
+ /**
45
+ * Create a proxy connection for HTTP requests
46
+ */
47
+ createProxyConnection(options: ProxyConnectionOptions): ProxyConnection;
48
+ /**
49
+ * Create a tunnel connection for HTTPS requests through proxy
50
+ */
51
+ createTunnelConnection(options: TunnelConnectionOptions): TunnelConnection;
52
+ /**
53
+ * Determine the appropriate connection type and create it
54
+ */
55
+ createConnection(host: string, port: number, protocol: string, engineOptions: HttpEngineOptions): Promise<net.Socket>;
56
+ }
57
+ //# sourceMappingURL=ConnectionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionManager.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/connections/ConnectionManager.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,KAAK,MAAM,E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B,GAAG,gBAAgB;IAIpE;;OAEG;IACH,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe;IAIvE;;OAEG;IACH,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,gBAAgB;IAI1E;;OAEG;IACH,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,iBAAiB,GAC/B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;CA6CvB"}
@@ -0,0 +1,78 @@
1
+ import { DirectConnection } from './DirectConnection.js';
2
+ import { ProxyConnection } from './ProxyConnection.js';
3
+ import { TunnelConnection } from './TunnelConnection.js';
4
+ /**
5
+ * Manages different types of HTTP connections
6
+ */
7
+ export class ConnectionManager {
8
+ logger;
9
+ stats;
10
+ constructor(logger, stats) {
11
+ this.logger = logger;
12
+ this.stats = stats;
13
+ }
14
+ /**
15
+ * Create a direct connection (HTTP or HTTPS)
16
+ */
17
+ createDirectConnection(options) {
18
+ return new DirectConnection(options);
19
+ }
20
+ /**
21
+ * Create a proxy connection for HTTP requests
22
+ */
23
+ createProxyConnection(options) {
24
+ return new ProxyConnection(options);
25
+ }
26
+ /**
27
+ * Create a tunnel connection for HTTPS requests through proxy
28
+ */
29
+ createTunnelConnection(options) {
30
+ return new TunnelConnection(options);
31
+ }
32
+ /**
33
+ * Determine the appropriate connection type and create it
34
+ */
35
+ createConnection(host, port, protocol, engineOptions) {
36
+ const connectionOptions = {
37
+ host,
38
+ port,
39
+ protocol,
40
+ timeout: engineOptions.timeout,
41
+ validateCertificates: engineOptions.validateCertificates,
42
+ certificates: engineOptions.certificates,
43
+ logger: this.logger,
44
+ stats: this.stats,
45
+ };
46
+ // Direct connection
47
+ if (!engineOptions.proxy) {
48
+ this.logger.debug('Deciding to create a direct connection...');
49
+ const directConnection = this.createDirectConnection(connectionOptions);
50
+ return directConnection.connect();
51
+ }
52
+ // Proxy connection
53
+ const proxyOptions = {
54
+ ...connectionOptions,
55
+ proxy: engineOptions.proxy,
56
+ proxyIsSsl: engineOptions.proxy.startsWith('https:'),
57
+ targetUrl: `${protocol}//${host}:${port}`,
58
+ proxyUsername: engineOptions.proxyUsername,
59
+ proxyPassword: engineOptions.proxyPassword,
60
+ proxyAuthorization: engineOptions.proxyAuthorization,
61
+ };
62
+ // Check if we need a tunnel (HTTPS target through proxy)
63
+ if (protocol === 'https:') {
64
+ this.logger.debug('Deciding to create a tunnel connection through the proxy...');
65
+ const tunnelOptions = {
66
+ ...proxyOptions,
67
+ targetHost: host,
68
+ targetPort: port,
69
+ };
70
+ const tunnelConnection = this.createTunnelConnection(tunnelOptions);
71
+ return tunnelConnection.connect();
72
+ }
73
+ this.logger.debug('Deciding to create a proxy connection...');
74
+ const proxyConnection = this.createProxyConnection(proxyOptions);
75
+ return proxyConnection.connect();
76
+ }
77
+ }
78
+ //# sourceMappingURL=ConnectionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/connections/ConnectionManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AA+BxD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACpB,MAAM,CAAiB;IACvB,KAAK,CAAc;IAE3B,YAAY,MAAuB,EAAE,KAAmB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED;;OAEG;IACH,sBAAsB,CAAC,OAA0B;QAC/C,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACtC,CAAC;IAED;;OAEG;IACH,qBAAqB,CAAC,OAA+B;QACnD,OAAO,IAAI,eAAe,CA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AC7C,GAAG,YAAY;gBACf,UAAU,EAAE,IAAI;gBAChB,UAAU,EAAE,IAAI;aACjB,CAAA;YACD,MAAM,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAA;YACnE,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAA;QACnC,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAA;QAC7D,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAA;QAChE,OAAO,eAAe,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;CACF","sourcesContent":["import net from 'net'\nimport { type Logger, type ILogObj } from '../../../lib/logging/index.js'\nimport type { RequestStats, HttpEngineOptions } from '../CoreEngine.js'\nimport { DirectConnection } from './DirectConnection.js'\nimport { ProxyConnection } from './ProxyConnection.js'\nimport { TunnelConnection } from './TunnelConnection.js'\nimport { HttpCertificate } from '../../../models/ClientCertificate.js'\n\nexport interface ConnectionOptions {\n host: string\n port: number\n protocol?: string\n timeout?: number\n validateCertificates?: boolean\n certificates?: HttpCertificate[]\n logger: Logger<ILogObj>\n stats: RequestStats\n}\n\nexport interface ProxyConnectionOptions extends ConnectionOptions {\n proxy: string\n proxyIsSsl: boolean\n targetUrl: string\n proxyUsername?: string\n proxyPassword?: string\n /**\n * The type of proxy authentication to use.\n */\n proxyAuthorization?: 'Basic'\n}\n\nexport interface TunnelConnectionOptions extends ProxyConnectionOptions {\n targetHost: string\n targetPort: number\n}\n\n/**\n * Manages different types of HTTP connections\n */\nexport class ConnectionManager {\n private logger: Logger<ILogObj>\n private stats: RequestStats\n\n constructor(logger: Logger<ILogObj>, stats: RequestStats) {\n this.logger = logger\n this.stats = stats\n }\n\n /**\n * Create a direct connection (HTTP or HTTPS)\n */\n createDirectConnection(options: ConnectionOptions): DirectConnection {\n return new DirectConnection(options)\n }\n\n /**\n * Create a proxy connection for HTTP requests\n */\n createProxyConnection(options: ProxyConnectionOptions): ProxyConnection {\n return new ProxyConnection(options)\n }\n\n /**\n * Create a tunnel connection for HTTPS requests through proxy\n */\n createTunnelConnection(options: TunnelConnectionOptions): TunnelConnection {\n return new TunnelConnection(options)\n }\n\n /**\n * Determine the appropriate connection type and create it\n */\n createConnection(\n host: string,\n port: number,\n protocol: string,\n engineOptions: HttpEngineOptions\n ): Promise<net.Socket> {\n const connectionOptions: ConnectionOptions = {\n host,\n port,\n protocol,\n timeout: engineOptions.timeout,\n validateCertificates: engineOptions.validateCertificates,\n certificates: engineOptions.certificates,\n logger: this.logger,\n stats: this.stats,\n }\n\n // Direct connection\n if (!engineOptions.proxy) {\n this.logger.debug('Deciding to create a direct connection...')\n const directConnection = this.createDirectConnection(connectionOptions)\n return directConnection.connect()\n }\n\n // Proxy connection\n const proxyOptions: ProxyConnectionOptions = {\n ...connectionOptions,\n proxy: engineOptions.proxy,\n proxyIsSsl: engineOptions.proxy.startsWith('https:'),\n targetUrl: `${protocol}//${host}:${port}`,\n proxyUsername: engineOptions.proxyUsername,\n proxyPassword: engineOptions.proxyPassword,\n proxyAuthorization: engineOptions.proxyAuthorization,\n }\n\n // Check if we need a tunnel (HTTPS target through proxy)\n if (protocol === 'https:') {\n this.logger.debug('Deciding to create a tunnel connection through the proxy...')\n const tunnelOptions: TunnelConnectionOptions = {\n ...proxyOptions,\n targetHost: host,\n targetPort: port,\n }\n const tunnelConnection = this.createTunnelConnection(tunnelOptions)\n return tunnelConnection.connect()\n }\n this.logger.debug('Deciding to create a proxy connection...')\n const proxyConnection = this.createProxyConnection(proxyOptions)\n return proxyConnection.connect()\n }\n}\n"]}
@@ -0,0 +1,70 @@
1
+ import { type Logger, type ILogObj } from '../../../lib/logging/index.js';
2
+ export interface DigestChallenge {
3
+ realm: string;
4
+ nonce: string;
5
+ qop?: string;
6
+ algorithm?: string;
7
+ opaque?: string;
8
+ stale?: string;
9
+ domain?: string;
10
+ }
11
+ export interface DigestResponse {
12
+ username: string;
13
+ realm: string;
14
+ nonce: string;
15
+ uri: string;
16
+ response: string;
17
+ qop?: string;
18
+ nc?: string;
19
+ cnonce?: string;
20
+ algorithm?: string;
21
+ opaque?: string;
22
+ }
23
+ /**
24
+ * Handles HTTP Digest authentication according to RFC 2617
25
+ */
26
+ export declare class DigestAuthHandler {
27
+ private logger;
28
+ private username;
29
+ private password;
30
+ private nc;
31
+ private cnonce;
32
+ constructor(username: string, password: string, logger: Logger<ILogObj>);
33
+ /**
34
+ * Parse a WWW-Authenticate or Proxy-Authenticate header
35
+ */
36
+ parseChallenge(authenticateHeader: string): DigestChallenge;
37
+ /**
38
+ * Generate a Digest authentication response
39
+ */
40
+ generateResponse(challenge: DigestChallenge, method: string, uri: string): string;
41
+ /**
42
+ * Calculate HA1 = MD5(username:realm:password)
43
+ */
44
+ private calculateHA1;
45
+ /**
46
+ * Calculate HA2 = MD5(method:uri)
47
+ */
48
+ private calculateHA2;
49
+ /**
50
+ * Generate a client nonce
51
+ */
52
+ private generateCnonce;
53
+ /**
54
+ * Format nonce count as 8-digit hex string
55
+ */
56
+ private formatNC;
57
+ /**
58
+ * Build the Authorization header string
59
+ */
60
+ private buildResponseHeader;
61
+ /**
62
+ * Reset the nonce count (useful for new sessions)
63
+ */
64
+ reset(): void;
65
+ /**
66
+ * Check if a challenge is stale
67
+ */
68
+ isStale(challenge: DigestChallenge): boolean;
69
+ }
70
+ //# sourceMappingURL=DigestAuthHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DigestAuthHandler.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/http-engine/connections/DigestAuthHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,+BAA+B,CAAA;AAEzE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,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