@quvel-kit/core 1.1.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 (285) hide show
  1. package/README.md +670 -0
  2. package/dist/auth/boot/defineAuthGuard.d.ts +54 -0
  3. package/dist/auth/boot/defineAuthGuard.d.ts.map +1 -0
  4. package/dist/auth/boot/defineAuthGuard.js +72 -0
  5. package/dist/auth/enums/AuthStatusEnum.d.ts +13 -0
  6. package/dist/auth/enums/AuthStatusEnum.d.ts.map +1 -0
  7. package/dist/auth/enums/AuthStatusEnum.js +13 -0
  8. package/dist/auth/index.d.ts +13 -0
  9. package/dist/auth/index.d.ts.map +1 -0
  10. package/dist/auth/index.js +13 -0
  11. package/dist/auth/services/AuthGuard.d.ts +58 -0
  12. package/dist/auth/services/AuthGuard.d.ts.map +1 -0
  13. package/dist/auth/services/AuthGuard.js +51 -0
  14. package/dist/auth/services/AuthService.d.ts +52 -0
  15. package/dist/auth/services/AuthService.d.ts.map +1 -0
  16. package/dist/auth/services/AuthService.js +67 -0
  17. package/dist/auth/services/PasswordResetService.d.ts +34 -0
  18. package/dist/auth/services/PasswordResetService.d.ts.map +1 -0
  19. package/dist/auth/services/PasswordResetService.js +45 -0
  20. package/dist/auth/services/TwoFactorChallengeService.d.ts +22 -0
  21. package/dist/auth/services/TwoFactorChallengeService.d.ts.map +1 -0
  22. package/dist/auth/services/TwoFactorChallengeService.js +29 -0
  23. package/dist/auth/services/TwoFactorService.d.ts +64 -0
  24. package/dist/auth/services/TwoFactorService.d.ts.map +1 -0
  25. package/dist/auth/services/TwoFactorService.js +68 -0
  26. package/dist/auth/services/index.d.ts +8 -0
  27. package/dist/auth/services/index.d.ts.map +1 -0
  28. package/dist/auth/services/index.js +5 -0
  29. package/dist/auth/types/auth-meta.d.ts +54 -0
  30. package/dist/auth/types/auth-meta.d.ts.map +1 -0
  31. package/dist/auth/types/auth-meta.js +6 -0
  32. package/dist/auth/types/index.d.ts +5 -0
  33. package/dist/auth/types/index.d.ts.map +1 -0
  34. package/dist/auth/types/index.js +4 -0
  35. package/dist/auth/utils/auth-meta.d.ts +75 -0
  36. package/dist/auth/utils/auth-meta.d.ts.map +1 -0
  37. package/dist/auth/utils/auth-meta.js +93 -0
  38. package/dist/boot/quvel.d.ts +26 -0
  39. package/dist/boot/quvel.d.ts.map +1 -0
  40. package/dist/boot/quvel.js +38 -0
  41. package/dist/build/index.d.ts +9 -0
  42. package/dist/build/index.d.ts.map +1 -0
  43. package/dist/build/index.js +8 -0
  44. package/dist/build/loadEnv.d.ts +14 -0
  45. package/dist/build/loadEnv.d.ts.map +1 -0
  46. package/dist/build/loadEnv.js +33 -0
  47. package/dist/build/quasarConfig.d.ts +67 -0
  48. package/dist/build/quasarConfig.d.ts.map +1 -0
  49. package/dist/build/quasarConfig.js +126 -0
  50. package/dist/components/Common/TaskErrors.vue +47 -0
  51. package/dist/components/Inputs/BaseInput.vue +88 -0
  52. package/dist/components/Misc/ClientOnly.vue +22 -0
  53. package/dist/components/Transitions/FadeInOut.vue +9 -0
  54. package/dist/components/Transitions/SlowExpand.vue +13 -0
  55. package/dist/components/WebSocketChannelManager.vue +634 -0
  56. package/dist/components/index.d.ts +12 -0
  57. package/dist/components/index.d.ts.map +1 -0
  58. package/dist/components/index.js +16 -0
  59. package/dist/composables/index.d.ts +19 -0
  60. package/dist/composables/index.d.ts.map +1 -0
  61. package/dist/composables/index.js +16 -0
  62. package/dist/composables/useClient.d.ts +16 -0
  63. package/dist/composables/useClient.d.ts.map +1 -0
  64. package/dist/composables/useClient.js +28 -0
  65. package/dist/composables/useMetaConfig.d.ts +14 -0
  66. package/dist/composables/useMetaConfig.d.ts.map +1 -0
  67. package/dist/composables/useMetaConfig.js +77 -0
  68. package/dist/composables/useQueryMessageHandler.d.ts +44 -0
  69. package/dist/composables/useQueryMessageHandler.d.ts.map +1 -0
  70. package/dist/composables/useQueryMessageHandler.js +74 -0
  71. package/dist/composables/useQuvel.d.ts +15 -0
  72. package/dist/composables/useQuvel.d.ts.map +1 -0
  73. package/dist/composables/useQuvel.js +38 -0
  74. package/dist/composables/useRecaptcha.d.ts +35 -0
  75. package/dist/composables/useRecaptcha.d.ts.map +1 -0
  76. package/dist/composables/useRecaptcha.js +87 -0
  77. package/dist/composables/useScopedService.d.ts +18 -0
  78. package/dist/composables/useScopedService.d.ts.map +1 -0
  79. package/dist/composables/useScopedService.js +25 -0
  80. package/dist/composables/useScript.d.ts +25 -0
  81. package/dist/composables/useScript.d.ts.map +1 -0
  82. package/dist/composables/useScript.js +106 -0
  83. package/dist/composables/useUrlQueryHandler.d.ts +38 -0
  84. package/dist/composables/useUrlQueryHandler.d.ts.map +1 -0
  85. package/dist/composables/useUrlQueryHandler.js +76 -0
  86. package/dist/composables/useWebSockets.d.ts +18 -0
  87. package/dist/composables/useWebSockets.d.ts.map +1 -0
  88. package/dist/composables/useWebSockets.js +55 -0
  89. package/dist/composables/useWindowEvent.d.ts +16 -0
  90. package/dist/composables/useWindowEvent.d.ts.map +1 -0
  91. package/dist/composables/useWindowEvent.js +27 -0
  92. package/dist/composables/useXsrf.d.ts +29 -0
  93. package/dist/composables/useXsrf.d.ts.map +1 -0
  94. package/dist/composables/useXsrf.js +59 -0
  95. package/dist/config/QuasarConfigBuilder.d.ts +100 -0
  96. package/dist/config/QuasarConfigBuilder.d.ts.map +1 -0
  97. package/dist/config/QuasarConfigBuilder.js +98 -0
  98. package/dist/config/i18n.d.ts +23 -0
  99. package/dist/config/i18n.d.ts.map +1 -0
  100. package/dist/config/i18n.js +43 -0
  101. package/dist/config/index.d.ts +8 -0
  102. package/dist/config/index.d.ts.map +1 -0
  103. package/dist/config/index.js +7 -0
  104. package/dist/config/moduleTransformer.d.ts +18 -0
  105. package/dist/config/moduleTransformer.d.ts.map +1 -0
  106. package/dist/config/moduleTransformer.js +76 -0
  107. package/dist/config/quvel.d.ts +40 -0
  108. package/dist/config/quvel.d.ts.map +1 -0
  109. package/dist/config/quvel.js +59 -0
  110. package/dist/config/quvel.types.d.ts +59 -0
  111. package/dist/config/quvel.types.d.ts.map +1 -0
  112. package/dist/config/quvel.types.js +6 -0
  113. package/dist/container/ServiceContainer.d.ts +107 -0
  114. package/dist/container/ServiceContainer.d.ts.map +1 -0
  115. package/dist/container/ServiceContainer.js +201 -0
  116. package/dist/container/types/vue.d.ts +9 -0
  117. package/dist/container/types.d.ts +81 -0
  118. package/dist/container/types.d.ts.map +1 -0
  119. package/dist/container/types.js +1 -0
  120. package/dist/i18n/en-US/common.d.ts +19 -0
  121. package/dist/i18n/en-US/common.d.ts.map +1 -0
  122. package/dist/i18n/en-US/common.js +17 -0
  123. package/dist/i18n/en-US/index.d.ts +21 -0
  124. package/dist/i18n/en-US/index.d.ts.map +1 -0
  125. package/dist/i18n/en-US/index.js +4 -0
  126. package/dist/i18n/es-MX/common.d.ts +19 -0
  127. package/dist/i18n/es-MX/common.d.ts.map +1 -0
  128. package/dist/i18n/es-MX/common.js +17 -0
  129. package/dist/i18n/es-MX/index.d.ts +21 -0
  130. package/dist/i18n/es-MX/index.d.ts.map +1 -0
  131. package/dist/i18n/es-MX/index.js +4 -0
  132. package/dist/index.d.ts +54 -0
  133. package/dist/index.d.ts.map +1 -0
  134. package/dist/index.js +67 -0
  135. package/dist/models/User.d.ts +32 -0
  136. package/dist/models/User.d.ts.map +1 -0
  137. package/dist/models/User.js +48 -0
  138. package/dist/module.d.ts +21 -0
  139. package/dist/module.d.ts.map +1 -0
  140. package/dist/module.js +45 -0
  141. package/dist/modules/helpers.d.ts +30 -0
  142. package/dist/modules/helpers.d.ts.map +1 -0
  143. package/dist/modules/helpers.js +45 -0
  144. package/dist/modules/index.d.ts +8 -0
  145. package/dist/modules/index.d.ts.map +1 -0
  146. package/dist/modules/index.js +6 -0
  147. package/dist/modules/types.d.ts +141 -0
  148. package/dist/modules/types.d.ts.map +1 -0
  149. package/dist/modules/types.js +7 -0
  150. package/dist/pages/ErrorNotFound.vue +300 -0
  151. package/dist/pages/index.d.ts +7 -0
  152. package/dist/pages/index.d.ts.map +1 -0
  153. package/dist/pages/index.js +6 -0
  154. package/dist/services/ApiService.d.ts +90 -0
  155. package/dist/services/ApiService.d.ts.map +1 -0
  156. package/dist/services/ApiService.js +159 -0
  157. package/dist/services/I18nService.d.ts +67 -0
  158. package/dist/services/I18nService.d.ts.map +1 -0
  159. package/dist/services/I18nService.js +92 -0
  160. package/dist/services/LogService.d.ts +31 -0
  161. package/dist/services/LogService.d.ts.map +1 -0
  162. package/dist/services/LogService.js +49 -0
  163. package/dist/services/Service.d.ts +10 -0
  164. package/dist/services/Service.d.ts.map +1 -0
  165. package/dist/services/Service.js +8 -0
  166. package/dist/services/TaskService.d.ts +64 -0
  167. package/dist/services/TaskService.d.ts.map +1 -0
  168. package/dist/services/TaskService.js +188 -0
  169. package/dist/services/ThemeService.d.ts +28 -0
  170. package/dist/services/ThemeService.d.ts.map +1 -0
  171. package/dist/services/ThemeService.js +77 -0
  172. package/dist/services/ValidationService.d.ts +55 -0
  173. package/dist/services/ValidationService.d.ts.map +1 -0
  174. package/dist/services/ValidationService.js +81 -0
  175. package/dist/services/WebSocketService.d.ts +59 -0
  176. package/dist/services/WebSocketService.d.ts.map +1 -0
  177. package/dist/services/WebSocketService.js +148 -0
  178. package/dist/services/logger/BaseLogger.d.ts +35 -0
  179. package/dist/services/logger/BaseLogger.d.ts.map +1 -0
  180. package/dist/services/logger/BaseLogger.js +66 -0
  181. package/dist/services/logger/ConsoleLogger.d.ts +21 -0
  182. package/dist/services/logger/ConsoleLogger.d.ts.map +1 -0
  183. package/dist/services/logger/ConsoleLogger.js +60 -0
  184. package/dist/services/logger/NullLogger.d.ts +10 -0
  185. package/dist/services/logger/NullLogger.d.ts.map +1 -0
  186. package/dist/services/logger/NullLogger.js +10 -0
  187. package/dist/stores/plugins/serviceContainer.d.ts +10 -0
  188. package/dist/stores/plugins/serviceContainer.d.ts.map +1 -0
  189. package/dist/stores/plugins/serviceContainer.js +14 -0
  190. package/dist/stores/sessionStore.d.ts +71 -0
  191. package/dist/stores/sessionStore.d.ts.map +1 -0
  192. package/dist/stores/sessionStore.js +125 -0
  193. package/dist/types/app.types.d.ts +202 -0
  194. package/dist/types/app.types.d.ts.map +1 -0
  195. package/dist/types/app.types.js +6 -0
  196. package/dist/types/config.types.d.ts +2 -0
  197. package/dist/types/config.types.d.ts.map +1 -0
  198. package/dist/types/config.types.js +1 -0
  199. package/dist/types/global.d.ts +33 -0
  200. package/dist/types/i18n.types.d.ts +21 -0
  201. package/dist/types/i18n.types.d.ts.map +1 -0
  202. package/dist/types/i18n.types.js +6 -0
  203. package/dist/types/laravel.types.d.ts +167 -0
  204. package/dist/types/laravel.types.d.ts.map +1 -0
  205. package/dist/types/laravel.types.js +6 -0
  206. package/dist/types/logging.types.d.ts +81 -0
  207. package/dist/types/logging.types.d.ts.map +1 -0
  208. package/dist/types/logging.types.js +22 -0
  209. package/dist/types/pinia.d.ts +24 -0
  210. package/dist/types/scripts.types.d.ts +31 -0
  211. package/dist/types/scripts.types.d.ts.map +1 -0
  212. package/dist/types/scripts.types.js +6 -0
  213. package/dist/types/ssr.d.ts +11 -0
  214. package/dist/types/task.types.d.ts +121 -0
  215. package/dist/types/task.types.d.ts.map +1 -0
  216. package/dist/types/task.types.js +7 -0
  217. package/dist/types/theme.types.d.ts +13 -0
  218. package/dist/types/theme.types.d.ts.map +1 -0
  219. package/dist/types/theme.types.js +17 -0
  220. package/dist/types/user.types.d.ts +24 -0
  221. package/dist/types/user.types.d.ts.map +1 -0
  222. package/dist/types/user.types.js +1 -0
  223. package/dist/types/vue-shim.d.ts +11 -0
  224. package/dist/types/websocket.types.d.ts +62 -0
  225. package/dist/types/websocket.types.d.ts.map +1 -0
  226. package/dist/types/websocket.types.js +6 -0
  227. package/dist/utils/apiInterceptors.d.ts +76 -0
  228. package/dist/utils/apiInterceptors.d.ts.map +1 -0
  229. package/dist/utils/apiInterceptors.js +149 -0
  230. package/dist/utils/assets.d.ts +40 -0
  231. package/dist/utils/assets.d.ts.map +1 -0
  232. package/dist/utils/assets.js +340 -0
  233. package/dist/utils/axios.d.ts +19 -0
  234. package/dist/utils/axios.d.ts.map +1 -0
  235. package/dist/utils/axios.js +113 -0
  236. package/dist/utils/config.d.ts +16 -0
  237. package/dist/utils/config.d.ts.map +1 -0
  238. package/dist/utils/config.js +48 -0
  239. package/dist/utils/container.d.ts +12 -0
  240. package/dist/utils/container.d.ts.map +1 -0
  241. package/dist/utils/container.js +11 -0
  242. package/dist/utils/deepMerge.d.ts +28 -0
  243. package/dist/utils/deepMerge.d.ts.map +1 -0
  244. package/dist/utils/deepMerge.js +59 -0
  245. package/dist/utils/envConfig.d.ts +73 -0
  246. package/dist/utils/envConfig.d.ts.map +1 -0
  247. package/dist/utils/envConfig.js +161 -0
  248. package/dist/utils/error.d.ts +44 -0
  249. package/dist/utils/error.d.ts.map +1 -0
  250. package/dist/utils/error.js +67 -0
  251. package/dist/utils/headers.d.ts +36 -0
  252. package/dist/utils/headers.d.ts.map +1 -0
  253. package/dist/utils/headers.js +54 -0
  254. package/dist/utils/i18n.d.ts +26 -0
  255. package/dist/utils/i18n.d.ts.map +1 -0
  256. package/dist/utils/i18n.js +56 -0
  257. package/dist/utils/index.d.ts +14 -0
  258. package/dist/utils/index.d.ts.map +1 -0
  259. package/dist/utils/index.js +13 -0
  260. package/dist/utils/loading.d.ts +29 -0
  261. package/dist/utils/loading.d.ts.map +1 -0
  262. package/dist/utils/loading.js +46 -0
  263. package/dist/utils/logging.d.ts +20 -0
  264. package/dist/utils/logging.d.ts.map +1 -0
  265. package/dist/utils/logging.js +54 -0
  266. package/dist/utils/notify.d.ts +15 -0
  267. package/dist/utils/notify.d.ts.map +1 -0
  268. package/dist/utils/notify.js +30 -0
  269. package/dist/utils/object.d.ts +28 -0
  270. package/dist/utils/object.d.ts.map +1 -0
  271. package/dist/utils/object.js +48 -0
  272. package/dist/utils/pagination.d.ts +60 -0
  273. package/dist/utils/pagination.d.ts.map +1 -0
  274. package/dist/utils/pagination.js +252 -0
  275. package/dist/utils/paths.d.ts +54 -0
  276. package/dist/utils/paths.d.ts.map +1 -0
  277. package/dist/utils/paths.js +48 -0
  278. package/dist/utils/platform.d.ts +25 -0
  279. package/dist/utils/platform.d.ts.map +1 -0
  280. package/dist/utils/platform.js +64 -0
  281. package/dist/utils/scripts.d.ts +20 -0
  282. package/dist/utils/scripts.d.ts.map +1 -0
  283. package/dist/utils/scripts.js +39 -0
  284. package/global.d.ts +29 -0
  285. package/package.json +119 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineAuthGuard.d.ts","sourceRoot":"","sources":["../../../src/auth/boot/defineAuthGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D;;;OAGG;IACH,eAAe,EAAE,MAAM,OAAO,CAAC;IAE/B;;;OAGG;IACH,wBAAwB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,IAC7C,+BAA+B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC5D,mBAyDF"}
