@qwickapps/server 1.3.1 → 1.5.0

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 (395) hide show
  1. package/README.md +157 -0
  2. package/dist/core/control-panel.d.ts.map +1 -1
  3. package/dist/core/control-panel.js +114 -0
  4. package/dist/core/control-panel.js.map +1 -1
  5. package/dist/core/types.d.ts +19 -0
  6. package/dist/core/types.d.ts.map +1 -1
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +15 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/plugins/auth/adapter-wrapper.d.ts +47 -0
  12. package/dist/plugins/auth/adapter-wrapper.d.ts.map +1 -0
  13. package/dist/plugins/auth/adapter-wrapper.js +166 -0
  14. package/dist/plugins/auth/adapter-wrapper.js.map +1 -0
  15. package/dist/plugins/auth/adapter-wrapper.test.d.ts +7 -0
  16. package/dist/plugins/auth/adapter-wrapper.test.d.ts.map +1 -0
  17. package/dist/plugins/auth/adapter-wrapper.test.js +303 -0
  18. package/dist/plugins/auth/adapter-wrapper.test.js.map +1 -0
  19. package/dist/plugins/auth/config-store.d.ts +11 -0
  20. package/dist/plugins/auth/config-store.d.ts.map +1 -0
  21. package/dist/plugins/auth/config-store.js +232 -0
  22. package/dist/plugins/auth/config-store.js.map +1 -0
  23. package/dist/plugins/auth/config-store.test.d.ts +7 -0
  24. package/dist/plugins/auth/config-store.test.d.ts.map +1 -0
  25. package/dist/plugins/auth/config-store.test.js +299 -0
  26. package/dist/plugins/auth/config-store.test.js.map +1 -0
  27. package/dist/plugins/auth/env-config.d.ts +51 -1
  28. package/dist/plugins/auth/env-config.d.ts.map +1 -1
  29. package/dist/plugins/auth/env-config.js +640 -7
  30. package/dist/plugins/auth/env-config.js.map +1 -1
  31. package/dist/plugins/auth/index.d.ts +6 -2
  32. package/dist/plugins/auth/index.d.ts.map +1 -1
  33. package/dist/plugins/auth/index.js +5 -1
  34. package/dist/plugins/auth/index.js.map +1 -1
  35. package/dist/plugins/auth/types.d.ts +106 -0
  36. package/dist/plugins/auth/types.d.ts.map +1 -1
  37. package/dist/plugins/bans/bans-plugin.d.ts.map +1 -1
  38. package/dist/plugins/bans/bans-plugin.js +12 -3
  39. package/dist/plugins/bans/bans-plugin.js.map +1 -1
  40. package/dist/plugins/devices/__tests__/devices-plugin.test.d.ts +11 -0
  41. package/dist/plugins/devices/__tests__/devices-plugin.test.d.ts.map +1 -0
  42. package/dist/plugins/devices/__tests__/devices-plugin.test.js +410 -0
  43. package/dist/plugins/devices/__tests__/devices-plugin.test.js.map +1 -0
  44. package/dist/plugins/devices/__tests__/token-utils.test.d.ts +7 -0
  45. package/dist/plugins/devices/__tests__/token-utils.test.d.ts.map +1 -0
  46. package/dist/plugins/devices/__tests__/token-utils.test.js +197 -0
  47. package/dist/plugins/devices/__tests__/token-utils.test.js.map +1 -0
  48. package/dist/plugins/devices/adapters/compute-adapter.d.ts +36 -0
  49. package/dist/plugins/devices/adapters/compute-adapter.d.ts.map +1 -0
  50. package/dist/plugins/devices/adapters/compute-adapter.js +100 -0
  51. package/dist/plugins/devices/adapters/compute-adapter.js.map +1 -0
  52. package/dist/plugins/devices/adapters/index.d.ts +12 -0
  53. package/dist/plugins/devices/adapters/index.d.ts.map +1 -0
  54. package/dist/plugins/devices/adapters/index.js +10 -0
  55. package/dist/plugins/devices/adapters/index.js.map +1 -0
  56. package/dist/plugins/devices/adapters/mobile-adapter.d.ts +41 -0
  57. package/dist/plugins/devices/adapters/mobile-adapter.d.ts.map +1 -0
  58. package/dist/plugins/devices/adapters/mobile-adapter.js +131 -0
  59. package/dist/plugins/devices/adapters/mobile-adapter.js.map +1 -0
  60. package/dist/plugins/devices/devices-plugin.d.ts +70 -0
  61. package/dist/plugins/devices/devices-plugin.d.ts.map +1 -0
  62. package/dist/plugins/devices/devices-plugin.js +453 -0
  63. package/dist/plugins/devices/devices-plugin.js.map +1 -0
  64. package/dist/plugins/devices/index.d.ts +18 -0
  65. package/dist/plugins/devices/index.d.ts.map +1 -0
  66. package/dist/plugins/devices/index.js +18 -0
  67. package/dist/plugins/devices/index.js.map +1 -0
  68. package/dist/plugins/devices/stores/index.d.ts +9 -0
  69. package/dist/plugins/devices/stores/index.d.ts.map +1 -0
  70. package/dist/plugins/devices/stores/index.js +9 -0
  71. package/dist/plugins/devices/stores/index.js.map +1 -0
  72. package/dist/plugins/devices/stores/postgres-store.d.ts +26 -0
  73. package/dist/plugins/devices/stores/postgres-store.d.ts.map +1 -0
  74. package/dist/plugins/devices/stores/postgres-store.js +199 -0
  75. package/dist/plugins/devices/stores/postgres-store.js.map +1 -0
  76. package/dist/plugins/devices/token-utils.d.ts +100 -0
  77. package/dist/plugins/devices/token-utils.d.ts.map +1 -0
  78. package/dist/plugins/devices/token-utils.js +162 -0
  79. package/dist/plugins/devices/token-utils.js.map +1 -0
  80. package/dist/plugins/devices/types.d.ts +307 -0
  81. package/dist/plugins/devices/types.d.ts.map +1 -0
  82. package/dist/plugins/devices/types.js +10 -0
  83. package/dist/plugins/devices/types.js.map +1 -0
  84. package/dist/plugins/index.d.ts +18 -4
  85. package/dist/plugins/index.d.ts.map +1 -1
  86. package/dist/plugins/index.js +16 -2
  87. package/dist/plugins/index.js.map +1 -1
  88. package/dist/plugins/notifications/__tests__/notifications-manager.test.d.ts +5 -0
  89. package/dist/plugins/notifications/__tests__/notifications-manager.test.d.ts.map +1 -0
  90. package/dist/plugins/notifications/__tests__/notifications-manager.test.js +470 -0
  91. package/dist/plugins/notifications/__tests__/notifications-manager.test.js.map +1 -0
  92. package/dist/plugins/notifications/index.d.ts +71 -0
  93. package/dist/plugins/notifications/index.d.ts.map +1 -0
  94. package/dist/plugins/notifications/index.js +72 -0
  95. package/dist/plugins/notifications/index.js.map +1 -0
  96. package/dist/plugins/notifications/notifications-manager.d.ts +182 -0
  97. package/dist/plugins/notifications/notifications-manager.d.ts.map +1 -0
  98. package/dist/plugins/notifications/notifications-manager.js +610 -0
  99. package/dist/plugins/notifications/notifications-manager.js.map +1 -0
  100. package/dist/plugins/notifications/notifications-plugin.d.ts +83 -0
  101. package/dist/plugins/notifications/notifications-plugin.d.ts.map +1 -0
  102. package/dist/plugins/notifications/notifications-plugin.js +337 -0
  103. package/dist/plugins/notifications/notifications-plugin.js.map +1 -0
  104. package/dist/plugins/notifications/types.d.ts +164 -0
  105. package/dist/plugins/notifications/types.d.ts.map +1 -0
  106. package/dist/plugins/notifications/types.js +9 -0
  107. package/dist/plugins/notifications/types.js.map +1 -0
  108. package/dist/plugins/parental/__tests__/parental-plugin.test.d.ts +12 -0
  109. package/dist/plugins/parental/__tests__/parental-plugin.test.d.ts.map +1 -0
  110. package/dist/plugins/parental/__tests__/parental-plugin.test.js +349 -0
  111. package/dist/plugins/parental/__tests__/parental-plugin.test.js.map +1 -0
  112. package/dist/plugins/parental/adapters/index.d.ts +8 -0
  113. package/dist/plugins/parental/adapters/index.d.ts.map +1 -0
  114. package/dist/plugins/parental/adapters/index.js +7 -0
  115. package/dist/plugins/parental/adapters/index.js.map +1 -0
  116. package/dist/plugins/parental/adapters/kids-adapter.d.ts +24 -0
  117. package/dist/plugins/parental/adapters/kids-adapter.d.ts.map +1 -0
  118. package/dist/plugins/parental/adapters/kids-adapter.js +174 -0
  119. package/dist/plugins/parental/adapters/kids-adapter.js.map +1 -0
  120. package/dist/plugins/parental/index.d.ts +14 -0
  121. package/dist/plugins/parental/index.d.ts.map +1 -0
  122. package/dist/plugins/parental/index.js +15 -0
  123. package/dist/plugins/parental/index.js.map +1 -0
  124. package/dist/plugins/parental/parental-plugin.d.ts +88 -0
  125. package/dist/plugins/parental/parental-plugin.d.ts.map +1 -0
  126. package/dist/plugins/parental/parental-plugin.js +666 -0
  127. package/dist/plugins/parental/parental-plugin.js.map +1 -0
  128. package/dist/plugins/parental/stores/index.d.ts +7 -0
  129. package/dist/plugins/parental/stores/index.d.ts.map +1 -0
  130. package/dist/plugins/parental/stores/index.js +7 -0
  131. package/dist/plugins/parental/stores/index.js.map +1 -0
  132. package/dist/plugins/parental/stores/postgres-store.d.ts +10 -0
  133. package/dist/plugins/parental/stores/postgres-store.d.ts.map +1 -0
  134. package/dist/plugins/parental/stores/postgres-store.js +209 -0
  135. package/dist/plugins/parental/stores/postgres-store.js.map +1 -0
  136. package/dist/plugins/parental/types.d.ts +154 -0
  137. package/dist/plugins/parental/types.d.ts.map +1 -0
  138. package/dist/plugins/parental/types.js +10 -0
  139. package/dist/plugins/parental/types.js.map +1 -0
  140. package/dist/plugins/profiles/__tests__/profiles-plugin.test.d.ts +11 -0
  141. package/dist/plugins/profiles/__tests__/profiles-plugin.test.d.ts.map +1 -0
  142. package/dist/plugins/profiles/__tests__/profiles-plugin.test.js +243 -0
  143. package/dist/plugins/profiles/__tests__/profiles-plugin.test.js.map +1 -0
  144. package/dist/plugins/profiles/index.d.ts +12 -0
  145. package/dist/plugins/profiles/index.d.ts.map +1 -0
  146. package/dist/plugins/profiles/index.js +13 -0
  147. package/dist/plugins/profiles/index.js.map +1 -0
  148. package/dist/plugins/profiles/profiles-plugin.d.ts +71 -0
  149. package/dist/plugins/profiles/profiles-plugin.d.ts.map +1 -0
  150. package/dist/plugins/profiles/profiles-plugin.js +481 -0
  151. package/dist/plugins/profiles/profiles-plugin.js.map +1 -0
  152. package/dist/plugins/profiles/stores/index.d.ts +9 -0
  153. package/dist/plugins/profiles/stores/index.d.ts.map +1 -0
  154. package/dist/plugins/profiles/stores/index.js +9 -0
  155. package/dist/plugins/profiles/stores/index.js.map +1 -0
  156. package/dist/plugins/profiles/stores/postgres-store.d.ts +18 -0
  157. package/dist/plugins/profiles/stores/postgres-store.d.ts.map +1 -0
  158. package/dist/plugins/profiles/stores/postgres-store.js +310 -0
  159. package/dist/plugins/profiles/stores/postgres-store.js.map +1 -0
  160. package/dist/plugins/profiles/types.d.ts +289 -0
  161. package/dist/plugins/profiles/types.d.ts.map +1 -0
  162. package/dist/plugins/profiles/types.js +10 -0
  163. package/dist/plugins/profiles/types.js.map +1 -0
  164. package/dist/plugins/rate-limit/__tests__/rate-limit-plugin.test.d.ts +7 -0
  165. package/dist/plugins/rate-limit/__tests__/rate-limit-plugin.test.d.ts.map +1 -0
  166. package/dist/plugins/rate-limit/__tests__/rate-limit-plugin.test.js +220 -0
  167. package/dist/plugins/rate-limit/__tests__/rate-limit-plugin.test.js.map +1 -0
  168. package/dist/plugins/rate-limit/cleanup.d.ts +40 -0
  169. package/dist/plugins/rate-limit/cleanup.d.ts.map +1 -0
  170. package/dist/plugins/rate-limit/cleanup.js +72 -0
  171. package/dist/plugins/rate-limit/cleanup.js.map +1 -0
  172. package/dist/plugins/rate-limit/env-config.d.ts +91 -0
  173. package/dist/plugins/rate-limit/env-config.d.ts.map +1 -0
  174. package/dist/plugins/rate-limit/env-config.js +318 -0
  175. package/dist/plugins/rate-limit/env-config.js.map +1 -0
  176. package/dist/plugins/rate-limit/index.d.ts +76 -0
  177. package/dist/plugins/rate-limit/index.d.ts.map +1 -0
  178. package/dist/plugins/rate-limit/index.js +79 -0
  179. package/dist/plugins/rate-limit/index.js.map +1 -0
  180. package/dist/plugins/rate-limit/middleware.d.ts +40 -0
  181. package/dist/plugins/rate-limit/middleware.d.ts.map +1 -0
  182. package/dist/plugins/rate-limit/middleware.js +169 -0
  183. package/dist/plugins/rate-limit/middleware.js.map +1 -0
  184. package/dist/plugins/rate-limit/rate-limit-plugin.d.ts +44 -0
  185. package/dist/plugins/rate-limit/rate-limit-plugin.d.ts.map +1 -0
  186. package/dist/plugins/rate-limit/rate-limit-plugin.js +354 -0
  187. package/dist/plugins/rate-limit/rate-limit-plugin.js.map +1 -0
  188. package/dist/plugins/rate-limit/rate-limit-service.d.ts +110 -0
  189. package/dist/plugins/rate-limit/rate-limit-service.d.ts.map +1 -0
  190. package/dist/plugins/rate-limit/rate-limit-service.js +172 -0
  191. package/dist/plugins/rate-limit/rate-limit-service.js.map +1 -0
  192. package/dist/plugins/rate-limit/stores/cache-store.d.ts +33 -0
  193. package/dist/plugins/rate-limit/stores/cache-store.d.ts.map +1 -0
  194. package/dist/plugins/rate-limit/stores/cache-store.js +225 -0
  195. package/dist/plugins/rate-limit/stores/cache-store.js.map +1 -0
  196. package/dist/plugins/rate-limit/stores/index.d.ts +8 -0
  197. package/dist/plugins/rate-limit/stores/index.d.ts.map +1 -0
  198. package/dist/plugins/rate-limit/stores/index.js +8 -0
  199. package/dist/plugins/rate-limit/stores/index.js.map +1 -0
  200. package/dist/plugins/rate-limit/stores/postgres-store.d.ts +34 -0
  201. package/dist/plugins/rate-limit/stores/postgres-store.d.ts.map +1 -0
  202. package/dist/plugins/rate-limit/stores/postgres-store.js +320 -0
  203. package/dist/plugins/rate-limit/stores/postgres-store.js.map +1 -0
  204. package/dist/plugins/rate-limit/strategies/fixed-window.d.ts +21 -0
  205. package/dist/plugins/rate-limit/strategies/fixed-window.d.ts.map +1 -0
  206. package/dist/plugins/rate-limit/strategies/fixed-window.js +97 -0
  207. package/dist/plugins/rate-limit/strategies/fixed-window.js.map +1 -0
  208. package/dist/plugins/rate-limit/strategies/index.d.ts +14 -0
  209. package/dist/plugins/rate-limit/strategies/index.d.ts.map +1 -0
  210. package/dist/plugins/rate-limit/strategies/index.js +27 -0
  211. package/dist/plugins/rate-limit/strategies/index.js.map +1 -0
  212. package/dist/plugins/rate-limit/strategies/sliding-window.d.ts +22 -0
  213. package/dist/plugins/rate-limit/strategies/sliding-window.d.ts.map +1 -0
  214. package/dist/plugins/rate-limit/strategies/sliding-window.js +122 -0
  215. package/dist/plugins/rate-limit/strategies/sliding-window.js.map +1 -0
  216. package/dist/plugins/rate-limit/strategies/token-bucket.d.ts +28 -0
  217. package/dist/plugins/rate-limit/strategies/token-bucket.d.ts.map +1 -0
  218. package/dist/plugins/rate-limit/strategies/token-bucket.js +121 -0
  219. package/dist/plugins/rate-limit/strategies/token-bucket.js.map +1 -0
  220. package/dist/plugins/rate-limit/types.d.ts +265 -0
  221. package/dist/plugins/rate-limit/types.d.ts.map +1 -0
  222. package/dist/plugins/rate-limit/types.js +9 -0
  223. package/dist/plugins/rate-limit/types.js.map +1 -0
  224. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.d.ts +11 -0
  225. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.d.ts.map +1 -0
  226. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.js +305 -0
  227. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.js.map +1 -0
  228. package/dist/plugins/subscriptions/index.d.ts +12 -0
  229. package/dist/plugins/subscriptions/index.d.ts.map +1 -0
  230. package/dist/plugins/subscriptions/index.js +13 -0
  231. package/dist/plugins/subscriptions/index.js.map +1 -0
  232. package/dist/plugins/subscriptions/stores/index.d.ts +9 -0
  233. package/dist/plugins/subscriptions/stores/index.d.ts.map +1 -0
  234. package/dist/plugins/subscriptions/stores/index.js +9 -0
  235. package/dist/plugins/subscriptions/stores/index.js.map +1 -0
  236. package/dist/plugins/subscriptions/stores/postgres-store.d.ts +14 -0
  237. package/dist/plugins/subscriptions/stores/postgres-store.d.ts.map +1 -0
  238. package/dist/plugins/subscriptions/stores/postgres-store.js +359 -0
  239. package/dist/plugins/subscriptions/stores/postgres-store.js.map +1 -0
  240. package/dist/plugins/subscriptions/subscriptions-plugin.d.ts +82 -0
  241. package/dist/plugins/subscriptions/subscriptions-plugin.d.ts.map +1 -0
  242. package/dist/plugins/subscriptions/subscriptions-plugin.js +449 -0
  243. package/dist/plugins/subscriptions/subscriptions-plugin.js.map +1 -0
  244. package/dist/plugins/subscriptions/types.d.ts +308 -0
  245. package/dist/plugins/subscriptions/types.d.ts.map +1 -0
  246. package/dist/plugins/subscriptions/types.js +10 -0
  247. package/dist/plugins/subscriptions/types.js.map +1 -0
  248. package/dist/plugins/usage/__tests__/usage-plugin.test.d.ts +11 -0
  249. package/dist/plugins/usage/__tests__/usage-plugin.test.d.ts.map +1 -0
  250. package/dist/plugins/usage/__tests__/usage-plugin.test.js +218 -0
  251. package/dist/plugins/usage/__tests__/usage-plugin.test.js.map +1 -0
  252. package/dist/plugins/usage/index.d.ts +12 -0
  253. package/dist/plugins/usage/index.d.ts.map +1 -0
  254. package/dist/plugins/usage/index.js +13 -0
  255. package/dist/plugins/usage/index.js.map +1 -0
  256. package/dist/plugins/usage/stores/index.d.ts +9 -0
  257. package/dist/plugins/usage/stores/index.d.ts.map +1 -0
  258. package/dist/plugins/usage/stores/index.js +9 -0
  259. package/dist/plugins/usage/stores/index.js.map +1 -0
  260. package/dist/plugins/usage/stores/postgres-store.d.ts +14 -0
  261. package/dist/plugins/usage/stores/postgres-store.d.ts.map +1 -0
  262. package/dist/plugins/usage/stores/postgres-store.js +146 -0
  263. package/dist/plugins/usage/stores/postgres-store.js.map +1 -0
  264. package/dist/plugins/usage/types.d.ts +195 -0
  265. package/dist/plugins/usage/types.d.ts.map +1 -0
  266. package/dist/plugins/usage/types.js +10 -0
  267. package/dist/plugins/usage/types.js.map +1 -0
  268. package/dist/plugins/usage/usage-plugin.d.ts +51 -0
  269. package/dist/plugins/usage/usage-plugin.d.ts.map +1 -0
  270. package/dist/plugins/usage/usage-plugin.js +412 -0
  271. package/dist/plugins/usage/usage-plugin.js.map +1 -0
  272. package/dist/plugins/users/__tests__/postgres-store.test.d.ts +10 -0
  273. package/dist/plugins/users/__tests__/postgres-store.test.d.ts.map +1 -0
  274. package/dist/plugins/users/__tests__/postgres-store.test.js +229 -0
  275. package/dist/plugins/users/__tests__/postgres-store.test.js.map +1 -0
  276. package/dist/plugins/users/__tests__/users-plugin.test.js +3 -0
  277. package/dist/plugins/users/__tests__/users-plugin.test.js.map +1 -1
  278. package/dist/plugins/users/index.d.ts +2 -2
  279. package/dist/plugins/users/index.d.ts.map +1 -1
  280. package/dist/plugins/users/index.js +1 -1
  281. package/dist/plugins/users/index.js.map +1 -1
  282. package/dist/plugins/users/stores/postgres-store.d.ts.map +1 -1
  283. package/dist/plugins/users/stores/postgres-store.js +76 -0
  284. package/dist/plugins/users/stores/postgres-store.js.map +1 -1
  285. package/dist/plugins/users/types.d.ts +74 -6
  286. package/dist/plugins/users/types.d.ts.map +1 -1
  287. package/dist/plugins/users/users-plugin.d.ts +15 -1
  288. package/dist/plugins/users/users-plugin.d.ts.map +1 -1
  289. package/dist/plugins/users/users-plugin.js +29 -0
  290. package/dist/plugins/users/users-plugin.js.map +1 -1
  291. package/dist-ui/assets/index-CynOqPkb.js +469 -0
  292. package/dist-ui/assets/{index-BY8OxNgO.js.map → index-CynOqPkb.js.map} +1 -1
  293. package/dist-ui/index.html +1 -1
  294. package/dist-ui-lib/api/controlPanelApi.d.ts +187 -0
  295. package/dist-ui-lib/components/StatCard.d.ts +16 -0
  296. package/dist-ui-lib/dashboard/widgets/AuthStatusWidget.d.ts +9 -0
  297. package/dist-ui-lib/dashboard/widgets/IntegrationStatusWidget.d.ts +9 -0
  298. package/dist-ui-lib/dashboard/widgets/NotificationsStatsWidget.d.ts +12 -0
  299. package/dist-ui-lib/dashboard/widgets/index.d.ts +3 -0
  300. package/dist-ui-lib/index.js +3579 -2379
  301. package/dist-ui-lib/index.js.map +1 -1
  302. package/dist-ui-lib/pages/IntegrationsPage.d.ts +1 -0
  303. package/dist-ui-lib/pages/NotificationsPage.d.ts +9 -0
  304. package/dist-ui-lib/pages/RateLimitPage.d.ts +1 -0
  305. package/dist-ui-lib/utils/formatters.d.ts +19 -0
  306. package/package.json +1 -1
  307. package/src/core/control-panel.ts +128 -0
  308. package/src/core/types.ts +17 -0
  309. package/src/index.ts +216 -0
  310. package/src/plugins/auth/adapter-wrapper.test.ts +395 -0
  311. package/src/plugins/auth/adapter-wrapper.ts +205 -0
  312. package/src/plugins/auth/config-store.test.ts +417 -0
  313. package/src/plugins/auth/config-store.ts +305 -0
  314. package/src/plugins/auth/env-config.ts +714 -7
  315. package/src/plugins/auth/index.ts +22 -1
  316. package/src/plugins/auth/types.ts +138 -0
  317. package/src/plugins/bans/bans-plugin.ts +15 -3
  318. package/src/plugins/devices/__tests__/devices-plugin.test.ts +551 -0
  319. package/src/plugins/devices/__tests__/token-utils.test.ts +264 -0
  320. package/src/plugins/devices/adapters/compute-adapter.ts +139 -0
  321. package/src/plugins/devices/adapters/index.ts +13 -0
  322. package/src/plugins/devices/adapters/mobile-adapter.ts +179 -0
  323. package/src/plugins/devices/devices-plugin.ts +538 -0
  324. package/src/plugins/devices/index.ts +69 -0
  325. package/src/plugins/devices/stores/index.ts +9 -0
  326. package/src/plugins/devices/stores/postgres-store.ts +304 -0
  327. package/src/plugins/devices/token-utils.ts +213 -0
  328. package/src/plugins/devices/types.ts +351 -0
  329. package/src/plugins/index.ts +267 -0
  330. package/src/plugins/notifications/__tests__/notifications-manager.test.ts +637 -0
  331. package/src/plugins/notifications/index.ts +91 -0
  332. package/src/plugins/notifications/notifications-manager.ts +773 -0
  333. package/src/plugins/notifications/notifications-plugin.ts +398 -0
  334. package/src/plugins/notifications/types.ts +207 -0
  335. package/src/plugins/parental/__tests__/parental-plugin.test.ts +465 -0
  336. package/src/plugins/parental/adapters/index.ts +8 -0
  337. package/src/plugins/parental/adapters/kids-adapter.ts +206 -0
  338. package/src/plugins/parental/index.ts +55 -0
  339. package/src/plugins/parental/parental-plugin.ts +759 -0
  340. package/src/plugins/parental/stores/index.ts +7 -0
  341. package/src/plugins/parental/stores/postgres-store.ts +304 -0
  342. package/src/plugins/parental/types.ts +180 -0
  343. package/src/plugins/profiles/__tests__/profiles-plugin.test.ts +321 -0
  344. package/src/plugins/profiles/index.ts +49 -0
  345. package/src/plugins/profiles/profiles-plugin.ts +546 -0
  346. package/src/plugins/profiles/stores/index.ts +9 -0
  347. package/src/plugins/profiles/stores/postgres-store.ts +439 -0
  348. package/src/plugins/profiles/types.ts +338 -0
  349. package/src/plugins/rate-limit/__tests__/rate-limit-plugin.test.ts +259 -0
  350. package/src/plugins/rate-limit/cleanup.ts +117 -0
  351. package/src/plugins/rate-limit/env-config.ts +400 -0
  352. package/src/plugins/rate-limit/index.ts +128 -0
  353. package/src/plugins/rate-limit/middleware.ts +212 -0
  354. package/src/plugins/rate-limit/rate-limit-plugin.ts +400 -0
  355. package/src/plugins/rate-limit/rate-limit-service.ts +228 -0
  356. package/src/plugins/rate-limit/stores/cache-store.ts +261 -0
  357. package/src/plugins/rate-limit/stores/index.ts +8 -0
  358. package/src/plugins/rate-limit/stores/postgres-store.ts +402 -0
  359. package/src/plugins/rate-limit/strategies/fixed-window.ts +116 -0
  360. package/src/plugins/rate-limit/strategies/index.ts +30 -0
  361. package/src/plugins/rate-limit/strategies/sliding-window.ts +157 -0
  362. package/src/plugins/rate-limit/strategies/token-bucket.ts +154 -0
  363. package/src/plugins/rate-limit/types.ts +338 -0
  364. package/src/plugins/subscriptions/__tests__/subscriptions-plugin.test.ts +404 -0
  365. package/src/plugins/subscriptions/index.ts +51 -0
  366. package/src/plugins/subscriptions/stores/index.ts +9 -0
  367. package/src/plugins/subscriptions/stores/postgres-store.ts +482 -0
  368. package/src/plugins/subscriptions/subscriptions-plugin.ts +530 -0
  369. package/src/plugins/subscriptions/types.ts +355 -0
  370. package/src/plugins/usage/__tests__/usage-plugin.test.ts +288 -0
  371. package/src/plugins/usage/index.ts +39 -0
  372. package/src/plugins/usage/stores/index.ts +9 -0
  373. package/src/plugins/usage/stores/postgres-store.ts +213 -0
  374. package/src/plugins/usage/types.ts +222 -0
  375. package/src/plugins/usage/usage-plugin.ts +484 -0
  376. package/src/plugins/users/__tests__/postgres-store.test.ts +326 -0
  377. package/src/plugins/users/__tests__/users-plugin.test.ts +3 -0
  378. package/src/plugins/users/index.ts +6 -0
  379. package/src/plugins/users/stores/postgres-store.ts +104 -0
  380. package/src/plugins/users/types.ts +82 -6
  381. package/src/plugins/users/users-plugin.ts +37 -0
  382. package/ui/src/App.tsx +36 -14
  383. package/ui/src/api/controlPanelApi.ts +329 -6
  384. package/ui/src/components/StatCard.tsx +58 -0
  385. package/ui/src/dashboard/builtInWidgets.tsx +7 -1
  386. package/ui/src/dashboard/widgets/AuthStatusWidget.tsx +143 -0
  387. package/ui/src/dashboard/widgets/IntegrationStatusWidget.tsx +135 -0
  388. package/ui/src/dashboard/widgets/NotificationsStatsWidget.tsx +167 -0
  389. package/ui/src/dashboard/widgets/index.ts +3 -0
  390. package/ui/src/pages/AuthPage.tsx +986 -142
  391. package/ui/src/pages/IntegrationsPage.tsx +288 -0
  392. package/ui/src/pages/NotificationsPage.tsx +417 -0
  393. package/ui/src/pages/RateLimitPage.tsx +292 -0
  394. package/ui/src/utils/formatters.ts +33 -0
  395. package/dist-ui/assets/index-BY8OxNgO.js +0 -465
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Token Bucket Rate Limit Strategy
3
+ *
4
+ * Implements a token bucket algorithm that allows bursts while maintaining
5
+ * a long-term rate limit.
6
+ *
7
+ * How it works:
8
+ * - Bucket starts full with `maxRequests` tokens
9
+ * - Each request consumes 1 token
10
+ * - Tokens refill at a constant rate (maxRequests / windowMs)
11
+ * - If no tokens available, request is rate limited
12
+ *
13
+ * Pros:
14
+ * - Allows short bursts of traffic
15
+ * - Smooth long-term rate limiting
16
+ *
17
+ * Cons:
18
+ * - More complex state management
19
+ * - Can allow more requests than fixed/sliding in short bursts
20
+ *
21
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
22
+ */
23
+
24
+ import type {
25
+ Strategy,
26
+ StrategyOptions,
27
+ StrategyContext,
28
+ LimitStatus,
29
+ CachedLimit,
30
+ } from '../types.js';
31
+
32
+ /**
33
+ * Calculate tokens to refill based on time elapsed
34
+ */
35
+ function calculateRefill(
36
+ lastRefill: number,
37
+ maxTokens: number,
38
+ refillRatePerMs: number
39
+ ): { tokens: number; newLastRefill: number } {
40
+ const now = Date.now();
41
+ const elapsed = now - lastRefill;
42
+ const tokensToAdd = elapsed * refillRatePerMs;
43
+
44
+ return {
45
+ tokens: Math.min(maxTokens, tokensToAdd),
46
+ newLastRefill: now,
47
+ };
48
+ }
49
+
50
+ /**
51
+ * Create the token bucket strategy
52
+ */
53
+ export function createTokenBucketStrategy(): Strategy {
54
+ return {
55
+ name: 'token-bucket',
56
+
57
+ async check(
58
+ key: string,
59
+ options: StrategyOptions,
60
+ context: StrategyContext
61
+ ): Promise<LimitStatus> {
62
+ const { maxRequests, windowMs, increment = true } = options;
63
+ const { store, cache, userId, tenantId, ipAddress } = context;
64
+
65
+ const now = Date.now();
66
+ // Refill rate: how many tokens per millisecond
67
+ const refillRatePerMs = maxRequests / windowMs;
68
+
69
+ // Try cache first
70
+ let cached = await cache.get(key);
71
+ let tokensRemaining = maxRequests; // Start with full bucket
72
+ let lastRefill = now;
73
+
74
+ if (cached && cached.tokensRemaining !== undefined && cached.lastRefill !== undefined) {
75
+ // Cache hit - calculate current tokens with refill
76
+ const refill = calculateRefill(cached.lastRefill, maxRequests, refillRatePerMs);
77
+ tokensRemaining = Math.min(maxRequests, (cached.tokensRemaining || 0) + refill.tokens);
78
+ lastRefill = refill.newLastRefill;
79
+ } else {
80
+ // Cache miss - check store
81
+ const stored = await store.get(key, userId);
82
+ if (stored && stored.tokensRemaining !== undefined && stored.lastRefill) {
83
+ const refill = calculateRefill(
84
+ stored.lastRefill.getTime(),
85
+ maxRequests,
86
+ refillRatePerMs
87
+ );
88
+ tokensRemaining = Math.min(maxRequests, (stored.tokensRemaining || 0) + refill.tokens);
89
+ lastRefill = refill.newLastRefill;
90
+ }
91
+ // If no stored data, start with full bucket
92
+ }
93
+
94
+ // Check if limited (less than 1 full token)
95
+ const limited = tokensRemaining < 1;
96
+
97
+ // Calculate when next token will be available
98
+ const timeUntilNextToken = limited ? Math.ceil((1 - tokensRemaining) / refillRatePerMs) : 0;
99
+ const resetAt = Math.ceil((now + timeUntilNextToken) / 1000);
100
+ const retryAfter = Math.max(0, Math.ceil(timeUntilNextToken / 1000));
101
+
102
+ // Calculate remaining (floor to show integer tokens)
103
+ const remaining = Math.max(0, Math.floor(tokensRemaining) - (increment && !limited ? 1 : 0));
104
+
105
+ // Consume token if requested and not limited
106
+ if (increment && !limited) {
107
+ const newTokens = tokensRemaining - 1;
108
+
109
+ // Update store with new token count
110
+ // We use a special increment that sets tokens instead of incrementing count
111
+ const updated = await store.increment(key, {
112
+ maxRequests,
113
+ windowMs,
114
+ strategy: 'token-bucket',
115
+ userId,
116
+ tenantId,
117
+ ipAddress,
118
+ amount: -1, // Signal to set tokens, not increment count
119
+ });
120
+
121
+ // Update cache
122
+ const newCached: CachedLimit = {
123
+ count: Math.floor(maxRequests - newTokens), // Count as consumed tokens
124
+ maxRequests,
125
+ windowStart: now,
126
+ windowEnd: now + windowMs,
127
+ strategy: 'token-bucket',
128
+ tokensRemaining: newTokens,
129
+ lastRefill,
130
+ };
131
+ await cache.set(key, newCached, windowMs);
132
+
133
+ return {
134
+ limited: false,
135
+ current: Math.floor(maxRequests - newTokens),
136
+ limit: maxRequests,
137
+ remaining: Math.floor(newTokens),
138
+ resetAt,
139
+ retryAfter: 0,
140
+ };
141
+ }
142
+
143
+ // Return status without consuming
144
+ return {
145
+ limited,
146
+ current: Math.floor(maxRequests - tokensRemaining),
147
+ limit: maxRequests,
148
+ remaining,
149
+ resetAt,
150
+ retryAfter,
151
+ };
152
+ },
153
+ };
154
+ }
@@ -0,0 +1,338 @@
1
+ /**
2
+ * Rate Limit Plugin Types
3
+ *
4
+ * Type definitions for the rate limiting plugin.
5
+ *
6
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
7
+ */
8
+
9
+ import type { Request, Response, NextFunction } from 'express';
10
+
11
+ // ============================================
12
+ // Strategy Types
13
+ // ============================================
14
+
15
+ export type RateLimitStrategy = 'sliding-window' | 'fixed-window' | 'token-bucket';
16
+
17
+ /**
18
+ * Result from a rate limit check
19
+ */
20
+ export interface LimitStatus {
21
+ /** Whether the limit has been exceeded */
22
+ limited: boolean;
23
+ /** Current request count in window */
24
+ current: number;
25
+ /** Maximum requests allowed */
26
+ limit: number;
27
+ /** Remaining requests in window */
28
+ remaining: number;
29
+ /** When the current window resets (Unix timestamp in seconds) */
30
+ resetAt: number;
31
+ /** Seconds until reset (for Retry-After header) */
32
+ retryAfter: number;
33
+ }
34
+
35
+ /**
36
+ * Strategy interface - all strategies must implement this
37
+ */
38
+ export interface Strategy {
39
+ name: RateLimitStrategy;
40
+
41
+ /**
42
+ * Check if the key is rate limited and optionally increment counter
43
+ */
44
+ check(
45
+ key: string,
46
+ options: StrategyOptions,
47
+ context: StrategyContext
48
+ ): Promise<LimitStatus>;
49
+ }
50
+
51
+ export interface StrategyOptions {
52
+ maxRequests: number;
53
+ windowMs: number;
54
+ /** Whether to increment the counter (default: true) */
55
+ increment?: boolean;
56
+ }
57
+
58
+ export interface StrategyContext {
59
+ store: RateLimitStore;
60
+ cache: RateLimitCache;
61
+ userId?: string;
62
+ tenantId?: string;
63
+ ipAddress?: string;
64
+ }
65
+
66
+ // ============================================
67
+ // Store Types
68
+ // ============================================
69
+
70
+ /**
71
+ * Stored rate limit record
72
+ */
73
+ export interface StoredLimit {
74
+ id: string;
75
+ key: string;
76
+ count: number;
77
+ maxRequests: number;
78
+ windowMs: number;
79
+ windowStart: Date;
80
+ windowEnd: Date;
81
+ strategy: RateLimitStrategy;
82
+ userId?: string;
83
+ tenantId?: string;
84
+ ipAddress?: string;
85
+ /** Token bucket: remaining tokens */
86
+ tokensRemaining?: number;
87
+ /** Token bucket: last refill time */
88
+ lastRefill?: Date;
89
+ createdAt: Date;
90
+ updatedAt: Date;
91
+ }
92
+
93
+ /**
94
+ * Options for incrementing a rate limit
95
+ */
96
+ export interface IncrementOptions {
97
+ maxRequests: number;
98
+ windowMs: number;
99
+ strategy: RateLimitStrategy;
100
+ userId?: string;
101
+ tenantId?: string;
102
+ ipAddress?: string;
103
+ /** Amount to increment by (default: 1) */
104
+ amount?: number;
105
+ }
106
+
107
+ /**
108
+ * Rate limit store interface - implementations handle persistence
109
+ */
110
+ export interface RateLimitStore {
111
+ /** Store name for logging */
112
+ name: string;
113
+
114
+ /** Initialize store (create tables, indexes, RLS) */
115
+ initialize(): Promise<void>;
116
+
117
+ /** Get current limit status for a key */
118
+ get(key: string, userId?: string): Promise<StoredLimit | null>;
119
+
120
+ /** Increment counter for a key, returns updated record */
121
+ increment(key: string, options: IncrementOptions): Promise<StoredLimit>;
122
+
123
+ /** Clear a specific limit */
124
+ clear(key: string, userId?: string): Promise<boolean>;
125
+
126
+ /** Clean up expired limits, returns count of deleted records */
127
+ cleanup(): Promise<number>;
128
+
129
+ /** Shutdown store */
130
+ shutdown(): Promise<void>;
131
+ }
132
+
133
+ /**
134
+ * PostgreSQL store configuration
135
+ */
136
+ export interface PostgresRateLimitStoreConfig {
137
+ /**
138
+ * PostgreSQL pool instance or function that returns one.
139
+ * Use a function for lazy initialization.
140
+ */
141
+ pool: unknown | (() => unknown);
142
+
143
+ /** Table name (default: 'rate_limits') */
144
+ tableName?: string;
145
+
146
+ /** Schema name (default: 'public') */
147
+ schema?: string;
148
+
149
+ /** Auto-create tables on initialize (default: true) */
150
+ autoCreateTables?: boolean;
151
+
152
+ /** Enable RLS policies (default: true) */
153
+ enableRLS?: boolean;
154
+ }
155
+
156
+ // ============================================
157
+ // Cache Types
158
+ // ============================================
159
+
160
+ /**
161
+ * Cached rate limit entry
162
+ */
163
+ export interface CachedLimit {
164
+ count: number;
165
+ maxRequests: number;
166
+ windowStart: number; // Unix timestamp ms
167
+ windowEnd: number; // Unix timestamp ms
168
+ strategy: RateLimitStrategy;
169
+ /** Token bucket specific */
170
+ tokensRemaining?: number;
171
+ lastRefill?: number;
172
+ }
173
+
174
+ /**
175
+ * Rate limit cache interface
176
+ */
177
+ export interface RateLimitCache {
178
+ /** Cache name for logging */
179
+ name: string;
180
+
181
+ /** Get cached limit for a key */
182
+ get(key: string): Promise<CachedLimit | null>;
183
+
184
+ /** Set cached limit with TTL */
185
+ set(key: string, value: CachedLimit, ttlMs: number): Promise<void>;
186
+
187
+ /** Atomic increment of count, returns new count */
188
+ increment(key: string, amount?: number): Promise<number | null>;
189
+
190
+ /** Delete a cached entry */
191
+ delete(key: string): Promise<boolean>;
192
+
193
+ /** Check if cache is available */
194
+ isAvailable(): boolean;
195
+
196
+ /** Shutdown cache */
197
+ shutdown(): Promise<void>;
198
+ }
199
+
200
+ /**
201
+ * Cache store configuration
202
+ */
203
+ export interface RateLimitCacheConfig {
204
+ /**
205
+ * Cache type:
206
+ * - 'redis': Use Redis via cache plugin
207
+ * - 'memory': Use in-memory cache
208
+ * - 'auto': Use Redis if available, fall back to memory
209
+ */
210
+ type?: 'redis' | 'memory' | 'auto';
211
+
212
+ /** Redis cache instance name (default: 'default') */
213
+ redisInstance?: string;
214
+
215
+ /** Default TTL in milliseconds (default: 60000) */
216
+ defaultTtlMs?: number;
217
+
218
+ /** Max in-memory entries (default: 10000) */
219
+ maxMemoryEntries?: number;
220
+
221
+ /** Key prefix for cache entries (default: 'ratelimit:') */
222
+ keyPrefix?: string;
223
+ }
224
+
225
+ // ============================================
226
+ // Middleware Types
227
+ // ============================================
228
+
229
+ /**
230
+ * Express middleware options
231
+ */
232
+ export interface RateLimitMiddlewareOptions {
233
+ /** Time window in milliseconds (default: 60000 = 1 min) */
234
+ windowMs?: number;
235
+
236
+ /** Max requests per window (static or dynamic) */
237
+ max?: number | ((req: Request) => number | Promise<number>);
238
+
239
+ /** Generate the rate limit key from request */
240
+ keyGenerator?: (req: Request) => string | Promise<string>;
241
+
242
+ /** Skip rate limiting for certain requests */
243
+ skip?: (req: Request) => boolean | Promise<boolean>;
244
+
245
+ /** Custom handler when limit is exceeded */
246
+ handler?: (req: Request, res: Response, next: NextFunction, status: LimitStatus) => void;
247
+
248
+ /** Strategy to use (default: 'sliding-window') */
249
+ strategy?: RateLimitStrategy;
250
+
251
+ /** Include standard rate limit headers (default: true) */
252
+ headers?: boolean;
253
+
254
+ /** Key prefix for this middleware instance */
255
+ keyPrefix?: string;
256
+ }
257
+
258
+ // ============================================
259
+ // Plugin Types
260
+ // ============================================
261
+
262
+ /**
263
+ * Rate limit plugin configuration
264
+ */
265
+ export interface RateLimitPluginConfig {
266
+ /**
267
+ * PostgreSQL store configuration (required for persistence)
268
+ */
269
+ store: RateLimitStore;
270
+
271
+ /**
272
+ * Default limits applied when not specified per-route
273
+ */
274
+ defaults?: {
275
+ /** Time window in milliseconds (default: 60000 = 1 min) */
276
+ windowMs?: number;
277
+ /** Max requests per window (default: 100) */
278
+ maxRequests?: number;
279
+ /** Strategy to use (default: 'sliding-window') */
280
+ strategy?: RateLimitStrategy;
281
+ };
282
+
283
+ /**
284
+ * Cache configuration
285
+ */
286
+ cache?: RateLimitCacheConfig;
287
+
288
+ /**
289
+ * Auto-cleanup configuration
290
+ */
291
+ cleanup?: {
292
+ /** Enable auto-cleanup of expired limits (default: true) */
293
+ enabled?: boolean;
294
+ /** Cleanup interval in milliseconds (default: 300000 = 5 min) */
295
+ intervalMs?: number;
296
+ };
297
+
298
+ /**
299
+ * API routes configuration
300
+ */
301
+ api?: {
302
+ /** Enable status API endpoints (default: true) */
303
+ enabled?: boolean;
304
+ /** Route prefix (default: '/rate-limit') */
305
+ prefix?: string;
306
+ };
307
+
308
+ /**
309
+ * UI configuration
310
+ */
311
+ ui?: {
312
+ /** Enable UI menu item and config page (default: true) */
313
+ enabled?: boolean;
314
+ };
315
+
316
+ /** Enable debug logging (default: false) */
317
+ debug?: boolean;
318
+ }
319
+
320
+ /**
321
+ * Options for checking a rate limit programmatically
322
+ */
323
+ export interface CheckLimitOptions {
324
+ /** Max requests (uses plugin default if not specified) */
325
+ maxRequests?: number;
326
+ /** Window in milliseconds (uses plugin default if not specified) */
327
+ windowMs?: number;
328
+ /** Strategy (uses plugin default if not specified) */
329
+ strategy?: RateLimitStrategy;
330
+ /** User ID for scoped limits */
331
+ userId?: string;
332
+ /** Tenant ID for scoped limits */
333
+ tenantId?: string;
334
+ /** IP address for scoped limits */
335
+ ipAddress?: string;
336
+ /** Whether to increment counter (default: true) */
337
+ increment?: boolean;
338
+ }