@kubb/agent 4.28.1 → 4.29.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 (290) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +416 -682
  3. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  4. package/.output/server/chunks/routes/api/health.get.mjs +4 -6
  5. package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
  6. package/.output/server/index.mjs +4 -6
  7. package/.output/server/index.mjs.map +1 -1
  8. package/.output/server/node_modules/@kubb/fabric-core/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
  9. package/.output/server/node_modules/@kubb/fabric-core/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
  10. package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +8 -9
  11. package/.output/server/node_modules/@kubb/fabric-core/dist/{Root-BQX3eHqb.js → onProcessExit-CF200hsz.js} +109 -190
  12. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +3 -4
  13. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +2 -3
  14. package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +58 -298
  15. package/.output/server/node_modules/@kubb/fabric-core/package.json +8 -18
  16. package/.output/server/node_modules/@kubb/react-fabric/dist/{chunk-DbZtQ4qb.js → chunk-Cnw5r_-A.js} +1 -5
  17. package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +39 -41
  18. package/.output/server/node_modules/@kubb/react-fabric/dist/{jsx-runtime-CQFBnRKx.js → jsx-runtime-Dm7PKVbc.js} +6 -24
  19. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +5 -4
  20. package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +3 -3
  21. package/.output/server/node_modules/@kubb/react-fabric/dist/{react--draJ5Pm.js → react-D652OKii.js} +31 -91
  22. package/.output/server/node_modules/@kubb/react-fabric/dist/{reactPlugin-DqJsInTf.js → reactPlugin-BkDkx1cs.js} +410 -1650
  23. package/.output/server/node_modules/@kubb/react-fabric/package.json +8 -11
  24. package/.output/server/node_modules/empathic/access.js +39 -0
  25. package/.output/server/node_modules/empathic/access.mjs +34 -0
  26. package/.output/server/node_modules/empathic/find.js +81 -0
  27. package/.output/server/node_modules/empathic/find.mjs +76 -0
  28. package/.output/server/node_modules/empathic/package.json +49 -0
  29. package/.output/server/node_modules/empathic/package.mjs +52 -0
  30. package/.output/server/node_modules/empathic/resolve.js +31 -0
  31. package/.output/server/node_modules/empathic/resolve.mjs +27 -0
  32. package/.output/server/node_modules/empathic/walk.js +22 -0
  33. package/.output/server/node_modules/empathic/walk.mjs +20 -0
  34. package/.output/server/node_modules/tinyexec/dist/main.js +633 -0
  35. package/.output/server/node_modules/tinyexec/package.json +61 -0
  36. package/.output/server/package.json +6 -44
  37. package/package.json +19 -21
  38. package/.output/server/node_modules/.nitro/path-key@3.1.1/index.js +0 -16
  39. package/.output/server/node_modules/.nitro/path-key@3.1.1/package.json +0 -39
  40. package/.output/server/node_modules/.nitro/path-key@4.0.0/index.js +0 -12
  41. package/.output/server/node_modules/.nitro/path-key@4.0.0/package.json +0 -41
  42. package/.output/server/node_modules/.nitro/path-to-regexp@3.3.0/index.js +0 -421
  43. package/.output/server/node_modules/.nitro/path-to-regexp@3.3.0/package.json +0 -46
  44. package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-BVHe6Par.js +0 -22
  45. package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/asyncIterator.js +0 -89
  46. package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/fromAnyIterable.js +0 -34
  47. package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/index.js +0 -6
  48. package/.output/server/node_modules/@sec-ant/readable-stream/package.json +0 -98
  49. package/.output/server/node_modules/@sindresorhus/merge-streams/index.js +0 -265
  50. package/.output/server/node_modules/@sindresorhus/merge-streams/package.json +0 -49
  51. package/.output/server/node_modules/balanced-match/index.js +0 -62
  52. package/.output/server/node_modules/balanced-match/package.json +0 -48
  53. package/.output/server/node_modules/brace-expansion/index.js +0 -201
  54. package/.output/server/node_modules/brace-expansion/package.json +0 -50
  55. package/.output/server/node_modules/bytes/index.js +0 -159
  56. package/.output/server/node_modules/bytes/package.json +0 -39
  57. package/.output/server/node_modules/concat-map/index.js +0 -13
  58. package/.output/server/node_modules/concat-map/package.json +0 -59
  59. package/.output/server/node_modules/content-disposition/index.js +0 -445
  60. package/.output/server/node_modules/content-disposition/package.json +0 -39
  61. package/.output/server/node_modules/cross-spawn/index.js +0 -39
  62. package/.output/server/node_modules/cross-spawn/lib/enoent.js +0 -59
  63. package/.output/server/node_modules/cross-spawn/lib/parse.js +0 -91
  64. package/.output/server/node_modules/cross-spawn/lib/util/escape.js +0 -47
  65. package/.output/server/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
  66. package/.output/server/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
  67. package/.output/server/node_modules/cross-spawn/package.json +0 -73
  68. package/.output/server/node_modules/execa/index.js +0 -28
  69. package/.output/server/node_modules/execa/lib/arguments/command.js +0 -20
  70. package/.output/server/node_modules/execa/lib/arguments/cwd.js +0 -39
  71. package/.output/server/node_modules/execa/lib/arguments/encoding-option.js +0 -50
  72. package/.output/server/node_modules/execa/lib/arguments/escape.js +0 -88
  73. package/.output/server/node_modules/execa/lib/arguments/fd-options.js +0 -108
  74. package/.output/server/node_modules/execa/lib/arguments/file-url.js +0 -25
  75. package/.output/server/node_modules/execa/lib/arguments/options.js +0 -96
  76. package/.output/server/node_modules/execa/lib/arguments/shell.js +0 -11
  77. package/.output/server/node_modules/execa/lib/arguments/specific.js +0 -111
  78. package/.output/server/node_modules/execa/lib/convert/add.js +0 -15
  79. package/.output/server/node_modules/execa/lib/convert/concurrent.js +0 -33
  80. package/.output/server/node_modules/execa/lib/convert/duplex.js +0 -69
  81. package/.output/server/node_modules/execa/lib/convert/iterable.js +0 -34
  82. package/.output/server/node_modules/execa/lib/convert/readable.js +0 -113
  83. package/.output/server/node_modules/execa/lib/convert/shared.js +0 -46
  84. package/.output/server/node_modules/execa/lib/convert/writable.js +0 -90
  85. package/.output/server/node_modules/execa/lib/io/contents.js +0 -116
  86. package/.output/server/node_modules/execa/lib/io/input-sync.js +0 -44
  87. package/.output/server/node_modules/execa/lib/io/iterate.js +0 -110
  88. package/.output/server/node_modules/execa/lib/io/max-buffer.js +0 -89
  89. package/.output/server/node_modules/execa/lib/io/output-async.js +0 -80
  90. package/.output/server/node_modules/execa/lib/io/output-sync.js +0 -135
  91. package/.output/server/node_modules/execa/lib/io/pipeline.js +0 -48
  92. package/.output/server/node_modules/execa/lib/io/strip-newline.js +0 -12
  93. package/.output/server/node_modules/execa/lib/ipc/array.js +0 -4
  94. package/.output/server/node_modules/execa/lib/ipc/buffer-messages.js +0 -47
  95. package/.output/server/node_modules/execa/lib/ipc/forward.js +0 -56
  96. package/.output/server/node_modules/execa/lib/ipc/get-each.js +0 -89
  97. package/.output/server/node_modules/execa/lib/ipc/get-one.js +0 -69
  98. package/.output/server/node_modules/execa/lib/ipc/graceful.js +0 -72
  99. package/.output/server/node_modules/execa/lib/ipc/incoming.js +0 -79
  100. package/.output/server/node_modules/execa/lib/ipc/ipc-input.js +0 -44
  101. package/.output/server/node_modules/execa/lib/ipc/methods.js +0 -49
  102. package/.output/server/node_modules/execa/lib/ipc/outgoing.js +0 -47
  103. package/.output/server/node_modules/execa/lib/ipc/reference.js +0 -44
  104. package/.output/server/node_modules/execa/lib/ipc/send.js +0 -91
  105. package/.output/server/node_modules/execa/lib/ipc/strict.js +0 -113
  106. package/.output/server/node_modules/execa/lib/ipc/validation.js +0 -111
  107. package/.output/server/node_modules/execa/lib/methods/bind.js +0 -23
  108. package/.output/server/node_modules/execa/lib/methods/command.js +0 -43
  109. package/.output/server/node_modules/execa/lib/methods/create.js +0 -65
  110. package/.output/server/node_modules/execa/lib/methods/main-async.js +0 -194
  111. package/.output/server/node_modules/execa/lib/methods/main-sync.js +0 -163
  112. package/.output/server/node_modules/execa/lib/methods/node.js +0 -51
  113. package/.output/server/node_modules/execa/lib/methods/parameters.js +0 -31
  114. package/.output/server/node_modules/execa/lib/methods/promise.js +0 -15
  115. package/.output/server/node_modules/execa/lib/methods/script.js +0 -22
  116. package/.output/server/node_modules/execa/lib/methods/template.js +0 -153
  117. package/.output/server/node_modules/execa/lib/pipe/abort.js +0 -20
  118. package/.output/server/node_modules/execa/lib/pipe/pipe-arguments.js +0 -91
  119. package/.output/server/node_modules/execa/lib/pipe/sequence.js +0 -24
  120. package/.output/server/node_modules/execa/lib/pipe/setup.js +0 -72
  121. package/.output/server/node_modules/execa/lib/pipe/streaming.js +0 -51
  122. package/.output/server/node_modules/execa/lib/pipe/throw.js +0 -58
  123. package/.output/server/node_modules/execa/lib/resolve/all-async.js +0 -46
  124. package/.output/server/node_modules/execa/lib/resolve/all-sync.js +0 -33
  125. package/.output/server/node_modules/execa/lib/resolve/exit-async.js +0 -54
  126. package/.output/server/node_modules/execa/lib/resolve/exit-sync.js +0 -25
  127. package/.output/server/node_modules/execa/lib/resolve/stdio.js +0 -47
  128. package/.output/server/node_modules/execa/lib/resolve/wait-stream.js +0 -96
  129. package/.output/server/node_modules/execa/lib/resolve/wait-subprocess.js +0 -146
  130. package/.output/server/node_modules/execa/lib/return/duration.js +0 -8
  131. package/.output/server/node_modules/execa/lib/return/early-error.js +0 -60
  132. package/.output/server/node_modules/execa/lib/return/final-error.js +0 -40
  133. package/.output/server/node_modules/execa/lib/return/message.js +0 -157
  134. package/.output/server/node_modules/execa/lib/return/reject.js +0 -13
  135. package/.output/server/node_modules/execa/lib/return/result.js +0 -186
  136. package/.output/server/node_modules/execa/lib/stdio/direction.js +0 -76
  137. package/.output/server/node_modules/execa/lib/stdio/duplicate.js +0 -116
  138. package/.output/server/node_modules/execa/lib/stdio/handle-async.js +0 -52
  139. package/.output/server/node_modules/execa/lib/stdio/handle-sync.js +0 -57
  140. package/.output/server/node_modules/execa/lib/stdio/handle.js +0 -214
  141. package/.output/server/node_modules/execa/lib/stdio/input-option.js +0 -50
  142. package/.output/server/node_modules/execa/lib/stdio/native.js +0 -106
  143. package/.output/server/node_modules/execa/lib/stdio/stdio-option.js +0 -60
  144. package/.output/server/node_modules/execa/lib/stdio/type.js +0 -173
  145. package/.output/server/node_modules/execa/lib/terminate/cancel.js +0 -20
  146. package/.output/server/node_modules/execa/lib/terminate/cleanup.js +0 -16
  147. package/.output/server/node_modules/execa/lib/terminate/graceful.js +0 -71
  148. package/.output/server/node_modules/execa/lib/terminate/kill.js +0 -93
  149. package/.output/server/node_modules/execa/lib/terminate/signal.js +0 -70
  150. package/.output/server/node_modules/execa/lib/terminate/timeout.js +0 -21
  151. package/.output/server/node_modules/execa/lib/transform/encoding-transform.js +0 -51
  152. package/.output/server/node_modules/execa/lib/transform/generator.js +0 -107
  153. package/.output/server/node_modules/execa/lib/transform/normalize.js +0 -111
  154. package/.output/server/node_modules/execa/lib/transform/object-mode.js +0 -41
  155. package/.output/server/node_modules/execa/lib/transform/run-async.js +0 -60
  156. package/.output/server/node_modules/execa/lib/transform/run-sync.js +0 -50
  157. package/.output/server/node_modules/execa/lib/transform/split.js +0 -110
  158. package/.output/server/node_modules/execa/lib/transform/validate.js +0 -43
  159. package/.output/server/node_modules/execa/lib/utils/abort-signal.js +0 -8
  160. package/.output/server/node_modules/execa/lib/utils/deferred.js +0 -7
  161. package/.output/server/node_modules/execa/lib/utils/max-listeners.js +0 -14
  162. package/.output/server/node_modules/execa/lib/utils/standard-stream.js +0 -6
  163. package/.output/server/node_modules/execa/lib/utils/uint-array.js +0 -69
  164. package/.output/server/node_modules/execa/lib/verbose/complete.js +0 -24
  165. package/.output/server/node_modules/execa/lib/verbose/custom.js +0 -26
  166. package/.output/server/node_modules/execa/lib/verbose/default.js +0 -54
  167. package/.output/server/node_modules/execa/lib/verbose/error.js +0 -13
  168. package/.output/server/node_modules/execa/lib/verbose/info.js +0 -39
  169. package/.output/server/node_modules/execa/lib/verbose/ipc.js +0 -15
  170. package/.output/server/node_modules/execa/lib/verbose/log.js +0 -54
  171. package/.output/server/node_modules/execa/lib/verbose/output.js +0 -60
  172. package/.output/server/node_modules/execa/lib/verbose/start.js +0 -15
  173. package/.output/server/node_modules/execa/lib/verbose/values.js +0 -33
  174. package/.output/server/node_modules/execa/package.json +0 -105
  175. package/.output/server/node_modules/figures/index.js +0 -292
  176. package/.output/server/node_modules/figures/package.json +0 -49
  177. package/.output/server/node_modules/fs-extra/lib/copy/copy-sync.js +0 -176
  178. package/.output/server/node_modules/fs-extra/lib/copy/copy.js +0 -180
  179. package/.output/server/node_modules/fs-extra/lib/copy/index.js +0 -7
  180. package/.output/server/node_modules/fs-extra/lib/empty/index.js +0 -39
  181. package/.output/server/node_modules/fs-extra/lib/ensure/file.js +0 -66
  182. package/.output/server/node_modules/fs-extra/lib/ensure/index.js +0 -23
  183. package/.output/server/node_modules/fs-extra/lib/ensure/link.js +0 -64
  184. package/.output/server/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -101
  185. package/.output/server/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -34
  186. package/.output/server/node_modules/fs-extra/lib/ensure/symlink.js +0 -67
  187. package/.output/server/node_modules/fs-extra/lib/fs/index.js +0 -146
  188. package/.output/server/node_modules/fs-extra/lib/index.js +0 -16
  189. package/.output/server/node_modules/fs-extra/lib/json/index.js +0 -16
  190. package/.output/server/node_modules/fs-extra/lib/json/jsonfile.js +0 -11
  191. package/.output/server/node_modules/fs-extra/lib/json/output-json-sync.js +0 -12
  192. package/.output/server/node_modules/fs-extra/lib/json/output-json.js +0 -12
  193. package/.output/server/node_modules/fs-extra/lib/mkdirs/index.js +0 -14
  194. package/.output/server/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -27
  195. package/.output/server/node_modules/fs-extra/lib/mkdirs/utils.js +0 -21
  196. package/.output/server/node_modules/fs-extra/lib/move/index.js +0 -7
  197. package/.output/server/node_modules/fs-extra/lib/move/move-sync.js +0 -55
  198. package/.output/server/node_modules/fs-extra/lib/move/move.js +0 -59
  199. package/.output/server/node_modules/fs-extra/lib/output-file/index.js +0 -31
  200. package/.output/server/node_modules/fs-extra/lib/path-exists/index.js +0 -12
  201. package/.output/server/node_modules/fs-extra/lib/remove/index.js +0 -17
  202. package/.output/server/node_modules/fs-extra/lib/util/async.js +0 -29
  203. package/.output/server/node_modules/fs-extra/lib/util/stat.js +0 -159
  204. package/.output/server/node_modules/fs-extra/lib/util/utimes.js +0 -36
  205. package/.output/server/node_modules/fs-extra/package.json +0 -71
  206. package/.output/server/node_modules/get-stream/package.json +0 -60
  207. package/.output/server/node_modules/get-stream/source/array-buffer.js +0 -84
  208. package/.output/server/node_modules/get-stream/source/array.js +0 -32
  209. package/.output/server/node_modules/get-stream/source/buffer.js +0 -19
  210. package/.output/server/node_modules/get-stream/source/contents.js +0 -121
  211. package/.output/server/node_modules/get-stream/source/exports.js +0 -5
  212. package/.output/server/node_modules/get-stream/source/index.js +0 -13
  213. package/.output/server/node_modules/get-stream/source/stream.js +0 -65
  214. package/.output/server/node_modules/get-stream/source/string.js +0 -41
  215. package/.output/server/node_modules/get-stream/source/utils.js +0 -11
  216. package/.output/server/node_modules/graceful-fs/clone.js +0 -23
  217. package/.output/server/node_modules/graceful-fs/graceful-fs.js +0 -448
  218. package/.output/server/node_modules/graceful-fs/legacy-streams.js +0 -118
  219. package/.output/server/node_modules/graceful-fs/package.json +0 -53
  220. package/.output/server/node_modules/graceful-fs/polyfills.js +0 -355
  221. package/.output/server/node_modules/human-signals/build/src/core.js +0 -273
  222. package/.output/server/node_modules/human-signals/build/src/main.js +0 -70
  223. package/.output/server/node_modules/human-signals/build/src/realtime.js +0 -16
  224. package/.output/server/node_modules/human-signals/build/src/signals.js +0 -34
  225. package/.output/server/node_modules/human-signals/package.json +0 -66
  226. package/.output/server/node_modules/is-plain-obj/index.js +0 -8
  227. package/.output/server/node_modules/is-plain-obj/package.json +0 -41
  228. package/.output/server/node_modules/is-stream/index.js +0 -37
  229. package/.output/server/node_modules/is-stream/package.json +0 -48
  230. package/.output/server/node_modules/is-unicode-supported/index.js +0 -21
  231. package/.output/server/node_modules/is-unicode-supported/package.json +0 -47
  232. package/.output/server/node_modules/isexe/index.js +0 -57
  233. package/.output/server/node_modules/isexe/mode.js +0 -41
  234. package/.output/server/node_modules/isexe/package.json +0 -31
  235. package/.output/server/node_modules/isexe/windows.js +0 -42
  236. package/.output/server/node_modules/js-runtime/dist/index.js +0 -5
  237. package/.output/server/node_modules/js-runtime/package.json +0 -72
  238. package/.output/server/node_modules/jsonfile/index.js +0 -88
  239. package/.output/server/node_modules/jsonfile/package.json +0 -40
  240. package/.output/server/node_modules/jsonfile/utils.js +0 -14
  241. package/.output/server/node_modules/mime-db/db.json +0 -7088
  242. package/.output/server/node_modules/mime-db/index.js +0 -11
  243. package/.output/server/node_modules/mime-db/package.json +0 -57
  244. package/.output/server/node_modules/mime-types/index.js +0 -188
  245. package/.output/server/node_modules/mime-types/package.json +0 -43
  246. package/.output/server/node_modules/minimatch/minimatch.js +0 -947
  247. package/.output/server/node_modules/minimatch/package.json +0 -33
  248. package/.output/server/node_modules/natural-orderby/dist/main.js +0 -19
  249. package/.output/server/node_modules/natural-orderby/dist/umd/natural-orderby.development.js +0 -420
  250. package/.output/server/node_modules/natural-orderby/dist/umd/natural-orderby.production.min.js +0 -11
  251. package/.output/server/node_modules/natural-orderby/package.json +0 -119
  252. package/.output/server/node_modules/npm-run-path/index.js +0 -55
  253. package/.output/server/node_modules/npm-run-path/package.json +0 -52
  254. package/.output/server/node_modules/parse-ms/index.js +0 -45
  255. package/.output/server/node_modules/parse-ms/package.json +0 -47
  256. package/.output/server/node_modules/path-is-inside/lib/path-is-inside.js +0 -28
  257. package/.output/server/node_modules/path-is-inside/package.json +0 -27
  258. package/.output/server/node_modules/pretty-ms/index.js +0 -149
  259. package/.output/server/node_modules/pretty-ms/package.json +0 -55
  260. package/.output/server/node_modules/range-parser/index.js +0 -158
  261. package/.output/server/node_modules/range-parser/package.json +0 -40
  262. package/.output/server/node_modules/serve-handler/package.json +0 -68
  263. package/.output/server/node_modules/serve-handler/src/directory.js +0 -16
  264. package/.output/server/node_modules/serve-handler/src/error.js +0 -10
  265. package/.output/server/node_modules/serve-handler/src/glob-slash.js +0 -9
  266. package/.output/server/node_modules/serve-handler/src/index.js +0 -769
  267. package/.output/server/node_modules/shebang-command/index.js +0 -19
  268. package/.output/server/node_modules/shebang-command/package.json +0 -34
  269. package/.output/server/node_modules/shebang-regex/index.js +0 -2
  270. package/.output/server/node_modules/shebang-regex/package.json +0 -35
  271. package/.output/server/node_modules/signal-exit/dist/mjs/index.js +0 -275
  272. package/.output/server/node_modules/signal-exit/dist/mjs/package.json +0 -3
  273. package/.output/server/node_modules/signal-exit/dist/mjs/signals.js +0 -39
  274. package/.output/server/node_modules/signal-exit/package.json +0 -106
  275. package/.output/server/node_modules/string-argv/index.js +0 -41
  276. package/.output/server/node_modules/string-argv/package.json +0 -51
  277. package/.output/server/node_modules/strip-final-newline/index.js +0 -26
  278. package/.output/server/node_modules/strip-final-newline/package.json +0 -49
  279. package/.output/server/node_modules/unicorn-magic/default.js +0 -14
  280. package/.output/server/node_modules/unicorn-magic/node.js +0 -49
  281. package/.output/server/node_modules/unicorn-magic/package.json +0 -62
  282. package/.output/server/node_modules/universalify/index.js +0 -24
  283. package/.output/server/node_modules/universalify/package.json +0 -34
  284. package/.output/server/node_modules/which/package.json +0 -43
  285. package/.output/server/node_modules/which/which.js +0 -125
  286. package/.output/server/node_modules/yoctocolors/base.js +0 -94
  287. package/.output/server/node_modules/yoctocolors/index.js +0 -2
  288. package/.output/server/node_modules/yoctocolors/package.json +0 -69
  289. /package/.output/server/node_modules/{.nitro/path-to-regexp@8.3.0 → path-to-regexp}/dist/index.js +0 -0
  290. /package/.output/server/node_modules/{.nitro/path-to-regexp@8.3.0 → path-to-regexp}/package.json +0 -0
