@vandenberghinc/volt 1.2.6 → 1.2.7

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 (462) hide show
  1. package/backend/dist/cjs/backend/src/blacklist.d.ts +12 -0
  2. package/backend/dist/cjs/backend/src/blacklist.js +78 -0
  3. package/backend/dist/cjs/backend/src/cli.d.ts +2 -0
  4. package/backend/dist/cjs/backend/src/cli.js +198 -0
  5. package/backend/dist/cjs/backend/src/database/collection.d.ts +1765 -0
  6. package/backend/dist/cjs/backend/src/database/collection.js +3301 -0
  7. package/backend/dist/cjs/backend/src/database/database.d.ts +92 -0
  8. package/backend/dist/cjs/backend/src/database/database.js +170 -0
  9. package/backend/dist/cjs/backend/src/database/document.d.ts +1 -0
  10. package/backend/dist/cjs/backend/src/database/document.js +15 -0
  11. package/backend/dist/cjs/backend/src/database/filters/filters.d.ts +6 -0
  12. package/backend/dist/cjs/backend/src/database/filters/filters.js +15 -0
  13. package/backend/dist/cjs/backend/src/database/filters/strict_filter.d.ts +223 -0
  14. package/backend/dist/cjs/backend/src/database/filters/strict_filter.js +15 -0
  15. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.d.ts +1 -0
  16. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.js +443 -0
  17. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.d.ts +1 -0
  18. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.js +15 -0
  19. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
  20. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.js +15 -0
  21. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
  22. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.js +15 -0
  23. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
  24. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.js +15 -0
  25. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
  26. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.js +15 -0
  27. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.d.ts +165 -0
  28. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.js +15 -0
  29. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
  30. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.js +355 -0
  31. package/backend/dist/cjs/backend/src/database/flatten.d.ts +78 -0
  32. package/backend/dist/cjs/backend/src/database/flatten.js +53 -0
  33. package/backend/dist/cjs/backend/src/database/flatten_test.d.ts +1 -0
  34. package/backend/dist/cjs/backend/src/database/flatten_test.js +175 -0
  35. package/backend/dist/cjs/backend/src/database/quota/quoata_v2.d.ts +533 -0
  36. package/backend/dist/cjs/backend/src/database/quota/quoata_v2.js +1046 -0
  37. package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +551 -0
  38. package/backend/dist/cjs/backend/src/database/quota/quota.js +1108 -0
  39. package/backend/dist/cjs/backend/src/database/quota/quota_v1.d.ts +534 -0
  40. package/backend/dist/cjs/backend/src/database/quota/quota_v1.js +1087 -0
  41. package/backend/dist/cjs/backend/src/database/quota/safe_int.d.ts +412 -0
  42. package/backend/dist/cjs/backend/src/database/quota/safe_int.js +745 -0
  43. package/backend/dist/cjs/backend/src/endpoint.d.ts +346 -0
  44. package/backend/dist/cjs/backend/src/endpoint.js +468 -0
  45. package/backend/dist/cjs/backend/src/errors/index.d.ts +7 -0
  46. package/backend/dist/cjs/backend/src/errors/index.js +25 -0
  47. package/backend/dist/cjs/backend/src/errors/internal_external.d.ts +52 -0
  48. package/backend/dist/cjs/backend/src/errors/internal_external.js +95 -0
  49. package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +41 -0
  50. package/backend/dist/cjs/backend/src/errors/invalid_usage_error.js +47 -0
  51. package/backend/dist/cjs/backend/src/errors/system_error.d.ts +261 -0
  52. package/backend/dist/cjs/backend/src/errors/system_error.js +436 -0
  53. package/backend/dist/cjs/backend/src/events.d.ts +97 -0
  54. package/backend/dist/cjs/backend/src/events.js +15 -0
  55. package/backend/dist/cjs/backend/src/frontend.d.ts +13 -0
  56. package/backend/dist/cjs/backend/src/frontend.js +56 -0
  57. package/backend/dist/cjs/backend/src/image_endpoint.d.ts +44 -0
  58. package/backend/dist/cjs/backend/src/image_endpoint.js +185 -0
  59. package/backend/dist/cjs/backend/src/index.d.ts +23 -0
  60. package/backend/dist/cjs/backend/src/index.js +70 -0
  61. package/backend/dist/cjs/backend/src/logger.d.ts +5 -0
  62. package/backend/dist/cjs/backend/src/logger.js +15 -0
  63. package/backend/dist/cjs/backend/src/meta.d.ts +112 -0
  64. package/backend/dist/cjs/backend/src/meta.js +181 -0
  65. package/backend/dist/cjs/backend/src/payments/paddle.d.ts +329 -0
  66. package/backend/dist/cjs/backend/src/payments/paddle.js +1996 -0
  67. package/backend/dist/cjs/backend/src/payments/stripe/checkout.d.ts +113 -0
  68. package/backend/dist/cjs/backend/src/payments/stripe/checkout.js +295 -0
  69. package/backend/dist/cjs/backend/src/payments/stripe/customers.d.ts +17 -0
  70. package/backend/dist/cjs/backend/src/payments/stripe/customers.js +164 -0
  71. package/backend/dist/cjs/backend/src/payments/stripe/error.d.ts +74 -0
  72. package/backend/dist/cjs/backend/src/payments/stripe/error.js +64 -0
  73. package/backend/dist/cjs/backend/src/payments/stripe/events.d.ts +155 -0
  74. package/backend/dist/cjs/backend/src/payments/stripe/events.js +15 -0
  75. package/backend/dist/cjs/backend/src/payments/stripe/meters.d.ts +105 -0
  76. package/backend/dist/cjs/backend/src/payments/stripe/meters.js +230 -0
  77. package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.d.ts +58 -0
  78. package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.js +109 -0
  79. package/backend/dist/cjs/backend/src/payments/stripe/products.d.ts +519 -0
  80. package/backend/dist/cjs/backend/src/payments/stripe/products.js +650 -0
  81. package/backend/dist/cjs/backend/src/payments/stripe/stripe.d.ts +215 -0
  82. package/backend/dist/cjs/backend/src/payments/stripe/stripe.js +468 -0
  83. package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.d.ts +172 -0
  84. package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.js +557 -0
  85. package/backend/dist/cjs/backend/src/payments/stripe/utils.d.ts +63 -0
  86. package/backend/dist/cjs/backend/src/payments/stripe/utils.js +118 -0
  87. package/backend/dist/cjs/backend/src/payments/stripe/webhooks.d.ts +105 -0
  88. package/backend/dist/cjs/backend/src/payments/stripe/webhooks.js +627 -0
  89. package/backend/dist/cjs/backend/src/plugins/browser.d.ts +1 -0
  90. package/backend/dist/cjs/backend/src/plugins/browser.js +15 -0
  91. package/backend/dist/cjs/backend/src/plugins/communication.d.ts +70 -0
  92. package/backend/dist/cjs/backend/src/plugins/communication.js +196 -0
  93. package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +255 -0
  94. package/backend/dist/cjs/backend/src/plugins/mail/mail.js +381 -0
  95. package/backend/dist/cjs/backend/src/plugins/mail/ui.d.ts +297 -0
  96. package/backend/dist/cjs/backend/src/plugins/mail/ui.js +1370 -0
  97. package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +1 -0
  98. package/backend/dist/cjs/backend/src/plugins/pdf.js +1456 -0
  99. package/backend/dist/cjs/backend/src/plugins/thread_monitor.d.ts +18 -0
  100. package/backend/dist/cjs/backend/src/plugins/thread_monitor.js +116 -0
  101. package/backend/dist/cjs/backend/src/rate_limit.d.ts +148 -0
  102. package/backend/dist/cjs/backend/src/rate_limit.js +543 -0
  103. package/backend/dist/cjs/backend/src/route.d.ts +39 -0
  104. package/backend/dist/cjs/backend/src/route.js +172 -0
  105. package/backend/dist/cjs/backend/src/server.d.ts +502 -0
  106. package/backend/dist/cjs/backend/src/server.js +1710 -0
  107. package/backend/dist/cjs/backend/src/server.old.d.ts +594 -0
  108. package/backend/dist/cjs/backend/src/server.old.js +2058 -0
  109. package/backend/dist/cjs/backend/src/splash_screen.d.ts +93 -0
  110. package/backend/dist/cjs/backend/src/splash_screen.js +119 -0
  111. package/backend/dist/cjs/backend/src/status.d.ts +89 -0
  112. package/backend/dist/cjs/backend/src/status.js +211 -0
  113. package/backend/dist/cjs/backend/src/stream.d.ts +494 -0
  114. package/backend/dist/cjs/backend/src/stream.js +1370 -0
  115. package/backend/dist/cjs/backend/src/users.d.ts +926 -0
  116. package/backend/dist/cjs/backend/src/users.js +2223 -0
  117. package/backend/dist/cjs/backend/src/utils.d.ts +22 -0
  118. package/backend/dist/cjs/backend/src/utils.js +626 -0
  119. package/backend/dist/cjs/backend/src/view.d.ts +115 -0
  120. package/backend/dist/cjs/backend/src/view.js +519 -0
  121. package/backend/dist/cjs/backend/src/vinc.d.ts +6 -0
  122. package/backend/dist/cjs/backend/src/vinc.js +40 -0
  123. package/backend/dist/cjs/backend/src/volt.d.ts +24 -0
  124. package/backend/dist/cjs/backend/src/volt.js +72 -0
  125. package/backend/dist/cjs/frontend/src/modules/request.d.ts +70 -0
  126. package/backend/dist/cjs/frontend/src/modules/request.js +99 -0
  127. package/backend/dist/cjs/package.json +1 -0
  128. package/backend/dist/esm/backend/src/blacklist.d.ts +12 -0
  129. package/backend/dist/esm/backend/src/blacklist.js +52 -0
  130. package/backend/dist/esm/backend/src/cli.d.ts +2 -0
  131. package/backend/dist/esm/backend/src/cli.js +211 -0
  132. package/backend/dist/esm/backend/src/database/collection.d.ts +1765 -0
  133. package/backend/dist/esm/backend/src/database/collection.js +3779 -0
  134. package/backend/dist/esm/backend/src/database/database.d.ts +92 -0
  135. package/backend/dist/esm/backend/src/database/database.js +214 -0
  136. package/backend/dist/esm/backend/src/database/document.d.ts +1 -0
  137. package/backend/dist/esm/backend/src/database/document.js +558 -0
  138. package/backend/dist/esm/backend/src/database/filters/filters.d.ts +6 -0
  139. package/backend/dist/esm/backend/src/database/filters/filters.js +1 -0
  140. package/backend/dist/esm/backend/src/database/filters/strict_filter.d.ts +223 -0
  141. package/backend/dist/esm/backend/src/database/filters/strict_filter.js +3 -0
  142. package/backend/dist/esm/backend/src/database/filters/strict_filter_test.d.ts +1 -0
  143. package/backend/dist/esm/backend/src/database/filters/strict_filter_test.js +505 -0
  144. package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.d.ts +1 -0
  145. package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.js +712 -0
  146. package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
  147. package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.js +5 -0
  148. package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
  149. package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.js +44 -0
  150. package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
  151. package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.js +5 -0
  152. package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
  153. package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.js +1 -0
  154. package/backend/dist/esm/backend/src/database/filters/strict_update_filter.d.ts +165 -0
  155. package/backend/dist/esm/backend/src/database/filters/strict_update_filter.js +5 -0
  156. package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
  157. package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.js +415 -0
  158. package/backend/dist/esm/backend/src/database/flatten.d.ts +78 -0
  159. package/backend/dist/esm/backend/src/database/flatten.js +22 -0
  160. package/backend/dist/esm/backend/src/database/flatten_test.d.ts +1 -0
  161. package/backend/dist/esm/backend/src/database/flatten_test.js +174 -0
  162. package/backend/dist/esm/backend/src/database/quota/quoata_v2.d.ts +533 -0
  163. package/backend/dist/esm/backend/src/database/quota/quoata_v2.js +1155 -0
  164. package/backend/dist/esm/backend/src/database/quota/quota.d.ts +551 -0
  165. package/backend/dist/esm/backend/src/database/quota/quota.js +1219 -0
  166. package/backend/dist/esm/backend/src/database/quota/quota_v1.d.ts +534 -0
  167. package/backend/dist/esm/backend/src/database/quota/quota_v1.js +1242 -0
  168. package/backend/dist/esm/backend/src/database/quota/safe_int.d.ts +412 -0
  169. package/backend/dist/esm/backend/src/database/quota/safe_int.js +810 -0
  170. package/backend/dist/esm/backend/src/endpoint.d.ts +346 -0
  171. package/backend/dist/esm/backend/src/endpoint.js +479 -0
  172. package/backend/dist/esm/backend/src/errors/index.d.ts +7 -0
  173. package/backend/dist/esm/backend/src/errors/index.js +7 -0
  174. package/backend/dist/esm/backend/src/errors/internal_external.d.ts +52 -0
  175. package/backend/dist/esm/backend/src/errors/internal_external.js +86 -0
  176. package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +41 -0
  177. package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +33 -0
  178. package/backend/dist/esm/backend/src/errors/system_error.d.ts +261 -0
  179. package/backend/dist/esm/backend/src/errors/system_error.js +444 -0
  180. package/backend/dist/esm/backend/src/events.d.ts +97 -0
  181. package/backend/dist/esm/backend/src/events.js +5 -0
  182. package/backend/dist/esm/backend/src/frontend.d.ts +13 -0
  183. package/backend/dist/esm/backend/src/frontend.js +23 -0
  184. package/backend/dist/esm/backend/src/image_endpoint.d.ts +44 -0
  185. package/backend/dist/esm/backend/src/image_endpoint.js +196 -0
  186. package/backend/dist/esm/backend/src/index.d.ts +23 -0
  187. package/backend/dist/esm/backend/src/index.js +26 -0
  188. package/backend/dist/esm/backend/src/logger.d.ts +5 -0
  189. package/backend/dist/esm/backend/src/logger.js +8 -0
  190. package/backend/dist/esm/backend/src/meta.d.ts +112 -0
  191. package/backend/dist/esm/backend/src/meta.js +152 -0
  192. package/backend/dist/esm/backend/src/payments/paddle.d.ts +329 -0
  193. package/backend/dist/esm/backend/src/payments/paddle.js +2276 -0
  194. package/backend/dist/esm/backend/src/payments/stripe/checkout.d.ts +113 -0
  195. package/backend/dist/esm/backend/src/payments/stripe/checkout.js +356 -0
  196. package/backend/dist/esm/backend/src/payments/stripe/customers.d.ts +17 -0
  197. package/backend/dist/esm/backend/src/payments/stripe/customers.js +193 -0
  198. package/backend/dist/esm/backend/src/payments/stripe/error.d.ts +74 -0
  199. package/backend/dist/esm/backend/src/payments/stripe/error.js +51 -0
  200. package/backend/dist/esm/backend/src/payments/stripe/events.d.ts +155 -0
  201. package/backend/dist/esm/backend/src/payments/stripe/events.js +5 -0
  202. package/backend/dist/esm/backend/src/payments/stripe/meters.d.ts +105 -0
  203. package/backend/dist/esm/backend/src/payments/stripe/meters.js +318 -0
  204. package/backend/dist/esm/backend/src/payments/stripe/payment_methods.d.ts +58 -0
  205. package/backend/dist/esm/backend/src/payments/stripe/payment_methods.js +135 -0
  206. package/backend/dist/esm/backend/src/payments/stripe/products.d.ts +519 -0
  207. package/backend/dist/esm/backend/src/payments/stripe/products.js +896 -0
  208. package/backend/dist/esm/backend/src/payments/stripe/stripe.d.ts +215 -0
  209. package/backend/dist/esm/backend/src/payments/stripe/stripe.js +464 -0
  210. package/backend/dist/esm/backend/src/payments/stripe/subscriptions.d.ts +172 -0
  211. package/backend/dist/esm/backend/src/payments/stripe/subscriptions.js +754 -0
  212. package/backend/dist/esm/backend/src/payments/stripe/utils.d.ts +63 -0
  213. package/backend/dist/esm/backend/src/payments/stripe/utils.js +131 -0
  214. package/backend/dist/esm/backend/src/payments/stripe/webhooks.d.ts +105 -0
  215. package/backend/dist/esm/backend/src/payments/stripe/webhooks.js +752 -0
  216. package/backend/dist/esm/backend/src/plugins/browser.d.ts +1 -0
  217. package/backend/dist/esm/backend/src/plugins/browser.js +170 -0
  218. package/backend/dist/esm/backend/src/plugins/communication.d.ts +70 -0
  219. package/backend/dist/esm/backend/src/plugins/communication.js +169 -0
  220. package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +255 -0
  221. package/backend/dist/esm/backend/src/plugins/mail/mail.js +396 -0
  222. package/backend/dist/esm/backend/src/plugins/mail/ui.d.ts +297 -0
  223. package/backend/dist/esm/backend/src/plugins/mail/ui.js +1400 -0
  224. package/backend/dist/esm/backend/src/plugins/pdf.d.ts +1 -0
  225. package/backend/dist/esm/backend/src/plugins/pdf.js +1694 -0
  226. package/backend/dist/esm/backend/src/plugins/thread_monitor.d.ts +18 -0
  227. package/backend/dist/esm/backend/src/plugins/thread_monitor.js +120 -0
  228. package/backend/dist/esm/backend/src/rate_limit.d.ts +148 -0
  229. package/backend/dist/esm/backend/src/rate_limit.js +667 -0
  230. package/backend/dist/esm/backend/src/route.d.ts +39 -0
  231. package/backend/dist/esm/backend/src/route.js +222 -0
  232. package/backend/dist/esm/backend/src/server.d.ts +502 -0
  233. package/backend/dist/esm/backend/src/server.js +2031 -0
  234. package/backend/dist/esm/backend/src/server.old.d.ts +594 -0
  235. package/backend/dist/esm/backend/src/server.old.js +2630 -0
  236. package/backend/dist/esm/backend/src/splash_screen.d.ts +93 -0
  237. package/backend/dist/esm/backend/src/splash_screen.js +156 -0
  238. package/backend/dist/esm/backend/src/status.d.ts +89 -0
  239. package/backend/dist/esm/backend/src/status.js +213 -0
  240. package/backend/dist/esm/backend/src/stream.d.ts +494 -0
  241. package/backend/dist/esm/backend/src/stream.js +1611 -0
  242. package/backend/dist/esm/backend/src/users.d.ts +926 -0
  243. package/backend/dist/esm/backend/src/users.js +2423 -0
  244. package/backend/dist/esm/backend/src/utils.d.ts +22 -0
  245. package/backend/dist/esm/backend/src/utils.js +463 -0
  246. package/backend/dist/esm/backend/src/view.d.ts +115 -0
  247. package/backend/dist/esm/backend/src/view.js +584 -0
  248. package/backend/dist/esm/backend/src/vinc.d.ts +6 -0
  249. package/backend/dist/esm/backend/src/vinc.js +6 -0
  250. package/backend/dist/esm/backend/src/volt.d.ts +24 -0
  251. package/backend/dist/esm/backend/src/volt.js +27 -0
  252. package/backend/dist/esm/frontend/src/modules/request.d.ts +70 -0
  253. package/backend/dist/esm/frontend/src/modules/request.js +117 -0
  254. package/frontend/dist/backend/src/database/collection.d.ts +1765 -0
  255. package/frontend/dist/backend/src/database/collection.js +3779 -0
  256. package/frontend/dist/backend/src/database/database.d.ts +92 -0
  257. package/frontend/dist/backend/src/database/database.js +214 -0
  258. package/frontend/dist/backend/src/database/filters/filters.d.ts +6 -0
  259. package/frontend/dist/backend/src/database/filters/filters.js +1 -0
  260. package/frontend/dist/backend/src/database/filters/strict_filter.d.ts +223 -0
  261. package/frontend/dist/backend/src/database/filters/strict_filter.js +3 -0
  262. package/frontend/dist/backend/src/database/filters/strict_update_filter.d.ts +165 -0
  263. package/frontend/dist/backend/src/database/filters/strict_update_filter.js +5 -0
  264. package/frontend/dist/backend/src/database/flatten.d.ts +78 -0
  265. package/frontend/dist/backend/src/database/flatten.js +22 -0
  266. package/frontend/dist/backend/src/endpoint.d.ts +346 -0
  267. package/frontend/dist/backend/src/endpoint.js +479 -0
  268. package/frontend/dist/backend/src/errors/index.d.ts +7 -0
  269. package/frontend/dist/backend/src/errors/index.js +7 -0
  270. package/frontend/dist/backend/src/errors/internal_external.d.ts +52 -0
  271. package/frontend/dist/backend/src/errors/internal_external.js +86 -0
  272. package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +41 -0
  273. package/frontend/dist/backend/src/errors/invalid_usage_error.js +33 -0
  274. package/frontend/dist/backend/src/errors/system_error.d.ts +261 -0
  275. package/frontend/dist/backend/src/errors/system_error.js +444 -0
  276. package/frontend/dist/backend/src/events.d.ts +97 -0
  277. package/frontend/dist/backend/src/events.js +5 -0
  278. package/frontend/dist/backend/src/frontend.d.ts +13 -0
  279. package/frontend/dist/backend/src/frontend.js +23 -0
  280. package/frontend/dist/backend/src/image_endpoint.d.ts +44 -0
  281. package/frontend/dist/backend/src/image_endpoint.js +196 -0
  282. package/frontend/dist/backend/src/meta.d.ts +112 -0
  283. package/frontend/dist/backend/src/meta.js +152 -0
  284. package/frontend/dist/backend/src/payments/paddle.d.ts +329 -0
  285. package/frontend/dist/backend/src/payments/paddle.js +2276 -0
  286. package/frontend/dist/backend/src/payments/stripe/checkout.d.ts +113 -0
  287. package/frontend/dist/backend/src/payments/stripe/checkout.js +356 -0
  288. package/frontend/dist/backend/src/payments/stripe/customers.d.ts +17 -0
  289. package/frontend/dist/backend/src/payments/stripe/customers.js +193 -0
  290. package/frontend/dist/backend/src/payments/stripe/error.d.ts +74 -0
  291. package/frontend/dist/backend/src/payments/stripe/error.js +51 -0
  292. package/frontend/dist/backend/src/payments/stripe/events.d.ts +155 -0
  293. package/frontend/dist/backend/src/payments/stripe/events.js +5 -0
  294. package/frontend/dist/backend/src/payments/stripe/meters.d.ts +105 -0
  295. package/frontend/dist/backend/src/payments/stripe/meters.js +318 -0
  296. package/frontend/dist/backend/src/payments/stripe/payment_methods.d.ts +58 -0
  297. package/frontend/dist/backend/src/payments/stripe/payment_methods.js +135 -0
  298. package/frontend/dist/backend/src/payments/stripe/products.d.ts +519 -0
  299. package/frontend/dist/backend/src/payments/stripe/products.js +896 -0
  300. package/frontend/dist/backend/src/payments/stripe/stripe.d.ts +215 -0
  301. package/frontend/dist/backend/src/payments/stripe/stripe.js +464 -0
  302. package/frontend/dist/backend/src/payments/stripe/subscriptions.d.ts +172 -0
  303. package/frontend/dist/backend/src/payments/stripe/subscriptions.js +754 -0
  304. package/frontend/dist/backend/src/payments/stripe/utils.d.ts +63 -0
  305. package/frontend/dist/backend/src/payments/stripe/utils.js +131 -0
  306. package/frontend/dist/backend/src/payments/stripe/webhooks.d.ts +105 -0
  307. package/frontend/dist/backend/src/payments/stripe/webhooks.js +752 -0
  308. package/frontend/dist/backend/src/plugins/mail/mail.d.ts +255 -0
  309. package/frontend/dist/backend/src/plugins/mail/mail.js +396 -0
  310. package/frontend/dist/backend/src/plugins/mail/ui.d.ts +297 -0
  311. package/frontend/dist/backend/src/plugins/mail/ui.js +1400 -0
  312. package/frontend/dist/backend/src/rate_limit.d.ts +148 -0
  313. package/frontend/dist/backend/src/rate_limit.js +667 -0
  314. package/frontend/dist/backend/src/route.d.ts +39 -0
  315. package/frontend/dist/backend/src/route.js +222 -0
  316. package/frontend/dist/backend/src/server.d.ts +502 -0
  317. package/frontend/dist/backend/src/server.js +2031 -0
  318. package/frontend/dist/backend/src/splash_screen.d.ts +93 -0
  319. package/frontend/dist/backend/src/splash_screen.js +156 -0
  320. package/frontend/dist/backend/src/status.d.ts +89 -0
  321. package/frontend/dist/backend/src/status.js +213 -0
  322. package/frontend/dist/backend/src/stream.d.ts +494 -0
  323. package/frontend/dist/backend/src/stream.js +1611 -0
  324. package/frontend/dist/backend/src/users.d.ts +926 -0
  325. package/frontend/dist/backend/src/users.js +2423 -0
  326. package/frontend/dist/backend/src/utils.d.ts +22 -0
  327. package/frontend/dist/backend/src/utils.js +463 -0
  328. package/frontend/dist/backend/src/view.d.ts +115 -0
  329. package/frontend/dist/backend/src/view.js +584 -0
  330. package/frontend/dist/frontend/src/css/adyen.css +92 -0
  331. package/frontend/dist/frontend/src/css/volt.css +75 -0
  332. package/frontend/dist/frontend/src/elements/base.d.ts +3743 -0
  333. package/frontend/dist/frontend/src/elements/base.js +12151 -0
  334. package/frontend/dist/frontend/src/elements/module.d.ts +95 -0
  335. package/frontend/dist/frontend/src/elements/module.js +216 -0
  336. package/frontend/dist/frontend/src/elements/register_element.d.ts +3 -0
  337. package/frontend/dist/frontend/src/elements/register_element.js +22 -0
  338. package/frontend/dist/frontend/src/elements/resize_query_manager.d.ts +0 -0
  339. package/frontend/dist/frontend/src/elements/resize_query_manager.js +150 -0
  340. package/frontend/dist/frontend/src/elements/types.d.ts +52 -0
  341. package/frontend/dist/frontend/src/elements/types.js +5 -0
  342. package/frontend/dist/frontend/src/index.d.ts +21 -0
  343. package/frontend/dist/frontend/src/index.js +29 -0
  344. package/frontend/dist/frontend/src/modules/attachment.d.ts +126 -0
  345. package/frontend/dist/frontend/src/modules/attachment.js +306 -0
  346. package/frontend/dist/frontend/src/modules/auth.d.ts +44 -0
  347. package/frontend/dist/frontend/src/modules/auth.js +80 -0
  348. package/frontend/dist/frontend/src/modules/color.d.ts +160 -0
  349. package/frontend/dist/frontend/src/modules/color.js +316 -0
  350. package/frontend/dist/frontend/src/modules/compression.d.ts +39 -0
  351. package/frontend/dist/frontend/src/modules/compression.js +102 -0
  352. package/frontend/dist/frontend/src/modules/cookies.d.ts +44 -0
  353. package/frontend/dist/frontend/src/modules/cookies.js +143 -0
  354. package/frontend/dist/frontend/src/modules/events.d.ts +31 -0
  355. package/frontend/dist/frontend/src/modules/events.js +79 -0
  356. package/frontend/dist/frontend/src/modules/google.d.ts +23 -0
  357. package/frontend/dist/frontend/src/modules/google.js +52 -0
  358. package/frontend/dist/frontend/src/modules/meta.d.ts +14 -0
  359. package/frontend/dist/frontend/src/modules/meta.js +48 -0
  360. package/frontend/dist/frontend/src/modules/paddle.d.ts +1207 -0
  361. package/frontend/dist/frontend/src/modules/paddle.js +2594 -0
  362. package/frontend/dist/frontend/src/modules/request.d.ts +70 -0
  363. package/frontend/dist/frontend/src/modules/request.js +117 -0
  364. package/frontend/dist/frontend/src/modules/settings.d.ts +3 -0
  365. package/frontend/dist/frontend/src/modules/settings.js +5 -0
  366. package/frontend/dist/frontend/src/modules/statics.d.ts +21 -0
  367. package/frontend/dist/frontend/src/modules/statics.js +43 -0
  368. package/frontend/dist/frontend/src/modules/stripe/cart.d.ts +112 -0
  369. package/frontend/dist/frontend/src/modules/stripe/cart.js +321 -0
  370. package/frontend/dist/frontend/src/modules/stripe/checkout.d.ts +7 -0
  371. package/frontend/dist/frontend/src/modules/stripe/checkout.js +37 -0
  372. package/frontend/dist/frontend/src/modules/stripe/index.m.d.ts +6 -0
  373. package/frontend/dist/frontend/src/modules/stripe/index.m.js +6 -0
  374. package/frontend/dist/frontend/src/modules/stripe/payments.d.ts +58 -0
  375. package/frontend/dist/frontend/src/modules/stripe/payments.js +92 -0
  376. package/frontend/dist/frontend/src/modules/support.d.ts +30 -0
  377. package/frontend/dist/frontend/src/modules/support.js +53 -0
  378. package/frontend/dist/frontend/src/modules/theme.d.ts +133 -0
  379. package/frontend/dist/frontend/src/modules/theme.js +406 -0
  380. package/frontend/dist/frontend/src/modules/themes.d.ts +12 -0
  381. package/frontend/dist/frontend/src/modules/themes.js +22 -0
  382. package/frontend/dist/frontend/src/modules/user.d.ts +164 -0
  383. package/frontend/dist/frontend/src/modules/user.js +270 -0
  384. package/frontend/dist/frontend/src/modules/utils.d.ts +176 -0
  385. package/frontend/dist/frontend/src/modules/utils.js +569 -0
  386. package/frontend/dist/frontend/src/types/gradient.d.ts +29 -0
  387. package/frontend/dist/frontend/src/types/gradient.js +79 -0
  388. package/frontend/dist/frontend/src/ui/border_button.d.ts +94 -0
  389. package/frontend/dist/frontend/src/ui/border_button.js +228 -0
  390. package/frontend/dist/frontend/src/ui/button.d.ts +241 -0
  391. package/frontend/dist/frontend/src/ui/button.js +682 -0
  392. package/frontend/dist/frontend/src/ui/canvas.d.ts +138 -0
  393. package/frontend/dist/frontend/src/ui/canvas.js +444 -0
  394. package/frontend/dist/frontend/src/ui/checkbox.d.ts +74 -0
  395. package/frontend/dist/frontend/src/ui/checkbox.js +321 -0
  396. package/frontend/dist/frontend/src/ui/code.d.ts +235 -0
  397. package/frontend/dist/frontend/src/ui/code.js +1007 -0
  398. package/frontend/dist/frontend/src/ui/context_menu.d.ts +36 -0
  399. package/frontend/dist/frontend/src/ui/context_menu.js +205 -0
  400. package/frontend/dist/frontend/src/ui/css.d.ts +16 -0
  401. package/frontend/dist/frontend/src/ui/css.js +48 -0
  402. package/frontend/dist/frontend/src/ui/divider.d.ts +15 -0
  403. package/frontend/dist/frontend/src/ui/divider.js +78 -0
  404. package/frontend/dist/frontend/src/ui/dropdown.d.ts +176 -0
  405. package/frontend/dist/frontend/src/ui/dropdown.js +481 -0
  406. package/frontend/dist/frontend/src/ui/for_each.d.ts +37 -0
  407. package/frontend/dist/frontend/src/ui/for_each.js +92 -0
  408. package/frontend/dist/frontend/src/ui/form.d.ts +34 -0
  409. package/frontend/dist/frontend/src/ui/form.js +233 -0
  410. package/frontend/dist/frontend/src/ui/frame_modes.d.ts +37 -0
  411. package/frontend/dist/frontend/src/ui/frame_modes.js +108 -0
  412. package/frontend/dist/frontend/src/ui/google_map.d.ts +24 -0
  413. package/frontend/dist/frontend/src/ui/google_map.js +106 -0
  414. package/frontend/dist/frontend/src/ui/gradient.d.ts +25 -0
  415. package/frontend/dist/frontend/src/ui/gradient.js +131 -0
  416. package/frontend/dist/frontend/src/ui/image.d.ts +111 -0
  417. package/frontend/dist/frontend/src/ui/image.js +576 -0
  418. package/frontend/dist/frontend/src/ui/input.d.ts +392 -0
  419. package/frontend/dist/frontend/src/ui/input.js +1201 -0
  420. package/frontend/dist/frontend/src/ui/link.d.ts +25 -0
  421. package/frontend/dist/frontend/src/ui/link.js +140 -0
  422. package/frontend/dist/frontend/src/ui/list.d.ts +37 -0
  423. package/frontend/dist/frontend/src/ui/list.js +170 -0
  424. package/frontend/dist/frontend/src/ui/loader_button.d.ts +80 -0
  425. package/frontend/dist/frontend/src/ui/loader_button.js +193 -0
  426. package/frontend/dist/frontend/src/ui/loaders.d.ts +57 -0
  427. package/frontend/dist/frontend/src/ui/loaders.js +157 -0
  428. package/frontend/dist/frontend/src/ui/popup.d.ts +94 -0
  429. package/frontend/dist/frontend/src/ui/popup.js +510 -0
  430. package/frontend/dist/frontend/src/ui/pseudo.d.ts +44 -0
  431. package/frontend/dist/frontend/src/ui/pseudo.js +154 -0
  432. package/frontend/dist/frontend/src/ui/scroller.d.ts +105 -0
  433. package/frontend/dist/frontend/src/ui/scroller.js +1253 -0
  434. package/frontend/dist/frontend/src/ui/slider.d.ts +45 -0
  435. package/frontend/dist/frontend/src/ui/slider.js +217 -0
  436. package/frontend/dist/frontend/src/ui/spacer.d.ts +15 -0
  437. package/frontend/dist/frontend/src/ui/spacer.js +78 -0
  438. package/frontend/dist/frontend/src/ui/span.d.ts +15 -0
  439. package/frontend/dist/frontend/src/ui/span.js +73 -0
  440. package/frontend/dist/frontend/src/ui/stack.d.ts +66 -0
  441. package/frontend/dist/frontend/src/ui/stack.js +335 -0
  442. package/frontend/dist/frontend/src/ui/steps.d.ts +131 -0
  443. package/frontend/dist/frontend/src/ui/steps.js +308 -0
  444. package/frontend/dist/frontend/src/ui/style.d.ts +17 -0
  445. package/frontend/dist/frontend/src/ui/style.js +73 -0
  446. package/frontend/dist/frontend/src/ui/switch.d.ts +69 -0
  447. package/frontend/dist/frontend/src/ui/switch.js +357 -0
  448. package/frontend/dist/frontend/src/ui/table.d.ts +100 -0
  449. package/frontend/dist/frontend/src/ui/table.js +405 -0
  450. package/frontend/dist/frontend/src/ui/tabs.d.ts +111 -0
  451. package/frontend/dist/frontend/src/ui/tabs.js +424 -0
  452. package/frontend/dist/frontend/src/ui/text.d.ts +15 -0
  453. package/frontend/dist/frontend/src/ui/text.js +83 -0
  454. package/frontend/dist/frontend/src/ui/title.d.ts +91 -0
  455. package/frontend/dist/frontend/src/ui/title.js +272 -0
  456. package/frontend/dist/frontend/src/ui/ui.d.ts +35 -0
  457. package/frontend/dist/frontend/src/ui/ui.js +38 -0
  458. package/frontend/dist/frontend/src/ui/view.d.ts +15 -0
  459. package/frontend/dist/frontend/src/ui/view.js +88 -0
  460. package/frontend/dist/frontend/src/volt.d.ts +20 -0
  461. package/frontend/dist/frontend/src/volt.js +27 -0
  462. package/package.json +7 -2
