netlify 13.3.5 → 21.5.1

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 (917) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +99 -157
  3. package/bin/run.js +66 -0
  4. package/dist/commands/api/api.d.ts +4 -0
  5. package/dist/commands/api/api.d.ts.map +1 -0
  6. package/dist/commands/api/api.js +42 -0
  7. package/dist/commands/api/api.js.map +1 -0
  8. package/dist/commands/api/index.d.ts +3 -0
  9. package/dist/commands/api/index.d.ts.map +1 -0
  10. package/dist/commands/api/index.js +14 -0
  11. package/dist/commands/api/index.js.map +1 -0
  12. package/dist/commands/base-command.d.ts +93 -0
  13. package/dist/commands/base-command.d.ts.map +1 -0
  14. package/dist/commands/base-command.js +623 -0
  15. package/dist/commands/base-command.js.map +1 -0
  16. package/dist/commands/blobs/blobs-delete.d.ts +5 -0
  17. package/dist/commands/blobs/blobs-delete.d.ts.map +1 -0
  18. package/dist/commands/blobs/blobs-delete.js +27 -0
  19. package/dist/commands/blobs/blobs-delete.js.map +1 -0
  20. package/dist/commands/blobs/blobs-get.d.ts +8 -0
  21. package/dist/commands/blobs/blobs-get.d.ts.map +1 -0
  22. package/dist/commands/blobs/blobs-get.js +32 -0
  23. package/dist/commands/blobs/blobs-get.js.map +1 -0
  24. package/dist/commands/blobs/blobs-list.d.ts +10 -0
  25. package/dist/commands/blobs/blobs-list.d.ts.map +1 -0
  26. package/dist/commands/blobs/blobs-list.js +39 -0
  27. package/dist/commands/blobs/blobs-list.js.map +1 -0
  28. package/dist/commands/blobs/blobs-set.d.ts +9 -0
  29. package/dist/commands/blobs/blobs-set.d.ts.map +1 -0
  30. package/dist/commands/blobs/blobs-set.js +48 -0
  31. package/dist/commands/blobs/blobs-set.js.map +1 -0
  32. package/dist/commands/blobs/blobs.d.ts +6 -0
  33. package/dist/commands/blobs/blobs.d.ts.map +1 -0
  34. package/dist/commands/blobs/blobs.js +82 -0
  35. package/dist/commands/blobs/blobs.js.map +1 -0
  36. package/dist/commands/build/build.d.ts +6 -0
  37. package/dist/commands/build/build.d.ts.map +1 -0
  38. package/dist/commands/build/build.js +39 -0
  39. package/dist/commands/build/build.js.map +1 -0
  40. package/dist/commands/build/index.d.ts +3 -0
  41. package/dist/commands/build/index.d.ts.map +1 -0
  42. package/dist/commands/build/index.js +25 -0
  43. package/dist/commands/build/index.js.map +1 -0
  44. package/dist/commands/clone/clone.d.ts +7 -0
  45. package/dist/commands/clone/clone.d.ts.map +1 -0
  46. package/dist/commands/clone/clone.js +64 -0
  47. package/dist/commands/clone/clone.js.map +1 -0
  48. package/dist/commands/clone/index.d.ts +3 -0
  49. package/dist/commands/clone/index.d.ts.map +1 -0
  50. package/dist/commands/clone/index.js +30 -0
  51. package/dist/commands/clone/index.js.map +1 -0
  52. package/dist/commands/clone/option_values.d.ts +6 -0
  53. package/dist/commands/clone/option_values.d.ts.map +1 -0
  54. package/dist/commands/clone/option_values.js +2 -0
  55. package/dist/commands/clone/option_values.js.map +1 -0
  56. package/dist/commands/completion/completion.d.ts +5 -0
  57. package/dist/commands/completion/completion.d.ts.map +1 -0
  58. package/dist/commands/completion/completion.js +67 -0
  59. package/dist/commands/completion/completion.js.map +1 -0
  60. package/dist/commands/completion/index.d.ts +3 -0
  61. package/dist/commands/completion/index.d.ts.map +1 -0
  62. package/dist/commands/completion/index.js +27 -0
  63. package/dist/commands/completion/index.js.map +1 -0
  64. package/dist/commands/deploy/deploy.d.ts +4 -0
  65. package/dist/commands/deploy/deploy.d.ts.map +1 -0
  66. package/dist/commands/deploy/deploy.js +687 -0
  67. package/dist/commands/deploy/deploy.js.map +1 -0
  68. package/dist/commands/deploy/index.d.ts +3 -0
  69. package/dist/commands/deploy/index.d.ts.map +1 -0
  70. package/dist/commands/deploy/index.js +132 -0
  71. package/dist/commands/deploy/index.js.map +1 -0
  72. package/dist/commands/deploy/option_values.d.ts +19 -0
  73. package/dist/commands/deploy/option_values.d.ts.map +1 -0
  74. package/dist/commands/deploy/option_values.js +3 -0
  75. package/dist/commands/deploy/option_values.js.map +1 -0
  76. package/dist/commands/dev/dev.d.ts +4 -0
  77. package/dist/commands/dev/dev.d.ts.map +1 -0
  78. package/dist/commands/dev/dev.js +176 -0
  79. package/dist/commands/dev/dev.js.map +1 -0
  80. package/dist/commands/dev/index.d.ts +3 -0
  81. package/dist/commands/dev/index.d.ts.map +1 -0
  82. package/dist/commands/dev/index.js +75 -0
  83. package/dist/commands/dev/index.js.map +1 -0
  84. package/dist/commands/dev-exec/dev-exec.d.ts +4 -0
  85. package/dist/commands/dev-exec/dev-exec.d.ts.map +1 -0
  86. package/dist/commands/dev-exec/dev-exec.js +14 -0
  87. package/dist/commands/dev-exec/dev-exec.js.map +1 -0
  88. package/dist/commands/dev-exec/index.d.ts +3 -0
  89. package/dist/commands/dev-exec/index.d.ts.map +1 -0
  90. package/dist/commands/dev-exec/index.js +17 -0
  91. package/dist/commands/dev-exec/index.js.map +1 -0
  92. package/dist/commands/env/env-clone.d.ts +4 -0
  93. package/dist/commands/env/env-clone.d.ts.map +1 -0
  94. package/dist/commands/env/env-clone.js +81 -0
  95. package/dist/commands/env/env-clone.js.map +1 -0
  96. package/dist/commands/env/env-get.d.ts +4 -0
  97. package/dist/commands/env/env-get.d.ts.map +1 -0
  98. package/dist/commands/env/env-get.js +29 -0
  99. package/dist/commands/env/env-get.js.map +1 -0
  100. package/dist/commands/env/env-import.d.ts +4 -0
  101. package/dist/commands/env/env-import.d.ts.map +1 -0
  102. package/dist/commands/env/env-import.js +78 -0
  103. package/dist/commands/env/env-import.js.map +1 -0
  104. package/dist/commands/env/env-list.d.ts +4 -0
  105. package/dist/commands/env/env-list.d.ts.map +1 -0
  106. package/dist/commands/env/env-list.js +85 -0
  107. package/dist/commands/env/env-list.js.map +1 -0
  108. package/dist/commands/env/env-set.d.ts +4 -0
  109. package/dist/commands/env/env-set.d.ts.map +1 -0
  110. package/dist/commands/env/env-set.js +118 -0
  111. package/dist/commands/env/env-set.js.map +1 -0
  112. package/dist/commands/env/env-unset.d.ts +4 -0
  113. package/dist/commands/env/env-unset.d.ts.map +1 -0
  114. package/dist/commands/env/env-unset.js +76 -0
  115. package/dist/commands/env/env-unset.js.map +1 -0
  116. package/dist/commands/env/env.d.ts +3 -0
  117. package/dist/commands/env/env.d.ts.map +1 -0
  118. package/dist/commands/env/env.js +139 -0
  119. package/dist/commands/env/env.js.map +1 -0
  120. package/dist/commands/env/index.d.ts +2 -0
  121. package/dist/commands/env/index.d.ts.map +1 -0
  122. package/dist/commands/env/index.js +2 -0
  123. package/dist/commands/env/index.js.map +1 -0
  124. package/dist/commands/functions/functions-build.d.ts +4 -0
  125. package/dist/commands/functions/functions-build.d.ts.map +1 -0
  126. package/dist/commands/functions/functions-build.js +26 -0
  127. package/dist/commands/functions/functions-build.js.map +1 -0
  128. package/dist/commands/functions/functions-create.d.ts +4 -0
  129. package/dist/commands/functions/functions-create.d.ts.map +1 -0
  130. package/dist/commands/functions/functions-create.js +629 -0
  131. package/dist/commands/functions/functions-create.js.map +1 -0
  132. package/dist/commands/functions/functions-invoke.d.ts +4 -0
  133. package/dist/commands/functions/functions-invoke.d.ts.map +1 -0
  134. package/dist/commands/functions/functions-invoke.js +210 -0
  135. package/dist/commands/functions/functions-invoke.js.map +1 -0
  136. package/dist/commands/functions/functions-list.d.ts +4 -0
  137. package/dist/commands/functions/functions-list.d.ts.map +1 -0
  138. package/dist/commands/functions/functions-list.js +38 -0
  139. package/dist/commands/functions/functions-list.js.map +1 -0
  140. package/dist/commands/functions/functions-serve.d.ts +4 -0
  141. package/dist/commands/functions/functions-serve.d.ts.map +1 -0
  142. package/dist/commands/functions/functions-serve.js +53 -0
  143. package/dist/commands/functions/functions-serve.js.map +1 -0
  144. package/dist/commands/functions/functions.d.ts +3 -0
  145. package/dist/commands/functions/functions.d.ts.map +1 -0
  146. package/dist/commands/functions/functions.js +108 -0
  147. package/dist/commands/functions/functions.js.map +1 -0
  148. package/dist/commands/functions/index.d.ts +2 -0
  149. package/dist/commands/functions/index.d.ts.map +1 -0
  150. package/dist/commands/functions/index.js +2 -0
  151. package/dist/commands/functions/index.js.map +1 -0
  152. package/dist/commands/index.d.ts +3 -0
  153. package/dist/commands/index.d.ts.map +1 -0
  154. package/dist/commands/index.js +3 -0
  155. package/dist/commands/index.js.map +1 -0
  156. package/dist/commands/init/index.d.ts +3 -0
  157. package/dist/commands/init/index.d.ts.map +1 -0
  158. package/dist/commands/init/index.js +17 -0
  159. package/dist/commands/init/index.js.map +1 -0
  160. package/dist/commands/init/init.d.ts +5 -0
  161. package/dist/commands/init/init.d.ts.map +1 -0
  162. package/dist/commands/init/init.js +192 -0
  163. package/dist/commands/init/init.js.map +1 -0
  164. package/dist/commands/link/index.d.ts +3 -0
  165. package/dist/commands/link/index.d.ts.map +1 -0
  166. package/dist/commands/link/index.js +25 -0
  167. package/dist/commands/link/index.js.map +1 -0
  168. package/dist/commands/link/link.d.ts +5 -0
  169. package/dist/commands/link/link.d.ts.map +1 -0
  170. package/dist/commands/link/link.js +305 -0
  171. package/dist/commands/link/link.js.map +1 -0
  172. package/dist/commands/link/option_values.d.ts +8 -0
  173. package/dist/commands/link/option_values.d.ts.map +1 -0
  174. package/dist/commands/link/option_values.js +3 -0
  175. package/dist/commands/link/option_values.js.map +1 -0
  176. package/dist/commands/login/index.d.ts +3 -0
  177. package/dist/commands/login/index.d.ts.map +1 -0
  178. package/dist/commands/login/index.js +17 -0
  179. package/dist/commands/login/index.js.map +1 -0
  180. package/dist/commands/login/login.d.ts +4 -0
  181. package/dist/commands/login/login.d.ts.map +1 -0
  182. package/dist/commands/login/login.js +30 -0
  183. package/dist/commands/login/login.js.map +1 -0
  184. package/dist/commands/logout/index.d.ts +3 -0
  185. package/dist/commands/logout/index.d.ts.map +1 -0
  186. package/dist/commands/logout/index.js +8 -0
  187. package/dist/commands/logout/index.js.map +1 -0
  188. package/dist/commands/logout/logout.d.ts +4 -0
  189. package/dist/commands/logout/logout.d.ts.map +1 -0
  190. package/dist/commands/logout/logout.js +23 -0
  191. package/dist/commands/logout/logout.js.map +1 -0
  192. package/dist/commands/logs/build.d.ts +8 -0
  193. package/dist/commands/logs/build.d.ts.map +1 -0
  194. package/dist/commands/logs/build.js +72 -0
  195. package/dist/commands/logs/build.js.map +1 -0
  196. package/dist/commands/logs/functions.d.ts +4 -0
  197. package/dist/commands/logs/functions.d.ts.map +1 -0
  198. package/dist/commands/logs/functions.js +79 -0
  199. package/dist/commands/logs/functions.js.map +1 -0
  200. package/dist/commands/logs/index.d.ts +5 -0
  201. package/dist/commands/logs/index.d.ts.map +1 -0
  202. package/dist/commands/logs/index.js +40 -0
  203. package/dist/commands/logs/index.js.map +1 -0
  204. package/dist/commands/logs/log-levels.d.ts +11 -0
  205. package/dist/commands/logs/log-levels.d.ts.map +1 -0
  206. package/dist/commands/logs/log-levels.js +12 -0
  207. package/dist/commands/logs/log-levels.js.map +1 -0
  208. package/dist/commands/main.d.ts +36 -0
  209. package/dist/commands/main.d.ts.map +1 -0
  210. package/dist/commands/main.js +225 -0
  211. package/dist/commands/main.js.map +1 -0
  212. package/dist/commands/open/index.d.ts +3 -0
  213. package/dist/commands/open/index.d.ts.map +1 -0
  214. package/dist/commands/open/index.js +32 -0
  215. package/dist/commands/open/index.js.map +1 -0
  216. package/dist/commands/open/open-admin.d.ts +3 -0
  217. package/dist/commands/open/open-admin.d.ts.map +1 -0
  218. package/dist/commands/open/open-admin.js +11 -0
  219. package/dist/commands/open/open-admin.js.map +1 -0
  220. package/dist/commands/open/open-site.d.ts +4 -0
  221. package/dist/commands/open/open-site.d.ts.map +1 -0
  222. package/dist/commands/open/open-site.js +12 -0
  223. package/dist/commands/open/open-site.js.map +1 -0
  224. package/dist/commands/open/open.d.ts +4 -0
  225. package/dist/commands/open/open.d.ts.map +1 -0
  226. package/dist/commands/open/open.js +14 -0
  227. package/dist/commands/open/open.js.map +1 -0
  228. package/dist/commands/recipes/common.d.ts +3 -0
  229. package/dist/commands/recipes/common.d.ts.map +1 -0
  230. package/dist/commands/recipes/common.js +26 -0
  231. package/dist/commands/recipes/common.js.map +1 -0
  232. package/dist/commands/recipes/index.d.ts +3 -0
  233. package/dist/commands/recipes/index.d.ts.map +1 -0
  234. package/dist/commands/recipes/index.js +21 -0
  235. package/dist/commands/recipes/index.js.map +1 -0
  236. package/dist/commands/recipes/recipes-list.d.ts +5 -0
  237. package/dist/commands/recipes/recipes-list.d.ts.map +1 -0
  238. package/dist/commands/recipes/recipes-list.js +15 -0
  239. package/dist/commands/recipes/recipes-list.js.map +1 -0
  240. package/dist/commands/recipes/recipes.d.ts +12 -0
  241. package/dist/commands/recipes/recipes.d.ts.map +1 -0
  242. package/dist/commands/recipes/recipes.js +53 -0
  243. package/dist/commands/recipes/recipes.js.map +1 -0
  244. package/dist/commands/serve/index.d.ts +3 -0
  245. package/dist/commands/serve/index.d.ts.map +1 -0
  246. package/dist/commands/serve/index.js +32 -0
  247. package/dist/commands/serve/index.js.map +1 -0
  248. package/dist/commands/serve/serve.d.ts +4 -0
  249. package/dist/commands/serve/serve.d.ts.map +1 -0
  250. package/dist/commands/serve/serve.js +149 -0
  251. package/dist/commands/serve/serve.js.map +1 -0
  252. package/dist/commands/sites/index.d.ts +2 -0
  253. package/dist/commands/sites/index.d.ts.map +1 -0
  254. package/dist/commands/sites/index.js +2 -0
  255. package/dist/commands/sites/index.js.map +1 -0
  256. package/dist/commands/sites/sites-create-template.d.ts +5 -0
  257. package/dist/commands/sites/sites-create-template.d.ts.map +1 -0
  258. package/dist/commands/sites/sites-create-template.js +235 -0
  259. package/dist/commands/sites/sites-create-template.js.map +1 -0
  260. package/dist/commands/sites/sites-create.d.ts +8 -0
  261. package/dist/commands/sites/sites-create.d.ts.map +1 -0
  262. package/dist/commands/sites/sites-create.js +122 -0
  263. package/dist/commands/sites/sites-create.js.map +1 -0
  264. package/dist/commands/sites/sites-delete.d.ts +4 -0
  265. package/dist/commands/sites/sites-delete.d.ts.map +1 -0
  266. package/dist/commands/sites/sites-delete.js +74 -0
  267. package/dist/commands/sites/sites-delete.js.map +1 -0
  268. package/dist/commands/sites/sites-list.d.ts +4 -0
  269. package/dist/commands/sites/sites-list.d.ts.map +1 -0
  270. package/dist/commands/sites/sites-list.js +59 -0
  271. package/dist/commands/sites/sites-list.js.map +1 -0
  272. package/dist/commands/sites/sites.d.ts +5 -0
  273. package/dist/commands/sites/sites.d.ts.map +1 -0
  274. package/dist/commands/sites/sites.js +77 -0
  275. package/dist/commands/sites/sites.js.map +1 -0
  276. package/dist/commands/status/index.d.ts +3 -0
  277. package/dist/commands/status/index.d.ts.map +1 -0
  278. package/dist/commands/status/index.js +21 -0
  279. package/dist/commands/status/index.js.map +1 -0
  280. package/dist/commands/status/status-hooks.d.ts +4 -0
  281. package/dist/commands/status/status-hooks.d.ts.map +1 -0
  282. package/dist/commands/status/status-hooks.js +30 -0
  283. package/dist/commands/status/status-hooks.js.map +1 -0
  284. package/dist/commands/status/status.d.ts +4 -0
  285. package/dist/commands/status/status.d.ts.map +1 -0
  286. package/dist/commands/status/status.js +73 -0
  287. package/dist/commands/status/status.js.map +1 -0
  288. package/dist/commands/switch/index.d.ts +3 -0
  289. package/dist/commands/switch/index.d.ts.map +1 -0
  290. package/dist/commands/switch/index.js +8 -0
  291. package/dist/commands/switch/index.js.map +1 -0
  292. package/dist/commands/switch/switch.d.ts +4 -0
  293. package/dist/commands/switch/switch.d.ts.map +1 -0
  294. package/dist/commands/switch/switch.js +31 -0
  295. package/dist/commands/switch/switch.js.map +1 -0
  296. package/dist/commands/unlink/index.d.ts +3 -0
  297. package/dist/commands/unlink/index.d.ts.map +1 -0
  298. package/dist/commands/unlink/index.js +15 -0
  299. package/dist/commands/unlink/index.js.map +1 -0
  300. package/dist/commands/unlink/unlink.d.ts +4 -0
  301. package/dist/commands/unlink/unlink.d.ts.map +1 -0
  302. package/dist/commands/unlink/unlink.js +22 -0
  303. package/dist/commands/unlink/unlink.js.map +1 -0
  304. package/dist/commands/watch/index.d.ts +3 -0
  305. package/dist/commands/watch/index.d.ts.map +1 -0
  306. package/dist/commands/watch/index.js +9 -0
  307. package/dist/commands/watch/index.js.map +1 -0
  308. package/dist/commands/watch/watch.d.ts +3 -0
  309. package/dist/commands/watch/watch.d.ts.map +1 -0
  310. package/dist/commands/watch/watch.js +91 -0
  311. package/dist/commands/watch/watch.js.map +1 -0
  312. package/dist/index.d.ts +2 -0
  313. package/dist/index.d.ts.map +1 -0
  314. package/dist/index.js +5 -0
  315. package/dist/index.js.map +1 -0
  316. package/dist/lib/account.d.ts +3 -0
  317. package/dist/lib/account.d.ts.map +1 -0
  318. package/dist/lib/account.js +3 -0
  319. package/dist/lib/account.js.map +1 -0
  320. package/dist/lib/api.d.ts +14 -0
  321. package/dist/lib/api.d.ts.map +1 -0
  322. package/dist/lib/api.js +27 -0
  323. package/dist/lib/api.js.map +1 -0
  324. package/dist/lib/blobs/blobs.d.ts +47 -0
  325. package/dist/lib/blobs/blobs.d.ts.map +1 -0
  326. package/dist/lib/blobs/blobs.js +82 -0
  327. package/dist/lib/blobs/blobs.js.map +1 -0
  328. package/dist/lib/build.d.ts +111 -0
  329. package/dist/lib/build.d.ts.map +1 -0
  330. package/dist/lib/build.js +75 -0
  331. package/dist/lib/build.js.map +1 -0
  332. package/dist/lib/completion/constants.d.ts +2 -0
  333. package/dist/lib/completion/constants.d.ts.map +1 -0
  334. package/dist/lib/completion/constants.js +3 -0
  335. package/dist/lib/completion/constants.js.map +1 -0
  336. package/dist/lib/completion/generate-autocompletion.d.ts +8 -0
  337. package/dist/lib/completion/generate-autocompletion.d.ts.map +1 -0
  338. package/dist/lib/completion/generate-autocompletion.js +42 -0
  339. package/dist/lib/completion/generate-autocompletion.js.map +1 -0
  340. package/dist/lib/completion/get-autocompletion.d.ts +13 -0
  341. package/dist/lib/completion/get-autocompletion.d.ts.map +1 -0
  342. package/dist/lib/completion/get-autocompletion.js +31 -0
  343. package/dist/lib/completion/get-autocompletion.js.map +1 -0
  344. package/dist/lib/completion/index.d.ts +2 -0
  345. package/dist/lib/completion/index.d.ts.map +1 -0
  346. package/dist/lib/completion/index.js +2 -0
  347. package/dist/lib/completion/index.js.map +1 -0
  348. package/dist/lib/completion/script.d.ts +3 -0
  349. package/dist/lib/completion/script.d.ts.map +1 -0
  350. package/dist/lib/completion/script.js +19 -0
  351. package/dist/lib/completion/script.js.map +1 -0
  352. package/dist/lib/edge-functions/bootstrap.d.ts +3 -0
  353. package/dist/lib/edge-functions/bootstrap.d.ts.map +1 -0
  354. package/dist/lib/edge-functions/bootstrap.js +20 -0
  355. package/dist/lib/edge-functions/bootstrap.js.map +1 -0
  356. package/dist/lib/edge-functions/consts.d.ts +11 -0
  357. package/dist/lib/edge-functions/consts.d.ts.map +1 -0
  358. package/dist/lib/edge-functions/consts.js +13 -0
  359. package/dist/lib/edge-functions/consts.js.map +1 -0
  360. package/dist/lib/edge-functions/deploy.d.ts +8 -0
  361. package/dist/lib/edge-functions/deploy.d.ts.map +1 -0
  362. package/dist/lib/edge-functions/deploy.js +34 -0
  363. package/dist/lib/edge-functions/deploy.js.map +1 -0
  364. package/dist/lib/edge-functions/editor-helper.d.ts +9 -0
  365. package/dist/lib/edge-functions/editor-helper.d.ts.map +1 -0
  366. package/dist/lib/edge-functions/editor-helper.js +31 -0
  367. package/dist/lib/edge-functions/editor-helper.js.map +1 -0
  368. package/dist/lib/edge-functions/headers.d.ts +35 -0
  369. package/dist/lib/edge-functions/headers.d.ts.map +1 -0
  370. package/dist/lib/edge-functions/headers.js +42 -0
  371. package/dist/lib/edge-functions/headers.js.map +1 -0
  372. package/dist/lib/edge-functions/proxy.d.ts +42 -0
  373. package/dist/lib/edge-functions/proxy.d.ts.map +1 -0
  374. package/dist/lib/edge-functions/proxy.js +151 -0
  375. package/dist/lib/edge-functions/proxy.js.map +1 -0
  376. package/dist/lib/edge-functions/registry.d.ts +103 -0
  377. package/dist/lib/edge-functions/registry.d.ts.map +1 -0
  378. package/dist/lib/edge-functions/registry.js +441 -0
  379. package/dist/lib/edge-functions/registry.js.map +1 -0
  380. package/dist/lib/exec-fetcher.d.ts +20 -0
  381. package/dist/lib/exec-fetcher.d.ts.map +1 -0
  382. package/dist/lib/exec-fetcher.js +104 -0
  383. package/dist/lib/exec-fetcher.js.map +1 -0
  384. package/dist/lib/fs.d.ts +10 -0
  385. package/dist/lib/fs.d.ts.map +1 -0
  386. package/dist/lib/fs.js +38 -0
  387. package/dist/lib/fs.js.map +1 -0
  388. package/dist/lib/functions/background.d.ts +5 -0
  389. package/dist/lib/functions/background.d.ts.map +1 -0
  390. package/dist/lib/functions/background.js +17 -0
  391. package/dist/lib/functions/background.js.map +1 -0
  392. package/dist/lib/functions/config.d.ts +23 -0
  393. package/dist/lib/functions/config.d.ts.map +1 -0
  394. package/dist/lib/functions/config.js +19 -0
  395. package/dist/lib/functions/config.js.map +1 -0
  396. package/dist/lib/functions/form-submissions-handler.d.ts +11 -0
  397. package/dist/lib/functions/form-submissions-handler.d.ts.map +1 -0
  398. package/dist/lib/functions/form-submissions-handler.js +154 -0
  399. package/dist/lib/functions/form-submissions-handler.js.map +1 -0
  400. package/dist/lib/functions/local-proxy.d.ts +9 -0
  401. package/dist/lib/functions/local-proxy.d.ts.map +1 -0
  402. package/dist/lib/functions/local-proxy.js +38 -0
  403. package/dist/lib/functions/local-proxy.js.map +1 -0
  404. package/dist/lib/functions/memoized-build.d.ts +11 -0
  405. package/dist/lib/functions/memoized-build.d.ts.map +1 -0
  406. package/dist/lib/functions/memoized-build.js +28 -0
  407. package/dist/lib/functions/memoized-build.js.map +1 -0
  408. package/dist/lib/functions/netlify-function.d.ts +91 -0
  409. package/dist/lib/functions/netlify-function.d.ts.map +1 -0
  410. package/dist/lib/functions/netlify-function.js +241 -0
  411. package/dist/lib/functions/netlify-function.js.map +1 -0
  412. package/dist/lib/functions/registry.d.ts +121 -0
  413. package/dist/lib/functions/registry.d.ts.map +1 -0
  414. package/dist/lib/functions/registry.js +437 -0
  415. package/dist/lib/functions/registry.js.map +1 -0
  416. package/dist/lib/functions/runtimes/go/index.d.ts +11 -0
  417. package/dist/lib/functions/runtimes/go/index.d.ts.map +1 -0
  418. package/dist/lib/functions/runtimes/go/index.js +65 -0
  419. package/dist/lib/functions/runtimes/go/index.js.map +1 -0
  420. package/dist/lib/functions/runtimes/index.d.ts +55 -0
  421. package/dist/lib/functions/runtimes/index.d.ts.map +1 -0
  422. package/dist/lib/functions/runtimes/index.js +10 -0
  423. package/dist/lib/functions/runtimes/index.js.map +1 -0
  424. package/dist/lib/functions/runtimes/js/builders/zisi.d.ts +35 -0
  425. package/dist/lib/functions/runtimes/js/builders/zisi.d.ts.map +1 -0
  426. package/dist/lib/functions/runtimes/js/builders/zisi.js +139 -0
  427. package/dist/lib/functions/runtimes/js/builders/zisi.js.map +1 -0
  428. package/dist/lib/functions/runtimes/js/constants.d.ts +2 -0
  429. package/dist/lib/functions/runtimes/js/constants.d.ts.map +1 -0
  430. package/dist/lib/functions/runtimes/js/constants.js +2 -0
  431. package/dist/lib/functions/runtimes/js/constants.js.map +1 -0
  432. package/dist/lib/functions/runtimes/js/index.d.ts +24 -0
  433. package/dist/lib/functions/runtimes/js/index.d.ts.map +1 -0
  434. package/dist/lib/functions/runtimes/js/index.js +95 -0
  435. package/dist/lib/functions/runtimes/js/index.js.map +1 -0
  436. package/dist/lib/functions/runtimes/js/worker.d.ts +8 -0
  437. package/dist/lib/functions/runtimes/js/worker.d.ts.map +1 -0
  438. package/dist/lib/functions/runtimes/js/worker.js +64 -0
  439. package/dist/lib/functions/runtimes/js/worker.js.map +1 -0
  440. package/dist/lib/functions/runtimes/rust/index.d.ts +11 -0
  441. package/dist/lib/functions/runtimes/rust/index.d.ts.map +1 -0
  442. package/dist/lib/functions/runtimes/rust/index.js +72 -0
  443. package/dist/lib/functions/runtimes/rust/index.js.map +1 -0
  444. package/dist/lib/functions/scheduled.d.ts +21 -0
  445. package/dist/lib/functions/scheduled.d.ts.map +1 -0
  446. package/dist/lib/functions/scheduled.js +77 -0
  447. package/dist/lib/functions/scheduled.js.map +1 -0
  448. package/dist/lib/functions/server.d.ts +38 -0
  449. package/dist/lib/functions/server.d.ts.map +1 -0
  450. package/dist/lib/functions/server.js +292 -0
  451. package/dist/lib/functions/server.js.map +1 -0
  452. package/dist/lib/functions/synchronous.d.ts +11 -0
  453. package/dist/lib/functions/synchronous.d.ts.map +1 -0
  454. package/dist/lib/functions/synchronous.js +132 -0
  455. package/dist/lib/functions/synchronous.js.map +1 -0
  456. package/dist/lib/functions/utils.d.ts +8 -0
  457. package/dist/lib/functions/utils.d.ts.map +1 -0
  458. package/dist/lib/functions/utils.js +42 -0
  459. package/dist/lib/functions/utils.js.map +1 -0
  460. package/dist/lib/geo-location.d.ts +31 -0
  461. package/dist/lib/geo-location.d.ts.map +1 -0
  462. package/dist/lib/geo-location.js +84 -0
  463. package/dist/lib/geo-location.js.map +1 -0
  464. package/dist/lib/http-agent.d.ts +22 -0
  465. package/dist/lib/http-agent.d.ts.map +1 -0
  466. package/dist/lib/http-agent.js +96 -0
  467. package/dist/lib/http-agent.js.map +1 -0
  468. package/dist/lib/images/proxy.d.ts +30 -0
  469. package/dist/lib/images/proxy.d.ts.map +1 -0
  470. package/dist/lib/images/proxy.js +117 -0
  471. package/dist/lib/images/proxy.js.map +1 -0
  472. package/dist/lib/log.d.ts +3 -0
  473. package/dist/lib/log.d.ts.map +1 -0
  474. package/dist/lib/log.js +16 -0
  475. package/dist/lib/log.js.map +1 -0
  476. package/dist/lib/path.d.ts +2 -0
  477. package/dist/lib/path.d.ts.map +1 -0
  478. package/dist/lib/path.js +2 -0
  479. package/dist/lib/path.js.map +1 -0
  480. package/dist/lib/render-error-template.d.ts +3 -0
  481. package/dist/lib/render-error-template.d.ts.map +1 -0
  482. package/dist/lib/render-error-template.js +21 -0
  483. package/dist/lib/render-error-template.js.map +1 -0
  484. package/dist/lib/settings.d.ts +14 -0
  485. package/dist/lib/settings.d.ts.map +1 -0
  486. package/dist/lib/settings.js +19 -0
  487. package/dist/lib/settings.js.map +1 -0
  488. package/dist/lib/spinner.d.ts +23 -0
  489. package/dist/lib/spinner.d.ts.map +1 -0
  490. package/dist/lib/spinner.js +30 -0
  491. package/dist/lib/spinner.js.map +1 -0
  492. package/dist/lib/string.d.ts +2 -0
  493. package/dist/lib/string.d.ts.map +1 -0
  494. package/dist/lib/string.js +6 -0
  495. package/dist/lib/string.js.map +1 -0
  496. package/dist/recipes/ai-context/context.d.ts +59 -0
  497. package/dist/recipes/ai-context/context.d.ts.map +1 -0
  498. package/dist/recipes/ai-context/context.js +195 -0
  499. package/dist/recipes/ai-context/context.js.map +1 -0
  500. package/dist/recipes/ai-context/index.d.ts +4 -0
  501. package/dist/recipes/ai-context/index.d.ts.map +1 -0
  502. package/dist/recipes/ai-context/index.js +132 -0
  503. package/dist/recipes/ai-context/index.js.map +1 -0
  504. package/dist/recipes/blobs-migrate/index.d.ts +9 -0
  505. package/dist/recipes/blobs-migrate/index.d.ts.map +1 -0
  506. package/dist/recipes/blobs-migrate/index.js +78 -0
  507. package/dist/recipes/blobs-migrate/index.js.map +1 -0
  508. package/dist/recipes/vscode/index.d.ts +12 -0
  509. package/dist/recipes/vscode/index.d.ts.map +1 -0
  510. package/dist/recipes/vscode/index.js +93 -0
  511. package/dist/recipes/vscode/index.js.map +1 -0
  512. package/dist/recipes/vscode/settings.d.ts +18 -0
  513. package/dist/recipes/vscode/settings.d.ts.map +1 -0
  514. package/dist/recipes/vscode/settings.js +61 -0
  515. package/dist/recipes/vscode/settings.js.map +1 -0
  516. package/dist/tsconfig.build.tsbuildinfo +1 -0
  517. package/dist/utils/addons/prepare.d.ts +13 -0
  518. package/dist/utils/addons/prepare.d.ts.map +1 -0
  519. package/dist/utils/addons/prepare.js +26 -0
  520. package/dist/utils/addons/prepare.js.map +1 -0
  521. package/dist/utils/build-info.d.ts +21 -0
  522. package/dist/utils/build-info.d.ts.map +1 -0
  523. package/dist/utils/build-info.js +122 -0
  524. package/dist/utils/build-info.js.map +1 -0
  525. package/dist/utils/cli-state.d.ts +13 -0
  526. package/dist/utils/cli-state.d.ts.map +1 -0
  527. package/dist/utils/cli-state.js +107 -0
  528. package/dist/utils/cli-state.js.map +1 -0
  529. package/dist/utils/command-helpers.d.ts +111 -0
  530. package/dist/utils/command-helpers.d.ts.map +1 -0
  531. package/dist/utils/command-helpers.js +270 -0
  532. package/dist/utils/command-helpers.js.map +1 -0
  533. package/dist/utils/copy-template-dir/copy-template-dir.d.ts +2 -0
  534. package/dist/utils/copy-template-dir/copy-template-dir.d.ts.map +1 -0
  535. package/dist/utils/copy-template-dir/copy-template-dir.js +66 -0
  536. package/dist/utils/copy-template-dir/copy-template-dir.js.map +1 -0
  537. package/dist/utils/create-deferred.d.ts +7 -0
  538. package/dist/utils/create-deferred.d.ts.map +1 -0
  539. package/dist/utils/create-deferred.js +11 -0
  540. package/dist/utils/create-deferred.js.map +1 -0
  541. package/dist/utils/create-stream-promise.d.ts +5 -0
  542. package/dist/utils/create-stream-promise.d.ts.map +1 -0
  543. package/dist/utils/create-stream-promise.js +46 -0
  544. package/dist/utils/create-stream-promise.js.map +1 -0
  545. package/dist/utils/deploy/constants.d.ts +10 -0
  546. package/dist/utils/deploy/constants.d.ts.map +1 -0
  547. package/dist/utils/deploy/constants.js +18 -0
  548. package/dist/utils/deploy/constants.js.map +1 -0
  549. package/dist/utils/deploy/deploy-site.d.ts +21 -0
  550. package/dist/utils/deploy/deploy-site.d.ts.map +1 -0
  551. package/dist/utils/deploy/deploy-site.js +156 -0
  552. package/dist/utils/deploy/deploy-site.js.map +1 -0
  553. package/dist/utils/deploy/hash-config.d.ts +10 -0
  554. package/dist/utils/deploy/hash-config.d.ts.map +1 -0
  555. package/dist/utils/deploy/hash-config.js +26 -0
  556. package/dist/utils/deploy/hash-config.js.map +1 -0
  557. package/dist/utils/deploy/hash-files.d.ts +15 -0
  558. package/dist/utils/deploy/hash-files.d.ts.map +1 -0
  559. package/dist/utils/deploy/hash-files.js +21 -0
  560. package/dist/utils/deploy/hash-files.js.map +1 -0
  561. package/dist/utils/deploy/hash-fns.d.ts +24 -0
  562. package/dist/utils/deploy/hash-fns.d.ts.map +1 -0
  563. package/dist/utils/deploy/hash-fns.js +141 -0
  564. package/dist/utils/deploy/hash-fns.js.map +1 -0
  565. package/dist/utils/deploy/hasher-segments.d.ts +15 -0
  566. package/dist/utils/deploy/hasher-segments.d.ts.map +1 -0
  567. package/dist/utils/deploy/hasher-segments.js +74 -0
  568. package/dist/utils/deploy/hasher-segments.js.map +1 -0
  569. package/dist/utils/deploy/status-cb.d.ts +7 -0
  570. package/dist/utils/deploy/status-cb.d.ts.map +1 -0
  571. package/dist/utils/deploy/status-cb.js +2 -0
  572. package/dist/utils/deploy/status-cb.js.map +1 -0
  573. package/dist/utils/deploy/upload-files.d.ts +7 -0
  574. package/dist/utils/deploy/upload-files.d.ts.map +1 -0
  575. package/dist/utils/deploy/upload-files.js +116 -0
  576. package/dist/utils/deploy/upload-files.js.map +1 -0
  577. package/dist/utils/deploy/util.d.ts +5 -0
  578. package/dist/utils/deploy/util.d.ts.map +1 -0
  579. package/dist/utils/deploy/util.js +93 -0
  580. package/dist/utils/deploy/util.js.map +1 -0
  581. package/dist/utils/detect-server-settings.d.ts +108 -0
  582. package/dist/utils/detect-server-settings.d.ts.map +1 -0
  583. package/dist/utils/detect-server-settings.js +252 -0
  584. package/dist/utils/detect-server-settings.js.map +1 -0
  585. package/dist/utils/dev-server-banner.d.ts +4 -0
  586. package/dist/utils/dev-server-banner.d.ts.map +1 -0
  587. package/dist/utils/dev-server-banner.js +15 -0
  588. package/dist/utils/dev-server-banner.js.map +1 -0
  589. package/dist/utils/dev.d.ts +72 -0
  590. package/dist/utils/dev.d.ts.map +1 -0
  591. package/dist/utils/dev.js +192 -0
  592. package/dist/utils/dev.js.map +1 -0
  593. package/dist/utils/dot-env.d.ts +26 -0
  594. package/dist/utils/dot-env.d.ts.map +1 -0
  595. package/dist/utils/dot-env.js +43 -0
  596. package/dist/utils/dot-env.js.map +1 -0
  597. package/dist/utils/env/index.d.ts +164 -0
  598. package/dist/utils/env/index.d.ts.map +1 -0
  599. package/dist/utils/env/index.js +254 -0
  600. package/dist/utils/env/index.js.map +1 -0
  601. package/dist/utils/execa.d.ts +4 -0
  602. package/dist/utils/execa.d.ts.map +1 -0
  603. package/dist/utils/execa.js +15 -0
  604. package/dist/utils/execa.js.map +1 -0
  605. package/dist/utils/feature-flags.d.ts +20 -0
  606. package/dist/utils/feature-flags.d.ts.map +1 -0
  607. package/dist/utils/feature-flags.js +21 -0
  608. package/dist/utils/feature-flags.js.map +1 -0
  609. package/dist/utils/framework-server.d.ts +13 -0
  610. package/dist/utils/framework-server.d.ts.map +1 -0
  611. package/dist/utils/framework-server.js +71 -0
  612. package/dist/utils/framework-server.js.map +1 -0
  613. package/dist/utils/frameworks-api.d.ts +20 -0
  614. package/dist/utils/frameworks-api.d.ts.map +1 -0
  615. package/dist/utils/frameworks-api.js +54 -0
  616. package/dist/utils/frameworks-api.js.map +1 -0
  617. package/dist/utils/functions/constants.d.ts +2 -0
  618. package/dist/utils/functions/constants.d.ts.map +1 -0
  619. package/dist/utils/functions/constants.js +2 -0
  620. package/dist/utils/functions/constants.js.map +1 -0
  621. package/dist/utils/functions/functions.d.ts +32 -0
  622. package/dist/utils/functions/functions.d.ts.map +1 -0
  623. package/dist/utils/functions/functions.js +39 -0
  624. package/dist/utils/functions/functions.js.map +1 -0
  625. package/dist/utils/functions/get-functions.d.ts +10 -0
  626. package/dist/utils/functions/get-functions.d.ts.map +1 -0
  627. package/dist/utils/functions/get-functions.js +35 -0
  628. package/dist/utils/functions/get-functions.js.map +1 -0
  629. package/dist/utils/functions/index.d.ts +4 -0
  630. package/dist/utils/functions/index.d.ts.map +1 -0
  631. package/dist/utils/functions/index.js +4 -0
  632. package/dist/utils/functions/index.js.map +1 -0
  633. package/dist/utils/get-cli-package-json.d.ts +4 -0
  634. package/dist/utils/get-cli-package-json.d.ts.map +1 -0
  635. package/dist/utils/get-cli-package-json.js +22 -0
  636. package/dist/utils/get-cli-package-json.js.map +1 -0
  637. package/dist/utils/get-global-config-store.d.ts +16 -0
  638. package/dist/utils/get-global-config-store.d.ts.map +1 -0
  639. package/dist/utils/get-global-config-store.js +87 -0
  640. package/dist/utils/get-global-config-store.js.map +1 -0
  641. package/dist/utils/get-repo-data.d.ts +17 -0
  642. package/dist/utils/get-repo-data.d.ts.map +1 -0
  643. package/dist/utils/get-repo-data.js +59 -0
  644. package/dist/utils/get-repo-data.js.map +1 -0
  645. package/dist/utils/get-site.d.ts +4 -0
  646. package/dist/utils/get-site.d.ts.map +1 -0
  647. package/dist/utils/get-site.js +21 -0
  648. package/dist/utils/get-site.js.map +1 -0
  649. package/dist/utils/gh-auth.d.ts +14 -0
  650. package/dist/utils/gh-auth.d.ts.map +1 -0
  651. package/dist/utils/gh-auth.js +92 -0
  652. package/dist/utils/gh-auth.js.map +1 -0
  653. package/dist/utils/gitignore.d.ts +2 -0
  654. package/dist/utils/gitignore.d.ts.map +1 -0
  655. package/dist/utils/gitignore.js +36 -0
  656. package/dist/utils/gitignore.js.map +1 -0
  657. package/dist/utils/headers.d.ts +15 -0
  658. package/dist/utils/headers.d.ts.map +1 -0
  659. package/dist/utils/headers.js +39 -0
  660. package/dist/utils/headers.js.map +1 -0
  661. package/dist/utils/hooks/requires-site-info.d.ts +7 -0
  662. package/dist/utils/hooks/requires-site-info.d.ts.map +1 -0
  663. package/dist/utils/hooks/requires-site-info.js +31 -0
  664. package/dist/utils/hooks/requires-site-info.js.map +1 -0
  665. package/dist/utils/init/config-github.d.ts +15 -0
  666. package/dist/utils/init/config-github.d.ts.map +1 -0
  667. package/dist/utils/init/config-github.js +214 -0
  668. package/dist/utils/init/config-github.js.map +1 -0
  669. package/dist/utils/init/config-manual.d.ts +8 -0
  670. package/dist/utils/init/config-manual.d.ts.map +1 -0
  671. package/dist/utils/init/config-manual.js +86 -0
  672. package/dist/utils/init/config-manual.js.map +1 -0
  673. package/dist/utils/init/config.d.ts +9 -0
  674. package/dist/utils/init/config.d.ts.map +1 -0
  675. package/dist/utils/init/config.js +29 -0
  676. package/dist/utils/init/config.js.map +1 -0
  677. package/dist/utils/init/plugins.d.ts +7 -0
  678. package/dist/utils/init/plugins.d.ts.map +1 -0
  679. package/dist/utils/init/plugins.js +4 -0
  680. package/dist/utils/init/plugins.js.map +1 -0
  681. package/dist/utils/init/utils.d.ts +154 -0
  682. package/dist/utils/init/utils.d.ts.map +1 -0
  683. package/dist/utils/init/utils.js +164 -0
  684. package/dist/utils/init/utils.js.map +1 -0
  685. package/dist/utils/live-tunnel.d.ts +9 -0
  686. package/dist/utils/live-tunnel.d.ts.map +1 -0
  687. package/dist/utils/live-tunnel.js +126 -0
  688. package/dist/utils/live-tunnel.js.map +1 -0
  689. package/dist/utils/multimap.d.ts +6 -0
  690. package/dist/utils/multimap.d.ts.map +1 -0
  691. package/dist/utils/multimap.js +10 -0
  692. package/dist/utils/multimap.js.map +1 -0
  693. package/dist/utils/nodejs-compile-cache.d.ts +24 -0
  694. package/dist/utils/nodejs-compile-cache.d.ts.map +1 -0
  695. package/dist/utils/nodejs-compile-cache.js +44 -0
  696. package/dist/utils/nodejs-compile-cache.js.map +1 -0
  697. package/dist/utils/normalize-repo-url.d.ts +11 -0
  698. package/dist/utils/normalize-repo-url.d.ts.map +1 -0
  699. package/dist/utils/normalize-repo-url.js +24 -0
  700. package/dist/utils/normalize-repo-url.js.map +1 -0
  701. package/dist/utils/open-browser.d.ts +7 -0
  702. package/dist/utils/open-browser.d.ts.map +1 -0
  703. package/dist/utils/open-browser.js +33 -0
  704. package/dist/utils/open-browser.js.map +1 -0
  705. package/dist/utils/parse-raw-flags.d.ts +3 -0
  706. package/dist/utils/parse-raw-flags.d.ts.map +1 -0
  707. package/dist/utils/parse-raw-flags.js +54 -0
  708. package/dist/utils/parse-raw-flags.js.map +1 -0
  709. package/dist/utils/prompts/blob-delete-prompts.d.ts +2 -0
  710. package/dist/utils/prompts/blob-delete-prompts.d.ts.map +1 -0
  711. package/dist/utils/prompts/blob-delete-prompts.js +12 -0
  712. package/dist/utils/prompts/blob-delete-prompts.js.map +1 -0
  713. package/dist/utils/prompts/blob-set-prompt.d.ts +2 -0
  714. package/dist/utils/prompts/blob-set-prompt.d.ts.map +1 -0
  715. package/dist/utils/prompts/blob-set-prompt.js +12 -0
  716. package/dist/utils/prompts/blob-set-prompt.js.map +1 -0
  717. package/dist/utils/prompts/confirm-prompt.d.ts +2 -0
  718. package/dist/utils/prompts/confirm-prompt.d.ts.map +1 -0
  719. package/dist/utils/prompts/confirm-prompt.js +21 -0
  720. package/dist/utils/prompts/confirm-prompt.js.map +1 -0
  721. package/dist/utils/prompts/env-clone-prompt.d.ts +11 -0
  722. package/dist/utils/prompts/env-clone-prompt.d.ts.map +1 -0
  723. package/dist/utils/prompts/env-clone-prompt.js +28 -0
  724. package/dist/utils/prompts/env-clone-prompt.js.map +1 -0
  725. package/dist/utils/prompts/env-set-prompts.d.ts +2 -0
  726. package/dist/utils/prompts/env-set-prompts.d.ts.map +1 -0
  727. package/dist/utils/prompts/env-set-prompts.js +12 -0
  728. package/dist/utils/prompts/env-set-prompts.js.map +1 -0
  729. package/dist/utils/prompts/env-unset-prompts.d.ts +8 -0
  730. package/dist/utils/prompts/env-unset-prompts.d.ts.map +1 -0
  731. package/dist/utils/prompts/env-unset-prompts.js +18 -0
  732. package/dist/utils/prompts/env-unset-prompts.js.map +1 -0
  733. package/dist/utils/prompts/prompt-messages.d.ts +25 -0
  734. package/dist/utils/prompts/prompt-messages.d.ts.map +1 -0
  735. package/dist/utils/prompts/prompt-messages.js +26 -0
  736. package/dist/utils/prompts/prompt-messages.js.map +1 -0
  737. package/dist/utils/proxy-server.d.ts +39 -0
  738. package/dist/utils/proxy-server.d.ts.map +1 -0
  739. package/dist/utils/proxy-server.js +50 -0
  740. package/dist/utils/proxy-server.js.map +1 -0
  741. package/dist/utils/proxy.d.ts +13 -0
  742. package/dist/utils/proxy.d.ts.map +1 -0
  743. package/dist/utils/proxy.js +782 -0
  744. package/dist/utils/proxy.js.map +1 -0
  745. package/dist/utils/read-repo-url.d.ts +12 -0
  746. package/dist/utils/read-repo-url.d.ts.map +1 -0
  747. package/dist/utils/read-repo-url.js +53 -0
  748. package/dist/utils/read-repo-url.js.map +1 -0
  749. package/dist/utils/redirects.d.ts +6 -0
  750. package/dist/utils/redirects.d.ts.map +1 -0
  751. package/dist/utils/redirects.js +59 -0
  752. package/dist/utils/redirects.js.map +1 -0
  753. package/dist/utils/request-id.d.ts +2 -0
  754. package/dist/utils/request-id.d.ts.map +1 -0
  755. package/dist/utils/request-id.js +3 -0
  756. package/dist/utils/request-id.js.map +1 -0
  757. package/dist/utils/rules-proxy.d.ts +16 -0
  758. package/dist/utils/rules-proxy.d.ts.map +1 -0
  759. package/dist/utils/rules-proxy.js +87 -0
  760. package/dist/utils/rules-proxy.js.map +1 -0
  761. package/dist/utils/run-build.d.ts +33 -0
  762. package/dist/utils/run-build.d.ts.map +1 -0
  763. package/dist/utils/run-build.js +126 -0
  764. package/dist/utils/run-build.js.map +1 -0
  765. package/dist/utils/run-git.d.ts +2 -0
  766. package/dist/utils/run-git.d.ts.map +1 -0
  767. package/dist/utils/run-git.js +7 -0
  768. package/dist/utils/run-git.js.map +1 -0
  769. package/dist/utils/run-program.d.ts +3 -0
  770. package/dist/utils/run-program.d.ts.map +1 -0
  771. package/dist/utils/run-program.js +13 -0
  772. package/dist/utils/run-program.js.map +1 -0
  773. package/dist/utils/scripted-commands.d.ts +3 -0
  774. package/dist/utils/scripted-commands.d.ts.map +1 -0
  775. package/dist/utils/scripted-commands.js +18 -0
  776. package/dist/utils/scripted-commands.js.map +1 -0
  777. package/dist/utils/shell.d.ts +8 -0
  778. package/dist/utils/shell.d.ts.map +1 -0
  779. package/dist/utils/shell.js +106 -0
  780. package/dist/utils/shell.js.map +1 -0
  781. package/dist/utils/sign-redirect.d.ts +7 -0
  782. package/dist/utils/sign-redirect.d.ts.map +1 -0
  783. package/dist/utils/sign-redirect.js +16 -0
  784. package/dist/utils/sign-redirect.js.map +1 -0
  785. package/dist/utils/sites/create-template.d.ts +14 -0
  786. package/dist/utils/sites/create-template.d.ts.map +1 -0
  787. package/dist/utils/sites/create-template.js +47 -0
  788. package/dist/utils/sites/create-template.js.map +1 -0
  789. package/dist/utils/sites/utils.d.ts +16 -0
  790. package/dist/utils/sites/utils.d.ts.map +1 -0
  791. package/dist/utils/sites/utils.js +63 -0
  792. package/dist/utils/sites/utils.js.map +1 -0
  793. package/dist/utils/static-server.d.ts +10 -0
  794. package/dist/utils/static-server.d.ts.map +1 -0
  795. package/dist/utils/static-server.js +36 -0
  796. package/dist/utils/static-server.js.map +1 -0
  797. package/dist/utils/telemetry/index.d.ts +3 -0
  798. package/dist/utils/telemetry/index.d.ts.map +1 -0
  799. package/dist/utils/telemetry/index.js +3 -0
  800. package/dist/utils/telemetry/index.js.map +1 -0
  801. package/dist/utils/telemetry/report-error.d.ts +10 -0
  802. package/dist/utils/telemetry/report-error.d.ts.map +1 -0
  803. package/dist/utils/telemetry/report-error.js +52 -0
  804. package/dist/utils/telemetry/report-error.js.map +1 -0
  805. package/dist/utils/telemetry/request.d.ts +2 -0
  806. package/dist/utils/telemetry/request.d.ts.map +1 -0
  807. package/dist/utils/telemetry/request.js +41 -0
  808. package/dist/utils/telemetry/request.js.map +1 -0
  809. package/dist/utils/telemetry/telemetry.d.ts +14 -0
  810. package/dist/utils/telemetry/telemetry.d.ts.map +1 -0
  811. package/dist/utils/telemetry/telemetry.js +94 -0
  812. package/dist/utils/telemetry/telemetry.js.map +1 -0
  813. package/dist/utils/telemetry/utils.d.ts +3 -0
  814. package/dist/utils/telemetry/utils.d.ts.map +1 -0
  815. package/dist/utils/telemetry/utils.js +7 -0
  816. package/dist/utils/telemetry/utils.js.map +1 -0
  817. package/dist/utils/telemetry/validation.d.ts +2 -0
  818. package/dist/utils/telemetry/validation.d.ts.map +1 -0
  819. package/dist/utils/telemetry/validation.js +63 -0
  820. package/dist/utils/telemetry/validation.js.map +1 -0
  821. package/dist/utils/temporary-file.d.ts +7 -0
  822. package/dist/utils/temporary-file.d.ts.map +1 -0
  823. package/dist/utils/temporary-file.js +16 -0
  824. package/dist/utils/temporary-file.js.map +1 -0
  825. package/dist/utils/types.d.ts +205 -0
  826. package/dist/utils/types.d.ts.map +1 -0
  827. package/dist/utils/types.js +2 -0
  828. package/dist/utils/types.js.map +1 -0
  829. package/dist/utils/validation.d.ts +6 -0
  830. package/dist/utils/validation.d.ts.map +1 -0
  831. package/dist/utils/validation.js +17 -0
  832. package/dist/utils/validation.js.map +1 -0
  833. package/dist/utils/websockets/index.d.ts +3 -0
  834. package/dist/utils/websockets/index.d.ts.map +1 -0
  835. package/dist/utils/websockets/index.js +3 -0
  836. package/dist/utils/websockets/index.js.map +1 -0
  837. package/functions-templates/go/hello-world/.netlify-function-template.mjs +6 -0
  838. package/functions-templates/go/hello-world/go.mod +5 -0
  839. package/functions-templates/go/hello-world/go.sum +22 -0
  840. package/functions-templates/go/hello-world/main.go +24 -0
  841. package/functions-templates/javascript/hello/.netlify-function-template.mjs +5 -0
  842. package/functions-templates/javascript/hello/{{name}}.js +4 -0
  843. package/functions-templates/javascript/hello-world/.netlify-function-template.mjs +6 -0
  844. package/functions-templates/javascript/hello-world/{{name}}.mjs +13 -0
  845. package/functions-templates/javascript/image-external/.netlify-function-template.mjs +5 -0
  846. package/functions-templates/javascript/image-external/{{name}}.js +12 -0
  847. package/functions-templates/javascript/localized-content/.netlify-function-template.mjs +5 -0
  848. package/functions-templates/javascript/localized-content/{{name}}.js +15 -0
  849. package/functions-templates/javascript/scheduled-function/.netlify-function-template.mjs +6 -0
  850. package/functions-templates/javascript/scheduled-function/package.json +20 -0
  851. package/functions-templates/javascript/scheduled-function/{{name}}.mjs +11 -0
  852. package/functions-templates/javascript/set-cookies/.netlify-function-template.mjs +5 -0
  853. package/functions-templates/javascript/set-cookies/{{name}}.js +28 -0
  854. package/functions-templates/javascript/set-req-header/.netlify-function-template.mjs +5 -0
  855. package/functions-templates/javascript/set-req-header/{{name}}.js +3 -0
  856. package/functions-templates/javascript/set-res-header/.netlify-function-template.mjs +5 -0
  857. package/functions-templates/javascript/set-res-header/{{name}}.js +5 -0
  858. package/functions-templates/javascript/transform-response/.netlify-function-template.mjs +5 -0
  859. package/functions-templates/javascript/transform-response/{{name}}.js +12 -0
  860. package/functions-templates/rust/hello-world/.netlify-function-template.mjs +6 -0
  861. package/functions-templates/rust/hello-world/Cargo.lock +1149 -0
  862. package/functions-templates/rust/hello-world/Cargo.toml +14 -0
  863. package/functions-templates/rust/hello-world/src/main.rs +29 -0
  864. package/functions-templates/typescript/abtest/.netlify-function-template.mjs +5 -0
  865. package/functions-templates/typescript/abtest/{{name}}.ts +31 -0
  866. package/functions-templates/typescript/geolocation/.netlify-function-template.mjs +5 -0
  867. package/functions-templates/typescript/geolocation/{{name}}.ts +23 -0
  868. package/functions-templates/typescript/hello-world/.netlify-function-template.mjs +6 -0
  869. package/functions-templates/typescript/hello-world/package-lock.json +95 -0
  870. package/functions-templates/typescript/hello-world/package.json +21 -0
  871. package/functions-templates/typescript/hello-world/{{name}}.mts +14 -0
  872. package/functions-templates/typescript/json/.netlify-function-template.mjs +5 -0
  873. package/functions-templates/typescript/json/{{name}}.ts +4 -0
  874. package/functions-templates/typescript/log/.netlify-function-template.mjs +5 -0
  875. package/functions-templates/typescript/log/{{name}}.ts +9 -0
  876. package/functions-templates/typescript/scheduled-function/.netlify-function-template.mjs +6 -0
  877. package/functions-templates/typescript/scheduled-function/package.json +22 -0
  878. package/functions-templates/typescript/scheduled-function/{{name}}.mts +11 -0
  879. package/functions-templates/typescript/set-cookies/.netlify-function-template.mjs +5 -0
  880. package/functions-templates/typescript/set-cookies/{{name}}.ts +29 -0
  881. package/functions-templates/typescript/set-req-header/.netlify-function-template.mjs +5 -0
  882. package/functions-templates/typescript/set-req-header/{{name}}.ts +5 -0
  883. package/functions-templates/typescript/set-res-header/.netlify-function-template.mjs +5 -0
  884. package/functions-templates/typescript/set-res-header/{{name}}.ts +7 -0
  885. package/functions-templates/typescript/transform-response/.netlify-function-template.mjs +5 -0
  886. package/functions-templates/typescript/transform-response/{{name}}.ts +13 -0
  887. package/npm-shrinkwrap.json +23183 -0
  888. package/package.json +147 -53
  889. package/scripts/bash.sh +15 -0
  890. package/scripts/fish.sh +8 -0
  891. package/scripts/netlifyPackage.js +68 -0
  892. package/scripts/path.ps1 +35 -0
  893. package/scripts/postinstall.js +82 -0
  894. package/scripts/prepublishOnly.js +29 -0
  895. package/scripts/zsh.sh +3 -0
  896. package/lib/index.d.ts +0 -54
  897. package/lib/index.js +0 -78
  898. package/lib/methods/body.d.ts +0 -1
  899. package/lib/methods/body.js +0 -25
  900. package/lib/methods/index.d.ts +0 -6
  901. package/lib/methods/index.js +0 -84
  902. package/lib/methods/params.d.ts +0 -1
  903. package/lib/methods/params.js +0 -14
  904. package/lib/methods/response.d.ts +0 -2
  905. package/lib/methods/response.js +0 -44
  906. package/lib/methods/retry.d.ts +0 -7
  907. package/lib/methods/retry.js +0 -40
  908. package/lib/methods/url.d.ts +0 -4
  909. package/lib/methods/url.js +0 -24
  910. package/lib/omit.d.ts +0 -1
  911. package/lib/omit.js +0 -7
  912. package/lib/open_api.d.ts +0 -1
  913. package/lib/open_api.js +0 -5
  914. package/lib/operations.d.ts +0 -1
  915. package/lib/operations.js +0 -19
  916. package/lib/types.d.ts +0 -129
  917. package/lib/types.js +0 -1
