@vandenberghinc/volt 1.2.5 → 1.2.6

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 (489) hide show
  1. package/frontend/assets/admin/admin.png +0 -0
  2. package/frontend/assets/admin/password.webp +0 -0
  3. package/frontend/assets/icons/arrow.v1.webp +0 -0
  4. package/frontend/assets/icons/copy.webp +0 -0
  5. package/frontend/assets/payments/arrow.long.webp +0 -0
  6. package/frontend/assets/payments/arrow.long2.webp +0 -0
  7. package/frontend/assets/payments/cancelled.webp +0 -0
  8. package/frontend/assets/payments/check.sign.webp +0 -0
  9. package/frontend/assets/payments/check.webp +0 -0
  10. package/frontend/assets/payments/close.webp +0 -0
  11. package/frontend/assets/payments/error.webp +0 -0
  12. package/frontend/assets/payments/exclamation.webp +0 -0
  13. package/frontend/assets/payments/minus.webp +0 -0
  14. package/frontend/assets/payments/party.webp +0 -0
  15. package/frontend/assets/payments/plus.webp +0 -0
  16. package/frontend/assets/payments/shopping_cart.webp +0 -0
  17. package/frontend/assets/payments/trash.webp +0 -0
  18. package/package.json +5 -1
  19. package/.libris/config.json +0 -82
  20. package/backend/dist/cjs/backend/src/blacklist.d.ts +0 -12
  21. package/backend/dist/cjs/backend/src/blacklist.js +0 -78
  22. package/backend/dist/cjs/backend/src/cli.d.ts +0 -2
  23. package/backend/dist/cjs/backend/src/cli.js +0 -198
  24. package/backend/dist/cjs/backend/src/database/collection.d.ts +0 -1765
  25. package/backend/dist/cjs/backend/src/database/collection.js +0 -3301
  26. package/backend/dist/cjs/backend/src/database/database.d.ts +0 -92
  27. package/backend/dist/cjs/backend/src/database/database.js +0 -170
  28. package/backend/dist/cjs/backend/src/database/document.d.ts +0 -1
  29. package/backend/dist/cjs/backend/src/database/document.js +0 -15
  30. package/backend/dist/cjs/backend/src/database/filters/filters.d.ts +0 -6
  31. package/backend/dist/cjs/backend/src/database/filters/filters.js +0 -15
  32. package/backend/dist/cjs/backend/src/database/filters/strict_filter.d.ts +0 -223
  33. package/backend/dist/cjs/backend/src/database/filters/strict_filter.js +0 -15
  34. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.d.ts +0 -1
  35. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.js +0 -443
  36. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.d.ts +0 -1
  37. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.js +0 -15
  38. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.d.ts +0 -50
  39. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.js +0 -15
  40. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.d.ts +0 -76
  41. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.js +0 -15
  42. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.d.ts +0 -75
  43. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.js +0 -15
  44. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.d.ts +0 -219
  45. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.js +0 -15
  46. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.d.ts +0 -165
  47. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.js +0 -15
  48. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.d.ts +0 -5
  49. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.js +0 -355
  50. package/backend/dist/cjs/backend/src/database/flatten.d.ts +0 -78
  51. package/backend/dist/cjs/backend/src/database/flatten.js +0 -53
  52. package/backend/dist/cjs/backend/src/database/flatten_test.d.ts +0 -1
  53. package/backend/dist/cjs/backend/src/database/flatten_test.js +0 -175
  54. package/backend/dist/cjs/backend/src/database/quota/quoata_v2.d.ts +0 -533
  55. package/backend/dist/cjs/backend/src/database/quota/quoata_v2.js +0 -1046
  56. package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +0 -551
  57. package/backend/dist/cjs/backend/src/database/quota/quota.js +0 -1108
  58. package/backend/dist/cjs/backend/src/database/quota/quota_v1.d.ts +0 -534
  59. package/backend/dist/cjs/backend/src/database/quota/quota_v1.js +0 -1087
  60. package/backend/dist/cjs/backend/src/database/quota/safe_int.d.ts +0 -412
  61. package/backend/dist/cjs/backend/src/database/quota/safe_int.js +0 -745
  62. package/backend/dist/cjs/backend/src/endpoint.d.ts +0 -346
  63. package/backend/dist/cjs/backend/src/endpoint.js +0 -468
  64. package/backend/dist/cjs/backend/src/errors/index.d.ts +0 -7
  65. package/backend/dist/cjs/backend/src/errors/index.js +0 -25
  66. package/backend/dist/cjs/backend/src/errors/internal_external.d.ts +0 -52
  67. package/backend/dist/cjs/backend/src/errors/internal_external.js +0 -95
  68. package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +0 -41
  69. package/backend/dist/cjs/backend/src/errors/invalid_usage_error.js +0 -47
  70. package/backend/dist/cjs/backend/src/errors/system_error.d.ts +0 -261
  71. package/backend/dist/cjs/backend/src/errors/system_error.js +0 -436
  72. package/backend/dist/cjs/backend/src/events.d.ts +0 -97
  73. package/backend/dist/cjs/backend/src/events.js +0 -15
  74. package/backend/dist/cjs/backend/src/frontend.d.ts +0 -11
  75. package/backend/dist/cjs/backend/src/frontend.js +0 -37
  76. package/backend/dist/cjs/backend/src/image_endpoint.d.ts +0 -44
  77. package/backend/dist/cjs/backend/src/image_endpoint.js +0 -185
  78. package/backend/dist/cjs/backend/src/index.d.ts +0 -23
  79. package/backend/dist/cjs/backend/src/index.js +0 -70
  80. package/backend/dist/cjs/backend/src/logger.d.ts +0 -5
  81. package/backend/dist/cjs/backend/src/logger.js +0 -15
  82. package/backend/dist/cjs/backend/src/meta.d.ts +0 -112
  83. package/backend/dist/cjs/backend/src/meta.js +0 -181
  84. package/backend/dist/cjs/backend/src/payments/paddle.d.ts +0 -329
  85. package/backend/dist/cjs/backend/src/payments/paddle.js +0 -1996
  86. package/backend/dist/cjs/backend/src/payments/stripe/checkout.d.ts +0 -113
  87. package/backend/dist/cjs/backend/src/payments/stripe/checkout.js +0 -295
  88. package/backend/dist/cjs/backend/src/payments/stripe/customers.d.ts +0 -17
  89. package/backend/dist/cjs/backend/src/payments/stripe/customers.js +0 -164
  90. package/backend/dist/cjs/backend/src/payments/stripe/error.d.ts +0 -74
  91. package/backend/dist/cjs/backend/src/payments/stripe/error.js +0 -64
  92. package/backend/dist/cjs/backend/src/payments/stripe/events.d.ts +0 -155
  93. package/backend/dist/cjs/backend/src/payments/stripe/events.js +0 -15
  94. package/backend/dist/cjs/backend/src/payments/stripe/meters.d.ts +0 -105
  95. package/backend/dist/cjs/backend/src/payments/stripe/meters.js +0 -230
  96. package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.d.ts +0 -58
  97. package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.js +0 -109
  98. package/backend/dist/cjs/backend/src/payments/stripe/products.d.ts +0 -519
  99. package/backend/dist/cjs/backend/src/payments/stripe/products.js +0 -650
  100. package/backend/dist/cjs/backend/src/payments/stripe/stripe.d.ts +0 -215
  101. package/backend/dist/cjs/backend/src/payments/stripe/stripe.js +0 -468
  102. package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.d.ts +0 -172
  103. package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.js +0 -557
  104. package/backend/dist/cjs/backend/src/payments/stripe/utils.d.ts +0 -63
  105. package/backend/dist/cjs/backend/src/payments/stripe/utils.js +0 -118
  106. package/backend/dist/cjs/backend/src/payments/stripe/webhooks.d.ts +0 -105
  107. package/backend/dist/cjs/backend/src/payments/stripe/webhooks.js +0 -627
  108. package/backend/dist/cjs/backend/src/plugins/browser.d.ts +0 -1
  109. package/backend/dist/cjs/backend/src/plugins/browser.js +0 -15
  110. package/backend/dist/cjs/backend/src/plugins/communication.d.ts +0 -70
  111. package/backend/dist/cjs/backend/src/plugins/communication.js +0 -196
  112. package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +0 -255
  113. package/backend/dist/cjs/backend/src/plugins/mail/mail.js +0 -381
  114. package/backend/dist/cjs/backend/src/plugins/mail/ui.d.ts +0 -297
  115. package/backend/dist/cjs/backend/src/plugins/mail/ui.js +0 -1370
  116. package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +0 -1
  117. package/backend/dist/cjs/backend/src/plugins/pdf.js +0 -1456
  118. package/backend/dist/cjs/backend/src/plugins/thread_monitor.d.ts +0 -18
  119. package/backend/dist/cjs/backend/src/plugins/thread_monitor.js +0 -116
  120. package/backend/dist/cjs/backend/src/rate_limit.d.ts +0 -148
  121. package/backend/dist/cjs/backend/src/rate_limit.js +0 -543
  122. package/backend/dist/cjs/backend/src/route.d.ts +0 -39
  123. package/backend/dist/cjs/backend/src/route.js +0 -172
  124. package/backend/dist/cjs/backend/src/server.d.ts +0 -502
  125. package/backend/dist/cjs/backend/src/server.js +0 -1713
  126. package/backend/dist/cjs/backend/src/server.old.d.ts +0 -594
  127. package/backend/dist/cjs/backend/src/server.old.js +0 -2058
  128. package/backend/dist/cjs/backend/src/splash_screen.d.ts +0 -93
  129. package/backend/dist/cjs/backend/src/splash_screen.js +0 -119
  130. package/backend/dist/cjs/backend/src/status.d.ts +0 -89
  131. package/backend/dist/cjs/backend/src/status.js +0 -211
  132. package/backend/dist/cjs/backend/src/stream.d.ts +0 -494
  133. package/backend/dist/cjs/backend/src/stream.js +0 -1370
  134. package/backend/dist/cjs/backend/src/users.d.ts +0 -926
  135. package/backend/dist/cjs/backend/src/users.js +0 -2223
  136. package/backend/dist/cjs/backend/src/utils.d.ts +0 -22
  137. package/backend/dist/cjs/backend/src/utils.js +0 -626
  138. package/backend/dist/cjs/backend/src/view.d.ts +0 -115
  139. package/backend/dist/cjs/backend/src/view.js +0 -519
  140. package/backend/dist/cjs/backend/src/vinc.d.ts +0 -6
  141. package/backend/dist/cjs/backend/src/vinc.js +0 -40
  142. package/backend/dist/cjs/backend/src/volt.d.ts +0 -24
  143. package/backend/dist/cjs/backend/src/volt.js +0 -72
  144. package/backend/dist/cjs/frontend/src/modules/request.d.ts +0 -70
  145. package/backend/dist/cjs/frontend/src/modules/request.js +0 -99
  146. package/backend/dist/cjs/package.json +0 -1
  147. package/backend/dist/esm/backend/src/blacklist.d.ts +0 -12
  148. package/backend/dist/esm/backend/src/blacklist.js +0 -52
  149. package/backend/dist/esm/backend/src/cli.d.ts +0 -2
  150. package/backend/dist/esm/backend/src/cli.js +0 -211
  151. package/backend/dist/esm/backend/src/database/collection.d.ts +0 -1765
  152. package/backend/dist/esm/backend/src/database/collection.js +0 -3779
  153. package/backend/dist/esm/backend/src/database/database.d.ts +0 -92
  154. package/backend/dist/esm/backend/src/database/database.js +0 -214
  155. package/backend/dist/esm/backend/src/database/document.d.ts +0 -1
  156. package/backend/dist/esm/backend/src/database/document.js +0 -558
  157. package/backend/dist/esm/backend/src/database/filters/filters.d.ts +0 -6
  158. package/backend/dist/esm/backend/src/database/filters/filters.js +0 -1
  159. package/backend/dist/esm/backend/src/database/filters/strict_filter.d.ts +0 -223
  160. package/backend/dist/esm/backend/src/database/filters/strict_filter.js +0 -3
  161. package/backend/dist/esm/backend/src/database/filters/strict_filter_test.d.ts +0 -1
  162. package/backend/dist/esm/backend/src/database/filters/strict_filter_test.js +0 -505
  163. package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.d.ts +0 -1
  164. package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.js +0 -712
  165. package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.d.ts +0 -50
  166. package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.js +0 -5
  167. package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.d.ts +0 -76
  168. package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.js +0 -44
  169. package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.d.ts +0 -75
  170. package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.js +0 -5
  171. package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.d.ts +0 -219
  172. package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.js +0 -1
  173. package/backend/dist/esm/backend/src/database/filters/strict_update_filter.d.ts +0 -165
  174. package/backend/dist/esm/backend/src/database/filters/strict_update_filter.js +0 -5
  175. package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.d.ts +0 -5
  176. package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.js +0 -415
  177. package/backend/dist/esm/backend/src/database/flatten.d.ts +0 -78
  178. package/backend/dist/esm/backend/src/database/flatten.js +0 -22
  179. package/backend/dist/esm/backend/src/database/flatten_test.d.ts +0 -1
  180. package/backend/dist/esm/backend/src/database/flatten_test.js +0 -174
  181. package/backend/dist/esm/backend/src/database/quota/quoata_v2.d.ts +0 -533
  182. package/backend/dist/esm/backend/src/database/quota/quoata_v2.js +0 -1155
  183. package/backend/dist/esm/backend/src/database/quota/quota.d.ts +0 -551
  184. package/backend/dist/esm/backend/src/database/quota/quota.js +0 -1219
  185. package/backend/dist/esm/backend/src/database/quota/quota_v1.d.ts +0 -534
  186. package/backend/dist/esm/backend/src/database/quota/quota_v1.js +0 -1242
  187. package/backend/dist/esm/backend/src/database/quota/safe_int.d.ts +0 -412
  188. package/backend/dist/esm/backend/src/database/quota/safe_int.js +0 -810
  189. package/backend/dist/esm/backend/src/endpoint.d.ts +0 -346
  190. package/backend/dist/esm/backend/src/endpoint.js +0 -479
  191. package/backend/dist/esm/backend/src/errors/index.d.ts +0 -7
  192. package/backend/dist/esm/backend/src/errors/index.js +0 -7
  193. package/backend/dist/esm/backend/src/errors/internal_external.d.ts +0 -52
  194. package/backend/dist/esm/backend/src/errors/internal_external.js +0 -86
  195. package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +0 -41
  196. package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +0 -33
  197. package/backend/dist/esm/backend/src/errors/system_error.d.ts +0 -261
  198. package/backend/dist/esm/backend/src/errors/system_error.js +0 -444
  199. package/backend/dist/esm/backend/src/events.d.ts +0 -97
  200. package/backend/dist/esm/backend/src/events.js +0 -5
  201. package/backend/dist/esm/backend/src/frontend.d.ts +0 -11
  202. package/backend/dist/esm/backend/src/frontend.js +0 -12
  203. package/backend/dist/esm/backend/src/image_endpoint.d.ts +0 -44
  204. package/backend/dist/esm/backend/src/image_endpoint.js +0 -196
  205. package/backend/dist/esm/backend/src/index.d.ts +0 -23
  206. package/backend/dist/esm/backend/src/index.js +0 -26
  207. package/backend/dist/esm/backend/src/logger.d.ts +0 -5
  208. package/backend/dist/esm/backend/src/logger.js +0 -8
  209. package/backend/dist/esm/backend/src/meta.d.ts +0 -112
  210. package/backend/dist/esm/backend/src/meta.js +0 -152
  211. package/backend/dist/esm/backend/src/payments/paddle.d.ts +0 -329
  212. package/backend/dist/esm/backend/src/payments/paddle.js +0 -2276
  213. package/backend/dist/esm/backend/src/payments/stripe/checkout.d.ts +0 -113
  214. package/backend/dist/esm/backend/src/payments/stripe/checkout.js +0 -356
  215. package/backend/dist/esm/backend/src/payments/stripe/customers.d.ts +0 -17
  216. package/backend/dist/esm/backend/src/payments/stripe/customers.js +0 -193
  217. package/backend/dist/esm/backend/src/payments/stripe/error.d.ts +0 -74
  218. package/backend/dist/esm/backend/src/payments/stripe/error.js +0 -51
  219. package/backend/dist/esm/backend/src/payments/stripe/events.d.ts +0 -155
  220. package/backend/dist/esm/backend/src/payments/stripe/events.js +0 -5
  221. package/backend/dist/esm/backend/src/payments/stripe/meters.d.ts +0 -105
  222. package/backend/dist/esm/backend/src/payments/stripe/meters.js +0 -318
  223. package/backend/dist/esm/backend/src/payments/stripe/payment_methods.d.ts +0 -58
  224. package/backend/dist/esm/backend/src/payments/stripe/payment_methods.js +0 -135
  225. package/backend/dist/esm/backend/src/payments/stripe/products.d.ts +0 -519
  226. package/backend/dist/esm/backend/src/payments/stripe/products.js +0 -896
  227. package/backend/dist/esm/backend/src/payments/stripe/stripe.d.ts +0 -215
  228. package/backend/dist/esm/backend/src/payments/stripe/stripe.js +0 -464
  229. package/backend/dist/esm/backend/src/payments/stripe/subscriptions.d.ts +0 -172
  230. package/backend/dist/esm/backend/src/payments/stripe/subscriptions.js +0 -754
  231. package/backend/dist/esm/backend/src/payments/stripe/utils.d.ts +0 -63
  232. package/backend/dist/esm/backend/src/payments/stripe/utils.js +0 -131
  233. package/backend/dist/esm/backend/src/payments/stripe/webhooks.d.ts +0 -105
  234. package/backend/dist/esm/backend/src/payments/stripe/webhooks.js +0 -752
  235. package/backend/dist/esm/backend/src/plugins/browser.d.ts +0 -1
  236. package/backend/dist/esm/backend/src/plugins/browser.js +0 -170
  237. package/backend/dist/esm/backend/src/plugins/communication.d.ts +0 -70
  238. package/backend/dist/esm/backend/src/plugins/communication.js +0 -169
  239. package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +0 -255
  240. package/backend/dist/esm/backend/src/plugins/mail/mail.js +0 -396
  241. package/backend/dist/esm/backend/src/plugins/mail/ui.d.ts +0 -297
  242. package/backend/dist/esm/backend/src/plugins/mail/ui.js +0 -1400
  243. package/backend/dist/esm/backend/src/plugins/pdf.d.ts +0 -1
  244. package/backend/dist/esm/backend/src/plugins/pdf.js +0 -1694
  245. package/backend/dist/esm/backend/src/plugins/thread_monitor.d.ts +0 -18
  246. package/backend/dist/esm/backend/src/plugins/thread_monitor.js +0 -120
  247. package/backend/dist/esm/backend/src/rate_limit.d.ts +0 -148
  248. package/backend/dist/esm/backend/src/rate_limit.js +0 -667
  249. package/backend/dist/esm/backend/src/route.d.ts +0 -39
  250. package/backend/dist/esm/backend/src/route.js +0 -222
  251. package/backend/dist/esm/backend/src/server.d.ts +0 -502
  252. package/backend/dist/esm/backend/src/server.js +0 -2034
  253. package/backend/dist/esm/backend/src/server.old.d.ts +0 -594
  254. package/backend/dist/esm/backend/src/server.old.js +0 -2630
  255. package/backend/dist/esm/backend/src/splash_screen.d.ts +0 -93
  256. package/backend/dist/esm/backend/src/splash_screen.js +0 -156
  257. package/backend/dist/esm/backend/src/status.d.ts +0 -89
  258. package/backend/dist/esm/backend/src/status.js +0 -213
  259. package/backend/dist/esm/backend/src/stream.d.ts +0 -494
  260. package/backend/dist/esm/backend/src/stream.js +0 -1611
  261. package/backend/dist/esm/backend/src/users.d.ts +0 -926
  262. package/backend/dist/esm/backend/src/users.js +0 -2423
  263. package/backend/dist/esm/backend/src/utils.d.ts +0 -22
  264. package/backend/dist/esm/backend/src/utils.js +0 -463
  265. package/backend/dist/esm/backend/src/view.d.ts +0 -115
  266. package/backend/dist/esm/backend/src/view.js +0 -584
  267. package/backend/dist/esm/backend/src/vinc.d.ts +0 -6
  268. package/backend/dist/esm/backend/src/vinc.js +0 -6
  269. package/backend/dist/esm/backend/src/volt.d.ts +0 -24
  270. package/backend/dist/esm/backend/src/volt.js +0 -27
  271. package/backend/dist/esm/frontend/src/modules/request.d.ts +0 -70
  272. package/backend/dist/esm/frontend/src/modules/request.js +0 -117
  273. package/backend/old/file_watcher.ts +0 -359
  274. package/backend/old/request.deprc.js +0 -626
  275. package/backend/old/response.deprc.js +0 -354
  276. package/frontend/dist/backend/src/database/collection.d.ts +0 -1765
  277. package/frontend/dist/backend/src/database/collection.js +0 -3779
  278. package/frontend/dist/backend/src/database/database.d.ts +0 -92
  279. package/frontend/dist/backend/src/database/database.js +0 -214
  280. package/frontend/dist/backend/src/database/filters/filters.d.ts +0 -6
  281. package/frontend/dist/backend/src/database/filters/filters.js +0 -1
  282. package/frontend/dist/backend/src/database/filters/strict_filter.d.ts +0 -223
  283. package/frontend/dist/backend/src/database/filters/strict_filter.js +0 -3
  284. package/frontend/dist/backend/src/database/filters/strict_update_filter.d.ts +0 -165
  285. package/frontend/dist/backend/src/database/filters/strict_update_filter.js +0 -5
  286. package/frontend/dist/backend/src/database/flatten.d.ts +0 -78
  287. package/frontend/dist/backend/src/database/flatten.js +0 -22
  288. package/frontend/dist/backend/src/endpoint.d.ts +0 -346
  289. package/frontend/dist/backend/src/endpoint.js +0 -479
  290. package/frontend/dist/backend/src/errors/index.d.ts +0 -7
  291. package/frontend/dist/backend/src/errors/index.js +0 -7
  292. package/frontend/dist/backend/src/errors/internal_external.d.ts +0 -52
  293. package/frontend/dist/backend/src/errors/internal_external.js +0 -86
  294. package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +0 -41
  295. package/frontend/dist/backend/src/errors/invalid_usage_error.js +0 -33
  296. package/frontend/dist/backend/src/errors/system_error.d.ts +0 -261
  297. package/frontend/dist/backend/src/errors/system_error.js +0 -444
  298. package/frontend/dist/backend/src/events.d.ts +0 -97
  299. package/frontend/dist/backend/src/events.js +0 -5
  300. package/frontend/dist/backend/src/frontend.d.ts +0 -11
  301. package/frontend/dist/backend/src/frontend.js +0 -12
  302. package/frontend/dist/backend/src/image_endpoint.d.ts +0 -44
  303. package/frontend/dist/backend/src/image_endpoint.js +0 -196
  304. package/frontend/dist/backend/src/meta.d.ts +0 -112
  305. package/frontend/dist/backend/src/meta.js +0 -152
  306. package/frontend/dist/backend/src/payments/paddle.d.ts +0 -329
  307. package/frontend/dist/backend/src/payments/paddle.js +0 -2276
  308. package/frontend/dist/backend/src/payments/stripe/checkout.d.ts +0 -113
  309. package/frontend/dist/backend/src/payments/stripe/checkout.js +0 -356
  310. package/frontend/dist/backend/src/payments/stripe/customers.d.ts +0 -17
  311. package/frontend/dist/backend/src/payments/stripe/customers.js +0 -193
  312. package/frontend/dist/backend/src/payments/stripe/error.d.ts +0 -74
  313. package/frontend/dist/backend/src/payments/stripe/error.js +0 -51
  314. package/frontend/dist/backend/src/payments/stripe/events.d.ts +0 -155
  315. package/frontend/dist/backend/src/payments/stripe/events.js +0 -5
  316. package/frontend/dist/backend/src/payments/stripe/meters.d.ts +0 -105
  317. package/frontend/dist/backend/src/payments/stripe/meters.js +0 -318
  318. package/frontend/dist/backend/src/payments/stripe/payment_methods.d.ts +0 -58
  319. package/frontend/dist/backend/src/payments/stripe/payment_methods.js +0 -135
  320. package/frontend/dist/backend/src/payments/stripe/products.d.ts +0 -519
  321. package/frontend/dist/backend/src/payments/stripe/products.js +0 -896
  322. package/frontend/dist/backend/src/payments/stripe/stripe.d.ts +0 -215
  323. package/frontend/dist/backend/src/payments/stripe/stripe.js +0 -464
  324. package/frontend/dist/backend/src/payments/stripe/subscriptions.d.ts +0 -172
  325. package/frontend/dist/backend/src/payments/stripe/subscriptions.js +0 -754
  326. package/frontend/dist/backend/src/payments/stripe/utils.d.ts +0 -63
  327. package/frontend/dist/backend/src/payments/stripe/utils.js +0 -131
  328. package/frontend/dist/backend/src/payments/stripe/webhooks.d.ts +0 -105
  329. package/frontend/dist/backend/src/payments/stripe/webhooks.js +0 -752
  330. package/frontend/dist/backend/src/plugins/mail/mail.d.ts +0 -255
  331. package/frontend/dist/backend/src/plugins/mail/mail.js +0 -396
  332. package/frontend/dist/backend/src/plugins/mail/ui.d.ts +0 -297
  333. package/frontend/dist/backend/src/plugins/mail/ui.js +0 -1400
  334. package/frontend/dist/backend/src/rate_limit.d.ts +0 -148
  335. package/frontend/dist/backend/src/rate_limit.js +0 -667
  336. package/frontend/dist/backend/src/route.d.ts +0 -39
  337. package/frontend/dist/backend/src/route.js +0 -222
  338. package/frontend/dist/backend/src/server.d.ts +0 -502
  339. package/frontend/dist/backend/src/server.js +0 -2034
  340. package/frontend/dist/backend/src/splash_screen.d.ts +0 -93
  341. package/frontend/dist/backend/src/splash_screen.js +0 -156
  342. package/frontend/dist/backend/src/status.d.ts +0 -89
  343. package/frontend/dist/backend/src/status.js +0 -213
  344. package/frontend/dist/backend/src/stream.d.ts +0 -494
  345. package/frontend/dist/backend/src/stream.js +0 -1611
  346. package/frontend/dist/backend/src/users.d.ts +0 -926
  347. package/frontend/dist/backend/src/users.js +0 -2423
  348. package/frontend/dist/backend/src/utils.d.ts +0 -22
  349. package/frontend/dist/backend/src/utils.js +0 -463
  350. package/frontend/dist/backend/src/view.d.ts +0 -115
  351. package/frontend/dist/backend/src/view.js +0 -584
  352. package/frontend/dist/frontend/src/elements/base.d.ts +0 -3743
  353. package/frontend/dist/frontend/src/elements/base.js +0 -12151
  354. package/frontend/dist/frontend/src/elements/module.d.ts +0 -95
  355. package/frontend/dist/frontend/src/elements/module.js +0 -216
  356. package/frontend/dist/frontend/src/elements/register_element.d.ts +0 -3
  357. package/frontend/dist/frontend/src/elements/register_element.js +0 -22
  358. package/frontend/dist/frontend/src/elements/resize_query_manager.d.ts +0 -0
  359. package/frontend/dist/frontend/src/elements/resize_query_manager.js +0 -150
  360. package/frontend/dist/frontend/src/elements/types.d.ts +0 -52
  361. package/frontend/dist/frontend/src/elements/types.js +0 -5
  362. package/frontend/dist/frontend/src/index.d.ts +0 -21
  363. package/frontend/dist/frontend/src/index.js +0 -29
  364. package/frontend/dist/frontend/src/modules/attachment.d.ts +0 -126
  365. package/frontend/dist/frontend/src/modules/attachment.js +0 -306
  366. package/frontend/dist/frontend/src/modules/auth.d.ts +0 -44
  367. package/frontend/dist/frontend/src/modules/auth.js +0 -80
  368. package/frontend/dist/frontend/src/modules/color.d.ts +0 -160
  369. package/frontend/dist/frontend/src/modules/color.js +0 -316
  370. package/frontend/dist/frontend/src/modules/compression.d.ts +0 -39
  371. package/frontend/dist/frontend/src/modules/compression.js +0 -102
  372. package/frontend/dist/frontend/src/modules/cookies.d.ts +0 -44
  373. package/frontend/dist/frontend/src/modules/cookies.js +0 -143
  374. package/frontend/dist/frontend/src/modules/events.d.ts +0 -31
  375. package/frontend/dist/frontend/src/modules/events.js +0 -79
  376. package/frontend/dist/frontend/src/modules/google.d.ts +0 -23
  377. package/frontend/dist/frontend/src/modules/google.js +0 -52
  378. package/frontend/dist/frontend/src/modules/meta.d.ts +0 -14
  379. package/frontend/dist/frontend/src/modules/meta.js +0 -48
  380. package/frontend/dist/frontend/src/modules/paddle.d.ts +0 -1207
  381. package/frontend/dist/frontend/src/modules/paddle.js +0 -2594
  382. package/frontend/dist/frontend/src/modules/request.d.ts +0 -70
  383. package/frontend/dist/frontend/src/modules/request.js +0 -117
  384. package/frontend/dist/frontend/src/modules/settings.d.ts +0 -3
  385. package/frontend/dist/frontend/src/modules/settings.js +0 -5
  386. package/frontend/dist/frontend/src/modules/statics.d.ts +0 -21
  387. package/frontend/dist/frontend/src/modules/statics.js +0 -43
  388. package/frontend/dist/frontend/src/modules/stripe/cart.d.ts +0 -112
  389. package/frontend/dist/frontend/src/modules/stripe/cart.js +0 -321
  390. package/frontend/dist/frontend/src/modules/stripe/checkout.d.ts +0 -7
  391. package/frontend/dist/frontend/src/modules/stripe/checkout.js +0 -37
  392. package/frontend/dist/frontend/src/modules/stripe/index.m.d.ts +0 -6
  393. package/frontend/dist/frontend/src/modules/stripe/index.m.js +0 -6
  394. package/frontend/dist/frontend/src/modules/stripe/payments.d.ts +0 -58
  395. package/frontend/dist/frontend/src/modules/stripe/payments.js +0 -92
  396. package/frontend/dist/frontend/src/modules/support.d.ts +0 -30
  397. package/frontend/dist/frontend/src/modules/support.js +0 -53
  398. package/frontend/dist/frontend/src/modules/theme.d.ts +0 -133
  399. package/frontend/dist/frontend/src/modules/theme.js +0 -406
  400. package/frontend/dist/frontend/src/modules/themes.d.ts +0 -12
  401. package/frontend/dist/frontend/src/modules/themes.js +0 -22
  402. package/frontend/dist/frontend/src/modules/user.d.ts +0 -164
  403. package/frontend/dist/frontend/src/modules/user.js +0 -270
  404. package/frontend/dist/frontend/src/modules/utils.d.ts +0 -176
  405. package/frontend/dist/frontend/src/modules/utils.js +0 -569
  406. package/frontend/dist/frontend/src/types/gradient.d.ts +0 -29
  407. package/frontend/dist/frontend/src/types/gradient.js +0 -79
  408. package/frontend/dist/frontend/src/ui/border_button.d.ts +0 -94
  409. package/frontend/dist/frontend/src/ui/border_button.js +0 -228
  410. package/frontend/dist/frontend/src/ui/button.d.ts +0 -241
  411. package/frontend/dist/frontend/src/ui/button.js +0 -682
  412. package/frontend/dist/frontend/src/ui/canvas.d.ts +0 -138
  413. package/frontend/dist/frontend/src/ui/canvas.js +0 -444
  414. package/frontend/dist/frontend/src/ui/checkbox.d.ts +0 -74
  415. package/frontend/dist/frontend/src/ui/checkbox.js +0 -321
  416. package/frontend/dist/frontend/src/ui/code.d.ts +0 -235
  417. package/frontend/dist/frontend/src/ui/code.js +0 -1007
  418. package/frontend/dist/frontend/src/ui/context_menu.d.ts +0 -36
  419. package/frontend/dist/frontend/src/ui/context_menu.js +0 -205
  420. package/frontend/dist/frontend/src/ui/css.d.ts +0 -16
  421. package/frontend/dist/frontend/src/ui/css.js +0 -48
  422. package/frontend/dist/frontend/src/ui/divider.d.ts +0 -15
  423. package/frontend/dist/frontend/src/ui/divider.js +0 -78
  424. package/frontend/dist/frontend/src/ui/dropdown.d.ts +0 -176
  425. package/frontend/dist/frontend/src/ui/dropdown.js +0 -481
  426. package/frontend/dist/frontend/src/ui/for_each.d.ts +0 -37
  427. package/frontend/dist/frontend/src/ui/for_each.js +0 -92
  428. package/frontend/dist/frontend/src/ui/form.d.ts +0 -34
  429. package/frontend/dist/frontend/src/ui/form.js +0 -233
  430. package/frontend/dist/frontend/src/ui/frame_modes.d.ts +0 -37
  431. package/frontend/dist/frontend/src/ui/frame_modes.js +0 -108
  432. package/frontend/dist/frontend/src/ui/google_map.d.ts +0 -24
  433. package/frontend/dist/frontend/src/ui/google_map.js +0 -106
  434. package/frontend/dist/frontend/src/ui/gradient.d.ts +0 -25
  435. package/frontend/dist/frontend/src/ui/gradient.js +0 -131
  436. package/frontend/dist/frontend/src/ui/image.d.ts +0 -111
  437. package/frontend/dist/frontend/src/ui/image.js +0 -576
  438. package/frontend/dist/frontend/src/ui/input.d.ts +0 -392
  439. package/frontend/dist/frontend/src/ui/input.js +0 -1201
  440. package/frontend/dist/frontend/src/ui/link.d.ts +0 -25
  441. package/frontend/dist/frontend/src/ui/link.js +0 -140
  442. package/frontend/dist/frontend/src/ui/list.d.ts +0 -37
  443. package/frontend/dist/frontend/src/ui/list.js +0 -170
  444. package/frontend/dist/frontend/src/ui/loader_button.d.ts +0 -80
  445. package/frontend/dist/frontend/src/ui/loader_button.js +0 -193
  446. package/frontend/dist/frontend/src/ui/loaders.d.ts +0 -57
  447. package/frontend/dist/frontend/src/ui/loaders.js +0 -157
  448. package/frontend/dist/frontend/src/ui/popup.d.ts +0 -94
  449. package/frontend/dist/frontend/src/ui/popup.js +0 -510
  450. package/frontend/dist/frontend/src/ui/pseudo.d.ts +0 -44
  451. package/frontend/dist/frontend/src/ui/pseudo.js +0 -154
  452. package/frontend/dist/frontend/src/ui/scroller.d.ts +0 -105
  453. package/frontend/dist/frontend/src/ui/scroller.js +0 -1253
  454. package/frontend/dist/frontend/src/ui/slider.d.ts +0 -45
  455. package/frontend/dist/frontend/src/ui/slider.js +0 -217
  456. package/frontend/dist/frontend/src/ui/spacer.d.ts +0 -15
  457. package/frontend/dist/frontend/src/ui/spacer.js +0 -78
  458. package/frontend/dist/frontend/src/ui/span.d.ts +0 -15
  459. package/frontend/dist/frontend/src/ui/span.js +0 -73
  460. package/frontend/dist/frontend/src/ui/stack.d.ts +0 -66
  461. package/frontend/dist/frontend/src/ui/stack.js +0 -335
  462. package/frontend/dist/frontend/src/ui/steps.d.ts +0 -131
  463. package/frontend/dist/frontend/src/ui/steps.js +0 -308
  464. package/frontend/dist/frontend/src/ui/style.d.ts +0 -17
  465. package/frontend/dist/frontend/src/ui/style.js +0 -73
  466. package/frontend/dist/frontend/src/ui/switch.d.ts +0 -69
  467. package/frontend/dist/frontend/src/ui/switch.js +0 -357
  468. package/frontend/dist/frontend/src/ui/table.d.ts +0 -100
  469. package/frontend/dist/frontend/src/ui/table.js +0 -405
  470. package/frontend/dist/frontend/src/ui/tabs.d.ts +0 -111
  471. package/frontend/dist/frontend/src/ui/tabs.js +0 -424
  472. package/frontend/dist/frontend/src/ui/text.d.ts +0 -15
  473. package/frontend/dist/frontend/src/ui/text.js +0 -83
  474. package/frontend/dist/frontend/src/ui/title.d.ts +0 -91
  475. package/frontend/dist/frontend/src/ui/title.js +0 -272
  476. package/frontend/dist/frontend/src/ui/ui.d.ts +0 -35
  477. package/frontend/dist/frontend/src/ui/ui.js +0 -38
  478. package/frontend/dist/frontend/src/ui/view.d.ts +0 -15
  479. package/frontend/dist/frontend/src/ui/view.js +0 -88
  480. package/frontend/dist/frontend/src/volt.d.ts +0 -20
  481. package/frontend/dist/frontend/src/volt.js +0 -27
  482. package/frontend/examples/theme/theme.ts +0 -58
  483. package/frontend/tools/bundle_d_ts.js +0 -71
  484. package/frontend/tools/convert_to_jsdoc_input.txt +0 -9452
  485. package/frontend/tools/convert_to_jsdoc_output.txt +0 -7626
  486. package/frontend/tools/convert_to_jsdoc_tmp.js +0 -345
  487. package/frontend/tools/scan_mixed_imports.js +0 -69
  488. /package/frontend/{dist/frontend/src/css → css}/adyen.css +0 -0
  489. /package/frontend/{dist/frontend/src/css → css}/volt.css +0 -0
