orcaq 1.0.26 → 1.0.28

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 (1434) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/-lZvfnzr.js +1 -0
  3. package/.output/public/_nuxt/ACi_yrrw.js +1 -0
  4. package/.output/public/_nuxt/AgentWorkspace.67IpTcyl.css +1 -0
  5. package/.output/public/_nuxt/B-E3EDXq.js +21 -0
  6. package/.output/public/_nuxt/B-o1cyu1.js +1 -0
  7. package/.output/public/_nuxt/B-rj9QI0.js +1 -0
  8. package/.output/public/_nuxt/B0pvfm-W.js +1 -0
  9. package/.output/public/_nuxt/B3XOCDJg.js +1 -0
  10. package/.output/public/_nuxt/B7iORLht.js +8 -0
  11. package/.output/public/_nuxt/B9xm8XSJ.js +1 -0
  12. package/.output/public/_nuxt/BDPGejuO.js +2 -0
  13. package/.output/public/_nuxt/BHFnD9yO.js +1 -0
  14. package/.output/public/_nuxt/BHp-OX9z.js +1 -0
  15. package/.output/public/_nuxt/BIW9Rd2L.js +1 -0
  16. package/.output/public/_nuxt/BJdgR-zN.js +1 -0
  17. package/.output/public/_nuxt/BKltSiU0.js +1 -0
  18. package/.output/public/_nuxt/BQAF7cM_.js +53 -0
  19. package/.output/public/_nuxt/BRpeq4XL.js +1 -0
  20. package/.output/public/_nuxt/BSs5g8DH.js +1 -0
  21. package/.output/public/_nuxt/BUuSKT2f.js +152 -0
  22. package/.output/public/_nuxt/BV4_2PzU.js +1 -0
  23. package/.output/public/_nuxt/BVmBXPoG.js +1 -0
  24. package/.output/public/_nuxt/BZEKLHO-.js +1 -0
  25. package/.output/public/_nuxt/BaseCodeEditor.SAr2eD8R.css +1 -0
  26. package/.output/public/_nuxt/BiOIaWuc.js +1 -0
  27. package/.output/public/_nuxt/BlWNlw-C.js +15 -0
  28. package/.output/public/_nuxt/BranJUWp.js +1 -0
  29. package/.output/public/_nuxt/BsnN2mQb.js +3 -0
  30. package/.output/public/_nuxt/BwddCgOY.js +1 -0
  31. package/.output/public/_nuxt/C26aAkUg.js +39 -0
  32. package/.output/public/_nuxt/CAcIcjka.js +9 -0
  33. package/.output/public/_nuxt/CO-m0olR.js +2 -0
  34. package/.output/public/_nuxt/CQNFvXDN.js +1 -0
  35. package/.output/public/_nuxt/CQQKPHb8.js +225 -0
  36. package/.output/public/_nuxt/CQr87mff.js +1 -0
  37. package/.output/public/_nuxt/C__Jz_zH.js +40 -0
  38. package/.output/public/_nuxt/CbjqLbgu.js +1 -0
  39. package/.output/public/_nuxt/CfblXyCF.js +1 -0
  40. package/.output/public/_nuxt/Cqe10li5.js +1 -0
  41. package/.output/public/_nuxt/CwtNS48a.js +1 -0
  42. package/.output/public/_nuxt/D4jtSPyP.js +3 -0
  43. package/.output/public/_nuxt/D8s-WG7x.js +1 -0
  44. package/.output/public/_nuxt/D9SCXF1G.js +1 -0
  45. package/.output/public/_nuxt/DAsY4LnG.js +1 -0
  46. package/.output/public/_nuxt/DM73sEXg.js +1 -0
  47. package/.output/public/_nuxt/DNmOzKte.js +1 -0
  48. package/.output/public/_nuxt/DdMwxl0I.js +1 -0
  49. package/.output/public/_nuxt/DfL_wWxk.js +1 -0
  50. package/.output/public/_nuxt/DftZZFKd.js +732 -0
  51. package/.output/public/_nuxt/DgPgl0Vt.js +39 -0
  52. package/.output/public/_nuxt/DpyvTVPg.js +8 -0
  53. package/.output/public/_nuxt/Ds4ET3BG.js +72 -0
  54. package/.output/public/_nuxt/Dwm3kp4S.js +3867 -0
  55. package/.output/public/_nuxt/DynamicTable.BW0D7NXb.css +1 -0
  56. package/.output/public/_nuxt/GqcI3eLm.js +67 -0
  57. package/.output/public/_nuxt/QuickQuery.CJ7tNjo4.css +1 -0
  58. package/.output/public/_nuxt/S6q6IfIg.js +6 -0
  59. package/.output/public/_nuxt/SzZsnvJ-.js +2 -0
  60. package/.output/public/_nuxt/T2yrk5P8.js +1 -0
  61. package/.output/public/_nuxt/UrLgZoyE.js +9 -0
  62. package/.output/public/_nuxt/W0T58tNs.js +1 -0
  63. package/.output/public/_nuxt/WrapperErdDiagram.DsE2QNGr.css +1 -0
  64. package/.output/public/_nuxt/Yzrsuije.js +1 -0
  65. package/.output/public/_nuxt/_fileId_.B3PtfMYN.css +1 -0
  66. package/.output/public/_nuxt/aKVabwds.js +1 -0
  67. package/.output/public/_nuxt/builds/latest.json +1 -1
  68. package/.output/public/_nuxt/builds/meta/1e32d709-950d-49a3-8d61-1b3385318747.json +1 -0
  69. package/.output/public/_nuxt/default.DC7ec2JI.css +1 -0
  70. package/.output/public/_nuxt/entry.Kia9TCip.css +1 -0
  71. package/.output/public/_nuxt/fuZLfV_i.js +1 -0
  72. package/.output/public/_nuxt/iDT-eQ46.js +1 -0
  73. package/.output/public/_nuxt/index.P0q-dO_S.css +1 -0
  74. package/.output/public/_nuxt/lN7hePE6.js +1 -0
  75. package/.output/public/_nuxt/logo.BsJ2Dfin.png +0 -0
  76. package/.output/public/_nuxt/mW-nBTJP.js +1 -0
  77. package/.output/public/_nuxt/rdXrKZa8.js +68 -0
  78. package/.output/public/_nuxt/vU5dtBjy.js +1 -0
  79. package/.output/public/logo-8-bits.svg +4 -0
  80. package/.output/server/chunks/_/create-adapter.mjs +68 -0
  81. package/.output/server/chunks/_/create-adapter.mjs.map +1 -0
  82. package/.output/server/chunks/_/database-error.mjs +53 -0
  83. package/.output/server/chunks/_/database-error.mjs.map +1 -0
  84. package/.output/server/chunks/_/database-roles.factory.mjs +737 -0
  85. package/.output/server/chunks/_/database-roles.factory.mjs.map +1 -0
  86. package/.output/server/chunks/_/db-connection.mjs +352 -0
  87. package/.output/server/chunks/_/db-connection.mjs.map +1 -0
  88. package/.output/server/chunks/_/error.mjs +25 -0
  89. package/.output/server/chunks/_/error.mjs.map +1 -0
  90. package/.output/server/chunks/_/functions.factory.mjs +174 -0
  91. package/.output/server/chunks/_/functions.factory.mjs.map +1 -0
  92. package/.output/server/chunks/_/instance-insights.factory.mjs +643 -0
  93. package/.output/server/chunks/_/instance-insights.factory.mjs.map +1 -0
  94. package/.output/server/chunks/_/metadata.factory.mjs +583 -0
  95. package/.output/server/chunks/_/metadata.factory.mjs.map +1 -0
  96. package/.output/server/chunks/_/query.factory.mjs +163 -0
  97. package/.output/server/chunks/_/query.factory.mjs.map +1 -0
  98. package/.output/server/chunks/_/tables.factory.mjs +788 -0
  99. package/.output/server/chunks/_/tables.factory.mjs.map +1 -0
  100. package/.output/server/chunks/_/views.factory.mjs +227 -0
  101. package/.output/server/chunks/_/views.factory.mjs.map +1 -0
  102. package/.output/server/chunks/build/client.manifest.mjs +565 -319
  103. package/.output/server/chunks/build/client.manifest.mjs.map +1 -1
  104. package/.output/server/chunks/nitro/nitro.mjs +717 -804
  105. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  106. package/.output/server/chunks/routes/api/ai/agent.mjs +1626 -0
  107. package/.output/server/chunks/routes/api/ai/agent.mjs.map +1 -0
  108. package/.output/server/chunks/routes/api/ai/chat.mjs +2 -2
  109. package/.output/server/chunks/routes/api/database-export/export-database.mjs +16 -5
  110. package/.output/server/chunks/routes/api/database-export/export-database.mjs.map +1 -1
  111. package/.output/server/chunks/routes/api/database-import/import-database.mjs +31 -5
  112. package/.output/server/chunks/routes/api/database-import/import-database.mjs.map +1 -1
  113. package/.output/server/chunks/routes/api/database-roles/create-role.mjs +13 -7
  114. package/.output/server/chunks/routes/api/database-roles/create-role.mjs.map +1 -1
  115. package/.output/server/chunks/routes/api/database-roles/delete-role.mjs +13 -7
  116. package/.output/server/chunks/routes/api/database-roles/delete-role.mjs.map +1 -1
  117. package/.output/server/chunks/routes/api/database-roles/get-databases-with-permissions.mjs +13 -7
  118. package/.output/server/chunks/routes/api/database-roles/get-databases-with-permissions.mjs.map +1 -1
  119. package/.output/server/chunks/routes/api/database-roles/get-databases.mjs +20 -9
  120. package/.output/server/chunks/routes/api/database-roles/get-databases.mjs.map +1 -1
  121. package/.output/server/chunks/routes/api/database-roles/get-permissions.mjs +13 -7
  122. package/.output/server/chunks/routes/api/database-roles/get-permissions.mjs.map +1 -1
  123. package/.output/server/chunks/routes/api/database-roles/get-role-inheritance.mjs +13 -7
  124. package/.output/server/chunks/routes/api/database-roles/get-role-inheritance.mjs.map +1 -1
  125. package/.output/server/chunks/routes/api/database-roles/get-role.mjs +13 -7
  126. package/.output/server/chunks/routes/api/database-roles/get-role.mjs.map +1 -1
  127. package/.output/server/chunks/routes/api/database-roles/get-roles.mjs +13 -7
  128. package/.output/server/chunks/routes/api/database-roles/get-roles.mjs.map +1 -1
  129. package/.output/server/chunks/routes/api/database-roles/get-schema-objects.mjs +13 -7
  130. package/.output/server/chunks/routes/api/database-roles/get-schema-objects.mjs.map +1 -1
  131. package/.output/server/chunks/routes/api/database-roles/get-schemas.mjs +13 -7
  132. package/.output/server/chunks/routes/api/database-roles/get-schemas.mjs.map +1 -1
  133. package/.output/server/chunks/routes/api/database-roles/grant-bulk-permissions.mjs +13 -7
  134. package/.output/server/chunks/routes/api/database-roles/grant-bulk-permissions.mjs.map +1 -1
  135. package/.output/server/chunks/routes/api/database-roles/grant-permission.mjs +13 -7
  136. package/.output/server/chunks/routes/api/database-roles/grant-permission.mjs.map +1 -1
  137. package/.output/server/chunks/routes/api/database-roles/revoke-permission.mjs +13 -7
  138. package/.output/server/chunks/routes/api/database-roles/revoke-permission.mjs.map +1 -1
  139. package/.output/server/chunks/routes/api/functions/definition.post.mjs +35 -0
  140. package/.output/server/chunks/routes/api/functions/definition.post.mjs.map +1 -0
  141. package/.output/server/chunks/routes/api/functions/delete.post.mjs +41 -0
  142. package/.output/server/chunks/routes/api/functions/delete.post.mjs.map +1 -0
  143. package/.output/server/chunks/routes/api/functions/overview.post.mjs +42 -0
  144. package/.output/server/chunks/routes/api/functions/overview.post.mjs.map +1 -0
  145. package/.output/server/chunks/routes/api/functions/rename.post.mjs +48 -0
  146. package/.output/server/chunks/routes/api/functions/rename.post.mjs.map +1 -0
  147. package/.output/server/chunks/routes/api/functions/signature.post.mjs +35 -0
  148. package/.output/server/chunks/routes/api/functions/signature.post.mjs.map +1 -0
  149. package/.output/server/chunks/routes/api/functions/update.post.mjs +45 -0
  150. package/.output/server/chunks/routes/api/functions/update.post.mjs.map +1 -0
  151. package/.output/server/chunks/routes/api/instance-insights/cancel-query.post.mjs +55 -0
  152. package/.output/server/chunks/routes/api/instance-insights/cancel-query.post.mjs.map +1 -0
  153. package/.output/server/chunks/routes/api/instance-insights/configuration.post.mjs +58 -0
  154. package/.output/server/chunks/routes/api/instance-insights/configuration.post.mjs.map +1 -0
  155. package/.output/server/chunks/routes/api/instance-insights/dashboard.post.mjs +55 -0
  156. package/.output/server/chunks/routes/api/instance-insights/dashboard.post.mjs.map +1 -0
  157. package/.output/server/chunks/routes/api/instance-insights/drop-slot.post.mjs +55 -0
  158. package/.output/server/chunks/routes/api/instance-insights/drop-slot.post.mjs.map +1 -0
  159. package/.output/server/chunks/routes/api/instance-insights/replication.post.mjs +55 -0
  160. package/.output/server/chunks/routes/api/instance-insights/replication.post.mjs.map +1 -0
  161. package/.output/server/chunks/routes/api/instance-insights/state.post.mjs +55 -0
  162. package/.output/server/chunks/routes/api/instance-insights/state.post.mjs.map +1 -0
  163. package/.output/server/chunks/routes/api/instance-insights/terminate-connection.post.mjs +55 -0
  164. package/.output/server/chunks/routes/api/instance-insights/terminate-connection.post.mjs.map +1 -0
  165. package/.output/server/chunks/routes/api/instance-insights/toggle-slot-status.post.mjs +60 -0
  166. package/.output/server/chunks/routes/api/instance-insights/toggle-slot-status.post.mjs.map +1 -0
  167. package/.output/server/chunks/routes/api/managment-connection/health-check.mjs +15 -4
  168. package/.output/server/chunks/routes/api/managment-connection/health-check.mjs.map +1 -1
  169. package/.output/server/chunks/routes/api/metadata/erd.post.mjs +34 -0
  170. package/.output/server/chunks/routes/api/metadata/erd.post.mjs.map +1 -0
  171. package/.output/server/chunks/routes/api/metadata/meta-data.post.mjs +36 -0
  172. package/.output/server/chunks/routes/api/metadata/meta-data.post.mjs.map +1 -0
  173. package/.output/server/chunks/routes/api/metadata/reverse-schemas.post.mjs +35 -0
  174. package/.output/server/chunks/routes/api/metadata/reverse-schemas.post.mjs.map +1 -0
  175. package/.output/server/chunks/routes/api/metrics/monitor.post.mjs +103 -0
  176. package/.output/server/chunks/routes/api/metrics/monitor.post.mjs.map +1 -0
  177. package/.output/server/chunks/routes/api/query/execute.post.mjs +46 -0
  178. package/.output/server/chunks/routes/api/query/execute.post.mjs.map +1 -0
  179. package/.output/server/chunks/routes/api/query/raw-execute-stream.post.mjs +44 -0
  180. package/.output/server/chunks/routes/api/query/raw-execute-stream.post.mjs.map +1 -0
  181. package/.output/server/chunks/routes/api/query/raw-execute.post.mjs +48 -0
  182. package/.output/server/chunks/routes/api/query/raw-execute.post.mjs.map +1 -0
  183. package/.output/server/chunks/routes/api/tables/bulk-delete.post.mjs +49 -0
  184. package/.output/server/chunks/routes/api/tables/bulk-delete.post.mjs.map +1 -0
  185. package/.output/server/chunks/routes/api/tables/bulk-update.post.mjs +50 -0
  186. package/.output/server/chunks/routes/api/tables/bulk-update.post.mjs.map +1 -0
  187. package/.output/server/chunks/routes/api/tables/ddl.post.mjs +32 -0
  188. package/.output/server/chunks/routes/api/tables/ddl.post.mjs.map +1 -0
  189. package/.output/server/chunks/routes/api/tables/export.post.mjs +47 -0
  190. package/.output/server/chunks/routes/api/tables/export.post.mjs.map +1 -0
  191. package/.output/server/chunks/routes/api/tables/indexes.post.mjs +32 -0
  192. package/.output/server/chunks/routes/api/tables/indexes.post.mjs.map +1 -0
  193. package/.output/server/chunks/routes/api/tables/meta.post.mjs +39 -0
  194. package/.output/server/chunks/routes/api/tables/meta.post.mjs.map +1 -0
  195. package/.output/server/chunks/routes/api/tables/overview.post.mjs +32 -0
  196. package/.output/server/chunks/routes/api/tables/overview.post.mjs.map +1 -0
  197. package/.output/server/chunks/routes/api/tables/rls.post.mjs +36 -0
  198. package/.output/server/chunks/routes/api/tables/rls.post.mjs.map +1 -0
  199. package/.output/server/chunks/routes/api/tables/rules.post.mjs +32 -0
  200. package/.output/server/chunks/routes/api/tables/rules.post.mjs.map +1 -0
  201. package/.output/server/chunks/routes/api/tables/size.post.mjs +32 -0
  202. package/.output/server/chunks/routes/api/tables/size.post.mjs.map +1 -0
  203. package/.output/server/chunks/routes/api/tables/structure.post.mjs +32 -0
  204. package/.output/server/chunks/routes/api/tables/structure.post.mjs.map +1 -0
  205. package/.output/server/chunks/routes/api/tables/triggers.post.mjs +32 -0
  206. package/.output/server/chunks/routes/api/tables/triggers.post.mjs.map +1 -0
  207. package/.output/server/chunks/routes/api/views/definition.post.mjs +27 -0
  208. package/.output/server/chunks/routes/api/views/definition.post.mjs.map +1 -0
  209. package/.output/server/chunks/routes/api/views/dependencies.post.mjs +27 -0
  210. package/.output/server/chunks/routes/api/views/dependencies.post.mjs.map +1 -0
  211. package/.output/server/chunks/routes/api/views/explain.post.mjs +29 -0
  212. package/.output/server/chunks/routes/api/views/explain.post.mjs.map +1 -0
  213. package/.output/server/chunks/routes/api/views/indexes.post.mjs +27 -0
  214. package/.output/server/chunks/routes/api/views/indexes.post.mjs.map +1 -0
  215. package/.output/server/chunks/routes/api/views/meta.post.mjs +27 -0
  216. package/.output/server/chunks/routes/api/views/meta.post.mjs.map +1 -0
  217. package/.output/server/chunks/routes/api/views/overview.post.mjs +27 -0
  218. package/.output/server/chunks/routes/api/views/overview.post.mjs.map +1 -0
  219. package/.output/server/chunks/routes/renderer.mjs +4 -4
  220. package/.output/server/chunks/virtual/_virtual_spa-template.mjs +1 -1
  221. package/.output/server/index.mjs +3 -3
  222. package/.output/server/node_modules/.nitro/@ai-sdk/provider-utils@4.0.19/dist/index.mjs +2756 -0
  223. package/.output/server/node_modules/.nitro/@ai-sdk/provider-utils@4.0.19/node_modules/@ai-sdk/provider/dist/index.mjs +404 -0
  224. package/.output/server/node_modules/.nitro/@ai-sdk/provider-utils@4.0.19/node_modules/@ai-sdk/provider/package.json +63 -0
  225. package/.output/server/node_modules/.nitro/@ai-sdk/provider-utils@4.0.19/package.json +81 -0
  226. package/.output/server/node_modules/.nitro/@ai-sdk/provider-utils@4.0.4/dist/index.mjs +2549 -0
  227. package/.output/server/node_modules/.nitro/@ai-sdk/provider-utils@4.0.4/node_modules/@ai-sdk/provider/dist/index.mjs +377 -0
  228. package/.output/server/node_modules/.nitro/@ai-sdk/provider-utils@4.0.4/node_modules/@ai-sdk/provider/package.json +57 -0
  229. package/.output/server/node_modules/.nitro/@ai-sdk/provider-utils@4.0.4/package.json +75 -0
  230. package/.output/server/node_modules/.nitro/@ai-sdk/provider@3.0.2/dist/index.mjs +377 -0
  231. package/.output/server/node_modules/.nitro/@ai-sdk/provider@3.0.2/package.json +57 -0
  232. package/.output/server/node_modules/.nitro/@ai-sdk/provider@3.0.8/dist/index.mjs +404 -0
  233. package/.output/server/node_modules/.nitro/@ai-sdk/provider@3.0.8/package.json +63 -0
  234. package/.output/server/node_modules/.nitro/debug@4.3.4/node_modules/ms/index.js +162 -0
  235. package/.output/server/node_modules/.nitro/debug@4.3.4/node_modules/ms/package.json +37 -0
  236. package/.output/server/node_modules/.nitro/debug@4.3.4/package.json +59 -0
  237. package/.output/server/node_modules/.nitro/debug@4.3.4/src/browser.js +269 -0
  238. package/.output/server/node_modules/.nitro/debug@4.3.4/src/common.js +274 -0
  239. package/.output/server/node_modules/.nitro/debug@4.3.4/src/index.js +10 -0
  240. package/.output/server/node_modules/.nitro/debug@4.3.4/src/node.js +263 -0
  241. package/.output/server/node_modules/.nitro/debug@4.4.0/node_modules/ms/index.js +162 -0
  242. package/.output/server/node_modules/.nitro/debug@4.4.0/node_modules/ms/package.json +38 -0
  243. package/.output/server/node_modules/.nitro/debug@4.4.0/package.json +65 -0
  244. package/.output/server/node_modules/.nitro/debug@4.4.0/src/browser.js +272 -0
  245. package/.output/server/node_modules/.nitro/debug@4.4.0/src/common.js +292 -0
  246. package/.output/server/node_modules/.nitro/debug@4.4.0/src/index.js +10 -0
  247. package/.output/server/node_modules/.nitro/debug@4.4.0/src/node.js +263 -0
  248. package/.output/server/node_modules/.nitro/ms@2.1.2/index.js +162 -0
  249. package/.output/server/node_modules/.nitro/ms@2.1.2/package.json +37 -0
  250. package/.output/server/node_modules/.nitro/ms@2.1.3/index.js +162 -0
  251. package/.output/server/node_modules/.nitro/ms@2.1.3/package.json +38 -0
  252. package/.output/server/node_modules/.nitro/pg-connection-string@2.6.2/index.js +112 -0
  253. package/.output/server/node_modules/.nitro/pg-connection-string@2.6.2/package.json +40 -0
  254. package/.output/server/node_modules/.nitro/pg-connection-string@2.7.0/index.js +112 -0
  255. package/.output/server/node_modules/.nitro/pg-connection-string@2.7.0/package.json +40 -0
  256. package/.output/server/node_modules/@ai-sdk/anthropic/node_modules/@ai-sdk/provider/dist/index.mjs +377 -0
  257. package/.output/server/node_modules/@ai-sdk/anthropic/node_modules/@ai-sdk/provider/package.json +57 -0
  258. package/.output/server/node_modules/@ai-sdk/anthropic/node_modules/@ai-sdk/provider-utils/dist/index.mjs +2549 -0
  259. package/.output/server/node_modules/@ai-sdk/anthropic/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs +377 -0
  260. package/.output/server/node_modules/@ai-sdk/anthropic/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/package.json +57 -0
  261. package/.output/server/node_modules/@ai-sdk/anthropic/node_modules/@ai-sdk/provider-utils/package.json +75 -0
  262. package/.output/server/node_modules/@ai-sdk/gateway/dist/index.mjs +539 -82
  263. package/.output/server/node_modules/@ai-sdk/gateway/node_modules/@ai-sdk/provider/dist/index.mjs +404 -0
  264. package/.output/server/node_modules/@ai-sdk/gateway/node_modules/@ai-sdk/provider/package.json +63 -0
  265. package/.output/server/node_modules/@ai-sdk/gateway/node_modules/@ai-sdk/provider-utils/dist/index.mjs +2756 -0
  266. package/.output/server/node_modules/@ai-sdk/gateway/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs +404 -0
  267. package/.output/server/node_modules/@ai-sdk/gateway/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/package.json +63 -0
  268. package/.output/server/node_modules/@ai-sdk/gateway/node_modules/@ai-sdk/provider-utils/package.json +81 -0
  269. package/.output/server/node_modules/@ai-sdk/gateway/package.json +16 -5
  270. package/.output/server/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider/dist/index.mjs +377 -0
  271. package/.output/server/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider/package.json +57 -0
  272. package/.output/server/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider-utils/dist/index.mjs +2549 -0
  273. package/.output/server/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs +377 -0
  274. package/.output/server/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/package.json +57 -0
  275. package/.output/server/node_modules/@ai-sdk/google/node_modules/@ai-sdk/provider-utils/package.json +75 -0
  276. package/.output/server/node_modules/@ai-sdk/openai/dist/index.mjs +1498 -961
  277. package/.output/server/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider/dist/index.mjs +404 -0
  278. package/.output/server/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider/package.json +63 -0
  279. package/.output/server/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider-utils/dist/index.mjs +2756 -0
  280. package/.output/server/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs +404 -0
  281. package/.output/server/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/package.json +63 -0
  282. package/.output/server/node_modules/@ai-sdk/openai/node_modules/@ai-sdk/provider-utils/package.json +81 -0
  283. package/.output/server/node_modules/@ai-sdk/openai/package.json +14 -5
  284. package/.output/server/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider/dist/index.mjs +377 -0
  285. package/.output/server/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider/package.json +57 -0
  286. package/.output/server/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider-utils/dist/index.mjs +2549 -0
  287. package/.output/server/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs +377 -0
  288. package/.output/server/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/package.json +57 -0
  289. package/.output/server/node_modules/@ai-sdk/openai-compatible/node_modules/@ai-sdk/provider-utils/package.json +75 -0
  290. package/.output/server/node_modules/@ai-sdk/provider/dist/index.mjs +32 -5
  291. package/.output/server/node_modules/@ai-sdk/provider/package.json +7 -1
  292. package/.output/server/node_modules/@ai-sdk/provider-utils/dist/index.mjs +231 -24
  293. package/.output/server/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs +404 -0
  294. package/.output/server/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/package.json +63 -0
  295. package/.output/server/node_modules/@ai-sdk/provider-utils/package.json +8 -2
  296. package/.output/server/node_modules/@ai-sdk/xai/node_modules/@ai-sdk/provider/dist/index.mjs +377 -0
  297. package/.output/server/node_modules/@ai-sdk/xai/node_modules/@ai-sdk/provider/package.json +57 -0
  298. package/.output/server/node_modules/@ai-sdk/xai/node_modules/@ai-sdk/provider-utils/dist/index.mjs +2549 -0
  299. package/.output/server/node_modules/@ai-sdk/xai/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs +377 -0
  300. package/.output/server/node_modules/@ai-sdk/xai/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/package.json +57 -0
  301. package/.output/server/node_modules/@ai-sdk/xai/node_modules/@ai-sdk/provider-utils/package.json +75 -0
  302. package/.output/server/node_modules/@iconify/utils/node_modules/debug/node_modules/ms/index.js +162 -0
  303. package/.output/server/node_modules/@iconify/utils/node_modules/debug/node_modules/ms/package.json +38 -0
  304. package/.output/server/node_modules/@iconify/utils/node_modules/debug/package.json +65 -0
  305. package/.output/server/node_modules/@iconify/utils/node_modules/debug/src/browser.js +272 -0
  306. package/.output/server/node_modules/@iconify/utils/node_modules/debug/src/common.js +292 -0
  307. package/.output/server/node_modules/@iconify/utils/node_modules/debug/src/index.js +10 -0
  308. package/.output/server/node_modules/@iconify/utils/node_modules/debug/src/node.js +263 -0
  309. package/.output/server/node_modules/@openrouter/ai-sdk-provider/dist/index.mjs +4656 -0
  310. package/.output/server/node_modules/@openrouter/ai-sdk-provider/package.json +82 -0
  311. package/.output/server/node_modules/ag-grid-community/dist/package/main.esm.mjs +50065 -0
  312. package/.output/server/node_modules/ag-grid-community/package.json +113 -0
  313. package/.output/server/node_modules/ai/dist/index.mjs +2069 -918
  314. package/.output/server/node_modules/ai/node_modules/@ai-sdk/provider/dist/index.mjs +404 -0
  315. package/.output/server/node_modules/ai/node_modules/@ai-sdk/provider/package.json +63 -0
  316. package/.output/server/node_modules/ai/node_modules/@ai-sdk/provider-utils/dist/index.mjs +2756 -0
  317. package/.output/server/node_modules/ai/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs +404 -0
  318. package/.output/server/node_modules/ai/node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/package.json +63 -0
  319. package/.output/server/node_modules/ai/node_modules/@ai-sdk/provider-utils/package.json +81 -0
  320. package/.output/server/node_modules/ai/package.json +15 -6
  321. package/.output/server/node_modules/asn1/lib/ber/errors.js +13 -0
  322. package/.output/server/node_modules/asn1/lib/ber/index.js +27 -0
  323. package/.output/server/node_modules/asn1/lib/ber/reader.js +262 -0
  324. package/.output/server/node_modules/asn1/lib/ber/types.js +36 -0
  325. package/.output/server/node_modules/asn1/lib/ber/writer.js +317 -0
  326. package/.output/server/node_modules/asn1/lib/index.js +20 -0
  327. package/.output/server/node_modules/asn1/package.json +31 -0
  328. package/.output/server/node_modules/bcrypt-pbkdf/index.js +556 -0
  329. package/.output/server/node_modules/bcrypt-pbkdf/package.json +15 -0
  330. package/.output/server/node_modules/colorette/index.cjs +218 -0
  331. package/.output/server/node_modules/colorette/package.json +39 -0
  332. package/.output/server/node_modules/debug/node_modules/ms/index.js +162 -0
  333. package/.output/server/node_modules/debug/node_modules/ms/package.json +38 -0
  334. package/.output/server/node_modules/file-saver/dist/FileSaver.min.js +3 -0
  335. package/.output/server/node_modules/file-saver/package.json +40 -0
  336. package/.output/server/node_modules/get-package-type/async.cjs +52 -0
  337. package/.output/server/node_modules/get-package-type/cache.cjs +3 -0
  338. package/.output/server/node_modules/get-package-type/index.cjs +7 -0
  339. package/.output/server/node_modules/get-package-type/is-node-modules.cjs +15 -0
  340. package/.output/server/node_modules/get-package-type/package.json +35 -0
  341. package/.output/server/node_modules/get-package-type/sync.cjs +42 -0
  342. package/.output/server/node_modules/knex/knex.js +23 -0
  343. package/.output/server/node_modules/knex/knex.mjs +11 -0
  344. package/.output/server/node_modules/knex/lib/builder-interface-augmenter.js +120 -0
  345. package/.output/server/node_modules/knex/lib/client.js +495 -0
  346. package/.output/server/node_modules/knex/lib/constants.js +61 -0
  347. package/.output/server/node_modules/knex/lib/dialects/better-sqlite3/index.js +77 -0
  348. package/.output/server/node_modules/knex/lib/dialects/cockroachdb/crdb-columncompiler.js +14 -0
  349. package/.output/server/node_modules/knex/lib/dialects/cockroachdb/crdb-querybuilder.js +11 -0
  350. package/.output/server/node_modules/knex/lib/dialects/cockroachdb/crdb-querycompiler.js +122 -0
  351. package/.output/server/node_modules/knex/lib/dialects/cockroachdb/crdb-tablecompiler.js +37 -0
  352. package/.output/server/node_modules/knex/lib/dialects/cockroachdb/crdb-viewcompiler.js +15 -0
  353. package/.output/server/node_modules/knex/lib/dialects/cockroachdb/index.js +86 -0
  354. package/.output/server/node_modules/knex/lib/dialects/index.js +34 -0
  355. package/.output/server/node_modules/knex/lib/dialects/mssql/index.js +500 -0
  356. package/.output/server/node_modules/knex/lib/dialects/mssql/mssql-formatter.js +34 -0
  357. package/.output/server/node_modules/knex/lib/dialects/mssql/query/mssql-querycompiler.js +601 -0
  358. package/.output/server/node_modules/knex/lib/dialects/mssql/schema/mssql-columncompiler.js +185 -0
  359. package/.output/server/node_modules/knex/lib/dialects/mssql/schema/mssql-compiler.js +91 -0
  360. package/.output/server/node_modules/knex/lib/dialects/mssql/schema/mssql-tablecompiler.js +378 -0
  361. package/.output/server/node_modules/knex/lib/dialects/mssql/schema/mssql-viewcompiler.js +55 -0
  362. package/.output/server/node_modules/knex/lib/dialects/mssql/transaction.js +176 -0
  363. package/.output/server/node_modules/knex/lib/dialects/mysql/index.js +206 -0
  364. package/.output/server/node_modules/knex/lib/dialects/mysql/query/mysql-querybuilder.js +14 -0
  365. package/.output/server/node_modules/knex/lib/dialects/mysql/query/mysql-querycompiler.js +292 -0
  366. package/.output/server/node_modules/knex/lib/dialects/mysql/schema/mysql-columncompiler.js +193 -0
  367. package/.output/server/node_modules/knex/lib/dialects/mysql/schema/mysql-compiler.js +60 -0
  368. package/.output/server/node_modules/knex/lib/dialects/mysql/schema/mysql-tablecompiler.js +405 -0
  369. package/.output/server/node_modules/knex/lib/dialects/mysql/schema/mysql-viewbuilder.js +21 -0
  370. package/.output/server/node_modules/knex/lib/dialects/mysql/schema/mysql-viewcompiler.js +15 -0
  371. package/.output/server/node_modules/knex/lib/dialects/mysql/transaction.js +46 -0
  372. package/.output/server/node_modules/knex/lib/dialects/mysql2/index.js +53 -0
  373. package/.output/server/node_modules/knex/lib/dialects/mysql2/transaction.js +44 -0
  374. package/.output/server/node_modules/knex/lib/dialects/oracle/index.js +92 -0
  375. package/.output/server/node_modules/knex/lib/dialects/oracle/query/oracle-querycompiler.js +343 -0
  376. package/.output/server/node_modules/knex/lib/dialects/oracle/schema/internal/incrementUtils.js +22 -0
  377. package/.output/server/node_modules/knex/lib/dialects/oracle/schema/internal/trigger.js +155 -0
  378. package/.output/server/node_modules/knex/lib/dialects/oracle/schema/oracle-columnbuilder.js +17 -0
  379. package/.output/server/node_modules/knex/lib/dialects/oracle/schema/oracle-columncompiler.js +126 -0
  380. package/.output/server/node_modules/knex/lib/dialects/oracle/schema/oracle-compiler.js +124 -0
  381. package/.output/server/node_modules/knex/lib/dialects/oracle/schema/oracle-tablecompiler.js +197 -0
  382. package/.output/server/node_modules/knex/lib/dialects/oracle/utils.js +106 -0
  383. package/.output/server/node_modules/knex/lib/dialects/oracledb/index.js +381 -0
  384. package/.output/server/node_modules/knex/lib/dialects/oracledb/query/oracledb-querycompiler.js +481 -0
  385. package/.output/server/node_modules/knex/lib/dialects/oracledb/schema/oracledb-columncompiler.js +61 -0
  386. package/.output/server/node_modules/knex/lib/dialects/oracledb/schema/oracledb-tablecompiler.js +19 -0
  387. package/.output/server/node_modules/knex/lib/dialects/oracledb/schema/oracledb-viewbuilder.js +13 -0
  388. package/.output/server/node_modules/knex/lib/dialects/oracledb/schema/oracledb-viewcompiler.js +19 -0
  389. package/.output/server/node_modules/knex/lib/dialects/oracledb/transaction.js +98 -0
  390. package/.output/server/node_modules/knex/lib/dialects/oracledb/utils.js +208 -0
  391. package/.output/server/node_modules/knex/lib/dialects/pgnative/index.js +60 -0
  392. package/.output/server/node_modules/knex/lib/dialects/postgres/execution/pg-transaction.js +19 -0
  393. package/.output/server/node_modules/knex/lib/dialects/postgres/index.js +361 -0
  394. package/.output/server/node_modules/knex/lib/dialects/postgres/query/pg-querybuilder.js +43 -0
  395. package/.output/server/node_modules/knex/lib/dialects/postgres/query/pg-querycompiler.js +400 -0
  396. package/.output/server/node_modules/knex/lib/dialects/postgres/schema/pg-columncompiler.js +156 -0
  397. package/.output/server/node_modules/knex/lib/dialects/postgres/schema/pg-compiler.js +138 -0
  398. package/.output/server/node_modules/knex/lib/dialects/postgres/schema/pg-tablecompiler.js +304 -0
  399. package/.output/server/node_modules/knex/lib/dialects/postgres/schema/pg-viewbuilder.js +21 -0
  400. package/.output/server/node_modules/knex/lib/dialects/postgres/schema/pg-viewcompiler.js +35 -0
  401. package/.output/server/node_modules/knex/lib/dialects/redshift/index.js +86 -0
  402. package/.output/server/node_modules/knex/lib/dialects/redshift/query/redshift-querycompiler.js +163 -0
  403. package/.output/server/node_modules/knex/lib/dialects/redshift/schema/redshift-columnbuilder.js +22 -0
  404. package/.output/server/node_modules/knex/lib/dialects/redshift/schema/redshift-columncompiler.js +67 -0
  405. package/.output/server/node_modules/knex/lib/dialects/redshift/schema/redshift-compiler.js +14 -0
  406. package/.output/server/node_modules/knex/lib/dialects/redshift/schema/redshift-tablecompiler.js +122 -0
  407. package/.output/server/node_modules/knex/lib/dialects/redshift/schema/redshift-viewcompiler.js +11 -0
  408. package/.output/server/node_modules/knex/lib/dialects/redshift/transaction.js +32 -0
  409. package/.output/server/node_modules/knex/lib/dialects/sqlite3/execution/sqlite-transaction.js +25 -0
  410. package/.output/server/node_modules/knex/lib/dialects/sqlite3/index.js +250 -0
  411. package/.output/server/node_modules/knex/lib/dialects/sqlite3/query/sqlite-querybuilder.js +33 -0
  412. package/.output/server/node_modules/knex/lib/dialects/sqlite3/query/sqlite-querycompiler.js +334 -0
  413. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/ddl.js +400 -0
  414. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/internal/compiler.js +327 -0
  415. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/internal/parser-combinator.js +161 -0
  416. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/internal/parser.js +638 -0
  417. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/internal/sqlite-ddl-operations.js +41 -0
  418. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/internal/tokenizer.js +38 -0
  419. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/internal/utils.js +12 -0
  420. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/sqlite-columncompiler.js +50 -0
  421. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/sqlite-compiler.js +80 -0
  422. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/sqlite-tablecompiler.js +347 -0
  423. package/.output/server/node_modules/knex/lib/dialects/sqlite3/schema/sqlite-viewcompiler.js +40 -0
  424. package/.output/server/node_modules/knex/lib/execution/batch-insert.js +51 -0
  425. package/.output/server/node_modules/knex/lib/execution/internal/delay.js +6 -0
  426. package/.output/server/node_modules/knex/lib/execution/internal/ensure-connection-callback.js +41 -0
  427. package/.output/server/node_modules/knex/lib/execution/internal/query-executioner.js +62 -0
  428. package/.output/server/node_modules/knex/lib/execution/runner.js +325 -0
  429. package/.output/server/node_modules/knex/lib/execution/transaction.js +413 -0
  430. package/.output/server/node_modules/knex/lib/formatter/formatterUtils.js +42 -0
  431. package/.output/server/node_modules/knex/lib/formatter/rawFormatter.js +84 -0
  432. package/.output/server/node_modules/knex/lib/formatter/wrappingFormatter.js +250 -0
  433. package/.output/server/node_modules/knex/lib/formatter.js +25 -0
  434. package/.output/server/node_modules/knex/lib/index.js +3 -0
  435. package/.output/server/node_modules/knex/lib/knex-builder/FunctionHelper.js +80 -0
  436. package/.output/server/node_modules/knex/lib/knex-builder/Knex.js +59 -0
  437. package/.output/server/node_modules/knex/lib/knex-builder/internal/config-resolver.js +57 -0
  438. package/.output/server/node_modules/knex/lib/knex-builder/internal/parse-connection.js +87 -0
  439. package/.output/server/node_modules/knex/lib/knex-builder/make-knex.js +345 -0
  440. package/.output/server/node_modules/knex/lib/logger.js +76 -0
  441. package/.output/server/node_modules/knex/lib/migrations/common/MigrationsLoader.js +36 -0
  442. package/.output/server/node_modules/knex/lib/migrations/migrate/MigrationGenerator.js +84 -0
  443. package/.output/server/node_modules/knex/lib/migrations/migrate/Migrator.js +599 -0
  444. package/.output/server/node_modules/knex/lib/migrations/migrate/migration-list-resolver.js +33 -0
  445. package/.output/server/node_modules/knex/lib/migrations/migrate/migrator-configuration-merger.js +58 -0
  446. package/.output/server/node_modules/knex/lib/migrations/migrate/sources/fs-migrations.js +74 -0
  447. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/cjs.stub +15 -0
  448. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/coffee.stub +13 -0
  449. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/eg.stub +14 -0
  450. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/js-schema.stub +22 -0
  451. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/js.stub +22 -0
  452. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/knexfile-coffee.stub +34 -0
  453. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/knexfile-eg.stub +43 -0
  454. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/knexfile-js.stub +47 -0
  455. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/knexfile-ls.stub +35 -0
  456. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/knexfile-ts.stub +47 -0
  457. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/ls.stub +14 -0
  458. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/mjs.stub +23 -0
  459. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/ts-schema.stub +21 -0
  460. package/.output/server/node_modules/knex/lib/migrations/migrate/stub/ts.stub +21 -0
  461. package/.output/server/node_modules/knex/lib/migrations/migrate/table-creator.js +77 -0
  462. package/.output/server/node_modules/knex/lib/migrations/migrate/table-resolver.js +27 -0
  463. package/.output/server/node_modules/knex/lib/migrations/seed/Seeder.js +137 -0
  464. package/.output/server/node_modules/knex/lib/migrations/seed/seeder-configuration-merger.js +60 -0
  465. package/.output/server/node_modules/knex/lib/migrations/seed/sources/fs-seeds.js +65 -0
  466. package/.output/server/node_modules/knex/lib/migrations/seed/stub/coffee.stub +9 -0
  467. package/.output/server/node_modules/knex/lib/migrations/seed/stub/eg.stub +11 -0
  468. package/.output/server/node_modules/knex/lib/migrations/seed/stub/js.stub +13 -0
  469. package/.output/server/node_modules/knex/lib/migrations/seed/stub/ls.stub +11 -0
  470. package/.output/server/node_modules/knex/lib/migrations/seed/stub/mjs.stub +12 -0
  471. package/.output/server/node_modules/knex/lib/migrations/seed/stub/ts.stub +13 -0
  472. package/.output/server/node_modules/knex/lib/migrations/util/fs.js +86 -0
  473. package/.output/server/node_modules/knex/lib/migrations/util/import-file.js +12 -0
  474. package/.output/server/node_modules/knex/lib/migrations/util/is-module-type.js +9 -0
  475. package/.output/server/node_modules/knex/lib/migrations/util/template.js +52 -0
  476. package/.output/server/node_modules/knex/lib/migrations/util/timestamp.js +14 -0
  477. package/.output/server/node_modules/knex/lib/query/analytic.js +52 -0
  478. package/.output/server/node_modules/knex/lib/query/constants.js +15 -0
  479. package/.output/server/node_modules/knex/lib/query/joinclause.js +270 -0
  480. package/.output/server/node_modules/knex/lib/query/method-constants.js +136 -0
  481. package/.output/server/node_modules/knex/lib/query/querybuilder.js +1793 -0
  482. package/.output/server/node_modules/knex/lib/query/querycompiler.js +1591 -0
  483. package/.output/server/node_modules/knex/lib/raw.js +139 -0
  484. package/.output/server/node_modules/knex/lib/ref.js +39 -0
  485. package/.output/server/node_modules/knex/lib/schema/builder.js +115 -0
  486. package/.output/server/node_modules/knex/lib/schema/columnbuilder.js +146 -0
  487. package/.output/server/node_modules/knex/lib/schema/columncompiler.js +307 -0
  488. package/.output/server/node_modules/knex/lib/schema/compiler.js +187 -0
  489. package/.output/server/node_modules/knex/lib/schema/internal/helpers.js +55 -0
  490. package/.output/server/node_modules/knex/lib/schema/tablebuilder.js +376 -0
  491. package/.output/server/node_modules/knex/lib/schema/tablecompiler.js +439 -0
  492. package/.output/server/node_modules/knex/lib/schema/viewbuilder.js +92 -0
  493. package/.output/server/node_modules/knex/lib/schema/viewcompiler.js +138 -0
  494. package/.output/server/node_modules/knex/lib/util/finally-mixin.js +13 -0
  495. package/.output/server/node_modules/knex/lib/util/helpers.js +95 -0
  496. package/.output/server/node_modules/knex/lib/util/is.js +32 -0
  497. package/.output/server/node_modules/knex/lib/util/nanoid.js +40 -0
  498. package/.output/server/node_modules/knex/lib/util/noop.js +1 -0
  499. package/.output/server/node_modules/knex/lib/util/save-async-stack.js +14 -0
  500. package/.output/server/node_modules/knex/lib/util/security.js +26 -0
  501. package/.output/server/node_modules/knex/lib/util/string.js +190 -0
  502. package/.output/server/node_modules/knex/lib/util/timeout.js +29 -0
  503. package/.output/server/node_modules/knex/node_modules/debug/node_modules/ms/index.js +162 -0
  504. package/.output/server/node_modules/knex/node_modules/debug/node_modules/ms/package.json +37 -0
  505. package/.output/server/node_modules/knex/node_modules/debug/package.json +59 -0
  506. package/.output/server/node_modules/knex/node_modules/debug/src/browser.js +269 -0
  507. package/.output/server/node_modules/knex/node_modules/debug/src/common.js +274 -0
  508. package/.output/server/node_modules/knex/node_modules/debug/src/index.js +10 -0
  509. package/.output/server/node_modules/knex/node_modules/debug/src/node.js +263 -0
  510. package/.output/server/node_modules/knex/node_modules/pg-connection-string/index.js +112 -0
  511. package/.output/server/node_modules/knex/node_modules/pg-connection-string/package.json +40 -0
  512. package/.output/server/node_modules/knex/package.json +267 -0
  513. package/.output/server/node_modules/lodash/_DataView.js +7 -0
  514. package/.output/server/node_modules/lodash/_Hash.js +32 -0
  515. package/.output/server/node_modules/lodash/_ListCache.js +32 -0
  516. package/.output/server/node_modules/lodash/_Map.js +7 -0
  517. package/.output/server/node_modules/lodash/_MapCache.js +32 -0
  518. package/.output/server/node_modules/lodash/_Promise.js +7 -0
  519. package/.output/server/node_modules/lodash/_Set.js +7 -0
  520. package/.output/server/node_modules/lodash/_SetCache.js +27 -0
  521. package/.output/server/node_modules/lodash/_Stack.js +27 -0
  522. package/.output/server/node_modules/lodash/_Symbol.js +6 -0
  523. package/.output/server/node_modules/lodash/_Uint8Array.js +6 -0
  524. package/.output/server/node_modules/lodash/_WeakMap.js +7 -0
  525. package/.output/server/node_modules/lodash/_apply.js +21 -0
  526. package/.output/server/node_modules/lodash/_arrayAggregator.js +22 -0
  527. package/.output/server/node_modules/lodash/_arrayEach.js +22 -0
  528. package/.output/server/node_modules/lodash/_arrayFilter.js +25 -0
  529. package/.output/server/node_modules/lodash/_arrayIncludes.js +17 -0
  530. package/.output/server/node_modules/lodash/_arrayIncludesWith.js +22 -0
  531. package/.output/server/node_modules/lodash/_arrayLikeKeys.js +49 -0
  532. package/.output/server/node_modules/lodash/_arrayMap.js +21 -0
  533. package/.output/server/node_modules/lodash/_arrayPush.js +20 -0
  534. package/.output/server/node_modules/lodash/_arrayReduce.js +26 -0
  535. package/.output/server/node_modules/lodash/_arraySome.js +23 -0
  536. package/.output/server/node_modules/lodash/_asciiToArray.js +12 -0
  537. package/.output/server/node_modules/lodash/_assignMergeValue.js +20 -0
  538. package/.output/server/node_modules/lodash/_assignValue.js +28 -0
  539. package/.output/server/node_modules/lodash/_assocIndexOf.js +21 -0
  540. package/.output/server/node_modules/lodash/_baseAggregator.js +21 -0
  541. package/.output/server/node_modules/lodash/_baseAssign.js +17 -0
  542. package/.output/server/node_modules/lodash/_baseAssignIn.js +17 -0
  543. package/.output/server/node_modules/lodash/_baseAssignValue.js +25 -0
  544. package/.output/server/node_modules/lodash/_baseClone.js +166 -0
  545. package/.output/server/node_modules/lodash/_baseCreate.js +30 -0
  546. package/.output/server/node_modules/lodash/_baseDelay.js +21 -0
  547. package/.output/server/node_modules/lodash/_baseDifference.js +67 -0
  548. package/.output/server/node_modules/lodash/_baseEach.js +14 -0
  549. package/.output/server/node_modules/lodash/_baseExtremum.js +32 -0
  550. package/.output/server/node_modules/lodash/_baseFilter.js +21 -0
  551. package/.output/server/node_modules/lodash/_baseFindIndex.js +24 -0
  552. package/.output/server/node_modules/lodash/_baseFlatten.js +38 -0
  553. package/.output/server/node_modules/lodash/_baseFor.js +16 -0
  554. package/.output/server/node_modules/lodash/_baseForOwn.js +16 -0
  555. package/.output/server/node_modules/lodash/_baseGet.js +24 -0
  556. package/.output/server/node_modules/lodash/_baseGetAllKeys.js +20 -0
  557. package/.output/server/node_modules/lodash/_baseGetTag.js +28 -0
  558. package/.output/server/node_modules/lodash/_baseGt.js +14 -0
  559. package/.output/server/node_modules/lodash/_baseHas.js +19 -0
  560. package/.output/server/node_modules/lodash/_baseHasIn.js +13 -0
  561. package/.output/server/node_modules/lodash/_baseIndexOf.js +20 -0
  562. package/.output/server/node_modules/lodash/_baseIsArguments.js +18 -0
  563. package/.output/server/node_modules/lodash/_baseIsEqual.js +28 -0
  564. package/.output/server/node_modules/lodash/_baseIsEqualDeep.js +83 -0
  565. package/.output/server/node_modules/lodash/_baseIsMap.js +18 -0
  566. package/.output/server/node_modules/lodash/_baseIsMatch.js +62 -0
  567. package/.output/server/node_modules/lodash/_baseIsNaN.js +12 -0
  568. package/.output/server/node_modules/lodash/_baseIsNative.js +47 -0
  569. package/.output/server/node_modules/lodash/_baseIsSet.js +18 -0
  570. package/.output/server/node_modules/lodash/_baseIsTypedArray.js +60 -0
  571. package/.output/server/node_modules/lodash/_baseIteratee.js +31 -0
  572. package/.output/server/node_modules/lodash/_baseKeys.js +30 -0
  573. package/.output/server/node_modules/lodash/_baseKeysIn.js +33 -0
  574. package/.output/server/node_modules/lodash/_baseMap.js +22 -0
  575. package/.output/server/node_modules/lodash/_baseMatches.js +22 -0
  576. package/.output/server/node_modules/lodash/_baseMatchesProperty.js +33 -0
  577. package/.output/server/node_modules/lodash/_baseMerge.js +42 -0
  578. package/.output/server/node_modules/lodash/_baseMergeDeep.js +94 -0
  579. package/.output/server/node_modules/lodash/_baseOrderBy.js +49 -0
  580. package/.output/server/node_modules/lodash/_basePickBy.js +30 -0
  581. package/.output/server/node_modules/lodash/_baseProperty.js +14 -0
  582. package/.output/server/node_modules/lodash/_basePropertyDeep.js +16 -0
  583. package/.output/server/node_modules/lodash/_basePropertyOf.js +14 -0
  584. package/.output/server/node_modules/lodash/_baseReduce.js +23 -0
  585. package/.output/server/node_modules/lodash/_baseRest.js +17 -0
  586. package/.output/server/node_modules/lodash/_baseSet.js +51 -0
  587. package/.output/server/node_modules/lodash/_baseSetToString.js +22 -0
  588. package/.output/server/node_modules/lodash/_baseSlice.js +31 -0
  589. package/.output/server/node_modules/lodash/_baseSome.js +22 -0
  590. package/.output/server/node_modules/lodash/_baseSortBy.js +21 -0
  591. package/.output/server/node_modules/lodash/_baseTimes.js +20 -0
  592. package/.output/server/node_modules/lodash/_baseToString.js +37 -0
  593. package/.output/server/node_modules/lodash/_baseTrim.js +19 -0
  594. package/.output/server/node_modules/lodash/_baseUnary.js +14 -0
  595. package/.output/server/node_modules/lodash/_baseUniq.js +72 -0
  596. package/.output/server/node_modules/lodash/_baseValues.js +19 -0
  597. package/.output/server/node_modules/lodash/_cacheHas.js +13 -0
  598. package/.output/server/node_modules/lodash/_castFunction.js +14 -0
  599. package/.output/server/node_modules/lodash/_castPath.js +21 -0
  600. package/.output/server/node_modules/lodash/_cloneArrayBuffer.js +16 -0
  601. package/.output/server/node_modules/lodash/_cloneBuffer.js +35 -0
  602. package/.output/server/node_modules/lodash/_cloneDataView.js +16 -0
  603. package/.output/server/node_modules/lodash/_cloneRegExp.js +17 -0
  604. package/.output/server/node_modules/lodash/_cloneSymbol.js +18 -0
  605. package/.output/server/node_modules/lodash/_cloneTypedArray.js +16 -0
  606. package/.output/server/node_modules/lodash/_compareAscending.js +41 -0
  607. package/.output/server/node_modules/lodash/_compareMultiple.js +44 -0
  608. package/.output/server/node_modules/lodash/_copyArray.js +20 -0
  609. package/.output/server/node_modules/lodash/_copyObject.js +40 -0
  610. package/.output/server/node_modules/lodash/_copySymbols.js +16 -0
  611. package/.output/server/node_modules/lodash/_copySymbolsIn.js +16 -0
  612. package/.output/server/node_modules/lodash/_coreJsData.js +6 -0
  613. package/.output/server/node_modules/lodash/_createAggregator.js +23 -0
  614. package/.output/server/node_modules/lodash/_createAssigner.js +37 -0
  615. package/.output/server/node_modules/lodash/_createBaseEach.js +32 -0
  616. package/.output/server/node_modules/lodash/_createBaseFor.js +25 -0
  617. package/.output/server/node_modules/lodash/_createSet.js +19 -0
  618. package/.output/server/node_modules/lodash/_customDefaultsAssignIn.js +29 -0
  619. package/.output/server/node_modules/lodash/_defineProperty.js +11 -0
  620. package/.output/server/node_modules/lodash/_equalArrays.js +84 -0
  621. package/.output/server/node_modules/lodash/_equalByTag.js +112 -0
  622. package/.output/server/node_modules/lodash/_equalObjects.js +90 -0
  623. package/.output/server/node_modules/lodash/_escapeHtmlChar.js +21 -0
  624. package/.output/server/node_modules/lodash/_escapeStringChar.js +22 -0
  625. package/.output/server/node_modules/lodash/_freeGlobal.js +4 -0
  626. package/.output/server/node_modules/lodash/_getAllKeys.js +16 -0
  627. package/.output/server/node_modules/lodash/_getAllKeysIn.js +17 -0
  628. package/.output/server/node_modules/lodash/_getMapData.js +18 -0
  629. package/.output/server/node_modules/lodash/_getMatchData.js +24 -0
  630. package/.output/server/node_modules/lodash/_getNative.js +17 -0
  631. package/.output/server/node_modules/lodash/_getPrototype.js +6 -0
  632. package/.output/server/node_modules/lodash/_getRawTag.js +46 -0
  633. package/.output/server/node_modules/lodash/_getSymbols.js +30 -0
  634. package/.output/server/node_modules/lodash/_getSymbolsIn.js +25 -0
  635. package/.output/server/node_modules/lodash/_getTag.js +58 -0
  636. package/.output/server/node_modules/lodash/_getValue.js +13 -0
  637. package/.output/server/node_modules/lodash/_hasPath.js +39 -0
  638. package/.output/server/node_modules/lodash/_hasUnicode.js +26 -0
  639. package/.output/server/node_modules/lodash/_hashClear.js +15 -0
  640. package/.output/server/node_modules/lodash/_hashDelete.js +17 -0
  641. package/.output/server/node_modules/lodash/_hashGet.js +30 -0
  642. package/.output/server/node_modules/lodash/_hashHas.js +23 -0
  643. package/.output/server/node_modules/lodash/_hashSet.js +23 -0
  644. package/.output/server/node_modules/lodash/_initCloneArray.js +26 -0
  645. package/.output/server/node_modules/lodash/_initCloneByTag.js +77 -0
  646. package/.output/server/node_modules/lodash/_initCloneObject.js +18 -0
  647. package/.output/server/node_modules/lodash/_isFlattenable.js +20 -0
  648. package/.output/server/node_modules/lodash/_isIndex.js +25 -0
  649. package/.output/server/node_modules/lodash/_isIterateeCall.js +30 -0
  650. package/.output/server/node_modules/lodash/_isKey.js +29 -0
  651. package/.output/server/node_modules/lodash/_isKeyable.js +15 -0
  652. package/.output/server/node_modules/lodash/_isMasked.js +20 -0
  653. package/.output/server/node_modules/lodash/_isPrototype.js +18 -0
  654. package/.output/server/node_modules/lodash/_isStrictComparable.js +15 -0
  655. package/.output/server/node_modules/lodash/_iteratorToArray.js +18 -0
  656. package/.output/server/node_modules/lodash/_listCacheClear.js +13 -0
  657. package/.output/server/node_modules/lodash/_listCacheDelete.js +35 -0
  658. package/.output/server/node_modules/lodash/_listCacheGet.js +19 -0
  659. package/.output/server/node_modules/lodash/_listCacheHas.js +16 -0
  660. package/.output/server/node_modules/lodash/_listCacheSet.js +26 -0
  661. package/.output/server/node_modules/lodash/_mapCacheClear.js +21 -0
  662. package/.output/server/node_modules/lodash/_mapCacheDelete.js +18 -0
  663. package/.output/server/node_modules/lodash/_mapCacheGet.js +16 -0
  664. package/.output/server/node_modules/lodash/_mapCacheHas.js +16 -0
  665. package/.output/server/node_modules/lodash/_mapCacheSet.js +22 -0
  666. package/.output/server/node_modules/lodash/_mapToArray.js +18 -0
  667. package/.output/server/node_modules/lodash/_matchesStrictComparable.js +20 -0
  668. package/.output/server/node_modules/lodash/_memoizeCapped.js +26 -0
  669. package/.output/server/node_modules/lodash/_nativeCreate.js +6 -0
  670. package/.output/server/node_modules/lodash/_nativeKeys.js +6 -0
  671. package/.output/server/node_modules/lodash/_nativeKeysIn.js +20 -0
  672. package/.output/server/node_modules/lodash/_nodeUtil.js +30 -0
  673. package/.output/server/node_modules/lodash/_objectToString.js +22 -0
  674. package/.output/server/node_modules/lodash/_overArg.js +15 -0
  675. package/.output/server/node_modules/lodash/_overRest.js +36 -0
  676. package/.output/server/node_modules/lodash/_reEscape.js +4 -0
  677. package/.output/server/node_modules/lodash/_reEvaluate.js +4 -0
  678. package/.output/server/node_modules/lodash/_reInterpolate.js +4 -0
  679. package/.output/server/node_modules/lodash/_root.js +9 -0
  680. package/.output/server/node_modules/lodash/_safeGet.js +21 -0
  681. package/.output/server/node_modules/lodash/_setCacheAdd.js +19 -0
  682. package/.output/server/node_modules/lodash/_setCacheHas.js +14 -0
  683. package/.output/server/node_modules/lodash/_setToArray.js +18 -0
  684. package/.output/server/node_modules/lodash/_setToString.js +14 -0
  685. package/.output/server/node_modules/lodash/_shortOut.js +37 -0
  686. package/.output/server/node_modules/lodash/_stackClear.js +15 -0
  687. package/.output/server/node_modules/lodash/_stackDelete.js +18 -0
  688. package/.output/server/node_modules/lodash/_stackGet.js +14 -0
  689. package/.output/server/node_modules/lodash/_stackHas.js +14 -0
  690. package/.output/server/node_modules/lodash/_stackSet.js +34 -0
  691. package/.output/server/node_modules/lodash/_strictIndexOf.js +23 -0
  692. package/.output/server/node_modules/lodash/_stringToArray.js +18 -0
  693. package/.output/server/node_modules/lodash/_stringToPath.js +27 -0
  694. package/.output/server/node_modules/lodash/_toKey.js +21 -0
  695. package/.output/server/node_modules/lodash/_toSource.js +26 -0
  696. package/.output/server/node_modules/lodash/_trimmedEndIndex.js +19 -0
  697. package/.output/server/node_modules/lodash/_unicodeToArray.js +40 -0
  698. package/.output/server/node_modules/lodash/assign.js +58 -0
  699. package/.output/server/node_modules/lodash/assignIn.js +40 -0
  700. package/.output/server/node_modules/lodash/assignInWith.js +38 -0
  701. package/.output/server/node_modules/lodash/attempt.js +35 -0
  702. package/.output/server/node_modules/lodash/chunk.js +50 -0
  703. package/.output/server/node_modules/lodash/clone.js +36 -0
  704. package/.output/server/node_modules/lodash/cloneDeep.js +29 -0
  705. package/.output/server/node_modules/lodash/compact.js +31 -0
  706. package/.output/server/node_modules/lodash/constant.js +26 -0
  707. package/.output/server/node_modules/lodash/defaults.js +64 -0
  708. package/.output/server/node_modules/lodash/defer.js +26 -0
  709. package/.output/server/node_modules/lodash/differenceWith.js +40 -0
  710. package/.output/server/node_modules/lodash/each.js +1 -0
  711. package/.output/server/node_modules/lodash/eq.js +37 -0
  712. package/.output/server/node_modules/lodash/escape.js +43 -0
  713. package/.output/server/node_modules/lodash/extend.js +1 -0
  714. package/.output/server/node_modules/lodash/filter.js +52 -0
  715. package/.output/server/node_modules/lodash/first.js +1 -0
  716. package/.output/server/node_modules/lodash/flatten.js +22 -0
  717. package/.output/server/node_modules/lodash/forEach.js +41 -0
  718. package/.output/server/node_modules/lodash/get.js +33 -0
  719. package/.output/server/node_modules/lodash/groupBy.js +41 -0
  720. package/.output/server/node_modules/lodash/has.js +35 -0
  721. package/.output/server/node_modules/lodash/hasIn.js +34 -0
  722. package/.output/server/node_modules/lodash/head.js +23 -0
  723. package/.output/server/node_modules/lodash/identity.js +21 -0
  724. package/.output/server/node_modules/lodash/includes.js +53 -0
  725. package/.output/server/node_modules/lodash/indexOf.js +42 -0
  726. package/.output/server/node_modules/lodash/isArguments.js +36 -0
  727. package/.output/server/node_modules/lodash/isArray.js +26 -0
  728. package/.output/server/node_modules/lodash/isArrayLike.js +33 -0
  729. package/.output/server/node_modules/lodash/isArrayLikeObject.js +33 -0
  730. package/.output/server/node_modules/lodash/isBuffer.js +38 -0
  731. package/.output/server/node_modules/lodash/isEmpty.js +77 -0
  732. package/.output/server/node_modules/lodash/isError.js +36 -0
  733. package/.output/server/node_modules/lodash/isFunction.js +37 -0
  734. package/.output/server/node_modules/lodash/isLength.js +35 -0
  735. package/.output/server/node_modules/lodash/isMap.js +27 -0
  736. package/.output/server/node_modules/lodash/isNil.js +25 -0
  737. package/.output/server/node_modules/lodash/isObject.js +31 -0
  738. package/.output/server/node_modules/lodash/isObjectLike.js +29 -0
  739. package/.output/server/node_modules/lodash/isPlainObject.js +62 -0
  740. package/.output/server/node_modules/lodash/isSet.js +27 -0
  741. package/.output/server/node_modules/lodash/isString.js +30 -0
  742. package/.output/server/node_modules/lodash/isSymbol.js +29 -0
  743. package/.output/server/node_modules/lodash/isTypedArray.js +27 -0
  744. package/.output/server/node_modules/lodash/keys.js +37 -0
  745. package/.output/server/node_modules/lodash/keysIn.js +32 -0
  746. package/.output/server/node_modules/lodash/last.js +20 -0
  747. package/.output/server/node_modules/lodash/map.js +53 -0
  748. package/.output/server/node_modules/lodash/max.js +29 -0
  749. package/.output/server/node_modules/lodash/memoize.js +73 -0
  750. package/.output/server/node_modules/lodash/merge.js +39 -0
  751. package/.output/server/node_modules/lodash/negate.js +40 -0
  752. package/.output/server/node_modules/lodash/noop.js +17 -0
  753. package/.output/server/node_modules/lodash/omitBy.js +29 -0
  754. package/.output/server/node_modules/lodash/package.json +19 -0
  755. package/.output/server/node_modules/lodash/pickBy.js +37 -0
  756. package/.output/server/node_modules/lodash/property.js +32 -0
  757. package/.output/server/node_modules/lodash/reduce.js +51 -0
  758. package/.output/server/node_modules/lodash/reject.js +46 -0
  759. package/.output/server/node_modules/lodash/some.js +51 -0
  760. package/.output/server/node_modules/lodash/sortBy.js +48 -0
  761. package/.output/server/node_modules/lodash/stubArray.js +23 -0
  762. package/.output/server/node_modules/lodash/stubFalse.js +18 -0
  763. package/.output/server/node_modules/lodash/tail.js +22 -0
  764. package/.output/server/node_modules/lodash/template.js +272 -0
  765. package/.output/server/node_modules/lodash/templateSettings.js +67 -0
  766. package/.output/server/node_modules/lodash/toArray.js +58 -0
  767. package/.output/server/node_modules/lodash/toFinite.js +42 -0
  768. package/.output/server/node_modules/lodash/toInteger.js +36 -0
  769. package/.output/server/node_modules/lodash/toNumber.js +64 -0
  770. package/.output/server/node_modules/lodash/toPlainObject.js +32 -0
  771. package/.output/server/node_modules/lodash/toString.js +28 -0
  772. package/.output/server/node_modules/lodash/transform.js +65 -0
  773. package/.output/server/node_modules/lodash/uniq.js +25 -0
  774. package/.output/server/node_modules/lodash/uniqueId.js +28 -0
  775. package/.output/server/node_modules/lodash/values.js +34 -0
  776. package/.output/server/node_modules/papaparse/package.json +58 -0
  777. package/.output/server/node_modules/papaparse/papaparse.js +1945 -0
  778. package/.output/server/node_modules/pg/node_modules/pg-connection-string/index.js +112 -0
  779. package/.output/server/node_modules/pg/node_modules/pg-connection-string/package.json +40 -0
  780. package/.output/server/node_modules/safer-buffer/package.json +34 -0
  781. package/.output/server/node_modules/safer-buffer/safer.js +77 -0
  782. package/.output/server/node_modules/ssh2/lib/Channel.js +295 -0
  783. package/.output/server/node_modules/ssh2/lib/agent.js +1123 -0
  784. package/.output/server/node_modules/ssh2/lib/client.js +2176 -0
  785. package/.output/server/node_modules/ssh2/lib/http-agents.js +84 -0
  786. package/.output/server/node_modules/ssh2/lib/index.js +44 -0
  787. package/.output/server/node_modules/ssh2/lib/keygen.js +582 -0
  788. package/.output/server/node_modules/ssh2/lib/protocol/Protocol.js +2136 -0
  789. package/.output/server/node_modules/ssh2/lib/protocol/SFTP.js +4052 -0
  790. package/.output/server/node_modules/ssh2/lib/protocol/constants.js +356 -0
  791. package/.output/server/node_modules/ssh2/lib/protocol/crypto/poly1305.js +43 -0
  792. package/.output/server/node_modules/ssh2/lib/protocol/crypto.js +1602 -0
  793. package/.output/server/node_modules/ssh2/lib/protocol/handlers.js +16 -0
  794. package/.output/server/node_modules/ssh2/lib/protocol/handlers.misc.js +1285 -0
  795. package/.output/server/node_modules/ssh2/lib/protocol/kex.js +1908 -0
  796. package/.output/server/node_modules/ssh2/lib/protocol/keyParser.js +1484 -0
  797. package/.output/server/node_modules/ssh2/lib/protocol/node-fs-compat.js +115 -0
  798. package/.output/server/node_modules/ssh2/lib/protocol/utils.js +356 -0
  799. package/.output/server/node_modules/ssh2/lib/protocol/zlib.js +255 -0
  800. package/.output/server/node_modules/ssh2/lib/server.js +1380 -0
  801. package/.output/server/node_modules/ssh2/lib/utils.js +336 -0
  802. package/.output/server/node_modules/ssh2/package.json +49 -0
  803. package/.output/server/node_modules/ssh2/util/pagent.exe +0 -0
  804. package/.output/server/node_modules/tarn/dist/PendingOperation.js +48 -0
  805. package/.output/server/node_modules/tarn/dist/Pool.js +516 -0
  806. package/.output/server/node_modules/tarn/dist/PromiseInspection.js +21 -0
  807. package/.output/server/node_modules/tarn/dist/Resource.js +19 -0
  808. package/.output/server/node_modules/tarn/dist/TimeoutError.js +5 -0
  809. package/.output/server/node_modules/tarn/dist/tarn.js +10 -0
  810. package/.output/server/node_modules/tarn/dist/utils.js +60 -0
  811. package/.output/server/node_modules/tarn/package.json +66 -0
  812. package/.output/server/node_modules/tweetnacl/nacl-fast.js +2388 -0
  813. package/.output/server/node_modules/tweetnacl/package.json +58 -0
  814. package/.output/server/package.json +20 -35
  815. package/package.json +1 -1
  816. package/.output/public/_nuxt/AKIL8y6B.js +0 -1
  817. package/.output/public/_nuxt/B5vWsFeq.js +0 -160
  818. package/.output/public/_nuxt/B7OaQ1wH.js +0 -8
  819. package/.output/public/_nuxt/BG-9_o0s.js +0 -3
  820. package/.output/public/_nuxt/BHnp06h8.js +0 -1
  821. package/.output/public/_nuxt/BKxFOGv6.js +0 -1
  822. package/.output/public/_nuxt/BNIRlgC1.js +0 -1
  823. package/.output/public/_nuxt/BNdHe5KI.js +0 -1
  824. package/.output/public/_nuxt/BQANhp-y.js +0 -1
  825. package/.output/public/_nuxt/BUYy1lWT.js +0 -215
  826. package/.output/public/_nuxt/Ber6tLDb.js +0 -1
  827. package/.output/public/_nuxt/BgEovngA.js +0 -1
  828. package/.output/public/_nuxt/BhgYrVrc.js +0 -6
  829. package/.output/public/_nuxt/BmnOz39b.js +0 -2
  830. package/.output/public/_nuxt/BuKJVBv4.js +0 -1
  831. package/.output/public/_nuxt/BxMjn94S.js +0 -4
  832. package/.output/public/_nuxt/C1dxTB9p.js +0 -39
  833. package/.output/public/_nuxt/C4mc67xO.js +0 -31
  834. package/.output/public/_nuxt/CAOPafml.js +0 -1
  835. package/.output/public/_nuxt/CPxn9ATh.js +0 -1
  836. package/.output/public/_nuxt/CQ_P7x7z.js +0 -3
  837. package/.output/public/_nuxt/CS9PCQVw.js +0 -6
  838. package/.output/public/_nuxt/CdEjcJco.js +0 -1
  839. package/.output/public/_nuxt/CeQk_zaG.js +0 -3867
  840. package/.output/public/_nuxt/CijEBUIh.js +0 -9
  841. package/.output/public/_nuxt/Cn-07UHL.js +0 -1
  842. package/.output/public/_nuxt/D4_A4fm4.js +0 -1
  843. package/.output/public/_nuxt/DAs4584G.js +0 -72
  844. package/.output/public/_nuxt/DBO1CAN4.js +0 -1
  845. package/.output/public/_nuxt/DF7Phtj8.js +0 -39
  846. package/.output/public/_nuxt/DMMO4O3Y.js +0 -1
  847. package/.output/public/_nuxt/DP-hoxaC.js +0 -1
  848. package/.output/public/_nuxt/DREcM-oC.js +0 -20
  849. package/.output/public/_nuxt/DX-rdvVh.js +0 -28
  850. package/.output/public/_nuxt/DXei3mDv.js +0 -1
  851. package/.output/public/_nuxt/DZcRPyDc.js +0 -26
  852. package/.output/public/_nuxt/D_QjJZ_n.js +0 -1
  853. package/.output/public/_nuxt/Dj2IVxO7.js +0 -1
  854. package/.output/public/_nuxt/DmMeuvwr.js +0 -1
  855. package/.output/public/_nuxt/DqlhGxxN.js +0 -32
  856. package/.output/public/_nuxt/DynamicTable.DJeANwbG.css +0 -1
  857. package/.output/public/_nuxt/GmXmO94-.js +0 -1
  858. package/.output/public/_nuxt/HPyUOgdi.js +0 -1
  859. package/.output/public/_nuxt/MdxV8r4v.js +0 -1
  860. package/.output/public/_nuxt/Mp6jDt1I.js +0 -1
  861. package/.output/public/_nuxt/QuickQuery.h4epNPla.css +0 -1
  862. package/.output/public/_nuxt/WrapperErdDiagram.DeMTjOwN.css +0 -1
  863. package/.output/public/_nuxt/Zvfofmwe.js +0 -1
  864. package/.output/public/_nuxt/_fileId_.BHiWIaF7.css +0 -1
  865. package/.output/public/_nuxt/builds/meta/db42d692-1628-4dd8-9442-d7621bdd9ac6.json +0 -1
  866. package/.output/public/_nuxt/cQYBDqKG.js +0 -1
  867. package/.output/public/_nuxt/default.BfdyU-m9.css +0 -1
  868. package/.output/public/_nuxt/entry.0UG0MnUy.css +0 -1
  869. package/.output/public/_nuxt/fIC3FurW.js +0 -1
  870. package/.output/public/_nuxt/index.BHg08rtV.css +0 -1
  871. package/.output/public/_nuxt/n9bD6NrC.js +0 -2
  872. package/.output/public/_nuxt/ykQL1ia3.js +0 -271
  873. package/.output/public/_nuxt/zD3bTrJp.js +0 -1
  874. package/.output/server/chunks/routes/api/database-roles/adapters/postgres.adapter.mjs +0 -700
  875. package/.output/server/chunks/routes/api/database-roles/adapters/postgres.adapter.mjs.map +0 -1
  876. package/.output/server/chunks/routes/api/database-roles/adapters/types.mjs +0 -2
  877. package/.output/server/chunks/routes/api/database-roles/adapters/types.mjs.map +0 -1
  878. package/.output/server/chunks/routes/api/database-roles/index.mjs +0 -39
  879. package/.output/server/chunks/routes/api/database-roles/index.mjs.map +0 -1
  880. package/.output/server/chunks/routes/api/delete-function.mjs +0 -65
  881. package/.output/server/chunks/routes/api/delete-function.mjs.map +0 -1
  882. package/.output/server/chunks/routes/api/execute-bulk-delete.mjs +0 -100
  883. package/.output/server/chunks/routes/api/execute-bulk-delete.mjs.map +0 -1
  884. package/.output/server/chunks/routes/api/execute-bulk-update.mjs +0 -105
  885. package/.output/server/chunks/routes/api/execute-bulk-update.mjs.map +0 -1
  886. package/.output/server/chunks/routes/api/execute.mjs +0 -47
  887. package/.output/server/chunks/routes/api/execute.mjs.map +0 -1
  888. package/.output/server/chunks/routes/api/export-table-data.mjs +0 -229
  889. package/.output/server/chunks/routes/api/export-table-data.mjs.map +0 -1
  890. package/.output/server/chunks/routes/api/get-function-signature.mjs +0 -96
  891. package/.output/server/chunks/routes/api/get-function-signature.mjs.map +0 -1
  892. package/.output/server/chunks/routes/api/get-one-function.mjs +0 -34
  893. package/.output/server/chunks/routes/api/get-one-function.mjs.map +0 -1
  894. package/.output/server/chunks/routes/api/get-one-table.mjs +0 -180
  895. package/.output/server/chunks/routes/api/get-one-table.mjs.map +0 -1
  896. package/.output/server/chunks/routes/api/get-over-view-function.mjs +0 -41
  897. package/.output/server/chunks/routes/api/get-over-view-function.mjs.map +0 -1
  898. package/.output/server/chunks/routes/api/get-over-view-tables.mjs +0 -53
  899. package/.output/server/chunks/routes/api/get-over-view-tables.mjs.map +0 -1
  900. package/.output/server/chunks/routes/api/get-over-view-views.mjs +0 -44
  901. package/.output/server/chunks/routes/api/get-over-view-views.mjs.map +0 -1
  902. package/.output/server/chunks/routes/api/get-reverse-table-schemas.mjs +0 -123
  903. package/.output/server/chunks/routes/api/get-reverse-table-schemas.mjs.map +0 -1
  904. package/.output/server/chunks/routes/api/get-schema-meta-data.mjs +0 -220
  905. package/.output/server/chunks/routes/api/get-schema-meta-data.mjs.map +0 -1
  906. package/.output/server/chunks/routes/api/get-table-ddl.mjs +0 -185
  907. package/.output/server/chunks/routes/api/get-table-ddl.mjs.map +0 -1
  908. package/.output/server/chunks/routes/api/get-table-size.mjs +0 -49
  909. package/.output/server/chunks/routes/api/get-table-size.mjs.map +0 -1
  910. package/.output/server/chunks/routes/api/get-table-structure.mjs +0 -111
  911. package/.output/server/chunks/routes/api/get-table-structure.mjs.map +0 -1
  912. package/.output/server/chunks/routes/api/get-tables.mjs +0 -287
  913. package/.output/server/chunks/routes/api/get-tables.mjs.map +0 -1
  914. package/.output/server/chunks/routes/api/get-view-definition.mjs +0 -57
  915. package/.output/server/chunks/routes/api/get-view-definition.mjs.map +0 -1
  916. package/.output/server/chunks/routes/api/getMetricMonitor.mjs +0 -46
  917. package/.output/server/chunks/routes/api/getMetricMonitor.mjs.map +0 -1
  918. package/.output/server/chunks/routes/api/raw-execute.mjs +0 -47
  919. package/.output/server/chunks/routes/api/raw-execute.mjs.map +0 -1
  920. package/.output/server/chunks/routes/api/rename-function.mjs +0 -77
  921. package/.output/server/chunks/routes/api/rename-function.mjs.map +0 -1
  922. package/.output/server/chunks/routes/api/update-function.mjs +0 -65
  923. package/.output/server/chunks/routes/api/update-function.mjs.map +0 -1
  924. package/.output/server/node_modules/@ioredis/commands/built/commands.json +0 -2447
  925. package/.output/server/node_modules/@ioredis/commands/built/index.js +0 -208
  926. package/.output/server/node_modules/@ioredis/commands/package.json +0 -52
  927. package/.output/server/node_modules/@sqltools/formatter/lib/core/Formatter.js +0 -234
  928. package/.output/server/node_modules/@sqltools/formatter/lib/core/Indentation.js +0 -42
  929. package/.output/server/node_modules/@sqltools/formatter/lib/core/InlineBlock.js +0 -60
  930. package/.output/server/node_modules/@sqltools/formatter/lib/core/Params.js +0 -21
  931. package/.output/server/node_modules/@sqltools/formatter/lib/core/Tokenizer.js +0 -272
  932. package/.output/server/node_modules/@sqltools/formatter/lib/core/escapeRegExp.js +0 -10
  933. package/.output/server/node_modules/@sqltools/formatter/lib/core/last.js +0 -7
  934. package/.output/server/node_modules/@sqltools/formatter/lib/core/types.js +0 -22
  935. package/.output/server/node_modules/@sqltools/formatter/lib/languages/Db2Formatter.js +0 -585
  936. package/.output/server/node_modules/@sqltools/formatter/lib/languages/N1qlFormatter.js +0 -257
  937. package/.output/server/node_modules/@sqltools/formatter/lib/languages/PlSqlFormatter.js +0 -459
  938. package/.output/server/node_modules/@sqltools/formatter/lib/languages/StandardSqlFormatter.js +0 -369
  939. package/.output/server/node_modules/@sqltools/formatter/lib/languages/utils/abstract.js +0 -23
  940. package/.output/server/node_modules/@sqltools/formatter/lib/sqlFormatter.js +0 -34
  941. package/.output/server/node_modules/@sqltools/formatter/package.json +0 -59
  942. package/.output/server/node_modules/ansis/index.js +0 -1
  943. package/.output/server/node_modules/ansis/package.json +0 -28
  944. package/.output/server/node_modules/app-root-path/index.js +0 -4
  945. package/.output/server/node_modules/app-root-path/lib/app-root-path.js +0 -30
  946. package/.output/server/node_modules/app-root-path/lib/resolve.js +0 -128
  947. package/.output/server/node_modules/app-root-path/package.json +0 -66
  948. package/.output/server/node_modules/balanced-match/index.js +0 -62
  949. package/.output/server/node_modules/balanced-match/package.json +0 -48
  950. package/.output/server/node_modules/brace-expansion/index.js +0 -203
  951. package/.output/server/node_modules/brace-expansion/package.json +0 -46
  952. package/.output/server/node_modules/cluster-key-slot/lib/index.js +0 -166
  953. package/.output/server/node_modules/cluster-key-slot/package.json +0 -56
  954. package/.output/server/node_modules/dedent/dist/dedent.js +0 -73
  955. package/.output/server/node_modules/dedent/package.json +0 -119
  956. package/.output/server/node_modules/denque/index.js +0 -481
  957. package/.output/server/node_modules/denque/package.json +0 -58
  958. package/.output/server/node_modules/dotenv/lib/main.js +0 -361
  959. package/.output/server/node_modules/dotenv/package.json +0 -61
  960. package/.output/server/node_modules/glob/dist/commonjs/glob.js +0 -247
  961. package/.output/server/node_modules/glob/dist/commonjs/has-magic.js +0 -27
  962. package/.output/server/node_modules/glob/dist/commonjs/ignore.js +0 -119
  963. package/.output/server/node_modules/glob/dist/commonjs/index.js +0 -68
  964. package/.output/server/node_modules/glob/dist/commonjs/package.json +0 -3
  965. package/.output/server/node_modules/glob/dist/commonjs/pattern.js +0 -219
  966. package/.output/server/node_modules/glob/dist/commonjs/processor.js +0 -301
  967. package/.output/server/node_modules/glob/dist/commonjs/walker.js +0 -387
  968. package/.output/server/node_modules/glob/package.json +0 -99
  969. package/.output/server/node_modules/inherits/inherits.js +0 -9
  970. package/.output/server/node_modules/inherits/inherits_browser.js +0 -27
  971. package/.output/server/node_modules/inherits/package.json +0 -29
  972. package/.output/server/node_modules/ioredis/built/Command.js +0 -349
  973. package/.output/server/node_modules/ioredis/built/DataHandler.js +0 -220
  974. package/.output/server/node_modules/ioredis/built/Pipeline.js +0 -334
  975. package/.output/server/node_modules/ioredis/built/Redis.js +0 -697
  976. package/.output/server/node_modules/ioredis/built/ScanStream.js +0 -51
  977. package/.output/server/node_modules/ioredis/built/Script.js +0 -62
  978. package/.output/server/node_modules/ioredis/built/SubscriptionSet.js +0 -41
  979. package/.output/server/node_modules/ioredis/built/autoPipelining.js +0 -159
  980. package/.output/server/node_modules/ioredis/built/cluster/ClusterOptions.js +0 -22
  981. package/.output/server/node_modules/ioredis/built/cluster/ClusterSubscriber.js +0 -202
  982. package/.output/server/node_modules/ioredis/built/cluster/ClusterSubscriberGroup.js +0 -224
  983. package/.output/server/node_modules/ioredis/built/cluster/ConnectionPool.js +0 -154
  984. package/.output/server/node_modules/ioredis/built/cluster/DelayQueue.js +0 -53
  985. package/.output/server/node_modules/ioredis/built/cluster/index.js +0 -862
  986. package/.output/server/node_modules/ioredis/built/cluster/util.js +0 -100
  987. package/.output/server/node_modules/ioredis/built/connectors/AbstractConnector.js +0 -26
  988. package/.output/server/node_modules/ioredis/built/connectors/SentinelConnector/FailoverDetector.js +0 -45
  989. package/.output/server/node_modules/ioredis/built/connectors/SentinelConnector/SentinelIterator.js +0 -37
  990. package/.output/server/node_modules/ioredis/built/connectors/SentinelConnector/index.js +0 -305
  991. package/.output/server/node_modules/ioredis/built/connectors/StandaloneConnector.js +0 -69
  992. package/.output/server/node_modules/ioredis/built/connectors/index.js +0 -7
  993. package/.output/server/node_modules/ioredis/built/constants/TLSProfiles.js +0 -149
  994. package/.output/server/node_modules/ioredis/built/errors/ClusterAllFailedError.js +0 -15
  995. package/.output/server/node_modules/ioredis/built/errors/MaxRetriesPerRequestError.js +0 -14
  996. package/.output/server/node_modules/ioredis/built/errors/index.js +0 -5
  997. package/.output/server/node_modules/ioredis/built/index.js +0 -62
  998. package/.output/server/node_modules/ioredis/built/redis/RedisOptions.js +0 -55
  999. package/.output/server/node_modules/ioredis/built/redis/event_handler.js +0 -292
  1000. package/.output/server/node_modules/ioredis/built/transaction.js +0 -93
  1001. package/.output/server/node_modules/ioredis/built/utils/Commander.js +0 -117
  1002. package/.output/server/node_modules/ioredis/built/utils/applyMixin.js +0 -8
  1003. package/.output/server/node_modules/ioredis/built/utils/debug.js +0 -95
  1004. package/.output/server/node_modules/ioredis/built/utils/index.js +0 -297
  1005. package/.output/server/node_modules/ioredis/built/utils/lodash.js +0 -9
  1006. package/.output/server/node_modules/ioredis/package.json +0 -100
  1007. package/.output/server/node_modules/lodash.defaults/index.js +0 -668
  1008. package/.output/server/node_modules/lodash.defaults/package.json +0 -19
  1009. package/.output/server/node_modules/lodash.isarguments/index.js +0 -229
  1010. package/.output/server/node_modules/lodash.isarguments/package.json +0 -19
  1011. package/.output/server/node_modules/lru-cache/dist/commonjs/index.js +0 -1546
  1012. package/.output/server/node_modules/lru-cache/dist/commonjs/package.json +0 -3
  1013. package/.output/server/node_modules/lru-cache/package.json +0 -116
  1014. package/.output/server/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +0 -14
  1015. package/.output/server/node_modules/minimatch/dist/commonjs/ast.js +0 -592
  1016. package/.output/server/node_modules/minimatch/dist/commonjs/brace-expressions.js +0 -152
  1017. package/.output/server/node_modules/minimatch/dist/commonjs/escape.js +0 -22
  1018. package/.output/server/node_modules/minimatch/dist/commonjs/index.js +0 -1017
  1019. package/.output/server/node_modules/minimatch/dist/commonjs/package.json +0 -3
  1020. package/.output/server/node_modules/minimatch/dist/commonjs/unescape.js +0 -24
  1021. package/.output/server/node_modules/minimatch/package.json +0 -82
  1022. package/.output/server/node_modules/minipass/dist/commonjs/index.js +0 -1028
  1023. package/.output/server/node_modules/minipass/dist/commonjs/package.json +0 -3
  1024. package/.output/server/node_modules/minipass/package.json +0 -82
  1025. package/.output/server/node_modules/path-scurry/dist/commonjs/index.js +0 -2014
  1026. package/.output/server/node_modules/path-scurry/dist/commonjs/package.json +0 -3
  1027. package/.output/server/node_modules/path-scurry/package.json +0 -89
  1028. package/.output/server/node_modules/redis-errors/index.js +0 -7
  1029. package/.output/server/node_modules/redis-errors/lib/modern.js +0 -59
  1030. package/.output/server/node_modules/redis-errors/lib/old.js +0 -119
  1031. package/.output/server/node_modules/redis-errors/package.json +0 -41
  1032. package/.output/server/node_modules/redis-parser/index.js +0 -3
  1033. package/.output/server/node_modules/redis-parser/lib/parser.js +0 -552
  1034. package/.output/server/node_modules/redis-parser/package.json +0 -53
  1035. package/.output/server/node_modules/reflect-metadata/Reflect.js +0 -1415
  1036. package/.output/server/node_modules/reflect-metadata/package.json +0 -68
  1037. package/.output/server/node_modules/safe-buffer/index.js +0 -65
  1038. package/.output/server/node_modules/safe-buffer/package.json +0 -51
  1039. package/.output/server/node_modules/sha.js/hash.js +0 -81
  1040. package/.output/server/node_modules/sha.js/index.js +0 -15
  1041. package/.output/server/node_modules/sha.js/package.json +0 -30
  1042. package/.output/server/node_modules/sha.js/sha.js +0 -94
  1043. package/.output/server/node_modules/sha.js/sha1.js +0 -99
  1044. package/.output/server/node_modules/sha.js/sha224.js +0 -53
  1045. package/.output/server/node_modules/sha.js/sha256.js +0 -135
  1046. package/.output/server/node_modules/sha.js/sha384.js +0 -57
  1047. package/.output/server/node_modules/sha.js/sha512.js +0 -260
  1048. package/.output/server/node_modules/sql-highlight/lib/escapeHtml.js +0 -59
  1049. package/.output/server/node_modules/sql-highlight/lib/index.js +0 -85
  1050. package/.output/server/node_modules/sql-highlight/lib/keywords.js +0 -145
  1051. package/.output/server/node_modules/sql-highlight/package.json +0 -49
  1052. package/.output/server/node_modules/standard-as-callback/built/index.js +0 -41
  1053. package/.output/server/node_modules/standard-as-callback/built/utils.js +0 -23
  1054. package/.output/server/node_modules/standard-as-callback/package.json +0 -40
  1055. package/.output/server/node_modules/tslib/package.json +0 -47
  1056. package/.output/server/node_modules/tslib/tslib.js +0 -484
  1057. package/.output/server/node_modules/typeorm/cache/DbQueryResultCache.js +0 -264
  1058. package/.output/server/node_modules/typeorm/cache/QueryResultCacheFactory.js +0 -42
  1059. package/.output/server/node_modules/typeorm/cache/RedisQueryResultCache.js +0 -197
  1060. package/.output/server/node_modules/typeorm/common/DeepPartial.js +0 -4
  1061. package/.output/server/node_modules/typeorm/common/EntityTarget.js +0 -4
  1062. package/.output/server/node_modules/typeorm/common/MixedList.js +0 -4
  1063. package/.output/server/node_modules/typeorm/common/ObjectLiteral.js +0 -4
  1064. package/.output/server/node_modules/typeorm/common/ObjectType.js +0 -4
  1065. package/.output/server/node_modules/typeorm/common/RelationType.js +0 -4
  1066. package/.output/server/node_modules/typeorm/connection/Connection.js +0 -16
  1067. package/.output/server/node_modules/typeorm/connection/ConnectionManager.js +0 -66
  1068. package/.output/server/node_modules/typeorm/connection/ConnectionMetadataBuilder.js +0 -74
  1069. package/.output/server/node_modules/typeorm/connection/ConnectionOptionsReader.js +0 -198
  1070. package/.output/server/node_modules/typeorm/connection/options-reader/ConnectionOptionsEnvReader.js +0 -111
  1071. package/.output/server/node_modules/typeorm/container.js +0 -60
  1072. package/.output/server/node_modules/typeorm/data-source/DataSource.js +0 -517
  1073. package/.output/server/node_modules/typeorm/decorator/Check.js +0 -27
  1074. package/.output/server/node_modules/typeorm/decorator/EntityRepository.js +0 -21
  1075. package/.output/server/node_modules/typeorm/decorator/Exclusion.js +0 -27
  1076. package/.output/server/node_modules/typeorm/decorator/ForeignKey.js +0 -44
  1077. package/.output/server/node_modules/typeorm/decorator/Generated.js +0 -24
  1078. package/.output/server/node_modules/typeorm/decorator/Index.js +0 -56
  1079. package/.output/server/node_modules/typeorm/decorator/Unique.js +0 -50
  1080. package/.output/server/node_modules/typeorm/decorator/columns/Column.js +0 -78
  1081. package/.output/server/node_modules/typeorm/decorator/columns/CreateDateColumn.js +0 -21
  1082. package/.output/server/node_modules/typeorm/decorator/columns/DeleteDateColumn.js +0 -20
  1083. package/.output/server/node_modules/typeorm/decorator/columns/ObjectIdColumn.js +0 -27
  1084. package/.output/server/node_modules/typeorm/decorator/columns/PrimaryColumn.js +0 -63
  1085. package/.output/server/node_modules/typeorm/decorator/columns/PrimaryGeneratedColumn.js +0 -59
  1086. package/.output/server/node_modules/typeorm/decorator/columns/UpdateDateColumn.js +0 -20
  1087. package/.output/server/node_modules/typeorm/decorator/columns/VersionColumn.js +0 -21
  1088. package/.output/server/node_modules/typeorm/decorator/columns/ViewColumn.js +0 -19
  1089. package/.output/server/node_modules/typeorm/decorator/columns/VirtualColumn.js +0 -49
  1090. package/.output/server/node_modules/typeorm/decorator/entity/ChildEntity.js +0 -25
  1091. package/.output/server/node_modules/typeorm/decorator/entity/Entity.js +0 -31
  1092. package/.output/server/node_modules/typeorm/decorator/entity/TableInheritance.js +0 -22
  1093. package/.output/server/node_modules/typeorm/decorator/entity-view/ViewEntity.js +0 -32
  1094. package/.output/server/node_modules/typeorm/decorator/listeners/AfterInsert.js +0 -19
  1095. package/.output/server/node_modules/typeorm/decorator/listeners/AfterLoad.js +0 -19
  1096. package/.output/server/node_modules/typeorm/decorator/listeners/AfterRecover.js +0 -19
  1097. package/.output/server/node_modules/typeorm/decorator/listeners/AfterRemove.js +0 -19
  1098. package/.output/server/node_modules/typeorm/decorator/listeners/AfterSoftRemove.js +0 -19
  1099. package/.output/server/node_modules/typeorm/decorator/listeners/AfterUpdate.js +0 -19
  1100. package/.output/server/node_modules/typeorm/decorator/listeners/BeforeInsert.js +0 -19
  1101. package/.output/server/node_modules/typeorm/decorator/listeners/BeforeRecover.js +0 -19
  1102. package/.output/server/node_modules/typeorm/decorator/listeners/BeforeRemove.js +0 -19
  1103. package/.output/server/node_modules/typeorm/decorator/listeners/BeforeSoftRemove.js +0 -19
  1104. package/.output/server/node_modules/typeorm/decorator/listeners/BeforeUpdate.js +0 -19
  1105. package/.output/server/node_modules/typeorm/decorator/listeners/EventSubscriber.js +0 -17
  1106. package/.output/server/node_modules/typeorm/decorator/options/ColumnOptions.js +0 -4
  1107. package/.output/server/node_modules/typeorm/decorator/options/EntityOptions.js +0 -4
  1108. package/.output/server/node_modules/typeorm/decorator/options/IndexOptions.js +0 -4
  1109. package/.output/server/node_modules/typeorm/decorator/options/JoinColumnOptions.js +0 -4
  1110. package/.output/server/node_modules/typeorm/decorator/options/JoinTableOptions.js +0 -4
  1111. package/.output/server/node_modules/typeorm/decorator/options/RelationOptions.js +0 -4
  1112. package/.output/server/node_modules/typeorm/decorator/options/ValueTransformer.js +0 -4
  1113. package/.output/server/node_modules/typeorm/decorator/relations/JoinColumn.js +0 -27
  1114. package/.output/server/node_modules/typeorm/decorator/relations/JoinTable.js +0 -34
  1115. package/.output/server/node_modules/typeorm/decorator/relations/ManyToMany.js +0 -46
  1116. package/.output/server/node_modules/typeorm/decorator/relations/ManyToOne.js +0 -46
  1117. package/.output/server/node_modules/typeorm/decorator/relations/OneToMany.js +0 -37
  1118. package/.output/server/node_modules/typeorm/decorator/relations/OneToOne.js +0 -45
  1119. package/.output/server/node_modules/typeorm/decorator/relations/RelationCount.js +0 -23
  1120. package/.output/server/node_modules/typeorm/decorator/relations/RelationId.js +0 -22
  1121. package/.output/server/node_modules/typeorm/decorator/tree/Tree.js +0 -21
  1122. package/.output/server/node_modules/typeorm/decorator/tree/TreeChildren.js +0 -34
  1123. package/.output/server/node_modules/typeorm/decorator/tree/TreeLevelColumn.js +0 -19
  1124. package/.output/server/node_modules/typeorm/decorator/tree/TreeParent.js +0 -33
  1125. package/.output/server/node_modules/typeorm/driver/DriverFactory.js +0 -98
  1126. package/.output/server/node_modules/typeorm/driver/DriverUtils.js +0 -228
  1127. package/.output/server/node_modules/typeorm/driver/Query.js +0 -16
  1128. package/.output/server/node_modules/typeorm/driver/SqlInMemory.js +0 -15
  1129. package/.output/server/node_modules/typeorm/driver/aurora-mysql/AuroraMysqlDriver.js +0 -847
  1130. package/.output/server/node_modules/typeorm/driver/aurora-mysql/AuroraMysqlQueryRunner.js +0 -1709
  1131. package/.output/server/node_modules/typeorm/driver/aurora-postgres/AuroraPostgresDriver.js +0 -103
  1132. package/.output/server/node_modules/typeorm/driver/aurora-postgres/AuroraPostgresQueryRunner.js +0 -146
  1133. package/.output/server/node_modules/typeorm/driver/better-sqlite3/BetterSqlite3Driver.js +0 -153
  1134. package/.output/server/node_modules/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js +0 -126
  1135. package/.output/server/node_modules/typeorm/driver/capacitor/CapacitorDriver.js +0 -78
  1136. package/.output/server/node_modules/typeorm/driver/capacitor/CapacitorQueryRunner.js +0 -98
  1137. package/.output/server/node_modules/typeorm/driver/cockroachdb/CockroachDriver.js +0 -885
  1138. package/.output/server/node_modules/typeorm/driver/cockroachdb/CockroachQueryRunner.js +0 -2453
  1139. package/.output/server/node_modules/typeorm/driver/cordova/CordovaDriver.js +0 -76
  1140. package/.output/server/node_modules/typeorm/driver/cordova/CordovaQueryRunner.js +0 -170
  1141. package/.output/server/node_modules/typeorm/driver/expo/ExpoDriver.js +0 -29
  1142. package/.output/server/node_modules/typeorm/driver/expo/ExpoDriverFactory.js +0 -22
  1143. package/.output/server/node_modules/typeorm/driver/expo/ExpoQueryRunner.js +0 -65
  1144. package/.output/server/node_modules/typeorm/driver/expo/legacy/ExpoLegacyDriver.js +0 -75
  1145. package/.output/server/node_modules/typeorm/driver/expo/legacy/ExpoLegacyQueryRunner.js +0 -169
  1146. package/.output/server/node_modules/typeorm/driver/mongodb/MongoDriver.js +0 -404
  1147. package/.output/server/node_modules/typeorm/driver/mongodb/MongoQueryRunner.js +0 -701
  1148. package/.output/server/node_modules/typeorm/driver/mongodb/bson.typings.js +0 -5
  1149. package/.output/server/node_modules/typeorm/driver/mongodb/typings.js +0 -23
  1150. package/.output/server/node_modules/typeorm/driver/mysql/MysqlDriver.js +0 -1105
  1151. package/.output/server/node_modules/typeorm/driver/mysql/MysqlQueryRunner.js +0 -2139
  1152. package/.output/server/node_modules/typeorm/driver/nativescript/NativescriptDriver.js +0 -94
  1153. package/.output/server/node_modules/typeorm/driver/nativescript/NativescriptQueryRunner.js +0 -92
  1154. package/.output/server/node_modules/typeorm/driver/oracle/OracleDriver.js +0 -869
  1155. package/.output/server/node_modules/typeorm/driver/oracle/OracleQueryRunner.js +0 -1884
  1156. package/.output/server/node_modules/typeorm/driver/postgres/PostgresDriver.js +0 -1259
  1157. package/.output/server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js +0 -2729
  1158. package/.output/server/node_modules/typeorm/driver/react-native/ReactNativeDriver.js +0 -728
  1159. package/.output/server/node_modules/typeorm/driver/react-native/ReactNativeQueryRunner.js +0 -107
  1160. package/.output/server/node_modules/typeorm/driver/sap/SapDriver.js +0 -681
  1161. package/.output/server/node_modules/typeorm/driver/sap/SapQueryRunner.js +0 -2054
  1162. package/.output/server/node_modules/typeorm/driver/spanner/SpannerDriver.js +0 -613
  1163. package/.output/server/node_modules/typeorm/driver/spanner/SpannerQueryRunner.js +0 -1464
  1164. package/.output/server/node_modules/typeorm/driver/sqlite/SqliteDriver.js +0 -174
  1165. package/.output/server/node_modules/typeorm/driver/sqlite/SqliteQueryRunner.js +0 -124
  1166. package/.output/server/node_modules/typeorm/driver/sqlite-abstract/AbstractSqliteDriver.js +0 -695
  1167. package/.output/server/node_modules/typeorm/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +0 -1511
  1168. package/.output/server/node_modules/typeorm/driver/sqljs/SqljsDriver.js +0 -250
  1169. package/.output/server/node_modules/typeorm/driver/sqljs/SqljsQueryRunner.js +0 -123
  1170. package/.output/server/node_modules/typeorm/driver/sqlserver/MssqlParameter.js +0 -23
  1171. package/.output/server/node_modules/typeorm/driver/sqlserver/SqlServerDriver.js +0 -922
  1172. package/.output/server/node_modules/typeorm/driver/sqlserver/SqlServerQueryRunner.js +0 -2484
  1173. package/.output/server/node_modules/typeorm/driver/types/DatabaseType.js +0 -4
  1174. package/.output/server/node_modules/typeorm/driver/types/GeoJsonTypes.js +0 -4
  1175. package/.output/server/node_modules/typeorm/driver/types/MetadataTableType.js +0 -11
  1176. package/.output/server/node_modules/typeorm/driver/types/ReplicationMode.js +0 -4
  1177. package/.output/server/node_modules/typeorm/entity-manager/EntityManager.js +0 -853
  1178. package/.output/server/node_modules/typeorm/entity-manager/EntityManagerFactory.js +0 -24
  1179. package/.output/server/node_modules/typeorm/entity-manager/MongoEntityManager.js +0 -668
  1180. package/.output/server/node_modules/typeorm/entity-manager/SqljsEntityManager.js +0 -44
  1181. package/.output/server/node_modules/typeorm/entity-schema/EntitySchema.js +0 -15
  1182. package/.output/server/node_modules/typeorm/entity-schema/EntitySchemaEmbeddedColumnOptions.js +0 -8
  1183. package/.output/server/node_modules/typeorm/entity-schema/EntitySchemaEmbeddedError.js +0 -18
  1184. package/.output/server/node_modules/typeorm/entity-schema/EntitySchemaOptions.js +0 -11
  1185. package/.output/server/node_modules/typeorm/entity-schema/EntitySchemaTransformer.js +0 -333
  1186. package/.output/server/node_modules/typeorm/error/AlreadyHasActiveConnectionError.js +0 -16
  1187. package/.output/server/node_modules/typeorm/error/CannotAttachTreeChildrenEntityError.js +0 -16
  1188. package/.output/server/node_modules/typeorm/error/CannotConnectAlreadyConnectedError.js +0 -15
  1189. package/.output/server/node_modules/typeorm/error/CannotCreateEntityIdMapError.js +0 -21
  1190. package/.output/server/node_modules/typeorm/error/CannotDetermineEntityError.js +0 -16
  1191. package/.output/server/node_modules/typeorm/error/CannotExecuteNotConnectedError.js +0 -15
  1192. package/.output/server/node_modules/typeorm/error/CannotGetEntityManagerNotConnectedError.js +0 -15
  1193. package/.output/server/node_modules/typeorm/error/CannotReflectMethodParameterTypeError.js +0 -18
  1194. package/.output/server/node_modules/typeorm/error/CircularRelationsError.js +0 -16
  1195. package/.output/server/node_modules/typeorm/error/ColumnTypeUndefinedError.js +0 -19
  1196. package/.output/server/node_modules/typeorm/error/ConnectionIsNotSetError.js +0 -15
  1197. package/.output/server/node_modules/typeorm/error/ConnectionNotFoundError.js +0 -15
  1198. package/.output/server/node_modules/typeorm/error/CustomRepositoryCannotInheritRepositoryError.js +0 -18
  1199. package/.output/server/node_modules/typeorm/error/CustomRepositoryDoesNotHaveEntityError.js +0 -18
  1200. package/.output/server/node_modules/typeorm/error/CustomRepositoryNotFoundError.js +0 -18
  1201. package/.output/server/node_modules/typeorm/error/DataTypeNotSupportedError.js +0 -14
  1202. package/.output/server/node_modules/typeorm/error/DriverOptionNotSetError.js +0 -16
  1203. package/.output/server/node_modules/typeorm/error/DriverPackageNotInstalledError.js +0 -16
  1204. package/.output/server/node_modules/typeorm/error/EntityMetadataNotFoundError.js +0 -29
  1205. package/.output/server/node_modules/typeorm/error/EntityNotFoundError.js +0 -42
  1206. package/.output/server/node_modules/typeorm/error/EntityPropertyNotFoundError.js +0 -17
  1207. package/.output/server/node_modules/typeorm/error/FindRelationsNotFoundError.js +0 -23
  1208. package/.output/server/node_modules/typeorm/error/ForbiddenTransactionModeOverrideError.js +0 -16
  1209. package/.output/server/node_modules/typeorm/error/InitializedRelationError.js +0 -20
  1210. package/.output/server/node_modules/typeorm/error/InsertValuesMissingError.js +0 -16
  1211. package/.output/server/node_modules/typeorm/error/LimitOnUpdateNotSupportedError.js +0 -15
  1212. package/.output/server/node_modules/typeorm/error/LockNotSupportedOnGivenDriverError.js +0 -15
  1213. package/.output/server/node_modules/typeorm/error/MetadataAlreadyExistsError.js +0 -18
  1214. package/.output/server/node_modules/typeorm/error/MetadataWithSuchNameAlreadyExistsError.js +0 -16
  1215. package/.output/server/node_modules/typeorm/error/MissingDeleteDateColumnError.js +0 -12
  1216. package/.output/server/node_modules/typeorm/error/MissingDriverError.js +0 -16
  1217. package/.output/server/node_modules/typeorm/error/MissingJoinColumnError.js +0 -23
  1218. package/.output/server/node_modules/typeorm/error/MissingJoinTableError.js +0 -23
  1219. package/.output/server/node_modules/typeorm/error/MissingPrimaryColumnError.js +0 -13
  1220. package/.output/server/node_modules/typeorm/error/MustBeEntityError.js +0 -15
  1221. package/.output/server/node_modules/typeorm/error/NestedSetMultipleRootError.js +0 -12
  1222. package/.output/server/node_modules/typeorm/error/NoConnectionForRepositoryError.js +0 -16
  1223. package/.output/server/node_modules/typeorm/error/NoConnectionOptionError.js +0 -16
  1224. package/.output/server/node_modules/typeorm/error/NoNeedToReleaseEntityManagerError.js +0 -17
  1225. package/.output/server/node_modules/typeorm/error/NoVersionOrUpdateDateColumnError.js +0 -15
  1226. package/.output/server/node_modules/typeorm/error/OffsetWithoutLimitNotSupportedError.js +0 -17
  1227. package/.output/server/node_modules/typeorm/error/OptimisticLockCanNotBeUsedError.js +0 -15
  1228. package/.output/server/node_modules/typeorm/error/OptimisticLockVersionMismatchError.js +0 -15
  1229. package/.output/server/node_modules/typeorm/error/PersistedEntityNotFoundError.js +0 -15
  1230. package/.output/server/node_modules/typeorm/error/PessimisticLockTransactionRequiredError.js +0 -15
  1231. package/.output/server/node_modules/typeorm/error/PrimaryColumnCannotBeNullableError.js +0 -13
  1232. package/.output/server/node_modules/typeorm/error/QueryFailedError.js +0 -30
  1233. package/.output/server/node_modules/typeorm/error/QueryRunnerAlreadyReleasedError.js +0 -12
  1234. package/.output/server/node_modules/typeorm/error/QueryRunnerProviderAlreadyReleasedError.js +0 -16
  1235. package/.output/server/node_modules/typeorm/error/RepositoryNotTreeError.js +0 -32
  1236. package/.output/server/node_modules/typeorm/error/ReturningStatementNotSupportedError.js +0 -16
  1237. package/.output/server/node_modules/typeorm/error/SubjectRemovedAndUpdatedError.js +0 -16
  1238. package/.output/server/node_modules/typeorm/error/SubjectWithoutIdentifierError.js +0 -17
  1239. package/.output/server/node_modules/typeorm/error/TransactionAlreadyStartedError.js +0 -15
  1240. package/.output/server/node_modules/typeorm/error/TransactionNotStartedError.js +0 -15
  1241. package/.output/server/node_modules/typeorm/error/TreeRepositoryNotSupportedError.js +0 -12
  1242. package/.output/server/node_modules/typeorm/error/TypeORMError.js +0 -23
  1243. package/.output/server/node_modules/typeorm/error/UpdateValuesMissingError.js +0 -12
  1244. package/.output/server/node_modules/typeorm/error/UsingJoinColumnIsNotAllowedError.js +0 -13
  1245. package/.output/server/node_modules/typeorm/error/UsingJoinColumnOnlyOnOneSideAllowedError.js +0 -14
  1246. package/.output/server/node_modules/typeorm/error/UsingJoinTableIsNotAllowedError.js +0 -14
  1247. package/.output/server/node_modules/typeorm/error/UsingJoinTableOnlyOnOneSideAllowedError.js +0 -14
  1248. package/.output/server/node_modules/typeorm/error/index.js +0 -66
  1249. package/.output/server/node_modules/typeorm/find-options/EqualOperator.js +0 -13
  1250. package/.output/server/node_modules/typeorm/find-options/FindManyOptions.js +0 -4
  1251. package/.output/server/node_modules/typeorm/find-options/FindOneOptions.js +0 -4
  1252. package/.output/server/node_modules/typeorm/find-options/FindOperator.js +0 -96
  1253. package/.output/server/node_modules/typeorm/find-options/FindOperatorType.js +0 -4
  1254. package/.output/server/node_modules/typeorm/find-options/FindOptionsOrder.js +0 -4
  1255. package/.output/server/node_modules/typeorm/find-options/FindOptionsRelations.js +0 -4
  1256. package/.output/server/node_modules/typeorm/find-options/FindOptionsSelect.js +0 -4
  1257. package/.output/server/node_modules/typeorm/find-options/FindOptionsUtils.js +0 -350
  1258. package/.output/server/node_modules/typeorm/find-options/FindOptionsWhere.js +0 -4
  1259. package/.output/server/node_modules/typeorm/find-options/FindTreeOptions.js +0 -4
  1260. package/.output/server/node_modules/typeorm/find-options/JoinOptions.js +0 -4
  1261. package/.output/server/node_modules/typeorm/find-options/OrderByCondition.js +0 -4
  1262. package/.output/server/node_modules/typeorm/find-options/operator/And.js +0 -9
  1263. package/.output/server/node_modules/typeorm/find-options/operator/Any.js +0 -13
  1264. package/.output/server/node_modules/typeorm/find-options/operator/ArrayContainedBy.js +0 -13
  1265. package/.output/server/node_modules/typeorm/find-options/operator/ArrayContains.js +0 -13
  1266. package/.output/server/node_modules/typeorm/find-options/operator/ArrayOverlap.js +0 -13
  1267. package/.output/server/node_modules/typeorm/find-options/operator/Between.js +0 -13
  1268. package/.output/server/node_modules/typeorm/find-options/operator/Equal.js +0 -17
  1269. package/.output/server/node_modules/typeorm/find-options/operator/ILike.js +0 -13
  1270. package/.output/server/node_modules/typeorm/find-options/operator/In.js +0 -13
  1271. package/.output/server/node_modules/typeorm/find-options/operator/IsNull.js +0 -13
  1272. package/.output/server/node_modules/typeorm/find-options/operator/JsonContains.js +0 -13
  1273. package/.output/server/node_modules/typeorm/find-options/operator/LessThan.js +0 -13
  1274. package/.output/server/node_modules/typeorm/find-options/operator/LessThanOrEqual.js +0 -13
  1275. package/.output/server/node_modules/typeorm/find-options/operator/Like.js +0 -13
  1276. package/.output/server/node_modules/typeorm/find-options/operator/MoreThan.js +0 -13
  1277. package/.output/server/node_modules/typeorm/find-options/operator/MoreThanOrEqual.js +0 -13
  1278. package/.output/server/node_modules/typeorm/find-options/operator/Not.js +0 -14
  1279. package/.output/server/node_modules/typeorm/find-options/operator/Or.js +0 -9
  1280. package/.output/server/node_modules/typeorm/find-options/operator/Raw.js +0 -12
  1281. package/.output/server/node_modules/typeorm/globals.js +0 -182
  1282. package/.output/server/node_modules/typeorm/index.js +0 -196
  1283. package/.output/server/node_modules/typeorm/index.mjs +0 -422
  1284. package/.output/server/node_modules/typeorm/logger/AbstractLogger.js +0 -238
  1285. package/.output/server/node_modules/typeorm/logger/AdvancedConsoleLogger.js +0 -56
  1286. package/.output/server/node_modules/typeorm/logger/DebugLogger.js +0 -78
  1287. package/.output/server/node_modules/typeorm/logger/FileLogger.js +0 -88
  1288. package/.output/server/node_modules/typeorm/logger/FormattedConsoleLogger.js +0 -59
  1289. package/.output/server/node_modules/typeorm/logger/Logger.js +0 -4
  1290. package/.output/server/node_modules/typeorm/logger/LoggerFactory.js +0 -39
  1291. package/.output/server/node_modules/typeorm/logger/LoggerOptions.js +0 -4
  1292. package/.output/server/node_modules/typeorm/logger/SimpleConsoleLogger.js +0 -57
  1293. package/.output/server/node_modules/typeorm/metadata/CheckMetadata.js +0 -35
  1294. package/.output/server/node_modules/typeorm/metadata/ColumnMetadata.js +0 -618
  1295. package/.output/server/node_modules/typeorm/metadata/EmbeddedMetadata.js +0 -224
  1296. package/.output/server/node_modules/typeorm/metadata/EntityListenerMetadata.js +0 -77
  1297. package/.output/server/node_modules/typeorm/metadata/EntityMetadata.js +0 -692
  1298. package/.output/server/node_modules/typeorm/metadata/ExclusionMetadata.js +0 -35
  1299. package/.output/server/node_modules/typeorm/metadata/ForeignKeyMetadata.js +0 -57
  1300. package/.output/server/node_modules/typeorm/metadata/IndexMetadata.js +0 -144
  1301. package/.output/server/node_modules/typeorm/metadata/RelationCountMetadata.js +0 -39
  1302. package/.output/server/node_modules/typeorm/metadata/RelationIdMetadata.js +0 -62
  1303. package/.output/server/node_modules/typeorm/metadata/RelationMetadata.js +0 -440
  1304. package/.output/server/node_modules/typeorm/metadata/UniqueMetadata.js +0 -101
  1305. package/.output/server/node_modules/typeorm/metadata/types/EventListenerTypes.js +0 -22
  1306. package/.output/server/node_modules/typeorm/metadata-args/MetadataArgsStorage.js +0 -236
  1307. package/.output/server/node_modules/typeorm/metadata-builder/ClosureJunctionEntityMetadataBuilder.js +0 -145
  1308. package/.output/server/node_modules/typeorm/metadata-builder/EntityMetadataBuilder.js +0 -838
  1309. package/.output/server/node_modules/typeorm/metadata-builder/EntityMetadataValidator.js +0 -258
  1310. package/.output/server/node_modules/typeorm/metadata-builder/JunctionEntityMetadataBuilder.js +0 -287
  1311. package/.output/server/node_modules/typeorm/metadata-builder/MetadataUtils.js +0 -44
  1312. package/.output/server/node_modules/typeorm/metadata-builder/RelationJoinColumnBuilder.js +0 -185
  1313. package/.output/server/node_modules/typeorm/migration/Migration.js +0 -21
  1314. package/.output/server/node_modules/typeorm/migration/MigrationExecutor.js +0 -534
  1315. package/.output/server/node_modules/typeorm/naming-strategy/DefaultNamingStrategy.js +0 -145
  1316. package/.output/server/node_modules/typeorm/naming-strategy/LegacyOracleNamingStrategy.js +0 -50
  1317. package/.output/server/node_modules/typeorm/package.json +0 -268
  1318. package/.output/server/node_modules/typeorm/persistence/EntityPersistExecutor.js +0 -170
  1319. package/.output/server/node_modules/typeorm/persistence/Subject.js +0 -239
  1320. package/.output/server/node_modules/typeorm/persistence/SubjectChangedColumnsComputer.js +0 -216
  1321. package/.output/server/node_modules/typeorm/persistence/SubjectDatabaseEntityLoader.js +0 -135
  1322. package/.output/server/node_modules/typeorm/persistence/SubjectExecutor.js +0 -760
  1323. package/.output/server/node_modules/typeorm/persistence/SubjectTopologicalSorter.js +0 -174
  1324. package/.output/server/node_modules/typeorm/persistence/subject-builder/CascadesSubjectBuilder.js +0 -107
  1325. package/.output/server/node_modules/typeorm/persistence/subject-builder/ManyToManySubjectBuilder.js +0 -218
  1326. package/.output/server/node_modules/typeorm/persistence/subject-builder/OneToManySubjectBuilder.js +0 -181
  1327. package/.output/server/node_modules/typeorm/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js +0 -155
  1328. package/.output/server/node_modules/typeorm/persistence/tree/ClosureSubjectExecutor.js +0 -241
  1329. package/.output/server/node_modules/typeorm/persistence/tree/MaterializedPathSubjectExecutor.js +0 -125
  1330. package/.output/server/node_modules/typeorm/persistence/tree/NestedSetSubjectExecutor.js +0 -271
  1331. package/.output/server/node_modules/typeorm/platform/PlatformTools.js +0 -243
  1332. package/.output/server/node_modules/typeorm/query-builder/Alias.js +0 -29
  1333. package/.output/server/node_modules/typeorm/query-builder/Brackets.js +0 -19
  1334. package/.output/server/node_modules/typeorm/query-builder/DeleteQueryBuilder.js +0 -200
  1335. package/.output/server/node_modules/typeorm/query-builder/InsertQueryBuilder.js +0 -745
  1336. package/.output/server/node_modules/typeorm/query-builder/JoinAttribute.js +0 -175
  1337. package/.output/server/node_modules/typeorm/query-builder/NotBrackets.js +0 -17
  1338. package/.output/server/node_modules/typeorm/query-builder/QueryBuilder.js +0 -1139
  1339. package/.output/server/node_modules/typeorm/query-builder/QueryBuilderUtils.js +0 -32
  1340. package/.output/server/node_modules/typeorm/query-builder/QueryExpressionMap.js +0 -328
  1341. package/.output/server/node_modules/typeorm/query-builder/RelationIdLoader.js +0 -503
  1342. package/.output/server/node_modules/typeorm/query-builder/RelationLoader.js +0 -283
  1343. package/.output/server/node_modules/typeorm/query-builder/RelationQueryBuilder.js +0 -155
  1344. package/.output/server/node_modules/typeorm/query-builder/RelationRemover.js +0 -143
  1345. package/.output/server/node_modules/typeorm/query-builder/RelationUpdater.js +0 -152
  1346. package/.output/server/node_modules/typeorm/query-builder/ReturningResultsEntityUpdator.js +0 -176
  1347. package/.output/server/node_modules/typeorm/query-builder/SelectQueryBuilder.js +0 -2656
  1348. package/.output/server/node_modules/typeorm/query-builder/SoftDeleteQueryBuilder.js +0 -368
  1349. package/.output/server/node_modules/typeorm/query-builder/UpdateQueryBuilder.js +0 -498
  1350. package/.output/server/node_modules/typeorm/query-builder/index.js +0 -20
  1351. package/.output/server/node_modules/typeorm/query-builder/relation-count/RelationCountAttribute.js +0 -80
  1352. package/.output/server/node_modules/typeorm/query-builder/relation-count/RelationCountLoader.js +0 -168
  1353. package/.output/server/node_modules/typeorm/query-builder/relation-count/RelationCountMetadataToAttributeTransformer.js +0 -55
  1354. package/.output/server/node_modules/typeorm/query-builder/relation-id/RelationIdAttribute.js +0 -88
  1355. package/.output/server/node_modules/typeorm/query-builder/relation-id/RelationIdLoader.js +0 -275
  1356. package/.output/server/node_modules/typeorm/query-builder/relation-id/RelationIdMetadataToAttributeTransformer.js +0 -55
  1357. package/.output/server/node_modules/typeorm/query-builder/result/DeleteResult.js +0 -17
  1358. package/.output/server/node_modules/typeorm/query-builder/result/InsertResult.js +0 -28
  1359. package/.output/server/node_modules/typeorm/query-builder/result/UpdateResult.js +0 -29
  1360. package/.output/server/node_modules/typeorm/query-builder/transformer/DocumentToEntityTransformer.js +0 -196
  1361. package/.output/server/node_modules/typeorm/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.js +0 -112
  1362. package/.output/server/node_modules/typeorm/query-builder/transformer/PlainObjectToNewEntityTransformer.js +0 -92
  1363. package/.output/server/node_modules/typeorm/query-builder/transformer/RawSqlResultsToEntityTransformer.js +0 -447
  1364. package/.output/server/node_modules/typeorm/query-runner/BaseQueryRunner.js +0 -454
  1365. package/.output/server/node_modules/typeorm/query-runner/QueryLock.js +0 -28
  1366. package/.output/server/node_modules/typeorm/query-runner/QueryResult.js +0 -17
  1367. package/.output/server/node_modules/typeorm/repository/AbstractRepository.js +0 -92
  1368. package/.output/server/node_modules/typeorm/repository/BaseEntity.js +0 -328
  1369. package/.output/server/node_modules/typeorm/repository/MongoRepository.js +0 -305
  1370. package/.output/server/node_modules/typeorm/repository/RemoveOptions.js +0 -4
  1371. package/.output/server/node_modules/typeorm/repository/Repository.js +0 -379
  1372. package/.output/server/node_modules/typeorm/repository/SaveOptions.js +0 -4
  1373. package/.output/server/node_modules/typeorm/repository/TreeRepository.js +0 -255
  1374. package/.output/server/node_modules/typeorm/schema-builder/MongoSchemaBuilder.js +0 -66
  1375. package/.output/server/node_modules/typeorm/schema-builder/RdbmsSchemaBuilder.js +0 -929
  1376. package/.output/server/node_modules/typeorm/schema-builder/options/TableCheckOptions.js +0 -4
  1377. package/.output/server/node_modules/typeorm/schema-builder/options/TableColumnOptions.js +0 -4
  1378. package/.output/server/node_modules/typeorm/schema-builder/options/TableExclusionOptions.js +0 -4
  1379. package/.output/server/node_modules/typeorm/schema-builder/options/TableForeignKeyOptions.js +0 -4
  1380. package/.output/server/node_modules/typeorm/schema-builder/options/TableIndexOptions.js +0 -4
  1381. package/.output/server/node_modules/typeorm/schema-builder/options/TableOptions.js +0 -4
  1382. package/.output/server/node_modules/typeorm/schema-builder/options/TableUniqueOptions.js +0 -4
  1383. package/.output/server/node_modules/typeorm/schema-builder/options/ViewOptions.js +0 -4
  1384. package/.output/server/node_modules/typeorm/schema-builder/table/Table.js +0 -296
  1385. package/.output/server/node_modules/typeorm/schema-builder/table/TableCheck.js +0 -49
  1386. package/.output/server/node_modules/typeorm/schema-builder/table/TableColumn.js +0 -117
  1387. package/.output/server/node_modules/typeorm/schema-builder/table/TableExclusion.js +0 -43
  1388. package/.output/server/node_modules/typeorm/schema-builder/table/TableForeignKey.js +0 -72
  1389. package/.output/server/node_modules/typeorm/schema-builder/table/TableIndex.js +0 -68
  1390. package/.output/server/node_modules/typeorm/schema-builder/table/TableUnique.js +0 -50
  1391. package/.output/server/node_modules/typeorm/schema-builder/util/TableUtils.js +0 -41
  1392. package/.output/server/node_modules/typeorm/schema-builder/util/ViewUtils.js +0 -27
  1393. package/.output/server/node_modules/typeorm/schema-builder/view/View.js +0 -71
  1394. package/.output/server/node_modules/typeorm/subscriber/Broadcaster.js +0 -660
  1395. package/.output/server/node_modules/typeorm/subscriber/BroadcasterResult.js +0 -30
  1396. package/.output/server/node_modules/typeorm/subscriber/event/QueryEvent.js +0 -4
  1397. package/.output/server/node_modules/typeorm/util/ApplyValueTransformers.js +0 -25
  1398. package/.output/server/node_modules/typeorm/util/DateUtils.js +0 -229
  1399. package/.output/server/node_modules/typeorm/util/DepGraph.js +0 -230
  1400. package/.output/server/node_modules/typeorm/util/DirectoryExportedClassesLoader.js +0 -65
  1401. package/.output/server/node_modules/typeorm/util/ImportUtils.js +0 -66
  1402. package/.output/server/node_modules/typeorm/util/InstanceChecker.js +0 -104
  1403. package/.output/server/node_modules/typeorm/util/ObjectUtils.js +0 -49
  1404. package/.output/server/node_modules/typeorm/util/OrmUtils.js +0 -443
  1405. package/.output/server/node_modules/typeorm/util/PathUtils.js +0 -33
  1406. package/.output/server/node_modules/typeorm/util/RandomGenerator.js +0 -154
  1407. package/.output/server/node_modules/typeorm/util/SqlTagUtils.js +0 -43
  1408. package/.output/server/node_modules/typeorm/util/StringUtils.js +0 -113
  1409. package/.output/server/node_modules/typeorm/util/TreeRepositoryUtils.js +0 -67
  1410. package/.output/server/node_modules/typeorm/util/VersionUtils.js +0 -27
  1411. package/.output/server/node_modules/typeorm/util/escapeRegExp.js +0 -10
  1412. package/.output/server/node_modules/uuid/dist/cjs/index.js +0 -31
  1413. package/.output/server/node_modules/uuid/dist/cjs/max.js +0 -3
  1414. package/.output/server/node_modules/uuid/dist/cjs/md5.js +0 -13
  1415. package/.output/server/node_modules/uuid/dist/cjs/native.js +0 -4
  1416. package/.output/server/node_modules/uuid/dist/cjs/nil.js +0 -3
  1417. package/.output/server/node_modules/uuid/dist/cjs/package.json +0 -1
  1418. package/.output/server/node_modules/uuid/dist/cjs/parse.js +0 -11
  1419. package/.output/server/node_modules/uuid/dist/cjs/regex.js +0 -3
  1420. package/.output/server/node_modules/uuid/dist/cjs/rng.js +0 -13
  1421. package/.output/server/node_modules/uuid/dist/cjs/sha1.js +0 -13
  1422. package/.output/server/node_modules/uuid/dist/cjs/stringify.js +0 -39
  1423. package/.output/server/node_modules/uuid/dist/cjs/v1.js +0 -87
  1424. package/.output/server/node_modules/uuid/dist/cjs/v1ToV6.js +0 -13
  1425. package/.output/server/node_modules/uuid/dist/cjs/v3.js +0 -14
  1426. package/.output/server/node_modules/uuid/dist/cjs/v35.js +0 -41
  1427. package/.output/server/node_modules/uuid/dist/cjs/v4.js +0 -29
  1428. package/.output/server/node_modules/uuid/dist/cjs/v5.js +0 -14
  1429. package/.output/server/node_modules/uuid/dist/cjs/v6.js +0 -19
  1430. package/.output/server/node_modules/uuid/dist/cjs/v6ToV1.js +0 -13
  1431. package/.output/server/node_modules/uuid/dist/cjs/v7.js +0 -69
  1432. package/.output/server/node_modules/uuid/dist/cjs/validate.js +0 -7
  1433. package/.output/server/node_modules/uuid/dist/cjs/version.js +0 -10
  1434. package/.output/server/node_modules/uuid/package.json +0 -132