@@ -0,0 +1,215 @@
1
+ /**
2
+ * @author Daan van den Bergh
3
+ * @copyright © 2026 - 2026 Daan van den Bergh. All rights reserved
4
+ */
5
+ import StripeClient from "stripe";
6
+ import { InitializedMeterProduct, InitializedOneTimeProduct, InitializedProduct, InitializedSubscriptionPlan, InitializedSubscriptionProduct, MeterProduct, Product, ProductId, SubscriptionPlan, SubscriptionPlanId } from "./products.js";
7
+ import { SemiActiveSubscriptionStatus } from "./subscriptions.js";
8
+ import { Server } from "../../server.js";
9
+ import { CancelMeterUsageEventOpts, CancelMeterUsageEventResult, RecordMeterUsageOpts, RecordMeterUsageResult } from "./meters.js";
10
+ import { Request } from "../../../../frontend/src/modules/request.js";
11
+ import { CreatedCheckoutSession } from "./checkout.js";
12
+ /**
13
+ * The stripe payments class.
14
+ */
15
+ export declare class Stripe {
16
+ /** The payments type. */
17
+ type: "stripe";
18
+ /** The initialized stripe client. */
19
+ client: StripeClient;
20
+ /** The uninitialized products. */
21
+ raw_products: Product[];
22
+ /** The initialized stripe products. */
23
+ products: InitializedProduct[];
24
+ /** The parent server instance. */
25
+ server: Server;
26
+ /** The webhook signing secret. */
27
+ webhook_signing_secret?: string;
28
+ /** Constructs the Stripe payments instance. */
29
+ constructor(server: Server, opts: Stripe.Opts);
30
+ /**
31
+ * Initialize all endpoints.
32
+ * @note Should not be called when initialized as a worker.
33
+ */
34
+ private initialize_endpoints;
35
+ /**
36
+ * Initialize the stripe class.
37
+ */
38
+ initialize(opts: {
39
+ /**
40
+ * By default the server is initialized as web server.
41
+ *
42
+ * However, when using worker threads, the web server parts are skipped.
43
+ * Only essential operations such as database, users, payments etc. are initialized.
44
+ * Therefore the server can still be used within a worker threads without
45
+ * the overhead of creating http/https servers, endpoints, static files, etc.
46
+ *
47
+ * The user-defined initialize callbacks are still executed but the `worker` is passed as indication.
48
+ */
49
+ worker?: boolean;
50
+ }): Promise<void>;
51
+ /**
52
+ * A callback to delete a user from the payments provider when the user is deleted from our system.
53
+ */
54
+ delete_user(uid: string): Promise<void>;
55
+ /**
56
+ * Get the stripe customer id for a given user id (uid), if a customer does
57
+ * not exist, it is automatically created and the new customer id is returned.
58
+ * @returns The stripe customer id.
59
+ */
60
+ ensure_stripe_customer(uid: string): Promise<string>;
61
+ /**
62
+ * Fetch an initialized product by its id.
63
+ * @throws {InternalStripeError} When the product is not found.
64
+ */
65
+ get_product(product_id: ProductId): InitializedProduct;
66
+ /**
67
+ * Fetch an initialized subscription or subscription plan by its id.
68
+ * @throws {InternalStripeError} When the product is not found.
69
+ */
70
+ get_subscription_or_plan(product_or_plan_id: ProductId | SubscriptionPlanId): InitializedSubscriptionProduct | InitializedSubscriptionPlan;
71
+ /**
72
+ * Get a one-time product by its id.
73
+ * @throws {InternalStripeError} When the product is not found or is not a one-time product.
74
+ */
75
+ get_one_time_product(product_id: ProductId): InitializedOneTimeProduct;
76
+ /**
77
+ * Get a subscription product by its id.
78
+ * @throws {InternalStripeError} When the product is not found or is not a subscription product.
79
+ */
80
+ get_subscription_product(product_id: ProductId): InitializedSubscriptionProduct;
81
+ /**
82
+ * Get a subscription plan by its id.
83
+ * @throws {InternalStripeError} When the plan is not found.
84
+ */
85
+ get_subscription_plan(plan_id: SubscriptionPlanId): InitializedSubscriptionPlan;
86
+ /**
87
+ * Resolve a subscription plan to its parent subscription product.
88
+ * @throws {InternalStripeError} When the plan or parent subscription is not found.
89
+ */
90
+ get_subscription_product_by_plan(plan: SubscriptionPlanId | SubscriptionPlan): InitializedSubscriptionProduct;
91
+ /**
92
+ * Get a meter product by its id.
93
+ * @throws {InternalStripeError} When the product is not found or is not a meter product.
94
+ */
95
+ get_meter_product(product_id: ProductId): InitializedMeterProduct;
96
+ /**
97
+ * Check if a user is subscribed to a subscription (plan).
98
+ * @returns `true` if the user has an active subscription to the plan or subscription product, `false` otherwise.
99
+ */
100
+ is_subscribed(opts: {
101
+ /** The user id */
102
+ uid: string;
103
+ /** The subcription (plan) or its id to check. */
104
+ plan: InitializedSubscriptionPlan | SubscriptionPlanId | InitializedMeterProduct | ProductId;
105
+ /** Only allow specific subscription statuses. */
106
+ status?: SemiActiveSubscriptionStatus[];
107
+ }): Promise<boolean>;
108
+ /**
109
+ * Fetch all active subscription plan id's for a user.
110
+ * @note
111
+ * Note that `trialing` and `past_due` subscriptions statuses are considered active,
112
+ * since Stripe can still attempt to pay those subscriptions and move them to `active` status.
113
+ * @returns An array of active subscription plan id's the user is subscribed to.
114
+ */
115
+ get_active_subscriptions<Status extends SemiActiveSubscriptionStatus = "active" | "trialing" | "past_due">(opts: {
116
+ /** The user id */
117
+ uid: string;
118
+ /** The optional subscription status to filter. */
119
+ status?: Status[];
120
+ }): Promise<Record<SubscriptionPlanId, Status>>;
121
+ /**
122
+ * Fetch all active meter subscription id's for a user.
123
+ * @note
124
+ * Note that only subscriptions with status `active` are considered active here,
125
+ * not `trialing` and `past_due`.
126
+ * This is to reduce risk of abusing meter products since they can be used in a pay-as-you-go manner without upfront commitment.
127
+ *
128
+ * @returns An array of active subscription plan id's the user is subscribed to.
129
+ */
130
+ get_active_meters<Status extends SemiActiveSubscriptionStatus = "active">(opts: {
131
+ /** The user id */
132
+ uid: string;
133
+ /** The optional subscription status to filter. */
134
+ status?: Status[];
135
+ }): Promise<Record<ProductId, Status>>;
136
+ /**
137
+ * Cancel a user's subscription to a plan.
138
+ * @warning This will cancel all of the user's subscriptions containing the plan's price id, use with caution.
139
+ * @warning This will cancel the entire subscription containing the plan, even if the subscription contains multiple plans.
140
+ * However, during checkout its not allowed to checkout multiple subscription plans, therefore this should not be an issue.
141
+ */
142
+ cancel_subscription(opts: {
143
+ /** The user id (uid) to cancel the subscription for. */
144
+ uid: string;
145
+ /** The specific plan to cancel (cancels subscriptions containing this plan price id). */
146
+ plan: InitializedSubscriptionPlan;
147
+ /** Whether to cancel at period end (default true). */
148
+ cancel_at_period_end?: boolean;
149
+ }): Promise<void>;
150
+ /**
151
+ * Record usage for a meter product.
152
+ */
153
+ record_meter_usage<Kind extends MeterProduct.Kind>(opts: RecordMeterUsageOpts<Kind>): Promise<RecordMeterUsageResult>;
154
+ /**
155
+ * Cancel a previously recorded meter usage event by its identifier (best-effort within 24 hours).
156
+ */
157
+ cancel_meter_usage_event(opts: CancelMeterUsageEventOpts): Promise<CancelMeterUsageEventResult>;
158
+ }
159
+ /** Nested types for the {@link Stripe} class. */
160
+ export declare namespace Stripe {
161
+ /** The user facing options for initializing the Stripe class. */
162
+ interface Opts {
163
+ /** The stripe API key. */
164
+ api_key: string;
165
+ /** The stripe products. */
166
+ products: Product[];
167
+ }
168
+ /** The types for the frontend endpoints. */
169
+ namespace Endpoints {
170
+ /** Get all (non-initialized) products. */
171
+ type GetProducts = Request.Info<"GET", "/volt/api/stripe/v1/products", undefined, {
172
+ products: Product[];
173
+ }, undefined>;
174
+ /** Get subscriptions of a user. */
175
+ type GetSubscriptions = Request.Info<"GET", "/volt/api/stripe/v1/subscriptions", undefined, {
176
+ subscriptions: {
177
+ product: InitializedSubscriptionProduct;
178
+ plan: InitializedSubscriptionPlan;
179
+ }[];
180
+ }, undefined>;
181
+ /** Get meter subscriptions of a user. */
182
+ type GetMeterSubscriptions = Request.Info<"GET", "/volt/api/stripe/v1/subscriptions/meters", undefined, {
183
+ meters: InitializedMeterProduct[];
184
+ }, undefined>;
185
+ /** Cancel a user subscription. */
186
+ type CancelSubscription = Request.Info<"DELETE", "/volt/api/stripe/v1/subscriptions", {
187
+ /** The subscription plan id to cancel. */
188
+ plan: SubscriptionPlanId;
189
+ /** Whether to cancel at period end (default true), or immediately. */
190
+ cancel_at_period_end?: boolean;
191
+ }, {}, undefined>;
192
+ /** Create checkout session id. */
193
+ type CreateCheckoutSessionId = Request.Info<"POST", "/volt/api/stripe/v1/checkout/session_id", undefined, {
194
+ session_id: string;
195
+ }, undefined>;
196
+ /** Start checkout session./ */
197
+ type StartCheckoutSession = Request.Info<"POST", "/volt/api/stripe/v1/checkout/session", {
198
+ /** The checkout session id generated by `create_checkout_session_id`. */
199
+ session_id: string;
200
+ /** The product or subscription plan id to checkout. */
201
+ line_items: {
202
+ /** The product or subscription plan to checkout. */
203
+ product: ProductId | SubscriptionPlanId;
204
+ /** The quantity to checkout (default 1). */
205
+ quantity: number;
206
+ }[];
207
+ /** Where Stripe should redirect after successful payment. */
208
+ success_url: string;
209
+ /** Where Stripe should redirect when the customer cancels. */
210
+ cancel_url: string;
211
+ /** Require tax id collection (useful for B2B in EU). */
212
+ tax_id_collection_enabled: boolean;
213
+ }, CreatedCheckoutSession, undefined>;
214
+ }
215
+ }
@@ -0,0 +1,464 @@
1
+ /**
2
+ * @author Daan van den Bergh
3
+ * @copyright © 2026 - 2026 Daan van den Bergh. All rights reserved
4
+ */
5
+ import StripeClient from "stripe";
6
+ import { delete_stripe_customer, ensure_stripe_customer } from "./customers.js";
7
+ import { initialize_products } from "./products.js";
8
+ import { assert } from "./utils.js";
9
+ import { cancel_user_subscription, delete_subscription_caches, is_user_subscribed_to, list_subscribed_meters, list_subscribed_plans } from "./subscriptions.js";
10
+ import { handle_stripe_webhook, register_or_update_stripe_webhook_endpoint } from "./webhooks.js";
11
+ import { cancel_meter_usage_event, record_meter_usage } from "./meters.js";
12
+ import { create_checkout_session_id, start_checkout_session } from "./checkout.js";
13
+ import { Endpoint } from "../../endpoint.js";
14
+ /**
15
+ * The stripe payments class.
16
+ */
17
+ export class Stripe {
18
+ /** The payments type. */
19
+ type = "stripe";
20
+ /** The initialized stripe client. */
21
+ client;
22
+ /** The uninitialized products. */
23
+ raw_products;
24
+ /** The initialized stripe products. */
25
+ products = [];
26
+ /** The parent server instance. */
27
+ server;
28
+ /** The webhook signing secret. */
29
+ webhook_signing_secret;
30
+ /** Constructs the Stripe payments instance. */
31
+ constructor(server, opts) {
32
+ this.raw_products = opts.products;
33
+ this.server = server;
34
+ this.client = new StripeClient(opts.api_key, {
35
+ typescript: true,
36
+ maxNetworkRetries: 5,
37
+ });
38
+ }
39
+ // -------------------------------------------------------------------------
40
+ // Private methods.
41
+ /**
42
+ * Initialize all endpoints.
43
+ * @note Should not be called when initialized as a worker.
44
+ */
45
+ async initialize_endpoints() {
46
+ // Create the webhook endpoint.
47
+ this.server.endpoint({
48
+ method: "POST",
49
+ endpoint: "/volt/api/stripe/webhook",
50
+ allow_unknown_params: true,
51
+ callback: async (stream) => {
52
+ // Ensure the request body is fully received.
53
+ await stream.join();
54
+ // Ensure we have the signing secret (set during initialize()).
55
+ if (!this.webhook_signing_secret) {
56
+ stream.error({
57
+ status: 500,
58
+ type: "stripe_webhook_not_initialized",
59
+ message: "Stripe webhook signing secret is not initialized.",
60
+ });
61
+ return;
62
+ }
63
+ // Stripe-Signature header (Node normalizes to lowercase).
64
+ const stripe_signature_header = stream.headers["stripe-signature"];
65
+ if (typeof stripe_signature_header !== "string" || stripe_signature_header.length === 0) {
66
+ stream.error({
67
+ status: 400,
68
+ type: "invalid_argument",
69
+ message: "Missing Stripe-Signature header.",
70
+ });
71
+ return;
72
+ }
73
+ // Handle the webhook.
74
+ await handle_stripe_webhook(this.client, {
75
+ server: this.server,
76
+ stream,
77
+ webhook_signing_secret: this.webhook_signing_secret,
78
+ // use wire body instead of raw body since we need the wired body for signature verification.
79
+ raw_body: stream.wire_body,
80
+ stripe_signature_header,
81
+ all_products: this.products,
82
+ });
83
+ },
84
+ });
85
+ // ---------------------------------------------
86
+ // Products endpoints.
87
+ // Create a checkout session id.
88
+ this.server.endpoint({
89
+ method: Endpoint.method("GET"),
90
+ endpoint: Endpoint.endpoint("/volt/api/stripe/v1/products"),
91
+ authenticated: false,
92
+ callback: async (stream) => {
93
+ return stream.send({
94
+ status: 200,
95
+ data: {
96
+ products: this.raw_products,
97
+ }
98
+ });
99
+ },
100
+ });
101
+ // ---------------------------------------------
102
+ // Subscriptions endpoints.
103
+ // Get subscriptions of a user.
104
+ this.server.endpoint({
105
+ method: Endpoint.method("GET"),
106
+ endpoint: Endpoint.endpoint("/volt/api/stripe/v1/subscriptions"),
107
+ authenticated: true,
108
+ callback: async (stream) => {
109
+ // Fetch all subscriptions.
110
+ const subs = await this.get_active_subscriptions({
111
+ uid: stream.uid,
112
+ });
113
+ const active_subs = [];
114
+ for (const plan_id of Object.keys(subs)) {
115
+ const plan = this.get_subscription_plan(plan_id);
116
+ const product = this.get_subscription_product_by_plan(plan);
117
+ active_subs.push({ product, plan, });
118
+ }
119
+ ;
120
+ return stream.send({
121
+ status: 200,
122
+ data: {
123
+ subscriptions: active_subs
124
+ }
125
+ });
126
+ },
127
+ });
128
+ // Get meter subscriptions of a user.
129
+ this.server.endpoint({
130
+ method: Endpoint.method("GET"),
131
+ endpoint: Endpoint.endpoint("/volt/api/stripe/v1/subscriptions/meters"),
132
+ authenticated: true,
133
+ callback: async (stream) => {
134
+ // Fetch all subscriptions.
135
+ const active = await this.get_active_meters({
136
+ uid: stream.uid,
137
+ });
138
+ const meters = [];
139
+ for (const product_id of Object.keys(active)) {
140
+ meters.push(this.get_meter_product(product_id));
141
+ }
142
+ return stream.send({
143
+ status: 200,
144
+ data: {
145
+ meters,
146
+ }
147
+ });
148
+ },
149
+ });
150
+ // Cancel subscription.
151
+ this.server.endpoint({
152
+ method: Endpoint.method("DELETE"),
153
+ endpoint: Endpoint.endpoint("/volt/api/stripe/v1/subscriptions"),
154
+ params: {
155
+ plan: "string",
156
+ cancel_at_period_end: { type: "boolean", default: true },
157
+ },
158
+ authenticated: true,
159
+ callback: async (stream, params) => {
160
+ // Fetch all subscriptions.
161
+ const res = await this.cancel_subscription({
162
+ uid: stream.uid,
163
+ plan: this.get_subscription_plan(params.plan),
164
+ cancel_at_period_end: params.cancel_at_period_end,
165
+ });
166
+ return stream.send({
167
+ status: 200,
168
+ data: {}
169
+ });
170
+ },
171
+ });
172
+ // ---------------------------------------------
173
+ // Checkout endpoints.
174
+ // Create a checkout session id.
175
+ this.server.endpoint({
176
+ method: Endpoint.method("POST"),
177
+ endpoint: Endpoint.endpoint("/volt/api/stripe/v1/checkout/session_id"),
178
+ authenticated: false,
179
+ callback: async (stream) => {
180
+ return stream.send({
181
+ status: 200,
182
+ data: {
183
+ session_id: create_checkout_session_id(stream.uid),
184
+ }
185
+ });
186
+ },
187
+ });
188
+ // Start a checkout session.
189
+ this.server.endpoint({
190
+ method: Endpoint.method("POST"),
191
+ endpoint: Endpoint.endpoint("/volt/api/stripe/v1/checkout/session"),
192
+ params: {
193
+ session_id: "string",
194
+ line_items: {
195
+ type: "array",
196
+ min: 1,
197
+ max: 50,
198
+ value_schema: {
199
+ type: "object",
200
+ schema: {
201
+ product: "string",
202
+ quantity: {
203
+ type: "number",
204
+ min: 1,
205
+ },
206
+ },
207
+ },
208
+ },
209
+ success_url: "string",
210
+ cancel_url: "string",
211
+ tax_id_collection_enabled: "boolean",
212
+ },
213
+ authenticated: false,
214
+ callback: async (stream, params) => {
215
+ const res = await start_checkout_session(this.client, this.server, {
216
+ uid: stream.uid,
217
+ session_id: params.session_id,
218
+ line_items: params.line_items,
219
+ success_url: params.success_url,
220
+ cancel_url: params.cancel_url,
221
+ tax_id_collection_enabled: params.tax_id_collection_enabled,
222
+ all_products: this.products,
223
+ allowed_hosts: undefined,
224
+ });
225
+ return stream.send({
226
+ status: 200,
227
+ data: res,
228
+ });
229
+ },
230
+ });
231
+ }
232
+ // -------------------------------------------------------------------------
233
+ // Initialization.
234
+ /**
235
+ * Initialize the stripe class.
236
+ */
237
+ async initialize(opts) {
238
+ // Initialize products.
239
+ this.products = await initialize_products(this.client, this.server, this.raw_products);
240
+ // Ensure the webhook is registered.
241
+ if (!opts.worker) {
242
+ if (this.server.https_enabled) {
243
+ const res = await register_or_update_stripe_webhook_endpoint(this.client, this.server, {
244
+ /**
245
+ * @warning
246
+ * Never change the webhook_id since this could break updating the webhook endpoint
247
+ * if the url / description etc changes.
248
+ */
249
+ webhook_app_id: "Volt.Stripe.Webhook",
250
+ webhook_url: `${this.server.full_domain}/volt/api/stripe/webhook`,
251
+ description: "The internal volt stripe payments webhook endpoint.",
252
+ ensure_enabled: true,
253
+ });
254
+ this.webhook_signing_secret = res.webhook_signing_secret;
255
+ }
256
+ // Initialize endpoints.
257
+ await this.initialize_endpoints();
258
+ }
259
+ }
260
+ // -------------------------------------------------------------------------
261
+ // Users API.
262
+ /**
263
+ * A callback to delete a user from the payments provider when the user is deleted from our system.
264
+ */
265
+ async delete_user(uid) {
266
+ await delete_stripe_customer(this.client, this.server, uid);
267
+ delete_subscription_caches(uid);
268
+ }
269
+ /**
270
+ * Get the stripe customer id for a given user id (uid), if a customer does
271
+ * not exist, it is automatically created and the new customer id is returned.
272
+ * @returns The stripe customer id.
273
+ */
274
+ async ensure_stripe_customer(uid) {
275
+ return await ensure_stripe_customer(this.client, this.server, uid);
276
+ }
277
+ // -------------------------------------------------------------------------
278
+ // Products API.
279
+ /**
280
+ * Fetch an initialized product by its id.
281
+ * @throws {InternalStripeError} When the product is not found.
282
+ */
283
+ get_product(product_id) {
284
+ const product = this.products.find((p) => p.id === product_id);
285
+ assert(product, "invalid_product", `Product with id '${product_id}' not found.`, { product_id });
286
+ return product;
287
+ }
288
+ /**
289
+ * Fetch an initialized subscription or subscription plan by its id.
290
+ * @throws {InternalStripeError} When the product is not found.
291
+ */
292
+ get_subscription_or_plan(product_or_plan_id) {
293
+ for (const product of this.products) {
294
+ if (product.type !== "subscription") {
295
+ continue;
296
+ }
297
+ if (product.id === product_or_plan_id) {
298
+ return product;
299
+ }
300
+ if (product.type === "subscription") {
301
+ const plan = product.plans.find((p) => p.id === product_or_plan_id);
302
+ if (plan) {
303
+ return product;
304
+ }
305
+ }
306
+ }
307
+ assert(false, "invalid_product", `Product or subscription plan with id '${product_or_plan_id}' not found.`, { product_id: product_or_plan_id });
308
+ }
309
+ /**
310
+ * Get a one-time product by its id.
311
+ * @throws {InternalStripeError} When the product is not found or is not a one-time product.
312
+ */
313
+ get_one_time_product(product_id) {
314
+ const product = this.get_product(product_id);
315
+ assert(product.type === "one_time", "invalid_product", `Product with id '${product_id}' is not a one-time product.`, { product_id, product_type: product.type });
316
+ return product;
317
+ }
318
+ /**
319
+ * Get a subscription product by its id.
320
+ * @throws {InternalStripeError} When the product is not found or is not a subscription product.
321
+ */
322
+ get_subscription_product(product_id) {
323
+ const product = this.get_product(product_id);
324
+ assert(product.type === "subscription", "invalid_product", `Product with id '${product_id}' is not a subscription product.`, { product_id, product_type: product.type });
325
+ return product;
326
+ }
327
+ /**
328
+ * Get a subscription plan by its id.
329
+ * @throws {InternalStripeError} When the plan is not found.
330
+ */
331
+ get_subscription_plan(plan_id) {
332
+ for (const product of this.products) {
333
+ if (product.type !== "subscription") {
334
+ continue;
335
+ }
336
+ const plan = product.plans.find((p) => p.id === plan_id);
337
+ if (plan) {
338
+ return plan;
339
+ }
340
+ }
341
+ assert(false, "invalid_product", `Subscription plan with id '${plan_id}' not found.`, { plan_id });
342
+ }
343
+ /**
344
+ * Resolve a subscription plan to its parent subscription product.
345
+ * @throws {InternalStripeError} When the plan or parent subscription is not found.
346
+ */
347
+ get_subscription_product_by_plan(plan) {
348
+ const plan_id = typeof plan === "string" ? plan : plan.id;
349
+ for (const product of this.products) {
350
+ if (product.type !== "subscription") {
351
+ continue;
352
+ }
353
+ const found_plan = product.plans.find((p) => p.id === plan_id);
354
+ if (found_plan) {
355
+ return product;
356
+ }
357
+ }
358
+ assert(false, "invalid_product", `Subscription plan with id '${plan_id}' not found.`, { plan_id });
359
+ }
360
+ /**
361
+ * Get a meter product by its id.
362
+ * @throws {InternalStripeError} When the product is not found or is not a meter product.
363
+ */
364
+ get_meter_product(product_id) {
365
+ const product = this.get_product(product_id);
366
+ assert(product.type === "meter", "invalid_product", `Product with id '${product_id}' is not a meter product.`, { product_id, product_type: product.type });
367
+ return product;
368
+ }
369
+ // -------------------------------------------------------------------------
370
+ // Subscriptions API.
371
+ /**
372
+ * Check if a user is subscribed to a subscription (plan).
373
+ * @returns `true` if the user has an active subscription to the plan or subscription product, `false` otherwise.
374
+ */
375
+ async is_subscribed(opts) {
376
+ let plan;
377
+ if (typeof opts.plan === "string") {
378
+ for (const product of this.products) {
379
+ if (product.type === "subscription") {
380
+ const found_plan = product.plans.find((p) => p.id === opts.plan);
381
+ if (found_plan) {
382
+ plan = found_plan;
383
+ break;
384
+ }
385
+ }
386
+ else if (product.type === "meter" && product.id === opts.plan) {
387
+ plan = product;
388
+ break;
389
+ }
390
+ }
391
+ }
392
+ else {
393
+ plan = opts.plan;
394
+ }
395
+ assert(plan, "invalid_argument", `Subscription plan or meter with id '${typeof opts.plan === "string" ? opts.plan : opts.plan.id}' not found.`, { plan_id: typeof opts.plan === "string" ? opts.plan : opts.plan.id });
396
+ return await is_user_subscribed_to(this.client, this.server, {
397
+ uid: opts.uid,
398
+ plan,
399
+ customer_id: undefined,
400
+ all_products: this.products,
401
+ status: opts.status,
402
+ });
403
+ }
404
+ /**
405
+ * Fetch all active subscription plan id's for a user.
406
+ * @note
407
+ * Note that `trialing` and `past_due` subscriptions statuses are considered active,
408
+ * since Stripe can still attempt to pay those subscriptions and move them to `active` status.
409
+ * @returns An array of active subscription plan id's the user is subscribed to.
410
+ */
411
+ async get_active_subscriptions(opts) {
412
+ return await list_subscribed_plans(this.client, this.server, {
413
+ uid: opts.uid,
414
+ customer_id: undefined,
415
+ all_products: this.products,
416
+ status: opts.status,
417
+ });
418
+ }
419
+ /**
420
+ * Fetch all active meter subscription id's for a user.
421
+ * @note
422
+ * Note that only subscriptions with status `active` are considered active here,
423
+ * not `trialing` and `past_due`.
424
+ * This is to reduce risk of abusing meter products since they can be used in a pay-as-you-go manner without upfront commitment.
425
+ *
426
+ * @returns An array of active subscription plan id's the user is subscribed to.
427
+ */
428
+ async get_active_meters(opts) {
429
+ return await list_subscribed_meters(this.client, this.server, {
430
+ uid: opts.uid,
431
+ stripe_customer_id: undefined,
432
+ all_products: this.products,
433
+ status: opts.status,
434
+ });
435
+ }
436
+ /**
437
+ * Cancel a user's subscription to a plan.
438
+ * @warning This will cancel all of the user's subscriptions containing the plan's price id, use with caution.
439
+ * @warning This will cancel the entire subscription containing the plan, even if the subscription contains multiple plans.
440
+ * However, during checkout its not allowed to checkout multiple subscription plans, therefore this should not be an issue.
441
+ */
442
+ async cancel_subscription(opts) {
443
+ await cancel_user_subscription(this.client, this.server, {
444
+ uid: opts.uid,
445
+ plan: opts.plan,
446
+ customer_id: undefined,
447
+ cancel_at_period_end: opts.cancel_at_period_end,
448
+ });
449
+ }
450
+ // -------------------------------------------------------------------------
451
+ // Meters API.
452
+ /**
453
+ * Record usage for a meter product.
454
+ */
455
+ async record_meter_usage(opts) {
456
+ return await record_meter_usage(this.client, this.server, this.products, opts);
457
+ }
458
+ /**
459
+ * Cancel a previously recorded meter usage event by its identifier (best-effort within 24 hours).
460
+ */
461
+ async cancel_meter_usage_event(opts) {
462
+ return await cancel_meter_usage_event(this.client, this.server, this.products, opts);
463
+ }
464
+ }