@@ -0,0 +1,72 @@
1
+ import { AuthGuard } from '../services/AuthGuard.js';
2
+ /**
3
+ * Create auth guard boot function
4
+ *
5
+ * This helper creates a Quasar boot function that sets up authentication
6
+ * guards for the router using the framework-agnostic AuthGuard service.
7
+ *
8
+ * @param config - Auth guard configuration
9
+ * @returns Boot function for Quasar
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { defineAuthGuard } from '@quvel-kit/core/auth';
14
+ * import { useSessionStore } from '../stores/sessionStore';
15
+ *
16
+ * export default boot(defineAuthGuard({
17
+ * requireAuthByDefault: true,
18
+ * loginRoute: 'login',
19
+ * successRoute: 'dashboard',
20
+ * isAuthenticated: () => useSessionStore().isAuthenticated,
21
+ * ensureSessionInitialized: async () => {
22
+ * const store = useSessionStore();
23
+ * if (!store.isInitialized) {
24
+ * await store.fetchSession();
25
+ * }
26
+ * },
27
+ * }));
28
+ * ```
29
+ */
30
+ export function defineAuthGuard(config) {
31
+ return async ({ router, urlPath, redirect }) => {
32
+ const authGuard = new AuthGuard({
33
+ requireAuthByDefault: config.requireAuthByDefault,
34
+ loginRoute: config.loginRoute,
35
+ successRoute: config.successRoute,
36
+ });
37
+ const resolvedRoute = router.resolve(urlPath);
38
+ const routeAuthMeta = resolvedRoute?.meta.auth;
39
+ if (routeAuthMeta?.skipAuth === true) {
40
+ return;
41
+ }
42
+ try {
43
+ await config.ensureSessionInitialized();
44
+ }
45
+ catch {
46
+ // Ignore fetch errors - the user is just not authenticated
47
+ }
48
+ const initialCheck = authGuard.check(routeAuthMeta, config.isAuthenticated());
49
+ if (initialCheck.action === 'redirect') {
50
+ const route = initialCheck.route;
51
+ const redirectTarget = route.startsWith('/') ? { path: route } : { name: route };
52
+ redirect(redirectTarget);
53
+ return;
54
+ }
55
+ router.beforeEach(async (to, _from, next) => {
56
+ try {
57
+ await config.ensureSessionInitialized();
58
+ }
59
+ catch {
60
+ // Ignore fetch errors
61
+ }
62
+ const authCheck = authGuard.check(to.meta.auth, config.isAuthenticated());
63
+ if (authCheck.action === 'redirect') {
64
+ const route = authCheck.route;
65
+ const redirectTarget = route.startsWith('/') ? { path: route } : { name: route };
66
+ next(redirectTarget);
67
+ return;
68
+ }
69
+ next();
70
+ });
71
+ };
72
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Authentication status codes
3
+ */
4
+ export declare enum AuthStatus {
5
+ USER_NOT_FOUND = "user_not_found",
6
+ INVALID_CREDENTIALS = "invalid_credentials",
7
+ EMAIL_ALREADY_IN_USE = "email_already_in_use",
8
+ EMAIL_NOT_VERIFIED = "email_not_verified",
9
+ LOGOUT_SUCCESS = "logout_success",
10
+ LOGIN_SUCCESS = "login_success",
11
+ REGISTER_SUCCESS = "register_success"
12
+ }
13
+ //# sourceMappingURL=AuthStatusEnum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthStatusEnum.d.ts","sourceRoot":"","sources":["../../../src/auth/enums/AuthStatusEnum.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,UAAU;IACpB,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,oBAAoB,yBAAyB;IAC7C,kBAAkB,uBAAuB;IAEzC,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;CACtC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Authentication status codes
3
+ */
4
+ export var AuthStatus;
5
+ (function (AuthStatus) {
6
+ AuthStatus["USER_NOT_FOUND"] = "user_not_found";
7
+ AuthStatus["INVALID_CREDENTIALS"] = "invalid_credentials";
8
+ AuthStatus["EMAIL_ALREADY_IN_USE"] = "email_already_in_use";
9
+ AuthStatus["EMAIL_NOT_VERIFIED"] = "email_not_verified";
10
+ AuthStatus["LOGOUT_SUCCESS"] = "logout_success";
11
+ AuthStatus["LOGIN_SUCCESS"] = "login_success";
12
+ AuthStatus["REGISTER_SUCCESS"] = "register_success";
13
+ })(AuthStatus || (AuthStatus = {}));
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Authentication Module
3
+ *
4
+ * Framework-agnostic authentication services, types, and utilities.
5
+ */
6
+ export { AuthService, PasswordResetService, TwoFactorService, TwoFactorChallengeService, AuthGuard, } from './services/index.js';
7
+ export type { AuthCheckResult, AuthGuardConfig, TwoFactorQRResponse, TwoFactorSecretResponse, TwoFactorRecoveryCodesResponse, } from './services/index.js';
8
+ export { defineAuthGuard } from './boot/defineAuthGuard.js';
9
+ export type { DefineAuthGuardConfig } from './boot/defineAuthGuard.js';
10
+ export type { AuthMeta } from './types/index.js';
11
+ export { createAuthMeta, createGuestOnlyAuth, createProtectedAuth, createPublicAuth, createSkipAuth, } from './utils/auth-meta.js';
12
+ export { AuthStatus } from './enums/AuthStatusEnum.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,yBAAyB,EACzB,SAAS,GACV,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGvE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Authentication Module
3
+ *
4
+ * Framework-agnostic authentication services, types, and utilities.
5
+ */
6
+ // Services
7
+ export { AuthService, PasswordResetService, TwoFactorService, TwoFactorChallengeService, AuthGuard, } from './services/index.js';
8
+ // Boot helpers
9
+ export { defineAuthGuard } from './boot/defineAuthGuard.js';
10
+ // Utilities
11
+ export { createAuthMeta, createGuestOnlyAuth, createProtectedAuth, createPublicAuth, createSkipAuth, } from './utils/auth-meta.js';
12
+ // Enums
13
+ export { AuthStatus } from './enums/AuthStatusEnum.js';
@@ -0,0 +1,58 @@
1
+ import type { AuthMeta } from '../types/auth-meta.js';
2
+ /**
3
+ * Configuration options for AuthGuard
4
+ */
5
+ export interface AuthGuardConfig {
6
+ /**
7
+ * Whether authentication is required by default for all routes
8
+ * @default true
9
+ */
10
+ requireAuthByDefault?: boolean;
11
+ /**
12
+ * Route name/path to redirect to for login
13
+ */
14
+ loginRoute: string;
15
+ /**
16
+ * Route name/path to redirect to after successful authentication
17
+ */
18
+ successRoute: string;
19
+ }
20
+ /**
21
+ * Result of an auth check
22
+ */
23
+ export interface AuthCheckResult {
24
+ /**
25
+ * Action to take: 'continue' allows navigation, 'redirect' blocks it
26
+ */
27
+ action: 'continue' | 'redirect';
28
+ /**
29
+ * Route to redirect to (only present when action is 'redirect')
30
+ */
31
+ route?: string;
32
+ }
33
+ /**
34
+ * Framework-agnostic authentication guard service.
35
+ *
36
+ * Evaluates route authentication requirements and determines
37
+ * whether navigation should proceed or redirect.
38
+ *
39
+ * This service contains the core auth logic that can be used
40
+ * by any routing framework's middleware/guards.
41
+ */
42
+ export declare class AuthGuard {
43
+ private config;
44
+ constructor(config: AuthGuardConfig);
45
+ /**
46
+ * Updates the guard configuration
47
+ */
48
+ setConfig(config: Partial<AuthGuardConfig>): void;
49
+ /**
50
+ * Performs an authentication check for a route
51
+ *
52
+ * @param authMeta - The auth metadata from the route
53
+ * @param isAuthenticated - Whether the user is currently authenticated
54
+ * @returns The result indicating whether to continue or redirect
55
+ */
56
+ check(authMeta: AuthMeta | undefined, isAuthenticated: boolean): AuthCheckResult;
57
+ }
58
+ //# sourceMappingURL=AuthGuard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthGuard.d.ts","sourceRoot":"","sources":["../../../src/auth/services/AuthGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,EAAE,eAAe;IAOnC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAIjD;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAAE,eAAe,EAAE,OAAO,GAAG,eAAe;CA4BjF"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Framework-agnostic authentication guard service.
3
+ *
4
+ * Evaluates route authentication requirements and determines
5
+ * whether navigation should proceed or redirect.
6
+ *
7
+ * This service contains the core auth logic that can be used
8
+ * by any routing framework's middleware/guards.
9
+ */
10
+ export class AuthGuard {
11
+ config;
12
+ constructor(config) {
13
+ this.config = {
14
+ requireAuthByDefault: true,
15
+ ...config,
16
+ };
17
+ }
18
+ /**
19
+ * Updates the guard configuration
20
+ */
21
+ setConfig(config) {
22
+ this.config = { ...this.config, ...config };
23
+ }
24
+ /**
25
+ * Performs an authentication check for a route
26
+ *
27
+ * @param authMeta - The auth metadata from the route
28
+ * @param isAuthenticated - Whether the user is currently authenticated
29
+ * @returns The result indicating whether to continue or redirect
30
+ */
31
+ check(authMeta, isAuthenticated) {
32
+ const authConfig = authMeta || {};
33
+ if (authConfig.skipAuth === true) {
34
+ return { action: 'continue' };
35
+ }
36
+ if (authConfig.guestOnly === true) {
37
+ if (isAuthenticated) {
38
+ const redirectTarget = authConfig.redirectTo || this.config.successRoute;
39
+ return { action: 'redirect', route: redirectTarget };
40
+ }
41
+ return { action: 'continue' };
42
+ }
43
+ const routeRequiresAuth = authConfig.requiresAuth !== undefined
44
+ ? authConfig.requiresAuth
45
+ : this.config.requireAuthByDefault;
46
+ if (routeRequiresAuth && !isAuthenticated) {
47
+ return { action: 'redirect', route: this.config.loginRoute };
48
+ }
49
+ return { action: 'continue' };
50
+ }
51
+ }
@@ -0,0 +1,52 @@
1
+ import { Service } from '../../services/Service.js';
2
+ import { ServiceContainer } from '../../container/ServiceContainer.js';
3
+ import type { RegisterService } from '../../container/types.js';
4
+ import type { IUser } from '../../types/user.types.js';
5
+ import { AuthStatus } from '../enums/AuthStatusEnum.js';
6
+ /**
7
+ * Service responsible for handling login, registration, and session management.
8
+ */
9
+ export declare class AuthService extends Service implements RegisterService {
10
+ private api;
11
+ /**
12
+ * Registers the service with the container.
13
+ *
14
+ * @param container - The service container instance.
15
+ */
16
+ register({ api }: ServiceContainer): void;
17
+ /**
18
+ * Fetches the current user session.
19
+ *
20
+ * @returns The user data or null if not authenticated.
21
+ */
22
+ fetchSession(): Promise<IUser | null>;
23
+ /**
24
+ * Logs the user out.
25
+ */
26
+ logout(): Promise<void>;
27
+ /**
28
+ * Authenticates a user with email and password.
29
+ *
30
+ * @param email - The user's email.
31
+ * @param password - The user's password.
32
+ * @returns The authenticated user data or two-factor challenge indication.
33
+ */
34
+ login(email: string, password: string): Promise<{
35
+ user?: IUser;
36
+ two_factor?: boolean;
37
+ }>;
38
+ /**
39
+ * Registers a new user.
40
+ *
41
+ * @param email - The user's email.
42
+ * @param password - The user's password.
43
+ * @param name - The user's name.
44
+ * @param recaptchaToken - Google reCAPTCHA token for verification
45
+ * @returns The registration status and user data.
46
+ */
47
+ signUp(email: string, password: string, name: string, recaptchaToken?: string): Promise<{
48
+ status: AuthStatus;
49
+ user: IUser;
50
+ }>;
51
+ }
52
+ //# sourceMappingURL=AuthService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthService.d.ts","sourceRoot":"","sources":["../../../src/auth/services/AuthService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD;;GAEG;AACH,qBAAa,WAAY,SAAQ,OAAQ,YAAW,eAAe;IACjE,OAAO,CAAC,GAAG,CAAc;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,gBAAgB,GAAG,IAAI;IAIzC;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAY3C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE,KAAK,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAO7F;;;;;;;;OAQG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC;QACT,MAAM,EAAE,UAAU,CAAC;QACnB,IAAI,EAAE,KAAK,CAAC;KACb,CAAC;CAWH"}
@@ -0,0 +1,67 @@
1
+ import { Service } from '../../services/Service.js';
2
+ /**
3
+ * Service responsible for handling login, registration, and session management.
4
+ */
5
+ export class AuthService extends Service {
6
+ api;
7
+ /**
8
+ * Registers the service with the container.
9
+ *
10
+ * @param container - The service container instance.
11
+ */
12
+ register({ api }) {
13
+ this.api = api;
14
+ }
15
+ /**
16
+ * Fetches the current user session.
17
+ *
18
+ * @returns The user data or null if not authenticated.
19
+ */
20
+ async fetchSession() {
21
+ try {
22
+ const { data } = await this.api.get('/auth/session', {
23
+ requiresSessionCookie: true,
24
+ });
25
+ return data;
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ /**
32
+ * Logs the user out.
33
+ */
34
+ async logout() {
35
+ await this.api.post('/auth/logout');
36
+ }
37
+ /**
38
+ * Authenticates a user with email and password.
39
+ *
40
+ * @param email - The user's email.
41
+ * @param password - The user's password.
42
+ * @returns The authenticated user data or two-factor challenge indication.
43
+ */
44
+ async login(email, password) {
45
+ return await this.api.post('/auth/login', {
46
+ email,
47
+ password,
48
+ });
49
+ }
50
+ /**
51
+ * Registers a new user.
52
+ *
53
+ * @param email - The user's email.
54
+ * @param password - The user's password.
55
+ * @param name - The user's name.
56
+ * @param recaptchaToken - Google reCAPTCHA token for verification
57
+ * @returns The registration status and user data.
58
+ */
59
+ async signUp(email, password, name, recaptchaToken) {
60
+ return await this.api.post('/auth/register', {
61
+ email,
62
+ password,
63
+ name,
64
+ captcha_token: recaptchaToken,
65
+ });
66
+ }
67
+ }
@@ -0,0 +1,34 @@
1
+ import { Service } from '../../services/Service.js';
2
+ import { ServiceContainer } from '../../container/ServiceContainer.js';
3
+ import type { RegisterService } from '../../container/types.js';
4
+ /**
5
+ * Service responsible for handling password reset operations.
6
+ */
7
+ export declare class PasswordResetService extends Service implements RegisterService {
8
+ private api;
9
+ /**
10
+ * Registers the service with the container.
11
+ *
12
+ * @param container - The service container instance.
13
+ */
14
+ register({ api }: ServiceContainer): void;
15
+ /**
16
+ * Sends a password reset link to the user's email.
17
+ *
18
+ * @param email - The user's email.
19
+ * @param recaptchaToken - Google reCAPTCHA token for verification
20
+ * @returns A promise that resolves when the request is complete.
21
+ */
22
+ sendPasswordResetLink(email: string, recaptchaToken?: string): Promise<void>;
23
+ /**
24
+ * Resets a user's password using a token.
25
+ *
26
+ * @param token - The password reset token.
27
+ * @param email - The user's email.
28
+ * @param password - The new password.
29
+ * @param passwordConfirmation - The password confirmation.
30
+ * @returns A promise that resolves when the password has been reset.
31
+ */
32
+ resetPassword(token: string, email: string, password: string, passwordConfirmation: string): Promise<void>;
33
+ }
34
+ //# sourceMappingURL=PasswordResetService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PasswordResetService.d.ts","sourceRoot":"","sources":["../../../src/auth/services/PasswordResetService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,OAAQ,YAAW,eAAe;IAC1E,OAAO,CAAC,GAAG,CAAc;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,gBAAgB,GAAG,IAAI;IAIzC;;;;;;OAMG;IACH,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO5E;;;;;;;;OAQG;IACH,aAAa,CACX,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAAC,IAAI,CAAC;CAQjB"}
@@ -0,0 +1,45 @@
1
+ import { Service } from '../../services/Service.js';
2
+ /**
3
+ * Service responsible for handling password reset operations.
4
+ */
5
+ export class PasswordResetService extends Service {
6
+ api;
7
+ /**
8
+ * Registers the service with the container.
9
+ *
10
+ * @param container - The service container instance.
11
+ */
12
+ register({ api }) {
13
+ this.api = api;
14
+ }
15
+ /**
16
+ * Sends a password reset link to the user's email.
17
+ *
18
+ * @param email - The user's email.
19
+ * @param recaptchaToken - Google reCAPTCHA token for verification
20
+ * @returns A promise that resolves when the request is complete.
21
+ */
22
+ sendPasswordResetLink(email, recaptchaToken) {
23
+ return this.api.post('/auth/forgot-password', {
24
+ email,
25
+ captcha_token: recaptchaToken,
26
+ });
27
+ }
28
+ /**
29
+ * Resets a user's password using a token.
30
+ *
31
+ * @param token - The password reset token.
32
+ * @param email - The user's email.
33
+ * @param password - The new password.
34
+ * @param passwordConfirmation - The password confirmation.
35
+ * @returns A promise that resolves when the password has been reset.
36
+ */
37
+ resetPassword(token, email, password, passwordConfirmation) {
38
+ return this.api.post('/auth/reset-password', {
39
+ token,
40
+ email,
41
+ password,
42
+ password_confirmation: passwordConfirmation,
43
+ });
44
+ }
45
+ }
@@ -0,0 +1,22 @@
1
+ import { Service } from '../../services/Service.js';
2
+ import { ServiceContainer } from '../../container/ServiceContainer.js';
3
+ import type { RegisterService } from '../../container/types.js';
4
+ /**
5
+ * Service for handling two-factor authentication challenges during login.
6
+ */
7
+ export declare class TwoFactorChallengeService extends Service implements RegisterService {
8
+ private api;
9
+ /**
10
+ * Registers the service.
11
+ */
12
+ register({ api }: ServiceContainer): void;
13
+ /**
14
+ * Submit two-factor authentication code to complete login
15
+ */
16
+ submitCode(code: string): Promise<void>;
17
+ /**
18
+ * Submit recovery code to complete login
19
+ */
20
+ submitRecoveryCode(recovery_code: string): Promise<void>;
21
+ }
22
+ //# sourceMappingURL=TwoFactorChallengeService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TwoFactorChallengeService.d.ts","sourceRoot":"","sources":["../../../src/auth/services/TwoFactorChallengeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,OAAQ,YAAW,eAAe;IAC/E,OAAO,CAAC,GAAG,CAAc;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,gBAAgB,GAAG,IAAI;IAIzC;;OAEG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7C;;OAEG;IACG,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAK/D"}
@@ -0,0 +1,29 @@
1
+ import { Service } from '../../services/Service.js';
2
+ /**
3
+ * Service for handling two-factor authentication challenges during login.
4
+ */
5
+ export class TwoFactorChallengeService extends Service {
6
+ api;
7
+ /**
8
+ * Registers the service.
9
+ */
10
+ register({ api }) {
11
+ this.api = api;
12
+ }
13
+ /**
14
+ * Submit two-factor authentication code to complete login
15
+ */
16
+ async submitCode(code) {
17
+ await this.api.post('/auth/two-factor-challenge', {
18
+ code,
19
+ });
20
+ }
21
+ /**
22
+ * Submit recovery code to complete login
23
+ */
24
+ async submitRecoveryCode(recovery_code) {
25
+ await this.api.post('/auth/two-factor-challenge', {
26
+ recovery_code,
27
+ });
28
+ }
29
+ }
@@ -0,0 +1,64 @@
1
+ import { Service } from '../../services/Service.js';
2
+ import { ServiceContainer } from '../../container/ServiceContainer.js';
3
+ import type { RegisterService } from '../../container/types.js';
4
+ /**
5
+ * Interface for two-factor authentication response data
6
+ */
7
+ export interface TwoFactorQRResponse {
8
+ svg: string;
9
+ }
10
+ export interface TwoFactorSecretResponse {
11
+ secretKey: string;
12
+ }
13
+ export interface TwoFactorRecoveryCodesResponse {
14
+ recoveryCodes: string[];
15
+ }
16
+ /**
17
+ * Service for managing two-factor authentication operations.
18
+ */
19
+ export declare class TwoFactorService extends Service implements RegisterService {
20
+ private api;
21
+ /**
22
+ * Registers the service.
23
+ */
24
+ register({ api }: ServiceContainer): void;
25
+ /**
26
+ * Confirm user password before sensitive operations
27
+ */
28
+ confirmPassword(password: string): Promise<void>;
29
+ /**
30
+ * Check if password confirmation is still valid
31
+ */
32
+ checkPasswordConfirmation(): Promise<{
33
+ confirmed: boolean;
34
+ }>;
35
+ /**
36
+ * Enable two-factor authentication for the current user
37
+ */
38
+ enable(): Promise<void>;
39
+ /**
40
+ * Disable two-factor authentication for the current user
41
+ */
42
+ disable(): Promise<void>;
43
+ /**
44
+ * Get the QR code for setting up two-factor authentication
45
+ */
46
+ getQRCode(): Promise<TwoFactorQRResponse>;
47
+ /**
48
+ * Get the secret key for manual entry
49
+ */
50
+ getSecretKey(): Promise<TwoFactorSecretResponse>;
51
+ /**
52
+ * Confirm two-factor authentication setup with verification code
53
+ */
54
+ confirm(code: string): Promise<void>;
55
+ /**
56
+ * Get recovery codes for two-factor authentication
57
+ */
58
+ getRecoveryCodes(): Promise<string[]>;
59
+ /**
60
+ * Regenerate recovery codes for two-factor authentication
61
+ */
62
+ regenerateRecoveryCodes(): Promise<string[]>;
63
+ }
64
+ //# sourceMappingURL=TwoFactorService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TwoFactorService.d.ts","sourceRoot":"","sources":["../../../src/auth/services/TwoFactorService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,8BAA8B;IAC7C,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,OAAQ,YAAW,eAAe;IACtE,OAAO,CAAC,GAAG,CAAc;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,gBAAgB,GAAG,IAAI;IAIzC;;OAEG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD;;OAEG;IACG,yBAAyB,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;IAIlE;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI/C;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAItD;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI3C;;OAEG;IACG,uBAAuB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAKnD"}
@@ -0,0 +1,68 @@
1
+ import { Service } from '../../services/Service.js';
2
+ /**
3
+ * Service for managing two-factor authentication operations.
4
+ */
5
+ export class TwoFactorService extends Service {
6
+ api;
7
+ /**
8
+ * Registers the service.
9
+ */
10
+ register({ api }) {
11
+ this.api = api;
12
+ }
13
+ /**
14
+ * Confirm user password before sensitive operations
15
+ */
16
+ async confirmPassword(password) {
17
+ await this.api.post('/auth/user/confirm-password', { password });
18
+ }
19
+ /**
20
+ * Check if password confirmation is still valid
21
+ */
22
+ async checkPasswordConfirmation() {
23
+ return await this.api.get('/auth/user/confirmed-password-status');
24
+ }
25
+ /**
26
+ * Enable two-factor authentication for the current user
27
+ */
28
+ async enable() {
29
+ await this.api.post('/auth/user/two-factor-authentication');
30
+ }
31
+ /**
32
+ * Disable two-factor authentication for the current user
33
+ */
34
+ async disable() {
35
+ await this.api.delete('/auth/user/two-factor-authentication');
36
+ }
37
+ /**
38
+ * Get the QR code for setting up two-factor authentication
39
+ */
40
+ async getQRCode() {
41
+ return await this.api.get('/auth/user/two-factor-qr-code');
42
+ }
43
+ /**
44
+ * Get the secret key for manual entry
45
+ */
46
+ async getSecretKey() {
47
+ return await this.api.get('/auth/user/two-factor-secret-key');
48
+ }
49
+ /**
50
+ * Confirm two-factor authentication setup with verification code
51
+ */
52
+ async confirm(code) {
53
+ await this.api.post('/auth/user/confirmed-two-factor-authentication', { code });
54
+ }
55
+ /**
56
+ * Get recovery codes for two-factor authentication
57
+ */
58
+ async getRecoveryCodes() {
59
+ return await this.api.get('/auth/user/two-factor-recovery-codes');
60
+ }
61
+ /**
62
+ * Regenerate recovery codes for two-factor authentication
63
+ */
64
+ async regenerateRecoveryCodes() {
65
+ await this.api.post('/auth/user/two-factor-recovery-codes');
66
+ return await this.api.get('/auth/user/two-factor-recovery-codes');
67
+ }
68
+ }