@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,110 @@
1
+ /**
2
+ * Rate Limit Service
3
+ *
4
+ * Core service that coordinates between cache and store,
5
+ * selects strategies, and provides the programmatic API.
6
+ *
7
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
8
+ */
9
+ import type { RateLimitStore, RateLimitCache, RateLimitStrategy, LimitStatus, CheckLimitOptions } from './types.js';
10
+ /**
11
+ * Service configuration
12
+ */
13
+ export interface RateLimitServiceConfig {
14
+ store: RateLimitStore;
15
+ cache: RateLimitCache;
16
+ defaults?: {
17
+ windowMs?: number;
18
+ maxRequests?: number;
19
+ strategy?: RateLimitStrategy;
20
+ };
21
+ }
22
+ /**
23
+ * Rate Limit Service
24
+ *
25
+ * Provides the core rate limiting functionality with caching.
26
+ */
27
+ export declare class RateLimitService {
28
+ private store;
29
+ private cache;
30
+ private defaults;
31
+ constructor(config: RateLimitServiceConfig);
32
+ /**
33
+ * Check if a key is rate limited
34
+ */
35
+ isLimited(key: string, options?: CheckLimitOptions): Promise<boolean>;
36
+ /**
37
+ * Check rate limit status without incrementing
38
+ */
39
+ checkLimit(key: string, options?: CheckLimitOptions): Promise<LimitStatus>;
40
+ /**
41
+ * Increment the rate limit counter and return status
42
+ */
43
+ incrementLimit(key: string, options?: CheckLimitOptions): Promise<LimitStatus>;
44
+ /**
45
+ * Get remaining requests for a key
46
+ */
47
+ getRemainingRequests(key: string, options?: CheckLimitOptions): Promise<number>;
48
+ /**
49
+ * Get full limit status for a key
50
+ */
51
+ getLimitStatus(key: string, options?: CheckLimitOptions): Promise<LimitStatus>;
52
+ /**
53
+ * Clear a rate limit (e.g., after successful CAPTCHA)
54
+ */
55
+ clearLimit(key: string, userId?: string): Promise<void>;
56
+ /**
57
+ * Get the current defaults
58
+ */
59
+ getDefaults(): {
60
+ windowMs: number;
61
+ maxRequests: number;
62
+ strategy: RateLimitStrategy;
63
+ };
64
+ /**
65
+ * Update the default settings at runtime
66
+ */
67
+ setDefaults(updates: Partial<{
68
+ windowMs: number;
69
+ maxRequests: number;
70
+ strategy: RateLimitStrategy;
71
+ }>): void;
72
+ /**
73
+ * Run cleanup of expired limits
74
+ */
75
+ cleanup(): Promise<number>;
76
+ }
77
+ /**
78
+ * Set the current rate limit service instance
79
+ * (Called by the plugin on startup)
80
+ */
81
+ export declare function setRateLimitService(service: RateLimitService | null): void;
82
+ /**
83
+ * Get the current rate limit service instance
84
+ */
85
+ export declare function getRateLimitService(): RateLimitService;
86
+ /**
87
+ * Check if a key is currently rate limited
88
+ */
89
+ export declare function isLimited(key: string, options?: CheckLimitOptions): Promise<boolean>;
90
+ /**
91
+ * Check rate limit status without incrementing counter
92
+ */
93
+ export declare function checkLimit(key: string, options?: CheckLimitOptions): Promise<LimitStatus>;
94
+ /**
95
+ * Increment the rate limit counter and return status
96
+ */
97
+ export declare function incrementLimit(key: string, options?: CheckLimitOptions): Promise<LimitStatus>;
98
+ /**
99
+ * Get remaining requests for a key
100
+ */
101
+ export declare function getRemainingRequests(key: string, options?: CheckLimitOptions): Promise<number>;
102
+ /**
103
+ * Get full limit status for a key
104
+ */
105
+ export declare function getLimitStatus(key: string, options?: CheckLimitOptions): Promise<LimitStatus>;
106
+ /**
107
+ * Clear a rate limit (e.g., after successful CAPTCHA)
108
+ */
109
+ export declare function clearLimit(key: string, userId?: string): Promise<void>;
110
+ //# sourceMappingURL=rate-limit-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit-service.d.ts","sourceR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AE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5E"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Rate Limit Service
3
+ *
4
+ * Core service that coordinates between cache and store,
5
+ * selects strategies, and provides the programmatic API.
6
+ *
7
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
8
+ */
9
+ import { getStrategy } from './strategies/index.js';
10
+ /**
11
+ * Default configuration values
12
+ */
13
+ const DEFAULTS = {
14
+ windowMs: 60000, // 1 minute
15
+ maxRequests: 100,
16
+ strategy: 'sliding-window',
17
+ };
18
+ /**
19
+ * Rate Limit Service
20
+ *
21
+ * Provides the core rate limiting functionality with caching.
22
+ */
23
+ export class RateLimitService {
24
+ constructor(config) {
25
+ this.store = config.store;
26
+ this.cache = config.cache;
27
+ this.defaults = {
28
+ windowMs: config.defaults?.windowMs ?? DEFAULTS.windowMs,
29
+ maxRequests: config.defaults?.maxRequests ?? DEFAULTS.maxRequests,
30
+ strategy: config.defaults?.strategy ?? DEFAULTS.strategy,
31
+ };
32
+ }
33
+ /**
34
+ * Check if a key is rate limited
35
+ */
36
+ async isLimited(key, options) {
37
+ const status = await this.checkLimit(key, { ...options, increment: false });
38
+ return status.limited;
39
+ }
40
+ /**
41
+ * Check rate limit status without incrementing
42
+ */
43
+ async checkLimit(key, options) {
44
+ const { maxRequests = this.defaults.maxRequests, windowMs = this.defaults.windowMs, strategy: strategyName = this.defaults.strategy, userId, tenantId, ipAddress, increment = false, } = options || {};
45
+ const strategy = getStrategy(strategyName);
46
+ const context = {
47
+ store: this.store,
48
+ cache: this.cache,
49
+ userId,
50
+ tenantId,
51
+ ipAddress,
52
+ };
53
+ return strategy.check(key, { maxRequests, windowMs, increment }, context);
54
+ }
55
+ /**
56
+ * Increment the rate limit counter and return status
57
+ */
58
+ async incrementLimit(key, options) {
59
+ return this.checkLimit(key, { ...options, increment: true });
60
+ }
61
+ /**
62
+ * Get remaining requests for a key
63
+ */
64
+ async getRemainingRequests(key, options) {
65
+ const status = await this.checkLimit(key, { ...options, increment: false });
66
+ return status.remaining;
67
+ }
68
+ /**
69
+ * Get full limit status for a key
70
+ */
71
+ async getLimitStatus(key, options) {
72
+ return this.checkLimit(key, { ...options, increment: false });
73
+ }
74
+ /**
75
+ * Clear a rate limit (e.g., after successful CAPTCHA)
76
+ */
77
+ async clearLimit(key, userId) {
78
+ // Clear from both cache and store
79
+ await Promise.all([
80
+ this.cache.delete(key),
81
+ this.store.clear(key, userId),
82
+ ]);
83
+ }
84
+ /**
85
+ * Get the current defaults
86
+ */
87
+ getDefaults() {
88
+ return { ...this.defaults };
89
+ }
90
+ /**
91
+ * Update the default settings at runtime
92
+ */
93
+ setDefaults(updates) {
94
+ if (updates.windowMs !== undefined && updates.windowMs > 0) {
95
+ this.defaults.windowMs = updates.windowMs;
96
+ }
97
+ if (updates.maxRequests !== undefined && updates.maxRequests > 0) {
98
+ this.defaults.maxRequests = updates.maxRequests;
99
+ }
100
+ if (updates.strategy !== undefined) {
101
+ // Validate strategy
102
+ const validStrategies = ['sliding-window', 'fixed-window', 'token-bucket'];
103
+ if (validStrategies.includes(updates.strategy)) {
104
+ this.defaults.strategy = updates.strategy;
105
+ }
106
+ }
107
+ }
108
+ /**
109
+ * Run cleanup of expired limits
110
+ */
111
+ async cleanup() {
112
+ return this.store.cleanup();
113
+ }
114
+ }
115
+ // Global service instance for helper functions
116
+ let currentService = null;
117
+ /**
118
+ * Set the current rate limit service instance
119
+ * (Called by the plugin on startup)
120
+ */
121
+ export function setRateLimitService(service) {
122
+ currentService = service;
123
+ }
124
+ /**
125
+ * Get the current rate limit service instance
126
+ */
127
+ export function getRateLimitService() {
128
+ if (!currentService) {
129
+ throw new Error('Rate limit plugin not initialized. Did you register the rate limit plugin?');
130
+ }
131
+ return currentService;
132
+ }
133
+ // ============================================
134
+ // Programmatic API (convenience functions)
135
+ // ============================================
136
+ /**
137
+ * Check if a key is currently rate limited
138
+ */
139
+ export async function isLimited(key, options) {
140
+ return getRateLimitService().isLimited(key, options);
141
+ }
142
+ /**
143
+ * Check rate limit status without incrementing counter
144
+ */
145
+ export async function checkLimit(key, options) {
146
+ return getRateLimitService().checkLimit(key, options);
147
+ }
148
+ /**
149
+ * Increment the rate limit counter and return status
150
+ */
151
+ export async function incrementLimit(key, options) {
152
+ return getRateLimitService().incrementLimit(key, options);
153
+ }
154
+ /**
155
+ * Get remaining requests for a key
156
+ */
157
+ export async function getRemainingRequests(key, options) {
158
+ return getRateLimitService().getRemainingRequests(key, options);
159
+ }
160
+ /**
161
+ * Get full limit status for a key
162
+ */
163
+ export async function getLimitStatus(key, options) {
164
+ return getRateLimitService().getLimitStatus(key, options);
165
+ }
166
+ /**
167
+ * Clear a rate limit (e.g., after successful CAPTCHA)
168
+ */
169
+ export async function clearLimit(key, userId) {
170
+ return getRateLimitService().clearLimit(key, userId);
171
+ }
172
+ //# sourceMappingURL=rate-limit-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit-service.js","sourceRoot":"","sources":["../../../src/plugins/rate-limit/rate-limit-service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;GAEG;AACH,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,KAAK,EAAE,WAAW;IAC5B,WAAW,EAAE,GAAG;IAChB,QAAQ,EAAE,gBAAqC;CAChD,CAAC;AAeF;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAK3B,YAAY,MAA8B;QACxC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG;YACd,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,QAAQ,IAAI,QAAQ,CAAC,QAAQ;YACxD,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,WAAW,I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AAW,EAAE,OAA2B;IACjF,OAAO,mBAAmB,EAAE,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAW,EAAE,OAA2B;IAC3E,OAAO,mBAAmB,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,MAAe;IAC3D,OAAO,mBAAmB,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Rate Limit Cache Store
3
+ *
4
+ * Provides a caching layer for rate limits using either Redis (via cache plugin)
5
+ * or an in-memory fallback with LRU eviction.
6
+ *
7
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
8
+ */
9
+ import type { RateLimitCache, RateLimitCacheConfig } from '../types.js';
10
+ /**
11
+ * Create a rate limit cache based on configuration
12
+ *
13
+ * @param config Cache configuration
14
+ * @returns RateLimitCache implementation
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * // Auto-detect (Redis if available, memory fallback)
19
+ * const cache = createRateLimitCache({ type: 'auto' });
20
+ *
21
+ * // Force Redis
22
+ * const redisCache = createRateLimitCache({ type: 'redis', redisInstance: 'default' });
23
+ *
24
+ * // Force in-memory
25
+ * const memoryCache = createRateLimitCache({ type: 'memory', maxMemoryEntries: 5000 });
26
+ * ```
27
+ */
28
+ export declare function createRateLimitCache(config?: RateLimitCacheConfig): RateLimitCache;
29
+ /**
30
+ * Create a no-op cache (for testing or when caching is disabled)
31
+ */
32
+ export declare function createNoOpCache(): RateLimitCache;
33
+ //# sourceMappingURL=cache-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-store.d.ts","sourceRoot":"","sources":["../../../../src/plugins/rate-limit/stores/cache-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EAErB,MAAM,aAAa,CAAC;AAgMrB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,GAAE,oBAAyB,GAAG,cAAc,CAsBtF;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,cAAc,CAUhD"}
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Rate Limit Cache Store
3
+ *
4
+ * Provides a caching layer for rate limits using either Redis (via cache plugin)
5
+ * or an in-memory fallback with LRU eviction.
6
+ *
7
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
8
+ */
9
+ import { hasCache, getCache } from '../../cache-plugin.js';
10
+ /**
11
+ * Simple LRU Cache implementation for in-memory fallback
12
+ */
13
+ class LRUCache {
14
+ constructor(maxSize) {
15
+ this.cache = new Map();
16
+ this.maxSize = maxSize;
17
+ }
18
+ get(key) {
19
+ const entry = this.cache.get(key);
20
+ if (!entry)
21
+ return null;
22
+ // Check expiration
23
+ if (entry.expiresAt <= Date.now()) {
24
+ this.cache.delete(key);
25
+ return null;
26
+ }
27
+ // Move to end (most recently used)
28
+ this.cache.delete(key);
29
+ this.cache.set(key, entry);
30
+ return entry.value;
31
+ }
32
+ set(key, value, ttlMs) {
33
+ // Remove oldest entries if at capacity
34
+ while (this.cache.size >= this.maxSize) {
35
+ const firstKey = this.cache.keys().next().value;
36
+ if (firstKey) {
37
+ this.cache.delete(firstKey);
38
+ }
39
+ else {
40
+ break;
41
+ }
42
+ }
43
+ this.cache.set(key, {
44
+ value,
45
+ expiresAt: Date.now() + ttlMs,
46
+ });
47
+ }
48
+ delete(key) {
49
+ return this.cache.delete(key);
50
+ }
51
+ has(key) {
52
+ const entry = this.cache.get(key);
53
+ if (!entry)
54
+ return false;
55
+ if (entry.expiresAt <= Date.now()) {
56
+ this.cache.delete(key);
57
+ return false;
58
+ }
59
+ return true;
60
+ }
61
+ }
62
+ /**
63
+ * Create a Redis-based cache (uses existing cache plugin)
64
+ */
65
+ function createRedisCache(config) {
66
+ const instanceName = config.redisInstance || 'default';
67
+ const keyPrefix = config.keyPrefix || 'ratelimit:';
68
+ const defaultTtlMs = config.defaultTtlMs || 60000;
69
+ const prefixKey = (key) => `${keyPrefix}${key}`;
70
+ return {
71
+ name: 'redis',
72
+ async get(key) {
73
+ if (!hasCache(instanceName))
74
+ return null;
75
+ try {
76
+ const cache = getCache(instanceName);
77
+ const value = await cache.get(prefixKey(key));
78
+ return value;
79
+ }
80
+ catch {
81
+ return null;
82
+ }
83
+ },
84
+ async set(key, value, ttlMs) {
85
+ if (!hasCache(instanceName))
86
+ return;
87
+ try {
88
+ const cache = getCache(instanceName);
89
+ const ttlSeconds = Math.ceil((ttlMs || defaultTtlMs) / 1000);
90
+ await cache.set(prefixKey(key), value, ttlSeconds);
91
+ }
92
+ catch {
93
+ // Ignore cache errors - we'll fall back to store
94
+ }
95
+ },
96
+ async increment(key, amount = 1) {
97
+ if (!hasCache(instanceName))
98
+ return null;
99
+ try {
100
+ const cache = getCache(instanceName);
101
+ // Get current value and increment
102
+ const current = await cache.get(prefixKey(key));
103
+ if (current) {
104
+ current.count += amount;
105
+ const ttlSeconds = Math.ceil((current.windowEnd - Date.now()) / 1000);
106
+ if (ttlSeconds > 0) {
107
+ await cache.set(prefixKey(key), current, ttlSeconds);
108
+ }
109
+ return current.count;
110
+ }
111
+ return null;
112
+ }
113
+ catch {
114
+ return null;
115
+ }
116
+ },
117
+ async delete(key) {
118
+ if (!hasCache(instanceName))
119
+ return false;
120
+ try {
121
+ const cache = getCache(instanceName);
122
+ return cache.delete(prefixKey(key));
123
+ }
124
+ catch {
125
+ return false;
126
+ }
127
+ },
128
+ isAvailable() {
129
+ return hasCache(instanceName);
130
+ },
131
+ async shutdown() {
132
+ // Redis cache is managed by cache plugin
133
+ },
134
+ };
135
+ }
136
+ /**
137
+ * Create an in-memory cache with LRU eviction
138
+ */
139
+ function createMemoryCache(config) {
140
+ const maxEntries = config.maxMemoryEntries || 10000;
141
+ const keyPrefix = config.keyPrefix || 'ratelimit:';
142
+ const defaultTtlMs = config.defaultTtlMs || 60000;
143
+ const lru = new LRUCache(maxEntries);
144
+ const prefixKey = (key) => `${keyPrefix}${key}`;
145
+ return {
146
+ name: 'memory',
147
+ async get(key) {
148
+ return lru.get(prefixKey(key));
149
+ },
150
+ async set(key, value, ttlMs) {
151
+ lru.set(prefixKey(key), value, ttlMs || defaultTtlMs);
152
+ },
153
+ async increment(key, amount = 1) {
154
+ const current = lru.get(prefixKey(key));
155
+ if (current) {
156
+ current.count += amount;
157
+ const ttlMs = current.windowEnd - Date.now();
158
+ if (ttlMs > 0) {
159
+ lru.set(prefixKey(key), current, ttlMs);
160
+ }
161
+ return current.count;
162
+ }
163
+ return null;
164
+ },
165
+ async delete(key) {
166
+ return lru.delete(prefixKey(key));
167
+ },
168
+ isAvailable() {
169
+ return true; // Memory cache is always available
170
+ },
171
+ async shutdown() {
172
+ // Nothing to do for memory cache
173
+ },
174
+ };
175
+ }
176
+ /**
177
+ * Create a rate limit cache based on configuration
178
+ *
179
+ * @param config Cache configuration
180
+ * @returns RateLimitCache implementation
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * // Auto-detect (Redis if available, memory fallback)
185
+ * const cache = createRateLimitCache({ type: 'auto' });
186
+ *
187
+ * // Force Redis
188
+ * const redisCache = createRateLimitCache({ type: 'redis', redisInstance: 'default' });
189
+ *
190
+ * // Force in-memory
191
+ * const memoryCache = createRateLimitCache({ type: 'memory', maxMemoryEntries: 5000 });
192
+ * ```
193
+ */
194
+ export function createRateLimitCache(config = {}) {
195
+ const cacheType = config.type || 'auto';
196
+ if (cacheType === 'redis') {
197
+ return createRedisCache(config);
198
+ }
199
+ if (cacheType === 'memory') {
200
+ return createMemoryCache(config);
201
+ }
202
+ // Auto: Use Redis if available, fall back to memory
203
+ const redisCache = createRedisCache(config);
204
+ if (redisCache.isAvailable()) {
205
+ return redisCache;
206
+ }
207
+ console.warn('[RateLimitCache] Redis not available, using in-memory cache. ' +
208
+ 'Rate limits will not sync across server instances.');
209
+ return createMemoryCache(config);
210
+ }
211
+ /**
212
+ * Create a no-op cache (for testing or when caching is disabled)
213
+ */
214
+ export function createNoOpCache() {
215
+ return {
216
+ name: 'noop',
217
+ async get() { return null; },
218
+ async set() { },
219
+ async increment() { return null; },
220
+ async delete() { return false; },
221
+ isAvailable() { return false; },
222
+ async shutdown() { },
223
+ };
224
+ }
225
+ //# sourceMappingURL=cache-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-store.js","sourceRoot":"","sources":["../../../../src/plugins/rate-limit/stores/cache-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;GAEG;AACH,MAAM,QAAQ;IAIZ,YAAY,OAAe;QAHnB,UAAK,GAAG,IAAI,GAAG,EAA2C,CAAC;QAIjE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,GAAG,CAAC,GAAW;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAExB,mBAAmB;QACnB,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,mCAAmC;QACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAE3B,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,GAAG,CAAC,GAAW,E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AC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAA+B,EAAE;IACpE,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC;IAExC,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,oDAAoD;IACpD,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,CAAC,IAAI,CACV,+DAA+D;QAC/D,oDAAoD,CACrD,CAAC;IACF,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,KAAK,CAAC,GAAG,KAAkC,OAAO,IAAI,CAAC,CAAC,CAAC;QACzD,KAAK,CAAC,GAAG,KAA+B,CAAC;QACzC,KAAK,CAAC,SAAS,KAA6B,OAAO,IAAI,CAAC,CAAC,CAAC;QAC1D,KAAK,CAAC,MAAM,KAAuB,OAAO,KAAK,CAAC,CAAC,CAAC;QAClD,WAAW,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;QACxC,KAAK,CAAC,QAAQ,KAA+B,CAAC;KAC/C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Rate Limit Stores
3
+ *
4
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
5
+ */
6
+ export { postgresRateLimitStore } from './postgres-store.js';
7
+ export { createRateLimitCache, createNoOpCache } from './cache-store.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/rate-limit/stores/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Rate Limit Stores
3
+ *
4
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
5
+ */
6
+ export { postgresRateLimitStore } from './postgres-store.js';
7
+ export { createRateLimitCache, createNoOpCache } from './cache-store.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/rate-limit/stores/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * PostgreSQL Rate Limit Store
3
+ *
4
+ * Rate limit storage implementation using PostgreSQL with Row-Level Security (RLS).
5
+ * Follows the same pattern as the preferences plugin's postgres-store.
6
+ *
7
+ * RLS Context Pattern:
8
+ * Each operation uses an explicit transaction and sets `app.current_user_id`
9
+ * as a transaction-local configuration variable. The RLS policy checks this
10
+ * variable to enforce that users can only access their own rate limits.
11
+ *
12
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
13
+ */
14
+ import type { RateLimitStore, PostgresRateLimitStoreConfig } from '../types.js';
15
+ /**
16
+ * Create a PostgreSQL rate limit store with RLS
17
+ *
18
+ * @param config Configuration including a pg Pool instance
19
+ * @returns RateLimitStore implementation
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { Pool } from 'pg';
24
+ * import { postgresRateLimitStore } from '@qwickapps/server';
25
+ *
26
+ * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
27
+ * const store = postgresRateLimitStore({ pool });
28
+ *
29
+ * // Or with lazy initialization:
30
+ * const store = postgresRateLimitStore({ pool: () => getPostgres().getPool() });
31
+ * ```
32
+ */
33
+ export declare function postgresRateLimitStore(config: PostgresRateLimitStoreConfig): RateLimitStore;
34
+ //# sourceMappingURL=postgres-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-store.d.ts","sourceRoot":"","sources":["../../../../src/plugins/rate-limit/stores/postgres-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,4BAA4B,EAG7B,MAAM,aAAa,CAAC;AAkDrB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,4BAA4B,GAAG,cAAc,CA0T3F"}