cdk-ecr-deployment 0.0.76 → 0.0.82

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 (357) hide show
  1. package/.gitattributes +20 -21
  2. package/.jsii +43 -35
  3. package/lambda/Dockerfile +25 -0
  4. package/lambda/install.js +64 -0
  5. package/lib/index.js +40 -23
  6. package/node_modules/@sindresorhus/is/dist/index.d.ts +225 -0
  7. package/node_modules/@sindresorhus/is/dist/index.js +427 -0
  8. package/node_modules/@sindresorhus/is/dist/types.d.ts +24 -0
  9. package/node_modules/@sindresorhus/is/dist/types.js +3 -0
  10. package/node_modules/@sindresorhus/is/license +9 -0
  11. package/node_modules/@sindresorhus/is/package.json +96 -0
  12. package/node_modules/@sindresorhus/is/readme.md +628 -0
  13. package/node_modules/@szmarczak/http-timer/LICENSE +21 -0
  14. package/node_modules/@szmarczak/http-timer/README.md +93 -0
  15. package/node_modules/@szmarczak/http-timer/dist/source/index.d.ts +32 -0
  16. package/node_modules/@szmarczak/http-timer/dist/source/index.js +126 -0
  17. package/node_modules/@szmarczak/http-timer/package.json +72 -0
  18. package/node_modules/@types/cacheable-request/LICENSE +21 -0
  19. package/node_modules/@types/cacheable-request/README.md +16 -0
  20. package/node_modules/@types/cacheable-request/index.d.ts +137 -0
  21. package/node_modules/@types/cacheable-request/node_modules/@types/node/LICENSE +21 -0
  22. package/node_modules/@types/cacheable-request/node_modules/@types/node/README.md +16 -0
  23. package/node_modules/@types/cacheable-request/node_modules/@types/node/assert/strict.d.ts +8 -0
  24. package/node_modules/@types/cacheable-request/node_modules/@types/node/assert.d.ts +912 -0
  25. package/node_modules/@types/cacheable-request/node_modules/@types/node/async_hooks.d.ts +497 -0
  26. package/node_modules/@types/cacheable-request/node_modules/@types/node/buffer.d.ts +2142 -0
  27. package/node_modules/@types/cacheable-request/node_modules/@types/node/child_process.d.ts +1366 -0
  28. package/node_modules/@types/cacheable-request/node_modules/@types/node/cluster.d.ts +414 -0
  29. package/node_modules/@types/cacheable-request/node_modules/@types/node/console.d.ts +412 -0
  30. package/node_modules/@types/cacheable-request/node_modules/@types/node/constants.d.ts +18 -0
  31. package/node_modules/@types/cacheable-request/node_modules/@types/node/crypto.d.ts +3307 -0
  32. package/node_modules/@types/cacheable-request/node_modules/@types/node/dgram.d.ts +545 -0
  33. package/node_modules/@types/cacheable-request/node_modules/@types/node/diagnostics_channel.d.ts +134 -0
  34. package/node_modules/@types/cacheable-request/node_modules/@types/node/dns/promises.d.ts +368 -0
  35. package/node_modules/@types/cacheable-request/node_modules/@types/node/dns.d.ts +654 -0
  36. package/node_modules/@types/cacheable-request/node_modules/@types/node/domain.d.ts +169 -0
  37. package/node_modules/@types/cacheable-request/node_modules/@types/node/events.d.ts +623 -0
  38. package/node_modules/@types/cacheable-request/node_modules/@types/node/fs/promises.d.ts +1091 -0
  39. package/node_modules/@types/cacheable-request/node_modules/@types/node/fs.d.ts +3784 -0
  40. package/node_modules/@types/cacheable-request/node_modules/@types/node/globals.d.ts +284 -0
  41. package/node_modules/@types/cacheable-request/node_modules/@types/node/globals.global.d.ts +1 -0
  42. package/node_modules/@types/cacheable-request/node_modules/@types/node/http.d.ts +1369 -0
  43. package/node_modules/@types/cacheable-request/node_modules/@types/node/http2.d.ts +2100 -0
  44. package/node_modules/@types/cacheable-request/node_modules/@types/node/https.d.ts +391 -0
  45. package/node_modules/@types/cacheable-request/node_modules/@types/node/index.d.ts +131 -0
  46. package/node_modules/@types/cacheable-request/node_modules/@types/node/inspector.d.ts +2745 -0
  47. package/node_modules/@types/cacheable-request/node_modules/@types/node/module.d.ts +114 -0
  48. package/node_modules/@types/cacheable-request/node_modules/@types/node/net.d.ts +783 -0
  49. package/node_modules/@types/cacheable-request/node_modules/@types/node/os.d.ts +455 -0
  50. package/node_modules/@types/cacheable-request/node_modules/@types/node/package.json +230 -0
  51. package/node_modules/@types/cacheable-request/node_modules/@types/node/path.d.ts +172 -0
  52. package/node_modules/@types/cacheable-request/node_modules/@types/node/perf_hooks.d.ts +555 -0
  53. package/node_modules/@types/cacheable-request/node_modules/@types/node/process.d.ts +1481 -0
  54. package/node_modules/@types/cacheable-request/node_modules/@types/node/punycode.d.ts +117 -0
  55. package/node_modules/@types/cacheable-request/node_modules/@types/node/querystring.d.ts +131 -0
  56. package/node_modules/@types/cacheable-request/node_modules/@types/node/readline.d.ts +543 -0
  57. package/node_modules/@types/cacheable-request/node_modules/@types/node/repl.d.ts +424 -0
  58. package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/consumers.d.ts +24 -0
  59. package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/promises.d.ts +42 -0
  60. package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/web.d.ts +391 -0
  61. package/node_modules/@types/cacheable-request/node_modules/@types/node/stream.d.ts +1249 -0
  62. package/node_modules/@types/cacheable-request/node_modules/@types/node/string_decoder.d.ts +67 -0
  63. package/node_modules/@types/cacheable-request/node_modules/@types/node/timers/promises.d.ts +68 -0
  64. package/node_modules/@types/cacheable-request/node_modules/@types/node/timers.d.ts +94 -0
  65. package/node_modules/@types/cacheable-request/node_modules/@types/node/tls.d.ts +1019 -0
  66. package/node_modules/@types/cacheable-request/node_modules/@types/node/trace_events.d.ts +161 -0
  67. package/node_modules/@types/cacheable-request/node_modules/@types/node/tty.d.ts +204 -0
  68. package/node_modules/@types/cacheable-request/node_modules/@types/node/url.d.ts +821 -0
  69. package/node_modules/@types/cacheable-request/node_modules/@types/node/util.d.ts +1594 -0
  70. package/node_modules/@types/cacheable-request/node_modules/@types/node/v8.d.ts +378 -0
  71. package/node_modules/@types/cacheable-request/node_modules/@types/node/vm.d.ts +507 -0
  72. package/node_modules/@types/cacheable-request/node_modules/@types/node/wasi.d.ts +158 -0
  73. package/node_modules/@types/cacheable-request/node_modules/@types/node/worker_threads.d.ts +649 -0
  74. package/node_modules/@types/cacheable-request/node_modules/@types/node/zlib.d.ts +517 -0
  75. package/node_modules/@types/cacheable-request/package.json +35 -0
  76. package/node_modules/@types/http-cache-semantics/LICENSE +21 -0
  77. package/node_modules/@types/http-cache-semantics/README.md +16 -0
  78. package/node_modules/@types/http-cache-semantics/index.d.ts +170 -0
  79. package/node_modules/@types/http-cache-semantics/package.json +25 -0
  80. package/node_modules/@types/keyv/LICENSE +21 -0
  81. package/node_modules/@types/keyv/README.md +16 -0
  82. package/node_modules/@types/keyv/index.d.ts +77 -0
  83. package/node_modules/@types/keyv/node_modules/@types/node/LICENSE +21 -0
  84. package/node_modules/@types/keyv/node_modules/@types/node/README.md +16 -0
  85. package/node_modules/@types/keyv/node_modules/@types/node/assert/strict.d.ts +8 -0
  86. package/node_modules/@types/keyv/node_modules/@types/node/assert.d.ts +912 -0
  87. package/node_modules/@types/keyv/node_modules/@types/node/async_hooks.d.ts +497 -0
  88. package/node_modules/@types/keyv/node_modules/@types/node/buffer.d.ts +2142 -0
  89. package/node_modules/@types/keyv/node_modules/@types/node/child_process.d.ts +1366 -0
  90. package/node_modules/@types/keyv/node_modules/@types/node/cluster.d.ts +414 -0
  91. package/node_modules/@types/keyv/node_modules/@types/node/console.d.ts +412 -0
  92. package/node_modules/@types/keyv/node_modules/@types/node/constants.d.ts +18 -0
  93. package/node_modules/@types/keyv/node_modules/@types/node/crypto.d.ts +3307 -0
  94. package/node_modules/@types/keyv/node_modules/@types/node/dgram.d.ts +545 -0
  95. package/node_modules/@types/keyv/node_modules/@types/node/diagnostics_channel.d.ts +134 -0
  96. package/node_modules/@types/keyv/node_modules/@types/node/dns/promises.d.ts +368 -0
  97. package/node_modules/@types/keyv/node_modules/@types/node/dns.d.ts +654 -0
  98. package/node_modules/@types/keyv/node_modules/@types/node/domain.d.ts +169 -0
  99. package/node_modules/@types/keyv/node_modules/@types/node/events.d.ts +623 -0
  100. package/node_modules/@types/keyv/node_modules/@types/node/fs/promises.d.ts +1091 -0
  101. package/node_modules/@types/keyv/node_modules/@types/node/fs.d.ts +3784 -0
  102. package/node_modules/@types/keyv/node_modules/@types/node/globals.d.ts +284 -0
  103. package/node_modules/@types/keyv/node_modules/@types/node/globals.global.d.ts +1 -0
  104. package/node_modules/@types/keyv/node_modules/@types/node/http.d.ts +1369 -0
  105. package/node_modules/@types/keyv/node_modules/@types/node/http2.d.ts +2100 -0
  106. package/node_modules/@types/keyv/node_modules/@types/node/https.d.ts +391 -0
  107. package/node_modules/@types/keyv/node_modules/@types/node/index.d.ts +131 -0
  108. package/node_modules/@types/keyv/node_modules/@types/node/inspector.d.ts +2745 -0
  109. package/node_modules/@types/keyv/node_modules/@types/node/module.d.ts +114 -0
  110. package/node_modules/@types/keyv/node_modules/@types/node/net.d.ts +783 -0
  111. package/node_modules/@types/keyv/node_modules/@types/node/os.d.ts +455 -0
  112. package/node_modules/@types/keyv/node_modules/@types/node/package.json +230 -0
  113. package/node_modules/@types/keyv/node_modules/@types/node/path.d.ts +172 -0
  114. package/node_modules/@types/keyv/node_modules/@types/node/perf_hooks.d.ts +555 -0
  115. package/node_modules/@types/keyv/node_modules/@types/node/process.d.ts +1481 -0
  116. package/node_modules/@types/keyv/node_modules/@types/node/punycode.d.ts +117 -0
  117. package/node_modules/@types/keyv/node_modules/@types/node/querystring.d.ts +131 -0
  118. package/node_modules/@types/keyv/node_modules/@types/node/readline.d.ts +543 -0
  119. package/node_modules/@types/keyv/node_modules/@types/node/repl.d.ts +424 -0
  120. package/node_modules/@types/keyv/node_modules/@types/node/stream/consumers.d.ts +24 -0
  121. package/node_modules/@types/keyv/node_modules/@types/node/stream/promises.d.ts +42 -0
  122. package/node_modules/@types/keyv/node_modules/@types/node/stream/web.d.ts +391 -0
  123. package/node_modules/@types/keyv/node_modules/@types/node/stream.d.ts +1249 -0
  124. package/node_modules/@types/keyv/node_modules/@types/node/string_decoder.d.ts +67 -0
  125. package/node_modules/@types/keyv/node_modules/@types/node/timers/promises.d.ts +68 -0
  126. package/node_modules/@types/keyv/node_modules/@types/node/timers.d.ts +94 -0
  127. package/node_modules/@types/keyv/node_modules/@types/node/tls.d.ts +1019 -0
  128. package/node_modules/@types/keyv/node_modules/@types/node/trace_events.d.ts +161 -0
  129. package/node_modules/@types/keyv/node_modules/@types/node/tty.d.ts +204 -0
  130. package/node_modules/@types/keyv/node_modules/@types/node/url.d.ts +821 -0
  131. package/node_modules/@types/keyv/node_modules/@types/node/util.d.ts +1594 -0
  132. package/node_modules/@types/keyv/node_modules/@types/node/v8.d.ts +378 -0
  133. package/node_modules/@types/keyv/node_modules/@types/node/vm.d.ts +507 -0
  134. package/node_modules/@types/keyv/node_modules/@types/node/wasi.d.ts +158 -0
  135. package/node_modules/@types/keyv/node_modules/@types/node/worker_threads.d.ts +649 -0
  136. package/node_modules/@types/keyv/node_modules/@types/node/zlib.d.ts +517 -0
  137. package/node_modules/@types/keyv/package.json +32 -0
  138. package/node_modules/@types/responselike/LICENSE +21 -0
  139. package/node_modules/@types/responselike/README.md +16 -0
  140. package/node_modules/@types/responselike/index.d.ts +34 -0
  141. package/node_modules/@types/responselike/node_modules/@types/node/LICENSE +21 -0
  142. package/node_modules/@types/responselike/node_modules/@types/node/README.md +16 -0
  143. package/node_modules/@types/responselike/node_modules/@types/node/assert/strict.d.ts +8 -0
  144. package/node_modules/@types/responselike/node_modules/@types/node/assert.d.ts +912 -0
  145. package/node_modules/@types/responselike/node_modules/@types/node/async_hooks.d.ts +497 -0
  146. package/node_modules/@types/responselike/node_modules/@types/node/buffer.d.ts +2142 -0
  147. package/node_modules/@types/responselike/node_modules/@types/node/child_process.d.ts +1366 -0
  148. package/node_modules/@types/responselike/node_modules/@types/node/cluster.d.ts +414 -0
  149. package/node_modules/@types/responselike/node_modules/@types/node/console.d.ts +412 -0
  150. package/node_modules/@types/responselike/node_modules/@types/node/constants.d.ts +18 -0
  151. package/node_modules/@types/responselike/node_modules/@types/node/crypto.d.ts +3307 -0
  152. package/node_modules/@types/responselike/node_modules/@types/node/dgram.d.ts +545 -0
  153. package/node_modules/@types/responselike/node_modules/@types/node/diagnostics_channel.d.ts +134 -0
  154. package/node_modules/@types/responselike/node_modules/@types/node/dns/promises.d.ts +368 -0
  155. package/node_modules/@types/responselike/node_modules/@types/node/dns.d.ts +654 -0
  156. package/node_modules/@types/responselike/node_modules/@types/node/domain.d.ts +169 -0
  157. package/node_modules/@types/responselike/node_modules/@types/node/events.d.ts +623 -0
  158. package/node_modules/@types/responselike/node_modules/@types/node/fs/promises.d.ts +1091 -0
  159. package/node_modules/@types/responselike/node_modules/@types/node/fs.d.ts +3784 -0
  160. package/node_modules/@types/responselike/node_modules/@types/node/globals.d.ts +284 -0
  161. package/node_modules/@types/responselike/node_modules/@types/node/globals.global.d.ts +1 -0
  162. package/node_modules/@types/responselike/node_modules/@types/node/http.d.ts +1369 -0
  163. package/node_modules/@types/responselike/node_modules/@types/node/http2.d.ts +2100 -0
  164. package/node_modules/@types/responselike/node_modules/@types/node/https.d.ts +391 -0
  165. package/node_modules/@types/responselike/node_modules/@types/node/index.d.ts +131 -0
  166. package/node_modules/@types/responselike/node_modules/@types/node/inspector.d.ts +2745 -0
  167. package/node_modules/@types/responselike/node_modules/@types/node/module.d.ts +114 -0
  168. package/node_modules/@types/responselike/node_modules/@types/node/net.d.ts +783 -0
  169. package/node_modules/@types/responselike/node_modules/@types/node/os.d.ts +455 -0
  170. package/node_modules/@types/responselike/node_modules/@types/node/package.json +230 -0
  171. package/node_modules/@types/responselike/node_modules/@types/node/path.d.ts +172 -0
  172. package/node_modules/@types/responselike/node_modules/@types/node/perf_hooks.d.ts +555 -0
  173. package/node_modules/@types/responselike/node_modules/@types/node/process.d.ts +1481 -0
  174. package/node_modules/@types/responselike/node_modules/@types/node/punycode.d.ts +117 -0
  175. package/node_modules/@types/responselike/node_modules/@types/node/querystring.d.ts +131 -0
  176. package/node_modules/@types/responselike/node_modules/@types/node/readline.d.ts +543 -0
  177. package/node_modules/@types/responselike/node_modules/@types/node/repl.d.ts +424 -0
  178. package/node_modules/@types/responselike/node_modules/@types/node/stream/consumers.d.ts +24 -0
  179. package/node_modules/@types/responselike/node_modules/@types/node/stream/promises.d.ts +42 -0
  180. package/node_modules/@types/responselike/node_modules/@types/node/stream/web.d.ts +391 -0
  181. package/node_modules/@types/responselike/node_modules/@types/node/stream.d.ts +1249 -0
  182. package/node_modules/@types/responselike/node_modules/@types/node/string_decoder.d.ts +67 -0
  183. package/node_modules/@types/responselike/node_modules/@types/node/timers/promises.d.ts +68 -0
  184. package/node_modules/@types/responselike/node_modules/@types/node/timers.d.ts +94 -0
  185. package/node_modules/@types/responselike/node_modules/@types/node/tls.d.ts +1019 -0
  186. package/node_modules/@types/responselike/node_modules/@types/node/trace_events.d.ts +161 -0
  187. package/node_modules/@types/responselike/node_modules/@types/node/tty.d.ts +204 -0
  188. package/node_modules/@types/responselike/node_modules/@types/node/url.d.ts +821 -0
  189. package/node_modules/@types/responselike/node_modules/@types/node/util.d.ts +1594 -0
  190. package/node_modules/@types/responselike/node_modules/@types/node/v8.d.ts +378 -0
  191. package/node_modules/@types/responselike/node_modules/@types/node/vm.d.ts +507 -0
  192. package/node_modules/@types/responselike/node_modules/@types/node/wasi.d.ts +158 -0
  193. package/node_modules/@types/responselike/node_modules/@types/node/worker_threads.d.ts +649 -0
  194. package/node_modules/@types/responselike/node_modules/@types/node/zlib.d.ts +517 -0
  195. package/node_modules/@types/responselike/package.json +25 -0
  196. package/node_modules/cacheable-lookup/LICENSE +21 -0
  197. package/node_modules/cacheable-lookup/README.md +240 -0
  198. package/node_modules/cacheable-lookup/index.d.ts +139 -0
  199. package/node_modules/cacheable-lookup/package.json +45 -0
  200. package/node_modules/cacheable-lookup/source/index.js +436 -0
  201. package/node_modules/cacheable-request/LICENSE +21 -0
  202. package/node_modules/cacheable-request/README.md +206 -0
  203. package/node_modules/cacheable-request/package.json +56 -0
  204. package/node_modules/cacheable-request/src/index.js +251 -0
  205. package/node_modules/clone-response/LICENSE +21 -0
  206. package/node_modules/clone-response/README.md +62 -0
  207. package/node_modules/clone-response/package.json +44 -0
  208. package/node_modules/clone-response/src/index.js +17 -0
  209. package/node_modules/decompress-response/index.d.ts +22 -0
  210. package/node_modules/decompress-response/index.js +58 -0
  211. package/node_modules/decompress-response/license +9 -0
  212. package/node_modules/decompress-response/node_modules/mimic-response/index.d.ts +17 -0
  213. package/node_modules/decompress-response/node_modules/mimic-response/index.js +77 -0
  214. package/node_modules/decompress-response/node_modules/mimic-response/license +9 -0
  215. package/node_modules/decompress-response/node_modules/mimic-response/package.json +42 -0
  216. package/node_modules/decompress-response/node_modules/mimic-response/readme.md +78 -0
  217. package/node_modules/decompress-response/package.json +56 -0
  218. package/node_modules/decompress-response/readme.md +48 -0
  219. package/node_modules/defer-to-connect/LICENSE +21 -0
  220. package/node_modules/defer-to-connect/README.md +38 -0
  221. package/node_modules/defer-to-connect/dist/source/index.d.ts +10 -0
  222. package/node_modules/defer-to-connect/dist/source/index.js +47 -0
  223. package/node_modules/defer-to-connect/package.json +71 -0
  224. package/node_modules/end-of-stream/LICENSE +21 -0
  225. package/node_modules/end-of-stream/README.md +54 -0
  226. package/node_modules/end-of-stream/index.js +94 -0
  227. package/node_modules/end-of-stream/package.json +37 -0
  228. package/node_modules/get-stream/buffer-stream.js +52 -0
  229. package/node_modules/get-stream/index.d.ts +108 -0
  230. package/node_modules/get-stream/index.js +60 -0
  231. package/node_modules/get-stream/license +9 -0
  232. package/node_modules/get-stream/package.json +50 -0
  233. package/node_modules/get-stream/readme.md +124 -0
  234. package/node_modules/got/dist/source/as-promise/create-rejection.d.ts +2 -0
  235. package/node_modules/got/dist/source/as-promise/create-rejection.js +30 -0
  236. package/node_modules/got/dist/source/as-promise/index.d.ts +3 -0
  237. package/node_modules/got/dist/source/as-promise/index.js +175 -0
  238. package/node_modules/got/dist/source/as-promise/normalize-arguments.d.ts +3 -0
  239. package/node_modules/got/dist/source/as-promise/normalize-arguments.js +78 -0
  240. package/node_modules/got/dist/source/as-promise/parse-body.d.ts +3 -0
  241. package/node_modules/got/dist/source/as-promise/parse-body.js +25 -0
  242. package/node_modules/got/dist/source/as-promise/types.d.ts +256 -0
  243. package/node_modules/got/dist/source/as-promise/types.js +42 -0
  244. package/node_modules/got/dist/source/core/calculate-retry-delay.d.ts +5 -0
  245. package/node_modules/got/dist/source/core/calculate-retry-delay.js +29 -0
  246. package/node_modules/got/dist/source/core/index.d.ts +1124 -0
  247. package/node_modules/got/dist/source/core/index.js +1497 -0
  248. package/node_modules/got/dist/source/core/utils/dns-ip-version.d.ts +5 -0
  249. package/node_modules/got/dist/source/core/utils/dns-ip-version.js +17 -0
  250. package/node_modules/got/dist/source/core/utils/get-body-size.d.ts +3 -0
  251. package/node_modules/got/dist/source/core/utils/get-body-size.js +32 -0
  252. package/node_modules/got/dist/source/core/utils/get-buffer.d.ts +4 -0
  253. package/node_modules/got/dist/source/core/utils/get-buffer.js +16 -0
  254. package/node_modules/got/dist/source/core/utils/is-form-data.d.ts +8 -0
  255. package/node_modules/got/dist/source/core/utils/is-form-data.js +4 -0
  256. package/node_modules/got/dist/source/core/utils/is-response-ok.d.ts +2 -0
  257. package/node_modules/got/dist/source/core/utils/is-response-ok.js +8 -0
  258. package/node_modules/got/dist/source/core/utils/options-to-url.d.ts +14 -0
  259. package/node_modules/got/dist/source/core/utils/options-to-url.js +53 -0
  260. package/node_modules/got/dist/source/core/utils/proxy-events.d.ts +3 -0
  261. package/node_modules/got/dist/source/core/utils/proxy-events.js +17 -0
  262. package/node_modules/got/dist/source/core/utils/timed-out.d.ts +29 -0
  263. package/node_modules/got/dist/source/core/utils/timed-out.js +121 -0
  264. package/node_modules/got/dist/source/core/utils/unhandle.d.ts +11 -0
  265. package/node_modules/got/dist/source/core/utils/unhandle.js +22 -0
  266. package/node_modules/got/dist/source/core/utils/url-to-options.d.ts +15 -0
  267. package/node_modules/got/dist/source/core/utils/url-to-options.js +24 -0
  268. package/node_modules/got/dist/source/core/utils/weakable-map.d.ts +8 -0
  269. package/node_modules/got/dist/source/core/utils/weakable-map.js +29 -0
  270. package/node_modules/got/dist/source/create.d.ts +5 -0
  271. package/node_modules/got/dist/source/create.js +240 -0
  272. package/node_modules/got/dist/source/index.d.ts +4 -0
  273. package/node_modules/got/dist/source/index.js +132 -0
  274. package/node_modules/got/dist/source/types.d.ts +344 -0
  275. package/node_modules/got/dist/source/types.js +2 -0
  276. package/node_modules/got/dist/source/utils/deep-freeze.d.ts +1 -0
  277. package/node_modules/got/dist/source/utils/deep-freeze.js +12 -0
  278. package/node_modules/got/dist/source/utils/deprecation-warning.d.ts +2 -0
  279. package/node_modules/got/dist/source/utils/deprecation-warning.js +13 -0
  280. package/node_modules/got/license +9 -0
  281. package/node_modules/got/package.json +130 -0
  282. package/node_modules/got/readme.md +2477 -0
  283. package/node_modules/http-cache-semantics/LICENSE +9 -0
  284. package/node_modules/http-cache-semantics/README.md +203 -0
  285. package/node_modules/http-cache-semantics/index.js +673 -0
  286. package/node_modules/http-cache-semantics/package.json +24 -0
  287. package/node_modules/http2-wrapper/LICENSE +21 -0
  288. package/node_modules/http2-wrapper/README.md +470 -0
  289. package/node_modules/http2-wrapper/package.json +54 -0
  290. package/node_modules/http2-wrapper/source/agent.js +670 -0
  291. package/node_modules/http2-wrapper/source/auto.js +149 -0
  292. package/node_modules/http2-wrapper/source/client-request.js +445 -0
  293. package/node_modules/http2-wrapper/source/incoming-message.js +58 -0
  294. package/node_modules/http2-wrapper/source/index.js +28 -0
  295. package/node_modules/http2-wrapper/source/utils/calculate-server-name.js +27 -0
  296. package/node_modules/http2-wrapper/source/utils/errors.js +45 -0
  297. package/node_modules/http2-wrapper/source/utils/is-request-pseudo-header.js +13 -0
  298. package/node_modules/http2-wrapper/source/utils/proxy-events.js +7 -0
  299. package/node_modules/http2-wrapper/source/utils/url-to-options.js +25 -0
  300. package/node_modules/json-buffer/.travis.yml +3 -0
  301. package/node_modules/json-buffer/LICENSE +22 -0
  302. package/node_modules/json-buffer/README.md +24 -0
  303. package/node_modules/json-buffer/index.js +58 -0
  304. package/node_modules/json-buffer/package.json +34 -0
  305. package/node_modules/json-buffer/test/index.js +63 -0
  306. package/node_modules/keyv/LICENSE +21 -0
  307. package/node_modules/keyv/README.md +290 -0
  308. package/node_modules/keyv/package.json +54 -0
  309. package/node_modules/keyv/src/index.js +109 -0
  310. package/node_modules/lowercase-keys/index.d.ts +16 -0
  311. package/node_modules/lowercase-keys/index.js +10 -0
  312. package/node_modules/lowercase-keys/license +9 -0
  313. package/node_modules/lowercase-keys/package.json +38 -0
  314. package/node_modules/lowercase-keys/readme.md +32 -0
  315. package/node_modules/mimic-response/index.js +32 -0
  316. package/node_modules/mimic-response/license +9 -0
  317. package/node_modules/mimic-response/package.json +37 -0
  318. package/node_modules/mimic-response/readme.md +54 -0
  319. package/node_modules/normalize-url/index.d.ts +267 -0
  320. package/node_modules/normalize-url/index.js +216 -0
  321. package/node_modules/normalize-url/license +9 -0
  322. package/node_modules/normalize-url/package.json +50 -0
  323. package/node_modules/normalize-url/readme.md +286 -0
  324. package/node_modules/once/LICENSE +15 -0
  325. package/node_modules/once/README.md +79 -0
  326. package/node_modules/once/once.js +42 -0
  327. package/node_modules/once/package.json +33 -0
  328. package/node_modules/p-cancelable/index.d.ts +176 -0
  329. package/node_modules/p-cancelable/index.js +111 -0
  330. package/node_modules/p-cancelable/license +9 -0
  331. package/node_modules/p-cancelable/package.json +49 -0
  332. package/node_modules/p-cancelable/readme.md +153 -0
  333. package/node_modules/pump/.travis.yml +5 -0
  334. package/node_modules/pump/LICENSE +21 -0
  335. package/node_modules/pump/README.md +65 -0
  336. package/node_modules/pump/index.js +82 -0
  337. package/node_modules/pump/package.json +24 -0
  338. package/node_modules/pump/test-browser.js +66 -0
  339. package/node_modules/pump/test-node.js +53 -0
  340. package/node_modules/quick-lru/index.d.ts +97 -0
  341. package/node_modules/quick-lru/index.js +123 -0
  342. package/node_modules/quick-lru/license +9 -0
  343. package/node_modules/quick-lru/package.json +43 -0
  344. package/node_modules/quick-lru/readme.md +111 -0
  345. package/node_modules/resolve-alpn/LICENSE +22 -0
  346. package/node_modules/resolve-alpn/README.md +60 -0
  347. package/node_modules/resolve-alpn/index.js +43 -0
  348. package/node_modules/resolve-alpn/package.json +34 -0
  349. package/node_modules/responselike/LICENSE +19 -0
  350. package/node_modules/responselike/README.md +77 -0
  351. package/node_modules/responselike/package.json +38 -0
  352. package/node_modules/responselike/src/index.js +34 -0
  353. package/node_modules/wrappy/LICENSE +15 -0
  354. package/node_modules/wrappy/README.md +36 -0
  355. package/node_modules/wrappy/package.json +29 -0
  356. package/node_modules/wrappy/wrappy.js +33 -0
  357. package/package.json +42 -39