@@ -0,0 +1,4052 @@
1
+ 'use strict';
2
+
3
+ const EventEmitter = require('events');
4
+ const fs = require('fs');
5
+ const { constants } = fs;
6
+ const {
7
+ Readable: ReadableStream,
8
+ Writable: WritableStream
9
+ } = require('stream');
10
+ const { inherits, types: { isDate } } = require('util');
11
+
12
+ const FastBuffer = Buffer[Symbol.species];
13
+
14
+ const {
15
+ bufferCopy,
16
+ bufferSlice,
17
+ makeBufferParser,
18
+ writeUInt32BE,
19
+ } = require('./utils.js');
20
+
21
+ const ATTR = {
22
+ SIZE: 0x00000001,
23
+ UIDGID: 0x00000002,
24
+ PERMISSIONS: 0x00000004,
25
+ ACMODTIME: 0x00000008,
26
+ EXTENDED: 0x80000000,
27
+ };
28
+
29
+ // Large enough to store all possible attributes
30
+ const ATTRS_BUF = Buffer.alloc(28);
31
+
32
+ const STATUS_CODE = {
33
+ OK: 0,
34
+ EOF: 1,
35
+ NO_SUCH_FILE: 2,
36
+ PERMISSION_DENIED: 3,
37
+ FAILURE: 4,
38
+ BAD_MESSAGE: 5,
39
+ NO_CONNECTION: 6,
40
+ CONNECTION_LOST: 7,
41
+ OP_UNSUPPORTED: 8
42
+ };
43
+
44
+ const VALID_STATUS_CODES = new Map(
45
+ Object.values(STATUS_CODE).map((n) => [n, 1])
46
+ );
47
+
48
+ const STATUS_CODE_STR = {
49
+ [STATUS_CODE.OK]: 'No error',
50
+ [STATUS_CODE.EOF]: 'End of file',
51
+ [STATUS_CODE.NO_SUCH_FILE]: 'No such file or directory',
52
+ [STATUS_CODE.PERMISSION_DENIED]: 'Permission denied',
53
+ [STATUS_CODE.FAILURE]: 'Failure',
54
+ [STATUS_CODE.BAD_MESSAGE]: 'Bad message',
55
+ [STATUS_CODE.NO_CONNECTION]: 'No connection',
56
+ [STATUS_CODE.CONNECTION_LOST]: 'Connection lost',
57
+ [STATUS_CODE.OP_UNSUPPORTED]: 'Operation unsupported',
58
+ };
59
+
60
+ const REQUEST = {
61
+ INIT: 1,
62
+ OPEN: 3,
63
+ CLOSE: 4,
64
+ READ: 5,
65
+ WRITE: 6,
66
+ LSTAT: 7,
67
+ FSTAT: 8,
68
+ SETSTAT: 9,
69
+ FSETSTAT: 10,
70
+ OPENDIR: 11,
71
+ READDIR: 12,
72
+ REMOVE: 13,
73
+ MKDIR: 14,
74
+ RMDIR: 15,
75
+ REALPATH: 16,
76
+ STAT: 17,
77
+ RENAME: 18,
78
+ READLINK: 19,
79
+ SYMLINK: 20,
80
+ EXTENDED: 200
81
+ };
82
+
83
+ const RESPONSE = {
84
+ VERSION: 2,
85
+ STATUS: 101,
86
+ HANDLE: 102,
87
+ DATA: 103,
88
+ NAME: 104,
89
+ ATTRS: 105,
90
+ EXTENDED: 201
91
+ };
92
+
93
+ const OPEN_MODE = {
94
+ READ: 0x00000001,
95
+ WRITE: 0x00000002,
96
+ APPEND: 0x00000004,
97
+ CREAT: 0x00000008,
98
+ TRUNC: 0x00000010,
99
+ EXCL: 0x00000020
100
+ };
101
+
102
+ const PKT_RW_OVERHEAD = 2 * 1024;
103
+ const MAX_REQID = 2 ** 32 - 1;
104
+ const CLIENT_VERSION_BUFFER = Buffer.from([
105
+ 0, 0, 0, 5 /* length */,
106
+ REQUEST.INIT,
107
+ 0, 0, 0, 3 /* version */
108
+ ]);
109
+ const SERVER_VERSION_BUFFER = Buffer.from([
110
+ 0, 0, 0, 5 /* length */,
111
+ RESPONSE.VERSION,
112
+ 0, 0, 0, 3 /* version */
113
+ ]);
114
+
115
+ const RE_OPENSSH = /^SSH-2.0-(?:OpenSSH|dropbear)/;
116
+ const OPENSSH_MAX_PKT_LEN = 256 * 1024;
117
+
118
+ const bufferParser = makeBufferParser();
119
+
120
+ const fakeStderr = {
121
+ readable: false,
122
+ writable: false,
123
+ push: (data) => {},
124
+ once: () => {},
125
+ on: () => {},
126
+ emit: () => {},
127
+ end: () => {},
128
+ };
129
+
130
+ function noop() {}
131
+
132
+ // Emulates enough of `Channel` to be able to be used as a drop-in replacement
133
+ // in order to process incoming data with as little overhead as possible
134
+ class SFTP extends EventEmitter {
135
+ constructor(client, chanInfo, cfg) {
136
+ super();
137
+
138
+ if (typeof cfg !== 'object' || !cfg)
139
+ cfg = {};
140
+
141
+ const remoteIdentRaw = client._protocol._remoteIdentRaw;
142
+
143
+ this.server = !!cfg.server;
144
+ this._debug = (typeof cfg.debug === 'function' ? cfg.debug : undefined);
145
+ this._isOpenSSH = (remoteIdentRaw && RE_OPENSSH.test(remoteIdentRaw));
146
+
147
+ this._version = -1;
148
+ this._extensions = {};
149
+ this._biOpt = cfg.biOpt;
150
+ this._pktLenBytes = 0;
151
+ this._pktLen = 0;
152
+ this._pktPos = 0;
153
+ this._pktType = 0;
154
+ this._pktData = undefined;
155
+ this._writeReqid = -1;
156
+ this._requests = {};
157
+ this._maxInPktLen = OPENSSH_MAX_PKT_LEN;
158
+ this._maxOutPktLen = 34000;
159
+ this._maxReadLen =
160
+ (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;
161
+ this._maxWriteLen =
162
+ (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;
163
+
164
+ this.maxOpenHandles = undefined;
165
+
166
+ // Channel compatibility
167
+ this._client = client;
168
+ this._protocol = client._protocol;
169
+ this._callbacks = [];
170
+ this._hasX11 = false;
171
+ this._exit = {
172
+ code: undefined,
173
+ signal: undefined,
174
+ dump: undefined,
175
+ desc: undefined,
176
+ };
177
+ this._waitWindow = false; // SSH-level backpressure
178
+ this._chunkcb = undefined;
179
+ this._buffer = [];
180
+ this.type = chanInfo.type;
181
+ this.subtype = undefined;
182
+ this.incoming = chanInfo.incoming;
183
+ this.outgoing = chanInfo.outgoing;
184
+ this.stderr = fakeStderr;
185
+ this.readable = true;
186
+ }
187
+
188
+ // This handles incoming data to parse
189
+ push(data) {
190
+ if (data === null) {
191
+ cleanupRequests(this);
192
+ if (!this.readable)
193
+ return;
194
+ // No more incoming data from the remote side
195
+ this.readable = false;
196
+ this.emit('end');
197
+ return;
198
+ }
199
+ /*
200
+ uint32 length
201
+ byte type
202
+ byte[length - 1] data payload
203
+ */
204
+ let p = 0;
205
+
206
+ while (p < data.length) {
207
+ if (this._pktLenBytes < 4) {
208
+ let nb = Math.min(4 - this._pktLenBytes, data.length - p);
209
+ this._pktLenBytes += nb;
210
+
211
+ while (nb--)
212
+ this._pktLen = (this._pktLen << 8) + data[p++];
213
+
214
+ if (this._pktLenBytes < 4)
215
+ return;
216
+ if (this._pktLen === 0)
217
+ return doFatalSFTPError(this, 'Invalid packet length');
218
+ if (this._pktLen > this._maxInPktLen) {
219
+ const max = this._maxInPktLen;
220
+ return doFatalSFTPError(
221
+ this,
222
+ `Packet length ${this._pktLen} exceeds max length of ${max}`
223
+ );
224
+ }
225
+ if (p >= data.length)
226
+ return;
227
+ }
228
+ if (this._pktPos < this._pktLen) {
229
+ const nb = Math.min(this._pktLen - this._pktPos, data.length - p);
230
+ if (p !== 0 || nb !== data.length) {
231
+ if (nb === this._pktLen) {
232
+ this._pkt = new FastBuffer(data.buffer, data.byteOffset + p, nb);
233
+ } else {
234
+ if (!this._pkt)
235
+ this._pkt = Buffer.allocUnsafe(this._pktLen);
236
+ this._pkt.set(
237
+ new Uint8Array(data.buffer, data.byteOffset + p, nb),
238
+ this._pktPos
239
+ );
240
+ }
241
+ } else if (nb === this._pktLen) {
242
+ this._pkt = data;
243
+ } else {
244
+ if (!this._pkt)
245
+ this._pkt = Buffer.allocUnsafe(this._pktLen);
246
+ this._pkt.set(data, this._pktPos);
247
+ }
248
+ p += nb;
249
+ this._pktPos += nb;
250
+ if (this._pktPos < this._pktLen)
251
+ return;
252
+ }
253
+
254
+ const type = this._pkt[0];
255
+ const payload = this._pkt;
256
+
257
+ // Prepare for next packet
258
+ this._pktLen = 0;
259
+ this._pktLenBytes = 0;
260
+ this._pkt = undefined;
261
+ this._pktPos = 0;
262
+
263
+ const handler = (this.server
264
+ ? SERVER_HANDLERS[type]
265
+ : CLIENT_HANDLERS[type]);
266
+ if (!handler)
267
+ return doFatalSFTPError(this, `Unknown packet type ${type}`);
268
+
269
+ if (this._version === -1) {
270
+ if (this.server) {
271
+ if (type !== REQUEST.INIT)
272
+ return doFatalSFTPError(this, `Expected INIT packet, got ${type}`);
273
+ } else if (type !== RESPONSE.VERSION) {
274
+ return doFatalSFTPError(this, `Expected VERSION packet, got ${type}`);
275
+ }
276
+ }
277
+
278
+ if (handler(this, payload) === false)
279
+ return;
280
+ }
281
+ }
282
+
283
+ end() {
284
+ this.destroy();
285
+ }
286
+ destroy() {
287
+ if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {
288
+ this.outgoing.state = 'closing';
289
+ this._protocol.channelClose(this.outgoing.id);
290
+ }
291
+ }
292
+ _init() {
293
+ this._init = noop;
294
+ if (!this.server)
295
+ sendOrBuffer(this, CLIENT_VERSION_BUFFER);
296
+ }
297
+
298
+ // ===========================================================================
299
+ // Client-specific ===========================================================
300
+ // ===========================================================================
301
+ createReadStream(path, options) {
302
+ if (this.server)
303
+ throw new Error('Client-only method called in server mode');
304
+
305
+ return new ReadStream(this, path, options);
306
+ }
307
+ createWriteStream(path, options) {
308
+ if (this.server)
309
+ throw new Error('Client-only method called in server mode');
310
+
311
+ return new WriteStream(this, path, options);
312
+ }
313
+ open(path, flags_, attrs, cb) {
314
+ if (this.server)
315
+ throw new Error('Client-only method called in server mode');
316
+
317
+ if (typeof attrs === 'function') {
318
+ cb = attrs;
319
+ attrs = undefined;
320
+ }
321
+
322
+ const flags = (typeof flags_ === 'number' ? flags_ : stringToFlags(flags_));
323
+ if (flags === null)
324
+ throw new Error(`Unknown flags string: ${flags_}`);
325
+
326
+ let attrsFlags = 0;
327
+ let attrsLen = 0;
328
+ if (typeof attrs === 'string' || typeof attrs === 'number')
329
+ attrs = { mode: attrs };
330
+ if (typeof attrs === 'object' && attrs !== null) {
331
+ attrs = attrsToBytes(attrs);
332
+ attrsFlags = attrs.flags;
333
+ attrsLen = attrs.nb;
334
+ }
335
+
336
+ /*
337
+ uint32 id
338
+ string filename
339
+ uint32 pflags
340
+ ATTRS attrs
341
+ */
342
+ const pathLen = Buffer.byteLength(path);
343
+ let p = 9;
344
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + 4 + attrsLen);
345
+
346
+ writeUInt32BE(buf, buf.length - 4, 0);
347
+ buf[4] = REQUEST.OPEN;
348
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
349
+ writeUInt32BE(buf, reqid, 5);
350
+
351
+ writeUInt32BE(buf, pathLen, p);
352
+ buf.utf8Write(path, p += 4, pathLen);
353
+ writeUInt32BE(buf, flags, p += pathLen);
354
+ writeUInt32BE(buf, attrsFlags, p += 4);
355
+ if (attrsLen) {
356
+ p += 4;
357
+
358
+ if (attrsLen === ATTRS_BUF.length)
359
+ buf.set(ATTRS_BUF, p);
360
+ else
361
+ bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);
362
+
363
+ p += attrsLen;
364
+ }
365
+ this._requests[reqid] = { cb };
366
+
367
+ const isBuffered = sendOrBuffer(this, buf);
368
+ this._debug && this._debug(
369
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPEN`
370
+ );
371
+ }
372
+ close(handle, cb) {
373
+ if (this.server)
374
+ throw new Error('Client-only method called in server mode');
375
+
376
+ if (!Buffer.isBuffer(handle))
377
+ throw new Error('handle is not a Buffer');
378
+
379
+ /*
380
+ uint32 id
381
+ string handle
382
+ */
383
+ const handleLen = handle.length;
384
+ let p = 9;
385
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);
386
+
387
+ writeUInt32BE(buf, buf.length - 4, 0);
388
+ buf[4] = REQUEST.CLOSE;
389
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
390
+ writeUInt32BE(buf, reqid, 5);
391
+
392
+ writeUInt32BE(buf, handleLen, p);
393
+ buf.set(handle, p += 4);
394
+
395
+ this._requests[reqid] = { cb };
396
+
397
+ const isBuffered = sendOrBuffer(this, buf);
398
+ this._debug && this._debug(
399
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} CLOSE`
400
+ );
401
+ }
402
+ read(handle, buf, off, len, position, cb) {
403
+ if (this.server)
404
+ throw new Error('Client-only method called in server mode');
405
+ if (!Buffer.isBuffer(handle))
406
+ throw new Error('handle is not a Buffer');
407
+ if (!Buffer.isBuffer(buf))
408
+ throw new Error('buffer is not a Buffer');
409
+ if (off >= buf.length)
410
+ throw new Error('offset is out of bounds');
411
+ if (off + len > buf.length)
412
+ throw new Error('length extends beyond buffer');
413
+ if (position === null)
414
+ throw new Error('null position currently unsupported');
415
+
416
+ read_(this, handle, buf, off, len, position, cb);
417
+ }
418
+ readData(handle, buf, off, len, position, cb) {
419
+ // Backwards compatibility
420
+ this.read(handle, buf, off, len, position, cb);
421
+ }
422
+ write(handle, buf, off, len, position, cb) {
423
+ if (this.server)
424
+ throw new Error('Client-only method called in server mode');
425
+
426
+ if (!Buffer.isBuffer(handle))
427
+ throw new Error('handle is not a Buffer');
428
+ if (!Buffer.isBuffer(buf))
429
+ throw new Error('buffer is not a Buffer');
430
+ if (off > buf.length)
431
+ throw new Error('offset is out of bounds');
432
+ if (off + len > buf.length)
433
+ throw new Error('length extends beyond buffer');
434
+ if (position === null)
435
+ throw new Error('null position currently unsupported');
436
+
437
+ if (!len) {
438
+ cb && process.nextTick(cb, undefined, 0);
439
+ return;
440
+ }
441
+
442
+ const maxDataLen = this._maxWriteLen;
443
+ const overflow = Math.max(len - maxDataLen, 0);
444
+ const origPosition = position;
445
+
446
+ if (overflow)
447
+ len = maxDataLen;
448
+
449
+ /*
450
+ uint32 id
451
+ string handle
452
+ uint64 offset
453
+ string data
454
+ */
455
+ const handleLen = handle.length;
456
+ let p = 9;
457
+ const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4 + len);
458
+
459
+ writeUInt32BE(out, out.length - 4, 0);
460
+ out[4] = REQUEST.WRITE;
461
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
462
+ writeUInt32BE(out, reqid, 5);
463
+
464
+ writeUInt32BE(out, handleLen, p);
465
+ out.set(handle, p += 4);
466
+ p += handleLen;
467
+ for (let i = 7; i >= 0; --i) {
468
+ out[p + i] = position & 0xFF;
469
+ position /= 256;
470
+ }
471
+ writeUInt32BE(out, len, p += 8);
472
+ bufferCopy(buf, out, off, off + len, p += 4);
473
+
474
+ this._requests[reqid] = {
475
+ cb: (err) => {
476
+ if (err) {
477
+ if (typeof cb === 'function')
478
+ cb(err);
479
+ } else if (overflow) {
480
+ this.write(handle,
481
+ buf,
482
+ off + len,
483
+ overflow,
484
+ origPosition + len,
485
+ cb);
486
+ } else if (typeof cb === 'function') {
487
+ cb(undefined, off + len);
488
+ }
489
+ }
490
+ };
491
+
492
+ const isSent = sendOrBuffer(this, out);
493
+ if (this._debug) {
494
+ const how = (isSent ? 'Sent' : 'Buffered');
495
+ this._debug(`SFTP: Outbound: ${how} WRITE (id:${reqid})`);
496
+ }
497
+ }
498
+ writeData(handle, buf, off, len, position, cb) {
499
+ // Backwards compatibility
500
+ this.write(handle, buf, off, len, position, cb);
501
+ }
502
+ fastGet(remotePath, localPath, opts, cb) {
503
+ if (this.server)
504
+ throw new Error('Client-only method called in server mode');
505
+
506
+ fastXfer(this, fs, remotePath, localPath, opts, cb);
507
+ }
508
+ fastPut(localPath, remotePath, opts, cb) {
509
+ if (this.server)
510
+ throw new Error('Client-only method called in server mode');
511
+
512
+ fastXfer(fs, this, localPath, remotePath, opts, cb);
513
+ }
514
+ readFile(path, options, callback_) {
515
+ if (this.server)
516
+ throw new Error('Client-only method called in server mode');
517
+
518
+ let callback;
519
+ if (typeof callback_ === 'function') {
520
+ callback = callback_;
521
+ } else if (typeof options === 'function') {
522
+ callback = options;
523
+ options = undefined;
524
+ }
525
+
526
+ if (typeof options === 'string')
527
+ options = { encoding: options, flag: 'r' };
528
+ else if (!options)
529
+ options = { encoding: null, flag: 'r' };
530
+ else if (typeof options !== 'object')
531
+ throw new TypeError('Bad arguments');
532
+
533
+ const encoding = options.encoding;
534
+ if (encoding && !Buffer.isEncoding(encoding))
535
+ throw new Error(`Unknown encoding: ${encoding}`);
536
+
537
+ // First stat the file, so we know the size.
538
+ let size;
539
+ let buffer; // Single buffer with file data
540
+ let buffers; // List for when size is unknown
541
+ let pos = 0;
542
+ let handle;
543
+
544
+ // SFTPv3 does not support using -1 for read position, so we have to track
545
+ // read position manually
546
+ let bytesRead = 0;
547
+
548
+ const flag = options.flag || 'r';
549
+
550
+ const read = () => {
551
+ if (size === 0) {
552
+ buffer = Buffer.allocUnsafe(8192);
553
+ this.read(handle, buffer, 0, 8192, bytesRead, afterRead);
554
+ } else {
555
+ this.read(handle, buffer, pos, size - pos, bytesRead, afterRead);
556
+ }
557
+ };
558
+
559
+ const afterRead = (er, nbytes) => {
560
+ let eof;
561
+ if (er) {
562
+ eof = (er.code === STATUS_CODE.EOF);
563
+ if (!eof) {
564
+ return this.close(handle, () => {
565
+ return callback && callback(er);
566
+ });
567
+ }
568
+ } else {
569
+ eof = false;
570
+ }
571
+
572
+ if (eof || (size === 0 && nbytes === 0))
573
+ return close();
574
+
575
+ bytesRead += nbytes;
576
+ pos += nbytes;
577
+ if (size !== 0) {
578
+ if (pos === size)
579
+ close();
580
+ else
581
+ read();
582
+ } else {
583
+ // Unknown size, just read until we don't get bytes.
584
+ buffers.push(bufferSlice(buffer, 0, nbytes));
585
+ read();
586
+ }
587
+ };
588
+ afterRead._wantEOFError = true;
589
+
590
+ const close = () => {
591
+ this.close(handle, (er) => {
592
+ if (size === 0) {
593
+ // Collect the data into the buffers list.
594
+ buffer = Buffer.concat(buffers, pos);
595
+ } else if (pos < size) {
596
+ buffer = bufferSlice(buffer, 0, pos);
597
+ }
598
+
599
+ if (encoding)
600
+ buffer = buffer.toString(encoding);
601
+ return callback && callback(er, buffer);
602
+ });
603
+ };
604
+
605
+ this.open(path, flag, 0o666, (er, handle_) => {
606
+ if (er)
607
+ return callback && callback(er);
608
+ handle = handle_;
609
+
610
+ const tryStat = (er, st) => {
611
+ if (er) {
612
+ // Try stat() for sftp servers that may not support fstat() for
613
+ // whatever reason
614
+ this.stat(path, (er_, st_) => {
615
+ if (er_) {
616
+ return this.close(handle, () => {
617
+ callback && callback(er);
618
+ });
619
+ }
620
+ tryStat(null, st_);
621
+ });
622
+ return;
623
+ }
624
+
625
+ size = st.size || 0;
626
+ if (size === 0) {
627
+ // The kernel lies about many files.
628
+ // Go ahead and try to read some bytes.
629
+ buffers = [];
630
+ return read();
631
+ }
632
+
633
+ buffer = Buffer.allocUnsafe(size);
634
+ read();
635
+ };
636
+ this.fstat(handle, tryStat);
637
+ });
638
+ }
639
+ writeFile(path, data, options, callback_) {
640
+ if (this.server)
641
+ throw new Error('Client-only method called in server mode');
642
+
643
+ let callback;
644
+ if (typeof callback_ === 'function') {
645
+ callback = callback_;
646
+ } else if (typeof options === 'function') {
647
+ callback = options;
648
+ options = undefined;
649
+ }
650
+
651
+ if (typeof options === 'string')
652
+ options = { encoding: options, mode: 0o666, flag: 'w' };
653
+ else if (!options)
654
+ options = { encoding: 'utf8', mode: 0o666, flag: 'w' };
655
+ else if (typeof options !== 'object')
656
+ throw new TypeError('Bad arguments');
657
+
658
+ if (options.encoding && !Buffer.isEncoding(options.encoding))
659
+ throw new Error(`Unknown encoding: ${options.encoding}`);
660
+
661
+ const flag = options.flag || 'w';
662
+ this.open(path, flag, options.mode, (openErr, handle) => {
663
+ if (openErr) {
664
+ callback && callback(openErr);
665
+ } else {
666
+ const buffer = (Buffer.isBuffer(data)
667
+ ? data
668
+ : Buffer.from('' + data, options.encoding || 'utf8'));
669
+ const position = (/a/.test(flag) ? null : 0);
670
+
671
+ // SFTPv3 does not support the notion of 'current position'
672
+ // (null position), so we just attempt to append to the end of the file
673
+ // instead
674
+ if (position === null) {
675
+ const tryStat = (er, st) => {
676
+ if (er) {
677
+ // Try stat() for sftp servers that may not support fstat() for
678
+ // whatever reason
679
+ this.stat(path, (er_, st_) => {
680
+ if (er_) {
681
+ return this.close(handle, () => {
682
+ callback && callback(er);
683
+ });
684
+ }
685
+ tryStat(null, st_);
686
+ });
687
+ return;
688
+ }
689
+ writeAll(this, handle, buffer, 0, buffer.length, st.size, callback);
690
+ };
691
+ this.fstat(handle, tryStat);
692
+ return;
693
+ }
694
+ writeAll(this, handle, buffer, 0, buffer.length, position, callback);
695
+ }
696
+ });
697
+ }
698
+ appendFile(path, data, options, callback_) {
699
+ if (this.server)
700
+ throw new Error('Client-only method called in server mode');
701
+
702
+ let callback;
703
+ if (typeof callback_ === 'function') {
704
+ callback = callback_;
705
+ } else if (typeof options === 'function') {
706
+ callback = options;
707
+ options = undefined;
708
+ }
709
+
710
+ if (typeof options === 'string')
711
+ options = { encoding: options, mode: 0o666, flag: 'a' };
712
+ else if (!options)
713
+ options = { encoding: 'utf8', mode: 0o666, flag: 'a' };
714
+ else if (typeof options !== 'object')
715
+ throw new TypeError('Bad arguments');
716
+
717
+ if (!options.flag)
718
+ options = Object.assign({ flag: 'a' }, options);
719
+ this.writeFile(path, data, options, callback);
720
+ }
721
+ exists(path, cb) {
722
+ if (this.server)
723
+ throw new Error('Client-only method called in server mode');
724
+
725
+ this.stat(path, (err) => {
726
+ cb && cb(err ? false : true);
727
+ });
728
+ }
729
+ unlink(filename, cb) {
730
+ if (this.server)
731
+ throw new Error('Client-only method called in server mode');
732
+
733
+ /*
734
+ uint32 id
735
+ string filename
736
+ */
737
+ const fnameLen = Buffer.byteLength(filename);
738
+ let p = 9;
739
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + fnameLen);
740
+
741
+ writeUInt32BE(buf, buf.length - 4, 0);
742
+ buf[4] = REQUEST.REMOVE;
743
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
744
+ writeUInt32BE(buf, reqid, 5);
745
+
746
+ writeUInt32BE(buf, fnameLen, p);
747
+ buf.utf8Write(filename, p += 4, fnameLen);
748
+
749
+ this._requests[reqid] = { cb };
750
+
751
+ const isBuffered = sendOrBuffer(this, buf);
752
+ this._debug && this._debug(
753
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REMOVE`
754
+ );
755
+ }
756
+ rename(oldPath, newPath, cb) {
757
+ if (this.server)
758
+ throw new Error('Client-only method called in server mode');
759
+
760
+ /*
761
+ uint32 id
762
+ string oldpath
763
+ string newpath
764
+ */
765
+ const oldLen = Buffer.byteLength(oldPath);
766
+ const newLen = Buffer.byteLength(newPath);
767
+ let p = 9;
768
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + oldLen + 4 + newLen);
769
+
770
+ writeUInt32BE(buf, buf.length - 4, 0);
771
+ buf[4] = REQUEST.RENAME;
772
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
773
+ writeUInt32BE(buf, reqid, 5);
774
+
775
+ writeUInt32BE(buf, oldLen, p);
776
+ buf.utf8Write(oldPath, p += 4, oldLen);
777
+ writeUInt32BE(buf, newLen, p += oldLen);
778
+ buf.utf8Write(newPath, p += 4, newLen);
779
+
780
+ this._requests[reqid] = { cb };
781
+
782
+ const isBuffered = sendOrBuffer(this, buf);
783
+ this._debug && this._debug(
784
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RENAME`
785
+ );
786
+ }
787
+ mkdir(path, attrs, cb) {
788
+ if (this.server)
789
+ throw new Error('Client-only method called in server mode');
790
+
791
+ let flags = 0;
792
+ let attrsLen = 0;
793
+
794
+ if (typeof attrs === 'function') {
795
+ cb = attrs;
796
+ attrs = undefined;
797
+ }
798
+ if (typeof attrs === 'object' && attrs !== null) {
799
+ attrs = attrsToBytes(attrs);
800
+ flags = attrs.flags;
801
+ attrsLen = attrs.nb;
802
+ }
803
+
804
+ /*
805
+ uint32 id
806
+ string path
807
+ ATTRS attrs
808
+ */
809
+ const pathLen = Buffer.byteLength(path);
810
+ let p = 9;
811
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);
812
+
813
+ writeUInt32BE(buf, buf.length - 4, 0);
814
+ buf[4] = REQUEST.MKDIR;
815
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
816
+ writeUInt32BE(buf, reqid, 5);
817
+
818
+ writeUInt32BE(buf, pathLen, p);
819
+ buf.utf8Write(path, p += 4, pathLen);
820
+ writeUInt32BE(buf, flags, p += pathLen);
821
+ if (attrsLen) {
822
+ p += 4;
823
+
824
+ if (attrsLen === ATTRS_BUF.length)
825
+ buf.set(ATTRS_BUF, p);
826
+ else
827
+ bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);
828
+
829
+ p += attrsLen;
830
+ }
831
+
832
+ this._requests[reqid] = { cb };
833
+
834
+ const isBuffered = sendOrBuffer(this, buf);
835
+ this._debug && this._debug(
836
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} MKDIR`
837
+ );
838
+ }
839
+ rmdir(path, cb) {
840
+ if (this.server)
841
+ throw new Error('Client-only method called in server mode');
842
+
843
+ /*
844
+ uint32 id
845
+ string path
846
+ */
847
+ const pathLen = Buffer.byteLength(path);
848
+ let p = 9;
849
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
850
+
851
+ writeUInt32BE(buf, buf.length - 4, 0);
852
+ buf[4] = REQUEST.RMDIR;
853
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
854
+ writeUInt32BE(buf, reqid, 5);
855
+
856
+ writeUInt32BE(buf, pathLen, p);
857
+ buf.utf8Write(path, p += 4, pathLen);
858
+
859
+ this._requests[reqid] = { cb };
860
+
861
+ const isBuffered = sendOrBuffer(this, buf);
862
+ this._debug && this._debug(
863
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RMDIR`
864
+ );
865
+ }
866
+ readdir(where, opts, cb) {
867
+ if (this.server)
868
+ throw new Error('Client-only method called in server mode');
869
+
870
+ if (typeof opts === 'function') {
871
+ cb = opts;
872
+ opts = {};
873
+ }
874
+ if (typeof opts !== 'object' || opts === null)
875
+ opts = {};
876
+
877
+ const doFilter = (opts && opts.full ? false : true);
878
+
879
+ if (!Buffer.isBuffer(where) && typeof where !== 'string')
880
+ throw new Error('missing directory handle or path');
881
+
882
+ if (typeof where === 'string') {
883
+ const entries = [];
884
+ let e = 0;
885
+
886
+ const reread = (err, handle) => {
887
+ if (err)
888
+ return cb(err);
889
+
890
+ this.readdir(handle, opts, (err, list) => {
891
+ const eof = (err && err.code === STATUS_CODE.EOF);
892
+
893
+ if (err && !eof)
894
+ return this.close(handle, () => cb(err));
895
+
896
+ if (eof) {
897
+ return this.close(handle, (err) => {
898
+ if (err)
899
+ return cb(err);
900
+ cb(undefined, entries);
901
+ });
902
+ }
903
+
904
+ for (let i = 0; i < list.length; ++i, ++e)
905
+ entries[e] = list[i];
906
+
907
+ reread(undefined, handle);
908
+ });
909
+ };
910
+ return this.opendir(where, reread);
911
+ }
912
+
913
+ /*
914
+ uint32 id
915
+ string handle
916
+ */
917
+ const handleLen = where.length;
918
+ let p = 9;
919
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);
920
+
921
+ writeUInt32BE(buf, buf.length - 4, 0);
922
+ buf[4] = REQUEST.READDIR;
923
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
924
+ writeUInt32BE(buf, reqid, 5);
925
+
926
+ writeUInt32BE(buf, handleLen, p);
927
+ buf.set(where, p += 4);
928
+
929
+ this._requests[reqid] = {
930
+ cb: (doFilter
931
+ ? (err, list) => {
932
+ if (typeof cb !== 'function')
933
+ return;
934
+ if (err)
935
+ return cb(err);
936
+
937
+ for (let i = list.length - 1; i >= 0; --i) {
938
+ if (list[i].filename === '.' || list[i].filename === '..')
939
+ list.splice(i, 1);
940
+ }
941
+
942
+ cb(undefined, list);
943
+ }
944
+ : cb)
945
+ };
946
+
947
+ const isBuffered = sendOrBuffer(this, buf);
948
+ this._debug && this._debug(
949
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READDIR`
950
+ );
951
+ }
952
+ fstat(handle, cb) {
953
+ if (this.server)
954
+ throw new Error('Client-only method called in server mode');
955
+
956
+ if (!Buffer.isBuffer(handle))
957
+ throw new Error('handle is not a Buffer');
958
+
959
+ /*
960
+ uint32 id
961
+ string handle
962
+ */
963
+ const handleLen = handle.length;
964
+ let p = 9;
965
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);
966
+
967
+ writeUInt32BE(buf, buf.length - 4, 0);
968
+ buf[4] = REQUEST.FSTAT;
969
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
970
+ writeUInt32BE(buf, reqid, 5);
971
+
972
+ writeUInt32BE(buf, handleLen, p);
973
+ buf.set(handle, p += 4);
974
+
975
+ this._requests[reqid] = { cb };
976
+
977
+ const isBuffered = sendOrBuffer(this, buf);
978
+ this._debug && this._debug(
979
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSTAT`
980
+ );
981
+ }
982
+ stat(path, cb) {
983
+ if (this.server)
984
+ throw new Error('Client-only method called in server mode');
985
+
986
+ /*
987
+ uint32 id
988
+ string path
989
+ */
990
+ const pathLen = Buffer.byteLength(path);
991
+ let p = 9;
992
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
993
+
994
+ writeUInt32BE(buf, buf.length - 4, 0);
995
+ buf[4] = REQUEST.STAT;
996
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
997
+ writeUInt32BE(buf, reqid, 5);
998
+
999
+ writeUInt32BE(buf, pathLen, p);
1000
+ buf.utf8Write(path, p += 4, pathLen);
1001
+
1002
+ this._requests[reqid] = { cb };
1003
+
1004
+ const isBuffered = sendOrBuffer(this, buf);
1005
+ this._debug && this._debug(
1006
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STAT`
1007
+ );
1008
+ }
1009
+ lstat(path, cb) {
1010
+ if (this.server)
1011
+ throw new Error('Client-only method called in server mode');
1012
+
1013
+ /*
1014
+ uint32 id
1015
+ string path
1016
+ */
1017
+ const pathLen = Buffer.byteLength(path);
1018
+ let p = 9;
1019
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
1020
+
1021
+ writeUInt32BE(buf, buf.length - 4, 0);
1022
+ buf[4] = REQUEST.LSTAT;
1023
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1024
+ writeUInt32BE(buf, reqid, 5);
1025
+
1026
+ writeUInt32BE(buf, pathLen, p);
1027
+ buf.utf8Write(path, p += 4, pathLen);
1028
+
1029
+ this._requests[reqid] = { cb };
1030
+
1031
+ const isBuffered = sendOrBuffer(this, buf);
1032
+ this._debug && this._debug(
1033
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} LSTAT`
1034
+ );
1035
+ }
1036
+ opendir(path, cb) {
1037
+ if (this.server)
1038
+ throw new Error('Client-only method called in server mode');
1039
+
1040
+ /*
1041
+ uint32 id
1042
+ string path
1043
+ */
1044
+ const pathLen = Buffer.byteLength(path);
1045
+ let p = 9;
1046
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
1047
+
1048
+ writeUInt32BE(buf, buf.length - 4, 0);
1049
+ buf[4] = REQUEST.OPENDIR;
1050
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1051
+ writeUInt32BE(buf, reqid, 5);
1052
+
1053
+ writeUInt32BE(buf, pathLen, p);
1054
+ buf.utf8Write(path, p += 4, pathLen);
1055
+
1056
+ this._requests[reqid] = { cb };
1057
+
1058
+ const isBuffered = sendOrBuffer(this, buf);
1059
+ this._debug && this._debug(
1060
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPENDIR`
1061
+ );
1062
+ }
1063
+ setstat(path, attrs, cb) {
1064
+ if (this.server)
1065
+ throw new Error('Client-only method called in server mode');
1066
+
1067
+ let flags = 0;
1068
+ let attrsLen = 0;
1069
+
1070
+ if (typeof attrs === 'object' && attrs !== null) {
1071
+ attrs = attrsToBytes(attrs);
1072
+ flags = attrs.flags;
1073
+ attrsLen = attrs.nb;
1074
+ } else if (typeof attrs === 'function') {
1075
+ cb = attrs;
1076
+ }
1077
+
1078
+ /*
1079
+ uint32 id
1080
+ string path
1081
+ ATTRS attrs
1082
+ */
1083
+ const pathLen = Buffer.byteLength(path);
1084
+ let p = 9;
1085
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);
1086
+
1087
+ writeUInt32BE(buf, buf.length - 4, 0);
1088
+ buf[4] = REQUEST.SETSTAT;
1089
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1090
+ writeUInt32BE(buf, reqid, 5);
1091
+
1092
+ writeUInt32BE(buf, pathLen, p);
1093
+ buf.utf8Write(path, p += 4, pathLen);
1094
+ writeUInt32BE(buf, flags, p += pathLen);
1095
+ if (attrsLen) {
1096
+ p += 4;
1097
+
1098
+ if (attrsLen === ATTRS_BUF.length)
1099
+ buf.set(ATTRS_BUF, p);
1100
+ else
1101
+ bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);
1102
+
1103
+ p += attrsLen;
1104
+ }
1105
+
1106
+ this._requests[reqid] = { cb };
1107
+
1108
+ const isBuffered = sendOrBuffer(this, buf);
1109
+ this._debug && this._debug(
1110
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SETSTAT`
1111
+ );
1112
+ }
1113
+ fsetstat(handle, attrs, cb) {
1114
+ if (this.server)
1115
+ throw new Error('Client-only method called in server mode');
1116
+
1117
+ if (!Buffer.isBuffer(handle))
1118
+ throw new Error('handle is not a Buffer');
1119
+
1120
+ let flags = 0;
1121
+ let attrsLen = 0;
1122
+
1123
+ if (typeof attrs === 'object' && attrs !== null) {
1124
+ attrs = attrsToBytes(attrs);
1125
+ flags = attrs.flags;
1126
+ attrsLen = attrs.nb;
1127
+ } else if (typeof attrs === 'function') {
1128
+ cb = attrs;
1129
+ }
1130
+
1131
+ /*
1132
+ uint32 id
1133
+ string handle
1134
+ ATTRS attrs
1135
+ */
1136
+ const handleLen = handle.length;
1137
+ let p = 9;
1138
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 4 + attrsLen);
1139
+
1140
+ writeUInt32BE(buf, buf.length - 4, 0);
1141
+ buf[4] = REQUEST.FSETSTAT;
1142
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1143
+ writeUInt32BE(buf, reqid, 5);
1144
+
1145
+ writeUInt32BE(buf, handleLen, p);
1146
+ buf.set(handle, p += 4);
1147
+ writeUInt32BE(buf, flags, p += handleLen);
1148
+ if (attrsLen) {
1149
+ p += 4;
1150
+
1151
+ if (attrsLen === ATTRS_BUF.length)
1152
+ buf.set(ATTRS_BUF, p);
1153
+ else
1154
+ bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);
1155
+
1156
+ p += attrsLen;
1157
+ }
1158
+
1159
+ this._requests[reqid] = { cb };
1160
+
1161
+ const isBuffered = sendOrBuffer(this, buf);
1162
+ this._debug && this._debug(
1163
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSETSTAT`
1164
+ );
1165
+ }
1166
+ futimes(handle, atime, mtime, cb) {
1167
+ return this.fsetstat(handle, {
1168
+ atime: toUnixTimestamp(atime),
1169
+ mtime: toUnixTimestamp(mtime)
1170
+ }, cb);
1171
+ }
1172
+ utimes(path, atime, mtime, cb) {
1173
+ return this.setstat(path, {
1174
+ atime: toUnixTimestamp(atime),
1175
+ mtime: toUnixTimestamp(mtime)
1176
+ }, cb);
1177
+ }
1178
+ fchown(handle, uid, gid, cb) {
1179
+ return this.fsetstat(handle, {
1180
+ uid: uid,
1181
+ gid: gid
1182
+ }, cb);
1183
+ }
1184
+ chown(path, uid, gid, cb) {
1185
+ return this.setstat(path, {
1186
+ uid: uid,
1187
+ gid: gid
1188
+ }, cb);
1189
+ }
1190
+ fchmod(handle, mode, cb) {
1191
+ return this.fsetstat(handle, {
1192
+ mode: mode
1193
+ }, cb);
1194
+ }
1195
+ chmod(path, mode, cb) {
1196
+ return this.setstat(path, {
1197
+ mode: mode
1198
+ }, cb);
1199
+ }
1200
+ readlink(path, cb) {
1201
+ if (this.server)
1202
+ throw new Error('Client-only method called in server mode');
1203
+
1204
+ /*
1205
+ uint32 id
1206
+ string path
1207
+ */
1208
+ const pathLen = Buffer.byteLength(path);
1209
+ let p = 9;
1210
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
1211
+
1212
+ writeUInt32BE(buf, buf.length - 4, 0);
1213
+ buf[4] = REQUEST.READLINK;
1214
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1215
+ writeUInt32BE(buf, reqid, 5);
1216
+
1217
+ writeUInt32BE(buf, pathLen, p);
1218
+ buf.utf8Write(path, p += 4, pathLen);
1219
+
1220
+ this._requests[reqid] = {
1221
+ cb: (err, names) => {
1222
+ if (typeof cb !== 'function')
1223
+ return;
1224
+ if (err)
1225
+ return cb(err);
1226
+ if (!names || !names.length)
1227
+ return cb(new Error('Response missing link info'));
1228
+ cb(undefined, names[0].filename);
1229
+ }
1230
+ };
1231
+
1232
+ const isBuffered = sendOrBuffer(this, buf);
1233
+ this._debug && this._debug(
1234
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READLINK`
1235
+ );
1236
+ }
1237
+ symlink(targetPath, linkPath, cb) {
1238
+ if (this.server)
1239
+ throw new Error('Client-only method called in server mode');
1240
+
1241
+ /*
1242
+ uint32 id
1243
+ string linkpath
1244
+ string targetpath
1245
+ */
1246
+ const linkLen = Buffer.byteLength(linkPath);
1247
+ const targetLen = Buffer.byteLength(targetPath);
1248
+ let p = 9;
1249
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + linkLen + 4 + targetLen);
1250
+
1251
+ writeUInt32BE(buf, buf.length - 4, 0);
1252
+ buf[4] = REQUEST.SYMLINK;
1253
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1254
+ writeUInt32BE(buf, reqid, 5);
1255
+
1256
+ if (this._isOpenSSH) {
1257
+ // OpenSSH has linkpath and targetpath positions switched
1258
+ writeUInt32BE(buf, targetLen, p);
1259
+ buf.utf8Write(targetPath, p += 4, targetLen);
1260
+ writeUInt32BE(buf, linkLen, p += targetLen);
1261
+ buf.utf8Write(linkPath, p += 4, linkLen);
1262
+ } else {
1263
+ writeUInt32BE(buf, linkLen, p);
1264
+ buf.utf8Write(linkPath, p += 4, linkLen);
1265
+ writeUInt32BE(buf, targetLen, p += linkLen);
1266
+ buf.utf8Write(targetPath, p += 4, targetLen);
1267
+ }
1268
+
1269
+ this._requests[reqid] = { cb };
1270
+
1271
+ const isBuffered = sendOrBuffer(this, buf);
1272
+ this._debug && this._debug(
1273
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SYMLINK`
1274
+ );
1275
+ }
1276
+ realpath(path, cb) {
1277
+ if (this.server)
1278
+ throw new Error('Client-only method called in server mode');
1279
+
1280
+ /*
1281
+ uint32 id
1282
+ string path
1283
+ */
1284
+ const pathLen = Buffer.byteLength(path);
1285
+ let p = 9;
1286
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
1287
+
1288
+ writeUInt32BE(buf, buf.length - 4, 0);
1289
+ buf[4] = REQUEST.REALPATH;
1290
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1291
+ writeUInt32BE(buf, reqid, 5);
1292
+
1293
+ writeUInt32BE(buf, pathLen, p);
1294
+ buf.utf8Write(path, p += 4, pathLen);
1295
+
1296
+ this._requests[reqid] = {
1297
+ cb: (err, names) => {
1298
+ if (typeof cb !== 'function')
1299
+ return;
1300
+ if (err)
1301
+ return cb(err);
1302
+ if (!names || !names.length)
1303
+ return cb(new Error('Response missing path info'));
1304
+ cb(undefined, names[0].filename);
1305
+ }
1306
+ };
1307
+
1308
+ const isBuffered = sendOrBuffer(this, buf);
1309
+ this._debug && this._debug(
1310
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REALPATH`
1311
+ );
1312
+ }
1313
+ // extended requests
1314
+ ext_openssh_rename(oldPath, newPath, cb) {
1315
+ if (this.server)
1316
+ throw new Error('Client-only method called in server mode');
1317
+
1318
+ const ext = this._extensions['posix-rename@openssh.com'];
1319
+ if (!ext || ext !== '1')
1320
+ throw new Error('Server does not support this extended request');
1321
+
1322
+ /*
1323
+ uint32 id
1324
+ string "posix-rename@openssh.com"
1325
+ string oldpath
1326
+ string newpath
1327
+ */
1328
+ const oldLen = Buffer.byteLength(oldPath);
1329
+ const newLen = Buffer.byteLength(newPath);
1330
+ let p = 9;
1331
+ const buf =
1332
+ Buffer.allocUnsafe(4 + 1 + 4 + 4 + 24 + 4 + oldLen + 4 + newLen);
1333
+
1334
+ writeUInt32BE(buf, buf.length - 4, 0);
1335
+ buf[4] = REQUEST.EXTENDED;
1336
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1337
+ writeUInt32BE(buf, reqid, 5);
1338
+
1339
+ writeUInt32BE(buf, 24, p);
1340
+ buf.utf8Write('posix-rename@openssh.com', p += 4, 24);
1341
+ writeUInt32BE(buf, oldLen, p += 24);
1342
+ buf.utf8Write(oldPath, p += 4, oldLen);
1343
+ writeUInt32BE(buf, newLen, p += oldLen);
1344
+ buf.utf8Write(newPath, p += 4, newLen);
1345
+
1346
+ this._requests[reqid] = { cb };
1347
+
1348
+ const isBuffered = sendOrBuffer(this, buf);
1349
+ if (this._debug) {
1350
+ const which = (isBuffered ? 'Buffered' : 'Sending');
1351
+ this._debug(`SFTP: Outbound: ${which} posix-rename@openssh.com`);
1352
+ }
1353
+ }
1354
+ ext_openssh_statvfs(path, cb) {
1355
+ if (this.server)
1356
+ throw new Error('Client-only method called in server mode');
1357
+
1358
+ const ext = this._extensions['statvfs@openssh.com'];
1359
+ if (!ext || ext !== '2')
1360
+ throw new Error('Server does not support this extended request');
1361
+
1362
+ /*
1363
+ uint32 id
1364
+ string "statvfs@openssh.com"
1365
+ string path
1366
+ */
1367
+ const pathLen = Buffer.byteLength(path);
1368
+ let p = 9;
1369
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 19 + 4 + pathLen);
1370
+
1371
+ writeUInt32BE(buf, buf.length - 4, 0);
1372
+ buf[4] = REQUEST.EXTENDED;
1373
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1374
+ writeUInt32BE(buf, reqid, 5);
1375
+
1376
+ writeUInt32BE(buf, 19, p);
1377
+ buf.utf8Write('statvfs@openssh.com', p += 4, 19);
1378
+ writeUInt32BE(buf, pathLen, p += 19);
1379
+ buf.utf8Write(path, p += 4, pathLen);
1380
+
1381
+ this._requests[reqid] = { extended: 'statvfs@openssh.com', cb };
1382
+
1383
+ const isBuffered = sendOrBuffer(this, buf);
1384
+ if (this._debug) {
1385
+ const which = (isBuffered ? 'Buffered' : 'Sending');
1386
+ this._debug(`SFTP: Outbound: ${which} statvfs@openssh.com`);
1387
+ }
1388
+ }
1389
+ ext_openssh_fstatvfs(handle, cb) {
1390
+ if (this.server)
1391
+ throw new Error('Client-only method called in server mode');
1392
+
1393
+ const ext = this._extensions['fstatvfs@openssh.com'];
1394
+ if (!ext || ext !== '2')
1395
+ throw new Error('Server does not support this extended request');
1396
+ if (!Buffer.isBuffer(handle))
1397
+ throw new Error('handle is not a Buffer');
1398
+
1399
+ /*
1400
+ uint32 id
1401
+ string "fstatvfs@openssh.com"
1402
+ string handle
1403
+ */
1404
+ const handleLen = handle.length;
1405
+ let p = 9;
1406
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + handleLen);
1407
+
1408
+ writeUInt32BE(buf, buf.length - 4, 0);
1409
+ buf[4] = REQUEST.EXTENDED;
1410
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1411
+ writeUInt32BE(buf, reqid, 5);
1412
+
1413
+ writeUInt32BE(buf, 20, p);
1414
+ buf.utf8Write('fstatvfs@openssh.com', p += 4, 20);
1415
+ writeUInt32BE(buf, handleLen, p += 20);
1416
+ buf.set(handle, p += 4);
1417
+
1418
+ this._requests[reqid] = { extended: 'fstatvfs@openssh.com', cb };
1419
+
1420
+ const isBuffered = sendOrBuffer(this, buf);
1421
+ if (this._debug) {
1422
+ const which = (isBuffered ? 'Buffered' : 'Sending');
1423
+ this._debug(`SFTP: Outbound: ${which} fstatvfs@openssh.com`);
1424
+ }
1425
+ }
1426
+ ext_openssh_hardlink(oldPath, newPath, cb) {
1427
+ if (this.server)
1428
+ throw new Error('Client-only method called in server mode');
1429
+
1430
+ const ext = this._extensions['hardlink@openssh.com'];
1431
+ if (ext !== '1')
1432
+ throw new Error('Server does not support this extended request');
1433
+
1434
+ /*
1435
+ uint32 id
1436
+ string "hardlink@openssh.com"
1437
+ string oldpath
1438
+ string newpath
1439
+ */
1440
+ const oldLen = Buffer.byteLength(oldPath);
1441
+ const newLen = Buffer.byteLength(newPath);
1442
+ let p = 9;
1443
+ const buf =
1444
+ Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + oldLen + 4 + newLen);
1445
+
1446
+ writeUInt32BE(buf, buf.length - 4, 0);
1447
+ buf[4] = REQUEST.EXTENDED;
1448
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1449
+ writeUInt32BE(buf, reqid, 5);
1450
+
1451
+ writeUInt32BE(buf, 20, p);
1452
+ buf.utf8Write('hardlink@openssh.com', p += 4, 20);
1453
+ writeUInt32BE(buf, oldLen, p += 20);
1454
+ buf.utf8Write(oldPath, p += 4, oldLen);
1455
+ writeUInt32BE(buf, newLen, p += oldLen);
1456
+ buf.utf8Write(newPath, p += 4, newLen);
1457
+
1458
+ this._requests[reqid] = { cb };
1459
+
1460
+ const isBuffered = sendOrBuffer(this, buf);
1461
+ if (this._debug) {
1462
+ const which = (isBuffered ? 'Buffered' : 'Sending');
1463
+ this._debug(`SFTP: Outbound: ${which} hardlink@openssh.com`);
1464
+ }
1465
+ }
1466
+ ext_openssh_fsync(handle, cb) {
1467
+ if (this.server)
1468
+ throw new Error('Client-only method called in server mode');
1469
+
1470
+ const ext = this._extensions['fsync@openssh.com'];
1471
+ if (ext !== '1')
1472
+ throw new Error('Server does not support this extended request');
1473
+ if (!Buffer.isBuffer(handle))
1474
+ throw new Error('handle is not a Buffer');
1475
+
1476
+ /*
1477
+ uint32 id
1478
+ string "fsync@openssh.com"
1479
+ string handle
1480
+ */
1481
+ const handleLen = handle.length;
1482
+ let p = 9;
1483
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 17 + 4 + handleLen);
1484
+
1485
+ writeUInt32BE(buf, buf.length - 4, 0);
1486
+ buf[4] = REQUEST.EXTENDED;
1487
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1488
+ writeUInt32BE(buf, reqid, 5);
1489
+
1490
+ writeUInt32BE(buf, 17, p);
1491
+ buf.utf8Write('fsync@openssh.com', p += 4, 17);
1492
+ writeUInt32BE(buf, handleLen, p += 17);
1493
+ buf.set(handle, p += 4);
1494
+
1495
+ this._requests[reqid] = { cb };
1496
+
1497
+ const isBuffered = sendOrBuffer(this, buf);
1498
+ this._debug && this._debug(
1499
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} fsync@openssh.com`
1500
+ );
1501
+ }
1502
+ ext_openssh_lsetstat(path, attrs, cb) {
1503
+ if (this.server)
1504
+ throw new Error('Client-only method called in server mode');
1505
+
1506
+ const ext = this._extensions['lsetstat@openssh.com'];
1507
+ if (ext !== '1')
1508
+ throw new Error('Server does not support this extended request');
1509
+
1510
+ let flags = 0;
1511
+ let attrsLen = 0;
1512
+
1513
+ if (typeof attrs === 'object' && attrs !== null) {
1514
+ attrs = attrsToBytes(attrs);
1515
+ flags = attrs.flags;
1516
+ attrsLen = attrs.nb;
1517
+ } else if (typeof attrs === 'function') {
1518
+ cb = attrs;
1519
+ }
1520
+
1521
+ /*
1522
+ uint32 id
1523
+ string "lsetstat@openssh.com"
1524
+ string path
1525
+ ATTRS attrs
1526
+ */
1527
+ const pathLen = Buffer.byteLength(path);
1528
+ let p = 9;
1529
+ const buf =
1530
+ Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + pathLen + 4 + attrsLen);
1531
+
1532
+ writeUInt32BE(buf, buf.length - 4, 0);
1533
+ buf[4] = REQUEST.EXTENDED;
1534
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1535
+ writeUInt32BE(buf, reqid, 5);
1536
+
1537
+ writeUInt32BE(buf, 20, p);
1538
+ buf.utf8Write('lsetstat@openssh.com', p += 4, 20);
1539
+
1540
+ writeUInt32BE(buf, pathLen, p += 20);
1541
+ buf.utf8Write(path, p += 4, pathLen);
1542
+
1543
+ writeUInt32BE(buf, flags, p += pathLen);
1544
+ if (attrsLen) {
1545
+ p += 4;
1546
+
1547
+ if (attrsLen === ATTRS_BUF.length)
1548
+ buf.set(ATTRS_BUF, p);
1549
+ else
1550
+ bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);
1551
+
1552
+ p += attrsLen;
1553
+ }
1554
+
1555
+ this._requests[reqid] = { cb };
1556
+
1557
+ const isBuffered = sendOrBuffer(this, buf);
1558
+ if (this._debug) {
1559
+ const status = (isBuffered ? 'Buffered' : 'Sending');
1560
+ this._debug(`SFTP: Outbound: ${status} lsetstat@openssh.com`);
1561
+ }
1562
+ }
1563
+ ext_openssh_expandPath(path, cb) {
1564
+ if (this.server)
1565
+ throw new Error('Client-only method called in server mode');
1566
+
1567
+ const ext = this._extensions['expand-path@openssh.com'];
1568
+ if (ext !== '1')
1569
+ throw new Error('Server does not support this extended request');
1570
+
1571
+ /*
1572
+ uint32 id
1573
+ string "expand-path@openssh.com"
1574
+ string path
1575
+ */
1576
+ const pathLen = Buffer.byteLength(path);
1577
+ let p = 9;
1578
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 23 + 4 + pathLen);
1579
+
1580
+ writeUInt32BE(buf, buf.length - 4, 0);
1581
+ buf[4] = REQUEST.EXTENDED;
1582
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1583
+ writeUInt32BE(buf, reqid, 5);
1584
+
1585
+ writeUInt32BE(buf, 23, p);
1586
+ buf.utf8Write('expand-path@openssh.com', p += 4, 23);
1587
+
1588
+ writeUInt32BE(buf, pathLen, p += 20);
1589
+ buf.utf8Write(path, p += 4, pathLen);
1590
+
1591
+ this._requests[reqid] = {
1592
+ cb: (err, names) => {
1593
+ if (typeof cb !== 'function')
1594
+ return;
1595
+ if (err)
1596
+ return cb(err);
1597
+ if (!names || !names.length)
1598
+ return cb(new Error('Response missing expanded path'));
1599
+ cb(undefined, names[0].filename);
1600
+ }
1601
+ };
1602
+
1603
+ const isBuffered = sendOrBuffer(this, buf);
1604
+ if (this._debug) {
1605
+ const status = (isBuffered ? 'Buffered' : 'Sending');
1606
+ this._debug(`SFTP: Outbound: ${status} expand-path@openssh.com`);
1607
+ }
1608
+ }
1609
+ ext_copy_data(srcHandle, srcOffset, len, dstHandle, dstOffset, cb) {
1610
+ if (this.server)
1611
+ throw new Error('Client-only method called in server mode');
1612
+
1613
+ const ext = this._extensions['copy-data'];
1614
+ if (ext !== '1')
1615
+ throw new Error('Server does not support this extended request');
1616
+
1617
+ if (!Buffer.isBuffer(srcHandle))
1618
+ throw new Error('Source handle is not a Buffer');
1619
+
1620
+ if (!Buffer.isBuffer(dstHandle))
1621
+ throw new Error('Destination handle is not a Buffer');
1622
+
1623
+ /*
1624
+ uint32 id
1625
+ string "copy-data"
1626
+ string read-from-handle
1627
+ uint64 read-from-offset
1628
+ uint64 read-data-length
1629
+ string write-to-handle
1630
+ uint64 write-to-offset
1631
+ */
1632
+ let p = 0;
1633
+ const buf = Buffer.allocUnsafe(
1634
+ 4 + 1
1635
+ + 4
1636
+ + 4 + 9
1637
+ + 4 + srcHandle.length
1638
+ + 8
1639
+ + 8
1640
+ + 4 + dstHandle.length
1641
+ + 8
1642
+ );
1643
+
1644
+ writeUInt32BE(buf, buf.length - 4, p);
1645
+ p += 4;
1646
+
1647
+ buf[p] = REQUEST.EXTENDED;
1648
+ ++p;
1649
+
1650
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1651
+ writeUInt32BE(buf, reqid, p);
1652
+ p += 4;
1653
+
1654
+ writeUInt32BE(buf, 9, p);
1655
+ p += 4;
1656
+ buf.utf8Write('copy-data', p, 9);
1657
+ p += 9;
1658
+
1659
+ writeUInt32BE(buf, srcHandle.length, p);
1660
+ p += 4;
1661
+ buf.set(srcHandle, p);
1662
+ p += srcHandle.length;
1663
+
1664
+ for (let i = 7; i >= 0; --i) {
1665
+ buf[p + i] = srcOffset & 0xFF;
1666
+ srcOffset /= 256;
1667
+ }
1668
+ p += 8;
1669
+
1670
+ for (let i = 7; i >= 0; --i) {
1671
+ buf[p + i] = len & 0xFF;
1672
+ len /= 256;
1673
+ }
1674
+ p += 8;
1675
+
1676
+ writeUInt32BE(buf, dstHandle.length, p);
1677
+ p += 4;
1678
+ buf.set(dstHandle, p);
1679
+ p += dstHandle.length;
1680
+
1681
+ for (let i = 7; i >= 0; --i) {
1682
+ buf[p + i] = dstOffset & 0xFF;
1683
+ dstOffset /= 256;
1684
+ }
1685
+
1686
+ this._requests[reqid] = { cb };
1687
+
1688
+ const isBuffered = sendOrBuffer(this, buf);
1689
+ if (this._debug) {
1690
+ const status = (isBuffered ? 'Buffered' : 'Sending');
1691
+ this._debug(`SFTP: Outbound: ${status} copy-data`);
1692
+ }
1693
+ }
1694
+ ext_home_dir(username, cb) {
1695
+ if (this.server)
1696
+ throw new Error('Client-only method called in server mode');
1697
+
1698
+ const ext = this._extensions['home-directory'];
1699
+ if (ext !== '1')
1700
+ throw new Error('Server does not support this extended request');
1701
+
1702
+ if (typeof username !== 'string')
1703
+ throw new TypeError('username is not a string');
1704
+
1705
+ /*
1706
+ uint32 id
1707
+ string "home-directory"
1708
+ string username
1709
+ */
1710
+ let p = 0;
1711
+ const usernameLen = Buffer.byteLength(username);
1712
+ const buf = Buffer.allocUnsafe(
1713
+ 4 + 1
1714
+ + 4
1715
+ + 4 + 14
1716
+ + 4 + usernameLen
1717
+ );
1718
+
1719
+ writeUInt32BE(buf, buf.length - 4, p);
1720
+ p += 4;
1721
+
1722
+ buf[p] = REQUEST.EXTENDED;
1723
+ ++p;
1724
+
1725
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1726
+ writeUInt32BE(buf, reqid, p);
1727
+ p += 4;
1728
+
1729
+ writeUInt32BE(buf, 14, p);
1730
+ p += 4;
1731
+ buf.utf8Write('home-directory', p, 14);
1732
+ p += 14;
1733
+
1734
+ writeUInt32BE(buf, usernameLen, p);
1735
+ p += 4;
1736
+ buf.utf8Write(username, p, usernameLen);
1737
+ p += usernameLen;
1738
+
1739
+ this._requests[reqid] = {
1740
+ cb: (err, names) => {
1741
+ if (typeof cb !== 'function')
1742
+ return;
1743
+ if (err)
1744
+ return cb(err);
1745
+ if (!names || !names.length)
1746
+ return cb(new Error('Response missing home directory'));
1747
+ cb(undefined, names[0].filename);
1748
+ }
1749
+ };
1750
+
1751
+ const isBuffered = sendOrBuffer(this, buf);
1752
+ if (this._debug) {
1753
+ const status = (isBuffered ? 'Buffered' : 'Sending');
1754
+ this._debug(`SFTP: Outbound: ${status} home-directory`);
1755
+ }
1756
+ }
1757
+ ext_users_groups(uids, gids, cb) {
1758
+ if (this.server)
1759
+ throw new Error('Client-only method called in server mode');
1760
+
1761
+ const ext = this._extensions['users-groups-by-id@openssh.com'];
1762
+ if (ext !== '1')
1763
+ throw new Error('Server does not support this extended request');
1764
+
1765
+ if (!Array.isArray(uids))
1766
+ throw new TypeError('uids is not an array');
1767
+ for (const val of uids) {
1768
+ if (!Number.isInteger(val) || val < 0 || val > (2 ** 32 - 1))
1769
+ throw new Error('uid values must all be 32-bit unsigned integers');
1770
+ }
1771
+ if (!Array.isArray(gids))
1772
+ throw new TypeError('gids is not an array');
1773
+ for (const val of gids) {
1774
+ if (!Number.isInteger(val) || val < 0 || val > (2 ** 32 - 1))
1775
+ throw new Error('gid values must all be 32-bit unsigned integers');
1776
+ }
1777
+
1778
+ /*
1779
+ uint32 id
1780
+ string "users-groups-by-id@openssh.com"
1781
+ string uids
1782
+ uint32 uid1
1783
+ ...
1784
+ string gids
1785
+ uint32 gid1
1786
+ ...
1787
+ */
1788
+ let p = 0;
1789
+ const buf = Buffer.allocUnsafe(
1790
+ 4 + 1
1791
+ + 4
1792
+ + 4 + 30
1793
+ + 4 + (4 * uids.length)
1794
+ + 4 + (4 * gids.length)
1795
+ );
1796
+
1797
+ writeUInt32BE(buf, buf.length - 4, p);
1798
+ p += 4;
1799
+
1800
+ buf[p] = REQUEST.EXTENDED;
1801
+ ++p;
1802
+
1803
+ const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
1804
+ writeUInt32BE(buf, reqid, p);
1805
+ p += 4;
1806
+
1807
+ writeUInt32BE(buf, 30, p);
1808
+ p += 4;
1809
+ buf.utf8Write('users-groups-by-id@openssh.com', p, 30);
1810
+ p += 30;
1811
+
1812
+ writeUInt32BE(buf, 4 * uids.length, p);
1813
+ p += 4;
1814
+ for (const val of uids) {
1815
+ writeUInt32BE(buf, val, p);
1816
+ p += 4;
1817
+ }
1818
+
1819
+ writeUInt32BE(buf, 4 * gids.length, p);
1820
+ p += 4;
1821
+ for (const val of gids) {
1822
+ writeUInt32BE(buf, val, p);
1823
+ p += 4;
1824
+ }
1825
+
1826
+ this._requests[reqid] = { extended: 'users-groups-by-id@openssh.com', cb };
1827
+
1828
+ const isBuffered = sendOrBuffer(this, buf);
1829
+ if (this._debug) {
1830
+ const status = (isBuffered ? 'Buffered' : 'Sending');
1831
+ this._debug(`SFTP: Outbound: ${status} users-groups-by-id@openssh.com`);
1832
+ }
1833
+ }
1834
+ // ===========================================================================
1835
+ // Server-specific ===========================================================
1836
+ // ===========================================================================
1837
+ handle(reqid, handle) {
1838
+ if (!this.server)
1839
+ throw new Error('Server-only method called in client mode');
1840
+
1841
+ if (!Buffer.isBuffer(handle))
1842
+ throw new Error('handle is not a Buffer');
1843
+
1844
+ const handleLen = handle.length;
1845
+
1846
+ if (handleLen > 256)
1847
+ throw new Error('handle too large (> 256 bytes)');
1848
+
1849
+ let p = 9;
1850
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);
1851
+
1852
+ writeUInt32BE(buf, buf.length - 4, 0);
1853
+ buf[4] = RESPONSE.HANDLE;
1854
+ writeUInt32BE(buf, reqid, 5);
1855
+
1856
+ writeUInt32BE(buf, handleLen, p);
1857
+ if (handleLen)
1858
+ buf.set(handle, p += 4);
1859
+
1860
+ const isBuffered = sendOrBuffer(this, buf);
1861
+ this._debug && this._debug(
1862
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} HANDLE`
1863
+ );
1864
+ }
1865
+ status(reqid, code, message) {
1866
+ if (!this.server)
1867
+ throw new Error('Server-only method called in client mode');
1868
+
1869
+ if (!VALID_STATUS_CODES.has(code))
1870
+ throw new Error(`Bad status code: ${code}`);
1871
+
1872
+ message || (message = '');
1873
+
1874
+ const msgLen = Buffer.byteLength(message);
1875
+ let p = 9;
1876
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 4 + msgLen + 4);
1877
+
1878
+ writeUInt32BE(buf, buf.length - 4, 0);
1879
+ buf[4] = RESPONSE.STATUS;
1880
+ writeUInt32BE(buf, reqid, 5);
1881
+
1882
+ writeUInt32BE(buf, code, p);
1883
+
1884
+ writeUInt32BE(buf, msgLen, p += 4);
1885
+ p += 4;
1886
+ if (msgLen) {
1887
+ buf.utf8Write(message, p, msgLen);
1888
+ p += msgLen;
1889
+ }
1890
+
1891
+ writeUInt32BE(buf, 0, p); // Empty language tag
1892
+
1893
+ const isBuffered = sendOrBuffer(this, buf);
1894
+ this._debug && this._debug(
1895
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STATUS`
1896
+ );
1897
+ }
1898
+ data(reqid, data, encoding) {
1899
+ if (!this.server)
1900
+ throw new Error('Server-only method called in client mode');
1901
+
1902
+ const isBuffer = Buffer.isBuffer(data);
1903
+
1904
+ if (!isBuffer && typeof data !== 'string')
1905
+ throw new Error('data is not a Buffer or string');
1906
+
1907
+ let isUTF8;
1908
+ if (!isBuffer && !encoding) {
1909
+ encoding = undefined;
1910
+ isUTF8 = true;
1911
+ }
1912
+
1913
+ const dataLen = (
1914
+ isBuffer
1915
+ ? data.length
1916
+ : Buffer.byteLength(data, encoding)
1917
+ );
1918
+ let p = 9;
1919
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + dataLen);
1920
+
1921
+ writeUInt32BE(buf, buf.length - 4, 0);
1922
+ buf[4] = RESPONSE.DATA;
1923
+ writeUInt32BE(buf, reqid, 5);
1924
+
1925
+ writeUInt32BE(buf, dataLen, p);
1926
+ if (dataLen) {
1927
+ if (isBuffer)
1928
+ buf.set(data, p += 4);
1929
+ else if (isUTF8)
1930
+ buf.utf8Write(data, p += 4, dataLen);
1931
+ else
1932
+ buf.write(data, p += 4, dataLen, encoding);
1933
+ }
1934
+
1935
+ const isBuffered = sendOrBuffer(this, buf);
1936
+ this._debug && this._debug(
1937
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} DATA`
1938
+ );
1939
+ }
1940
+ name(reqid, names) {
1941
+ if (!this.server)
1942
+ throw new Error('Server-only method called in client mode');
1943
+
1944
+ if (!Array.isArray(names)) {
1945
+ if (typeof names !== 'object' || names === null)
1946
+ throw new Error('names is not an object or array');
1947
+ names = [ names ];
1948
+ }
1949
+
1950
+ const count = names.length;
1951
+ let namesLen = 0;
1952
+ let nameAttrs;
1953
+ const attrs = [];
1954
+
1955
+ for (let i = 0; i < count; ++i) {
1956
+ const name = names[i];
1957
+ const filename = (
1958
+ !name || !name.filename || typeof name.filename !== 'string'
1959
+ ? ''
1960
+ : name.filename
1961
+ );
1962
+ namesLen += 4 + Buffer.byteLength(filename);
1963
+ const longname = (
1964
+ !name || !name.longname || typeof name.longname !== 'string'
1965
+ ? ''
1966
+ : name.longname
1967
+ );
1968
+ namesLen += 4 + Buffer.byteLength(longname);
1969
+
1970
+ if (typeof name.attrs === 'object' && name.attrs !== null) {
1971
+ nameAttrs = attrsToBytes(name.attrs);
1972
+ namesLen += 4 + nameAttrs.nb;
1973
+
1974
+ if (nameAttrs.nb) {
1975
+ let bytes;
1976
+
1977
+ if (nameAttrs.nb === ATTRS_BUF.length) {
1978
+ bytes = new Uint8Array(ATTRS_BUF);
1979
+ } else {
1980
+ bytes = new Uint8Array(nameAttrs.nb);
1981
+ bufferCopy(ATTRS_BUF, bytes, 0, nameAttrs.nb, 0);
1982
+ }
1983
+
1984
+ nameAttrs.bytes = bytes;
1985
+ }
1986
+
1987
+ attrs.push(nameAttrs);
1988
+ } else {
1989
+ namesLen += 4;
1990
+ attrs.push(null);
1991
+ }
1992
+ }
1993
+
1994
+ let p = 9;
1995
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + namesLen);
1996
+
1997
+ writeUInt32BE(buf, buf.length - 4, 0);
1998
+ buf[4] = RESPONSE.NAME;
1999
+ writeUInt32BE(buf, reqid, 5);
2000
+
2001
+ writeUInt32BE(buf, count, p);
2002
+
2003
+ p += 4;
2004
+
2005
+ for (let i = 0; i < count; ++i) {
2006
+ const name = names[i];
2007
+
2008
+ {
2009
+ const filename = (
2010
+ !name || !name.filename || typeof name.filename !== 'string'
2011
+ ? ''
2012
+ : name.filename
2013
+ );
2014
+ const len = Buffer.byteLength(filename);
2015
+ writeUInt32BE(buf, len, p);
2016
+ p += 4;
2017
+ if (len) {
2018
+ buf.utf8Write(filename, p, len);
2019
+ p += len;
2020
+ }
2021
+ }
2022
+
2023
+ {
2024
+ const longname = (
2025
+ !name || !name.longname || typeof name.longname !== 'string'
2026
+ ? ''
2027
+ : name.longname
2028
+ );
2029
+ const len = Buffer.byteLength(longname);
2030
+ writeUInt32BE(buf, len, p);
2031
+ p += 4;
2032
+ if (len) {
2033
+ buf.utf8Write(longname, p, len);
2034
+ p += len;
2035
+ }
2036
+ }
2037
+
2038
+ const attr = attrs[i];
2039
+ if (attr) {
2040
+ writeUInt32BE(buf, attr.flags, p);
2041
+ p += 4;
2042
+ if (attr.flags && attr.bytes) {
2043
+ buf.set(attr.bytes, p);
2044
+ p += attr.nb;
2045
+ }
2046
+ } else {
2047
+ writeUInt32BE(buf, 0, p);
2048
+ p += 4;
2049
+ }
2050
+ }
2051
+
2052
+ const isBuffered = sendOrBuffer(this, buf);
2053
+ this._debug && this._debug(
2054
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} NAME`
2055
+ );
2056
+ }
2057
+ attrs(reqid, attrs) {
2058
+ if (!this.server)
2059
+ throw new Error('Server-only method called in client mode');
2060
+
2061
+ if (typeof attrs !== 'object' || attrs === null)
2062
+ throw new Error('attrs is not an object');
2063
+
2064
+ attrs = attrsToBytes(attrs);
2065
+ const flags = attrs.flags;
2066
+ const attrsLen = attrs.nb;
2067
+ let p = 9;
2068
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + attrsLen);
2069
+
2070
+ writeUInt32BE(buf, buf.length - 4, 0);
2071
+ buf[4] = RESPONSE.ATTRS;
2072
+ writeUInt32BE(buf, reqid, 5);
2073
+
2074
+ writeUInt32BE(buf, flags, p);
2075
+ if (attrsLen) {
2076
+ p += 4;
2077
+
2078
+ if (attrsLen === ATTRS_BUF.length)
2079
+ buf.set(ATTRS_BUF, p);
2080
+ else
2081
+ bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);
2082
+
2083
+ p += attrsLen;
2084
+ }
2085
+
2086
+ const isBuffered = sendOrBuffer(this, buf);
2087
+ this._debug && this._debug(
2088
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} ATTRS`
2089
+ );
2090
+ }
2091
+ }
2092
+
2093
+ function tryCreateBuffer(size) {
2094
+ try {
2095
+ return Buffer.allocUnsafe(size);
2096
+ } catch (ex) {
2097
+ return ex;
2098
+ }
2099
+ }
2100
+
2101
+ function read_(self, handle, buf, off, len, position, cb, req_) {
2102
+ const maxDataLen = self._maxReadLen;
2103
+ const overflow = Math.max(len - maxDataLen, 0);
2104
+
2105
+ if (overflow)
2106
+ len = maxDataLen;
2107
+
2108
+ /*
2109
+ uint32 id
2110
+ string handle
2111
+ uint64 offset
2112
+ uint32 len
2113
+ */
2114
+ const handleLen = handle.length;
2115
+ let p = 9;
2116
+ let pos = position;
2117
+ const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4);
2118
+
2119
+ writeUInt32BE(out, out.length - 4, 0);
2120
+ out[4] = REQUEST.READ;
2121
+ const reqid = self._writeReqid = (self._writeReqid + 1) & MAX_REQID;
2122
+ writeUInt32BE(out, reqid, 5);
2123
+
2124
+ writeUInt32BE(out, handleLen, p);
2125
+ out.set(handle, p += 4);
2126
+ p += handleLen;
2127
+ for (let i = 7; i >= 0; --i) {
2128
+ out[p + i] = pos & 0xFF;
2129
+ pos /= 256;
2130
+ }
2131
+ writeUInt32BE(out, len, p += 8);
2132
+
2133
+ if (typeof cb !== 'function')
2134
+ cb = noop;
2135
+
2136
+ const req = (req_ || {
2137
+ nb: 0,
2138
+ position,
2139
+ off,
2140
+ origOff: off,
2141
+ len: undefined,
2142
+ overflow: undefined,
2143
+ cb: (err, data, nb) => {
2144
+ const len = req.len;
2145
+ const overflow = req.overflow;
2146
+
2147
+ if (err) {
2148
+ if (cb._wantEOFError || err.code !== STATUS_CODE.EOF)
2149
+ return cb(err);
2150
+ } else if (nb > len) {
2151
+ return cb(new Error('Received more data than requested'));
2152
+ } else if (nb === len && overflow) {
2153
+ req.nb += nb;
2154
+ req.position += nb;
2155
+ req.off += nb;
2156
+ read_(self, handle, buf, req.off, overflow, req.position, cb, req);
2157
+ return;
2158
+ }
2159
+
2160
+ nb = (nb || 0);
2161
+ if (req.origOff === 0 && buf.length === req.nb)
2162
+ data = buf;
2163
+ else
2164
+ data = bufferSlice(buf, req.origOff, req.origOff + req.nb + nb);
2165
+ cb(undefined, req.nb + nb, data, req.position);
2166
+ },
2167
+ buffer: undefined,
2168
+ });
2169
+
2170
+ req.len = len;
2171
+ req.overflow = overflow;
2172
+
2173
+ // TODO: avoid creating multiple buffer slices when we need to re-call read_()
2174
+ // because of overflow
2175
+ req.buffer = bufferSlice(buf, off, off + len);
2176
+
2177
+ self._requests[reqid] = req;
2178
+
2179
+ const isBuffered = sendOrBuffer(self, out);
2180
+ self._debug && self._debug(
2181
+ `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READ`
2182
+ );
2183
+ }
2184
+
2185
+ function fastXfer(src, dst, srcPath, dstPath, opts, cb) {
2186
+ let concurrency = 64;
2187
+ let chunkSize = 32768;
2188
+ let onstep;
2189
+ let mode;
2190
+ let fileSize;
2191
+
2192
+ if (typeof opts === 'function') {
2193
+ cb = opts;
2194
+ } else if (typeof opts === 'object' && opts !== null) {
2195
+ if (typeof opts.concurrency === 'number'
2196
+ && opts.concurrency > 0
2197
+ && !isNaN(opts.concurrency)) {
2198
+ concurrency = opts.concurrency;
2199
+ }
2200
+ if (typeof opts.chunkSize === 'number'
2201
+ && opts.chunkSize > 0
2202
+ && !isNaN(opts.chunkSize)) {
2203
+ chunkSize = opts.chunkSize;
2204
+ }
2205
+ if (typeof opts.fileSize === 'number'
2206
+ && opts.fileSize > 0
2207
+ && !isNaN(opts.fileSize)) {
2208
+ fileSize = opts.fileSize;
2209
+ }
2210
+ if (typeof opts.step === 'function')
2211
+ onstep = opts.step;
2212
+
2213
+ if (typeof opts.mode === 'string' || typeof opts.mode === 'number')
2214
+ mode = modeNum(opts.mode);
2215
+ }
2216
+
2217
+ // Internal state variables
2218
+ let fsize;
2219
+ let pdst = 0;
2220
+ let total = 0;
2221
+ let hadError = false;
2222
+ let srcHandle;
2223
+ let dstHandle;
2224
+ let readbuf;
2225
+ let bufsize = chunkSize * concurrency;
2226
+
2227
+ function onerror(err) {
2228
+ if (hadError)
2229
+ return;
2230
+
2231
+ hadError = true;
2232
+
2233
+ let left = 0;
2234
+ let cbfinal;
2235
+
2236
+ if (srcHandle || dstHandle) {
2237
+ cbfinal = () => {
2238
+ if (--left === 0)
2239
+ cb(err);
2240
+ };
2241
+ if (srcHandle && (src === fs || src.outgoing.state === 'open'))
2242
+ ++left;
2243
+ if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))
2244
+ ++left;
2245
+ if (srcHandle && (src === fs || src.outgoing.state === 'open'))
2246
+ src.close(srcHandle, cbfinal);
2247
+ if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))
2248
+ dst.close(dstHandle, cbfinal);
2249
+ } else {
2250
+ cb(err);
2251
+ }
2252
+ }
2253
+
2254
+ src.open(srcPath, 'r', (err, sourceHandle) => {
2255
+ if (err)
2256
+ return onerror(err);
2257
+
2258
+ srcHandle = sourceHandle;
2259
+
2260
+ if (fileSize === undefined)
2261
+ src.fstat(srcHandle, tryStat);
2262
+ else
2263
+ tryStat(null, { size: fileSize });
2264
+
2265
+ function tryStat(err, attrs) {
2266
+ if (err) {
2267
+ if (src !== fs) {
2268
+ // Try stat() for sftp servers that may not support fstat() for
2269
+ // whatever reason
2270
+ src.stat(srcPath, (err_, attrs_) => {
2271
+ if (err_)
2272
+ return onerror(err);
2273
+ tryStat(null, attrs_);
2274
+ });
2275
+ return;
2276
+ }
2277
+ return onerror(err);
2278
+ }
2279
+ fsize = attrs.size;
2280
+
2281
+ dst.open(dstPath, 'w', (err, destHandle) => {
2282
+ if (err)
2283
+ return onerror(err);
2284
+
2285
+ dstHandle = destHandle;
2286
+
2287
+ if (fsize <= 0)
2288
+ return onerror();
2289
+
2290
+ // Use less memory where possible
2291
+ while (bufsize > fsize) {
2292
+ if (concurrency === 1) {
2293
+ bufsize = fsize;
2294
+ break;
2295
+ }
2296
+ bufsize -= chunkSize;
2297
+ --concurrency;
2298
+ }
2299
+
2300
+ readbuf = tryCreateBuffer(bufsize);
2301
+ if (readbuf instanceof Error)
2302
+ return onerror(readbuf);
2303
+
2304
+ if (mode !== undefined) {
2305
+ dst.fchmod(dstHandle, mode, function tryAgain(err) {
2306
+ if (err) {
2307
+ // Try chmod() for sftp servers that may not support fchmod()
2308
+ // for whatever reason
2309
+ dst.chmod(dstPath, mode, (err_) => tryAgain());
2310
+ return;
2311
+ }
2312
+ startReads();
2313
+ });
2314
+ } else {
2315
+ startReads();
2316
+ }
2317
+
2318
+ function onread(err, nb, data, dstpos, datapos, origChunkLen) {
2319
+ if (err)
2320
+ return onerror(err);
2321
+
2322
+ datapos = datapos || 0;
2323
+
2324
+ dst.write(dstHandle, readbuf, datapos, nb, dstpos, writeCb);
2325
+
2326
+ function writeCb(err) {
2327
+ if (err)
2328
+ return onerror(err);
2329
+
2330
+ total += nb;
2331
+ onstep && onstep(total, nb, fsize);
2332
+
2333
+ if (nb < origChunkLen)
2334
+ return singleRead(datapos, dstpos + nb, origChunkLen - nb);
2335
+
2336
+ if (total === fsize) {
2337
+ dst.close(dstHandle, (err) => {
2338
+ dstHandle = undefined;
2339
+ if (err)
2340
+ return onerror(err);
2341
+ src.close(srcHandle, (err) => {
2342
+ srcHandle = undefined;
2343
+ if (err)
2344
+ return onerror(err);
2345
+ cb();
2346
+ });
2347
+ });
2348
+ return;
2349
+ }
2350
+
2351
+ if (pdst >= fsize)
2352
+ return;
2353
+
2354
+ const chunk =
2355
+ (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);
2356
+ singleRead(datapos, pdst, chunk);
2357
+ pdst += chunk;
2358
+ }
2359
+ }
2360
+
2361
+ function makeCb(psrc, pdst, chunk) {
2362
+ return (err, nb, data) => {
2363
+ onread(err, nb, data, pdst, psrc, chunk);
2364
+ };
2365
+ }
2366
+
2367
+ function singleRead(psrc, pdst, chunk) {
2368
+ src.read(srcHandle,
2369
+ readbuf,
2370
+ psrc,
2371
+ chunk,
2372
+ pdst,
2373
+ makeCb(psrc, pdst, chunk));
2374
+ }
2375
+
2376
+ function startReads() {
2377
+ let reads = 0;
2378
+ let psrc = 0;
2379
+ while (pdst < fsize && reads < concurrency) {
2380
+ const chunk =
2381
+ (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);
2382
+ singleRead(psrc, pdst, chunk);
2383
+ psrc += chunk;
2384
+ pdst += chunk;
2385
+ ++reads;
2386
+ }
2387
+ }
2388
+ });
2389
+ }
2390
+ });
2391
+ }
2392
+
2393
+ function writeAll(sftp, handle, buffer, offset, length, position, callback_) {
2394
+ const callback = (typeof callback_ === 'function' ? callback_ : undefined);
2395
+
2396
+ sftp.write(handle,
2397
+ buffer,
2398
+ offset,
2399
+ length,
2400
+ position,
2401
+ (writeErr, written) => {
2402
+ if (writeErr) {
2403
+ return sftp.close(handle, () => {
2404
+ callback && callback(writeErr);
2405
+ });
2406
+ }
2407
+ if (written === length) {
2408
+ sftp.close(handle, callback);
2409
+ } else {
2410
+ offset += written;
2411
+ length -= written;
2412
+ position += written;
2413
+ writeAll(sftp, handle, buffer, offset, length, position, callback);
2414
+ }
2415
+ });
2416
+ }
2417
+
2418
+ class Stats {
2419
+ constructor(initial) {
2420
+ this.mode = (initial && initial.mode);
2421
+ this.uid = (initial && initial.uid);
2422
+ this.gid = (initial && initial.gid);
2423
+ this.size = (initial && initial.size);
2424
+ this.atime = (initial && initial.atime);
2425
+ this.mtime = (initial && initial.mtime);
2426
+ this.extended = (initial && initial.extended);
2427
+ }
2428
+ isDirectory() {
2429
+ return ((this.mode & constants.S_IFMT) === constants.S_IFDIR);
2430
+ }
2431
+ isFile() {
2432
+ return ((this.mode & constants.S_IFMT) === constants.S_IFREG);
2433
+ }
2434
+ isBlockDevice() {
2435
+ return ((this.mode & constants.S_IFMT) === constants.S_IFBLK);
2436
+ }
2437
+ isCharacterDevice() {
2438
+ return ((this.mode & constants.S_IFMT) === constants.S_IFCHR);
2439
+ }
2440
+ isSymbolicLink() {
2441
+ return ((this.mode & constants.S_IFMT) === constants.S_IFLNK);
2442
+ }
2443
+ isFIFO() {
2444
+ return ((this.mode & constants.S_IFMT) === constants.S_IFIFO);
2445
+ }
2446
+ isSocket() {
2447
+ return ((this.mode & constants.S_IFMT) === constants.S_IFSOCK);
2448
+ }
2449
+ }
2450
+
2451
+ function attrsToBytes(attrs) {
2452
+ let flags = 0;
2453
+ let nb = 0;
2454
+
2455
+ if (typeof attrs === 'object' && attrs !== null) {
2456
+ if (typeof attrs.size === 'number') {
2457
+ flags |= ATTR.SIZE;
2458
+ const val = attrs.size;
2459
+ // Big Endian
2460
+ ATTRS_BUF[nb++] = val / 72057594037927940; // 2**56
2461
+ ATTRS_BUF[nb++] = val / 281474976710656; // 2**48
2462
+ ATTRS_BUF[nb++] = val / 1099511627776; // 2**40
2463
+ ATTRS_BUF[nb++] = val / 4294967296; // 2**32
2464
+ ATTRS_BUF[nb++] = val / 16777216; // 2**24
2465
+ ATTRS_BUF[nb++] = val / 65536; // 2**16
2466
+ ATTRS_BUF[nb++] = val / 256; // 2**8
2467
+ ATTRS_BUF[nb++] = val;
2468
+ }
2469
+ if (typeof attrs.uid === 'number' && typeof attrs.gid === 'number') {
2470
+ flags |= ATTR.UIDGID;
2471
+ const uid = attrs.uid;
2472
+ const gid = attrs.gid;
2473
+ // Big Endian
2474
+ ATTRS_BUF[nb++] = uid >>> 24;
2475
+ ATTRS_BUF[nb++] = uid >>> 16;
2476
+ ATTRS_BUF[nb++] = uid >>> 8;
2477
+ ATTRS_BUF[nb++] = uid;
2478
+ ATTRS_BUF[nb++] = gid >>> 24;
2479
+ ATTRS_BUF[nb++] = gid >>> 16;
2480
+ ATTRS_BUF[nb++] = gid >>> 8;
2481
+ ATTRS_BUF[nb++] = gid;
2482
+ }
2483
+ if (typeof attrs.mode === 'number' || typeof attrs.mode === 'string') {
2484
+ const mode = modeNum(attrs.mode);
2485
+ flags |= ATTR.PERMISSIONS;
2486
+ // Big Endian
2487
+ ATTRS_BUF[nb++] = mode >>> 24;
2488
+ ATTRS_BUF[nb++] = mode >>> 16;
2489
+ ATTRS_BUF[nb++] = mode >>> 8;
2490
+ ATTRS_BUF[nb++] = mode;
2491
+ }
2492
+ if ((typeof attrs.atime === 'number' || isDate(attrs.atime))
2493
+ && (typeof attrs.mtime === 'number' || isDate(attrs.mtime))) {
2494
+ const atime = toUnixTimestamp(attrs.atime);
2495
+ const mtime = toUnixTimestamp(attrs.mtime);
2496
+
2497
+ flags |= ATTR.ACMODTIME;
2498
+ // Big Endian
2499
+ ATTRS_BUF[nb++] = atime >>> 24;
2500
+ ATTRS_BUF[nb++] = atime >>> 16;
2501
+ ATTRS_BUF[nb++] = atime >>> 8;
2502
+ ATTRS_BUF[nb++] = atime;
2503
+ ATTRS_BUF[nb++] = mtime >>> 24;
2504
+ ATTRS_BUF[nb++] = mtime >>> 16;
2505
+ ATTRS_BUF[nb++] = mtime >>> 8;
2506
+ ATTRS_BUF[nb++] = mtime;
2507
+ }
2508
+ // TODO: extended attributes
2509
+ }
2510
+
2511
+ return { flags, nb };
2512
+ }
2513
+
2514
+ function toUnixTimestamp(time) {
2515
+ // eslint-disable-next-line no-self-compare
2516
+ if (typeof time === 'number' && time === time) // Valid, non-NaN number
2517
+ return time;
2518
+ if (isDate(time))
2519
+ return parseInt(time.getTime() / 1000, 10);
2520
+ throw new Error(`Cannot parse time: ${time}`);
2521
+ }
2522
+
2523
+ function modeNum(mode) {
2524
+ // eslint-disable-next-line no-self-compare
2525
+ if (typeof mode === 'number' && mode === mode) // Valid, non-NaN number
2526
+ return mode;
2527
+ if (typeof mode === 'string')
2528
+ return modeNum(parseInt(mode, 8));
2529
+ throw new Error(`Cannot parse mode: ${mode}`);
2530
+ }
2531
+
2532
+ const stringFlagMap = {
2533
+ 'r': OPEN_MODE.READ,
2534
+ 'r+': OPEN_MODE.READ | OPEN_MODE.WRITE,
2535
+ 'w': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE,
2536
+ 'wx': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,
2537
+ 'xw': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,
2538
+ 'w+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,
2539
+ 'wx+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE
2540
+ | OPEN_MODE.EXCL,
2541
+ 'xw+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE
2542
+ | OPEN_MODE.EXCL,
2543
+ 'a': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE,
2544
+ 'ax': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,
2545
+ 'xa': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,
2546
+ 'a+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,
2547
+ 'ax+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE
2548
+ | OPEN_MODE.EXCL,
2549
+ 'xa+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE
2550
+ | OPEN_MODE.EXCL
2551
+ };
2552
+
2553
+ function stringToFlags(str) {
2554
+ const flags = stringFlagMap[str];
2555
+ return (flags !== undefined ? flags : null);
2556
+ }
2557
+
2558
+ const flagsToString = (() => {
2559
+ const stringFlagMapKeys = Object.keys(stringFlagMap);
2560
+ return (flags) => {
2561
+ for (let i = 0; i < stringFlagMapKeys.length; ++i) {
2562
+ const key = stringFlagMapKeys[i];
2563
+ if (stringFlagMap[key] === flags)
2564
+ return key;
2565
+ }
2566
+ return null;
2567
+ };
2568
+ })();
2569
+
2570
+ function readAttrs(biOpt) {
2571
+ /*
2572
+ uint32 flags
2573
+ uint64 size present only if flag SSH_FILEXFER_ATTR_SIZE
2574
+ uint32 uid present only if flag SSH_FILEXFER_ATTR_UIDGID
2575
+ uint32 gid present only if flag SSH_FILEXFER_ATTR_UIDGID
2576
+ uint32 permissions present only if flag SSH_FILEXFER_ATTR_PERMISSIONS
2577
+ uint32 atime present only if flag SSH_FILEXFER_ACMODTIME
2578
+ uint32 mtime present only if flag SSH_FILEXFER_ACMODTIME
2579
+ uint32 extended_count present only if flag SSH_FILEXFER_ATTR_EXTENDED
2580
+ string extended_type
2581
+ string extended_data
2582
+ ... more extended data (extended_type - extended_data pairs),
2583
+ so that number of pairs equals extended_count
2584
+ */
2585
+ const flags = bufferParser.readUInt32BE();
2586
+ if (flags === undefined)
2587
+ return;
2588
+
2589
+ const attrs = new Stats();
2590
+ if (flags & ATTR.SIZE) {
2591
+ const size = bufferParser.readUInt64BE(biOpt);
2592
+ if (size === undefined)
2593
+ return;
2594
+ attrs.size = size;
2595
+ }
2596
+
2597
+ if (flags & ATTR.UIDGID) {
2598
+ const uid = bufferParser.readUInt32BE();
2599
+ const gid = bufferParser.readUInt32BE();
2600
+ if (gid === undefined)
2601
+ return;
2602
+ attrs.uid = uid;
2603
+ attrs.gid = gid;
2604
+ }
2605
+
2606
+ if (flags & ATTR.PERMISSIONS) {
2607
+ const mode = bufferParser.readUInt32BE();
2608
+ if (mode === undefined)
2609
+ return;
2610
+ attrs.mode = mode;
2611
+ }
2612
+
2613
+ if (flags & ATTR.ACMODTIME) {
2614
+ const atime = bufferParser.readUInt32BE();
2615
+ const mtime = bufferParser.readUInt32BE();
2616
+ if (mtime === undefined)
2617
+ return;
2618
+ attrs.atime = atime;
2619
+ attrs.mtime = mtime;
2620
+ }
2621
+
2622
+ if (flags & ATTR.EXTENDED) {
2623
+ const count = bufferParser.readUInt32BE();
2624
+ if (count === undefined)
2625
+ return;
2626
+ const extended = {};
2627
+ for (let i = 0; i < count; ++i) {
2628
+ const type = bufferParser.readString(true);
2629
+ const data = bufferParser.readString();
2630
+ if (data === undefined)
2631
+ return;
2632
+ extended[type] = data;
2633
+ }
2634
+ attrs.extended = extended;
2635
+ }
2636
+
2637
+ return attrs;
2638
+ }
2639
+
2640
+ function sendOrBuffer(sftp, payload) {
2641
+ const ret = tryWritePayload(sftp, payload);
2642
+ if (ret !== undefined) {
2643
+ sftp._buffer.push(ret);
2644
+ return false;
2645
+ }
2646
+ return true;
2647
+ }
2648
+
2649
+ function tryWritePayload(sftp, payload) {
2650
+ const outgoing = sftp.outgoing;
2651
+ if (outgoing.state !== 'open')
2652
+ return;
2653
+
2654
+ if (outgoing.window === 0) {
2655
+ sftp._waitWindow = true;
2656
+ sftp._chunkcb = drainBuffer;
2657
+ return payload;
2658
+ }
2659
+
2660
+ let ret;
2661
+ const len = payload.length;
2662
+ let p = 0;
2663
+
2664
+ while (len - p > 0 && outgoing.window > 0) {
2665
+ const actualLen = Math.min(len - p, outgoing.window, outgoing.packetSize);
2666
+ outgoing.window -= actualLen;
2667
+ if (outgoing.window === 0) {
2668
+ sftp._waitWindow = true;
2669
+ sftp._chunkcb = drainBuffer;
2670
+ }
2671
+
2672
+ if (p === 0 && actualLen === len) {
2673
+ sftp._protocol.channelData(sftp.outgoing.id, payload);
2674
+ } else {
2675
+ sftp._protocol.channelData(sftp.outgoing.id,
2676
+ bufferSlice(payload, p, p + actualLen));
2677
+ }
2678
+
2679
+ p += actualLen;
2680
+ }
2681
+
2682
+ if (len - p > 0) {
2683
+ if (p > 0)
2684
+ ret = bufferSlice(payload, p, len);
2685
+ else
2686
+ ret = payload; // XXX: should never get here?
2687
+ }
2688
+
2689
+ return ret;
2690
+ }
2691
+
2692
+ function drainBuffer() {
2693
+ this._chunkcb = undefined;
2694
+ const buffer = this._buffer;
2695
+ let i = 0;
2696
+ while (i < buffer.length) {
2697
+ const payload = buffer[i];
2698
+ const ret = tryWritePayload(this, payload);
2699
+ if (ret !== undefined) {
2700
+ if (ret !== payload)
2701
+ buffer[i] = ret;
2702
+ if (i > 0)
2703
+ this._buffer = buffer.slice(i);
2704
+ return;
2705
+ }
2706
+ ++i;
2707
+ }
2708
+ if (i > 0)
2709
+ this._buffer = [];
2710
+ }
2711
+
2712
+ function doFatalSFTPError(sftp, msg, noDebug) {
2713
+ const err = new Error(msg);
2714
+ err.level = 'sftp-protocol';
2715
+ if (!noDebug && sftp._debug)
2716
+ sftp._debug(`SFTP: Inbound: ${msg}`);
2717
+ sftp.emit('error', err);
2718
+ sftp.destroy();
2719
+ cleanupRequests(sftp);
2720
+ return false;
2721
+ }
2722
+
2723
+ function cleanupRequests(sftp) {
2724
+ const keys = Object.keys(sftp._requests);
2725
+ if (keys.length === 0)
2726
+ return;
2727
+
2728
+ const reqs = sftp._requests;
2729
+ sftp._requests = {};
2730
+ const err = new Error('No response from server');
2731
+ for (let i = 0; i < keys.length; ++i) {
2732
+ const req = reqs[keys[i]];
2733
+ if (typeof req.cb === 'function')
2734
+ req.cb(err);
2735
+ }
2736
+ }
2737
+
2738
+ function requestLimits(sftp, cb) {
2739
+ /*
2740
+ uint32 id
2741
+ string "limits@openssh.com"
2742
+ */
2743
+ let p = 9;
2744
+ const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 18);
2745
+
2746
+ writeUInt32BE(buf, buf.length - 4, 0);
2747
+ buf[4] = REQUEST.EXTENDED;
2748
+ const reqid = sftp._writeReqid = (sftp._writeReqid + 1) & MAX_REQID;
2749
+ writeUInt32BE(buf, reqid, 5);
2750
+
2751
+ writeUInt32BE(buf, 18, p);
2752
+ buf.utf8Write('limits@openssh.com', p += 4, 18);
2753
+
2754
+ sftp._requests[reqid] = { extended: 'limits@openssh.com', cb };
2755
+
2756
+ const isBuffered = sendOrBuffer(sftp, buf);
2757
+ if (sftp._debug) {
2758
+ const which = (isBuffered ? 'Buffered' : 'Sending');
2759
+ sftp._debug(`SFTP: Outbound: ${which} limits@openssh.com`);
2760
+ }
2761
+ }
2762
+
2763
+ const CLIENT_HANDLERS = {
2764
+ [RESPONSE.VERSION]: (sftp, payload) => {
2765
+ if (sftp._version !== -1)
2766
+ return doFatalSFTPError(sftp, 'Duplicate VERSION packet');
2767
+
2768
+ const extensions = {};
2769
+
2770
+ /*
2771
+ uint32 version
2772
+ <extension data>
2773
+ */
2774
+ bufferParser.init(payload, 1);
2775
+ let version = bufferParser.readUInt32BE();
2776
+ while (bufferParser.avail()) {
2777
+ const extName = bufferParser.readString(true);
2778
+ const extData = bufferParser.readString(true);
2779
+ if (extData === undefined) {
2780
+ version = undefined;
2781
+ break;
2782
+ }
2783
+ extensions[extName] = extData;
2784
+ }
2785
+ bufferParser.clear();
2786
+
2787
+ if (version === undefined)
2788
+ return doFatalSFTPError(sftp, 'Malformed VERSION packet');
2789
+
2790
+ if (sftp._debug) {
2791
+ const names = Object.keys(extensions);
2792
+ if (names.length) {
2793
+ sftp._debug(
2794
+ `SFTP: Inbound: Received VERSION (v${version}, exts:${names})`
2795
+ );
2796
+ } else {
2797
+ sftp._debug(`SFTP: Inbound: Received VERSION (v${version})`);
2798
+ }
2799
+ }
2800
+
2801
+ sftp._version = version;
2802
+ sftp._extensions = extensions;
2803
+
2804
+ if (extensions['limits@openssh.com'] === '1') {
2805
+ return requestLimits(sftp, (err, limits) => {
2806
+ if (!err) {
2807
+ if (limits.maxPktLen > 0)
2808
+ sftp._maxOutPktLen = limits.maxPktLen;
2809
+ if (limits.maxReadLen > 0)
2810
+ sftp._maxReadLen = limits.maxReadLen;
2811
+ if (limits.maxWriteLen > 0)
2812
+ sftp._maxWriteLen = limits.maxWriteLen;
2813
+ sftp.maxOpenHandles = (
2814
+ limits.maxOpenHandles > 0 ? limits.maxOpenHandles : Infinity
2815
+ );
2816
+ }
2817
+ sftp.emit('ready');
2818
+ });
2819
+ }
2820
+
2821
+ sftp.emit('ready');
2822
+ },
2823
+ [RESPONSE.STATUS]: (sftp, payload) => {
2824
+ bufferParser.init(payload, 1);
2825
+ const reqID = bufferParser.readUInt32BE();
2826
+ /*
2827
+ uint32 error/status code
2828
+ string error message (ISO-10646 UTF-8)
2829
+ string language tag
2830
+ */
2831
+ const errorCode = bufferParser.readUInt32BE();
2832
+ const errorMsg = bufferParser.readString(true);
2833
+ bufferParser.clear();
2834
+
2835
+ // Note: we avoid checking that the error message and language tag are in
2836
+ // the packet because there are some broken implementations that incorrectly
2837
+ // omit them. The language tag in general was never really used amongst ssh
2838
+ // implementations, so in the case of a missing error message we just
2839
+ // default to something sensible.
2840
+
2841
+ if (sftp._debug) {
2842
+ const jsonMsg = JSON.stringify(errorMsg);
2843
+ sftp._debug(
2844
+ `SFTP: Inbound: Received STATUS (id:${reqID}, ${errorCode}, ${jsonMsg})`
2845
+ );
2846
+ }
2847
+ const req = sftp._requests[reqID];
2848
+ delete sftp._requests[reqID];
2849
+ if (req && typeof req.cb === 'function') {
2850
+ if (errorCode === STATUS_CODE.OK) {
2851
+ req.cb();
2852
+ return;
2853
+ }
2854
+ const err = new Error(errorMsg
2855
+ || STATUS_CODE_STR[errorCode]
2856
+ || 'Unknown status');
2857
+ err.code = errorCode;
2858
+ req.cb(err);
2859
+ }
2860
+ },
2861
+ [RESPONSE.HANDLE]: (sftp, payload) => {
2862
+ bufferParser.init(payload, 1);
2863
+ const reqID = bufferParser.readUInt32BE();
2864
+ /*
2865
+ string handle
2866
+ */
2867
+ const handle = bufferParser.readString();
2868
+ bufferParser.clear();
2869
+
2870
+ if (handle === undefined) {
2871
+ if (reqID !== undefined)
2872
+ delete sftp._requests[reqID];
2873
+ return doFatalSFTPError(sftp, 'Malformed HANDLE packet');
2874
+ }
2875
+
2876
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received HANDLE (id:${reqID})`);
2877
+
2878
+ const req = sftp._requests[reqID];
2879
+ delete sftp._requests[reqID];
2880
+ if (req && typeof req.cb === 'function')
2881
+ req.cb(undefined, handle);
2882
+ },
2883
+ [RESPONSE.DATA]: (sftp, payload) => {
2884
+ bufferParser.init(payload, 1);
2885
+ const reqID = bufferParser.readUInt32BE();
2886
+ let req;
2887
+ if (reqID !== undefined) {
2888
+ req = sftp._requests[reqID];
2889
+ delete sftp._requests[reqID];
2890
+ }
2891
+ /*
2892
+ string data
2893
+ */
2894
+ if (req && typeof req.cb === 'function') {
2895
+ if (req.buffer) {
2896
+ // We have already pre-allocated space to store the data
2897
+
2898
+ const nb = bufferParser.readString(req.buffer);
2899
+ bufferParser.clear();
2900
+
2901
+ if (nb !== undefined) {
2902
+ sftp._debug && sftp._debug(
2903
+ `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`
2904
+ );
2905
+ req.cb(undefined, req.buffer, nb);
2906
+ return;
2907
+ }
2908
+ } else {
2909
+ const data = bufferParser.readString();
2910
+ bufferParser.clear();
2911
+
2912
+ if (data !== undefined) {
2913
+ sftp._debug && sftp._debug(
2914
+ `SFTP: Inbound: Received DATA (id:${reqID}, ${data.length})`
2915
+ );
2916
+ req.cb(undefined, data);
2917
+ return;
2918
+ }
2919
+ }
2920
+ } else {
2921
+ const nb = bufferParser.skipString();
2922
+ bufferParser.clear();
2923
+ if (nb !== undefined) {
2924
+ sftp._debug && sftp._debug(
2925
+ `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`
2926
+ );
2927
+ return;
2928
+ }
2929
+ }
2930
+
2931
+ return doFatalSFTPError(sftp, 'Malformed DATA packet');
2932
+ },
2933
+ [RESPONSE.NAME]: (sftp, payload) => {
2934
+ bufferParser.init(payload, 1);
2935
+ const reqID = bufferParser.readUInt32BE();
2936
+ let req;
2937
+ if (reqID !== undefined) {
2938
+ req = sftp._requests[reqID];
2939
+ delete sftp._requests[reqID];
2940
+ }
2941
+ /*
2942
+ uint32 count
2943
+ repeats count times:
2944
+ string filename
2945
+ string longname
2946
+ ATTRS attrs
2947
+ */
2948
+ const count = bufferParser.readUInt32BE();
2949
+ if (count !== undefined) {
2950
+ let names = [];
2951
+ for (let i = 0; i < count; ++i) {
2952
+ // We are going to assume UTF-8 for filenames despite the SFTPv3
2953
+ // spec not specifying an encoding because the specs for newer
2954
+ // versions of the protocol all explicitly specify UTF-8 for
2955
+ // filenames
2956
+ const filename = bufferParser.readString(true);
2957
+
2958
+ // `longname` only exists in SFTPv3 and since it typically will
2959
+ // contain the filename, we assume it is also UTF-8
2960
+ const longname = bufferParser.readString(true);
2961
+
2962
+ const attrs = readAttrs(sftp._biOpt);
2963
+ if (attrs === undefined) {
2964
+ names = undefined;
2965
+ break;
2966
+ }
2967
+ names.push({ filename, longname, attrs });
2968
+ }
2969
+ if (names !== undefined) {
2970
+ sftp._debug && sftp._debug(
2971
+ `SFTP: Inbound: Received NAME (id:${reqID}, ${names.length})`
2972
+ );
2973
+ bufferParser.clear();
2974
+ if (req && typeof req.cb === 'function')
2975
+ req.cb(undefined, names);
2976
+ return;
2977
+ }
2978
+ }
2979
+
2980
+ bufferParser.clear();
2981
+ return doFatalSFTPError(sftp, 'Malformed NAME packet');
2982
+ },
2983
+ [RESPONSE.ATTRS]: (sftp, payload) => {
2984
+ bufferParser.init(payload, 1);
2985
+ const reqID = bufferParser.readUInt32BE();
2986
+ let req;
2987
+ if (reqID !== undefined) {
2988
+ req = sftp._requests[reqID];
2989
+ delete sftp._requests[reqID];
2990
+ }
2991
+ /*
2992
+ ATTRS attrs
2993
+ */
2994
+ const attrs = readAttrs(sftp._biOpt);
2995
+ bufferParser.clear();
2996
+ if (attrs !== undefined) {
2997
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received ATTRS (id:${reqID})`);
2998
+ if (req && typeof req.cb === 'function')
2999
+ req.cb(undefined, attrs);
3000
+ return;
3001
+ }
3002
+
3003
+ return doFatalSFTPError(sftp, 'Malformed ATTRS packet');
3004
+ },
3005
+ [RESPONSE.EXTENDED]: (sftp, payload) => {
3006
+ bufferParser.init(payload, 1);
3007
+ const reqID = bufferParser.readUInt32BE();
3008
+ if (reqID !== undefined) {
3009
+ const req = sftp._requests[reqID];
3010
+ if (req) {
3011
+ delete sftp._requests[reqID];
3012
+ switch (req.extended) {
3013
+ case 'statvfs@openssh.com':
3014
+ case 'fstatvfs@openssh.com': {
3015
+ /*
3016
+ uint64 f_bsize // file system block size
3017
+ uint64 f_frsize // fundamental fs block size
3018
+ uint64 f_blocks // number of blocks (unit f_frsize)
3019
+ uint64 f_bfree // free blocks in file system
3020
+ uint64 f_bavail // free blocks for non-root
3021
+ uint64 f_files // total file inodes
3022
+ uint64 f_ffree // free file inodes
3023
+ uint64 f_favail // free file inodes for to non-root
3024
+ uint64 f_fsid // file system id
3025
+ uint64 f_flag // bit mask of f_flag values
3026
+ uint64 f_namemax // maximum filename length
3027
+ */
3028
+ const biOpt = sftp._biOpt;
3029
+ const stats = {
3030
+ f_bsize: bufferParser.readUInt64BE(biOpt),
3031
+ f_frsize: bufferParser.readUInt64BE(biOpt),
3032
+ f_blocks: bufferParser.readUInt64BE(biOpt),
3033
+ f_bfree: bufferParser.readUInt64BE(biOpt),
3034
+ f_bavail: bufferParser.readUInt64BE(biOpt),
3035
+ f_files: bufferParser.readUInt64BE(biOpt),
3036
+ f_ffree: bufferParser.readUInt64BE(biOpt),
3037
+ f_favail: bufferParser.readUInt64BE(biOpt),
3038
+ f_sid: bufferParser.readUInt64BE(biOpt),
3039
+ f_flag: bufferParser.readUInt64BE(biOpt),
3040
+ f_namemax: bufferParser.readUInt64BE(biOpt),
3041
+ };
3042
+ if (stats.f_namemax === undefined)
3043
+ break;
3044
+ if (sftp._debug) {
3045
+ sftp._debug(
3046
+ 'SFTP: Inbound: Received EXTENDED_REPLY '
3047
+ + `(id:${reqID}, ${req.extended})`
3048
+ );
3049
+ }
3050
+ bufferParser.clear();
3051
+ if (typeof req.cb === 'function')
3052
+ req.cb(undefined, stats);
3053
+ return;
3054
+ }
3055
+ case 'limits@openssh.com': {
3056
+ /*
3057
+ uint64 max-packet-length
3058
+ uint64 max-read-length
3059
+ uint64 max-write-length
3060
+ uint64 max-open-handles
3061
+ */
3062
+ const limits = {
3063
+ maxPktLen: bufferParser.readUInt64BE(),
3064
+ maxReadLen: bufferParser.readUInt64BE(),
3065
+ maxWriteLen: bufferParser.readUInt64BE(),
3066
+ maxOpenHandles: bufferParser.readUInt64BE(),
3067
+ };
3068
+ if (limits.maxOpenHandles === undefined)
3069
+ break;
3070
+ if (sftp._debug) {
3071
+ sftp._debug(
3072
+ 'SFTP: Inbound: Received EXTENDED_REPLY '
3073
+ + `(id:${reqID}, ${req.extended})`
3074
+ );
3075
+ }
3076
+ bufferParser.clear();
3077
+ if (typeof req.cb === 'function')
3078
+ req.cb(undefined, limits);
3079
+ return;
3080
+ }
3081
+ case 'users-groups-by-id@openssh.com': {
3082
+ /*
3083
+ string usernames
3084
+ string username1
3085
+ ...
3086
+ string groupnames
3087
+ string groupname1
3088
+ ...
3089
+ */
3090
+ const usernameCount = bufferParser.readUInt32BE();
3091
+ if (usernameCount === undefined)
3092
+ break;
3093
+ const usernames = new Array(usernameCount);
3094
+ for (let i = 0; i < usernames.length; ++i)
3095
+ usernames[i] = bufferParser.readString(true);
3096
+
3097
+ const groupnameCount = bufferParser.readUInt32BE();
3098
+ if (groupnameCount === undefined)
3099
+ break;
3100
+ const groupnames = new Array(groupnameCount);
3101
+ for (let i = 0; i < groupnames.length; ++i)
3102
+ groupnames[i] = bufferParser.readString(true);
3103
+ if (groupnames.length > 0
3104
+ && groupnames[groupnames.length - 1] === undefined) {
3105
+ break;
3106
+ }
3107
+
3108
+ if (sftp._debug) {
3109
+ sftp._debug(
3110
+ 'SFTP: Inbound: Received EXTENDED_REPLY '
3111
+ + `(id:${reqID}, ${req.extended})`
3112
+ );
3113
+ }
3114
+ bufferParser.clear();
3115
+ if (typeof req.cb === 'function')
3116
+ req.cb(undefined, usernames, groupnames);
3117
+ return;
3118
+ }
3119
+ default:
3120
+ // Unknown extended request
3121
+ sftp._debug && sftp._debug(
3122
+ `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`
3123
+ );
3124
+ bufferParser.clear();
3125
+ if (typeof req.cb === 'function')
3126
+ req.cb();
3127
+ return;
3128
+ }
3129
+ } else {
3130
+ sftp._debug && sftp._debug(
3131
+ `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`
3132
+ );
3133
+ bufferParser.clear();
3134
+ return;
3135
+ }
3136
+ }
3137
+
3138
+ bufferParser.clear();
3139
+ return doFatalSFTPError(sftp, 'Malformed EXTENDED_REPLY packet');
3140
+ },
3141
+ };
3142
+ const SERVER_HANDLERS = {
3143
+ [REQUEST.INIT]: (sftp, payload) => {
3144
+ if (sftp._version !== -1)
3145
+ return doFatalSFTPError(sftp, 'Duplicate INIT packet');
3146
+
3147
+ const extensions = {};
3148
+
3149
+ /*
3150
+ uint32 version
3151
+ <extension data>
3152
+ */
3153
+ bufferParser.init(payload, 1);
3154
+ let version = bufferParser.readUInt32BE();
3155
+ while (bufferParser.avail()) {
3156
+ const extName = bufferParser.readString(true);
3157
+ const extData = bufferParser.readString(true);
3158
+ if (extData === undefined) {
3159
+ version = undefined;
3160
+ break;
3161
+ }
3162
+ extensions[extName] = extData;
3163
+ }
3164
+ bufferParser.clear();
3165
+
3166
+ if (version === undefined)
3167
+ return doFatalSFTPError(sftp, 'Malformed INIT packet');
3168
+
3169
+ if (sftp._debug) {
3170
+ const names = Object.keys(extensions);
3171
+ if (names.length) {
3172
+ sftp._debug(
3173
+ `SFTP: Inbound: Received INIT (v${version}, exts:${names})`
3174
+ );
3175
+ } else {
3176
+ sftp._debug(`SFTP: Inbound: Received INIT (v${version})`);
3177
+ }
3178
+ }
3179
+
3180
+ sendOrBuffer(sftp, SERVER_VERSION_BUFFER);
3181
+
3182
+ sftp._version = version;
3183
+ sftp._extensions = extensions;
3184
+ sftp.emit('ready');
3185
+ },
3186
+ [REQUEST.OPEN]: (sftp, payload) => {
3187
+ bufferParser.init(payload, 1);
3188
+ const reqID = bufferParser.readUInt32BE();
3189
+ /*
3190
+ string filename
3191
+ uint32 pflags
3192
+ ATTRS attrs
3193
+ */
3194
+ const filename = bufferParser.readString(true);
3195
+ const pflags = bufferParser.readUInt32BE();
3196
+ const attrs = readAttrs(sftp._biOpt);
3197
+ bufferParser.clear();
3198
+
3199
+ if (attrs === undefined)
3200
+ return doFatalSFTPError(sftp, 'Malformed OPEN packet');
3201
+
3202
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received OPEN (id:${reqID})`);
3203
+
3204
+ if (!sftp.emit('OPEN', reqID, filename, pflags, attrs)) {
3205
+ // Automatically reject request if no handler for request type
3206
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3207
+ }
3208
+ },
3209
+ [REQUEST.CLOSE]: (sftp, payload) => {
3210
+ bufferParser.init(payload, 1);
3211
+ const reqID = bufferParser.readUInt32BE();
3212
+ /*
3213
+ string handle
3214
+ */
3215
+ const handle = bufferParser.readString();
3216
+ bufferParser.clear();
3217
+
3218
+ if (handle === undefined || handle.length > 256)
3219
+ return doFatalSFTPError(sftp, 'Malformed CLOSE packet');
3220
+
3221
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received CLOSE (id:${reqID})`);
3222
+
3223
+ if (!sftp.emit('CLOSE', reqID, handle)) {
3224
+ // Automatically reject request if no handler for request type
3225
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3226
+ }
3227
+ },
3228
+ [REQUEST.READ]: (sftp, payload) => {
3229
+ bufferParser.init(payload, 1);
3230
+ const reqID = bufferParser.readUInt32BE();
3231
+ /*
3232
+ string handle
3233
+ uint64 offset
3234
+ uint32 len
3235
+ */
3236
+ const handle = bufferParser.readString();
3237
+ const offset = bufferParser.readUInt64BE(sftp._biOpt);
3238
+ const len = bufferParser.readUInt32BE();
3239
+ bufferParser.clear();
3240
+
3241
+ if (len === undefined || handle.length > 256)
3242
+ return doFatalSFTPError(sftp, 'Malformed READ packet');
3243
+
3244
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received READ (id:${reqID})`);
3245
+
3246
+ if (!sftp.emit('READ', reqID, handle, offset, len)) {
3247
+ // Automatically reject request if no handler for request type
3248
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3249
+ }
3250
+ },
3251
+ [REQUEST.WRITE]: (sftp, payload) => {
3252
+ bufferParser.init(payload, 1);
3253
+ const reqID = bufferParser.readUInt32BE();
3254
+ /*
3255
+ string handle
3256
+ uint64 offset
3257
+ string data
3258
+ */
3259
+ const handle = bufferParser.readString();
3260
+ const offset = bufferParser.readUInt64BE(sftp._biOpt);
3261
+ const data = bufferParser.readString();
3262
+ bufferParser.clear();
3263
+
3264
+ if (data === undefined || handle.length > 256)
3265
+ return doFatalSFTPError(sftp, 'Malformed WRITE packet');
3266
+
3267
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received WRITE (id:${reqID})`);
3268
+
3269
+ if (!sftp.emit('WRITE', reqID, handle, offset, data)) {
3270
+ // Automatically reject request if no handler for request type
3271
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3272
+ }
3273
+ },
3274
+ [REQUEST.LSTAT]: (sftp, payload) => {
3275
+ bufferParser.init(payload, 1);
3276
+ const reqID = bufferParser.readUInt32BE();
3277
+ /*
3278
+ string path
3279
+ */
3280
+ const path = bufferParser.readString(true);
3281
+ bufferParser.clear();
3282
+
3283
+ if (path === undefined)
3284
+ return doFatalSFTPError(sftp, 'Malformed LSTAT packet');
3285
+
3286
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received LSTAT (id:${reqID})`);
3287
+
3288
+ if (!sftp.emit('LSTAT', reqID, path)) {
3289
+ // Automatically reject request if no handler for request type
3290
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3291
+ }
3292
+ },
3293
+ [REQUEST.FSTAT]: (sftp, payload) => {
3294
+ bufferParser.init(payload, 1);
3295
+ const reqID = bufferParser.readUInt32BE();
3296
+ /*
3297
+ string handle
3298
+ */
3299
+ const handle = bufferParser.readString();
3300
+ bufferParser.clear();
3301
+
3302
+ if (handle === undefined || handle.length > 256)
3303
+ return doFatalSFTPError(sftp, 'Malformed FSTAT packet');
3304
+
3305
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received FSTAT (id:${reqID})`);
3306
+
3307
+ if (!sftp.emit('FSTAT', reqID, handle)) {
3308
+ // Automatically reject request if no handler for request type
3309
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3310
+ }
3311
+ },
3312
+ [REQUEST.SETSTAT]: (sftp, payload) => {
3313
+ bufferParser.init(payload, 1);
3314
+ const reqID = bufferParser.readUInt32BE();
3315
+ /*
3316
+ string path
3317
+ ATTRS attrs
3318
+ */
3319
+ const path = bufferParser.readString(true);
3320
+ const attrs = readAttrs(sftp._biOpt);
3321
+ bufferParser.clear();
3322
+
3323
+ if (attrs === undefined)
3324
+ return doFatalSFTPError(sftp, 'Malformed SETSTAT packet');
3325
+
3326
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received SETSTAT (id:${reqID})`);
3327
+
3328
+ if (!sftp.emit('SETSTAT', reqID, path, attrs)) {
3329
+ // Automatically reject request if no handler for request type
3330
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3331
+ }
3332
+ },
3333
+ [REQUEST.FSETSTAT]: (sftp, payload) => {
3334
+ bufferParser.init(payload, 1);
3335
+ const reqID = bufferParser.readUInt32BE();
3336
+ /*
3337
+ string handle
3338
+ ATTRS attrs
3339
+ */
3340
+ const handle = bufferParser.readString();
3341
+ const attrs = readAttrs(sftp._biOpt);
3342
+ bufferParser.clear();
3343
+
3344
+ if (attrs === undefined || handle.length > 256)
3345
+ return doFatalSFTPError(sftp, 'Malformed FSETSTAT packet');
3346
+
3347
+ sftp._debug && sftp._debug(
3348
+ `SFTP: Inbound: Received FSETSTAT (id:${reqID})`
3349
+ );
3350
+
3351
+ if (!sftp.emit('FSETSTAT', reqID, handle, attrs)) {
3352
+ // Automatically reject request if no handler for request type
3353
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3354
+ }
3355
+ },
3356
+ [REQUEST.OPENDIR]: (sftp, payload) => {
3357
+ bufferParser.init(payload, 1);
3358
+ const reqID = bufferParser.readUInt32BE();
3359
+ /*
3360
+ string path
3361
+ */
3362
+ const path = bufferParser.readString(true);
3363
+ bufferParser.clear();
3364
+
3365
+ if (path === undefined)
3366
+ return doFatalSFTPError(sftp, 'Malformed OPENDIR packet');
3367
+
3368
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received OPENDIR (id:${reqID})`);
3369
+
3370
+ if (!sftp.emit('OPENDIR', reqID, path)) {
3371
+ // Automatically reject request if no handler for request type
3372
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3373
+ }
3374
+ },
3375
+ [REQUEST.READDIR]: (sftp, payload) => {
3376
+ bufferParser.init(payload, 1);
3377
+ const reqID = bufferParser.readUInt32BE();
3378
+ /*
3379
+ string handle
3380
+ */
3381
+ const handle = bufferParser.readString();
3382
+ bufferParser.clear();
3383
+
3384
+ if (handle === undefined || handle.length > 256)
3385
+ return doFatalSFTPError(sftp, 'Malformed READDIR packet');
3386
+
3387
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received READDIR (id:${reqID})`);
3388
+
3389
+ if (!sftp.emit('READDIR', reqID, handle)) {
3390
+ // Automatically reject request if no handler for request type
3391
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3392
+ }
3393
+ },
3394
+ [REQUEST.REMOVE]: (sftp, payload) => {
3395
+ bufferParser.init(payload, 1);
3396
+ const reqID = bufferParser.readUInt32BE();
3397
+ /*
3398
+ string path
3399
+ */
3400
+ const path = bufferParser.readString(true);
3401
+ bufferParser.clear();
3402
+
3403
+ if (path === undefined)
3404
+ return doFatalSFTPError(sftp, 'Malformed REMOVE packet');
3405
+
3406
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received REMOVE (id:${reqID})`);
3407
+
3408
+ if (!sftp.emit('REMOVE', reqID, path)) {
3409
+ // Automatically reject request if no handler for request type
3410
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3411
+ }
3412
+ },
3413
+ [REQUEST.MKDIR]: (sftp, payload) => {
3414
+ bufferParser.init(payload, 1);
3415
+ const reqID = bufferParser.readUInt32BE();
3416
+ /*
3417
+ string path
3418
+ ATTRS attrs
3419
+ */
3420
+ const path = bufferParser.readString(true);
3421
+ const attrs = readAttrs(sftp._biOpt);
3422
+ bufferParser.clear();
3423
+
3424
+ if (attrs === undefined)
3425
+ return doFatalSFTPError(sftp, 'Malformed MKDIR packet');
3426
+
3427
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received MKDIR (id:${reqID})`);
3428
+
3429
+ if (!sftp.emit('MKDIR', reqID, path, attrs)) {
3430
+ // Automatically reject request if no handler for request type
3431
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3432
+ }
3433
+ },
3434
+ [REQUEST.RMDIR]: (sftp, payload) => {
3435
+ bufferParser.init(payload, 1);
3436
+ const reqID = bufferParser.readUInt32BE();
3437
+ /*
3438
+ string path
3439
+ */
3440
+ const path = bufferParser.readString(true);
3441
+ bufferParser.clear();
3442
+
3443
+ if (path === undefined)
3444
+ return doFatalSFTPError(sftp, 'Malformed RMDIR packet');
3445
+
3446
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received RMDIR (id:${reqID})`);
3447
+
3448
+ if (!sftp.emit('RMDIR', reqID, path)) {
3449
+ // Automatically reject request if no handler for request type
3450
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3451
+ }
3452
+ },
3453
+ [REQUEST.REALPATH]: (sftp, payload) => {
3454
+ bufferParser.init(payload, 1);
3455
+ const reqID = bufferParser.readUInt32BE();
3456
+ /*
3457
+ string path
3458
+ */
3459
+ const path = bufferParser.readString(true);
3460
+ bufferParser.clear();
3461
+
3462
+ if (path === undefined)
3463
+ return doFatalSFTPError(sftp, 'Malformed REALPATH packet');
3464
+
3465
+ sftp._debug && sftp._debug(
3466
+ `SFTP: Inbound: Received REALPATH (id:${reqID})`
3467
+ );
3468
+
3469
+ if (!sftp.emit('REALPATH', reqID, path)) {
3470
+ // Automatically reject request if no handler for request type
3471
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3472
+ }
3473
+ },
3474
+ [REQUEST.STAT]: (sftp, payload) => {
3475
+ bufferParser.init(payload, 1);
3476
+ const reqID = bufferParser.readUInt32BE();
3477
+ /*
3478
+ string path
3479
+ */
3480
+ const path = bufferParser.readString(true);
3481
+ bufferParser.clear();
3482
+
3483
+ if (path === undefined)
3484
+ return doFatalSFTPError(sftp, 'Malformed STAT packet');
3485
+
3486
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received STAT (id:${reqID})`);
3487
+
3488
+ if (!sftp.emit('STAT', reqID, path)) {
3489
+ // Automatically reject request if no handler for request type
3490
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3491
+ }
3492
+ },
3493
+ [REQUEST.RENAME]: (sftp, payload) => {
3494
+ bufferParser.init(payload, 1);
3495
+ const reqID = bufferParser.readUInt32BE();
3496
+ /*
3497
+ string oldpath
3498
+ string newpath
3499
+ */
3500
+ const oldPath = bufferParser.readString(true);
3501
+ const newPath = bufferParser.readString(true);
3502
+ bufferParser.clear();
3503
+
3504
+ if (newPath === undefined)
3505
+ return doFatalSFTPError(sftp, 'Malformed RENAME packet');
3506
+
3507
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received RENAME (id:${reqID})`);
3508
+
3509
+ if (!sftp.emit('RENAME', reqID, oldPath, newPath)) {
3510
+ // Automatically reject request if no handler for request type
3511
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3512
+ }
3513
+ },
3514
+ [REQUEST.READLINK]: (sftp, payload) => {
3515
+ bufferParser.init(payload, 1);
3516
+ const reqID = bufferParser.readUInt32BE();
3517
+ /*
3518
+ string path
3519
+ */
3520
+ const path = bufferParser.readString(true);
3521
+ bufferParser.clear();
3522
+
3523
+ if (path === undefined)
3524
+ return doFatalSFTPError(sftp, 'Malformed READLINK packet');
3525
+
3526
+ sftp._debug && sftp._debug(
3527
+ `SFTP: Inbound: Received READLINK (id:${reqID})`
3528
+ );
3529
+
3530
+ if (!sftp.emit('READLINK', reqID, path)) {
3531
+ // Automatically reject request if no handler for request type
3532
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3533
+ }
3534
+ },
3535
+ [REQUEST.SYMLINK]: (sftp, payload) => {
3536
+ bufferParser.init(payload, 1);
3537
+ const reqID = bufferParser.readUInt32BE();
3538
+ /*
3539
+ string linkpath
3540
+ string targetpath
3541
+ */
3542
+ const linkPath = bufferParser.readString(true);
3543
+ const targetPath = bufferParser.readString(true);
3544
+ bufferParser.clear();
3545
+
3546
+ if (targetPath === undefined)
3547
+ return doFatalSFTPError(sftp, 'Malformed SYMLINK packet');
3548
+
3549
+ sftp._debug && sftp._debug(`SFTP: Inbound: Received SYMLINK (id:${reqID})`);
3550
+
3551
+ let handled;
3552
+ if (sftp._isOpenSSH) {
3553
+ // OpenSSH has linkpath and targetpath positions switched
3554
+ handled = sftp.emit('SYMLINK', reqID, targetPath, linkPath);
3555
+ } else {
3556
+ handled = sftp.emit('SYMLINK', reqID, linkPath, targetPath);
3557
+ }
3558
+ if (!handled) {
3559
+ // Automatically reject request if no handler for request type
3560
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3561
+ }
3562
+ },
3563
+ [REQUEST.EXTENDED]: (sftp, payload) => {
3564
+ bufferParser.init(payload, 1);
3565
+ const reqID = bufferParser.readUInt32BE();
3566
+ /*
3567
+ string extended-request
3568
+ ... any request-specific data ...
3569
+ */
3570
+ const extName = bufferParser.readString(true);
3571
+ if (extName === undefined) {
3572
+ bufferParser.clear();
3573
+ return doFatalSFTPError(sftp, 'Malformed EXTENDED packet');
3574
+ }
3575
+
3576
+ let extData;
3577
+ if (bufferParser.avail())
3578
+ extData = bufferParser.readRaw();
3579
+ bufferParser.clear();
3580
+
3581
+ sftp._debug && sftp._debug(
3582
+ `SFTP: Inbound: Received EXTENDED (id:${reqID})`
3583
+ );
3584
+
3585
+ if (!sftp.emit('EXTENDED', reqID, extName, extData)) {
3586
+ // Automatically reject request if no handler for request type
3587
+ sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
3588
+ }
3589
+ },
3590
+ };
3591
+
3592
+ // =============================================================================
3593
+ // ReadStream/WriteStream-related ==============================================
3594
+ // =============================================================================
3595
+ const {
3596
+ ERR_INVALID_ARG_TYPE,
3597
+ ERR_OUT_OF_RANGE,
3598
+ validateNumber
3599
+ } = require('./node-fs-compat');
3600
+
3601
+ const kMinPoolSpace = 128;
3602
+
3603
+ let pool;
3604
+ // It can happen that we expect to read a large chunk of data, and reserve
3605
+ // a large chunk of the pool accordingly, but the read() call only filled
3606
+ // a portion of it. If a concurrently executing read() then uses the same pool,
3607
+ // the "reserved" portion cannot be used, so we allow it to be re-used as a
3608
+ // new pool later.
3609
+ const poolFragments = [];
3610
+
3611
+ function allocNewPool(poolSize) {
3612
+ if (poolFragments.length > 0)
3613
+ pool = poolFragments.pop();
3614
+ else
3615
+ pool = Buffer.allocUnsafe(poolSize);
3616
+ pool.used = 0;
3617
+ }
3618
+
3619
+ // Check the `this.start` and `this.end` of stream.
3620
+ function checkPosition(pos, name) {
3621
+ if (!Number.isSafeInteger(pos)) {
3622
+ validateNumber(pos, name);
3623
+ if (!Number.isInteger(pos))
3624
+ throw new ERR_OUT_OF_RANGE(name, 'an integer', pos);
3625
+ throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);
3626
+ }
3627
+ if (pos < 0)
3628
+ throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);
3629
+ }
3630
+
3631
+ function roundUpToMultipleOf8(n) {
3632
+ return (n + 7) & ~7; // Align to 8 byte boundary.
3633
+ }
3634
+
3635
+ function ReadStream(sftp, path, options) {
3636
+ if (options === undefined)
3637
+ options = {};
3638
+ else if (typeof options === 'string')
3639
+ options = { encoding: options };
3640
+ else if (options === null || typeof options !== 'object')
3641
+ throw new TypeError('"options" argument must be a string or an object');
3642
+ else
3643
+ options = Object.create(options);
3644
+
3645
+ // A little bit bigger buffer and water marks by default
3646
+ if (options.highWaterMark === undefined)
3647
+ options.highWaterMark = 64 * 1024;
3648
+
3649
+ // For backwards compat do not emit close on destroy.
3650
+ options.emitClose = false;
3651
+ options.autoDestroy = false; // Node 14 major change.
3652
+
3653
+ ReadableStream.call(this, options);
3654
+
3655
+ this.path = path;
3656
+ this.flags = options.flags === undefined ? 'r' : options.flags;
3657
+ this.mode = options.mode === undefined ? 0o666 : options.mode;
3658
+
3659
+ this.start = options.start;
3660
+ this.end = options.end;
3661
+ this.autoClose = options.autoClose === undefined ? true : options.autoClose;
3662
+ this.pos = 0;
3663
+ this.bytesRead = 0;
3664
+ this.isClosed = false;
3665
+
3666
+ this.handle = options.handle === undefined ? null : options.handle;
3667
+ this.sftp = sftp;
3668
+ this._opening = false;
3669
+
3670
+ if (this.start !== undefined) {
3671
+ checkPosition(this.start, 'start');
3672
+
3673
+ this.pos = this.start;
3674
+ }
3675
+
3676
+ if (this.end === undefined) {
3677
+ this.end = Infinity;
3678
+ } else if (this.end !== Infinity) {
3679
+ checkPosition(this.end, 'end');
3680
+
3681
+ if (this.start !== undefined && this.start > this.end) {
3682
+ throw new ERR_OUT_OF_RANGE(
3683
+ 'start',
3684
+ `<= "end" (here: ${this.end})`,
3685
+ this.start
3686
+ );
3687
+ }
3688
+ }
3689
+
3690
+ this.on('end', function() {
3691
+ if (this.autoClose)
3692
+ this.destroy();
3693
+ });
3694
+
3695
+ if (!Buffer.isBuffer(this.handle))
3696
+ this.open();
3697
+ }
3698
+ inherits(ReadStream, ReadableStream);
3699
+
3700
+ ReadStream.prototype.open = function() {
3701
+ if (this._opening)
3702
+ return;
3703
+
3704
+ this._opening = true;
3705
+
3706
+ this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {
3707
+ this._opening = false;
3708
+
3709
+ if (er) {
3710
+ this.emit('error', er);
3711
+ if (this.autoClose)
3712
+ this.destroy();
3713
+ return;
3714
+ }
3715
+
3716
+ this.handle = handle;
3717
+ this.emit('open', handle);
3718
+ this.emit('ready');
3719
+ // Start the flow of data.
3720
+ this.read();
3721
+ });
3722
+ };
3723
+
3724
+ ReadStream.prototype._read = function(n) {
3725
+ if (!Buffer.isBuffer(this.handle))
3726
+ return this.once('open', () => this._read(n));
3727
+
3728
+ // XXX: safe to remove this?
3729
+ if (this.destroyed)
3730
+ return;
3731
+
3732
+ if (!pool || pool.length - pool.used < kMinPoolSpace) {
3733
+ // Discard the old pool.
3734
+ allocNewPool(this.readableHighWaterMark
3735
+ || this._readableState.highWaterMark);
3736
+ }
3737
+
3738
+ // Grab another reference to the pool in the case that while we're
3739
+ // in the thread pool another read() finishes up the pool, and
3740
+ // allocates a new one.
3741
+ const thisPool = pool;
3742
+ let toRead = Math.min(pool.length - pool.used, n);
3743
+ const start = pool.used;
3744
+
3745
+ if (this.end !== undefined)
3746
+ toRead = Math.min(this.end - this.pos + 1, toRead);
3747
+
3748
+ // Already read everything we were supposed to read!
3749
+ // treat as EOF.
3750
+ if (toRead <= 0)
3751
+ return this.push(null);
3752
+
3753
+ // the actual read.
3754
+ this.sftp.read(this.handle,
3755
+ pool,
3756
+ pool.used,
3757
+ toRead,
3758
+ this.pos,
3759
+ (er, bytesRead) => {
3760
+ if (er) {
3761
+ this.emit('error', er);
3762
+ if (this.autoClose)
3763
+ this.destroy();
3764
+ return;
3765
+ }
3766
+ let b = null;
3767
+
3768
+ // Now that we know how much data we have actually read, re-wind the
3769
+ // 'used' field if we can, and otherwise allow the remainder of our
3770
+ // reservation to be used as a new pool later.
3771
+ if (start + toRead === thisPool.used && thisPool === pool) {
3772
+ thisPool.used = roundUpToMultipleOf8(thisPool.used + bytesRead - toRead);
3773
+ } else {
3774
+ // Round down to the next lowest multiple of 8 to ensure the new pool
3775
+ // fragment start and end positions are aligned to an 8 byte boundary.
3776
+ const alignedEnd = (start + toRead) & ~7;
3777
+ const alignedStart = roundUpToMultipleOf8(start + bytesRead);
3778
+ if (alignedEnd - alignedStart >= kMinPoolSpace)
3779
+ poolFragments.push(thisPool.slice(alignedStart, alignedEnd));
3780
+ }
3781
+
3782
+ if (bytesRead > 0) {
3783
+ this.bytesRead += bytesRead;
3784
+ b = thisPool.slice(start, start + bytesRead);
3785
+ }
3786
+
3787
+ // Move the pool positions, and internal position for reading.
3788
+ this.pos += bytesRead;
3789
+
3790
+ this.push(b);
3791
+ });
3792
+
3793
+ pool.used = roundUpToMultipleOf8(pool.used + toRead);
3794
+ };
3795
+
3796
+ ReadStream.prototype._destroy = function(err, cb) {
3797
+ if (this._opening && !Buffer.isBuffer(this.handle)) {
3798
+ this.once('open', closeStream.bind(null, this, cb, err));
3799
+ return;
3800
+ }
3801
+
3802
+ closeStream(this, cb, err);
3803
+ this.handle = null;
3804
+ this._opening = false;
3805
+ };
3806
+
3807
+ function closeStream(stream, cb, err) {
3808
+ if (!stream.handle)
3809
+ return onclose();
3810
+
3811
+ stream.sftp.close(stream.handle, onclose);
3812
+
3813
+ function onclose(er) {
3814
+ er = er || err;
3815
+ cb(er);
3816
+ stream.isClosed = true;
3817
+ if (!er)
3818
+ stream.emit('close');
3819
+ }
3820
+ }
3821
+
3822
+ ReadStream.prototype.close = function(cb) {
3823
+ this.destroy(null, cb);
3824
+ };
3825
+
3826
+ Object.defineProperty(ReadStream.prototype, 'pending', {
3827
+ get() {
3828
+ return this.handle === null;
3829
+ },
3830
+ configurable: true
3831
+ });
3832
+
3833
+ // TODO: add `concurrency` setting to allow more than one in-flight WRITE
3834
+ // request to server to improve throughput
3835
+ function WriteStream(sftp, path, options) {
3836
+ if (options === undefined)
3837
+ options = {};
3838
+ else if (typeof options === 'string')
3839
+ options = { encoding: options };
3840
+ else if (options === null || typeof options !== 'object')
3841
+ throw new TypeError('"options" argument must be a string or an object');
3842
+ else
3843
+ options = Object.create(options);
3844
+
3845
+ // For backwards compat do not emit close on destroy.
3846
+ options.emitClose = false;
3847
+ options.autoDestroy = false; // Node 14 major change.
3848
+
3849
+ WritableStream.call(this, options);
3850
+
3851
+ this.path = path;
3852
+ this.flags = options.flags === undefined ? 'w' : options.flags;
3853
+ this.mode = options.mode === undefined ? 0o666 : options.mode;
3854
+
3855
+ this.start = options.start;
3856
+ this.autoClose = options.autoClose === undefined ? true : options.autoClose;
3857
+ this.pos = 0;
3858
+ this.bytesWritten = 0;
3859
+ this.isClosed = false;
3860
+
3861
+ this.handle = options.handle === undefined ? null : options.handle;
3862
+ this.sftp = sftp;
3863
+ this._opening = false;
3864
+
3865
+ if (this.start !== undefined) {
3866
+ checkPosition(this.start, 'start');
3867
+
3868
+ this.pos = this.start;
3869
+ }
3870
+
3871
+ if (options.encoding)
3872
+ this.setDefaultEncoding(options.encoding);
3873
+
3874
+ // Node v6.x only
3875
+ this.on('finish', function() {
3876
+ if (this._writableState.finalCalled)
3877
+ return;
3878
+ if (this.autoClose)
3879
+ this.destroy();
3880
+ });
3881
+
3882
+ if (!Buffer.isBuffer(this.handle))
3883
+ this.open();
3884
+ }
3885
+ inherits(WriteStream, WritableStream);
3886
+
3887
+ WriteStream.prototype._final = function(cb) {
3888
+ if (this.autoClose)
3889
+ this.destroy();
3890
+ cb();
3891
+ };
3892
+
3893
+ WriteStream.prototype.open = function() {
3894
+ if (this._opening)
3895
+ return;
3896
+
3897
+ this._opening = true;
3898
+
3899
+ this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {
3900
+ this._opening = false;
3901
+
3902
+ if (er) {
3903
+ this.emit('error', er);
3904
+ if (this.autoClose)
3905
+ this.destroy();
3906
+ return;
3907
+ }
3908
+
3909
+ this.handle = handle;
3910
+
3911
+ const tryAgain = (err) => {
3912
+ if (err) {
3913
+ // Try chmod() for sftp servers that may not support fchmod() for
3914
+ // whatever reason
3915
+ this.sftp.chmod(this.path, this.mode, (err_) => tryAgain());
3916
+ return;
3917
+ }
3918
+
3919
+ // SFTPv3 requires absolute offsets, no matter the open flag used
3920
+ if (this.flags[0] === 'a') {
3921
+ const tryStat = (err, st) => {
3922
+ if (err) {
3923
+ // Try stat() for sftp servers that may not support fstat() for
3924
+ // whatever reason
3925
+ this.sftp.stat(this.path, (err_, st_) => {
3926
+ if (err_) {
3927
+ this.destroy();
3928
+ this.emit('error', err);
3929
+ return;
3930
+ }
3931
+ tryStat(null, st_);
3932
+ });
3933
+ return;
3934
+ }
3935
+
3936
+ this.pos = st.size;
3937
+ this.emit('open', handle);
3938
+ this.emit('ready');
3939
+ };
3940
+
3941
+ this.sftp.fstat(handle, tryStat);
3942
+ return;
3943
+ }
3944
+
3945
+ this.emit('open', handle);
3946
+ this.emit('ready');
3947
+ };
3948
+
3949
+ this.sftp.fchmod(handle, this.mode, tryAgain);
3950
+ });
3951
+ };
3952
+
3953
+ WriteStream.prototype._write = function(data, encoding, cb) {
3954
+ if (!Buffer.isBuffer(data)) {
3955
+ const err = new ERR_INVALID_ARG_TYPE('data', 'Buffer', data);
3956
+ return this.emit('error', err);
3957
+ }
3958
+
3959
+ if (!Buffer.isBuffer(this.handle)) {
3960
+ return this.once('open', function() {
3961
+ this._write(data, encoding, cb);
3962
+ });
3963
+ }
3964
+
3965
+ this.sftp.write(this.handle,
3966
+ data,
3967
+ 0,
3968
+ data.length,
3969
+ this.pos,
3970
+ (er, bytes) => {
3971
+ if (er) {
3972
+ if (this.autoClose)
3973
+ this.destroy();
3974
+ return cb(er);
3975
+ }
3976
+ this.bytesWritten += bytes;
3977
+ cb();
3978
+ });
3979
+
3980
+ this.pos += data.length;
3981
+ };
3982
+
3983
+ WriteStream.prototype._writev = function(data, cb) {
3984
+ if (!Buffer.isBuffer(this.handle)) {
3985
+ return this.once('open', function() {
3986
+ this._writev(data, cb);
3987
+ });
3988
+ }
3989
+
3990
+ const sftp = this.sftp;
3991
+ const handle = this.handle;
3992
+ let writesLeft = data.length;
3993
+
3994
+ const onwrite = (er, bytes) => {
3995
+ if (er) {
3996
+ this.destroy();
3997
+ return cb(er);
3998
+ }
3999
+ this.bytesWritten += bytes;
4000
+ if (--writesLeft === 0)
4001
+ cb();
4002
+ };
4003
+
4004
+ // TODO: try to combine chunks to reduce number of requests to the server?
4005
+ for (let i = 0; i < data.length; ++i) {
4006
+ const chunk = data[i].chunk;
4007
+
4008
+ sftp.write(handle, chunk, 0, chunk.length, this.pos, onwrite);
4009
+ this.pos += chunk.length;
4010
+ }
4011
+ };
4012
+
4013
+ if (typeof WritableStream.prototype.destroy !== 'function')
4014
+ WriteStream.prototype.destroy = ReadStream.prototype.destroy;
4015
+
4016
+ WriteStream.prototype._destroy = ReadStream.prototype._destroy;
4017
+ WriteStream.prototype.close = function(cb) {
4018
+ if (cb) {
4019
+ if (this.isClosed) {
4020
+ process.nextTick(cb);
4021
+ return;
4022
+ }
4023
+ this.on('close', cb);
4024
+ }
4025
+
4026
+ // If we are not autoClosing, we should call
4027
+ // destroy on 'finish'.
4028
+ if (!this.autoClose)
4029
+ this.on('finish', this.destroy.bind(this));
4030
+
4031
+ this.end();
4032
+ };
4033
+
4034
+ // There is no shutdown() for files.
4035
+ WriteStream.prototype.destroySoon = WriteStream.prototype.end;
4036
+
4037
+ Object.defineProperty(WriteStream.prototype, 'pending', {
4038
+ get() {
4039
+ return this.handle === null;
4040
+ },
4041
+ configurable: true
4042
+ });
4043
+ // =============================================================================
4044
+
4045
+ module.exports = {
4046
+ flagsToString,
4047
+ OPEN_MODE,
4048
+ SFTP,
4049
+ Stats,
4050
+ STATUS_CODE,
4051
+ stringToFlags,
4052
+ };