@@ -1,769 +0,0 @@
1
- // Native
2
- const {promisify} = require('util');
3
- const path = require('path');
4
- const {createHash} = require('crypto');
5
- const {realpath, lstat, createReadStream, readdir} = require('fs');
6
-
7
- // Packages
8
- const url = require('url');
9
- const slasher = require('./glob-slash');
10
- const minimatch = require('minimatch');
11
- const pathToRegExp = require('path-to-regexp');
12
- const mime = require('mime-types');
13
- const bytes = require('bytes');
14
- const contentDisposition = require('content-disposition');
15
- const isPathInside = require('path-is-inside');
16
- const parseRange = require('range-parser');
17
-
18
- // Other
19
- const directoryTemplate = require('./directory');
20
- const errorTemplate = require('./error');
21
-
22
- const etags = new Map();
23
-
24
- const calculateSha = (handlers, absolutePath) =>
25
- new Promise((resolve, reject) => {
26
- const hash = createHash('sha1');
27
- hash.update(path.extname(absolutePath));
28
- hash.update('-');
29
- const rs = handlers.createReadStream(absolutePath);
30
- rs.on('error', reject);
31
- rs.on('data', buf => hash.update(buf));
32
- rs.on('end', () => {
33
- const sha = hash.digest('hex');
34
- resolve(sha);
35
- });
36
- });
37
-
38
- const sourceMatches = (source, requestPath, allowSegments) => {
39
- const keys = [];
40
- const slashed = slasher(source);
41
- const resolvedPath = path.posix.resolve(requestPath);
42
-
43
- let results = null;
44
-
45
- if (allowSegments) {
46
- const normalized = slashed.replace('*', '(.*)');
47
- const expression = pathToRegExp(normalized, keys);
48
-
49
- results = expression.exec(resolvedPath);
50
-
51
- if (!results) {
52
- // clear keys so that they are not used
53
- // later with empty results. this may
54
- // happen if minimatch returns true
55
- keys.length = 0;
56
- }
57
- }
58
-
59
- if (results || minimatch(resolvedPath, slashed)) {
60
- return {
61
- keys,
62
- results
63
- };
64
- }
65
-
66
- return null;
67
- };
68
-
69
- const toTarget = (source, destination, previousPath) => {
70
- const matches = sourceMatches(source, previousPath, true);
71
-
72
- if (!matches) {
73
- return null;
74
- }
75
-
76
- const {keys, results} = matches;
77
-
78
- const props = {};
79
- const {protocol} = url.parse(destination);
80
- const normalizedDest = protocol ? destination : slasher(destination);
81
- const toPath = pathToRegExp.compile(normalizedDest);
82
-
83
- for (let index = 0; index < keys.length; index++) {
84
- const {name} = keys[index];
85
- props[name] = results[index + 1];
86
- }
87
-
88
- return toPath(props);
89
- };
90
-
91
- const applyRewrites = (requestPath, rewrites = [], repetitive) => {
92
- // We need to copy the array, since we're going to modify it.
93
- const rewritesCopy = rewrites.slice();
94
-
95
- // If the method was called again, the path was already rewritten
96
- // so we need to make sure to return it.
97
- const fallback = repetitive ? requestPath : null;
98
-
99
- if (rewritesCopy.length === 0) {
100
- return fallback;
101
- }
102
-
103
- for (let index = 0; index < rewritesCopy.length; index++) {
104
- const {source, destination} = rewrites[index];
105
- const target = toTarget(source, destination, requestPath);
106
-
107
- if (target) {
108
- // Remove rules that were already applied
109
- rewritesCopy.splice(index, 1);
110
-
111
- // Check if there are remaining ones to be applied
112
- return applyRewrites(slasher(target), rewritesCopy, true);
113
- }
114
- }
115
-
116
- return fallback;
117
- };
118
-
119
- const ensureSlashStart = target => (target.startsWith('/') ? target : `/${target}`);
120
-
121
- const shouldRedirect = (decodedPath, {redirects = [], trailingSlash}, cleanUrl) => {
122
- const slashing = typeof trailingSlash === 'boolean';
123
- const defaultType = 301;
124
- const matchHTML = /(\.html|\/index)$/g;
125
-
126
- if (redirects.length === 0 && !slashing && !cleanUrl) {
127
- return null;
128
- }
129
-
130
- // By stripping the HTML parts from the decoded
131
- // path *before* handling the trailing slash, we make
132
- // sure that only *one* redirect occurs if both
133
- // config options are used.
134
- if (cleanUrl && matchHTML.test(decodedPath)) {
135
- decodedPath = decodedPath.replace(matchHTML, '');
136
- if (decodedPath.indexOf('//') > -1) {
137
- decodedPath = decodedPath.replace(/\/+/g, '/');
138
- }
139
- return {
140
- target: ensureSlashStart(decodedPath),
141
- statusCode: defaultType
142
- };
143
- }
144
-
145
- if (slashing) {
146
- const {ext, name} = path.parse(decodedPath);
147
- const isTrailed = decodedPath.endsWith('/');
148
- const isDotfile = name.startsWith('.');
149
-
150
- let target = null;
151
-
152
- if (!trailingSlash && isTrailed) {
153
- target = decodedPath.slice(0, -1);
154
- } else if (trailingSlash && !isTrailed && !ext && !isDotfile) {
155
- target = `${decodedPath}/`;
156
- }
157
-
158
- if (decodedPath.indexOf('//') > -1) {
159
- target = decodedPath.replace(/\/+/g, '/');
160
- }
161
-
162
- if (target) {
163
- return {
164
- target: ensureSlashStart(target),
165
- statusCode: defaultType
166
- };
167
- }
168
- }
169
-
170
- // This is currently the fastest way to
171
- // iterate over an array
172
- for (let index = 0; index < redirects.length; index++) {
173
- const {source, destination, type} = redirects[index];
174
- const target = toTarget(source, destination, decodedPath);
175
-
176
- if (target) {
177
- return {
178
- target,
179
- statusCode: type || defaultType
180
- };
181
- }
182
- }
183
-
184
- return null;
185
- };
186
-
187
- const appendHeaders = (target, source) => {
188
- for (let index = 0; index < source.length; index++) {
189
- const {key, value} = source[index];
190
- target[key] = value;
191
- }
192
- };
193
-
194
- const getHeaders = async (handlers, config, current, absolutePath, stats) => {
195
- const {headers: customHeaders = [], etag = false} = config;
196
- const related = {};
197
- const {base} = path.parse(absolutePath);
198
- const relativePath = path.relative(current, absolutePath);
199
-
200
- if (customHeaders.length > 0) {
201
- // By iterating over all headers and never stopping, developers
202
- // can specify multiple header sources in the config that
203
- // might match a single path.
204
- for (let index = 0; index < customHeaders.length; index++) {
205
- const {source, headers} = customHeaders[index];
206
-
207
- if (sourceMatches(source, slasher(relativePath))) {
208
- appendHeaders(related, headers);
209
- }
210
- }
211
- }
212
-
213
- let defaultHeaders = {};
214
-
215
- if (stats) {
216
- defaultHeaders = {
217
- 'Content-Length': stats.size,
218
- // Default to "inline", which always tries to render in the browser,
219
- // if that's not working, it will save the file. But to be clear: This
220
- // only happens if it cannot find a appropiate value.
221
- 'Content-Disposition': contentDisposition(base, {
222
- type: 'inline'
223
- }),
224
- 'Accept-Ranges': 'bytes'
225
- };
226
-
227
- if (etag) {
228
- let [mtime, sha] = etags.get(absolutePath) || [];
229
- if (Number(mtime) !== Number(stats.mtime)) {
230
- sha = await calculateSha(handlers, absolutePath);
231
- etags.set(absolutePath, [stats.mtime, sha]);
232
- }
233
- defaultHeaders['ETag'] = `"${sha}"`;
234
- } else {
235
- defaultHeaders['Last-Modified'] = stats.mtime.toUTCString();
236
- }
237
-
238
- const contentType = mime.contentType(base);
239
-
240
- if (contentType) {
241
- defaultHeaders['Content-Type'] = contentType;
242
- }
243
- }
244
-
245
- const headers = Object.assign(defaultHeaders, related);
246
-
247
- for (const key in headers) {
248
- if (headers.hasOwnProperty(key) && headers[key] === null) {
249
- delete headers[key];
250
- }
251
- }
252
-
253
- return headers;
254
- };
255
-
256
- const applicable = (decodedPath, configEntry) => {
257
- if (typeof configEntry === 'boolean') {
258
- return configEntry;
259
- }
260
-
261
- if (Array.isArray(configEntry)) {
262
- for (let index = 0; index < configEntry.length; index++) {
263
- const source = configEntry[index];
264
-
265
- if (sourceMatches(source, decodedPath)) {
266
- return true;
267
- }
268
- }
269
-
270
- return false;
271
- }
272
-
273
- return true;
274
- };
275
-
276
- const getPossiblePaths = (relativePath, extension) => [
277
- path.join(relativePath, `index${extension}`),
278
- relativePath.endsWith('/') ? relativePath.replace(/\/$/g, extension) : (relativePath + extension)
279
- ].filter(item => path.basename(item) !== extension);
280
-
281
- const findRelated = async (current, relativePath, rewrittenPath, originalStat) => {
282
- const possible = rewrittenPath ? [rewrittenPath] : getPossiblePaths(relativePath, '.html');
283
-
284
- let stats = null;
285
-
286
- for (let index = 0; index < possible.length; index++) {
287
- const related = possible[index];
288
- const absolutePath = path.join(current, related);
289
-
290
- try {
291
- stats = await originalStat(absolutePath);
292
- } catch (err) {
293
- if (err.code !== 'ENOENT' && err.code !== 'ENOTDIR') {
294
- throw err;
295
- }
296
- }
297
-
298
- if (stats) {
299
- return {
300
- stats,
301
- absolutePath
302
- };
303
- }
304
- }
305
-
306
- return null;
307
- };
308
-
309
- const canBeListed = (excluded, file) => {
310
- const slashed = slasher(file);
311
- let whether = true;
312
-
313
- for (let mark = 0; mark < excluded.length; mark++) {
314
- const source = excluded[mark];
315
-
316
- if (sourceMatches(source, slashed)) {
317
- whether = false;
318
- break;
319
- }
320
- }
321
-
322
- return whether;
323
- };
324
-
325
- const renderDirectory = async (current, acceptsJSON, handlers, methods, config, paths) => {
326
- const {directoryListing, trailingSlash, unlisted = [], renderSingle} = config;
327
- const slashSuffix = typeof trailingSlash === 'boolean' ? (trailingSlash ? '/' : '') : '/';
328
- const {relativePath, absolutePath} = paths;
329
-
330
- const excluded = [
331
- '.DS_Store',
332
- '.git',
333
- ...unlisted
334
- ];
335
-
336
- if (!applicable(relativePath, directoryListing) && !renderSingle) {
337
- return {};
338
- }
339
-
340
- let files = await handlers.readdir(absolutePath);
341
-
342
- const canRenderSingle = renderSingle && (files.length === 1);
343
-
344
- for (let index = 0; index < files.length; index++) {
345
- const file = files[index];
346
-
347
- const filePath = path.resolve(absolutePath, file);
348
- const details = path.parse(filePath);
349
-
350
- // It's important to indicate that the `stat` call was
351
- // spawned by the directory listing, as Now is
352
- // simulating those calls and needs to special-case this.
353
- let stats = null;
354
-
355
- if (methods.lstat) {
356
- stats = await handlers.lstat(filePath, true);
357
- } else {
358
- stats = await handlers.lstat(filePath);
359
- }
360
-
361
- details.relative = path.join(relativePath, details.base);
362
-
363
- if (stats.isDirectory()) {
364
- details.base += slashSuffix;
365
- details.relative += slashSuffix;
366
- details.type = 'folder';
367
- } else {
368
- if (canRenderSingle) {
369
- return {
370
- singleFile: true,
371
- absolutePath: filePath,
372
- stats
373
- };
374
- }
375
-
376
- details.ext = details.ext.split('.')[1] || 'txt';
377
- details.type = 'file';
378
-
379
- details.size = bytes(stats.size, {
380
- unitSeparator: ' ',
381
- decimalPlaces: 0
382
- });
383
- }
384
-
385
- details.title = details.base;
386
-
387
- if (canBeListed(excluded, file)) {
388
- files[index] = details;
389
- } else {
390
- delete files[index];
391
- }
392
- }
393
-
394
- const toRoot = path.relative(current, absolutePath);
395
- const directory = path.join(path.basename(current), toRoot, slashSuffix);
396
- const pathParts = directory.split(path.sep).filter(Boolean);
397
-
398
- // Sort to list directories first, then sort alphabetically
399
- files = files.sort((a, b) => {
400
- const aIsDir = a.type === 'directory';
401
- const bIsDir = b.type === 'directory';
402
-
403
- /* istanbul ignore next */
404
- if (aIsDir && !bIsDir) {
405
- return -1;
406
- }
407
-
408
- if ((bIsDir && !aIsDir) || (a.base > b.base)) {
409
- return 1;
410
- }
411
-
412
- /* istanbul ignore next */
413
- if (a.base < b.base) {
414
- return -1;
415
- }
416
-
417
- /* istanbul ignore next */
418
- return 0;
419
- }).filter(Boolean);
420
-
421
- // Add parent directory to the head of the sorted files array
422
- if (toRoot.length > 0) {
423
- const directoryPath = [...pathParts].slice(1);
424
- const relative = path.join('/', ...directoryPath, '..', slashSuffix);
425
-
426
- files.unshift({
427
- type: 'directory',
428
- base: '..',
429
- relative,
430
- title: relative,
431
- ext: ''
432
- });
433
- }
434
-
435
- const subPaths = [];
436
-
437
- for (let index = 0; index < pathParts.length; index++) {
438
- const parents = [];
439
- const isLast = index === (pathParts.length - 1);
440
-
441
- let before = 0;
442
-
443
- while (before <= index) {
444
- parents.push(pathParts[before]);
445
- before++;
446
- }
447
-
448
- parents.shift();
449
-
450
- subPaths.push({
451
- name: pathParts[index] + (isLast ? slashSuffix : '/'),
452
- url: index === 0 ? '' : parents.join('/') + slashSuffix
453
- });
454
- }
455
-
456
- const spec = {
457
- files,
458
- directory,
459
- paths: subPaths
460
- };
461
-
462
- const output = acceptsJSON ? JSON.stringify(spec) : directoryTemplate(spec);
463
-
464
- return {directory: output};
465
- };
466
-
467
- const sendError = async (absolutePath, response, acceptsJSON, current, handlers, config, spec) => {
468
- const {err: original, message, code, statusCode} = spec;
469
-
470
- /* istanbul ignore next */
471
- if (original && process.env.NODE_ENV !== 'test') {
472
- console.error(original);
473
- }
474
-
475
- response.statusCode = statusCode;
476
-
477
- if (acceptsJSON) {
478
- response.setHeader('Content-Type', 'application/json; charset=utf-8');
479
-
480
- response.end(JSON.stringify({
481
- error: {
482
- code,
483
- message
484
- }
485
- }));
486
-
487
- return;
488
- }
489
-
490
- let stats = null;
491
-
492
- const errorPage = path.join(current, `${statusCode}.html`);
493
-
494
- try {
495
- stats = await handlers.lstat(errorPage);
496
- } catch (err) {
497
- if (err.code !== 'ENOENT') {
498
- console.error(err);
499
- }
500
- }
501
-
502
- if (stats) {
503
- let stream = null;
504
-
505
- try {
506
- stream = await handlers.createReadStream(errorPage);
507
-
508
- const headers = await getHeaders(handlers, config, current, errorPage, stats);
509
-
510
- response.writeHead(statusCode, headers);
511
- stream.pipe(response);
512
-
513
- return;
514
- } catch (err) {
515
- console.error(err);
516
- }
517
- }
518
-
519
- const headers = await getHeaders(handlers, config, current, absolutePath, null);
520
- headers['Content-Type'] = 'text/html; charset=utf-8';
521
-
522
- response.writeHead(statusCode, headers);
523
- response.end(errorTemplate({statusCode, message}));
524
- };
525
-
526
- const internalError = async (...args) => {
527
- const lastIndex = args.length - 1;
528
- const err = args[lastIndex];
529
-
530
- args[lastIndex] = {
531
- statusCode: 500,
532
- code: 'internal_server_error',
533
- message: 'A server error has occurred',
534
- err
535
- };
536
-
537
- return sendError(...args);
538
- };
539
-
540
- const getHandlers = methods => Object.assign({
541
- lstat: promisify(lstat),
542
- realpath: promisify(realpath),
543
- createReadStream,
544
- readdir: promisify(readdir),
545
- sendError
546
- }, methods);
547
-
548
- module.exports = async (request, response, config = {}, methods = {}) => {
549
- const cwd = process.cwd();
550
- const current = config.public ? path.resolve(cwd, config.public) : cwd;
551
- const handlers = getHandlers(methods);
552
-
553
- let relativePath = null;
554
- let acceptsJSON = null;
555
-
556
- if (request.headers.accept) {
557
- acceptsJSON = request.headers.accept.includes('application/json');
558
- }
559
-
560
- try {
561
- relativePath = decodeURIComponent(url.parse(request.url).pathname);
562
- } catch (err) {
563
- return sendError('/', response, acceptsJSON, current, handlers, config, {
564
- statusCode: 400,
565
- code: 'bad_request',
566
- message: 'Bad Request'
567
- });
568
- }
569
-
570
- let absolutePath = path.join(current, relativePath);
571
-
572
- // Prevent path traversal vulnerabilities. We could do this
573
- // by ourselves, but using the package covers all the edge cases.
574
- if (!isPathInside(absolutePath, current)) {
575
- return sendError(absolutePath, response, acceptsJSON, current, handlers, config, {
576
- statusCode: 400,
577
- code: 'bad_request',
578
- message: 'Bad Request'
579
- });
580
- }
581
-
582
- const cleanUrl = applicable(relativePath, config.cleanUrls);
583
- const redirect = shouldRedirect(relativePath, config, cleanUrl);
584
-
585
- if (redirect) {
586
- response.writeHead(redirect.statusCode, {
587
- Location: encodeURI(redirect.target)
588
- });
589
-
590
- response.end();
591
- return;
592
- }
593
-
594
- let stats = null;
595
-
596
- // It's extremely important that we're doing multiple stat calls. This one
597
- // right here could technically be removed, but then the program
598
- // would be slower. Because for directories, we always want to see if a related file
599
- // exists and then (after that), fetch the directory itself if no
600
- // related file was found. However (for files, of which most have extensions), we should
601
- // always stat right away.
602
- //
603
- // When simulating a file system without directory indexes, calculating whether a
604
- // directory exists requires loading all the file paths and then checking if
605
- // one of them includes the path of the directory. As that's a very
606
- // performance-expensive thing to do, we need to ensure it's not happening if not really necessary.
607
-
608
- if (path.extname(relativePath) !== '') {
609
- try {
610
- stats = await handlers.lstat(absolutePath);
611
- } catch (err) {
612
- if (err.code !== 'ENOENT' && err.code !== 'ENOTDIR') {
613
- return internalError(absolutePath, response, acceptsJSON, current, handlers, config, err);
614
- }
615
- }
616
- }
617
-
618
- const rewrittenPath = applyRewrites(relativePath, config.rewrites);
619
-
620
- if (!stats && (cleanUrl || rewrittenPath)) {
621
- try {
622
- const related = await findRelated(current, relativePath, rewrittenPath, handlers.lstat);
623
-
624
- if (related) {
625
- ({stats, absolutePath} = related);
626
- }
627
- } catch (err) {
628
- if (err.code !== 'ENOENT' && err.code !== 'ENOTDIR') {
629
- return internalError(absolutePath, response, acceptsJSON, current, handlers, config, err);
630
- }
631
- }
632
- }
633
-
634
- if (!stats) {
635
- try {
636
- stats = await handlers.lstat(absolutePath);
637
- } catch (err) {
638
- if (err.code !== 'ENOENT' && err.code !== 'ENOTDIR') {
639
- return internalError(absolutePath, response, acceptsJSON, current, handlers, config, err);
640
- }
641
- }
642
- }
643
-
644
- if (stats && stats.isDirectory()) {
645
- let directory = null;
646
- let singleFile = null;
647
-
648
- try {
649
- const related = await renderDirectory(current, acceptsJSON, handlers, methods, config, {
650
- relativePath,
651
- absolutePath
652
- });
653
-
654
- if (related.singleFile) {
655
- ({stats, absolutePath, singleFile} = related);
656
- } else {
657
- ({directory} = related);
658
- }
659
- } catch (err) {
660
- if (err.code !== 'ENOENT') {
661
- return internalError(absolutePath, response, acceptsJSON, current, handlers, config, err);
662
- }
663
- }
664
-
665
- if (directory) {
666
- const contentType = acceptsJSON ? 'application/json; charset=utf-8' : 'text/html; charset=utf-8';
667
-
668
- response.statusCode = 200;
669
- response.setHeader('Content-Type', contentType);
670
- response.end(directory);
671
-
672
- return;
673
- }
674
-
675
- if (!singleFile) {
676
- // The directory listing is disabled, so we want to
677
- // render a 404 error.
678
- stats = null;
679
- }
680
- }
681
-
682
- const isSymLink = stats && stats.isSymbolicLink();
683
-
684
- // There are two scenarios in which we want to reply with
685
- // a 404 error: Either the path does not exist, or it is a
686
- // symlink while the `symlinks` option is disabled (which it is by default).
687
- if (!stats || (!config.symlinks && isSymLink)) {
688
- // allow for custom 404 handling
689
- return handlers.sendError(absolutePath, response, acceptsJSON, current, handlers, config, {
690
- statusCode: 404,
691
- code: 'not_found',
692
- message: 'The requested path could not be found'
693
- });
694
- }
695
-
696
- // If we figured out that the target is a symlink, we need to
697
- // resolve the symlink and run a new `stat` call just for the
698
- // target of that symlink.
699
- if (isSymLink) {
700
- try {
701
- absolutePath = await handlers.realpath(absolutePath);
702
- } catch (err) {
703
- if (err.code !== 'ENOENT') {
704
- throw err;
705
- }
706
-
707
- // The requested symlink is invalid
708
- return handlers.sendError(absolutePath, response, acceptsJSON, current, handlers, config, {
709
- statusCode: 404,
710
- code: 'not_found',
711
- message: 'The requested path could not be found'
712
- });
713
- }
714
- stats = await handlers.lstat(absolutePath);
715
- }
716
-
717
- const streamOpts = {};
718
-
719
- // TODO ? if-range
720
- if (request.headers.range && stats.size) {
721
- const range = parseRange(stats.size, request.headers.range);
722
-
723
- if (typeof range === 'object' && range.type === 'bytes') {
724
- const {start, end} = range[0];
725
-
726
- streamOpts.start = start;
727
- streamOpts.end = end;
728
-
729
- response.statusCode = 206;
730
- } else {
731
- response.statusCode = 416;
732
- response.setHeader('Content-Range', `bytes */${stats.size}`);
733
- }
734
- }
735
-
736
- // TODO ? multiple ranges
737
-
738
- let stream = null;
739
-
740
- try {
741
- stream = await handlers.createReadStream(absolutePath, streamOpts);
742
- } catch (err) {
743
- return internalError(absolutePath, response, acceptsJSON, current, handlers, config, err);
744
- }
745
-
746
- const headers = await getHeaders(handlers, config, current, absolutePath, stats);
747
-
748
- // eslint-disable-next-line no-undefined
749
- if (streamOpts.start !== undefined && streamOpts.end !== undefined) {
750
- headers['Content-Range'] = `bytes ${streamOpts.start}-${streamOpts.end}/${stats.size}`;
751
- headers['Content-Length'] = streamOpts.end - streamOpts.start + 1;
752
- }
753
-
754
- // We need to check for `headers.ETag` being truthy first, otherwise it will
755
- // match `undefined` being equal to `undefined`, which is true.
756
- //
757
- // Checking for `undefined` and `null` is also important, because `Range` can be `0`.
758
- //
759
- // eslint-disable-next-line no-eq-null
760
- if (request.headers.range == null && headers.ETag && headers.ETag === request.headers['if-none-match']) {
761
- response.statusCode = 304;
762
- response.end();
763
-
764
- return;
765
- }
766
-
767
- response.writeHead(response.statusCode || 200, headers);
768
- stream.pipe(response);
769
- };