@@ -0,0 +1,1497 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnsupportedProtocolError = exports.ReadError = exports.TimeoutError = exports.UploadError = exports.CacheError = exports.HTTPError = exports.MaxRedirectsError = exports.RequestError = exports.setNonEnumerableProperties = exports.knownHookEvents = exports.withoutBody = exports.kIsNormalizedAlready = void 0;
4
+ const util_1 = require("util");
5
+ const stream_1 = require("stream");
6
+ const fs_1 = require("fs");
7
+ const url_1 = require("url");
8
+ const http = require("http");
9
+ const http_1 = require("http");
10
+ const https = require("https");
11
+ const http_timer_1 = require("@szmarczak/http-timer");
12
+ const cacheable_lookup_1 = require("cacheable-lookup");
13
+ const CacheableRequest = require("cacheable-request");
14
+ const decompressResponse = require("decompress-response");
15
+ // @ts-expect-error Missing types
16
+ const http2wrapper = require("http2-wrapper");
17
+ const lowercaseKeys = require("lowercase-keys");
18
+ const is_1 = require("@sindresorhus/is");
19
+ const get_body_size_1 = require("./utils/get-body-size");
20
+ const is_form_data_1 = require("./utils/is-form-data");
21
+ const proxy_events_1 = require("./utils/proxy-events");
22
+ const timed_out_1 = require("./utils/timed-out");
23
+ const url_to_options_1 = require("./utils/url-to-options");
24
+ const options_to_url_1 = require("./utils/options-to-url");
25
+ const weakable_map_1 = require("./utils/weakable-map");
26
+ const get_buffer_1 = require("./utils/get-buffer");
27
+ const dns_ip_version_1 = require("./utils/dns-ip-version");
28
+ const is_response_ok_1 = require("./utils/is-response-ok");
29
+ const deprecation_warning_1 = require("../utils/deprecation-warning");
30
+ const normalize_arguments_1 = require("../as-promise/normalize-arguments");
31
+ const calculate_retry_delay_1 = require("./calculate-retry-delay");
32
+ let globalDnsCache;
33
+ const kRequest = Symbol('request');
34
+ const kResponse = Symbol('response');
35
+ const kResponseSize = Symbol('responseSize');
36
+ const kDownloadedSize = Symbol('downloadedSize');
37
+ const kBodySize = Symbol('bodySize');
38
+ const kUploadedSize = Symbol('uploadedSize');
39
+ const kServerResponsesPiped = Symbol('serverResponsesPiped');
40
+ const kUnproxyEvents = Symbol('unproxyEvents');
41
+ const kIsFromCache = Symbol('isFromCache');
42
+ const kCancelTimeouts = Symbol('cancelTimeouts');
43
+ const kStartedReading = Symbol('startedReading');
44
+ const kStopReading = Symbol('stopReading');
45
+ const kTriggerRead = Symbol('triggerRead');
46
+ const kBody = Symbol('body');
47
+ const kJobs = Symbol('jobs');
48
+ const kOriginalResponse = Symbol('originalResponse');
49
+ const kRetryTimeout = Symbol('retryTimeout');
50
+ exports.kIsNormalizedAlready = Symbol('isNormalizedAlready');
51
+ const supportsBrotli = is_1.default.string(process.versions.brotli);
52
+ exports.withoutBody = new Set(['GET', 'HEAD']);
53
+ exports.knownHookEvents = [
54
+ 'init',
55
+ 'beforeRequest',
56
+ 'beforeRedirect',
57
+ 'beforeError',
58
+ 'beforeRetry',
59
+ // Promise-Only
60
+ 'afterResponse'
61
+ ];
62
+ function validateSearchParameters(searchParameters) {
63
+ // eslint-disable-next-line guard-for-in
64
+ for (const key in searchParameters) {
65
+ const value = searchParameters[key];
66
+ if (!is_1.default.string(value) && !is_1.default.number(value) && !is_1.default.boolean(value) && !is_1.default.null_(value) && !is_1.default.undefined(value)) {
67
+ throw new TypeError(`The \`searchParams\` value '${String(value)}' must be a string, number, boolean or null`);
68
+ }
69
+ }
70
+ }
71
+ function isClientRequest(clientRequest) {
72
+ return is_1.default.object(clientRequest) && !('statusCode' in clientRequest);
73
+ }
74
+ const cacheableStore = new weakable_map_1.default();
75
+ const waitForOpenFile = async (file) => new Promise((resolve, reject) => {
76
+ const onError = (error) => {
77
+ reject(error);
78
+ };
79
+ // Node.js 12 has incomplete types
80
+ if (!file.pending) {
81
+ resolve();
82
+ }
83
+ file.once('error', onError);
84
+ file.once('ready', () => {
85
+ file.off('error', onError);
86
+ resolve();
87
+ });
88
+ });
89
+ const redirectCodes = new Set([300, 301, 302, 303, 304, 307, 308]);
90
+ const nonEnumerableProperties = [
91
+ 'context',
92
+ 'body',
93
+ 'json',
94
+ 'form'
95
+ ];
96
+ exports.setNonEnumerableProperties = (sources, to) => {
97
+ // Non enumerable properties shall not be merged
98
+ const properties = {};
99
+ for (const source of sources) {
100
+ if (!source) {
101
+ continue;
102
+ }
103
+ for (const name of nonEnumerableProperties) {
104
+ if (!(name in source)) {
105
+ continue;
106
+ }
107
+ properties[name] = {
108
+ writable: true,
109
+ configurable: true,
110
+ enumerable: false,
111
+ // @ts-expect-error TS doesn't see the check above
112
+ value: source[name]
113
+ };
114
+ }
115
+ }
116
+ Object.defineProperties(to, properties);
117
+ };
118
+ /**
119
+ An error to be thrown when a request fails.
120
+ Contains a `code` property with error class code, like `ECONNREFUSED`.
121
+ */
122
+ class RequestError extends Error {
123
+ constructor(message, error, self) {
124
+ var _a, _b;
125
+ super(message);
126
+ Error.captureStackTrace(this, this.constructor);
127
+ this.name = 'RequestError';
128
+ this.code = (_a = error.code) !== null && _a !== void 0 ? _a : 'ERR_GOT_REQUEST_ERROR';
129
+ if (self instanceof Request) {
130
+ Object.defineProperty(this, 'request', {
131
+ enumerable: false,
132
+ value: self
133
+ });
134
+ Object.defineProperty(this, 'response', {
135
+ enumerable: false,
136
+ value: self[kResponse]
137
+ });
138
+ Object.defineProperty(this, 'options', {
139
+ // This fails because of TS 3.7.2 useDefineForClassFields
140
+ // Ref: https://github.com/microsoft/TypeScript/issues/34972
141
+ enumerable: false,
142
+ value: self.options
143
+ });
144
+ }
145
+ else {
146
+ Object.defineProperty(this, 'options', {
147
+ // This fails because of TS 3.7.2 useDefineForClassFields
148
+ // Ref: https://github.com/microsoft/TypeScript/issues/34972
149
+ enumerable: false,
150
+ value: self
151
+ });
152
+ }
153
+ this.timings = (_b = this.request) === null || _b === void 0 ? void 0 : _b.timings;
154
+ // Recover the original stacktrace
155
+ if (is_1.default.string(error.stack) && is_1.default.string(this.stack)) {
156
+ const indexOfMessage = this.stack.indexOf(this.message) + this.message.length;
157
+ const thisStackTrace = this.stack.slice(indexOfMessage).split('\n').reverse();
158
+ const errorStackTrace = error.stack.slice(error.stack.indexOf(error.message) + error.message.length).split('\n').reverse();
159
+ // Remove duplicated traces
160
+ while (errorStackTrace.length !== 0 && errorStackTrace[0] === thisStackTrace[0]) {
161
+ thisStackTrace.shift();
162
+ }
163
+ this.stack = `${this.stack.slice(0, indexOfMessage)}${thisStackTrace.reverse().join('\n')}${errorStackTrace.reverse().join('\n')}`;
164
+ }
165
+ }
166
+ }
167
+ exports.RequestError = RequestError;
168
+ /**
169
+ An error to be thrown when the server redirects you more than ten times.
170
+ Includes a `response` property.
171
+ */
172
+ class MaxRedirectsError extends RequestError {
173
+ constructor(request) {
174
+ super(`Redirected ${request.options.maxRedirects} times. Aborting.`, {}, request);
175
+ this.name = 'MaxRedirectsError';
176
+ this.code = 'ERR_TOO_MANY_REDIRECTS';
177
+ }
178
+ }
179
+ exports.MaxRedirectsError = MaxRedirectsError;
180
+ /**
181
+ An error to be thrown when the server response code is not 2xx nor 3xx if `options.followRedirect` is `true`, but always except for 304.
182
+ Includes a `response` property.
183
+ */
184
+ class HTTPError extends RequestError {
185
+ constructor(response) {
186
+ super(`Response code ${response.statusCode} (${response.statusMessage})`, {}, response.request);
187
+ this.name = 'HTTPError';
188
+ this.code = 'ERR_NON_2XX_3XX_RESPONSE';
189
+ }
190
+ }
191
+ exports.HTTPError = HTTPError;
192
+ /**
193
+ An error to be thrown when a cache method fails.
194
+ For example, if the database goes down or there's a filesystem error.
195
+ */
196
+ class CacheError extends RequestError {
197
+ constructor(error, request) {
198
+ super(error.message, error, request);
199
+ this.name = 'CacheError';
200
+ this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_CACHE_ACCESS' : this.code;
201
+ }
202
+ }
203
+ exports.CacheError = CacheError;
204
+ /**
205
+ An error to be thrown when the request body is a stream and an error occurs while reading from that stream.
206
+ */
207
+ class UploadError extends RequestError {
208
+ constructor(error, request) {
209
+ super(error.message, error, request);
210
+ this.name = 'UploadError';
211
+ this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_UPLOAD' : this.code;
212
+ }
213
+ }
214
+ exports.UploadError = UploadError;
215
+ /**
216
+ An error to be thrown when the request is aborted due to a timeout.
217
+ Includes an `event` and `timings` property.
218
+ */
219
+ class TimeoutError extends RequestError {
220
+ constructor(error, timings, request) {
221
+ super(error.message, error, request);
222
+ this.name = 'TimeoutError';
223
+ this.event = error.event;
224
+ this.timings = timings;
225
+ }
226
+ }
227
+ exports.TimeoutError = TimeoutError;
228
+ /**
229
+ An error to be thrown when reading from response stream fails.
230
+ */
231
+ class ReadError extends RequestError {
232
+ constructor(error, request) {
233
+ super(error.message, error, request);
234
+ this.name = 'ReadError';
235
+ this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_READING_RESPONSE_STREAM' : this.code;
236
+ }
237
+ }
238
+ exports.ReadError = ReadError;
239
+ /**
240
+ An error to be thrown when given an unsupported protocol.
241
+ */
242
+ class UnsupportedProtocolError extends RequestError {
243
+ constructor(options) {
244
+ super(`Unsupported protocol "${options.url.protocol}"`, {}, options);
245
+ this.name = 'UnsupportedProtocolError';
246
+ this.code = 'ERR_UNSUPPORTED_PROTOCOL';
247
+ }
248
+ }
249
+ exports.UnsupportedProtocolError = UnsupportedProtocolError;
250
+ const proxiedRequestEvents = [
251
+ 'socket',
252
+ 'connect',
253
+ 'continue',
254
+ 'information',
255
+ 'upgrade',
256
+ 'timeout'
257
+ ];
258
+ class Request extends stream_1.Duplex {
259
+ constructor(url, options = {}, defaults) {
260
+ super({
261
+ // This must be false, to enable throwing after destroy
262
+ // It is used for retry logic in Promise API
263
+ autoDestroy: false,
264
+ // It needs to be zero because we're just proxying the data to another stream
265
+ highWaterMark: 0
266
+ });
267
+ this[kDownloadedSize] = 0;
268
+ this[kUploadedSize] = 0;
269
+ this.requestInitialized = false;
270
+ this[kServerResponsesPiped] = new Set();
271
+ this.redirects = [];
272
+ this[kStopReading] = false;
273
+ this[kTriggerRead] = false;
274
+ this[kJobs] = [];
275
+ this.retryCount = 0;
276
+ // TODO: Remove this when targeting Node.js >= 12
277
+ this._progressCallbacks = [];
278
+ const unlockWrite = () => this._unlockWrite();
279
+ const lockWrite = () => this._lockWrite();
280
+ this.on('pipe', (source) => {
281
+ source.prependListener('data', unlockWrite);
282
+ source.on('data', lockWrite);
283
+ source.prependListener('end', unlockWrite);
284
+ source.on('end', lockWrite);
285
+ });
286
+ this.on('unpipe', (source) => {
287
+ source.off('data', unlockWrite);
288
+ source.off('data', lockWrite);
289
+ source.off('end', unlockWrite);
290
+ source.off('end', lockWrite);
291
+ });
292
+ this.on('pipe', source => {
293
+ if (source instanceof http_1.IncomingMessage) {
294
+ this.options.headers = {
295
+ ...source.headers,
296
+ ...this.options.headers
297
+ };
298
+ }
299
+ });
300
+ const { json, body, form } = options;
301
+ if (json || body || form) {
302
+ this._lockWrite();
303
+ }
304
+ if (exports.kIsNormalizedAlready in options) {
305
+ this.options = options;
306
+ }
307
+ else {
308
+ try {
309
+ // @ts-expect-error Common TypeScript bug saying that `this.constructor` is not accessible
310
+ this.options = this.constructor.normalizeArguments(url, options, defaults);
311
+ }
312
+ catch (error) {
313
+ // TODO: Move this to `_destroy()`
314
+ if (is_1.default.nodeStream(options.body)) {
315
+ options.body.destroy();
316
+ }
317
+ this.destroy(error);
318
+ return;
319
+ }
320
+ }
321
+ (async () => {
322
+ var _a;
323
+ try {
324
+ if (this.options.body instanceof fs_1.ReadStream) {
325
+ await waitForOpenFile(this.options.body);
326
+ }
327
+ const { url: normalizedURL } = this.options;
328
+ if (!normalizedURL) {
329
+ throw new TypeError('Missing `url` property');
330
+ }
331
+ this.requestUrl = normalizedURL.toString();
332
+ decodeURI(this.requestUrl);
333
+ await this._finalizeBody();
334
+ await this._makeRequest();
335
+ if (this.destroyed) {
336
+ (_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.destroy();
337
+ return;
338
+ }
339
+ // Queued writes etc.
340
+ for (const job of this[kJobs]) {
341
+ job();
342
+ }
343
+ // Prevent memory leak
344
+ this[kJobs].length = 0;
345
+ this.requestInitialized = true;
346
+ }
347
+ catch (error) {
348
+ if (error instanceof RequestError) {
349
+ this._beforeError(error);
350
+ return;
351
+ }
352
+ // This is a workaround for https://github.com/nodejs/node/issues/33335
353
+ if (!this.destroyed) {
354
+ this.destroy(error);
355
+ }
356
+ }
357
+ })();
358
+ }
359
+ static normalizeArguments(url, options, defaults) {
360
+ var _a, _b, _c, _d, _e;
361
+ const rawOptions = options;
362
+ if (is_1.default.object(url) && !is_1.default.urlInstance(url)) {
363
+ options = { ...defaults, ...url, ...options };
364
+ }
365
+ else {
366
+ if (url && options && options.url !== undefined) {
367
+ throw new TypeError('The `url` option is mutually exclusive with the `input` argument');
368
+ }
369
+ options = { ...defaults, ...options };
370
+ if (url !== undefined) {
371
+ options.url = url;
372
+ }
373
+ if (is_1.default.urlInstance(options.url)) {
374
+ options.url = new url_1.URL(options.url.toString());
375
+ }
376
+ }
377
+ // TODO: Deprecate URL options in Got 12.
378
+ // Support extend-specific options
379
+ if (options.cache === false) {
380
+ options.cache = undefined;
381
+ }
382
+ if (options.dnsCache === false) {
383
+ options.dnsCache = undefined;
384
+ }
385
+ // Nice type assertions
386
+ is_1.assert.any([is_1.default.string, is_1.default.undefined], options.method);
387
+ is_1.assert.any([is_1.default.object, is_1.default.undefined], options.headers);
388
+ is_1.assert.any([is_1.default.string, is_1.default.urlInstance, is_1.default.undefined], options.prefixUrl);
389
+ is_1.assert.any([is_1.default.object, is_1.default.undefined], options.cookieJar);
390
+ is_1.assert.any([is_1.default.object, is_1.default.string, is_1.default.undefined], options.searchParams);
391
+ is_1.assert.any([is_1.default.object, is_1.default.string, is_1.default.undefined], options.cache);
392
+ is_1.assert.any([is_1.default.object, is_1.default.number, is_1.default.undefined], options.timeout);
393
+ is_1.assert.any([is_1.default.object, is_1.default.undefined], options.context);
394
+ is_1.assert.any([is_1.default.object, is_1.default.undefined], options.hooks);
395
+ is_1.assert.any([is_1.default.boolean, is_1.default.undefined], options.decompress);
396
+ is_1.assert.any([is_1.default.boolean, is_1.default.undefined], options.ignoreInvalidCookies);
397
+ is_1.assert.any([is_1.default.boolean, is_1.default.undefined], options.followRedirect);
398
+ is_1.assert.any([is_1.default.number, is_1.default.undefined], options.maxRedirects);
399
+ is_1.assert.any([is_1.default.boolean, is_1.default.undefined], options.throwHttpErrors);
400
+ is_1.assert.any([is_1.default.boolean, is_1.default.undefined], options.http2);
401
+ is_1.assert.any([is_1.default.boolean, is_1.default.undefined], options.allowGetBody);
402
+ is_1.assert.any([is_1.default.string, is_1.default.undefined], options.localAddress);
403
+ is_1.assert.any([dns_ip_version_1.isDnsLookupIpVersion, is_1.default.undefined], options.dnsLookupIpVersion);
404
+ is_1.assert.any([is_1.default.object, is_1.default.undefined], options.https);
405
+ is_1.assert.any([is_1.default.boolean, is_1.default.undefined], options.rejectUnauthorized);
406
+ if (options.https) {
407
+ is_1.assert.any([is_1.default.boolean, is_1.default.undefined], options.https.rejectUnauthorized);
408
+ is_1.assert.any([is_1.default.function_, is_1.default.undefined], options.https.checkServerIdentity);
409
+ is_1.assert.any([is_1.default.string, is_1.default.object, is_1.default.array, is_1.default.undefined], options.https.certificateAuthority);
410
+ is_1.assert.any([is_1.default.string, is_1.default.object, is_1.default.array, is_1.default.undefined], options.https.key);
411
+ is_1.assert.any([is_1.default.string, is_1.default.object, is_1.default.array, is_1.default.undefined], options.https.certificate);
412
+ is_1.assert.any([is_1.default.string, is_1.default.undefined], options.https.passphrase);
413
+ is_1.assert.any([is_1.default.string, is_1.default.buffer, is_1.default.array, is_1.default.undefined], options.https.pfx);
414
+ }
415
+ is_1.assert.any([is_1.default.object, is_1.default.undefined], options.cacheOptions);
416
+ // `options.method`
417
+ if (is_1.default.string(options.method)) {
418
+ options.method = options.method.toUpperCase();
419
+ }
420
+ else {
421
+ options.method = 'GET';
422
+ }
423
+ // `options.headers`
424
+ if (options.headers === (defaults === null || defaults === void 0 ? void 0 : defaults.headers)) {
425
+ options.headers = { ...options.headers };
426
+ }
427
+ else {
428
+ options.headers = lowercaseKeys({ ...(defaults === null || defaults === void 0 ? void 0 : defaults.headers), ...options.headers });
429
+ }
430
+ // Disallow legacy `url.Url`
431
+ if ('slashes' in options) {
432
+ throw new TypeError('The legacy `url.Url` has been deprecated. Use `URL` instead.');
433
+ }
434
+ // `options.auth`
435
+ if ('auth' in options) {
436
+ throw new TypeError('Parameter `auth` is deprecated. Use `username` / `password` instead.');
437
+ }
438
+ // `options.searchParams`
439
+ if ('searchParams' in options) {
440
+ if (options.searchParams && options.searchParams !== (defaults === null || defaults === void 0 ? void 0 : defaults.searchParams)) {
441
+ let searchParameters;
442
+ if (is_1.default.string(options.searchParams) || (options.searchParams instanceof url_1.URLSearchParams)) {
443
+ searchParameters = new url_1.URLSearchParams(options.searchParams);
444
+ }
445
+ else {
446
+ validateSearchParameters(options.searchParams);
447
+ searchParameters = new url_1.URLSearchParams();
448
+ // eslint-disable-next-line guard-for-in
449
+ for (const key in options.searchParams) {
450
+ const value = options.searchParams[key];
451
+ if (value === null) {
452
+ searchParameters.append(key, '');
453
+ }
454
+ else if (value !== undefined) {
455
+ searchParameters.append(key, value);
456
+ }
457
+ }
458
+ }
459
+ // `normalizeArguments()` is also used to merge options
460
+ (_a = defaults === null || defaults === void 0 ? void 0 : defaults.searchParams) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => {
461
+ // Only use default if one isn't already defined
462
+ if (!searchParameters.has(key)) {
463
+ searchParameters.append(key, value);
464
+ }
465
+ });
466
+ options.searchParams = searchParameters;
467
+ }
468
+ }
469
+ // `options.username` & `options.password`
470
+ options.username = (_b = options.username) !== null && _b !== void 0 ? _b : '';
471
+ options.password = (_c = options.password) !== null && _c !== void 0 ? _c : '';
472
+ // `options.prefixUrl` & `options.url`
473
+ if (is_1.default.undefined(options.prefixUrl)) {
474
+ options.prefixUrl = (_d = defaults === null || defaults === void 0 ? void 0 : defaults.prefixUrl) !== null && _d !== void 0 ? _d : '';
475
+ }
476
+ else {
477
+ options.prefixUrl = options.prefixUrl.toString();
478
+ if (options.prefixUrl !== '' && !options.prefixUrl.endsWith('/')) {
479
+ options.prefixUrl += '/';
480
+ }
481
+ }
482
+ if (is_1.default.string(options.url)) {
483
+ if (options.url.startsWith('/')) {
484
+ throw new Error('`input` must not start with a slash when using `prefixUrl`');
485
+ }
486
+ options.url = options_to_url_1.default(options.prefixUrl + options.url, options);
487
+ }
488
+ else if ((is_1.default.undefined(options.url) && options.prefixUrl !== '') || options.protocol) {
489
+ options.url = options_to_url_1.default(options.prefixUrl, options);
490
+ }
491
+ if (options.url) {
492
+ if ('port' in options) {
493
+ delete options.port;
494
+ }
495
+ // Make it possible to change `options.prefixUrl`
496
+ let { prefixUrl } = options;
497
+ Object.defineProperty(options, 'prefixUrl', {
498
+ set: (value) => {
499
+ const url = options.url;
500
+ if (!url.href.startsWith(value)) {
501
+ throw new Error(`Cannot change \`prefixUrl\` from ${prefixUrl} to ${value}: ${url.href}`);
502
+ }
503
+ options.url = new url_1.URL(value + url.href.slice(prefixUrl.length));
504
+ prefixUrl = value;
505
+ },
506
+ get: () => prefixUrl
507
+ });
508
+ // Support UNIX sockets
509
+ let { protocol } = options.url;
510
+ if (protocol === 'unix:') {
511
+ protocol = 'http:';
512
+ options.url = new url_1.URL(`http://unix${options.url.pathname}${options.url.search}`);
513
+ }
514
+ // Set search params
515
+ if (options.searchParams) {
516
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
517
+ options.url.search = options.searchParams.toString();
518
+ }
519
+ // Protocol check
520
+ if (protocol !== 'http:' && protocol !== 'https:') {
521
+ throw new UnsupportedProtocolError(options);
522
+ }
523
+ // Update `username`
524
+ if (options.username === '') {
525
+ options.username = options.url.username;
526
+ }
527
+ else {
528
+ options.url.username = options.username;
529
+ }
530
+ // Update `password`
531
+ if (options.password === '') {
532
+ options.password = options.url.password;
533
+ }
534
+ else {
535
+ options.url.password = options.password;
536
+ }
537
+ }
538
+ // `options.cookieJar`
539
+ const { cookieJar } = options;
540
+ if (cookieJar) {
541
+ let { setCookie, getCookieString } = cookieJar;
542
+ is_1.assert.function_(setCookie);
543
+ is_1.assert.function_(getCookieString);
544
+ /* istanbul ignore next: Horrible `tough-cookie` v3 check */
545
+ if (setCookie.length === 4 && getCookieString.length === 0) {
546
+ setCookie = util_1.promisify(setCookie.bind(options.cookieJar));
547
+ getCookieString = util_1.promisify(getCookieString.bind(options.cookieJar));
548
+ options.cookieJar = {
549
+ setCookie,
550
+ getCookieString: getCookieString
551
+ };
552
+ }
553
+ }
554
+ // `options.cache`
555
+ const { cache } = options;
556
+ if (cache) {
557
+ if (!cacheableStore.has(cache)) {
558
+ cacheableStore.set(cache, new CacheableRequest(((requestOptions, handler) => {
559
+ const result = requestOptions[kRequest](requestOptions, handler);
560
+ // TODO: remove this when `cacheable-request` supports async request functions.
561
+ if (is_1.default.promise(result)) {
562
+ // @ts-expect-error
563
+ // We only need to implement the error handler in order to support HTTP2 caching.
564
+ // The result will be a promise anyway.
565
+ result.once = (event, handler) => {
566
+ if (event === 'error') {
567
+ result.catch(handler);
568
+ }
569
+ else if (event === 'abort') {
570
+ // The empty catch is needed here in case when
571
+ // it rejects before it's `await`ed in `_makeRequest`.
572
+ (async () => {
573
+ try {
574
+ const request = (await result);
575
+ request.once('abort', handler);
576
+ }
577
+ catch (_a) { }
578
+ })();
579
+ }
580
+ else {
581
+ /* istanbul ignore next: safety check */
582
+ throw new Error(`Unknown HTTP2 promise event: ${event}`);
583
+ }
584
+ return result;
585
+ };
586
+ }
587
+ return result;
588
+ }), cache));
589
+ }
590
+ }
591
+ // `options.cacheOptions`
592
+ options.cacheOptions = { ...options.cacheOptions };
593
+ // `options.dnsCache`
594
+ if (options.dnsCache === true) {
595
+ if (!globalDnsCache) {
596
+ globalDnsCache = new cacheable_lookup_1.default();
597
+ }
598
+ options.dnsCache = globalDnsCache;
599
+ }
600
+ else if (!is_1.default.undefined(options.dnsCache) && !options.dnsCache.lookup) {
601
+ throw new TypeError(`Parameter \`dnsCache\` must be a CacheableLookup instance or a boolean, got ${is_1.default(options.dnsCache)}`);
602
+ }
603
+ // `options.timeout`
604
+ if (is_1.default.number(options.timeout)) {
605
+ options.timeout = { request: options.timeout };
606
+ }
607
+ else if (defaults && options.timeout !== defaults.timeout) {
608
+ options.timeout = {
609
+ ...defaults.timeout,
610
+ ...options.timeout
611
+ };
612
+ }
613
+ else {
614
+ options.timeout = { ...options.timeout };
615
+ }
616
+ // `options.context`
617
+ if (!options.context) {
618
+ options.context = {};
619
+ }
620
+ // `options.hooks`
621
+ const areHooksDefault = options.hooks === (defaults === null || defaults === void 0 ? void 0 : defaults.hooks);
622
+ options.hooks = { ...options.hooks };
623
+ for (const event of exports.knownHookEvents) {
624
+ if (event in options.hooks) {
625
+ if (is_1.default.array(options.hooks[event])) {
626
+ // See https://github.com/microsoft/TypeScript/issues/31445#issuecomment-576929044
627
+ options.hooks[event] = [...options.hooks[event]];
628
+ }
629
+ else {
630
+ throw new TypeError(`Parameter \`${event}\` must be an Array, got ${is_1.default(options.hooks[event])}`);
631
+ }
632
+ }
633
+ else {
634
+ options.hooks[event] = [];
635
+ }
636
+ }
637
+ if (defaults && !areHooksDefault) {
638
+ for (const event of exports.knownHookEvents) {
639
+ const defaultHooks = defaults.hooks[event];
640
+ if (defaultHooks.length > 0) {
641
+ // See https://github.com/microsoft/TypeScript/issues/31445#issuecomment-576929044
642
+ options.hooks[event] = [
643
+ ...defaults.hooks[event],
644
+ ...options.hooks[event]
645
+ ];
646
+ }
647
+ }
648
+ }
649
+ // DNS options
650
+ if ('family' in options) {
651
+ deprecation_warning_1.default('"options.family" was never documented, please use "options.dnsLookupIpVersion"');
652
+ }
653
+ // HTTPS options
654
+ if (defaults === null || defaults === void 0 ? void 0 : defaults.https) {
655
+ options.https = { ...defaults.https, ...options.https };
656
+ }
657
+ if ('rejectUnauthorized' in options) {
658
+ deprecation_warning_1.default('"options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized"');
659
+ }
660
+ if ('checkServerIdentity' in options) {
661
+ deprecation_warning_1.default('"options.checkServerIdentity" was never documented, please use "options.https.checkServerIdentity"');
662
+ }
663
+ if ('ca' in options) {
664
+ deprecation_warning_1.default('"options.ca" was never documented, please use "options.https.certificateAuthority"');
665
+ }
666
+ if ('key' in options) {
667
+ deprecation_warning_1.default('"options.key" was never documented, please use "options.https.key"');
668
+ }
669
+ if ('cert' in options) {
670
+ deprecation_warning_1.default('"options.cert" was never documented, please use "options.https.certificate"');
671
+ }
672
+ if ('passphrase' in options) {
673
+ deprecation_warning_1.default('"options.passphrase" was never documented, please use "options.https.passphrase"');
674
+ }
675
+ if ('pfx' in options) {
676
+ deprecation_warning_1.default('"options.pfx" was never documented, please use "options.https.pfx"');
677
+ }
678
+ // Other options
679
+ if ('followRedirects' in options) {
680
+ throw new TypeError('The `followRedirects` option does not exist. Use `followRedirect` instead.');
681
+ }
682
+ if (options.agent) {
683
+ for (const key in options.agent) {
684
+ if (key !== 'http' && key !== 'https' && key !== 'http2') {
685
+ throw new TypeError(`Expected the \`options.agent\` properties to be \`http\`, \`https\` or \`http2\`, got \`${key}\``);
686
+ }
687
+ }
688
+ }
689
+ options.maxRedirects = (_e = options.maxRedirects) !== null && _e !== void 0 ? _e : 0;
690
+ // Set non-enumerable properties
691
+ exports.setNonEnumerableProperties([defaults, rawOptions], options);
692
+ return normalize_arguments_1.default(options, defaults);
693
+ }
694
+ _lockWrite() {
695
+ const onLockedWrite = () => {
696
+ throw new TypeError('The payload has been already provided');
697
+ };
698
+ this.write = onLockedWrite;
699
+ this.end = onLockedWrite;
700
+ }
701
+ _unlockWrite() {
702
+ this.write = super.write;
703
+ this.end = super.end;
704
+ }
705
+ async _finalizeBody() {
706
+ const { options } = this;
707
+ const { headers } = options;
708
+ const isForm = !is_1.default.undefined(options.form);
709
+ const isJSON = !is_1.default.undefined(options.json);
710
+ const isBody = !is_1.default.undefined(options.body);
711
+ const hasPayload = isForm || isJSON || isBody;
712
+ const cannotHaveBody = exports.withoutBody.has(options.method) && !(options.method === 'GET' && options.allowGetBody);
713
+ this._cannotHaveBody = cannotHaveBody;
714
+ if (hasPayload) {
715
+ if (cannotHaveBody) {
716
+ throw new TypeError(`The \`${options.method}\` method cannot be used with a body`);
717
+ }
718
+ if ([isBody, isForm, isJSON].filter(isTrue => isTrue).length > 1) {
719
+ throw new TypeError('The `body`, `json` and `form` options are mutually exclusive');
720
+ }
721
+ if (isBody &&
722
+ !(options.body instanceof stream_1.Readable) &&
723
+ !is_1.default.string(options.body) &&
724
+ !is_1.default.buffer(options.body) &&
725
+ !is_form_data_1.default(options.body)) {
726
+ throw new TypeError('The `body` option must be a stream.Readable, string or Buffer');
727
+ }
728
+ if (isForm && !is_1.default.object(options.form)) {
729
+ throw new TypeError('The `form` option must be an Object');
730
+ }
731
+ {
732
+ // Serialize body
733
+ const noContentType = !is_1.default.string(headers['content-type']);
734
+ if (isBody) {
735
+ // Special case for https://github.com/form-data/form-data
736
+ if (is_form_data_1.default(options.body) && noContentType) {
737
+ headers['content-type'] = `multipart/form-data; boundary=${options.body.getBoundary()}`;
738
+ }
739
+ this[kBody] = options.body;
740
+ }
741
+ else if (isForm) {
742
+ if (noContentType) {
743
+ headers['content-type'] = 'application/x-www-form-urlencoded';
744
+ }
745
+ this[kBody] = (new url_1.URLSearchParams(options.form)).toString();
746
+ }
747
+ else {
748
+ if (noContentType) {
749
+ headers['content-type'] = 'application/json';
750
+ }
751
+ this[kBody] = options.stringifyJson(options.json);
752
+ }
753
+ const uploadBodySize = await get_body_size_1.default(this[kBody], options.headers);
754
+ // See https://tools.ietf.org/html/rfc7230#section-3.3.2
755
+ // A user agent SHOULD send a Content-Length in a request message when
756
+ // no Transfer-Encoding is sent and the request method defines a meaning
757
+ // for an enclosed payload body. For example, a Content-Length header
758
+ // field is normally sent in a POST request even when the value is 0
759
+ // (indicating an empty payload body). A user agent SHOULD NOT send a
760
+ // Content-Length header field when the request message does not contain
761
+ // a payload body and the method semantics do not anticipate such a
762
+ // body.
763
+ if (is_1.default.undefined(headers['content-length']) && is_1.default.undefined(headers['transfer-encoding'])) {
764
+ if (!cannotHaveBody && !is_1.default.undefined(uploadBodySize)) {
765
+ headers['content-length'] = String(uploadBodySize);
766
+ }
767
+ }
768
+ }
769
+ }
770
+ else if (cannotHaveBody) {
771
+ this._lockWrite();
772
+ }
773
+ else {
774
+ this._unlockWrite();
775
+ }
776
+ this[kBodySize] = Number(headers['content-length']) || undefined;
777
+ }
778
+ async _onResponseBase(response) {
779
+ const { options } = this;
780
+ const { url } = options;
781
+ this[kOriginalResponse] = response;
782
+ if (options.decompress) {
783
+ response = decompressResponse(response);
784
+ }
785
+ const statusCode = response.statusCode;
786
+ const typedResponse = response;
787
+ typedResponse.statusMessage = typedResponse.statusMessage ? typedResponse.statusMessage : http.STATUS_CODES[statusCode];
788
+ typedResponse.url = options.url.toString();
789
+ typedResponse.requestUrl = this.requestUrl;
790
+ typedResponse.redirectUrls = this.redirects;
791
+ typedResponse.request = this;
792
+ typedResponse.isFromCache = response.fromCache || false;
793
+ typedResponse.ip = this.ip;
794
+ typedResponse.retryCount = this.retryCount;
795
+ this[kIsFromCache] = typedResponse.isFromCache;
796
+ this[kResponseSize] = Number(response.headers['content-length']) || undefined;
797
+ this[kResponse] = response;
798
+ response.once('end', () => {
799
+ this[kResponseSize] = this[kDownloadedSize];
800
+ this.emit('downloadProgress', this.downloadProgress);
801
+ });
802
+ response.once('error', (error) => {
803
+ // Force clean-up, because some packages don't do this.
804
+ // TODO: Fix decompress-response
805
+ response.destroy();
806
+ this._beforeError(new ReadError(error, this));
807
+ });
808
+ response.once('aborted', () => {
809
+ this._beforeError(new ReadError({
810
+ name: 'Error',
811
+ message: 'The server aborted pending request',
812
+ code: 'ECONNRESET'
813
+ }, this));
814
+ });
815
+ this.emit('downloadProgress', this.downloadProgress);
816
+ const rawCookies = response.headers['set-cookie'];
817
+ if (is_1.default.object(options.cookieJar) && rawCookies) {
818
+ let promises = rawCookies.map(async (rawCookie) => options.cookieJar.setCookie(rawCookie, url.toString()));
819
+ if (options.ignoreInvalidCookies) {
820
+ promises = promises.map(async (p) => p.catch(() => { }));
821
+ }
822
+ try {
823
+ await Promise.all(promises);
824
+ }
825
+ catch (error) {
826
+ this._beforeError(error);
827
+ return;
828
+ }
829
+ }
830
+ if (options.followRedirect && response.headers.location && redirectCodes.has(statusCode)) {
831
+ // We're being redirected, we don't care about the response.
832
+ // It'd be best to abort the request, but we can't because
833
+ // we would have to sacrifice the TCP connection. We don't want that.
834
+ response.resume();
835
+ if (this[kRequest]) {
836
+ this[kCancelTimeouts]();
837
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
838
+ delete this[kRequest];
839
+ this[kUnproxyEvents]();
840
+ }
841
+ const shouldBeGet = statusCode === 303 && options.method !== 'GET' && options.method !== 'HEAD';
842
+ if (shouldBeGet || !options.methodRewriting) {
843
+ // Server responded with "see other", indicating that the resource exists at another location,
844
+ // and the client should request it from that location via GET or HEAD.
845
+ options.method = 'GET';
846
+ if ('body' in options) {
847
+ delete options.body;
848
+ }
849
+ if ('json' in options) {
850
+ delete options.json;
851
+ }
852
+ if ('form' in options) {
853
+ delete options.form;
854
+ }
855
+ this[kBody] = undefined;
856
+ delete options.headers['content-length'];
857
+ }
858
+ if (this.redirects.length >= options.maxRedirects) {
859
+ this._beforeError(new MaxRedirectsError(this));
860
+ return;
861
+ }
862
+ try {
863
+ // Do not remove. See https://github.com/sindresorhus/got/pull/214
864
+ const redirectBuffer = Buffer.from(response.headers.location, 'binary').toString();
865
+ // Handles invalid URLs. See https://github.com/sindresorhus/got/issues/604
866
+ const redirectUrl = new url_1.URL(redirectBuffer, url);
867
+ const redirectString = redirectUrl.toString();
868
+ decodeURI(redirectString);
869
+ // Redirecting to a different site, clear sensitive data.
870
+ if (redirectUrl.hostname !== url.hostname || redirectUrl.port !== url.port) {
871
+ if ('host' in options.headers) {
872
+ delete options.headers.host;
873
+ }
874
+ if ('cookie' in options.headers) {
875
+ delete options.headers.cookie;
876
+ }
877
+ if ('authorization' in options.headers) {
878
+ delete options.headers.authorization;
879
+ }
880
+ if (options.username || options.password) {
881
+ options.username = '';
882
+ options.password = '';
883
+ }
884
+ }
885
+ else {
886
+ redirectUrl.username = options.username;
887
+ redirectUrl.password = options.password;
888
+ }
889
+ this.redirects.push(redirectString);
890
+ options.url = redirectUrl;
891
+ for (const hook of options.hooks.beforeRedirect) {
892
+ // eslint-disable-next-line no-await-in-loop
893
+ await hook(options, typedResponse);
894
+ }
895
+ this.emit('redirect', typedResponse, options);
896
+ await this._makeRequest();
897
+ }
898
+ catch (error) {
899
+ this._beforeError(error);
900
+ return;
901
+ }
902
+ return;
903
+ }
904
+ if (options.isStream && options.throwHttpErrors && !is_response_ok_1.isResponseOk(typedResponse)) {
905
+ this._beforeError(new HTTPError(typedResponse));
906
+ return;
907
+ }
908
+ response.on('readable', () => {
909
+ if (this[kTriggerRead]) {
910
+ this._read();
911
+ }
912
+ });
913
+ this.on('resume', () => {
914
+ response.resume();
915
+ });
916
+ this.on('pause', () => {
917
+ response.pause();
918
+ });
919
+ response.once('end', () => {
920
+ this.push(null);
921
+ });
922
+ this.emit('response', response);
923
+ for (const destination of this[kServerResponsesPiped]) {
924
+ if (destination.headersSent) {
925
+ continue;
926
+ }
927
+ // eslint-disable-next-line guard-for-in
928
+ for (const key in response.headers) {
929
+ const isAllowed = options.decompress ? key !== 'content-encoding' : true;
930
+ const value = response.headers[key];
931
+ if (isAllowed) {
932
+ destination.setHeader(key, value);
933
+ }
934
+ }
935
+ destination.statusCode = statusCode;
936
+ }
937
+ }
938
+ async _onResponse(response) {
939
+ try {
940
+ await this._onResponseBase(response);
941
+ }
942
+ catch (error) {
943
+ /* istanbul ignore next: better safe than sorry */
944
+ this._beforeError(error);
945
+ }
946
+ }
947
+ _onRequest(request) {
948
+ const { options } = this;
949
+ const { timeout, url } = options;
950
+ http_timer_1.default(request);
951
+ this[kCancelTimeouts] = timed_out_1.default(request, timeout, url);
952
+ const responseEventName = options.cache ? 'cacheableResponse' : 'response';
953
+ request.once(responseEventName, (response) => {
954
+ void this._onResponse(response);
955
+ });
956
+ request.once('error', (error) => {
957
+ var _a;
958
+ // Force clean-up, because some packages (e.g. nock) don't do this.
959
+ request.destroy();
960
+ // Node.js <= 12.18.2 mistakenly emits the response `end` first.
961
+ (_a = request.res) === null || _a === void 0 ? void 0 : _a.removeAllListeners('end');
962
+ error = error instanceof timed_out_1.TimeoutError ? new TimeoutError(error, this.timings, this) : new RequestError(error.message, error, this);
963
+ this._beforeError(error);
964
+ });
965
+ this[kUnproxyEvents] = proxy_events_1.default(request, this, proxiedRequestEvents);
966
+ this[kRequest] = request;
967
+ this.emit('uploadProgress', this.uploadProgress);
968
+ // Send body
969
+ const body = this[kBody];
970
+ const currentRequest = this.redirects.length === 0 ? this : request;
971
+ if (is_1.default.nodeStream(body)) {
972
+ body.pipe(currentRequest);
973
+ body.once('error', (error) => {
974
+ this._beforeError(new UploadError(error, this));
975
+ });
976
+ }
977
+ else {
978
+ this._unlockWrite();
979
+ if (!is_1.default.undefined(body)) {
980
+ this._writeRequest(body, undefined, () => { });
981
+ currentRequest.end();
982
+ this._lockWrite();
983
+ }
984
+ else if (this._cannotHaveBody || this._noPipe) {
985
+ currentRequest.end();
986
+ this._lockWrite();
987
+ }
988
+ }
989
+ this.emit('request', request);
990
+ }
991
+ async _createCacheableRequest(url, options) {
992
+ return new Promise((resolve, reject) => {
993
+ // TODO: Remove `utils/url-to-options.ts` when `cacheable-request` is fixed
994
+ Object.assign(options, url_to_options_1.default(url));
995
+ // `http-cache-semantics` checks this
996
+ // TODO: Fix this ignore.
997
+ // @ts-expect-error
998
+ delete options.url;
999
+ let request;
1000
+ // This is ugly
1001
+ const cacheRequest = cacheableStore.get(options.cache)(options, async (response) => {
1002
+ // TODO: Fix `cacheable-response`
1003
+ response._readableState.autoDestroy = false;
1004
+ if (request) {
1005
+ (await request).emit('cacheableResponse', response);
1006
+ }
1007
+ resolve(response);
1008
+ });
1009
+ // Restore options
1010
+ options.url = url;
1011
+ cacheRequest.once('error', reject);
1012
+ cacheRequest.once('request', async (requestOrPromise) => {
1013
+ request = requestOrPromise;
1014
+ resolve(request);
1015
+ });
1016
+ });
1017
+ }
1018
+ async _makeRequest() {
1019
+ var _a, _b, _c, _d, _e;
1020
+ const { options } = this;
1021
+ const { headers } = options;
1022
+ for (const key in headers) {
1023
+ if (is_1.default.undefined(headers[key])) {
1024
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
1025
+ delete headers[key];
1026
+ }
1027
+ else if (is_1.default.null_(headers[key])) {
1028
+ throw new TypeError(`Use \`undefined\` instead of \`null\` to delete the \`${key}\` header`);
1029
+ }
1030
+ }
1031
+ if (options.decompress && is_1.default.undefined(headers['accept-encoding'])) {
1032
+ headers['accept-encoding'] = supportsBrotli ? 'gzip, deflate, br' : 'gzip, deflate';
1033
+ }
1034
+ // Set cookies
1035
+ if (options.cookieJar) {
1036
+ const cookieString = await options.cookieJar.getCookieString(options.url.toString());
1037
+ if (is_1.default.nonEmptyString(cookieString)) {
1038
+ options.headers.cookie = cookieString;
1039
+ }
1040
+ }
1041
+ for (const hook of options.hooks.beforeRequest) {
1042
+ // eslint-disable-next-line no-await-in-loop
1043
+ const result = await hook(options);
1044
+ if (!is_1.default.undefined(result)) {
1045
+ // @ts-expect-error Skip the type mismatch to support abstract responses
1046
+ options.request = () => result;
1047
+ break;
1048
+ }
1049
+ }
1050
+ if (options.body && this[kBody] !== options.body) {
1051
+ this[kBody] = options.body;
1052
+ }
1053
+ const { agent, request, timeout, url } = options;
1054
+ if (options.dnsCache && !('lookup' in options)) {
1055
+ options.lookup = options.dnsCache.lookup;
1056
+ }
1057
+ // UNIX sockets
1058
+ if (url.hostname === 'unix') {
1059
+ const matches = /(?<socketPath>.+?):(?<path>.+)/.exec(`${url.pathname}${url.search}`);
1060
+ if (matches === null || matches === void 0 ? void 0 : matches.groups) {
1061
+ const { socketPath, path } = matches.groups;
1062
+ Object.assign(options, {
1063
+ socketPath,
1064
+ path,
1065
+ host: ''
1066
+ });
1067
+ }
1068
+ }
1069
+ const isHttps = url.protocol === 'https:';
1070
+ // Fallback function
1071
+ let fallbackFn;
1072
+ if (options.http2) {
1073
+ fallbackFn = http2wrapper.auto;
1074
+ }
1075
+ else {
1076
+ fallbackFn = isHttps ? https.request : http.request;
1077
+ }
1078
+ const realFn = (_a = options.request) !== null && _a !== void 0 ? _a : fallbackFn;
1079
+ // Cache support
1080
+ const fn = options.cache ? this._createCacheableRequest : realFn;
1081
+ // Pass an agent directly when HTTP2 is disabled
1082
+ if (agent && !options.http2) {
1083
+ options.agent = agent[isHttps ? 'https' : 'http'];
1084
+ }
1085
+ // Prepare plain HTTP request options
1086
+ options[kRequest] = realFn;
1087
+ delete options.request;
1088
+ // TODO: Fix this ignore.
1089
+ // @ts-expect-error
1090
+ delete options.timeout;
1091
+ const requestOptions = options;
1092
+ requestOptions.shared = (_b = options.cacheOptions) === null || _b === void 0 ? void 0 : _b.shared;
1093
+ requestOptions.cacheHeuristic = (_c = options.cacheOptions) === null || _c === void 0 ? void 0 : _c.cacheHeuristic;
1094
+ requestOptions.immutableMinTimeToLive = (_d = options.cacheOptions) === null || _d === void 0 ? void 0 : _d.immutableMinTimeToLive;
1095
+ requestOptions.ignoreCargoCult = (_e = options.cacheOptions) === null || _e === void 0 ? void 0 : _e.ignoreCargoCult;
1096
+ // If `dnsLookupIpVersion` is not present do not override `family`
1097
+ if (options.dnsLookupIpVersion !== undefined) {
1098
+ try {
1099
+ requestOptions.family = dns_ip_version_1.dnsLookupIpVersionToFamily(options.dnsLookupIpVersion);
1100
+ }
1101
+ catch (_f) {
1102
+ throw new Error('Invalid `dnsLookupIpVersion` option value');
1103
+ }
1104
+ }
1105
+ // HTTPS options remapping
1106
+ if (options.https) {
1107
+ if ('rejectUnauthorized' in options.https) {
1108
+ requestOptions.rejectUnauthorized = options.https.rejectUnauthorized;
1109
+ }
1110
+ if (options.https.checkServerIdentity) {
1111
+ requestOptions.checkServerIdentity = options.https.checkServerIdentity;
1112
+ }
1113
+ if (options.https.certificateAuthority) {
1114
+ requestOptions.ca = options.https.certificateAuthority;
1115
+ }
1116
+ if (options.https.certificate) {
1117
+ requestOptions.cert = options.https.certificate;
1118
+ }
1119
+ if (options.https.key) {
1120
+ requestOptions.key = options.https.key;
1121
+ }
1122
+ if (options.https.passphrase) {
1123
+ requestOptions.passphrase = options.https.passphrase;
1124
+ }
1125
+ if (options.https.pfx) {
1126
+ requestOptions.pfx = options.https.pfx;
1127
+ }
1128
+ }
1129
+ try {
1130
+ let requestOrResponse = await fn(url, requestOptions);
1131
+ if (is_1.default.undefined(requestOrResponse)) {
1132
+ requestOrResponse = fallbackFn(url, requestOptions);
1133
+ }
1134
+ // Restore options
1135
+ options.request = request;
1136
+ options.timeout = timeout;
1137
+ options.agent = agent;
1138
+ // HTTPS options restore
1139
+ if (options.https) {
1140
+ if ('rejectUnauthorized' in options.https) {
1141
+ delete requestOptions.rejectUnauthorized;
1142
+ }
1143
+ if (options.https.checkServerIdentity) {
1144
+ // @ts-expect-error - This one will be removed when we remove the alias.
1145
+ delete requestOptions.checkServerIdentity;
1146
+ }
1147
+ if (options.https.certificateAuthority) {
1148
+ delete requestOptions.ca;
1149
+ }
1150
+ if (options.https.certificate) {
1151
+ delete requestOptions.cert;
1152
+ }
1153
+ if (options.https.key) {
1154
+ delete requestOptions.key;
1155
+ }
1156
+ if (options.https.passphrase) {
1157
+ delete requestOptions.passphrase;
1158
+ }
1159
+ if (options.https.pfx) {
1160
+ delete requestOptions.pfx;
1161
+ }
1162
+ }
1163
+ if (isClientRequest(requestOrResponse)) {
1164
+ this._onRequest(requestOrResponse);
1165
+ // Emit the response after the stream has been ended
1166
+ }
1167
+ else if (this.writable) {
1168
+ this.once('finish', () => {
1169
+ void this._onResponse(requestOrResponse);
1170
+ });
1171
+ this._unlockWrite();
1172
+ this.end();
1173
+ this._lockWrite();
1174
+ }
1175
+ else {
1176
+ void this._onResponse(requestOrResponse);
1177
+ }
1178
+ }
1179
+ catch (error) {
1180
+ if (error instanceof CacheableRequest.CacheError) {
1181
+ throw new CacheError(error, this);
1182
+ }
1183
+ throw new RequestError(error.message, error, this);
1184
+ }
1185
+ }
1186
+ async _error(error) {
1187
+ try {
1188
+ for (const hook of this.options.hooks.beforeError) {
1189
+ // eslint-disable-next-line no-await-in-loop
1190
+ error = await hook(error);
1191
+ }
1192
+ }
1193
+ catch (error_) {
1194
+ error = new RequestError(error_.message, error_, this);
1195
+ }
1196
+ this.destroy(error);
1197
+ }
1198
+ _beforeError(error) {
1199
+ if (this[kStopReading]) {
1200
+ return;
1201
+ }
1202
+ const { options } = this;
1203
+ const retryCount = this.retryCount + 1;
1204
+ this[kStopReading] = true;
1205
+ if (!(error instanceof RequestError)) {
1206
+ error = new RequestError(error.message, error, this);
1207
+ }
1208
+ const typedError = error;
1209
+ const { response } = typedError;
1210
+ void (async () => {
1211
+ if (response && !response.body) {
1212
+ response.setEncoding(this._readableState.encoding);
1213
+ try {
1214
+ response.rawBody = await get_buffer_1.default(response);
1215
+ response.body = response.rawBody.toString();
1216
+ }
1217
+ catch (_a) { }
1218
+ }
1219
+ if (this.listenerCount('retry') !== 0) {
1220
+ let backoff;
1221
+ try {
1222
+ let retryAfter;
1223
+ if (response && 'retry-after' in response.headers) {
1224
+ retryAfter = Number(response.headers['retry-after']);
1225
+ if (Number.isNaN(retryAfter)) {
1226
+ retryAfter = Date.parse(response.headers['retry-after']) - Date.now();
1227
+ if (retryAfter <= 0) {
1228
+ retryAfter = 1;
1229
+ }
1230
+ }
1231
+ else {
1232
+ retryAfter *= 1000;
1233
+ }
1234
+ }
1235
+ backoff = await options.retry.calculateDelay({
1236
+ attemptCount: retryCount,
1237
+ retryOptions: options.retry,
1238
+ error: typedError,
1239
+ retryAfter,
1240
+ computedValue: calculate_retry_delay_1.default({
1241
+ attemptCount: retryCount,
1242
+ retryOptions: options.retry,
1243
+ error: typedError,
1244
+ retryAfter,
1245
+ computedValue: 0
1246
+ })
1247
+ });
1248
+ }
1249
+ catch (error_) {
1250
+ void this._error(new RequestError(error_.message, error_, this));
1251
+ return;
1252
+ }
1253
+ if (backoff) {
1254
+ const retry = async () => {
1255
+ try {
1256
+ for (const hook of this.options.hooks.beforeRetry) {
1257
+ // eslint-disable-next-line no-await-in-loop
1258
+ await hook(this.options, typedError, retryCount);
1259
+ }
1260
+ }
1261
+ catch (error_) {
1262
+ void this._error(new RequestError(error_.message, error, this));
1263
+ return;
1264
+ }
1265
+ // Something forced us to abort the retry
1266
+ if (this.destroyed) {
1267
+ return;
1268
+ }
1269
+ this.destroy();
1270
+ this.emit('retry', retryCount, error);
1271
+ };
1272
+ this[kRetryTimeout] = setTimeout(retry, backoff);
1273
+ return;
1274
+ }
1275
+ }
1276
+ void this._error(typedError);
1277
+ })();
1278
+ }
1279
+ _read() {
1280
+ this[kTriggerRead] = true;
1281
+ const response = this[kResponse];
1282
+ if (response && !this[kStopReading]) {
1283
+ // We cannot put this in the `if` above
1284
+ // because `.read()` also triggers the `end` event
1285
+ if (response.readableLength) {
1286
+ this[kTriggerRead] = false;
1287
+ }
1288
+ let data;
1289
+ while ((data = response.read()) !== null) {
1290
+ this[kDownloadedSize] += data.length;
1291
+ this[kStartedReading] = true;
1292
+ const progress = this.downloadProgress;
1293
+ if (progress.percent < 1) {
1294
+ this.emit('downloadProgress', progress);
1295
+ }
1296
+ this.push(data);
1297
+ }
1298
+ }
1299
+ }
1300
+ // Node.js 12 has incorrect types, so the encoding must be a string
1301
+ _write(chunk, encoding, callback) {
1302
+ const write = () => {
1303
+ this._writeRequest(chunk, encoding, callback);
1304
+ };
1305
+ if (this.requestInitialized) {
1306
+ write();
1307
+ }
1308
+ else {
1309
+ this[kJobs].push(write);
1310
+ }
1311
+ }
1312
+ _writeRequest(chunk, encoding, callback) {
1313
+ if (this[kRequest].destroyed) {
1314
+ // Probably the `ClientRequest` instance will throw
1315
+ return;
1316
+ }
1317
+ this._progressCallbacks.push(() => {
1318
+ this[kUploadedSize] += Buffer.byteLength(chunk, encoding);
1319
+ const progress = this.uploadProgress;
1320
+ if (progress.percent < 1) {
1321
+ this.emit('uploadProgress', progress);
1322
+ }
1323
+ });
1324
+ // TODO: What happens if it's from cache? Then this[kRequest] won't be defined.
1325
+ this[kRequest].write(chunk, encoding, (error) => {
1326
+ if (!error && this._progressCallbacks.length > 0) {
1327
+ this._progressCallbacks.shift()();
1328
+ }
1329
+ callback(error);
1330
+ });
1331
+ }
1332
+ _final(callback) {
1333
+ const endRequest = () => {
1334
+ // FIX: Node.js 10 calls the write callback AFTER the end callback!
1335
+ while (this._progressCallbacks.length !== 0) {
1336
+ this._progressCallbacks.shift()();
1337
+ }
1338
+ // We need to check if `this[kRequest]` is present,
1339
+ // because it isn't when we use cache.
1340
+ if (!(kRequest in this)) {
1341
+ callback();
1342
+ return;
1343
+ }
1344
+ if (this[kRequest].destroyed) {
1345
+ callback();
1346
+ return;
1347
+ }
1348
+ this[kRequest].end((error) => {
1349
+ if (!error) {
1350
+ this[kBodySize] = this[kUploadedSize];
1351
+ this.emit('uploadProgress', this.uploadProgress);
1352
+ this[kRequest].emit('upload-complete');
1353
+ }
1354
+ callback(error);
1355
+ });
1356
+ };
1357
+ if (this.requestInitialized) {
1358
+ endRequest();
1359
+ }
1360
+ else {
1361
+ this[kJobs].push(endRequest);
1362
+ }
1363
+ }
1364
+ _destroy(error, callback) {
1365
+ var _a;
1366
+ this[kStopReading] = true;
1367
+ // Prevent further retries
1368
+ clearTimeout(this[kRetryTimeout]);
1369
+ if (kRequest in this) {
1370
+ this[kCancelTimeouts]();
1371
+ // TODO: Remove the next `if` when these get fixed:
1372
+ // - https://github.com/nodejs/node/issues/32851
1373
+ if (!((_a = this[kResponse]) === null || _a === void 0 ? void 0 : _a.complete)) {
1374
+ this[kRequest].destroy();
1375
+ }
1376
+ }
1377
+ if (error !== null && !is_1.default.undefined(error) && !(error instanceof RequestError)) {
1378
+ error = new RequestError(error.message, error, this);
1379
+ }
1380
+ callback(error);
1381
+ }
1382
+ get _isAboutToError() {
1383
+ return this[kStopReading];
1384
+ }
1385
+ /**
1386
+ The remote IP address.
1387
+ */
1388
+ get ip() {
1389
+ var _a;
1390
+ return (_a = this.socket) === null || _a === void 0 ? void 0 : _a.remoteAddress;
1391
+ }
1392
+ /**
1393
+ Indicates whether the request has been aborted or not.
1394
+ */
1395
+ get aborted() {
1396
+ var _a, _b, _c;
1397
+ return ((_b = (_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.destroyed) !== null && _b !== void 0 ? _b : this.destroyed) && !((_c = this[kOriginalResponse]) === null || _c === void 0 ? void 0 : _c.complete);
1398
+ }
1399
+ get socket() {
1400
+ var _a, _b;
1401
+ return (_b = (_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.socket) !== null && _b !== void 0 ? _b : undefined;
1402
+ }
1403
+ /**
1404
+ Progress event for downloading (receiving a response).
1405
+ */
1406
+ get downloadProgress() {
1407
+ let percent;
1408
+ if (this[kResponseSize]) {
1409
+ percent = this[kDownloadedSize] / this[kResponseSize];
1410
+ }
1411
+ else if (this[kResponseSize] === this[kDownloadedSize]) {
1412
+ percent = 1;
1413
+ }
1414
+ else {
1415
+ percent = 0;
1416
+ }
1417
+ return {
1418
+ percent,
1419
+ transferred: this[kDownloadedSize],
1420
+ total: this[kResponseSize]
1421
+ };
1422
+ }
1423
+ /**
1424
+ Progress event for uploading (sending a request).
1425
+ */
1426
+ get uploadProgress() {
1427
+ let percent;
1428
+ if (this[kBodySize]) {
1429
+ percent = this[kUploadedSize] / this[kBodySize];
1430
+ }
1431
+ else if (this[kBodySize] === this[kUploadedSize]) {
1432
+ percent = 1;
1433
+ }
1434
+ else {
1435
+ percent = 0;
1436
+ }
1437
+ return {
1438
+ percent,
1439
+ transferred: this[kUploadedSize],
1440
+ total: this[kBodySize]
1441
+ };
1442
+ }
1443
+ /**
1444
+ The object contains the following properties:
1445
+
1446
+ - `start` - Time when the request started.
1447
+ - `socket` - Time when a socket was assigned to the request.
1448
+ - `lookup` - Time when the DNS lookup finished.
1449
+ - `connect` - Time when the socket successfully connected.
1450
+ - `secureConnect` - Time when the socket securely connected.
1451
+ - `upload` - Time when the request finished uploading.
1452
+ - `response` - Time when the request fired `response` event.
1453
+ - `end` - Time when the response fired `end` event.
1454
+ - `error` - Time when the request fired `error` event.
1455
+ - `abort` - Time when the request fired `abort` event.
1456
+ - `phases`
1457
+ - `wait` - `timings.socket - timings.start`
1458
+ - `dns` - `timings.lookup - timings.socket`
1459
+ - `tcp` - `timings.connect - timings.lookup`
1460
+ - `tls` - `timings.secureConnect - timings.connect`
1461
+ - `request` - `timings.upload - (timings.secureConnect || timings.connect)`
1462
+ - `firstByte` - `timings.response - timings.upload`
1463
+ - `download` - `timings.end - timings.response`
1464
+ - `total` - `(timings.end || timings.error || timings.abort) - timings.start`
1465
+
1466
+ If something has not been measured yet, it will be `undefined`.
1467
+
1468
+ __Note__: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
1469
+ */
1470
+ get timings() {
1471
+ var _a;
1472
+ return (_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.timings;
1473
+ }
1474
+ /**
1475
+ Whether the response was retrieved from the cache.
1476
+ */
1477
+ get isFromCache() {
1478
+ return this[kIsFromCache];
1479
+ }
1480
+ pipe(destination, options) {
1481
+ if (this[kStartedReading]) {
1482
+ throw new Error('Failed to pipe. The response has been emitted already.');
1483
+ }
1484
+ if (destination instanceof http_1.ServerResponse) {
1485
+ this[kServerResponsesPiped].add(destination);
1486
+ }
1487
+ return super.pipe(destination, options);
1488
+ }
1489
+ unpipe(destination) {
1490
+ if (destination instanceof http_1.ServerResponse) {
1491
+ this[kServerResponsesPiped].delete(destination);
1492
+ }
1493
+ super.unpipe(destination);
1494
+ return this;
1495
+ }
1496
+ }
1497
+ exports.default = Request;