@@ -1,1370 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var stdin_exports = {};
29
- __export(stdin_exports, {
30
- Stream: () => Stream
31
- });
32
- module.exports = __toCommonJS(stdin_exports);
33
- var vlib = __toESM(require("@vandenberghinc/vlib"));
34
- var import_node_stream = require("node:stream");
35
- var fs = __toESM(require("node:fs"));
36
- var import_node_stream2 = require("node:stream");
37
- var zlib = __toESM(require("node:zlib"));
38
- var import_rate_limit = __toESM(require("./rate_limit.js"));
39
- var import_utils = require("./utils.js");
40
- const { debug } = vlib;
41
- class Stream {
42
- /** The request headers. */
43
- headers;
44
- /** Whether this stream is an HTTP/2 stream. */
45
- http2;
46
- /** Whether this stream is an HTTP/1.1 stream (when false, it's an HTTP/2 stream). */
47
- http1;
48
- /** The status code of the sent response. */
49
- status_code;
50
- /** Whether the response has been finished. */
51
- finished;
52
- /** The received body potentially decompressed as string. */
53
- body;
54
- /** The raw body as a Buffer, potentially decompressed. */
55
- raw_body;
56
- /** The body wired exactly as is, not decompressed etc. */
57
- wire_body;
58
- /** The internal promise that resolves when the body is fully received. */
59
- promise;
60
- /** The cached value of {@link normalize_ip} */
61
- _normalized_ip;
62
- s;
63
- req;
64
- res;
65
- _ip;
66
- _port;
67
- _method;
68
- _params;
69
- _is_query_params;
70
- _endpoint;
71
- _query_string;
72
- _cookies;
73
- _uid;
74
- res_cookies;
75
- res_headers;
76
- /**
77
- * Create a new Stream wrapper for HTTP/1.1 or HTTP/2.
78
- *
79
- * @param stream The HTTP/2 stream (when using HTTP/2).
80
- * @param headers The request headers.
81
- * @param req The HTTP/1.1 request (when using HTTP/1.1).
82
- * @param res The HTTP/1.1/HTTP/2 response object.
83
- */
84
- constructor(stream, headers, req, res) {
85
- this.s = stream;
86
- this.headers = headers ?? {};
87
- this.req = req;
88
- this.res = res;
89
- this.http2 = req == null;
90
- this.http1 = req != null;
91
- if (this.http1) {
92
- this.headers = this.req.headers;
93
- }
94
- this._ip = this.http2 ? this.s.session.socket.remoteAddress : this.req.socket.remoteAddress;
95
- this._port = this.http2 ? this.s.session.socket.remotePort : this.req.socket.remotePort;
96
- this._method = this.http2 ? this.headers[":method"] : this.req.method;
97
- this._params = void 0;
98
- this._is_query_params = false;
99
- this._endpoint = void 0;
100
- this._query_string = void 0;
101
- this._cookies = void 0;
102
- this._uid = void 0;
103
- this.status_code = void 0;
104
- this.finished = false;
105
- this.res_cookies = [];
106
- this.res_headers = this.http1 ? [] : {};
107
- this.body = "";
108
- this.raw_body = Buffer.alloc(0);
109
- this.wire_body = Buffer.alloc(0);
110
- this.promise = void 0;
111
- this._recv_body();
112
- }
113
- /**
114
- * Receive and buffer the request body, handling optional gzip/deflate decompression.
115
- * Sets {@link body} and resolves the internal promise used by {@link join}.
116
- */
117
- _recv_body() {
118
- this.promise = new Promise((resolve, reject) => {
119
- const buffs = [];
120
- const wire_buffs = [];
121
- let decompress_stream;
122
- const content_encoding = this.headers["content-encoding"];
123
- if (content_encoding === "gzip") {
124
- decompress_stream = zlib.createGunzip();
125
- } else if (content_encoding === "deflate") {
126
- decompress_stream = zlib.createInflate();
127
- }
128
- const cleanup = () => {
129
- if (decompress_stream) {
130
- decompress_stream.close();
131
- }
132
- };
133
- const on_error = (e) => {
134
- cleanup();
135
- reject(e);
136
- };
137
- if (this.http2) {
138
- const source2 = this.s;
139
- source2.on("data", (chunk) => {
140
- wire_buffs.push(chunk);
141
- });
142
- let decoded2 = source2;
143
- if (decompress_stream) {
144
- decoded2 = source2.pipe(decompress_stream);
145
- }
146
- source2.on("error", on_error);
147
- decoded2.on("error", on_error);
148
- decoded2.on("data", (chunk) => {
149
- buffs.push(chunk);
150
- });
151
- decoded2.on("end", () => {
152
- try {
153
- this.wire_body = Buffer.concat(wire_buffs);
154
- this.raw_body = Buffer.concat(buffs);
155
- this.body = this.raw_body.toString("utf8");
156
- cleanup();
157
- resolve();
158
- } catch (e) {
159
- on_error(e);
160
- }
161
- });
162
- return;
163
- }
164
- const source = this.req;
165
- source.on("data", (chunk) => {
166
- wire_buffs.push(chunk);
167
- });
168
- let decoded = source;
169
- if (decompress_stream) {
170
- decoded = source.pipe(decompress_stream);
171
- }
172
- source.on("error", on_error);
173
- decoded.on("error", on_error);
174
- decoded.on("data", (chunk) => {
175
- buffs.push(chunk);
176
- });
177
- decoded.on("end", () => {
178
- try {
179
- this.wire_body = Buffer.concat(wire_buffs);
180
- this.raw_body = Buffer.concat(buffs);
181
- this.body = this.raw_body.toString("utf8");
182
- cleanup();
183
- resolve();
184
- } catch (e) {
185
- on_error(e);
186
- }
187
- });
188
- });
189
- }
190
- /**
191
- * Parse and cache the request endpoint and query string.
192
- * Populates {@link _endpoint} and {@link _query_string}.
193
- * @private
194
- */
195
- _parse_endoint() {
196
- if (this._endpoint !== void 0) {
197
- return;
198
- }
199
- this._endpoint = this.http2 ? this.headers[":path"] : this.req.url;
200
- let index;
201
- if ((index = this._endpoint.indexOf("?")) !== -1) {
202
- this._query_string = this._endpoint.substr(index + 1);
203
- this._endpoint = this._endpoint.substr(0, index);
204
- }
205
- this._endpoint = this._endpoint.replace(/\/\//g, "/");
206
- if (this._endpoint.length > 1 && this._endpoint.charAt(this._endpoint.length - 1) === "/") {
207
- this._endpoint = this._endpoint.substr(0, this._endpoint.length - 1);
208
- }
209
- }
210
- /**
211
- * Parse and cache request parameters from the query string or JSON body.
212
- * Returns the parsed params map.
213
- */
214
- _parse_params() {
215
- this._parse_endoint();
216
- if (this._params !== void 0) {
217
- return;
218
- }
219
- this._params = {};
220
- if (this._query_string !== void 0) {
221
- if (this._query_string.charAt(0) === "{") {
222
- try {
223
- this._params = JSON.parse(decodeURIComponent(this._query_string));
224
- } catch (err) {
225
- throw Error(`Invalid json request query: ${err}.`);
226
- }
227
- } else {
228
- this._is_query_params = true;
229
- let is_key = true, key = "", value = "";
230
- const number_regex = /^-?\d+(\.\d+)?$/;
231
- const add_value = () => {
232
- let output_value;
233
- switch (value) {
234
- case "true":
235
- case "True":
236
- output_value = true;
237
- break;
238
- case "false":
239
- case "False":
240
- output_value = false;
241
- break;
242
- case "null":
243
- case "None":
244
- case "undefined":
245
- output_value = null;
246
- break;
247
- default:
248
- output_value = decodeURIComponent(value.replaceAll("+", " "));
249
- if (number_regex.test(output_value)) {
250
- if (output_value.indexOf(".") !== -1) {
251
- output_value = parseFloat(output_value);
252
- } else {
253
- output_value = parseInt(output_value);
254
- }
255
- }
256
- break;
257
- }
258
- this._params[decodeURIComponent(key.replaceAll("+", " "))] = output_value;
259
- key = "";
260
- value = "";
261
- is_key = true;
262
- };
263
- for (let i = 0; i < this._query_string.length; i++) {
264
- const c = this._query_string.charAt(i);
265
- if (is_key && c === "=") {
266
- is_key = false;
267
- continue;
268
- } else if (is_key === false && c === "&") {
269
- add_value();
270
- continue;
271
- }
272
- if (is_key) {
273
- key += c;
274
- } else {
275
- value += c;
276
- }
277
- }
278
- if (key.length > 0) {
279
- add_value();
280
- }
281
- }
282
- } else if (this.body.trim().charAt(0) === "{") {
283
- try {
284
- this._params = JSON.parse(this.body);
285
- } catch (err) {
286
- throw Error(`Invalid json request body: ${err}.`);
287
- }
288
- }
289
- return this._params;
290
- }
291
- /**
292
- * Parses & returns the cookies cookies,
293
- * while assigning it to {@link _cookies}
294
- *
295
- * @warning On subsequent calls cookies will be parsed again.
296
- */
297
- _parse_cookies() {
298
- this._cookies = {};
299
- const cookie_str = this.http2 ? this.headers["cookie"] : this.req.headers.cookie;
300
- if (cookie_str == null) {
301
- return this._cookies;
302
- }
303
- let key = "";
304
- let value = "";
305
- let cookie = {};
306
- let cookie_length = 0;
307
- let cookie_key = null;
308
- let is_value = false;
309
- let is_str = null;
310
- const append_to_cookie = () => {
311
- if (key.length > 0) {
312
- if (cookie_length === 0) {
313
- cookie.value = value;
314
- } else {
315
- cookie[key] = value;
316
- }
317
- ++cookie_length;
318
- }
319
- key = "";
320
- value = "";
321
- is_value = false;
322
- is_str = null;
323
- };
324
- const append_cookie = () => {
325
- if (cookie_key != null) {
326
- this._cookies[cookie_key] = cookie;
327
- cookie_key = null;
328
- cookie = {};
329
- cookie_length = 0;
330
- }
331
- };
332
- for (let x = 0; x < cookie_str.length; x++) {
333
- const c = cookie_str.charAt(x);
334
- if (is_value) {
335
- if (is_str === c) {
336
- value = value.substr(1, value.length - 1);
337
- append_to_cookie();
338
- } else if (is_str == null && c === " ") {
339
- append_to_cookie();
340
- } else if (is_str == null && c === ";") {
341
- append_to_cookie();
342
- append_cookie();
343
- } else {
344
- value += c;
345
- if (value.length === 1 && (c === '"' || c === "'")) {
346
- is_str = c;
347
- }
348
- }
349
- } else if (c == " " || c == " ") {
350
- continue;
351
- } else if (c == "=") {
352
- if (cookie_key == null) {
353
- cookie_key = key;
354
- }
355
- is_value = true;
356
- } else {
357
- key += c;
358
- }
359
- }
360
- append_to_cookie();
361
- append_cookie();
362
- return this._cookies;
363
- }
364
- // ---------------------------------------------------------
365
- // Functions.
366
- /**
367
- * Wait until the request body is fully received.
368
- * Resolves when the internal receive promise completes.
369
- */
370
- async join() {
371
- await this.promise;
372
- }
373
- // Get the requests ip.
374
- /**
375
- * Get the request's ip.
376
- *
377
- * @example
378
- * ```ts
379
- * const ip = stream.ip;
380
- * ```
381
- * @docs
382
- */
383
- get ip() {
384
- return this._ip;
385
- }
386
- /**
387
- * Retrieve the normalized IP address, suitable for rate limiting and logging.
388
- * @throws {Error} If the IP is invalid.
389
- * @returns The normalized IP.
390
- * @docs
391
- */
392
- normalized_ip() {
393
- if (this._normalized_ip != null) {
394
- return this._normalized_ip;
395
- }
396
- return this._normalized_ip = import_rate_limit.default.normalize_ip(this._ip);
397
- }
398
- // Get the requests port.
399
- /**
400
- * Get the request's port.
401
- *
402
- * @example
403
- * ```ts
404
- * const port = stream.port;
405
- * ```
406
- * @docs
407
- */
408
- get port() {
409
- return this._port;
410
- }
411
- // Get the method.
412
- /**
413
- * Get the request method.
414
- *
415
- * @example
416
- * ```ts
417
- * const method = stream.method;
418
- * ```
419
- * @docs
420
- */
421
- get method() {
422
- return this._method;
423
- }
424
- // Get the endpoint.
425
- /**
426
- * Get the request's endpoint. This will not include the query string.
427
- *
428
- * @example
429
- * ```ts
430
- * const endpoint = stream.endpoint;
431
- * ```
432
- * @docs
433
- */
434
- get endpoint() {
435
- if (this._endpoint !== void 0) {
436
- return this._endpoint;
437
- }
438
- this._parse_endoint();
439
- return this._endpoint;
440
- }
441
- // Get the params.
442
- /**
443
- * Get the request's query or body params.
444
- *
445
- * @example
446
- * ```ts
447
- * const params = stream.params;
448
- * ```
449
- * @docs
450
- */
451
- get params() {
452
- if (this._params !== void 0) {
453
- return this._params;
454
- }
455
- this._parse_params();
456
- return this._params;
457
- }
458
- /** Add a param (used by the server backend for path parameters). */
459
- add_param(name, value) {
460
- if (!this._params) {
461
- this._params = {};
462
- }
463
- this._params[name] = value;
464
- }
465
- // Get a param by name and optionally by type.
466
- /**
467
- * Get a single query or body parameter with an optional type cast.
468
- *
469
- * @warning Throws an error when the parameter does not exist or when the type is different from the specified type(s), unless parameter `def` is defined.
470
- *
471
- * @param name The name of the parameter.
472
- * @param type The type cast of the parameters, valid types are `[null, "boolean", "number", "string", "array", "object"]`.
473
- * @param def
474
- * The default value to return when the parameter does not exist.
475
- *
476
- * If the parameter is not defined and `def` is `undefined` then this function will throw an error.
477
- * When `def` is `undefined` errors will be thrown, when `def` is `null` and the parameter is undefined then `null` will be returned as the default value.
478
- *
479
- * Errors will always be thrown when the incorrect type has been sent by the user.
480
- * @example
481
- * ```ts
482
- * const param = stream.param("myparameter", "number", 10);
483
- * ```
484
- * @docs
485
- */
486
- param(name, type = null, def = void 0) {
487
- this._parse_params();
488
- let value = this._params[name];
489
- if (type != null) {
490
- let is_type_array = Array.isArray(type);
491
- const type_str = () => {
492
- let str = "";
493
- if (type != null) {
494
- str += " type ";
495
- if (is_type_array) {
496
- let i = 0, one_but_last_i = type.length - 2;
497
- type.forEach((item, i2) => {
498
- str += `"${item}"`;
499
- if (i2 < one_but_last_i) {
500
- str += ", ";
501
- } else if (i2 === one_but_last_i) {
502
- str += " or ";
503
- }
504
- });
505
- } else {
506
- str += `"${type}"`;
507
- }
508
- }
509
- return str;
510
- };
511
- const type_eq_or_includes = (match) => {
512
- if (is_type_array) {
513
- return type.includes(match);
514
- }
515
- return match === type;
516
- };
517
- if (value == null || value === "") {
518
- if (def !== void 0) {
519
- return def;
520
- }
521
- throw Error(`Define parameter "${name}"${type_str()}.`);
522
- }
523
- if (this._is_query_params && type_eq_or_includes("string") === false) {
524
- if (is_type_array === false) {
525
- type = [type];
526
- }
527
- const success = type.some((type2) => {
528
- if (type2 === "string") {
529
- return true;
530
- }
531
- if (type2 === "null" && value === "null") {
532
- value = null;
533
- return true;
534
- }
535
- const is_boolean = type2 === "boolean";
536
- if (is_boolean && value === "true") {
537
- value = true;
538
- return true;
539
- }
540
- if (is_boolean && value === "false") {
541
- value = false;
542
- return true;
543
- }
544
- if (type2 === "array") {
545
- value = value.split(",");
546
- return true;
547
- }
548
- if (type2 === "object") {
549
- const split = value.split(",");
550
- value = {};
551
- split.forEach((item) => {
552
- const pair = item.split(":");
553
- value[pair[0]] = pair[1];
554
- });
555
- return true;
556
- }
557
- if (type2 === "number" && /^-?\d+(\.\d+)?$/.test(value)) {
558
- value = parseFloat(value);
559
- return true;
560
- }
561
- });
562
- if (!success) {
563
- throw Error(`Parameter "${name}" should be of${type_str()}.`);
564
- }
565
- } else if (!this._is_query_params) {
566
- const value_type = typeof value;
567
- if (!is_type_array) {
568
- type = [type];
569
- }
570
- const success = type.some((type2) => {
571
- const l_is_array = type2 === "array";
572
- const l_is_null = type2 === "null";
573
- if (!l_is_array && !l_is_null && type2 === value_type) {
574
- return true;
575
- }
576
- if (l_is_null && value == null) {
577
- return true;
578
- }
579
- if (l_is_array && Array.isArray(value)) {
580
- return true;
581
- }
582
- });
583
- if (!success) {
584
- throw Error(`Parameter "${name}" should be of${type_str()}.`);
585
- }
586
- }
587
- } else if (value == null || value === "") {
588
- if (def !== void 0) {
589
- return def;
590
- }
591
- throw Error(`Define parameter "${name}".`);
592
- }
593
- return value;
594
- }
595
- // Get the request cookies.
596
- /**
597
- * Get the request's cookies
598
- *
599
- * @example
600
- * ```ts
601
- * const cookies = stream.cookies;
602
- * ```
603
- * @docs
604
- */
605
- get cookies() {
606
- if (this._cookies != null)
607
- return this._cookies;
608
- return this._parse_cookies();
609
- }
610
- // DEPRECATED since its only available for http2.
611
- // /**
612
- // * Check if the stream is closed.
613
- // *
614
- // * @example
615
- // * ```ts
616
- // * const ip = stream.closed;
617
- // * ```
618
- // * @docs
619
- // */
620
- // get closed(): boolean {
621
- // if (!this.http2) { throw new Error("This function is only supported for http2 streams."); }
622
- // return this.s!.closed;
623
- // }
624
- // Check if the stream is destroyed
625
- /**
626
- * Check if the stream is destroyed.
627
- *
628
- * @example
629
- * ```ts
630
- * const ip = stream.destroyed;
631
- * ```
632
- * @docs
633
- */
634
- get destroyed() {
635
- if (this.http2) {
636
- return this.s.destroyed;
637
- } else {
638
- return this.req.destroyed;
639
- }
640
- }
641
- // ---------------------------------------------------------
642
- // Functions.
643
- // Get the authenticated uid.
644
- /**
645
- * Get the authenticated uid; `undefined` when the request was not authenticated.
646
- *
647
- * @example
648
- * ```ts
649
- * const uid = stream.uid;
650
- * ```
651
- * @docs
652
- */
653
- get uid() {
654
- return this._uid;
655
- }
656
- set uid(value) {
657
- this._uid = value;
658
- }
659
- /**
660
- * Apply templates to an in-memory body.
661
- * Only applies to string bodies to avoid corrupting binary payloads.
662
- */
663
- apply_templates_to_body(input, templates) {
664
- if (templates == null || Object.keys(templates).length === 0) {
665
- return input;
666
- }
667
- if (typeof input !== "string") {
668
- return input;
669
- }
670
- let out = input;
671
- for (const key of Object.keys(templates)) {
672
- const value = templates[key];
673
- const value_str = typeof value === "string" ? value : JSON.stringify(value);
674
- out = out.split(`{{${key}}}`).join(value_str);
675
- }
676
- return out;
677
- }
678
- /**
679
- * Create a transform stream that applies templates across chunk boundaries.
680
- * This avoids missing replacements when a template key is split between chunks.
681
- */
682
- create_template_replace_transform(templates) {
683
- const keys = Object.keys(templates);
684
- const max_key_len = keys.reduce((max, k) => Math.max(max, k.length), 0);
685
- const keep_len = Math.max(0, max_key_len - 1);
686
- let carry = "";
687
- return new import_node_stream.Transform({
688
- transform(chunk, _enc, cb) {
689
- try {
690
- const str = carry + chunk.toString("utf8");
691
- const cut_idx = Math.max(0, str.length - keep_len);
692
- const safe_head = str.slice(0, cut_idx);
693
- carry = str.slice(cut_idx);
694
- let out = safe_head;
695
- for (const key of keys) {
696
- const value = templates[key];
697
- const value_str = typeof value === "string" ? value : JSON.stringify(value);
698
- out = out.split(`{{${key}}}`).join(value_str);
699
- }
700
- cb(null, out);
701
- } catch (err) {
702
- cb(err);
703
- }
704
- },
705
- flush(cb) {
706
- try {
707
- let out = carry;
708
- for (const key of keys) {
709
- const value = templates[key];
710
- const value_str = typeof value === "string" ? value : JSON.stringify(value);
711
- out = out.split(`{{${key}}}`).join(value_str);
712
- }
713
- cb(null, out);
714
- } catch (err) {
715
- cb(err);
716
- }
717
- }
718
- });
719
- }
720
- /** Create output headers for http2. */
721
- create_http2_headers(status, new_headers) {
722
- const normalize_header_value = (v) => {
723
- if (v == null)
724
- return void 0;
725
- if (typeof v === "boolean")
726
- return v ? "true" : "false";
727
- if (typeof v === "number")
728
- return v;
729
- if (typeof v === "string")
730
- return v;
731
- return String(v);
732
- };
733
- const out_headers = {
734
- ":status": status
735
- };
736
- if (!Array.isArray(this.res_headers)) {
737
- for (const [k, v] of Object.entries(this.res_headers)) {
738
- const nv = normalize_header_value(v);
739
- if (nv !== void 0)
740
- out_headers[k.toLowerCase()] = nv;
741
- }
742
- }
743
- for (const [k, v] of Object.entries(new_headers)) {
744
- const nv = normalize_header_value(v);
745
- if (nv !== void 0)
746
- out_headers[k.toLowerCase()] = nv;
747
- }
748
- if (this.res_cookies.length > 0) {
749
- out_headers["set-cookie"] = this.res_cookies;
750
- }
751
- return out_headers;
752
- }
753
- /** Assign http headers to response. */
754
- set_http1_headers(status, headers) {
755
- if (!this.res) {
756
- throw new Error("HTTP/1.1 response is missing.");
757
- }
758
- this.res.statusCode = status;
759
- for (let i = 0; i < this.res_headers.length; i++) {
760
- this.res.setHeader(this.res_headers[i][0].toLowerCase(), this.res_headers[i][1]);
761
- }
762
- Object.keys(headers).forEach((key) => {
763
- const v = headers[key];
764
- if (v != null) {
765
- this.res?.setHeader(key.toLowerCase(), typeof v === "boolean" ? v.toString() : v);
766
- }
767
- });
768
- }
769
- /**
770
- * Send a response.
771
- * @example
772
- * ```ts
773
- * stream.send({status: 200, data: "Hello World!"});
774
- * ```
775
- * @docs
776
- */
777
- send({ status = 200, headers = {}, data, compress = false, from_file, templates }) {
778
- this.status_code = status;
779
- let body = data;
780
- if (typeof body === "boolean" || typeof body === "number") {
781
- body = body.toString();
782
- }
783
- const get_accept_encoding = () => {
784
- const accept_encoding = this.headers?.["accept-encoding"];
785
- if (typeof accept_encoding === "string") {
786
- return accept_encoding;
787
- }
788
- if (Array.isArray(accept_encoding) && accept_encoding.length > 0) {
789
- return accept_encoding.join(", ");
790
- }
791
- const req_accept_encoding = this.req?.headers?.["accept-encoding"];
792
- if (typeof req_accept_encoding === "string") {
793
- return req_accept_encoding;
794
- }
795
- if (Array.isArray(req_accept_encoding) && req_accept_encoding.length > 0) {
796
- return req_accept_encoding.join(", ");
797
- }
798
- return "";
799
- };
800
- body = this.apply_templates_to_body(body, templates);
801
- if (this.http2) {
802
- const stream = this.s;
803
- const out_headers = this.create_http2_headers(status, headers);
804
- if (from_file) {
805
- const from_path = from_file instanceof vlib.Path ? from_file : new vlib.Path(from_file);
806
- const needs_template_replace = templates != null && Object.keys(templates).length > 0;
807
- const should_gzip = compress && get_accept_encoding().includes("gzip") && !(import_utils.Utils.is_compressed_extension(from_path.extension()) ?? false);
808
- const content_type = import_utils.Utils.mime_type(from_path.extension());
809
- if (content_type && out_headers["content-type"] == null) {
810
- out_headers["content-type"] = content_type;
811
- }
812
- const is_text_response = typeof content_type === "string" && (content_type.startsWith("text/") || content_type === "application/javascript" || content_type === "application/json" || content_type === "image/svg+xml" || content_type === "application/xml" || content_type === "text/xml");
813
- const should_apply_templates = needs_template_replace && is_text_response;
814
- if (should_gzip) {
815
- out_headers["content-encoding"] = "gzip";
816
- out_headers["vary"] = "Accept-Encoding";
817
- delete out_headers["content-length"];
818
- }
819
- if (should_apply_templates) {
820
- delete out_headers["content-length"];
821
- }
822
- if (!should_gzip && !should_apply_templates && typeof stream.respondWithFile === "function") {
823
- stream.respondWithFile(from_path.toString(), out_headers, {});
824
- if (debug.on(3))
825
- debug("Sending http2 file response: ", status, " - file: ", from_path.toString());
826
- this.finished = true;
827
- return this;
828
- }
829
- stream.respond(out_headers);
830
- const file_read_stream = fs.createReadStream(from_path.toString());
831
- const transforms = [];
832
- if (should_apply_templates) {
833
- transforms.push(this.create_template_replace_transform(templates));
834
- }
835
- if (should_gzip) {
836
- transforms.push(zlib.createGzip({ level: zlib.constants.Z_BEST_COMPRESSION }));
837
- }
838
- (0, import_node_stream2.pipeline)(file_read_stream, ...transforms, stream, (err) => {
839
- if (err) {
840
- try {
841
- stream.close();
842
- } catch {
843
- }
844
- }
845
- });
846
- if (debug.on(3))
847
- debug("Sending http2 streamed file response: ", status, " - file: ", from_path.toString());
848
- this.finished = true;
849
- return this;
850
- } else {
851
- if (body && typeof body === "object" && Buffer.isBuffer(body) === false && body instanceof Uint8Array === false) {
852
- out_headers["content-type"] = "application/json";
853
- body = JSON.stringify(body);
854
- body = this.apply_templates_to_body(body, templates);
855
- }
856
- if (body && typeof body === "object" && !(body instanceof Buffer) && !(body instanceof Uint8Array)) {
857
- body = JSON.stringify(body);
858
- body = this.apply_templates_to_body(body, templates);
859
- }
860
- const should_gzip_body = compress && !!body && get_accept_encoding().includes("gzip");
861
- if (should_gzip_body) {
862
- out_headers["content-encoding"] = "gzip";
863
- out_headers["vary"] = "Accept-Encoding";
864
- delete out_headers["content-length"];
865
- }
866
- stream.respond(out_headers);
867
- if (debug.on(3))
868
- debug("Sending response: ", status, " - has body: ", !!body);
869
- if (!body) {
870
- stream.end();
871
- this.finished = true;
872
- return this;
873
- } else if (should_gzip_body) {
874
- const raw_buffer = typeof body === "string" ? Buffer.from(body) : Buffer.isBuffer(body) || body instanceof Uint8Array ? Buffer.from(body) : Buffer.from(JSON.stringify(body));
875
- zlib.gzip(raw_buffer, { level: zlib.constants.Z_BEST_COMPRESSION }, (err, gz_buffer) => {
876
- if (err) {
877
- stream.end(raw_buffer);
878
- return;
879
- }
880
- stream.end(gz_buffer);
881
- });
882
- this.finished = true;
883
- return this;
884
- } else {
885
- if (Buffer.isBuffer(body) || body instanceof Uint8Array) {
886
- stream.end(body);
887
- } else {
888
- stream.end(Buffer.from(body));
889
- }
890
- this.finished = true;
891
- return this;
892
- }
893
- }
894
- } else {
895
- const req = this.req;
896
- const res = this.res;
897
- this.set_http1_headers(status, headers);
898
- if (from_file) {
899
- const from_path = from_file instanceof vlib.Path ? from_file : new vlib.Path(from_file);
900
- const content_type = import_utils.Utils.mime_type(from_path.extension());
901
- if (content_type) {
902
- res.setHeader("Content-Type", content_type);
903
- }
904
- const needs_template_replace = templates != null && Object.keys(templates).length > 0;
905
- const is_text_response = typeof content_type === "string" && (content_type.startsWith("text/") || content_type === "application/javascript" || content_type === "application/json" || content_type === "image/svg+xml" || content_type === "application/xml" || content_type === "text/xml");
906
- const should_apply_templates = needs_template_replace && is_text_response;
907
- const should_gzip = compress && get_accept_encoding().includes("gzip") && !(import_utils.Utils.is_compressed_extension(from_path.extension()) ?? false);
908
- if (should_gzip) {
909
- res.setHeader("Content-Encoding", "gzip");
910
- res.setHeader("Vary", "Accept-Encoding");
911
- res.removeHeader("Content-Length");
912
- } else if (!should_apply_templates) {
913
- try {
914
- if (from_path.is_file()) {
915
- res.setHeader("Content-Length", from_path.size);
916
- }
917
- } catch {
918
- }
919
- }
920
- if (should_apply_templates) {
921
- res.removeHeader("Content-Length");
922
- }
923
- const file_read_stream = fs.createReadStream(from_path.toString());
924
- const transforms = [];
925
- if (should_apply_templates) {
926
- transforms.push(this.create_template_replace_transform(templates));
927
- }
928
- if (should_gzip) {
929
- transforms.push(zlib.createGzip({ level: zlib.constants.Z_BEST_COMPRESSION }));
930
- }
931
- (0, import_node_stream2.pipeline)(file_read_stream, ...transforms, res, (err) => {
932
- if (err) {
933
- try {
934
- res.destroy(err);
935
- } catch {
936
- }
937
- }
938
- });
939
- if (debug.on(3))
940
- debug("Sending http1 streamed file response: ", status, " - file: ", from_path.toString());
941
- this.finished = true;
942
- return this;
943
- } else {
944
- if (body && typeof body === "object" && Buffer.isBuffer(body) === false && body instanceof Uint8Array === false) {
945
- res.setHeader("Content-Type", "application/json");
946
- body = JSON.stringify(body);
947
- body = this.apply_templates_to_body(body, templates);
948
- }
949
- const should_gzip_body = compress && !!body && get_accept_encoding().includes("gzip");
950
- if (should_gzip_body) {
951
- res.setHeader("Content-Encoding", "gzip");
952
- res.setHeader("Vary", "Accept-Encoding");
953
- res.removeHeader("Content-Length");
954
- const raw_buffer = typeof body === "string" ? Buffer.from(body) : Buffer.isBuffer(body) || body instanceof Uint8Array ? Buffer.from(body) : Buffer.from(JSON.stringify(body));
955
- zlib.gzip(raw_buffer, { level: zlib.constants.Z_BEST_COMPRESSION }, (err, gz_buffer) => {
956
- if (err) {
957
- res.end(raw_buffer);
958
- return;
959
- }
960
- res.end(gz_buffer);
961
- });
962
- if (debug.on(3))
963
- debug("Sending http1 response: ", status, " - has body: ", !!body, " - gzip: true");
964
- } else if (body) {
965
- res.end(body);
966
- } else {
967
- res.end();
968
- }
969
- this.finished = true;
970
- return this;
971
- }
972
- }
973
- }
974
- // Send a successs response.
975
- /**
976
- * Send a response
977
- *
978
- * @param options The response options.
979
- * @param options.status The response status.
980
- * @param options.headers The response headers.
981
- * @param options.data The data of the response body to send.
982
- * @param options.compress Whether the response should be gzip-compressed.
983
- * @example
984
- * ```ts
985
- * stream.success({data: "Hello World!"});
986
- * ```
987
- * @docs
988
- */
989
- success({ status = 200, headers = {}, data, from_file, compress = false } = {}) {
990
- if (debug.on(3))
991
- debug("Sending [success] response: ", status, " - body: ", data);
992
- return this.send({ status, headers, data, compress, from_file });
993
- }
994
- // Send an error response.
995
- /**
996
- * Send an error response
997
- *
998
- * @param options The error response options.
999
- * @param options.message The error message.
1000
- * @param options.type The error type.
1001
- * @param options.invalid_fields The invalid fields when validation fails.
1002
- * @param options.status The response status.
1003
- * @param options.headers The response headers.
1004
- * @param options.compress Whether the response should be gzip-compressed.
1005
- * @param options.data Optional data to include in the error response, nested in the JSON response under field `data`.
1006
- * @example
1007
- * ```ts
1008
- * stream.error({ message: "Some error occurred", status: 400 });
1009
- * ```
1010
- * @docs
1011
- */
1012
- error({ message, type = "APIError", invalid_fields = {}, status = 500, headers = {}, compress = false, data }) {
1013
- if (debug.on(3))
1014
- debug("Sending [error] response: ", status, " - message: ", message);
1015
- const api_error = {
1016
- error: {
1017
- type,
1018
- message,
1019
- status,
1020
- invalid_fields
1021
- },
1022
- data
1023
- };
1024
- return this.send({ status, headers, compress, data: api_error });
1025
- }
1026
- /**
1027
- * Stream a response through a transform pipeline with an optional gzip step and a hard byte limit.
1028
- *
1029
- * @param options Pipeline options.
1030
- * @param options.status The HTTP status code to send.
1031
- * @param options.headers The response headers to send.
1032
- * @param options.body The readable stream to pipe into the response.
1033
- * @param options.transforms Optional transform streams applied in order.
1034
- * @param options.compress When true, gzip-compresses the streamed response if the client supports it.
1035
- * @param options.max_bytes The maximum number of bytes allowed to be written to the client.
1036
- * Set to `-1` for unlimited (use with caution).
1037
- */
1038
- pipeline({ status = 200, headers = {}, body, transforms = [], compress = false, max_bytes = 10 * 1024 * 1024 }) {
1039
- if (this.finished) {
1040
- throw new Error("Cannot pipeline a response that has already been finished.");
1041
- }
1042
- if (!Number.isInteger(status) || status < 100 || status > 599) {
1043
- throw new Error("Invalid status code.");
1044
- }
1045
- if (!Number.isFinite(max_bytes)) {
1046
- throw new Error("Invalid max_bytes value.");
1047
- }
1048
- if (!Array.isArray(transforms) || transforms.length > 32) {
1049
- throw new Error("Invalid transforms configuration.");
1050
- }
1051
- this.status_code = status;
1052
- this.finished = true;
1053
- const all_streams = [body, ...transforms];
1054
- const accept_encoding_header = this.headers?.["accept-encoding"];
1055
- const accept_encoding = typeof accept_encoding_header === "string" ? accept_encoding_header : Array.isArray(accept_encoding_header) ? accept_encoding_header.join(", ") : "";
1056
- const has_content_encoding = (() => {
1057
- for (const k of Object.keys(headers ?? {})) {
1058
- if (k.toLowerCase() === "content-encoding")
1059
- return true;
1060
- }
1061
- const existing = this.get_header("content-encoding");
1062
- return existing != null;
1063
- })();
1064
- const should_gzip = compress === true && accept_encoding.includes("gzip") && !has_content_encoding;
1065
- if (should_gzip) {
1066
- all_streams.push(zlib.createGzip({ level: zlib.constants.Z_BEST_COMPRESSION }));
1067
- }
1068
- if (max_bytes >= 0) {
1069
- let written = 0;
1070
- const limiter = new import_node_stream.Transform({
1071
- transform(chunk, _enc, cb) {
1072
- written += chunk.length;
1073
- if (written > max_bytes) {
1074
- cb(new Error("Response exceeded max_bytes."));
1075
- return;
1076
- }
1077
- cb(null, chunk);
1078
- }
1079
- });
1080
- all_streams.push(limiter);
1081
- }
1082
- const cleanup = (err) => {
1083
- for (const s of all_streams) {
1084
- if ("destroy" in s && typeof s.destroy === "function") {
1085
- s.destroy(err);
1086
- }
1087
- }
1088
- };
1089
- if (this.http2) {
1090
- const h2 = this.s;
1091
- if (!h2) {
1092
- throw new Error("HTTP/2 stream is missing.");
1093
- }
1094
- const out_headers = this.create_http2_headers(status, headers);
1095
- if (should_gzip) {
1096
- out_headers["content-encoding"] = "gzip";
1097
- out_headers["vary"] = "Accept-Encoding";
1098
- }
1099
- delete out_headers["content-length"];
1100
- h2.respond(out_headers);
1101
- h2.once("close", () => {
1102
- cleanup(new Error("Client disconnected."));
1103
- });
1104
- (0, import_node_stream2.pipeline)(...all_streams, h2, (err) => {
1105
- if (err) {
1106
- cleanup(err instanceof Error ? err : new Error("Pipeline failed."));
1107
- try {
1108
- h2.close();
1109
- } catch {
1110
- }
1111
- }
1112
- });
1113
- return this;
1114
- } else {
1115
- const res = this.res;
1116
- if (!res) {
1117
- throw new Error("HTTP/1.1 response is missing.");
1118
- }
1119
- this.set_http1_headers(status, headers);
1120
- if (should_gzip) {
1121
- res.setHeader("Content-Encoding", "gzip");
1122
- res.setHeader("Vary", "Accept-Encoding");
1123
- }
1124
- res.removeHeader("Content-Length");
1125
- res.once("close", () => {
1126
- cleanup(new Error("Client disconnected."));
1127
- });
1128
- (0, import_node_stream2.pipeline)(...all_streams, res, (err) => {
1129
- if (err) {
1130
- cleanup(err instanceof Error ? err : new Error("Pipeline failed."));
1131
- try {
1132
- res.destroy();
1133
- } catch {
1134
- }
1135
- }
1136
- });
1137
- }
1138
- return this;
1139
- }
1140
- // Set headers.
1141
- /**
1142
- * Add a new header to the response data.
1143
- *
1144
- * @param name The header name.
1145
- * @param value The header value.
1146
- * @example
1147
- * ```ts
1148
- * stream.set_header("Connection", "close");
1149
- * ```
1150
- * @docs
1151
- */
1152
- set_header(name, value) {
1153
- name = name.toLowerCase();
1154
- if (this.http2) {
1155
- this.res_headers[name] = value;
1156
- } else {
1157
- this.res_headers.append([name, value]);
1158
- }
1159
- return this;
1160
- }
1161
- // Set headers.
1162
- /**
1163
- * Add new headers to the response data.
1164
- *
1165
- * @param headers The new response headers.
1166
- * @example
1167
- * ```ts
1168
- * stream.set_headers({"Connection": "close"});
1169
- * ```
1170
- * @docs
1171
- */
1172
- set_headers(headers = {}) {
1173
- if (headers == null) {
1174
- return this;
1175
- }
1176
- if (this.http2) {
1177
- Object.keys(headers).forEach((key) => {
1178
- this.res_headers[key.toLowerCase()] = headers[key];
1179
- });
1180
- } else {
1181
- Object.keys(headers).forEach((key) => {
1182
- this.res_headers.append([key.toLowerCase(), headers[key]]);
1183
- });
1184
- }
1185
- return this;
1186
- }
1187
- /**
1188
- * Get an added response header.
1189
- *
1190
- * @param name The header name.
1191
- * @example
1192
- * ```ts
1193
- * stream.get_header("Connection");
1194
- * ```
1195
- * @docs
1196
- */
1197
- get_header(name) {
1198
- name = name.toLowerCase();
1199
- if (this.http2) {
1200
- return this.res_headers[name];
1201
- } else {
1202
- return this.res_headers.find((h) => h[0] === name)?.[1];
1203
- }
1204
- }
1205
- /**
1206
- * Remove header names from the response data.
1207
- *
1208
- * @param names The header names to remove.
1209
- * @example
1210
- * ```ts
1211
- * stream.remove_header("Connection", "User-Agent");
1212
- * ```
1213
- * @docs
1214
- */
1215
- remove_header(...names) {
1216
- names = names.map((n) => n.toLowerCase());
1217
- if (this.http1) {
1218
- const headers = [];
1219
- for (let i = 0; i < this.res_headers.length; i++) {
1220
- if (!names.includes(this.res_headers[i][0])) {
1221
- headers.push(this.res_headers[i]);
1222
- }
1223
- }
1224
- this.res_headers = headers;
1225
- } else {
1226
- for (let i = 0; i < names.length; i++) {
1227
- delete this.res_headers[names[i]];
1228
- }
1229
- }
1230
- return this;
1231
- }
1232
- /**
1233
- * Alias of {@link remove_header}.
1234
- *
1235
- * @param names The header names to remove.
1236
- */
1237
- remove_headers(...names) {
1238
- return this.remove_header(...names);
1239
- }
1240
- /**
1241
- * Set a cookie to be sent with the response.
1242
- *
1243
- * Accepts either:
1244
- * 1) a pre-built cookie header string (used as-is, no validation), or
1245
- * 2) a structured object describing the cookie, from which a standards-compliant
1246
- * cookie string will be generated.
1247
- *
1248
- * If a cookie with the same name already exists in the pending response list,
1249
- * it will be replaced.
1250
- *
1251
- * @warning Cookies are only included in the response when using `send()`,
1252
- * `success()` or `error()`.
1253
- *
1254
- * @example
1255
- * ```ts
1256
- * stream.set_cookie("sid=abc123; Path=/; SameSite=Lax; Secure; HttpOnly");
1257
- *
1258
- * stream.set_cookie({
1259
- * name: "sid",
1260
- * value: session_id,
1261
- * http_only: true,
1262
- * secure: true,
1263
- * same_site: "Lax",
1264
- * path: "/",
1265
- * max_age: 60 * 60 * 24 * 14,
1266
- * });
1267
- * ```
1268
- */
1269
- set_cookie(cookie) {
1270
- if (typeof cookie === "string") {
1271
- const cookie_str2 = cookie.trim();
1272
- const name_end2 = cookie_str2.indexOf("=");
1273
- if (name_end2 !== -1) {
1274
- const name2 = cookie_str2.substring(0, name_end2);
1275
- for (let i = 0; i < this.res_cookies.length; i++) {
1276
- if (this.res_cookies[i].startsWith(name2)) {
1277
- this.res_cookies[i] = cookie_str2;
1278
- return this;
1279
- }
1280
- }
1281
- }
1282
- this.res_cookies.push(cookie_str2);
1283
- return this;
1284
- }
1285
- const { name, value, path = "/", domain, max_age, expires, secure, http_only, same_site, prefix, extra } = cookie;
1286
- if (!name || typeof name !== "string") {
1287
- throw new Error("set_cookie: cookie.name must be a non-empty string");
1288
- }
1289
- const full_name = `${prefix ?? ""}${name}`;
1290
- if (prefix === "__Host-") {
1291
- if (domain) {
1292
- throw new Error("__Host- cookies must not include a domain attribute");
1293
- }
1294
- if (path !== "/") {
1295
- throw new Error("__Host- cookies must have path='/'");
1296
- }
1297
- if (!secure) {
1298
- throw new Error("__Host- cookies require secure=true");
1299
- }
1300
- }
1301
- if (prefix === "__Secure-" && !secure) {
1302
- throw new Error("__Secure- cookies require secure=true");
1303
- }
1304
- const encoded_value = value === null || typeof value === "undefined" ? "" : encodeURIComponent(String(value));
1305
- const parts = [];
1306
- parts.push(`${full_name}=${encoded_value}`);
1307
- if (path)
1308
- parts.push(`Path=${path}`);
1309
- if (domain)
1310
- parts.push(`Domain=${domain}`);
1311
- if (typeof max_age === "number" && Number.isFinite(max_age)) {
1312
- parts.push(`Max-Age=${Math.trunc(max_age)}`);
1313
- }
1314
- if (expires) {
1315
- const exp = expires instanceof Date ? expires.toUTCString() : String(expires).trim();
1316
- if (exp)
1317
- parts.push(`Expires=${exp}`);
1318
- }
1319
- if (secure)
1320
- parts.push("Secure");
1321
- if (http_only)
1322
- parts.push("HttpOnly");
1323
- if (same_site)
1324
- parts.push(`SameSite=${same_site}`);
1325
- if (extra && Array.isArray(extra)) {
1326
- for (const attr of extra) {
1327
- const trimmed = String(attr).trim();
1328
- if (trimmed)
1329
- parts.push(trimmed);
1330
- }
1331
- }
1332
- const cookie_str = parts.join("; ");
1333
- const name_end = cookie_str.indexOf("=");
1334
- if (name_end !== -1) {
1335
- const existing_name = cookie_str.substring(0, name_end);
1336
- for (let i = 0; i < this.res_cookies.length; i++) {
1337
- if (this.res_cookies[i].startsWith(existing_name)) {
1338
- this.res_cookies[i] = cookie_str;
1339
- return this;
1340
- }
1341
- }
1342
- }
1343
- this.res_cookies.push(cookie_str);
1344
- return this;
1345
- }
1346
- // Set cookies.
1347
- /**
1348
- * Set cookies that will be sent with the response.
1349
- *
1350
- * @warning Will only be added to the response when the user uses `send()`, `success()` or `error()`.
1351
- * @param cookies The cookie strings.
1352
- * @example
1353
- * ```ts
1354
- * stream.set_cookies("MyCookie1=Hello World;", "MyCookie2=Hello Universe;");
1355
- * ```
1356
- * @docs
1357
- */
1358
- set_cookies(...cookies) {
1359
- for (let i = 0; i < cookies.length; i++) {
1360
- this.set_cookie(cookies[i]);
1361
- }
1362
- return this;
1363
- }
1364
- }
1365
- ;
1366
- ;
1367
- // Annotate the CommonJS export names for ESM import in node:
1368
- 0 && (module.exports = {
1369
- Stream
1370
- });