monitor-transfer-dsh 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +51 -2
  3. package/cordis.patch.yml +4 -0
  4. package/lib/client.js +381 -0
  5. package/lib/index.js +267 -0
  6. package/package.json +67 -3
  7. package/skill/SKILL.md +48 -0
  8. package/skill/tools/node_modules/.package-lock.json +163 -0
  9. package/skill/tools/node_modules/pg/LICENSE +21 -0
  10. package/skill/tools/node_modules/pg/README.md +96 -0
  11. package/skill/tools/node_modules/pg/esm/index.mjs +20 -0
  12. package/skill/tools/node_modules/pg/lib/client.js +846 -0
  13. package/skill/tools/node_modules/pg/lib/connection-parameters.js +184 -0
  14. package/skill/tools/node_modules/pg/lib/connection.js +250 -0
  15. package/skill/tools/node_modules/pg/lib/crypto/cert-signatures.js +122 -0
  16. package/skill/tools/node_modules/pg/lib/crypto/sasl.js +262 -0
  17. package/skill/tools/node_modules/pg/lib/crypto/utils.js +89 -0
  18. package/skill/tools/node_modules/pg/lib/defaults.js +94 -0
  19. package/skill/tools/node_modules/pg/lib/index.js +73 -0
  20. package/skill/tools/node_modules/pg/lib/native/client.js +428 -0
  21. package/skill/tools/node_modules/pg/lib/native/index.js +2 -0
  22. package/skill/tools/node_modules/pg/lib/native/query.js +167 -0
  23. package/skill/tools/node_modules/pg/lib/query.js +263 -0
  24. package/skill/tools/node_modules/pg/lib/result.js +109 -0
  25. package/skill/tools/node_modules/pg/lib/stream.js +83 -0
  26. package/skill/tools/node_modules/pg/lib/type-overrides.js +35 -0
  27. package/skill/tools/node_modules/pg/lib/utils.js +225 -0
  28. package/skill/tools/node_modules/pg/package.json +76 -0
  29. package/skill/tools/node_modules/pg-cloudflare/LICENSE +21 -0
  30. package/skill/tools/node_modules/pg-cloudflare/README.md +112 -0
  31. package/skill/tools/node_modules/pg-cloudflare/dist/empty.d.ts +2 -0
  32. package/skill/tools/node_modules/pg-cloudflare/dist/empty.js +6 -0
  33. package/skill/tools/node_modules/pg-cloudflare/dist/empty.js.map +1 -0
  34. package/skill/tools/node_modules/pg-cloudflare/dist/index.d.ts +29 -0
  35. package/skill/tools/node_modules/pg-cloudflare/dist/index.js +171 -0
  36. package/skill/tools/node_modules/pg-cloudflare/dist/index.js.map +1 -0
  37. package/skill/tools/node_modules/pg-cloudflare/esm/index.mjs +3 -0
  38. package/skill/tools/node_modules/pg-cloudflare/package.json +39 -0
  39. package/skill/tools/node_modules/pg-cloudflare/src/empty.ts +3 -0
  40. package/skill/tools/node_modules/pg-cloudflare/src/index.ts +187 -0
  41. package/skill/tools/node_modules/pg-cloudflare/src/types.d.ts +25 -0
  42. package/skill/tools/node_modules/pg-connection-string/LICENSE +21 -0
  43. package/skill/tools/node_modules/pg-connection-string/README.md +105 -0
  44. package/skill/tools/node_modules/pg-connection-string/esm/index.mjs +8 -0
  45. package/skill/tools/node_modules/pg-connection-string/index.d.ts +37 -0
  46. package/skill/tools/node_modules/pg-connection-string/index.js +237 -0
  47. package/skill/tools/node_modules/pg-connection-string/package.json +51 -0
  48. package/skill/tools/node_modules/pg-int8/LICENSE +13 -0
  49. package/skill/tools/node_modules/pg-int8/README.md +16 -0
  50. package/skill/tools/node_modules/pg-int8/index.js +100 -0
  51. package/skill/tools/node_modules/pg-int8/package.json +24 -0
  52. package/skill/tools/node_modules/pg-pool/LICENSE +21 -0
  53. package/skill/tools/node_modules/pg-pool/README.md +357 -0
  54. package/skill/tools/node_modules/pg-pool/esm/index.mjs +5 -0
  55. package/skill/tools/node_modules/pg-pool/index.js +517 -0
  56. package/skill/tools/node_modules/pg-pool/package.json +51 -0
  57. package/skill/tools/node_modules/pg-protocol/LICENSE +21 -0
  58. package/skill/tools/node_modules/pg-protocol/README.md +3 -0
  59. package/skill/tools/node_modules/pg-protocol/dist/b.d.ts +1 -0
  60. package/skill/tools/node_modules/pg-protocol/dist/b.js +23 -0
  61. package/skill/tools/node_modules/pg-protocol/dist/b.js.map +1 -0
  62. package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.d.ts +14 -0
  63. package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js +55 -0
  64. package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js.map +1 -0
  65. package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.d.ts +21 -0
  66. package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js +113 -0
  67. package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js.map +1 -0
  68. package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.d.ts +1 -0
  69. package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js +538 -0
  70. package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js.map +1 -0
  71. package/skill/tools/node_modules/pg-protocol/dist/index.d.ts +5 -0
  72. package/skill/tools/node_modules/pg-protocol/dist/index.js +15 -0
  73. package/skill/tools/node_modules/pg-protocol/dist/index.js.map +1 -0
  74. package/skill/tools/node_modules/pg-protocol/dist/messages.d.ts +161 -0
  75. package/skill/tools/node_modules/pg-protocol/dist/messages.js +160 -0
  76. package/skill/tools/node_modules/pg-protocol/dist/messages.js.map +1 -0
  77. package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.d.ts +1 -0
  78. package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js +325 -0
  79. package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js.map +1 -0
  80. package/skill/tools/node_modules/pg-protocol/dist/parser.d.ts +22 -0
  81. package/skill/tools/node_modules/pg-protocol/dist/parser.js +325 -0
  82. package/skill/tools/node_modules/pg-protocol/dist/parser.js.map +1 -0
  83. package/skill/tools/node_modules/pg-protocol/dist/serializer.d.ts +42 -0
  84. package/skill/tools/node_modules/pg-protocol/dist/serializer.js +198 -0
  85. package/skill/tools/node_modules/pg-protocol/dist/serializer.js.map +1 -0
  86. package/skill/tools/node_modules/pg-protocol/esm/index.js +11 -0
  87. package/skill/tools/node_modules/pg-protocol/package.json +44 -0
  88. package/skill/tools/node_modules/pg-protocol/src/b.ts +25 -0
  89. package/skill/tools/node_modules/pg-protocol/src/buffer-reader.ts +58 -0
  90. package/skill/tools/node_modules/pg-protocol/src/buffer-writer.ts +120 -0
  91. package/skill/tools/node_modules/pg-protocol/src/inbound-parser.test.ts +585 -0
  92. package/skill/tools/node_modules/pg-protocol/src/index.ts +11 -0
  93. package/skill/tools/node_modules/pg-protocol/src/messages.ts +262 -0
  94. package/skill/tools/node_modules/pg-protocol/src/outbound-serializer.test.ts +356 -0
  95. package/skill/tools/node_modules/pg-protocol/src/parser.ts +414 -0
  96. package/skill/tools/node_modules/pg-protocol/src/serializer.ts +286 -0
  97. package/skill/tools/node_modules/pg-protocol/src/testing/buffer-list.ts +67 -0
  98. package/skill/tools/node_modules/pg-protocol/src/testing/test-buffers.ts +166 -0
  99. package/skill/tools/node_modules/pg-types/.travis.yml +7 -0
  100. package/skill/tools/node_modules/pg-types/Makefile +14 -0
  101. package/skill/tools/node_modules/pg-types/README.md +75 -0
  102. package/skill/tools/node_modules/pg-types/index.d.ts +137 -0
  103. package/skill/tools/node_modules/pg-types/index.js +47 -0
  104. package/skill/tools/node_modules/pg-types/index.test-d.ts +21 -0
  105. package/skill/tools/node_modules/pg-types/lib/arrayParser.js +11 -0
  106. package/skill/tools/node_modules/pg-types/lib/binaryParsers.js +257 -0
  107. package/skill/tools/node_modules/pg-types/lib/builtins.js +73 -0
  108. package/skill/tools/node_modules/pg-types/lib/textParsers.js +215 -0
  109. package/skill/tools/node_modules/pg-types/package.json +42 -0
  110. package/skill/tools/node_modules/pg-types/test/index.js +24 -0
  111. package/skill/tools/node_modules/pg-types/test/types.js +597 -0
  112. package/skill/tools/node_modules/pgpass/README.md +74 -0
  113. package/skill/tools/node_modules/pgpass/lib/helper.js +233 -0
  114. package/skill/tools/node_modules/pgpass/lib/index.js +23 -0
  115. package/skill/tools/node_modules/pgpass/package.json +41 -0
  116. package/skill/tools/node_modules/postgres-array/index.d.ts +4 -0
  117. package/skill/tools/node_modules/postgres-array/index.js +97 -0
  118. package/skill/tools/node_modules/postgres-array/license +21 -0
  119. package/skill/tools/node_modules/postgres-array/package.json +35 -0
  120. package/skill/tools/node_modules/postgres-array/readme.md +43 -0
  121. package/skill/tools/node_modules/postgres-bytea/index.js +33 -0
  122. package/skill/tools/node_modules/postgres-bytea/license +21 -0
  123. package/skill/tools/node_modules/postgres-bytea/package.json +34 -0
  124. package/skill/tools/node_modules/postgres-bytea/readme.md +34 -0
  125. package/skill/tools/node_modules/postgres-date/index.js +116 -0
  126. package/skill/tools/node_modules/postgres-date/license +21 -0
  127. package/skill/tools/node_modules/postgres-date/package.json +33 -0
  128. package/skill/tools/node_modules/postgres-date/readme.md +49 -0
  129. package/skill/tools/node_modules/postgres-interval/index.d.ts +20 -0
  130. package/skill/tools/node_modules/postgres-interval/index.js +125 -0
  131. package/skill/tools/node_modules/postgres-interval/license +21 -0
  132. package/skill/tools/node_modules/postgres-interval/package.json +36 -0
  133. package/skill/tools/node_modules/postgres-interval/readme.md +48 -0
  134. package/skill/tools/node_modules/split2/LICENSE +13 -0
  135. package/skill/tools/node_modules/split2/README.md +85 -0
  136. package/skill/tools/node_modules/split2/bench.js +27 -0
  137. package/skill/tools/node_modules/split2/index.js +141 -0
  138. package/skill/tools/node_modules/split2/package.json +39 -0
  139. package/skill/tools/node_modules/split2/test.js +409 -0
  140. package/skill/tools/node_modules/undici/LICENSE +21 -0
  141. package/skill/tools/node_modules/undici/README.md +828 -0
  142. package/skill/tools/node_modules/undici/docs/docs/api/Agent.md +291 -0
  143. package/skill/tools/node_modules/undici/docs/docs/api/BalancedPool.md +297 -0
  144. package/skill/tools/node_modules/undici/docs/docs/api/CacheStorage.md +188 -0
  145. package/skill/tools/node_modules/undici/docs/docs/api/CacheStore.md +375 -0
  146. package/skill/tools/node_modules/undici/docs/docs/api/Client.md +538 -0
  147. package/skill/tools/node_modules/undici/docs/docs/api/ClientStats.md +93 -0
  148. package/skill/tools/node_modules/undici/docs/docs/api/Connector.md +198 -0
  149. package/skill/tools/node_modules/undici/docs/docs/api/ContentType.md +97 -0
  150. package/skill/tools/node_modules/undici/docs/docs/api/Cookies.md +179 -0
  151. package/skill/tools/node_modules/undici/docs/docs/api/Debug.md +78 -0
  152. package/skill/tools/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +518 -0
  153. package/skill/tools/node_modules/undici/docs/docs/api/Dispatcher.md +842 -0
  154. package/skill/tools/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +171 -0
  155. package/skill/tools/node_modules/undici/docs/docs/api/Errors.md +624 -0
  156. package/skill/tools/node_modules/undici/docs/docs/api/EventSource.md +358 -0
  157. package/skill/tools/node_modules/undici/docs/docs/api/Fetch.md +721 -0
  158. package/skill/tools/node_modules/undici/docs/docs/api/GlobalInstallation.md +121 -0
  159. package/skill/tools/node_modules/undici/docs/docs/api/H2CClient.md +386 -0
  160. package/skill/tools/node_modules/undici/docs/docs/api/Interceptors.md +439 -0
  161. package/skill/tools/node_modules/undici/docs/docs/api/MockAgent.md +622 -0
  162. package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistory.md +371 -0
  163. package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +206 -0
  164. package/skill/tools/node_modules/undici/docs/docs/api/MockClient.md +199 -0
  165. package/skill/tools/node_modules/undici/docs/docs/api/MockErrors.md +63 -0
  166. package/skill/tools/node_modules/undici/docs/docs/api/MockPool.md +618 -0
  167. package/skill/tools/node_modules/undici/docs/docs/api/Pool.md +278 -0
  168. package/skill/tools/node_modules/undici/docs/docs/api/PoolStats.md +141 -0
  169. package/skill/tools/node_modules/undici/docs/docs/api/ProxyAgent.md +248 -0
  170. package/skill/tools/node_modules/undici/docs/docs/api/RedirectHandler.md +279 -0
  171. package/skill/tools/node_modules/undici/docs/docs/api/RetryAgent.md +136 -0
  172. package/skill/tools/node_modules/undici/docs/docs/api/RetryHandler.md +200 -0
  173. package/skill/tools/node_modules/undici/docs/docs/api/RoundRobinPool.md +239 -0
  174. package/skill/tools/node_modules/undici/docs/docs/api/SnapshotAgent.md +361 -0
  175. package/skill/tools/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +256 -0
  176. package/skill/tools/node_modules/undici/docs/docs/api/Util.md +82 -0
  177. package/skill/tools/node_modules/undici/docs/docs/api/WebSocket.md +536 -0
  178. package/skill/tools/node_modules/undici/docs/docs/api/api-lifecycle.md +159 -0
  179. package/skill/tools/node_modules/undici/docs/docs/best-practices/client-certificate.md +66 -0
  180. package/skill/tools/node_modules/undici/docs/docs/best-practices/crawling.md +60 -0
  181. package/skill/tools/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +233 -0
  182. package/skill/tools/node_modules/undici/docs/docs/best-practices/mocking-request.md +192 -0
  183. package/skill/tools/node_modules/undici/docs/docs/best-practices/proxy.md +129 -0
  184. package/skill/tools/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +226 -0
  185. package/skill/tools/node_modules/undici/docs/docs/best-practices/writing-tests.md +65 -0
  186. package/skill/tools/node_modules/undici/docs/docs/getting-started.md +281 -0
  187. package/skill/tools/node_modules/undici/docs/docs/index.md +793 -0
  188. package/skill/tools/node_modules/undici/docs/docs/site.json +125 -0
  189. package/skill/tools/node_modules/undici/docs/docs/type-map.json +79 -0
  190. package/skill/tools/node_modules/undici/index-fetch.js +65 -0
  191. package/skill/tools/node_modules/undici/index.d.ts +3 -0
  192. package/skill/tools/node_modules/undici/index.js +236 -0
  193. package/skill/tools/node_modules/undici/lib/api/abort-signal.js +59 -0
  194. package/skill/tools/node_modules/undici/lib/api/api-connect.js +112 -0
  195. package/skill/tools/node_modules/undici/lib/api/api-pipeline.js +265 -0
  196. package/skill/tools/node_modules/undici/lib/api/api-request.js +244 -0
  197. package/skill/tools/node_modules/undici/lib/api/api-stream.js +270 -0
  198. package/skill/tools/node_modules/undici/lib/api/api-upgrade.js +121 -0
  199. package/skill/tools/node_modules/undici/lib/api/index.js +7 -0
  200. package/skill/tools/node_modules/undici/lib/api/readable.js +615 -0
  201. package/skill/tools/node_modules/undici/lib/cache/memory-cache-store.js +314 -0
  202. package/skill/tools/node_modules/undici/lib/cache/sqlite-cache-store.js +593 -0
  203. package/skill/tools/node_modules/undici/lib/core/connect.js +198 -0
  204. package/skill/tools/node_modules/undici/lib/core/constants.js +131 -0
  205. package/skill/tools/node_modules/undici/lib/core/diagnostics.js +227 -0
  206. package/skill/tools/node_modules/undici/lib/core/errors.js +534 -0
  207. package/skill/tools/node_modules/undici/lib/core/request.js +582 -0
  208. package/skill/tools/node_modules/undici/lib/core/socks5-client.js +422 -0
  209. package/skill/tools/node_modules/undici/lib/core/socks5-utils.js +212 -0
  210. package/skill/tools/node_modules/undici/lib/core/symbols.js +81 -0
  211. package/skill/tools/node_modules/undici/lib/core/tree.js +160 -0
  212. package/skill/tools/node_modules/undici/lib/core/util.js +1035 -0
  213. package/skill/tools/node_modules/undici/lib/dispatcher/agent.js +181 -0
  214. package/skill/tools/node_modules/undici/lib/dispatcher/balanced-pool.js +217 -0
  215. package/skill/tools/node_modules/undici/lib/dispatcher/client-h1.js +1846 -0
  216. package/skill/tools/node_modules/undici/lib/dispatcher/client-h2.js +1989 -0
  217. package/skill/tools/node_modules/undici/lib/dispatcher/client.js +749 -0
  218. package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher-base.js +198 -0
  219. package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher.js +58 -0
  220. package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +127 -0
  221. package/skill/tools/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +190 -0
  222. package/skill/tools/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
  223. package/skill/tools/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
  224. package/skill/tools/node_modules/undici/lib/dispatcher/parser-h1.js +1065 -0
  225. package/skill/tools/node_modules/undici/lib/dispatcher/pool-base.js +347 -0
  226. package/skill/tools/node_modules/undici/lib/dispatcher/pool.js +229 -0
  227. package/skill/tools/node_modules/undici/lib/dispatcher/proxy-agent.js +418 -0
  228. package/skill/tools/node_modules/undici/lib/dispatcher/retry-agent.js +48 -0
  229. package/skill/tools/node_modules/undici/lib/dispatcher/round-robin-pool.js +169 -0
  230. package/skill/tools/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +350 -0
  231. package/skill/tools/node_modules/undici/lib/encoding/index.js +33 -0
  232. package/skill/tools/node_modules/undici/lib/global.js +82 -0
  233. package/skill/tools/node_modules/undici/lib/handler/cache-handler.js +1222 -0
  234. package/skill/tools/node_modules/undici/lib/handler/cache-revalidation-handler.js +134 -0
  235. package/skill/tools/node_modules/undici/lib/handler/decorator-handler.js +76 -0
  236. package/skill/tools/node_modules/undici/lib/handler/deduplication-handler.js +540 -0
  237. package/skill/tools/node_modules/undici/lib/handler/redirect-handler.js +284 -0
  238. package/skill/tools/node_modules/undici/lib/handler/retry-handler.js +686 -0
  239. package/skill/tools/node_modules/undici/lib/interceptor/cache.js +771 -0
  240. package/skill/tools/node_modules/undici/lib/interceptor/decompress.js +574 -0
  241. package/skill/tools/node_modules/undici/lib/interceptor/deduplicate.js +118 -0
  242. package/skill/tools/node_modules/undici/lib/interceptor/dns.js +593 -0
  243. package/skill/tools/node_modules/undici/lib/interceptor/dump.js +99 -0
  244. package/skill/tools/node_modules/undici/lib/interceptor/redirect.js +21 -0
  245. package/skill/tools/node_modules/undici/lib/interceptor/response-error.js +139 -0
  246. package/skill/tools/node_modules/undici/lib/interceptor/retry.js +19 -0
  247. package/skill/tools/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
  248. package/skill/tools/node_modules/undici/lib/llhttp/constants.js +531 -0
  249. package/skill/tools/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
  250. package/skill/tools/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
  251. package/skill/tools/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
  252. package/skill/tools/node_modules/undici/lib/llhttp/utils.js +12 -0
  253. package/skill/tools/node_modules/undici/lib/milo/LICENSE.md +7 -0
  254. package/skill/tools/node_modules/undici/lib/milo/no-simd.js +1002 -0
  255. package/skill/tools/node_modules/undici/lib/milo/simd.js +1002 -0
  256. package/skill/tools/node_modules/undici/lib/mock/mock-agent.js +255 -0
  257. package/skill/tools/node_modules/undici/lib/mock/mock-call-history.js +248 -0
  258. package/skill/tools/node_modules/undici/lib/mock/mock-client.js +68 -0
  259. package/skill/tools/node_modules/undici/lib/mock/mock-errors.js +29 -0
  260. package/skill/tools/node_modules/undici/lib/mock/mock-interceptor.js +227 -0
  261. package/skill/tools/node_modules/undici/lib/mock/mock-pool.js +68 -0
  262. package/skill/tools/node_modules/undici/lib/mock/mock-symbols.js +32 -0
  263. package/skill/tools/node_modules/undici/lib/mock/mock-utils.js +730 -0
  264. package/skill/tools/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
  265. package/skill/tools/node_modules/undici/lib/mock/snapshot-agent.js +371 -0
  266. package/skill/tools/node_modules/undici/lib/mock/snapshot-recorder.js +624 -0
  267. package/skill/tools/node_modules/undici/lib/mock/snapshot-utils.js +159 -0
  268. package/skill/tools/node_modules/undici/lib/util/cache.js +764 -0
  269. package/skill/tools/node_modules/undici/lib/util/date.js +670 -0
  270. package/skill/tools/node_modules/undici/lib/util/runtime-features.js +93 -0
  271. package/skill/tools/node_modules/undici/lib/util/stats.js +32 -0
  272. package/skill/tools/node_modules/undici/lib/util/timers.js +425 -0
  273. package/skill/tools/node_modules/undici/lib/web/cache/cache.js +871 -0
  274. package/skill/tools/node_modules/undici/lib/web/cache/cachestorage.js +158 -0
  275. package/skill/tools/node_modules/undici/lib/web/cache/util.js +45 -0
  276. package/skill/tools/node_modules/undici/lib/web/cookies/constants.js +12 -0
  277. package/skill/tools/node_modules/undici/lib/web/cookies/index.js +211 -0
  278. package/skill/tools/node_modules/undici/lib/web/cookies/parse.js +318 -0
  279. package/skill/tools/node_modules/undici/lib/web/cookies/util.js +371 -0
  280. package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource-stream.js +575 -0
  281. package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource.js +547 -0
  282. package/skill/tools/node_modules/undici/lib/web/eventsource/util.js +60 -0
  283. package/skill/tools/node_modules/undici/lib/web/fetch/LICENSE +21 -0
  284. package/skill/tools/node_modules/undici/lib/web/fetch/body.js +583 -0
  285. package/skill/tools/node_modules/undici/lib/web/fetch/constants.js +131 -0
  286. package/skill/tools/node_modules/undici/lib/web/fetch/data-url.js +596 -0
  287. package/skill/tools/node_modules/undici/lib/web/fetch/formdata-parser.js +594 -0
  288. package/skill/tools/node_modules/undici/lib/web/fetch/formdata.js +272 -0
  289. package/skill/tools/node_modules/undici/lib/web/fetch/global.js +40 -0
  290. package/skill/tools/node_modules/undici/lib/web/fetch/headers.js +722 -0
  291. package/skill/tools/node_modules/undici/lib/web/fetch/index.js +2451 -0
  292. package/skill/tools/node_modules/undici/lib/web/fetch/request.js +1117 -0
  293. package/skill/tools/node_modules/undici/lib/web/fetch/response.js +638 -0
  294. package/skill/tools/node_modules/undici/lib/web/fetch/util.js +1530 -0
  295. package/skill/tools/node_modules/undici/lib/web/infra/index.js +244 -0
  296. package/skill/tools/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
  297. package/skill/tools/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
  298. package/skill/tools/node_modules/undici/lib/web/webidl/index.js +992 -0
  299. package/skill/tools/node_modules/undici/lib/web/websocket/connection.js +350 -0
  300. package/skill/tools/node_modules/undici/lib/web/websocket/constants.js +126 -0
  301. package/skill/tools/node_modules/undici/lib/web/websocket/events.js +348 -0
  302. package/skill/tools/node_modules/undici/lib/web/websocket/frame.js +127 -0
  303. package/skill/tools/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
  304. package/skill/tools/node_modules/undici/lib/web/websocket/receiver.js +530 -0
  305. package/skill/tools/node_modules/undici/lib/web/websocket/sender.js +109 -0
  306. package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketerror.js +107 -0
  307. package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketstream.js +511 -0
  308. package/skill/tools/node_modules/undici/lib/web/websocket/util.js +347 -0
  309. package/skill/tools/node_modules/undici/lib/web/websocket/websocket.js +783 -0
  310. package/skill/tools/node_modules/undici/package.json +154 -0
  311. package/skill/tools/node_modules/undici/scripts/strip-comments.js +10 -0
  312. package/skill/tools/node_modules/undici/types/README.md +6 -0
  313. package/skill/tools/node_modules/undici/types/agent.d.ts +30 -0
  314. package/skill/tools/node_modules/undici/types/api.d.ts +43 -0
  315. package/skill/tools/node_modules/undici/types/balanced-pool.d.ts +30 -0
  316. package/skill/tools/node_modules/undici/types/cache-interceptor.d.ts +189 -0
  317. package/skill/tools/node_modules/undici/types/cache.d.ts +36 -0
  318. package/skill/tools/node_modules/undici/types/client-stats.d.ts +15 -0
  319. package/skill/tools/node_modules/undici/types/client.d.ts +190 -0
  320. package/skill/tools/node_modules/undici/types/connector.d.ts +37 -0
  321. package/skill/tools/node_modules/undici/types/content-type.d.ts +21 -0
  322. package/skill/tools/node_modules/undici/types/cookies.d.ts +30 -0
  323. package/skill/tools/node_modules/undici/types/diagnostics-channel.d.ts +75 -0
  324. package/skill/tools/node_modules/undici/types/dispatcher.d.ts +253 -0
  325. package/skill/tools/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
  326. package/skill/tools/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
  327. package/skill/tools/node_modules/undici/types/errors.d.ts +202 -0
  328. package/skill/tools/node_modules/undici/types/eventsource.d.ts +66 -0
  329. package/skill/tools/node_modules/undici/types/fetch.d.ts +235 -0
  330. package/skill/tools/node_modules/undici/types/formdata.d.ts +108 -0
  331. package/skill/tools/node_modules/undici/types/global-dispatcher.d.ts +9 -0
  332. package/skill/tools/node_modules/undici/types/global-origin.d.ts +7 -0
  333. package/skill/tools/node_modules/undici/types/h2c-client.d.ts +73 -0
  334. package/skill/tools/node_modules/undici/types/handlers.d.ts +16 -0
  335. package/skill/tools/node_modules/undici/types/header.d.ts +165 -0
  336. package/skill/tools/node_modules/undici/types/index.d.ts +93 -0
  337. package/skill/tools/node_modules/undici/types/interceptors.d.ts +87 -0
  338. package/skill/tools/node_modules/undici/types/mock-agent.d.ts +69 -0
  339. package/skill/tools/node_modules/undici/types/mock-call-history.d.ts +111 -0
  340. package/skill/tools/node_modules/undici/types/mock-client.d.ts +27 -0
  341. package/skill/tools/node_modules/undici/types/mock-errors.d.ts +12 -0
  342. package/skill/tools/node_modules/undici/types/mock-interceptor.d.ts +98 -0
  343. package/skill/tools/node_modules/undici/types/mock-pool.d.ts +27 -0
  344. package/skill/tools/node_modules/undici/types/patch.d.ts +29 -0
  345. package/skill/tools/node_modules/undici/types/pool-stats.d.ts +19 -0
  346. package/skill/tools/node_modules/undici/types/pool.d.ts +39 -0
  347. package/skill/tools/node_modules/undici/types/proxy-agent.d.ts +36 -0
  348. package/skill/tools/node_modules/undici/types/readable.d.ts +68 -0
  349. package/skill/tools/node_modules/undici/types/retry-agent.d.ts +8 -0
  350. package/skill/tools/node_modules/undici/types/retry-handler.d.ts +125 -0
  351. package/skill/tools/node_modules/undici/types/round-robin-pool.d.ts +39 -0
  352. package/skill/tools/node_modules/undici/types/snapshot-agent.d.ts +113 -0
  353. package/skill/tools/node_modules/undici/types/socks5-proxy-agent.d.ts +27 -0
  354. package/skill/tools/node_modules/undici/types/util.d.ts +18 -0
  355. package/skill/tools/node_modules/undici/types/utility.d.ts +7 -0
  356. package/skill/tools/node_modules/undici/types/webidl.d.ts +352 -0
  357. package/skill/tools/node_modules/undici/types/websocket.d.ts +188 -0
  358. package/skill/tools/node_modules/xtend/.jshintrc +30 -0
  359. package/skill/tools/node_modules/xtend/LICENSE +20 -0
  360. package/skill/tools/node_modules/xtend/README.md +32 -0
  361. package/skill/tools/node_modules/xtend/immutable.js +19 -0
  362. package/skill/tools/node_modules/xtend/mutable.js +17 -0
  363. package/skill/tools/node_modules/xtend/package.json +55 -0
  364. package/skill/tools/node_modules/xtend/test.js +103 -0
  365. package/skill/tools/package-lock.json +172 -0
  366. package/skill/tools/package.json +9 -0
  367. package/skill/tools/transfer_core.js +414 -0