@@ -0,0 +1,782 @@
1
+ import { Buffer } from 'buffer';
2
+ import { once } from 'events';
3
+ import { readFile } from 'fs/promises';
4
+ import http from 'http';
5
+ import https from 'https';
6
+ import { isIPv6 } from 'net';
7
+ import { Socket } from 'node:net';
8
+ import { Readable } from 'node:stream';
9
+ import path from 'path';
10
+ import process from 'process';
11
+ import url from 'url';
12
+ import util from 'util';
13
+ import zlib from 'zlib';
14
+ import contentType from 'content-type';
15
+ import cookie from 'cookie';
16
+ import { getProperty } from 'dot-prop';
17
+ import generateETag from 'etag';
18
+ import getAvailablePort from 'get-port';
19
+ import httpProxy from 'http-proxy';
20
+ import { createProxyMiddleware } from 'http-proxy-middleware';
21
+ import { jwtDecode } from 'jwt-decode';
22
+ import { locatePath } from 'locate-path';
23
+ import throttle from 'lodash/throttle.js';
24
+ import pFilter from 'p-filter';
25
+ import { handleProxyRequest, initializeProxy as initializeEdgeFunctionsProxy, isEdgeFunctionsRequest, } from '../lib/edge-functions/proxy.js';
26
+ import { fileExistsAsync, isFileAsync } from '../lib/fs.js';
27
+ import { getFormHandler } from '../lib/functions/form-submissions-handler.js';
28
+ import { DEFAULT_FUNCTION_URL_EXPRESSION } from '../lib/functions/registry.js';
29
+ import { initializeProxy as initializeImageProxy, isImageRequest } from '../lib/images/proxy.js';
30
+ import renderErrorTemplate from '../lib/render-error-template.js';
31
+ import { NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, log } from './command-helpers.js';
32
+ import createStreamPromise from './create-stream-promise.js';
33
+ import { NFFunctionName, NFFunctionRoute, NFRequestID, headersForPath, parseHeaders } from './headers.js';
34
+ import { generateRequestID } from './request-id.js';
35
+ import { createRewriter, onChanges } from './rules-proxy.js';
36
+ import { signRedirect } from './sign-redirect.js';
37
+ const gunzip = util.promisify(zlib.gunzip);
38
+ const gzip = util.promisify(zlib.gzip);
39
+ const brotliDecompress = util.promisify(zlib.brotliDecompress);
40
+ const brotliCompress = util.promisify(zlib.brotliCompress);
41
+ const deflate = util.promisify(zlib.deflate);
42
+ const inflate = util.promisify(zlib.inflate);
43
+ const shouldGenerateETag = Symbol('Internal: response should generate ETag');
44
+ const decompressResponseBody = async function (body, contentEncoding = '') {
45
+ switch (contentEncoding) {
46
+ case 'gzip':
47
+ return await gunzip(body);
48
+ case 'br':
49
+ return await brotliDecompress(body);
50
+ case 'deflate':
51
+ return await inflate(body);
52
+ default:
53
+ return body;
54
+ }
55
+ };
56
+ const compressResponseBody = async function (body, contentEncoding = '') {
57
+ switch (contentEncoding) {
58
+ case 'gzip':
59
+ return await gzip(body);
60
+ case 'br':
61
+ return await brotliCompress(body);
62
+ case 'deflate':
63
+ return await deflate(body);
64
+ default:
65
+ return Buffer.from(body, 'utf8');
66
+ }
67
+ };
68
+ const injectHtml = async function (responseBody, proxyRes, htmlInjections) {
69
+ const decompressedBody = await decompressResponseBody(responseBody, proxyRes.headers['content-encoding']);
70
+ const bodyWithInjections = (htmlInjections ?? []).reduce((accum, htmlInjection) => {
71
+ if (!htmlInjection.html || typeof htmlInjection.html !== 'string') {
72
+ return accum;
73
+ }
74
+ const location = htmlInjection.location ?? 'before_closing_head_tag';
75
+ if (location === 'before_closing_head_tag') {
76
+ accum = accum.replace('</head>', `${htmlInjection.html}</head>`);
77
+ }
78
+ else if (location === 'before_closing_body_tag') {
79
+ accum = accum.replace('</body>', `${htmlInjection.html}</body>`);
80
+ }
81
+ return accum;
82
+ }, decompressedBody.toString());
83
+ return await compressResponseBody(bodyWithInjections, proxyRes.headers['content-encoding']);
84
+ };
85
+ const formatEdgeFunctionError = (errorBuffer, acceptsHtml) => {
86
+ const { error: { message, name, stack }, } = JSON.parse(errorBuffer.toString());
87
+ if (!acceptsHtml) {
88
+ return `${name}: ${message}\n ${stack}`;
89
+ }
90
+ return JSON.stringify({
91
+ errorType: name,
92
+ errorMessage: message,
93
+ trace: stack.split('\\n'),
94
+ });
95
+ };
96
+ function isInternal(url) {
97
+ return url?.startsWith('/.netlify/') ?? false;
98
+ }
99
+ function isFunction(functionsPort, url) {
100
+ return functionsPort && url.match(DEFAULT_FUNCTION_URL_EXPRESSION);
101
+ }
102
+ function getAddonUrl(addonsUrls, req) {
103
+ const matches = req.url?.match(/^\/.netlify\/([^/]+)(\/.*)/);
104
+ const addonUrl = matches && addonsUrls[matches[1]];
105
+ return addonUrl ? `${addonUrl}${matches[2]}` : null;
106
+ }
107
+ const getStatic = async function (pathname, publicFolder) {
108
+ const alternatives = [pathname, ...alternativePathsFor(pathname)].map((filePath) => path.resolve(publicFolder, filePath.slice(1)));
109
+ const file = await locatePath(alternatives);
110
+ if (file === undefined) {
111
+ return false;
112
+ }
113
+ return `/${path.relative(publicFolder, file)}`;
114
+ };
115
+ const isEndpointExists = async function (endpoint, origin) {
116
+ const url = new URL(endpoint, origin);
117
+ try {
118
+ const res = await fetch(url, { method: 'HEAD' });
119
+ return res.status !== 404;
120
+ }
121
+ catch (e) {
122
+ return false;
123
+ }
124
+ };
125
+ const isExternal = function (match) {
126
+ return 'to' in match && /^https?:\/\//.exec(match.to) != null;
127
+ };
128
+ const stripOrigin = function ({ hash, pathname, search }) {
129
+ return `${pathname}${search}${hash}`;
130
+ };
131
+ const proxyToExternalUrl = function ({ dest, destURL, req, res, }) {
132
+ const handler = createProxyMiddleware({
133
+ target: dest.origin,
134
+ changeOrigin: true,
135
+ pathRewrite: () => destURL,
136
+ // hide logging
137
+ logLevel: 'warn',
138
+ ...(Buffer.isBuffer(req.originalBody) && { buffer: Readable.from(req.originalBody) }),
139
+ });
140
+ // @ts-expect-error TS(2345) FIXME: Argument of type 'Request' is not assignable to parameter of type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.
141
+ handler(req, res, () => { });
142
+ };
143
+ // @ts-expect-error TS(7031) FIXME: Binding element 'addonUrl' implicitly has an 'any'... Remove this comment to see the full error message
144
+ const handleAddonUrl = function ({ addonUrl, req, res }) {
145
+ const dest = new URL(addonUrl);
146
+ const destURL = stripOrigin(dest);
147
+ proxyToExternalUrl({ req, res, dest, destURL });
148
+ };
149
+ const isRedirect = function (match) {
150
+ return 'status' in match && match.status != null && match.status >= 300 && match.status <= 400;
151
+ };
152
+ const render404 = async function (publicFolder) {
153
+ const maybe404Page = path.resolve(publicFolder, '404.html');
154
+ try {
155
+ const isFile = await isFileAsync(maybe404Page);
156
+ if (isFile)
157
+ return await readFile(maybe404Page, 'utf-8');
158
+ }
159
+ catch (error) {
160
+ console.warn(NETLIFYDEVWARN, 'Error while serving 404.html file', error instanceof Error ? error.message : error?.toString());
161
+ }
162
+ return 'Not Found';
163
+ };
164
+ // Used as an optimization to avoid dual lookups for missing assets
165
+ const assetExtensionRegExp = /\.(html?|png|jpg|js|css|svg|gif|ico|woff|woff2)$/;
166
+ // @ts-expect-error TS(7006) FIXME: Parameter 'url' implicitly has an 'any' type.
167
+ const alternativePathsFor = function (url) {
168
+ if (isFunction(true, url)) {
169
+ return [];
170
+ }
171
+ const paths = [];
172
+ if (url[url.length - 1] === '/') {
173
+ const end = url.length - 1;
174
+ if (url !== '/') {
175
+ paths.push(`${url.slice(0, end)}.html`, `${url.slice(0, end)}.htm`);
176
+ }
177
+ paths.push(`${url}index.html`, `${url}index.htm`);
178
+ }
179
+ else if (!assetExtensionRegExp.test(url)) {
180
+ paths.push(`${url}.html`, `${url}.htm`, `${url}/index.html`, `${url}/index.htm`);
181
+ }
182
+ return paths;
183
+ };
184
+ const notifyActivity = throttle((api, siteId, devServerId) => {
185
+ // @ts-expect-error(serhalp) -- It looks like the generated API types don't include "internal" methods
186
+ // (https://github.com/netlify/open-api/blob/66813d46e47f207443b7aebce2c22c4a4c8ca867/swagger.yml#L2642). Fix?
187
+ api.markDevServerActivity({ siteId, devServerId }).catch((error) => {
188
+ console.error(`${NETLIFYDEVWARN} Failed to notify activity`, error);
189
+ });
190
+ }, 30 * 1000);
191
+ const serveRedirect = async function ({ env, functionsRegistry, imageProxy, match, options, proxy, req, res, siteInfo, }) {
192
+ if (!match)
193
+ return proxy.web(req, res, options);
194
+ options = options || req.proxyOptions || {};
195
+ options.match = null;
196
+ if (match.force404) {
197
+ res.writeHead(404);
198
+ res.end(await render404(options.publicFolder));
199
+ return;
200
+ }
201
+ if (match.proxyHeaders && Object.keys(match.proxyHeaders).length >= 0) {
202
+ Object.entries(match.proxyHeaders).forEach(([key, value]) => {
203
+ req.headers[key] = value;
204
+ });
205
+ }
206
+ if (match.signingSecret) {
207
+ const signingSecretVar = env[match.signingSecret];
208
+ if (signingSecretVar) {
209
+ req.headers['x-nf-sign'] = signRedirect({
210
+ deployContext: 'dev',
211
+ secret: signingSecretVar.value,
212
+ siteID: siteInfo.id,
213
+ siteURL: siteInfo.url,
214
+ });
215
+ }
216
+ else {
217
+ log(NETLIFYDEVWARN, `Could not sign redirect because environment variable ${chalk.yellow(match.signingSecret)} is not set`);
218
+ }
219
+ }
220
+ if (isFunction(options.functionsPort, req.url)) {
221
+ return proxy.web(req, res, { target: options.functionsServer });
222
+ }
223
+ const urlForAddons = getAddonUrl(options.addonsUrls, req);
224
+ if (urlForAddons) {
225
+ handleAddonUrl({ req, res, addonUrl: urlForAddons });
226
+ return;
227
+ }
228
+ const originalURL = req.url;
229
+ if (match.exceptions && match.exceptions.JWT) {
230
+ // Some values of JWT can start with :, so, make sure to normalize them
231
+ const expectedRoles = new Set(match.exceptions.JWT.split(',').map((value) => (value.startsWith(':') ? value.slice(1) : value)));
232
+ const cookieValues = cookie.parse(req.headers.cookie || '');
233
+ const token = cookieValues.nf_jwt;
234
+ // Serve not found by default
235
+ req.url = '/.netlify/non-existent-path';
236
+ if (token) {
237
+ let jwtValue = {};
238
+ try {
239
+ jwtValue = jwtDecode(token) || {};
240
+ }
241
+ catch (error) {
242
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
243
+ console.warn(NETLIFYDEVWARN, 'Error while decoding JWT provided in request', error.message);
244
+ res.writeHead(400);
245
+ res.end('Invalid JWT provided. Please see logs for more info.');
246
+ return;
247
+ }
248
+ // @ts-expect-error TS(2339) FIXME: Property 'exp' does not exist on type '{}'.
249
+ if ((jwtValue.exp || 0) < Math.round(Date.now() / MILLISEC_TO_SEC)) {
250
+ console.warn(NETLIFYDEVWARN, 'Expired JWT provided in request', req.url);
251
+ }
252
+ else {
253
+ const presentedRoles = getProperty(jwtValue, options.jwtRolePath) || [];
254
+ if (!Array.isArray(presentedRoles)) {
255
+ console.warn(NETLIFYDEVWARN, `Invalid roles value provided in JWT ${options.jwtRolePath}`, presentedRoles);
256
+ res.writeHead(400);
257
+ res.end('Invalid JWT provided. Please see logs for more info.');
258
+ return;
259
+ }
260
+ // Restore the URL if everything is correct
261
+ if (presentedRoles.some((pr) => expectedRoles.has(pr))) {
262
+ req.url = originalURL;
263
+ }
264
+ }
265
+ }
266
+ }
267
+ const reqUrl = reqToURL(req, req.url);
268
+ const isHiddenProxy = match.proxyHeaders &&
269
+ Object.entries(match.proxyHeaders).some(([key, val]) => key.toLowerCase() === 'x-nf-hidden-proxy' && val === 'true');
270
+ const staticFile = await getStatic(decodeURIComponent(reqUrl.pathname), options.publicFolder);
271
+ const endpointExists = !staticFile &&
272
+ !isHiddenProxy &&
273
+ process.env.NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS &&
274
+ (await isEndpointExists(decodeURIComponent(reqUrl.pathname), options.target));
275
+ if (staticFile || endpointExists) {
276
+ const pathname = staticFile || reqUrl.pathname;
277
+ req.url = encodeURI(decodeURI(pathname)) + reqUrl.search;
278
+ // if there is an existing static file and it is not a forced redirect, return the file
279
+ if (!match.force) {
280
+ return proxy.web(req, res, { ...options, staticFile });
281
+ }
282
+ }
283
+ if (match.force || !staticFile || !options.framework || req.method === 'POST') {
284
+ // construct destination URL from redirect rule match
285
+ const dest = new URL(match.to, `${reqUrl.protocol}//${reqUrl.host}`);
286
+ // We pass through request params if the redirect rule
287
+ // doesn't have any query params
288
+ if ([...dest.searchParams].length === 0) {
289
+ dest.searchParams.forEach((_, key) => {
290
+ dest.searchParams.delete(key);
291
+ });
292
+ const requestParams = new URLSearchParams(reqUrl.searchParams);
293
+ requestParams.forEach((val, key) => {
294
+ dest.searchParams.append(key, val);
295
+ });
296
+ }
297
+ let destURL = stripOrigin(dest);
298
+ if (isExternal(match)) {
299
+ if (isRedirect(match)) {
300
+ // This is a redirect, so we set the complete external URL as destination
301
+ destURL = `${dest}`;
302
+ }
303
+ else {
304
+ if (!isHiddenProxy) {
305
+ console.log(`${NETLIFYDEVLOG} Proxying to ${dest}`);
306
+ }
307
+ proxyToExternalUrl({ req, res, dest, destURL });
308
+ return;
309
+ }
310
+ }
311
+ if (isRedirect(match)) {
312
+ console.log(`${NETLIFYDEVLOG} Redirecting ${req.url} to ${destURL}`);
313
+ res.writeHead(match.status, {
314
+ Location: destURL,
315
+ 'Cache-Control': 'no-cache',
316
+ });
317
+ res.end(`Redirecting to ${destURL}`);
318
+ return;
319
+ }
320
+ const ct = req.headers['content-type'] ? contentType.parse(req).type : '';
321
+ if (req.method === 'POST' &&
322
+ !isInternal(req.url) &&
323
+ !isInternal(destURL) &&
324
+ (ct.endsWith('/x-www-form-urlencoded') || ct === 'multipart/form-data')) {
325
+ return proxy.web(req, res, { target: options.functionsServer });
326
+ }
327
+ const destStaticFile = await getStatic(dest.pathname, options.publicFolder);
328
+ const matchingFunction = functionsRegistry &&
329
+ (await functionsRegistry.getFunctionForURLPath(destURL, req.method, () => Boolean(destStaticFile)));
330
+ let statusValue;
331
+ if (match.force ||
332
+ (!staticFile && ((!options.framework && destStaticFile) || isInternal(destURL) || matchingFunction))) {
333
+ req.url = destStaticFile ? destStaticFile + dest.search : destURL;
334
+ const { status } = match;
335
+ statusValue = status;
336
+ console.log(`${NETLIFYDEVLOG} Rewrote URL to`, req.url);
337
+ }
338
+ if (matchingFunction) {
339
+ const functionHeaders = matchingFunction.func
340
+ ? {
341
+ [NFFunctionName]: matchingFunction.func?.name,
342
+ [NFFunctionRoute]: matchingFunction.route,
343
+ }
344
+ : {};
345
+ const url = reqToURL(req, originalURL);
346
+ req.headers['x-netlify-original-pathname'] = url.pathname;
347
+ req.headers['x-netlify-original-search'] = url.search;
348
+ return proxy.web(req, res, { headers: functionHeaders, target: options.functionsServer });
349
+ }
350
+ if (isImageRequest(req)) {
351
+ return imageProxy(req, res);
352
+ }
353
+ const addonUrl = getAddonUrl(options.addonsUrls, req);
354
+ if (addonUrl) {
355
+ handleAddonUrl({ req, res, addonUrl });
356
+ return;
357
+ }
358
+ return proxy.web(req, res, { ...options, status: statusValue });
359
+ }
360
+ return proxy.web(req, res, options);
361
+ };
362
+ // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type.
363
+ const reqToURL = function (req, pathname) {
364
+ return new URL(pathname, `${req.protocol || (req.headers.scheme && `${req.headers.scheme}:`) || 'http:'}//${req.headers.host || req.hostname}`);
365
+ };
366
+ const MILLISEC_TO_SEC = 1e3;
367
+ const initializeProxy = async function ({ config, configPath, distDir, env, host, imageProxy, port, projectDir, siteInfo, }) {
368
+ const proxy = httpProxy.createProxyServer({
369
+ selfHandleResponse: true,
370
+ target: {
371
+ host,
372
+ port,
373
+ },
374
+ });
375
+ const headersFiles = [...new Set([path.resolve(projectDir, '_headers'), path.resolve(distDir, '_headers')])];
376
+ let headers = await parseHeaders({ headersFiles, configPath, config });
377
+ const watchedHeadersFiles = configPath === undefined ? headersFiles : [...headersFiles, configPath];
378
+ onChanges(watchedHeadersFiles, async () => {
379
+ const existingHeadersFiles = await pFilter(watchedHeadersFiles, fileExistsAsync);
380
+ console.log(`${NETLIFYDEVLOG} Reloading headers files from`, existingHeadersFiles.map((headerFile) => path.relative(projectDir, headerFile)));
381
+ headers = await parseHeaders({ headersFiles, configPath, config });
382
+ });
383
+ // @ts-expect-error TS(2339) FIXME: Property 'before' does not exist on type 'Server'.
384
+ proxy.before('web', 'stream', (req) => {
385
+ // See https://github.com/http-party/node-http-proxy/issues/1219#issuecomment-511110375
386
+ if (req.headers.expect) {
387
+ req.__expectHeader = req.headers.expect;
388
+ delete req.headers.expect;
389
+ }
390
+ });
391
+ proxy.on('error', (err, req, res, proxyUrl) => {
392
+ // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message
393
+ const options = req.proxyOptions;
394
+ const isConRefused = 'code' in err && err.code === 'ECONNREFUSED';
395
+ if (options?.detectTarget && !(res instanceof Socket) && isConRefused && proxyUrl) {
396
+ // got econnrefused while detectTarget set to true -> try to switch between current ipVer and other (4 to 6 and vice versa)
397
+ // proxyUrl is parsed in http-proxy using url, parsing the same here. Difference between it and
398
+ // URL that hostname not includes [] symbols when using url.parse
399
+ // eslint-disable-next-line n/no-deprecated-api
400
+ const targetUrl = typeof proxyUrl === 'string' ? url.parse(proxyUrl) : proxyUrl;
401
+ const isCurrentHost = targetUrl.hostname === options.targetHostname;
402
+ if (targetUrl.hostname && isCurrentHost) {
403
+ const newHost = isIPv6(targetUrl.hostname) ? '127.0.0.1' : '::1';
404
+ options.target = `http://${isIPv6(newHost) ? `[${newHost}]` : newHost}:${targetUrl.port}`;
405
+ options.targetHostname = newHost;
406
+ options.isChangingTarget = true;
407
+ proxy.web(req, res, options);
408
+ return;
409
+ }
410
+ }
411
+ if (res instanceof http.ServerResponse) {
412
+ res.writeHead(500, {
413
+ 'Content-Type': 'text/plain',
414
+ });
415
+ }
416
+ const message = isEdgeFunctionsRequest(req)
417
+ ? 'There was an error with an Edge Function. Please check the terminal for more details.'
418
+ : 'Could not proxy request.';
419
+ res.end(message);
420
+ });
421
+ proxy.on('proxyReq', (proxyReq, req) => {
422
+ const requestID = generateRequestID();
423
+ proxyReq.setHeader(NFRequestID, requestID);
424
+ req.headers[NFRequestID] = requestID;
425
+ if (isEdgeFunctionsRequest(req)) {
426
+ handleProxyRequest(req, proxyReq);
427
+ }
428
+ // @ts-expect-error TS(2339) FIXME: Property '__expectHeader' does not exist on type '... Remove this comment to see the full error message
429
+ if (req.__expectHeader) {
430
+ // @ts-expect-error TS(2339) FIXME: Property '__expectHeader' does not exist on type '... Remove this comment to see the full error message
431
+ proxyReq.setHeader('Expect', req.__expectHeader);
432
+ }
433
+ // @ts-expect-error TS(2339) FIXME: Property 'originalBody' does not exist on type 'In... Remove this comment to see the full error message
434
+ if (req.originalBody) {
435
+ // @ts-expect-error TS(2339) FIXME: Property 'originalBody' does not exist on type 'In... Remove this comment to see the full error message
436
+ proxyReq.write(req.originalBody);
437
+ }
438
+ });
439
+ proxy.on('proxyRes', (proxyRes, req, res) => {
440
+ res.setHeader('server', 'Netlify');
441
+ const requestID = req.headers[NFRequestID];
442
+ if (requestID) {
443
+ res.setHeader(NFRequestID, requestID);
444
+ }
445
+ // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message
446
+ const options = req.proxyOptions;
447
+ if (options.isChangingTarget) {
448
+ // got a response after switching the ipVer for host (and its not an error since we will be in on('error') handler) - let's remember this host now
449
+ // options are not exported in ts for the proxy:
450
+ // @ts-expect-error TS(2339) FIXME: Property 'options' does not exist on type 'In...
451
+ proxy.options.target.host = options.targetHostname;
452
+ options.changeSettings?.({
453
+ frameworkHost: options.targetHostname,
454
+ detectFrameworkHost: false,
455
+ });
456
+ console.log(`${NETLIFYDEVLOG} Switched host to ${options.targetHostname}`);
457
+ }
458
+ if (proxyRes.statusCode === 404 || proxyRes.statusCode === 403) {
459
+ // If a request for `/path` has failed, we'll a few variations like
460
+ // `/path/index.html` to mimic the CDN behavior.
461
+ // @ts-expect-error TS(2339) FIXME: Property 'alternativePaths' does not exist on type... Remove this comment to see the full error message
462
+ if (req.alternativePaths && req.alternativePaths.length !== 0) {
463
+ // @ts-expect-error TS(2339) FIXME: Property 'alternativePaths' does not exist on type... Remove this comment to see the full error message
464
+ req.url = req.alternativePaths.shift();
465
+ // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message
466
+ proxy.web(req, res, req.proxyOptions);
467
+ return;
468
+ }
469
+ // The request has failed but we might still have a matching redirect
470
+ // rule (without `force`) that should kick in. This is how we mimic the
471
+ // file shadowing behavior from the CDN.
472
+ if (options && options.match) {
473
+ return serveRedirect({
474
+ // We don't want to match functions at this point because any redirects
475
+ // to functions will have already been processed, so we don't supply a
476
+ // functions registry to `serveRedirect`.
477
+ functionsRegistry: null,
478
+ req,
479
+ res,
480
+ proxy: handlers,
481
+ imageProxy,
482
+ match: options.match,
483
+ options,
484
+ siteInfo,
485
+ env,
486
+ });
487
+ }
488
+ }
489
+ if (options.staticFile && isRedirect({ status: proxyRes.statusCode }) && proxyRes.headers.location) {
490
+ req.url = proxyRes.headers.location;
491
+ return serveRedirect({
492
+ // We don't want to match functions at this point because any redirects
493
+ // to functions will have already been processed, so we don't supply a
494
+ // functions registry to `serveRedirect`.
495
+ functionsRegistry: null,
496
+ req,
497
+ res,
498
+ proxy: handlers,
499
+ imageProxy,
500
+ match: null,
501
+ options,
502
+ siteInfo,
503
+ env,
504
+ });
505
+ }
506
+ // @ts-expect-error TS(7034) FIXME: Variable 'responseData' implicitly has type 'any[]... Remove this comment to see the full error message
507
+ const responseData = [];
508
+ // @ts-expect-error TS(2345) FIXME: Argument of type 'string | undefined' is not assig... Remove this comment to see the full error message
509
+ const requestURL = new URL(req.url, `http://${req.headers.host || '127.0.0.1'}`);
510
+ const headersRules = headersForPath(headers, requestURL.pathname);
511
+ const configInjections = config.dev?.processing?.html?.injections ?? [];
512
+ const htmlInjections = configInjections.length > 0 && proxyRes.headers?.['content-type']?.startsWith('text/html')
513
+ ? configInjections
514
+ : undefined;
515
+ // for streamed responses, we can't do etag generation nor error templates.
516
+ // we'll just stream them through!
517
+ // when html_injections are present in dev config, we can't use streamed response
518
+ const isStreamedResponse = proxyRes.headers['content-length'] === undefined;
519
+ if (isStreamedResponse && !htmlInjections) {
520
+ Object.entries(headersRules).forEach(([key, val]) => {
521
+ // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
522
+ res.setHeader(key, val);
523
+ });
524
+ res.writeHead(options.status || proxyRes.statusCode, proxyRes.headers);
525
+ proxyRes.on('data', function onData(data) {
526
+ res.write(data);
527
+ });
528
+ proxyRes.on('end', function onEnd() {
529
+ res.end();
530
+ });
531
+ return;
532
+ }
533
+ proxyRes.on('data', function onData(data) {
534
+ responseData.push(data);
535
+ });
536
+ proxyRes.on('end', async function onEnd() {
537
+ // @ts-expect-error TS(7005) FIXME: Variable 'responseData' implicitly has an 'any[]' ... Remove this comment to see the full error message
538
+ let responseBody = Buffer.concat(responseData);
539
+ let responseStatus = options.status || proxyRes.statusCode;
540
+ // `req[shouldGenerateETag]` may contain a function that determines
541
+ // whether the response should have an ETag header.
542
+ if (
543
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
544
+ typeof req[shouldGenerateETag] === 'function' &&
545
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
546
+ req[shouldGenerateETag]({ statusCode: responseStatus }) === true) {
547
+ const etag = generateETag(responseBody, { weak: true });
548
+ if (req.headers['if-none-match'] === etag) {
549
+ responseStatus = 304;
550
+ }
551
+ res.setHeader('etag', etag);
552
+ }
553
+ Object.entries(headersRules).forEach(([key, val]) => {
554
+ // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
555
+ res.setHeader(key, val);
556
+ });
557
+ const isUncaughtError = proxyRes.headers['x-nf-uncaught-error'] === '1';
558
+ if (isEdgeFunctionsRequest(req) && isUncaughtError) {
559
+ const acceptsHtml = req.headers.accept?.includes('text/html') ?? false;
560
+ const decompressedBody = await decompressResponseBody(responseBody, proxyRes.headers['content-encoding']);
561
+ const formattedBody = formatEdgeFunctionError(decompressedBody, acceptsHtml);
562
+ const errorResponse = acceptsHtml
563
+ ? await renderErrorTemplate(formattedBody, '../../src/lib/templates/function-error.html', 'edge function')
564
+ : formattedBody;
565
+ const contentLength = Buffer.from(errorResponse, 'utf8').byteLength;
566
+ res.setHeader('content-length', contentLength);
567
+ res.statusCode = 500;
568
+ res.write(errorResponse);
569
+ return res.end();
570
+ }
571
+ let proxyResHeaders = proxyRes.headers;
572
+ if (htmlInjections) {
573
+ responseBody = await injectHtml(responseBody, proxyRes, htmlInjections);
574
+ proxyResHeaders = {
575
+ ...proxyResHeaders,
576
+ 'content-length': String(responseBody.byteLength),
577
+ };
578
+ delete proxyResHeaders['transfer-encoding'];
579
+ }
580
+ res.writeHead(responseStatus, proxyResHeaders);
581
+ if (responseStatus !== 304) {
582
+ res.write(responseBody);
583
+ }
584
+ res.end();
585
+ });
586
+ });
587
+ const handlers = {
588
+ // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type.
589
+ web: (req, res, options) => {
590
+ const requestURL = new URL(req.url, 'http://127.0.0.1');
591
+ req.proxyOptions = options;
592
+ req.alternativePaths = alternativePathsFor(requestURL.pathname).map((filePath) => filePath + requestURL.search);
593
+ // Ref: https://nodejs.org/api/net.html#net_socket_remoteaddress
594
+ req.headers['x-forwarded-for'] = req.connection.remoteAddress || '';
595
+ proxy.web(req, res, options);
596
+ },
597
+ // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type.
598
+ ws: (req, socket, head, options) => {
599
+ proxy.ws(req, socket, head, options);
600
+ },
601
+ };
602
+ return handlers;
603
+ };
604
+ const onRequest = async ({ addonsUrls, api, edgeFunctionsProxy, env, functionsRegistry, functionsServer, imageProxy, proxy, rewriter, settings, siteInfo, }, req, res) => {
605
+ req.originalBody =
606
+ req.method && ['GET', 'OPTIONS', 'HEAD'].includes(req.method) ? null : await createStreamPromise(req, BYTES_LIMIT);
607
+ if (isImageRequest(req)) {
608
+ return imageProxy(req, res);
609
+ }
610
+ const edgeFunctionsProxyURL = await edgeFunctionsProxy?.(req);
611
+ if (edgeFunctionsProxyURL !== undefined) {
612
+ return proxy.web(req, res, { target: edgeFunctionsProxyURL });
613
+ }
614
+ const functionMatch = functionsRegistry &&
615
+ (await functionsRegistry.getFunctionForURLPath(req.url, req.method, () => getStatic(decodeURIComponent(reqToURL(req, req.url).pathname), settings.dist ?? '')));
616
+ if (functionMatch) {
617
+ // Setting an internal header with the function name so that we don't
618
+ // have to match the URL again in the functions server.
619
+ const headers = {};
620
+ if (functionMatch.func) {
621
+ headers[NFFunctionName] = functionMatch.func.name;
622
+ }
623
+ if (functionMatch.route) {
624
+ headers[NFFunctionRoute] = functionMatch.route.pattern;
625
+ }
626
+ return proxy.web(req, res, { headers, target: functionsServer });
627
+ }
628
+ const addonUrl = getAddonUrl(addonsUrls, req);
629
+ if (addonUrl) {
630
+ handleAddonUrl({ req, res, addonUrl });
631
+ return;
632
+ }
633
+ const match = await rewriter(req);
634
+ const options = {
635
+ match,
636
+ addonsUrls,
637
+ target: `http://${settings.frameworkHost && isIPv6(settings.frameworkHost) ? `[${settings.frameworkHost}]` : settings.frameworkHost}:${settings.frameworkPort}`,
638
+ detectTarget: settings.detectFrameworkHost,
639
+ targetHostname: settings.frameworkHost,
640
+ publicFolder: settings.dist,
641
+ functionsServer,
642
+ functionsPort: settings.functionsPort,
643
+ jwtRolePath: settings.jwtRolePath,
644
+ framework: settings.framework,
645
+ changeSettings(newSettings) {
646
+ Object.assign(settings, newSettings);
647
+ },
648
+ };
649
+ const maybeNotifyActivity = () => {
650
+ if (req.method === 'GET' && api && process.env.NETLIFY_DEV_SERVER_ID) {
651
+ notifyActivity(api, siteInfo.id, process.env.NETLIFY_DEV_SERVER_ID);
652
+ }
653
+ };
654
+ if (match) {
655
+ if (!isExternal(match)) {
656
+ maybeNotifyActivity();
657
+ }
658
+ // We don't want to generate an ETag for 3xx redirects.
659
+ // @ts-expect-error TS(7031) FIXME: Binding element 'statusCode' implicitly has an 'an... Remove this comment to see the full error message
660
+ req[shouldGenerateETag] = ({ statusCode }) => statusCode < 300 || statusCode >= 400;
661
+ return serveRedirect({ req, res, proxy, imageProxy, match, options, siteInfo, env, functionsRegistry });
662
+ }
663
+ // The request will be served by the framework server, which means we want to
664
+ // generate an ETag unless we're rendering an error page. The only way for
665
+ // us to know that is by looking at the status code
666
+ // @ts-expect-error TS(7031) FIXME: Binding element 'statusCode' implicitly has an 'an... Remove this comment to see the full error message
667
+ req[shouldGenerateETag] = ({ statusCode }) => statusCode >= 200 && statusCode < 300;
668
+ const hasFormSubmissionHandler = functionsRegistry && getFormHandler({ functionsRegistry, logWarning: false });
669
+ const ct = req.headers['content-type'] ? contentType.parse(req).type : '';
670
+ if (hasFormSubmissionHandler &&
671
+ functionsServer &&
672
+ req.method === 'POST' &&
673
+ !isInternal(req.url) &&
674
+ (ct.endsWith('/x-www-form-urlencoded') || ct === 'multipart/form-data')) {
675
+ return proxy.web(req, res, { target: functionsServer });
676
+ }
677
+ maybeNotifyActivity();
678
+ proxy.web(req, res, options);
679
+ };
680
+ export const getProxyUrl = function (settings) {
681
+ const scheme = settings.https ? 'https' : 'http';
682
+ return `${scheme}://localhost:${settings.port}`;
683
+ };
684
+ export const startProxy = async function ({ accountId, addonsUrls, api, blobsContext, command, config, configPath, debug, disableEdgeFunctions, env, functionsRegistry, geoCountry, geolocationMode, getUpdatedConfig, inspectSettings, offline, projectDir, repositoryRoot, settings, siteInfo, state, }) {
685
+ const secondaryServerPort = settings.https ? await getAvailablePort() : null;
686
+ const functionsServer = settings.functionsPort ? `http://127.0.0.1:${settings.functionsPort}` : null;
687
+ let edgeFunctionsProxy;
688
+ if (disableEdgeFunctions) {
689
+ log(NETLIFYDEVWARN, 'Edge functions are disabled. Run without the --internal-disable-edge-functions flag to enable them.');
690
+ }
691
+ else {
692
+ edgeFunctionsProxy = await initializeEdgeFunctionsProxy({
693
+ command,
694
+ blobsContext,
695
+ config,
696
+ configPath,
697
+ debug,
698
+ env,
699
+ geolocationMode,
700
+ geoCountry,
701
+ getUpdatedConfig,
702
+ inspectSettings,
703
+ mainPort: settings.port,
704
+ offline,
705
+ passthroughPort: secondaryServerPort || settings.port,
706
+ settings,
707
+ projectDir,
708
+ repositoryRoot,
709
+ siteInfo,
710
+ accountId,
711
+ state,
712
+ });
713
+ }
714
+ const imageProxy = initializeImageProxy({
715
+ config,
716
+ settings,
717
+ });
718
+ const proxy = await initializeProxy({
719
+ env,
720
+ host: settings.frameworkHost,
721
+ port: settings.frameworkPort,
722
+ distDir: settings.dist,
723
+ projectDir,
724
+ configPath,
725
+ siteInfo,
726
+ imageProxy,
727
+ config,
728
+ });
729
+ const rewriter = await createRewriter({
730
+ config,
731
+ configPath,
732
+ distDir: settings.dist,
733
+ geoCountry,
734
+ jwtSecret: settings.jwtSecret,
735
+ jwtRoleClaim: settings.jwtRolePath,
736
+ projectDir,
737
+ });
738
+ const onRequestWithOptions = onRequest.bind(undefined, {
739
+ proxy,
740
+ rewriter,
741
+ settings,
742
+ addonsUrls,
743
+ functionsRegistry,
744
+ functionsServer,
745
+ edgeFunctionsProxy,
746
+ imageProxy,
747
+ siteInfo,
748
+ env,
749
+ api,
750
+ });
751
+ const primaryServer = settings.https
752
+ ? https.createServer({ cert: settings.https.cert, key: settings.https.key }, onRequestWithOptions)
753
+ : http.createServer(onRequestWithOptions);
754
+ const onUpgrade = async function onUpgrade(req, socket, head) {
755
+ const match = await rewriter(req);
756
+ if (match && !match.force404 && isExternal(match)) {
757
+ const reqUrl = reqToURL(req, req.url);
758
+ const dest = new URL(match.to, `${reqUrl.protocol}//${reqUrl.host}`);
759
+ const destURL = stripOrigin(dest);
760
+ proxy.ws(req, socket, head, { target: dest.origin, changeOrigin: true, pathRewrite: () => destURL });
761
+ return;
762
+ }
763
+ proxy.ws(req, socket, head, {});
764
+ };
765
+ primaryServer.on('upgrade', onUpgrade);
766
+ primaryServer.listen({ port: settings.port });
767
+ const eventQueue = [once(primaryServer, 'listening')];
768
+ // If we're running the main server on HTTPS, we need to start a secondary
769
+ // server on HTTP for receiving passthrough requests from edge functions.
770
+ // This lets us run the Deno server on HTTP and avoid the complications of
771
+ // Deno talking to Node on HTTPS with potentially untrusted certificates.
772
+ if (secondaryServerPort) {
773
+ const secondaryServer = http.createServer(onRequestWithOptions);
774
+ secondaryServer.on('upgrade', onUpgrade);
775
+ secondaryServer.listen({ port: secondaryServerPort });
776
+ eventQueue.push(once(secondaryServer, 'listening'));
777
+ }
778
+ await Promise.all(eventQueue);
779
+ return getProxyUrl(settings);
780
+ };
781
+ const BYTES_LIMIT = 30;
782
+ //# sourceMappingURL=proxy.js.map