@@ -0,0 +1,1035 @@
1
+ 'use strict'
2
+
3
+ const assert = require('node:assert')
4
+ const { kDestroyed, kBodyUsed, kListeners, kBody } = require('./symbols')
5
+ const { IncomingMessage } = require('node:http')
6
+ const stream = require('node:stream')
7
+ const net = require('node:net')
8
+ const { stringify } = require('node:querystring')
9
+ const { EventEmitter: EE, addAbortListener: addAbortListenerNative } = require('node:events')
10
+ const timers = require('../util/timers')
11
+ const { InvalidArgumentError, ConnectTimeoutError } = require('./errors')
12
+ const { headerNameLowerCasedRecord } = require('./constants')
13
+ const { tree } = require('./tree')
14
+
15
+ class BodyAsyncIterable {
16
+ constructor (body) {
17
+ this[kBody] = body
18
+ this[kBodyUsed] = false
19
+ }
20
+
21
+ async * [Symbol.asyncIterator] () {
22
+ assert(!this[kBodyUsed], 'disturbed')
23
+ this[kBodyUsed] = true
24
+ yield * this[kBody]
25
+ }
26
+ }
27
+
28
+ function noop () {}
29
+
30
+ /**
31
+ * @param {*} body
32
+ * @returns {*}
33
+ */
34
+ function wrapRequestBody (body) {
35
+ if (isStream(body)) {
36
+ // TODO (fix): Provide some way for the user to cache the file to e.g. /tmp
37
+ // so that it can be dispatched again?
38
+ // TODO (fix): Do we need 100-expect support to provide a way to do this properly?
39
+ if (bodyLength(body) === 0) {
40
+ body
41
+ .on('data', function () {
42
+ assert(false)
43
+ })
44
+ }
45
+
46
+ if (typeof body.readableDidRead !== 'boolean') {
47
+ body[kBodyUsed] = false
48
+ EE.prototype.on.call(body, 'data', function () {
49
+ this[kBodyUsed] = true
50
+ })
51
+ }
52
+
53
+ return body
54
+ } else if (body && typeof body.pipeTo === 'function') {
55
+ // TODO (fix): We can't access ReadableStream internal state
56
+ // to determine whether or not it has been disturbed. This is just
57
+ // a workaround.
58
+ return new BodyAsyncIterable(body)
59
+ } else if (body && isFormDataLike(body)) {
60
+ return body
61
+ } else if (
62
+ body &&
63
+ typeof body !== 'string' &&
64
+ !ArrayBuffer.isView(body) &&
65
+ isIterable(body)
66
+ ) {
67
+ // TODO: Should we allow re-using iterable if !this.opts.idempotent
68
+ // or through some other flag?
69
+ return new BodyAsyncIterable(body)
70
+ } else {
71
+ return body
72
+ }
73
+ }
74
+
75
+ /**
76
+ * @param {*} obj
77
+ * @returns {obj is import('node:stream').Stream}
78
+ */
79
+ function isStream (obj) {
80
+ return obj && typeof obj === 'object' && typeof obj.pipe === 'function' && typeof obj.on === 'function'
81
+ }
82
+
83
+ /**
84
+ * @param {*} object
85
+ * @returns {object is Blob}
86
+ */
87
+ function isBlobLike (object) {
88
+ return object instanceof Blob
89
+ }
90
+
91
+ /**
92
+ * @param {string} url The path to check for query strings or fragments.
93
+ * @returns {boolean} Returns true if the path contains a query string or fragment.
94
+ */
95
+ function pathHasQueryOrFragment (url) {
96
+ return (
97
+ url.includes('?') ||
98
+ url.includes('#')
99
+ )
100
+ }
101
+
102
+ /**
103
+ * @param {string} url The URL to add the query params to
104
+ * @param {import('node:querystring').ParsedUrlQueryInput} queryParams The object to serialize into a URL query string
105
+ * @returns {string} The URL with the query params added
106
+ */
107
+ function serializePathWithQuery (url, queryParams) {
108
+ if (pathHasQueryOrFragment(url)) {
109
+ throw new Error('Query params cannot be passed when url already contains "?" or "#".')
110
+ }
111
+
112
+ const stringified = stringify(queryParams)
113
+
114
+ if (stringified) {
115
+ url += '?' + stringified
116
+ }
117
+
118
+ return url
119
+ }
120
+
121
+ /**
122
+ * @param {number|string|undefined} port
123
+ * @returns {boolean}
124
+ */
125
+ function isValidPort (port) {
126
+ const value = parseInt(port, 10)
127
+ return (
128
+ value === Number(port) &&
129
+ value >= 0 &&
130
+ value <= 65535
131
+ )
132
+ }
133
+
134
+ /**
135
+ * Check if the value is a valid http or https prefixed string.
136
+ *
137
+ * @param {string} value
138
+ * @returns {boolean}
139
+ */
140
+ function isHttpOrHttpsPrefixed (value) {
141
+ return (
142
+ value != null &&
143
+ value[0] === 'h' &&
144
+ value[1] === 't' &&
145
+ value[2] === 't' &&
146
+ value[3] === 'p' &&
147
+ (
148
+ value[4] === ':' ||
149
+ (
150
+ value[4] === 's' &&
151
+ value[5] === ':'
152
+ )
153
+ )
154
+ )
155
+ }
156
+
157
+ /**
158
+ * @param {string|URL|Record<string,string>} url
159
+ * @returns {URL}
160
+ */
161
+ function parseURL (url) {
162
+ if (typeof url === 'string') {
163
+ /**
164
+ * @type {URL}
165
+ */
166
+ url = new URL(url)
167
+
168
+ if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
169
+ throw new InvalidArgumentError('Invalid URL protocol: the URL must start with `http:` or `https:`.')
170
+ }
171
+
172
+ return url
173
+ }
174
+
175
+ if (!url || typeof url !== 'object') {
176
+ throw new InvalidArgumentError('Invalid URL: The URL argument must be a non-null object.')
177
+ }
178
+
179
+ if (!(url instanceof URL)) {
180
+ if (url.port != null && url.port !== '' && isValidPort(url.port) === false) {
181
+ throw new InvalidArgumentError('Invalid URL: port must be a valid integer or a string representation of an integer.')
182
+ }
183
+
184
+ if (url.path != null && typeof url.path !== 'string') {
185
+ throw new InvalidArgumentError('Invalid URL path: the path must be a string or null/undefined.')
186
+ }
187
+
188
+ if (url.pathname != null && typeof url.pathname !== 'string') {
189
+ throw new InvalidArgumentError('Invalid URL pathname: the pathname must be a string or null/undefined.')
190
+ }
191
+
192
+ if (url.hostname != null && typeof url.hostname !== 'string') {
193
+ throw new InvalidArgumentError('Invalid URL hostname: the hostname must be a string or null/undefined.')
194
+ }
195
+
196
+ if (url.origin != null && typeof url.origin !== 'string') {
197
+ throw new InvalidArgumentError('Invalid URL origin: the origin must be a string or null/undefined.')
198
+ }
199
+
200
+ if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
201
+ throw new InvalidArgumentError('Invalid URL protocol: the URL must start with `http:` or `https:`.')
202
+ }
203
+
204
+ const port = url.port != null
205
+ ? url.port
206
+ : (url.protocol === 'https:' ? 443 : 80)
207
+ let origin = url.origin != null
208
+ ? url.origin
209
+ : `${url.protocol || ''}//${url.hostname || ''}:${port}`
210
+ let path = url.path != null
211
+ ? url.path
212
+ : `${url.pathname || ''}${url.search || ''}`
213
+
214
+ if (origin[origin.length - 1] === '/') {
215
+ origin = origin.slice(0, origin.length - 1)
216
+ }
217
+
218
+ if (path && path[0] !== '/') {
219
+ path = `/${path}`
220
+ }
221
+ // new URL(path, origin) is unsafe when `path` contains an absolute URL
222
+ // From https://developer.mozilla.org/en-US/docs/Web/API/URL/URL:
223
+ // If first parameter is a relative URL, second param is required, and will be used as the base URL.
224
+ // If first parameter is an absolute URL, a given second param will be ignored.
225
+ return new URL(`${origin}${path}`)
226
+ }
227
+
228
+ if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
229
+ throw new InvalidArgumentError('Invalid URL protocol: the URL must start with `http:` or `https:`.')
230
+ }
231
+
232
+ return url
233
+ }
234
+
235
+ /**
236
+ * @param {string|URL|Record<string, string>} url
237
+ * @returns {URL}
238
+ */
239
+ function parseOrigin (url) {
240
+ url = parseURL(url)
241
+
242
+ if (url.pathname !== '/' || url.search || url.hash) {
243
+ throw new InvalidArgumentError('invalid url')
244
+ }
245
+
246
+ return url
247
+ }
248
+
249
+ /**
250
+ * @param {string} host
251
+ * @returns {string}
252
+ */
253
+ function getHostname (host) {
254
+ if (host[0] === '[') {
255
+ const idx = host.indexOf(']')
256
+
257
+ assert(idx !== -1)
258
+ return host.substring(1, idx)
259
+ }
260
+
261
+ const idx = host.indexOf(':')
262
+ if (idx === -1) return host
263
+
264
+ return host.substring(0, idx)
265
+ }
266
+
267
+ /**
268
+ * IP addresses are not valid server names per RFC6066
269
+ * Currently, the only server names supported are DNS hostnames
270
+ * @param {string|null} host
271
+ * @returns {string|null}
272
+ */
273
+ function getServerName (host) {
274
+ if (!host) {
275
+ return null
276
+ }
277
+
278
+ assert(typeof host === 'string')
279
+
280
+ const servername = getHostname(host)
281
+ if (net.isIP(servername)) {
282
+ return ''
283
+ }
284
+
285
+ return servername
286
+ }
287
+
288
+ /**
289
+ * @function
290
+ * @template T
291
+ * @param {T} obj
292
+ * @returns {T}
293
+ */
294
+ function deepClone (obj) {
295
+ return JSON.parse(JSON.stringify(obj))
296
+ }
297
+
298
+ /**
299
+ * @param {*} obj
300
+ * @returns {obj is AsyncIterable}
301
+ */
302
+ function isAsyncIterable (obj) {
303
+ return !!(obj != null && typeof obj[Symbol.asyncIterator] === 'function')
304
+ }
305
+
306
+ /**
307
+ * @param {*} obj
308
+ * @returns {obj is Iterable}
309
+ */
310
+ function isIterable (obj) {
311
+ return !!(obj != null && (typeof obj[Symbol.iterator] === 'function' || typeof obj[Symbol.asyncIterator] === 'function'))
312
+ }
313
+
314
+ /**
315
+ * Checks whether an object has a safe Symbol.iterator — i.e. one that is
316
+ * either own or inherited from a non-Object.prototype chain. This prevents
317
+ * prototype-pollution attacks from injecting a fake iterator on
318
+ * Object.prototype.
319
+ * @param {object} obj
320
+ * @returns {boolean}
321
+ */
322
+ function hasSafeIterator (obj) {
323
+ const prototype = Object.getPrototypeOf(obj)
324
+ const ownIterator = Object.hasOwn(obj, Symbol.iterator)
325
+ return ownIterator || (prototype != null && prototype !== Object.prototype && typeof obj[Symbol.iterator] === 'function')
326
+ }
327
+
328
+ /**
329
+ * @param {Blob|Buffer|import ('stream').Stream} body
330
+ * @returns {number|null}
331
+ */
332
+ function bodyLength (body) {
333
+ if (body == null) {
334
+ return 0
335
+ } else if (isStream(body)) {
336
+ const state = body._readableState
337
+ return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length)
338
+ ? state.length
339
+ : null
340
+ } else if (isBlobLike(body)) {
341
+ return body.size != null ? body.size : null
342
+ } else if (isBuffer(body)) {
343
+ return body.byteLength
344
+ }
345
+
346
+ return null
347
+ }
348
+
349
+ /**
350
+ * @param {import ('stream').Stream} body
351
+ * @returns {boolean}
352
+ */
353
+ function isDestroyed (body) {
354
+ return body && !!(body.destroyed || body[kDestroyed] || (stream.isDestroyed?.(body)))
355
+ }
356
+
357
+ /**
358
+ * @param {import ('stream').Stream} stream
359
+ * @param {Error} [err]
360
+ * @returns {void}
361
+ */
362
+ function destroy (stream, err) {
363
+ if (stream == null || !isStream(stream) || isDestroyed(stream)) {
364
+ return
365
+ }
366
+
367
+ if (typeof stream.destroy === 'function') {
368
+ if (Object.getPrototypeOf(stream).constructor === IncomingMessage) {
369
+ // See: https://github.com/nodejs/node/pull/38505/files
370
+ stream.socket = null
371
+ }
372
+
373
+ try {
374
+ stream.destroy(err)
375
+ } catch {
376
+ // stream.destroy may throw on managed sockets (e.g., http2).
377
+ // Silently ignore — the socket lifecycle is handled by the subsystem.
378
+ }
379
+ } else if (err) {
380
+ queueMicrotask(() => {
381
+ stream.emit('error', err)
382
+ })
383
+ }
384
+
385
+ if (stream.destroyed !== true) {
386
+ stream[kDestroyed] = true
387
+ }
388
+ }
389
+
390
+ const KEEPALIVE_TIMEOUT_EXPR = /(?:^|,)[\t ]*timeout=(\d+)/i
391
+ /**
392
+ * @param {string} val
393
+ * @returns {number | null}
394
+ */
395
+ function parseKeepAliveTimeout (val) {
396
+ const m = val.match(KEEPALIVE_TIMEOUT_EXPR)
397
+ return m ? parseInt(m[1], 10) * 1000 : null
398
+ }
399
+
400
+ /**
401
+ * Retrieves a header name and returns its lowercase value.
402
+ * @param {string | Buffer} value Header name
403
+ * @returns {string}
404
+ */
405
+ function headerNameToString (value) {
406
+ return typeof value === 'string'
407
+ ? headerNameLowerCasedRecord[value] ?? value.toLowerCase()
408
+ : tree.lookup(value) ?? value.toString('latin1').toLowerCase()
409
+ }
410
+
411
+ /**
412
+ * Receive the buffer as a string and return its lowercase value.
413
+ * @param {Buffer} value Header name
414
+ * @returns {string}
415
+ */
416
+ function bufferToLowerCasedHeaderName (value) {
417
+ return tree.lookup(value) ?? value.toString('latin1').toLowerCase()
418
+ }
419
+
420
+ /**
421
+ * Writes a header onto a plain object without going through the
422
+ * `Object.prototype` `__proto__` setter. Plain assignment there drops a string
423
+ * value and, when the value is an array, replaces the object's prototype
424
+ * instead of storing anything. Every other name is a normal assignment.
425
+ *
426
+ * @param {Record<string, string | string[]>} obj Accumulator to write onto
427
+ * @param {string} key Header name
428
+ * @param {string | string[]} value Header value
429
+ * @returns {void}
430
+ */
431
+ function setHeader (obj, key, value) {
432
+ if (key === '__proto__') {
433
+ Object.defineProperty(obj, key, {
434
+ value,
435
+ enumerable: true,
436
+ configurable: true,
437
+ writable: true
438
+ })
439
+ } else {
440
+ obj[key] = value
441
+ }
442
+ }
443
+
444
+ /**
445
+ * @param {(Buffer | string)[]} headers
446
+ * @param {Record<string, string | string[]>} [obj]
447
+ * @returns {Record<string, string | string[]>}
448
+ */
449
+ function parseHeaders (headers, obj) {
450
+ if (obj === undefined) obj = {}
451
+
452
+ for (let i = 0; i < headers.length; i += 2) {
453
+ const key = headerNameToString(headers[i])
454
+ let val = obj[key]
455
+
456
+ if (val !== undefined) {
457
+ if (!Object.hasOwn(obj, key)) {
458
+ const headersValue = typeof headers[i + 1] === 'string'
459
+ ? headers[i + 1]
460
+ : Array.isArray(headers[i + 1])
461
+ ? headers[i + 1].map(x => x.toString('latin1'))
462
+ : headers[i + 1].toString('latin1')
463
+
464
+ if (key === '__proto__') {
465
+ Object.defineProperty(obj, key, {
466
+ value: headersValue,
467
+ enumerable: true,
468
+ configurable: true,
469
+ writable: true
470
+ })
471
+ } else {
472
+ obj[key] = headersValue
473
+ }
474
+ } else {
475
+ if (typeof val === 'string') {
476
+ val = [val]
477
+ obj[key] = val
478
+ }
479
+ val.push(headers[i + 1].toString('latin1'))
480
+ }
481
+ } else {
482
+ const headersValue = typeof headers[i + 1] === 'string'
483
+ ? headers[i + 1]
484
+ : Array.isArray(headers[i + 1])
485
+ ? headers[i + 1].map(x => x.toString('latin1'))
486
+ : headers[i + 1].toString('latin1')
487
+
488
+ obj[key] = headersValue
489
+ }
490
+ }
491
+
492
+ return obj
493
+ }
494
+
495
+ /**
496
+ * @param {Buffer[] | string[] | Record<string, string | string[]> | null | undefined} headers
497
+ * @returns {string[]}
498
+ */
499
+ function parseRawHeaders (headers) {
500
+ if (headers == null) {
501
+ return []
502
+ }
503
+
504
+ if (!Array.isArray(headers)) {
505
+ const rawHeaders = []
506
+
507
+ for (const [name, value] of Object.entries(headers)) {
508
+ if (Array.isArray(value)) {
509
+ for (const entry of value) {
510
+ rawHeaders.push(name, `${entry}`)
511
+ }
512
+ } else {
513
+ rawHeaders.push(name, `${value}`)
514
+ }
515
+ }
516
+
517
+ return rawHeaders
518
+ }
519
+
520
+ const headersLength = headers.length
521
+ /**
522
+ * @type {string[]}
523
+ */
524
+ const ret = new Array(headersLength)
525
+
526
+ let key
527
+ let val
528
+
529
+ for (let n = 0; n < headersLength; n += 2) {
530
+ key = headers[n]
531
+ val = headers[n + 1]
532
+
533
+ typeof key !== 'string' && (key = key.toString())
534
+ typeof val !== 'string' && (val = val.toString('latin1'))
535
+
536
+ ret[n] = key
537
+ ret[n + 1] = val
538
+ }
539
+
540
+ return ret
541
+ }
542
+
543
+ /**
544
+ * @param {Record<string, string | string[]>} headers
545
+ * @returns {Buffer[]}
546
+ */
547
+ function toRawHeaders (headers) {
548
+ const rawHeaders = []
549
+
550
+ for (const [name, value] of Object.entries(headers)) {
551
+ if (Array.isArray(value)) {
552
+ for (const entry of value) {
553
+ rawHeaders.push(Buffer.from(name, 'latin1'), Buffer.from(`${entry}`, 'latin1'))
554
+ }
555
+ } else {
556
+ rawHeaders.push(Buffer.from(name, 'latin1'), Buffer.from(`${value}`, 'latin1'))
557
+ }
558
+ }
559
+
560
+ return rawHeaders
561
+ }
562
+
563
+ /**
564
+ * @param {string[]} headers
565
+ * @param {Buffer[]} headers
566
+ */
567
+ function encodeRawHeaders (headers) {
568
+ if (!Array.isArray(headers)) {
569
+ throw new TypeError('expected headers to be an array')
570
+ }
571
+ return headers.map(x => Buffer.from(x))
572
+ }
573
+
574
+ /**
575
+ * @param {*} buffer
576
+ * @returns {buffer is Buffer}
577
+ */
578
+ function isBuffer (buffer) {
579
+ // See, https://github.com/mcollina/undici/pull/319
580
+ return buffer instanceof Uint8Array || Buffer.isBuffer(buffer)
581
+ }
582
+
583
+ /**
584
+ * Asserts that the handler object is a request handler.
585
+ *
586
+ * @param {object} handler
587
+ * @param {string} method
588
+ * @param {string} [upgrade]
589
+ * @returns {asserts handler is import('../api/api-request').RequestHandler}
590
+ */
591
+ function assertRequestHandler (handler, method, upgrade) {
592
+ if (!handler || typeof handler !== 'object') {
593
+ throw new InvalidArgumentError('handler must be an object')
594
+ }
595
+
596
+ if (typeof handler.onRequestStart !== 'function') {
597
+ throw new InvalidArgumentError('invalid onRequestStart method')
598
+ }
599
+
600
+ if (typeof handler.onResponseError !== 'function') {
601
+ throw new InvalidArgumentError('invalid onResponseError method')
602
+ }
603
+
604
+ if (typeof handler.onBodySent !== 'function' && handler.onBodySent !== undefined) {
605
+ throw new InvalidArgumentError('invalid onBodySent method')
606
+ }
607
+
608
+ if (typeof handler.onRequestSent !== 'function' && handler.onRequestSent !== undefined) {
609
+ throw new InvalidArgumentError('invalid onRequestSent method')
610
+ }
611
+
612
+ if (upgrade || method === 'CONNECT') {
613
+ if (typeof handler.onRequestUpgrade !== 'function') {
614
+ throw new InvalidArgumentError('invalid onRequestUpgrade method')
615
+ }
616
+ } else {
617
+ if (typeof handler.onResponseStart !== 'function') {
618
+ throw new InvalidArgumentError('invalid onResponseStart method')
619
+ }
620
+
621
+ if (typeof handler.onResponseData !== 'function') {
622
+ throw new InvalidArgumentError('invalid onResponseData method')
623
+ }
624
+
625
+ if (typeof handler.onResponseEnd !== 'function') {
626
+ throw new InvalidArgumentError('invalid onResponseEnd method')
627
+ }
628
+ }
629
+ }
630
+
631
+ /**
632
+ * A body is disturbed if it has been read from and it cannot be re-used without
633
+ * losing state or data.
634
+ * @param {import('node:stream').Readable} body
635
+ * @returns {boolean}
636
+ */
637
+ function isDisturbed (body) {
638
+ // TODO (fix): Why is body[kBodyUsed] needed?
639
+ return !!(body && (stream.isDisturbed(body) || body[kBodyUsed]))
640
+ }
641
+
642
+ /**
643
+ * @typedef {object} SocketInfo
644
+ * @property {string} [localAddress]
645
+ * @property {number} [localPort]
646
+ * @property {string} [remoteAddress]
647
+ * @property {number} [remotePort]
648
+ * @property {string} [remoteFamily]
649
+ * @property {number} [timeout]
650
+ * @property {number} bytesWritten
651
+ * @property {number} bytesRead
652
+ */
653
+
654
+ /**
655
+ * @param {import('net').Socket} socket
656
+ * @returns {SocketInfo}
657
+ */
658
+ function getSocketInfo (socket) {
659
+ return {
660
+ localAddress: socket.localAddress,
661
+ localPort: socket.localPort,
662
+ remoteAddress: socket.remoteAddress,
663
+ remotePort: socket.remotePort,
664
+ remoteFamily: socket.remoteFamily,
665
+ timeout: socket.timeout,
666
+ bytesWritten: socket.bytesWritten,
667
+ bytesRead: socket.bytesRead
668
+ }
669
+ }
670
+
671
+ /**
672
+ * The object should be a FormData instance and contains all the required
673
+ * methods.
674
+ * @param {*} object
675
+ * @returns {object is FormData}
676
+ */
677
+ function isFormDataLike (object) {
678
+ return (
679
+ object &&
680
+ typeof object === 'object' &&
681
+ typeof object.append === 'function' &&
682
+ typeof object.delete === 'function' &&
683
+ typeof object.get === 'function' &&
684
+ typeof object.getAll === 'function' &&
685
+ typeof object.has === 'function' &&
686
+ typeof object.set === 'function' &&
687
+ object[Symbol.toStringTag] === 'FormData'
688
+ )
689
+ }
690
+
691
+ function addAbortListener (signal, listener) {
692
+ if (!signal || 'aborted' in signal) {
693
+ return addAbortListenerNative(signal, listener)[Symbol.dispose]
694
+ }
695
+
696
+ if (typeof signal.addEventListener === 'function') {
697
+ signal.addEventListener('abort', listener, { once: true })
698
+ return () => signal.removeEventListener('abort', listener)
699
+ }
700
+ signal.once('abort', listener)
701
+ return () => signal.removeListener('abort', listener)
702
+ }
703
+
704
+ const validTokenChars = new Uint8Array([
705
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15
706
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
707
+ 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 32-47 (!"#$%&'()*+,-./)
708
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48-63 (0-9:;<=>?)
709
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64-79 (@A-O)
710
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 80-95 (P-Z[\]^_)
711
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96-111 (`a-o)
712
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, // 112-127 (p-z{|}~)
713
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 128-143
714
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 144-159
715
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 160-175
716
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 176-191
717
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 192-207
718
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 208-223
719
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 224-239
720
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 240-255
721
+ ])
722
+
723
+ /**
724
+ * @see https://tools.ietf.org/html/rfc7230#section-3.2.6
725
+ * @param {number} c
726
+ * @returns {boolean}
727
+ */
728
+ function isTokenCharCode (c) {
729
+ return (validTokenChars[c] === 1)
730
+ }
731
+
732
+ const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/
733
+
734
+ /**
735
+ * @param {string} characters
736
+ * @returns {boolean}
737
+ */
738
+ function isValidHTTPToken (characters) {
739
+ if (characters.length >= 12) return tokenRegExp.test(characters)
740
+ if (characters.length === 0) return false
741
+
742
+ for (let i = 0; i < characters.length; i++) {
743
+ if (validTokenChars[characters.charCodeAt(i)] !== 1) {
744
+ return false
745
+ }
746
+ }
747
+ return true
748
+ }
749
+
750
+ // headerCharRegex have been lifted from
751
+ // https://github.com/nodejs/node/blob/main/lib/_http_common.js
752
+
753
+ /**
754
+ * Matches if val contains an invalid field-vchar
755
+ * field-value = *( field-content / obs-fold )
756
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
757
+ * field-vchar = VCHAR / obs-text
758
+ */
759
+ const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/
760
+
761
+ /**
762
+ * @param {string} characters
763
+ * @returns {boolean}
764
+ */
765
+ function isValidHeaderValue (characters) {
766
+ return !headerCharRegex.test(characters)
767
+ }
768
+
769
+ const rangeHeaderRegex = /^bytes (\d+)-(\d+)\/(\d+|\*)?$/
770
+
771
+ /**
772
+ * @typedef {object} RangeHeader
773
+ * @property {number} start
774
+ * @property {number | null} end
775
+ * @property {number | null} size
776
+ */
777
+
778
+ /**
779
+ * Parse accordingly to RFC 9110
780
+ * @see https://www.rfc-editor.org/rfc/rfc9110#field.content-range
781
+ * @param {string} [range]
782
+ * @returns {RangeHeader|null}
783
+ */
784
+ function parseRangeHeader (range) {
785
+ if (range == null || range === '') return { start: 0, end: null, size: null }
786
+ if (!range) return null
787
+
788
+ const m = rangeHeaderRegex.exec(range)
789
+ return m
790
+ ? {
791
+ start: parseInt(m[1]),
792
+ end: m[2] ? parseInt(m[2]) : null,
793
+ size: m[3] && m[3] !== '*' ? parseInt(m[3]) : null
794
+ }
795
+ : null
796
+ }
797
+
798
+ /**
799
+ * @template {import("events").EventEmitter} T
800
+ * @param {T} obj
801
+ * @param {string} name
802
+ * @param {(...args: any[]) => void} listener
803
+ * @returns {T}
804
+ */
805
+ function addListener (obj, name, listener) {
806
+ const listeners = (obj[kListeners] ??= [])
807
+ listeners.push([name, listener])
808
+ obj.on(name, listener)
809
+ return obj
810
+ }
811
+
812
+ /**
813
+ * @template {import("events").EventEmitter} T
814
+ * @param {T} obj
815
+ * @returns {T}
816
+ */
817
+ function removeAllListeners (obj) {
818
+ if (obj[kListeners] != null) {
819
+ for (const [name, listener] of obj[kListeners]) {
820
+ obj.removeListener(name, listener)
821
+ }
822
+ obj[kListeners] = null
823
+ }
824
+ return obj
825
+ }
826
+
827
+ /**
828
+ * @param {import ('../dispatcher/client')} client
829
+ * @param {import ('../core/request')} request
830
+ * @param {Error} err
831
+ */
832
+ function errorRequest (client, request, err) {
833
+ try {
834
+ request.onResponseError(err)
835
+ assert(request.aborted)
836
+ } catch (err) {
837
+ client.emit('error', err)
838
+ }
839
+ }
840
+
841
+ /**
842
+ * @param {WeakRef<net.Socket>} socketWeakRef
843
+ * @param {object} opts
844
+ * @param {number} opts.timeout
845
+ * @param {string} opts.hostname
846
+ * @param {number} opts.port
847
+ * @returns {() => void}
848
+ */
849
+ const setupConnectTimeout = process.platform === 'win32'
850
+ ? (socketWeakRef, opts) => {
851
+ if (!opts.timeout) {
852
+ return noop
853
+ }
854
+
855
+ let s1 = null
856
+ let s2 = null
857
+ const fastTimer = timers.setFastTimeout(() => {
858
+ // setImmediate is added to make sure that we prioritize socket error events over timeouts
859
+ s1 = setImmediate(() => {
860
+ // Windows needs an extra setImmediate probably due to implementation differences in the socket logic
861
+ s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts))
862
+ })
863
+ }, opts.timeout)
864
+ return () => {
865
+ timers.clearFastTimeout(fastTimer)
866
+ clearImmediate(s1)
867
+ clearImmediate(s2)
868
+ }
869
+ }
870
+ : (socketWeakRef, opts) => {
871
+ if (!opts.timeout) {
872
+ return noop
873
+ }
874
+
875
+ let s1 = null
876
+ const fastTimer = timers.setFastTimeout(() => {
877
+ // setImmediate is added to make sure that we prioritize socket error events over timeouts
878
+ s1 = setImmediate(() => {
879
+ onConnectTimeout(socketWeakRef.deref(), opts)
880
+ })
881
+ }, opts.timeout)
882
+ return () => {
883
+ timers.clearFastTimeout(fastTimer)
884
+ clearImmediate(s1)
885
+ }
886
+ }
887
+
888
+ /**
889
+ * @param {net.Socket} socket
890
+ * @param {object} opts
891
+ * @param {number} opts.timeout
892
+ * @param {string} opts.hostname
893
+ * @param {number} opts.port
894
+ */
895
+ function onConnectTimeout (socket, opts) {
896
+ // The socket could be already garbage collected
897
+ if (socket == null) {
898
+ return
899
+ }
900
+
901
+ let message = 'Connect Timeout Error'
902
+ if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) {
903
+ message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(', ')},`
904
+ } else {
905
+ message += ` (attempted address: ${opts.hostname}:${opts.port},`
906
+ }
907
+
908
+ message += ` timeout: ${opts.timeout}ms)`
909
+
910
+ destroy(socket, new ConnectTimeoutError(message))
911
+ }
912
+
913
+ let lastUrlString = null
914
+ let lastProtocol = null
915
+
916
+ /**
917
+ * @param {string} urlString
918
+ * @returns {string}
919
+ */
920
+ function getProtocolFromUrlString (urlString) {
921
+ // Requests are typically dispatched against the same origin over and over,
922
+ // so cache the last (urlString, protocol) pair to skip re-parsing.
923
+ if (urlString === lastUrlString) {
924
+ return lastProtocol
925
+ }
926
+
927
+ const protocol = getProtocolFromUrlStringSlow(urlString)
928
+ lastUrlString = urlString
929
+ lastProtocol = protocol
930
+
931
+ return protocol
932
+ }
933
+
934
+ /**
935
+ * @param {string} urlString
936
+ * @returns {string}
937
+ */
938
+ function getProtocolFromUrlStringSlow (urlString) {
939
+ if (
940
+ urlString[0] === 'h' &&
941
+ urlString[1] === 't' &&
942
+ urlString[2] === 't' &&
943
+ urlString[3] === 'p'
944
+ ) {
945
+ switch (urlString[4]) {
946
+ case ':':
947
+ return 'http:'
948
+ case 's':
949
+ if (urlString[5] === ':') {
950
+ return 'https:'
951
+ }
952
+ }
953
+ }
954
+ // fallback if none of the usual suspects
955
+ return urlString.slice(0, urlString.indexOf(':') + 1)
956
+ }
957
+
958
+ const kEnumerableProperty = {
959
+ __proto__: null,
960
+ enumerable: true
961
+ }
962
+
963
+ const normalizedMethodRecordsBase = {
964
+ delete: 'DELETE',
965
+ DELETE: 'DELETE',
966
+ get: 'GET',
967
+ GET: 'GET',
968
+ head: 'HEAD',
969
+ HEAD: 'HEAD',
970
+ options: 'OPTIONS',
971
+ OPTIONS: 'OPTIONS',
972
+ post: 'POST',
973
+ POST: 'POST',
974
+ put: 'PUT',
975
+ PUT: 'PUT',
976
+ query: 'QUERY',
977
+ QUERY: 'QUERY'
978
+ }
979
+
980
+ const normalizedMethodRecords = {
981
+ ...normalizedMethodRecordsBase,
982
+ patch: 'patch',
983
+ PATCH: 'PATCH'
984
+ }
985
+
986
+ // Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`.
987
+ Object.setPrototypeOf(normalizedMethodRecordsBase, null)
988
+ Object.setPrototypeOf(normalizedMethodRecords, null)
989
+
990
+ module.exports = {
991
+ kEnumerableProperty,
992
+ isDisturbed,
993
+ isBlobLike,
994
+ parseOrigin,
995
+ parseURL,
996
+ getServerName,
997
+ isStream,
998
+ isIterable,
999
+ hasSafeIterator,
1000
+ isAsyncIterable,
1001
+ isDestroyed,
1002
+ headerNameToString,
1003
+ bufferToLowerCasedHeaderName,
1004
+ addListener,
1005
+ removeAllListeners,
1006
+ errorRequest,
1007
+ parseRawHeaders,
1008
+ toRawHeaders,
1009
+ encodeRawHeaders,
1010
+ parseHeaders,
1011
+ setHeader,
1012
+ parseKeepAliveTimeout,
1013
+ destroy,
1014
+ bodyLength,
1015
+ deepClone,
1016
+ isBuffer,
1017
+ assertRequestHandler,
1018
+ getSocketInfo,
1019
+ isFormDataLike,
1020
+ pathHasQueryOrFragment,
1021
+ serializePathWithQuery,
1022
+ addAbortListener,
1023
+ isValidHTTPToken,
1024
+ isValidHeaderValue,
1025
+ isTokenCharCode,
1026
+ parseRangeHeader,
1027
+ normalizedMethodRecordsBase,
1028
+ normalizedMethodRecords,
1029
+ isValidPort,
1030
+ isHttpOrHttpsPrefixed,
1031
+ safeHTTPMethods: Object.freeze(['GET', 'HEAD', 'OPTIONS', 'TRACE']),
1032
+ wrapRequestBody,
1033
+ setupConnectTimeout,
1034
+ getProtocolFromUrlString
1035
+ }