@greatapps/common 1.1.173 → 1.1.175

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 (378) hide show
  1. package/dist/components/account/AccountModals.mjs +18 -0
  2. package/dist/components/account/AccountModals.mjs.map +1 -0
  3. package/dist/components/account/ConfigurationsMyAccountModal.mjs +132 -0
  4. package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -0
  5. package/dist/components/account/ConfirmDeleteAccountModal.mjs +45 -0
  6. package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -0
  7. package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +45 -0
  8. package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -0
  9. package/dist/components/account/DeleteAccountModal.mjs +123 -0
  10. package/dist/components/account/DeleteAccountModal.mjs.map +1 -0
  11. package/dist/components/account/DisableTwoFactorAuthModal.mjs +67 -0
  12. package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -0
  13. package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +42 -0
  14. package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -0
  15. package/dist/components/account/TwoFactorAuthModal.mjs +190 -0
  16. package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -0
  17. package/dist/components/account/constants.mjs +29 -0
  18. package/dist/components/account/constants.mjs.map +1 -0
  19. package/dist/components/account/hooks/useChangeEmailForm.mjs +53 -0
  20. package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -0
  21. package/dist/components/account/hooks/useChangePasswordForm.mjs +47 -0
  22. package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -0
  23. package/dist/components/account/hooks/useChangePhoneForm.mjs +74 -0
  24. package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -0
  25. package/dist/components/account/hooks/useConfigurationsModal.mjs +33 -0
  26. package/dist/components/account/hooks/useConfigurationsModal.mjs.map +1 -0
  27. package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +54 -0
  28. package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -0
  29. package/dist/components/account/hooks/useOtpVerification.mjs +94 -0
  30. package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -0
  31. package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +80 -0
  32. package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -0
  33. package/dist/components/account/sections/ChangeEmailModal.mjs +181 -0
  34. package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -0
  35. package/dist/components/account/sections/ChangePasswordSection.mjs +64 -0
  36. package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -0
  37. package/dist/components/account/sections/ChangePhoneModal.mjs +184 -0
  38. package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -0
  39. package/dist/components/account/sections/MyProfileSection.mjs +303 -0
  40. package/dist/components/account/sections/MyProfileSection.mjs.map +1 -0
  41. package/dist/components/account/sections/PreferencesSection.mjs +250 -0
  42. package/dist/components/account/sections/PreferencesSection.mjs.map +1 -0
  43. package/dist/components/account/sections/SecuritySection.mjs +147 -0
  44. package/dist/components/account/sections/SecuritySection.mjs.map +1 -0
  45. package/dist/components/handlers/SearchParamsHandler.mjs +24 -0
  46. package/dist/components/handlers/SearchParamsHandler.mjs.map +1 -0
  47. package/dist/components/layouts/AppMobileNavBar.mjs +115 -0
  48. package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -0
  49. package/dist/components/layouts/AppNavBar.mjs +49 -0
  50. package/dist/components/layouts/AppNavBar.mjs.map +1 -0
  51. package/dist/components/layouts/MainLayout.mjs +60 -0
  52. package/dist/components/layouts/MainLayout.mjs.map +1 -0
  53. package/dist/components/layouts/MdSideBarNavigation.mjs +54 -0
  54. package/dist/components/layouts/MdSideBarNavigation.mjs.map +1 -0
  55. package/dist/components/layouts/NavBar.mjs +132 -0
  56. package/dist/components/layouts/NavBar.mjs.map +1 -0
  57. package/dist/components/layouts/NavBarItem.mjs +23 -0
  58. package/dist/components/layouts/NavBarItem.mjs.map +1 -0
  59. package/dist/components/layouts/NotificationsPopover.mjs +97 -0
  60. package/dist/components/layouts/NotificationsPopover.mjs.map +1 -0
  61. package/dist/components/layouts/ProfilePopover.mjs +149 -0
  62. package/dist/components/layouts/ProfilePopover.mjs.map +1 -0
  63. package/dist/components/layouts/SideBarNavigation.mjs +22 -0
  64. package/dist/components/layouts/SideBarNavigation.mjs.map +1 -0
  65. package/dist/components/layouts/UsersSelectorPopover.mjs +230 -0
  66. package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -0
  67. package/dist/components/modals/ModalManager.mjs +19 -0
  68. package/dist/components/modals/ModalManager.mjs.map +1 -0
  69. package/dist/components/modals/Modals.mjs +20 -0
  70. package/dist/components/modals/Modals.mjs.map +1 -0
  71. package/dist/components/navigation/AppNavigation.mjs +30 -0
  72. package/dist/components/navigation/AppNavigation.mjs.map +1 -0
  73. package/dist/components/navigation/AppNavigationContext.mjs +13 -0
  74. package/dist/components/navigation/AppNavigationContext.mjs.map +1 -0
  75. package/dist/components/navigation/CancelledSubscriptionBanner.mjs +59 -0
  76. package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -0
  77. package/dist/components/navigation/NavItem.mjs +35 -0
  78. package/dist/components/navigation/NavItem.mjs.map +1 -0
  79. package/dist/components/navigation/NavItemsContext.mjs +16 -0
  80. package/dist/components/navigation/NavItemsContext.mjs.map +1 -0
  81. package/dist/components/navigation/ProjectSelectorPopover.mjs +128 -0
  82. package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -0
  83. package/dist/components/navigation/shells/DesktopShell.mjs +11 -0
  84. package/dist/components/navigation/shells/DesktopShell.mjs.map +1 -0
  85. package/dist/components/navigation/shells/MdShell.mjs +11 -0
  86. package/dist/components/navigation/shells/MdShell.mjs.map +1 -0
  87. package/dist/components/navigation/shells/MobileShell.mjs +27 -0
  88. package/dist/components/navigation/shells/MobileShell.mjs.map +1 -0
  89. package/dist/components/navigation/shells/TabsMobileShell.mjs +59 -0
  90. package/dist/components/navigation/shells/TabsMobileShell.mjs.map +1 -0
  91. package/dist/components/navigation/subcomponents/CreditsCard.mjs +30 -0
  92. package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -0
  93. package/dist/components/navigation/subcomponents/NavItems.mjs +25 -0
  94. package/dist/components/navigation/subcomponents/NavItems.mjs.map +1 -0
  95. package/dist/components/navigation/subcomponents/PlanCard.mjs +25 -0
  96. package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -0
  97. package/dist/components/navigation/subcomponents/ProjectSelector.mjs +130 -0
  98. package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -0
  99. package/dist/components/navigation/types.mjs +1 -0
  100. package/dist/components/navigation/types.mjs.map +1 -0
  101. package/dist/components/pages/notifications/Notifications.mjs +156 -0
  102. package/dist/components/pages/notifications/Notifications.mjs.map +1 -0
  103. package/dist/components/ui/buttons/Button.mjs +52 -0
  104. package/dist/components/ui/buttons/Button.mjs.map +1 -0
  105. package/dist/components/ui/buttons/CancelButton.mjs +17 -0
  106. package/dist/components/ui/buttons/CancelButton.mjs.map +1 -0
  107. package/dist/components/ui/buttons/CopyButton.mjs +42 -0
  108. package/dist/components/ui/buttons/CopyButton.mjs.map +1 -0
  109. package/dist/components/ui/data-display/Accordion.mjs +76 -0
  110. package/dist/components/ui/data-display/Accordion.mjs.map +1 -0
  111. package/dist/components/ui/data-display/Badge.mjs +42 -0
  112. package/dist/components/ui/data-display/Badge.mjs.map +1 -0
  113. package/dist/components/ui/data-display/Card.mjs +92 -0
  114. package/dist/components/ui/data-display/Card.mjs.map +1 -0
  115. package/dist/components/ui/data-display/Pagination.mjs +118 -0
  116. package/dist/components/ui/data-display/Pagination.mjs.map +1 -0
  117. package/dist/components/ui/data-display/ScrollArea.mjs +62 -0
  118. package/dist/components/ui/data-display/ScrollArea.mjs.map +1 -0
  119. package/dist/components/ui/data-display/Separator.mjs +28 -0
  120. package/dist/components/ui/data-display/Separator.mjs.map +1 -0
  121. package/dist/components/ui/data-display/Table.mjs +116 -0
  122. package/dist/components/ui/data-display/Table.mjs.map +1 -0
  123. package/dist/components/ui/data-display/Tabs.mjs +69 -0
  124. package/dist/components/ui/data-display/Tabs.mjs.map +1 -0
  125. package/dist/components/ui/data-display/UserAvatar.mjs +49 -0
  126. package/dist/components/ui/data-display/UserAvatar.mjs.map +1 -0
  127. package/dist/components/ui/feedback/CircularProgress.mjs +71 -0
  128. package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -0
  129. package/dist/components/ui/feedback/DefaultCircularProgress.mjs +50 -0
  130. package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -0
  131. package/dist/components/ui/feedback/LoadingOverlay.mjs +19 -0
  132. package/dist/components/ui/feedback/LoadingOverlay.mjs.map +1 -0
  133. package/dist/components/ui/feedback/Progress.mjs +37 -0
  134. package/dist/components/ui/feedback/Progress.mjs.map +1 -0
  135. package/dist/components/ui/feedback/Toast.mjs +77 -0
  136. package/dist/components/ui/feedback/Toast.mjs.map +1 -0
  137. package/dist/components/ui/form/Calendar.mjs +204 -0
  138. package/dist/components/ui/form/Calendar.mjs.map +1 -0
  139. package/dist/components/ui/form/Checkbox.mjs +33 -0
  140. package/dist/components/ui/form/Checkbox.mjs.map +1 -0
  141. package/dist/components/ui/form/ComboboxField.mjs +130 -0
  142. package/dist/components/ui/form/ComboboxField.mjs.map +1 -0
  143. package/dist/components/ui/form/DatePicker.mjs +82 -0
  144. package/dist/components/ui/form/DatePicker.mjs.map +1 -0
  145. package/dist/components/ui/form/DateRangePicker.mjs +92 -0
  146. package/dist/components/ui/form/DateRangePicker.mjs.map +1 -0
  147. package/dist/components/ui/form/FormField.mjs +103 -0
  148. package/dist/components/ui/form/FormField.mjs.map +1 -0
  149. package/dist/components/ui/form/Input.mjs +21 -0
  150. package/dist/components/ui/form/Input.mjs.map +1 -0
  151. package/dist/components/ui/form/InputOtp.mjs +70 -0
  152. package/dist/components/ui/form/InputOtp.mjs.map +1 -0
  153. package/dist/components/ui/form/PhoneInput.mjs +174 -0
  154. package/dist/components/ui/form/PhoneInput.mjs.map +1 -0
  155. package/dist/components/ui/form/RadioGroup.mjs +37 -0
  156. package/dist/components/ui/form/RadioGroup.mjs.map +1 -0
  157. package/dist/components/ui/form/Select.mjs +179 -0
  158. package/dist/components/ui/form/Select.mjs.map +1 -0
  159. package/dist/components/ui/form/SelectField.mjs +80 -0
  160. package/dist/components/ui/form/SelectField.mjs.map +1 -0
  161. package/dist/components/ui/form/Switch.mjs +33 -0
  162. package/dist/components/ui/form/Switch.mjs.map +1 -0
  163. package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs +40 -0
  164. package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +1 -0
  165. package/dist/components/ui/form/TextAreaField.mjs +56 -0
  166. package/dist/components/ui/form/TextAreaField.mjs.map +1 -0
  167. package/dist/components/ui/form/Textarea.mjs +20 -0
  168. package/dist/components/ui/form/Textarea.mjs.map +1 -0
  169. package/dist/components/ui/overlay/Command.mjs +178 -0
  170. package/dist/components/ui/overlay/Command.mjs.map +1 -0
  171. package/dist/components/ui/overlay/Dialog.mjs +142 -0
  172. package/dist/components/ui/overlay/Dialog.mjs.map +1 -0
  173. package/dist/components/ui/overlay/Popover.mjs +46 -0
  174. package/dist/components/ui/overlay/Popover.mjs.map +1 -0
  175. package/dist/components/ui/overlay/Sheet.mjs +142 -0
  176. package/dist/components/ui/overlay/Sheet.mjs.map +1 -0
  177. package/dist/components/ui/overlay/Tooltip.mjs +57 -0
  178. package/dist/components/ui/overlay/Tooltip.mjs.map +1 -0
  179. package/dist/components/widgets/notifications/NotificationCard.mjs +54 -0
  180. package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -0
  181. package/dist/enums/AccountSectionType.mjs +11 -0
  182. package/dist/enums/AccountSectionType.mjs.map +1 -0
  183. package/dist/hooks/copy-to-clipboard.hook.mjs +52 -0
  184. package/dist/hooks/copy-to-clipboard.hook.mjs.map +1 -0
  185. package/dist/hooks/useCountdownTimer.mjs +29 -0
  186. package/dist/hooks/useCountdownTimer.mjs.map +1 -0
  187. package/dist/hooks/useDebounce.mjs +19 -0
  188. package/dist/hooks/useDebounce.mjs.map +1 -0
  189. package/dist/hooks/useDebounceState.mjs +12 -0
  190. package/dist/hooks/useDebounceState.mjs.map +1 -0
  191. package/dist/hooks/useDebouncedEffect.mjs +44 -0
  192. package/dist/hooks/useDebouncedEffect.mjs.map +1 -0
  193. package/dist/hooks/useIsMobile.mjs +18 -0
  194. package/dist/hooks/useIsMobile.mjs.map +1 -0
  195. package/dist/hooks/usePasswordVisibility.mjs +13 -0
  196. package/dist/hooks/usePasswordVisibility.mjs.map +1 -0
  197. package/dist/index.mjs +457 -0
  198. package/dist/index.mjs.map +1 -0
  199. package/dist/infra/api/client.mjs +136 -0
  200. package/dist/infra/api/client.mjs.map +1 -0
  201. package/dist/infra/api/types.mjs +31 -0
  202. package/dist/infra/api/types.mjs.map +1 -0
  203. package/dist/infra/utils/client-info.mjs +27 -0
  204. package/dist/infra/utils/client-info.mjs.map +1 -0
  205. package/dist/infra/utils/clsx.mjs +9 -0
  206. package/dist/infra/utils/clsx.mjs.map +1 -0
  207. package/dist/infra/utils/params.mjs +21 -0
  208. package/dist/infra/utils/params.mjs.map +1 -0
  209. package/dist/infra/utils/parser.mjs +24 -0
  210. package/dist/infra/utils/parser.mjs.map +1 -0
  211. package/dist/infra/utils/percentage.mjs +20 -0
  212. package/dist/infra/utils/percentage.mjs.map +1 -0
  213. package/dist/middleware.mjs +10 -0
  214. package/dist/middleware.mjs.map +1 -0
  215. package/dist/middlewares/chain.mjs +37 -0
  216. package/dist/middlewares/chain.mjs.map +1 -0
  217. package/dist/middlewares/create-auth-middleware.mjs +28 -0
  218. package/dist/middlewares/create-auth-middleware.mjs.map +1 -0
  219. package/dist/middlewares/types.mjs +11 -0
  220. package/dist/middlewares/types.mjs.map +1 -0
  221. package/dist/modules/accounts/actions/account-management.action.mjs +82 -0
  222. package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -0
  223. package/dist/modules/accounts/actions/find-current-account.action.mjs +10 -0
  224. package/dist/modules/accounts/actions/find-current-account.action.mjs.map +1 -0
  225. package/dist/modules/accounts/actions/list-currencies.action.mjs +10 -0
  226. package/dist/modules/accounts/actions/list-currencies.action.mjs.map +1 -0
  227. package/dist/modules/accounts/actions/list-timezones.action.mjs +10 -0
  228. package/dist/modules/accounts/actions/list-timezones.action.mjs.map +1 -0
  229. package/dist/modules/accounts/hooks/current-account.hook.mjs +24 -0
  230. package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -0
  231. package/dist/modules/accounts/hooks/useAccountManagement.mjs +71 -0
  232. package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -0
  233. package/dist/modules/accounts/hooks/useCurrencies.mjs +17 -0
  234. package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -0
  235. package/dist/modules/accounts/hooks/useTimezones.mjs +17 -0
  236. package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -0
  237. package/dist/modules/accounts/services/account.service.mjs +180 -0
  238. package/dist/modules/accounts/services/account.service.mjs.map +1 -0
  239. package/dist/modules/accounts/services/currency.service.mjs +24 -0
  240. package/dist/modules/accounts/services/currency.service.mjs.map +1 -0
  241. package/dist/modules/accounts/services/timezone.service.mjs +65 -0
  242. package/dist/modules/accounts/services/timezone.service.mjs.map +1 -0
  243. package/dist/modules/accounts/services/two-factor.service.mjs +77 -0
  244. package/dist/modules/accounts/services/two-factor.service.mjs.map +1 -0
  245. package/dist/modules/accounts/types.mjs +1 -0
  246. package/dist/modules/accounts/types.mjs.map +1 -0
  247. package/dist/modules/auth/actions/login.action.mjs +14 -0
  248. package/dist/modules/auth/actions/login.action.mjs.map +1 -0
  249. package/dist/modules/auth/actions/logout.action.mjs +14 -0
  250. package/dist/modules/auth/actions/logout.action.mjs.map +1 -0
  251. package/dist/modules/auth/actions/register.action.mjs +14 -0
  252. package/dist/modules/auth/actions/register.action.mjs.map +1 -0
  253. package/dist/modules/auth/actions/validate-session.action.mjs +60 -0
  254. package/dist/modules/auth/actions/validate-session.action.mjs.map +1 -0
  255. package/dist/modules/auth/actions/verify-two-factor.action.mjs +17 -0
  256. package/dist/modules/auth/actions/verify-two-factor.action.mjs.map +1 -0
  257. package/dist/modules/auth/hooks/login.hook.mjs +13 -0
  258. package/dist/modules/auth/hooks/login.hook.mjs.map +1 -0
  259. package/dist/modules/auth/hooks/logout.hook.mjs +13 -0
  260. package/dist/modules/auth/hooks/logout.hook.mjs.map +1 -0
  261. package/dist/modules/auth/hooks/register.hook.mjs +13 -0
  262. package/dist/modules/auth/hooks/register.hook.mjs.map +1 -0
  263. package/dist/modules/auth/hooks/useUserQuery.mjs +63 -0
  264. package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -0
  265. package/dist/modules/auth/schema.mjs +1 -0
  266. package/dist/modules/auth/schema.mjs.map +1 -0
  267. package/dist/modules/auth/services/auth.service.mjs +294 -0
  268. package/dist/modules/auth/services/auth.service.mjs.map +1 -0
  269. package/dist/modules/auth/utils/get-user-context.mjs +24 -0
  270. package/dist/modules/auth/utils/get-user-context.mjs.map +1 -0
  271. package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs +10 -0
  272. package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs.map +1 -0
  273. package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +76 -0
  274. package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -0
  275. package/dist/modules/ia-credits/services/ia-credits.service.mjs +31 -0
  276. package/dist/modules/ia-credits/services/ia-credits.service.mjs.map +1 -0
  277. package/dist/modules/ia-credits/types.mjs +25 -0
  278. package/dist/modules/ia-credits/types.mjs.map +1 -0
  279. package/dist/modules/projects/actions/add-project-user.action.mjs +10 -0
  280. package/dist/modules/projects/actions/add-project-user.action.mjs.map +1 -0
  281. package/dist/modules/projects/actions/list-available-users.action.mjs +10 -0
  282. package/dist/modules/projects/actions/list-available-users.action.mjs.map +1 -0
  283. package/dist/modules/projects/actions/list-project-users.action.mjs +10 -0
  284. package/dist/modules/projects/actions/list-project-users.action.mjs.map +1 -0
  285. package/dist/modules/projects/actions/remove-project-user.action.mjs +10 -0
  286. package/dist/modules/projects/actions/remove-project-user.action.mjs.map +1 -0
  287. package/dist/modules/projects/hooks/list-available-users.hook.mjs +34 -0
  288. package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -0
  289. package/dist/modules/projects/hooks/list-project-users.hook.mjs +34 -0
  290. package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -0
  291. package/dist/modules/projects/services/project-users.service.mjs +78 -0
  292. package/dist/modules/projects/services/project-users.service.mjs.map +1 -0
  293. package/dist/modules/projects/types.mjs +22 -0
  294. package/dist/modules/projects/types.mjs.map +1 -0
  295. package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs +10 -0
  296. package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs.map +1 -0
  297. package/dist/modules/subscriptions/constants/addons.constants.mjs +12 -0
  298. package/dist/modules/subscriptions/constants/addons.constants.mjs.map +1 -0
  299. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +20 -0
  300. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -0
  301. package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +18 -0
  302. package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -0
  303. package/dist/modules/subscriptions/services/subscriptions.service.mjs +32 -0
  304. package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -0
  305. package/dist/modules/subscriptions/types.mjs +57 -0
  306. package/dist/modules/subscriptions/types.mjs.map +1 -0
  307. package/dist/modules/users/action/find-user-by-id.action.mjs +10 -0
  308. package/dist/modules/users/action/find-user-by-id.action.mjs.map +1 -0
  309. package/dist/modules/users/action/list-messages.action.mjs +13 -0
  310. package/dist/modules/users/action/list-messages.action.mjs.map +1 -0
  311. package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +10 -0
  312. package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -0
  313. package/dist/modules/users/action/mark-message-as-read.action.mjs +10 -0
  314. package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -0
  315. package/dist/modules/users/hooks/messages.hook.mjs +57 -0
  316. package/dist/modules/users/hooks/messages.hook.mjs.map +1 -0
  317. package/dist/modules/users/schema/messages.schema.mjs +21 -0
  318. package/dist/modules/users/schema/messages.schema.mjs.map +1 -0
  319. package/dist/modules/users/schema.mjs +11 -0
  320. package/dist/modules/users/schema.mjs.map +1 -0
  321. package/dist/modules/users/services/messages.service.mjs +35 -0
  322. package/dist/modules/users/services/messages.service.mjs.map +1 -0
  323. package/dist/modules/users/services/user.service.mjs +50 -0
  324. package/dist/modules/users/services/user.service.mjs.map +1 -0
  325. package/dist/modules/whitelabel/actions/find-whitelabel-styles.action.mjs +15 -0
  326. package/dist/modules/whitelabel/actions/find-whitelabel-styles.action.mjs.map +1 -0
  327. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs +21 -0
  328. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +1 -0
  329. package/dist/modules/whitelabel/schema.mjs +1 -0
  330. package/dist/modules/whitelabel/schema.mjs.map +1 -0
  331. package/dist/modules/whitelabel/services/whitelabel-styles.service.mjs +81 -0
  332. package/dist/modules/whitelabel/services/whitelabel-styles.service.mjs.map +1 -0
  333. package/dist/modules/whitelabel/services/whitelabel.service.mjs +61 -0
  334. package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +1 -0
  335. package/dist/modules/whitelabel/styles-schema.mjs +1 -0
  336. package/dist/modules/whitelabel/styles-schema.mjs.map +1 -0
  337. package/dist/providers/auth.provider.mjs +100 -0
  338. package/dist/providers/auth.provider.mjs.map +1 -0
  339. package/dist/providers/query.provider.mjs +99 -0
  340. package/dist/providers/query.provider.mjs.map +1 -0
  341. package/dist/providers/whitelabel.provider.mjs +31 -0
  342. package/dist/providers/whitelabel.provider.mjs.map +1 -0
  343. package/dist/server.mjs +84 -0
  344. package/dist/server.mjs.map +1 -0
  345. package/dist/store/useAccountModals.mjs +18 -0
  346. package/dist/store/useAccountModals.mjs.map +1 -0
  347. package/dist/store/useMdSidebarStore.mjs +11 -0
  348. package/dist/store/useMdSidebarStore.mjs.map +1 -0
  349. package/dist/store/useMobileNavbarSheet.mjs +14 -0
  350. package/dist/store/useMobileNavbarSheet.mjs.map +1 -0
  351. package/dist/store/useModalManager.mjs +75 -0
  352. package/dist/store/useModalManager.mjs.map +1 -0
  353. package/dist/utils/browser/clipboard.mjs +36 -0
  354. package/dist/utils/browser/clipboard.mjs.map +1 -0
  355. package/dist/utils/countries.mjs +219 -0
  356. package/dist/utils/countries.mjs.map +1 -0
  357. package/dist/utils/file/index.mjs +9 -0
  358. package/dist/utils/file/index.mjs.map +1 -0
  359. package/dist/utils/format/masks.mjs +56 -0
  360. package/dist/utils/format/masks.mjs.map +1 -0
  361. package/dist/utils/intl/locales.mjs +12 -0
  362. package/dist/utils/intl/locales.mjs.map +1 -0
  363. package/dist/utils/safeServerAction.mjs +16 -0
  364. package/dist/utils/safeServerAction.mjs.map +1 -0
  365. package/dist/utils/validators/account.mjs +26 -0
  366. package/dist/utils/validators/account.mjs.map +1 -0
  367. package/dist/utils/validators/common.mjs +47 -0
  368. package/dist/utils/validators/common.mjs.map +1 -0
  369. package/dist/utils/withAction.mjs +13 -0
  370. package/dist/utils/withAction.mjs.map +1 -0
  371. package/package.json +3 -2
  372. package/src/components/account/hooks/useChangePhoneForm.tsx +81 -69
  373. package/src/components/account/sections/ChangeEmailModal.tsx +2 -1
  374. package/src/components/account/sections/ChangePhoneModal.tsx +231 -229
  375. package/src/components/ui/form/PhoneInput.tsx +205 -98
  376. package/src/modules/accounts/actions/account-management.action.ts +4 -4
  377. package/src/modules/accounts/services/account.service.ts +4 -4
  378. package/src/utils/countries.ts +224 -0
@@ -0,0 +1,60 @@
1
+ "use server";
2
+ import { redirect } from "next/navigation";
3
+ import { cookies, headers } from "next/headers";
4
+ import { authService } from "../services/auth.service";
5
+ import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
6
+ async function redirectToLogin() {
7
+ const h = await headers();
8
+ const referer = h.get("referer");
9
+ const gappsUrl = process.env.NEXT_PUBLIC_GREAT_APPS;
10
+ if (gappsUrl) {
11
+ const loginUrl2 = new URL(`${gappsUrl.replace(/\/$/, "")}/login`);
12
+ if (referer) {
13
+ const refererUrl = new URL(referer);
14
+ if (!["/login", "/register", "/forgot-password"].includes(refererUrl.pathname)) {
15
+ loginUrl2.searchParams.set("redirect", referer);
16
+ }
17
+ }
18
+ redirect(loginUrl2.toString());
19
+ return;
20
+ }
21
+ if (!referer) {
22
+ redirect("/login");
23
+ return;
24
+ }
25
+ const url = new URL(referer);
26
+ if (["/login", "/register", "/forgot-password"].includes(url.pathname)) {
27
+ return;
28
+ }
29
+ const loginUrl = new URL("/login", url.origin);
30
+ loginUrl.searchParams.set("redirect", url.pathname + url.search);
31
+ redirect(loginUrl.toString());
32
+ }
33
+ async function validateSessionAction() {
34
+ if (process.env.DUMMY_AUTH_TOKEN) return true;
35
+ const cookieStore = await cookies();
36
+ const cookie = cookieStore.get("greatapps")?.value;
37
+ if (!cookie) {
38
+ await redirectToLogin();
39
+ return false;
40
+ }
41
+ try {
42
+ const clientInfo = await getClientInfoFromRequest();
43
+ const isValid = await authService.validateSession(clientInfo);
44
+ if (!isValid) {
45
+ await authService.removeAuthCookie();
46
+ await redirectToLogin();
47
+ return false;
48
+ }
49
+ return true;
50
+ } catch (error) {
51
+ console.error("[validateSessionAction] Error:", error);
52
+ await authService.removeAuthCookie();
53
+ await redirectToLogin();
54
+ return false;
55
+ }
56
+ }
57
+ export {
58
+ validateSessionAction
59
+ };
60
+ //# sourceMappingURL=validate-session.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/actions/validate-session.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { redirect } from 'next/navigation';\r\nimport { cookies, headers } from 'next/headers';\r\nimport { authService } from '../services/auth.service';\r\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\r\n\r\nasync function redirectToLogin() {\r\n const h = await headers();\r\n const referer = h.get('referer');\r\n const gappsUrl = process.env.NEXT_PUBLIC_GREAT_APPS;\r\n\r\n if (gappsUrl) {\r\n const loginUrl = new URL(`${gappsUrl.replace(/\\/$/, '')}/login`);\r\n if (referer) {\r\n const refererUrl = new URL(referer);\r\n if (!['/login', '/register', '/forgot-password'].includes(refererUrl.pathname)) {\r\n loginUrl.searchParams.set('redirect', referer);\r\n }\r\n }\r\n redirect(loginUrl.toString());\r\n return;\r\n }\r\n\r\n if (!referer) {\r\n redirect('/login');\r\n return;\r\n }\r\n\r\n const url = new URL(referer);\r\n\r\n if (['/login', '/register', '/forgot-password'].includes(url.pathname)) {\r\n return;\r\n }\r\n\r\n const loginUrl = new URL('/login', url.origin);\r\n loginUrl.searchParams.set('redirect', url.pathname + url.search);\r\n redirect(loginUrl.toString());\r\n}\r\n\r\nexport async function validateSessionAction(): Promise<boolean> {\r\n if (process.env.DUMMY_AUTH_TOKEN) return true;\r\n\r\n const cookieStore = await cookies();\r\n const cookie = cookieStore.get('greatapps')?.value;\r\n\r\n if (!cookie) {\r\n await redirectToLogin();\r\n return false;\r\n }\r\n\r\n try {\r\n const clientInfo = await getClientInfoFromRequest();\r\n const isValid = await authService.validateSession(clientInfo);\r\n\r\n if (!isValid) {\r\n await authService.removeAuthCookie();\r\n await redirectToLogin();\r\n return false;\r\n }\r\n\r\n return true;\r\n } catch (error) {\r\n console.error('[validateSessionAction] Error:', error);\r\n await authService.removeAuthCookie();\r\n await redirectToLogin();\r\n return false;\r\n }\r\n}\r\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,SAAS,eAAe;AACjC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AAEzC,eAAe,kBAAkB;AAC/B,QAAM,IAA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;AACnC,UAAM,gBAAgB;AACtB,WAAO;AAAA,EACT;AACF;","names":["loginUrl"]}
@@ -0,0 +1,17 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { authService } from "../services/auth.service";
4
+ import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
5
+ async function verifyTwoFactorAction(cookie, code) {
6
+ return safeServerAction(async () => {
7
+ if (!/^\d{6}$/.test(code)) {
8
+ throw new Error("Formato inv\xE1lido");
9
+ }
10
+ const clientInfo = await getClientInfoFromRequest();
11
+ await authService.verifyTwoFactor(cookie, code, clientInfo);
12
+ });
13
+ }
14
+ export {
15
+ verifyTwoFactorAction
16
+ };
17
+ //# sourceMappingURL=verify-two-factor.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/actions/verify-two-factor.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { safeServerAction } from '../../../utils/safeServerAction';\r\nimport { authService } from '../services/auth.service';\r\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\r\n\r\nexport async function verifyTwoFactorAction(cookie: string, code: string) {\r\n return safeServerAction(async () => {\r\n if (!/^\\d{6}$/.test(code)) {\r\n throw new Error('Formato inválido');\r\n }\r\n const clientInfo = await getClientInfoFromRequest();\r\n await authService.verifyTwoFactor(cookie, code, clientInfo);\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AAEzC,eAAsB,sBAAsB,QAAgB,MAAc;AACxE,SAAO,iBAAiB,YAAY;AAClC,QAAI,CAAC,UAAU,KAAK,IAAI,GAAG;AACzB,YAAM,IAAI,MAAM,qBAAkB;AAAA,IACpC;AACA,UAAM,aAAa,MAAM,yBAAyB;AAClD,UAAM,YAAY,gBAAgB,QAAQ,MAAM,UAAU;AAAA,EAC5D,CAAC;AACH;","names":[]}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { useMutation } from "@tanstack/react-query";
3
+ import { loginAction } from "../actions/login.action";
4
+ import { withAction } from "../../../utils/withAction";
5
+ function useLogin() {
6
+ return useMutation({
7
+ mutationFn: (credentials) => withAction(loginAction)(credentials)
8
+ });
9
+ }
10
+ export {
11
+ useLogin
12
+ };
13
+ //# sourceMappingURL=login.hook.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/hooks/login.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { loginAction } from \"../actions/login.action\";\nimport { LoginRequest, LoginSuccessResponse } from \"../schema\";\nimport { withAction } from \"../../../utils/withAction\";\n\nexport function useLogin() {\n return useMutation({\n mutationFn: (credentials: LoginRequest) =>\n withAction(loginAction)(credentials) as Promise<LoginSuccessResponse>,\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAE5B,SAAS,kBAAkB;AAEpB,SAAS,WAAW;AACzB,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,gBACX,WAAW,WAAW,EAAE,WAAW;AAAA,EACvC,CAAC;AACH;","names":[]}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { useMutation } from "@tanstack/react-query";
3
+ import { logoutAction } from "../actions/logout.action";
4
+ import { withAction } from "../../../utils/withAction";
5
+ function useLogout() {
6
+ return useMutation({
7
+ mutationFn: withAction(logoutAction)
8
+ });
9
+ }
10
+ export {
11
+ useLogout
12
+ };
13
+ //# sourceMappingURL=logout.hook.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/hooks/logout.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { logoutAction } from \"../actions/logout.action\";\nimport { withAction } from \"../../../utils/withAction\";\n\nexport function useLogout() {\n return useMutation({\n mutationFn: withAction(logoutAction),\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,SAAS,YAAY;AAC1B,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,YAAY;AAAA,EACrC,CAAC;AACH;","names":[]}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { useMutation } from "@tanstack/react-query";
3
+ import { registerAction } from "../actions/register.action";
4
+ import { withAction } from "../../../utils/withAction";
5
+ function useRegister() {
6
+ return useMutation({
7
+ mutationFn: withAction(registerAction)
8
+ });
9
+ }
10
+ export {
11
+ useRegister
12
+ };
13
+ //# sourceMappingURL=register.hook.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/hooks/register.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { registerAction } from \"../actions/register.action\";\nimport { withAction } from \"../../../utils/withAction\";\n\nexport function useRegister() {\n return useMutation({\n mutationFn: withAction(registerAction),\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB;AAEpB,SAAS,cAAc;AAC5B,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,cAAc;AAAA,EACvC,CAAC;AACH;","names":[]}
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
3
+ import { withAction } from "../../../utils/withAction";
4
+ const USER_QUERY_KEY = ["user"];
5
+ async function fetchUser() {
6
+ const { findUserById: getUserDataAction } = await import("../../users/action/find-user-by-id.action");
7
+ const result = await getUserDataAction();
8
+ return result.success && result.data ? result.data : null;
9
+ }
10
+ async function validateUserSession() {
11
+ const { validateSessionAction } = await import("../actions/validate-session.action");
12
+ return await validateSessionAction();
13
+ }
14
+ function useUserQuery() {
15
+ return useQuery({
16
+ queryKey: USER_QUERY_KEY,
17
+ queryFn: fetchUser,
18
+ staleTime: 5 * 60 * 1e3,
19
+ gcTime: 10 * 60 * 1e3,
20
+ retry: false
21
+ });
22
+ }
23
+ function useUserValidateSession(options) {
24
+ return useQuery({
25
+ queryKey: ["user-validate-session"],
26
+ queryFn: validateUserSession,
27
+ retry: false,
28
+ staleTime: 5 * 60 * 1e3,
29
+ ...options,
30
+ refetchOnMount: "always",
31
+ refetchOnWindowFocus: true
32
+ });
33
+ }
34
+ function useTwoFactorVerify() {
35
+ const queryClient = useQueryClient();
36
+ return useMutation({
37
+ mutationFn: async ({ cookie, code }) => {
38
+ const { verifyTwoFactorAction } = await import("../actions/verify-two-factor.action");
39
+ return withAction(() => verifyTwoFactorAction(cookie, code))();
40
+ },
41
+ onSuccess: () => {
42
+ queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
43
+ queryClient.invalidateQueries({ queryKey: ["two-factor-pending"] });
44
+ }
45
+ });
46
+ }
47
+ function useInvalidateUser() {
48
+ const queryClient = useQueryClient();
49
+ return () => queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
50
+ }
51
+ function useSetUserData() {
52
+ const queryClient = useQueryClient();
53
+ return (user) => queryClient.setQueryData(USER_QUERY_KEY, user);
54
+ }
55
+ export {
56
+ USER_QUERY_KEY,
57
+ useInvalidateUser,
58
+ useSetUserData,
59
+ useTwoFactorVerify,
60
+ useUserQuery,
61
+ useUserValidateSession
62
+ };
63
+ //# sourceMappingURL=useUserQuery.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/hooks/useUserQuery.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useMutation, useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query';\r\nimport { User } from '../../users/schema';\r\nimport { withAction } from '../../../utils/withAction';\r\n\r\nexport const USER_QUERY_KEY = ['user'];\r\n\r\nasync function fetchUser(): Promise<User | null> {\r\n const { findUserById: getUserDataAction } = await import('../../users/action/find-user-by-id.action');\r\n const result = await getUserDataAction();\r\n return result.success && result.data ? result.data : null;\r\n}\r\n\r\nasync function validateUserSession(): Promise<boolean> {\r\n const { validateSessionAction } = await import('../actions/validate-session.action');\r\n return await validateSessionAction();\r\n}\r\n\r\nexport function useUserQuery() {\r\n return useQuery({\r\n queryKey: USER_QUERY_KEY,\r\n queryFn: fetchUser,\r\n staleTime: 5 * 60 * 1000,\r\n gcTime: 10 * 60 * 1000,\r\n retry: false,\r\n });\r\n}\r\n\r\nexport function useUserValidateSession(options?: UseQueryOptions) {\r\n return useQuery({\r\n queryKey: ['user-validate-session'],\r\n queryFn: validateUserSession,\r\n retry: false,\r\n staleTime: 5 * 60 * 1000,\r\n ...options,\r\n refetchOnMount: 'always',\r\n refetchOnWindowFocus: true,\r\n });\r\n}\r\n\r\nexport function useTwoFactorVerify() {\r\n const queryClient = useQueryClient();\r\n\r\n return useMutation({\r\n mutationFn: async ({ cookie, code }: { cookie: string; code: string }) => {\r\n const { verifyTwoFactorAction } = await import('../actions/verify-two-factor.action');\r\n return withAction(() => verifyTwoFactorAction(cookie, code))();\r\n },\r\n onSuccess: () => {\r\n queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });\r\n queryClient.invalidateQueries({ queryKey: ['two-factor-pending'] });\r\n },\r\n });\r\n}\r\n\r\nexport function useInvalidateUser() {\r\n const queryClient = useQueryClient();\r\n return () => queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });\r\n}\r\n\r\nexport function useSetUserData() {\r\n const queryClient = useQueryClient();\r\n return (user: User | null) => queryClient.setQueryData(USER_QUERY_KEY, user);\r\n}\r\n"],"mappings":";AAEA,SAAS,aAAa,UAAU,sBAAuC;AAEvE,SAAS,kBAAkB;AAEpB,MAAM,iBAAiB,CAAC,MAAM;AAErC,eAAe,YAAkC;AAC/C,QAAM,EAAE,cAAc,kBAAkB,IAAI,MAAM,OAAO,2CAA2C;AACpG,QAAM,SAAS,MAAM,kBAAkB;AACvC,SAAO,OAAO,WAAW,OAAO,OAAO,OAAO,OAAO;AACvD;AAEA,eAAe,sBAAwC;AACrD,QAAM,EAAE,sBAAsB,IAAI,MAAM,OAAO,oCAAoC;AACnF,SAAO,MAAM,sBAAsB;AACrC;AAEO,SAAS,eAAe;AAC7B,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW,IAAI,KAAK;AAAA,IACpB,QAAQ,KAAK,KAAK;AAAA,IAClB,OAAO;AAAA,EACT,CAAC;AACH;AAEO,SAAS,uBAAuB,SAA2B;AAChE,SAAO,SAAS;AAAA,IACd,UAAU,CAAC,uBAAuB;AAAA,IAClC,SAAS;AAAA,IACT,OAAO;AAAA,IACP,WAAW,IAAI,KAAK;AAAA,IACpB,GAAG;AAAA,IACH,gBAAgB;AAAA,IAChB,sBAAsB;AAAA,EACxB,CAAC;AACH;AAEO,SAAS,qBAAqB;AACnC,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,OAAO,EAAE,QAAQ,KAAK,MAAwC;AACxE,YAAM,EAAE,sBAAsB,IAAI,MAAM,OAAO,qCAAqC;AACpF,aAAO,WAAW,MAAM,sBAAsB,QAAQ,IAAI,CAAC,EAAE;AAAA,IAC/D;AAAA,IACA,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,eAAe,CAAC;AAC1D,kBAAY,kBAAkB,EAAE,UAAU,CAAC,oBAAoB,EAAE,CAAC;AAAA,IACpE;AAAA,EACF,CAAC;AACH;AAEO,SAAS,oBAAoB;AAClC,QAAM,cAAc,eAAe;AACnC,SAAO,MAAM,YAAY,kBAAkB,EAAE,UAAU,eAAe,CAAC;AACzE;AAEO,SAAS,iBAAiB;AAC/B,QAAM,cAAc,eAAe;AACnC,SAAO,CAAC,SAAsB,YAAY,aAAa,gBAAgB,IAAI;AAC7E;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,294 @@
1
+ import { cookies } from "next/headers";
2
+ import { api } from "../../../infra/api/client";
3
+ import { ApiError } from "../../../infra/api/types";
4
+ const AUTH_COOKIE_NAME = "greatapps";
5
+ const COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
6
+ const COOKIE_OPTIONS = {
7
+ httpOnly: true,
8
+ secure: process.env.NODE_ENV === "production",
9
+ sameSite: "lax",
10
+ path: "/",
11
+ domain: process.env.DOMAIN_COOKIE
12
+ };
13
+ class AuthService {
14
+ async login(credentials, clientInfo) {
15
+ const response = await api.apps.post("/auth/login", {
16
+ email: credentials.email,
17
+ password: credentials.password,
18
+ source: credentials?.source,
19
+ location: clientInfo.location,
20
+ ip: clientInfo.ip,
21
+ timezone: clientInfo.timezone,
22
+ agent: clientInfo.agent
23
+ });
24
+ console.log("[AuthService.login] response", JSON.stringify(response));
25
+ if (response.status === 0) {
26
+ throw new ApiError(
27
+ response.message || "E-mail ou senha incorretos",
28
+ response.code || "LOGIN_FAILED",
29
+ 401
30
+ );
31
+ }
32
+ if (!response.cookie) {
33
+ throw new ApiError(
34
+ "Resposta de autentica\xE7\xE3o inv\xE1lida",
35
+ "INVALID_RESPONSE",
36
+ 500
37
+ );
38
+ }
39
+ if (response.two_factor_required) {
40
+ return { result: "two_factor_required", cookie: response.cookie };
41
+ }
42
+ await this.setAuthCookie(response.cookie);
43
+ const [{ userService }, { accountService }] = await Promise.all([
44
+ import("../../users/services/user.service"),
45
+ import("../../accounts/services/account.service")
46
+ ]);
47
+ const [user, account] = await Promise.all([
48
+ userService.findById(),
49
+ accountService.findCurrentAccount()
50
+ ]);
51
+ return {
52
+ result: "success",
53
+ user,
54
+ account,
55
+ accessToken: response.cookie,
56
+ refreshToken: "",
57
+ expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1e3).toISOString()
58
+ };
59
+ }
60
+ async verifyTwoFactor(cookie, code, clientInfo) {
61
+ const payload = {
62
+ location: clientInfo.location,
63
+ ip: clientInfo.ip,
64
+ timezone: clientInfo.timezone,
65
+ agent: clientInfo.agent,
66
+ cookie,
67
+ code
68
+ };
69
+ const response = await api.apps.post(
70
+ "/auth/code",
71
+ payload
72
+ );
73
+ if (response.status === 0) {
74
+ throw new ApiError("C\xF3digo 2FA inv\xE1lido", "TWO_FACTOR_FAILED", 401);
75
+ }
76
+ if (!response?.data?.cookie) {
77
+ throw new ApiError(
78
+ "Resposta de autentica\xE7\xE3o inv\xE1lida ap\xF3s 2FA",
79
+ "INVALID_RESPONSE",
80
+ 500
81
+ );
82
+ }
83
+ await this.setAuthCookie(response.data.cookie);
84
+ return { status: 1 };
85
+ }
86
+ async register(data, clientInfo) {
87
+ const today = /* @__PURE__ */ new Date();
88
+ const trialEndDate = new Date(today);
89
+ trialEndDate.setDate(today.getDate() + 7);
90
+ const idPlan = await this.resolvePlanId(data.idPlan);
91
+ const payload = {
92
+ name: data.accountName,
93
+ bussiness_type: data.businessType ?? 0,
94
+ language: "pt-br",
95
+ timezone: "America/Sao_Paulo",
96
+ currency: "BRL",
97
+ location: clientInfo.location,
98
+ ip: clientInfo.ip,
99
+ agent: clientInfo.agent,
100
+ user: {
101
+ id_api: "",
102
+ name: data.name,
103
+ last_name: data.lastName || "",
104
+ rg: data.rg || "",
105
+ cpf: data.cpf || "",
106
+ gender: data.gender,
107
+ email: data.email,
108
+ phone: data.phone,
109
+ password: data.password,
110
+ profile: "owner",
111
+ language: "pt-br"
112
+ },
113
+ subscription: {
114
+ type: "trial",
115
+ id_cupom: data.couponCode || "",
116
+ id_plan: idPlan,
117
+ due_date: trialEndDate.toISOString().split("T")[0],
118
+ id_product: 1
119
+ }
120
+ };
121
+ const response = await api.apps.post(
122
+ "/accounts",
123
+ payload
124
+ );
125
+ if (response.status === 0) {
126
+ throw new ApiError(
127
+ response.message || "Erro ao criar conta",
128
+ "REGISTER_FAILED",
129
+ 400
130
+ );
131
+ }
132
+ if (!response.data || response.data.length === 0) {
133
+ throw new ApiError(
134
+ "Resposta de registro inv\xE1lida",
135
+ "INVALID_RESPONSE",
136
+ 500
137
+ );
138
+ }
139
+ if (!response.cookie) {
140
+ throw new ApiError(
141
+ "Resposta de autentica\xE7\xE3o inv\xE1lida",
142
+ "INVALID_RESPONSE",
143
+ 500
144
+ );
145
+ }
146
+ const accountData = response.data[0];
147
+ await this.setAuthCookie(response.cookie);
148
+ const [{ userService }, { accountService }] = await Promise.all([
149
+ import("../../users/services/user.service"),
150
+ import("../../accounts/services/account.service")
151
+ ]);
152
+ const [user, account] = await Promise.all([
153
+ userService.findById(),
154
+ accountService.findCurrentAccount()
155
+ ]);
156
+ return {
157
+ user,
158
+ account,
159
+ accessToken: response.cookie,
160
+ refreshToken: "",
161
+ expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1e3).toISOString(),
162
+ requiresEmailVerification: !accountData.verified
163
+ };
164
+ }
165
+ async logout(clientInfo) {
166
+ const cookie = await this.getToken();
167
+ if (!cookie) {
168
+ throw new ApiError(
169
+ "Usu\xE1rio n\xE3o autenticado",
170
+ "NOT_AUTHENTICATED_LOGOUT",
171
+ 401
172
+ );
173
+ }
174
+ const payload = {
175
+ location: clientInfo.location,
176
+ ip: clientInfo.ip,
177
+ timezone: clientInfo.timezone,
178
+ agent: clientInfo.agent,
179
+ cookie
180
+ };
181
+ try {
182
+ const response = await api.apps.post(
183
+ "/auth/logout",
184
+ payload
185
+ );
186
+ if (response.status === 0) {
187
+ throw new ApiError(
188
+ response.message || "Erro ao realizar logout",
189
+ response.code || "LOGOUT_FAILED",
190
+ 400
191
+ );
192
+ }
193
+ } finally {
194
+ await this.removeAuthCookie();
195
+ }
196
+ return {
197
+ success: true
198
+ };
199
+ }
200
+ async forgotPassword(_data) {
201
+ throw new ApiError(
202
+ "Recupera\xE7\xE3o de senha n\xE3o implementada",
203
+ "NOT_IMPLEMENTED",
204
+ 501
205
+ );
206
+ }
207
+ async resetPassword(_data) {
208
+ throw new ApiError(
209
+ "Redefini\xE7\xE3o de senha n\xE3o implementada",
210
+ "NOT_IMPLEMENTED",
211
+ 501
212
+ );
213
+ }
214
+ async verifyEmail(_data) {
215
+ throw new ApiError(
216
+ "Verifica\xE7\xE3o de email n\xE3o implementada",
217
+ "NOT_IMPLEMENTED",
218
+ 501
219
+ );
220
+ }
221
+ async resendVerification(_data) {
222
+ throw new ApiError(
223
+ "Reenvio de verifica\xE7\xE3o n\xE3o implementado",
224
+ "NOT_IMPLEMENTED",
225
+ 501
226
+ );
227
+ }
228
+ async validateSession(clientInfo) {
229
+ const cookie = await this.getToken();
230
+ if (!cookie) {
231
+ return false;
232
+ }
233
+ try {
234
+ const payload = {
235
+ location: clientInfo.location,
236
+ ip: clientInfo.ip,
237
+ timezone: clientInfo.timezone,
238
+ agent: clientInfo.agent,
239
+ cookie
240
+ };
241
+ const response = await api.apps.post(
242
+ "/auth/keep",
243
+ payload
244
+ );
245
+ return response.status === 1;
246
+ } catch (error) {
247
+ console.error("[AuthService] validateSession error", error);
248
+ return false;
249
+ }
250
+ }
251
+ async isAuthenticated() {
252
+ const token = await this.getToken();
253
+ return !!token;
254
+ }
255
+ async getToken() {
256
+ if (process.env.DUMMY_AUTH_TOKEN) return process.env.DUMMY_AUTH_TOKEN;
257
+ const cookieStore = await cookies();
258
+ return cookieStore.get(AUTH_COOKIE_NAME)?.value;
259
+ }
260
+ async resolvePlanId(idPlan) {
261
+ if (idPlan === void 0 || idPlan === null) return 1;
262
+ if (typeof idPlan === "number") return idPlan;
263
+ const response = await api.apps.get(
264
+ `/plans?search=${encodeURIComponent(idPlan)}`
265
+ );
266
+ if (response.status === 0 || !response.data || response.data.length === 0) {
267
+ throw new ApiError(
268
+ `Plano "${idPlan}" n\xE3o encontrado`,
269
+ "PLAN_NOT_FOUND",
270
+ 404
271
+ );
272
+ }
273
+ return response.data[0].id;
274
+ }
275
+ async setAuthCookie(token) {
276
+ const cookieStore = await cookies();
277
+ cookieStore.set(AUTH_COOKIE_NAME, token, {
278
+ ...COOKIE_OPTIONS,
279
+ maxAge: COOKIE_MAX_AGE
280
+ });
281
+ }
282
+ async removeAuthCookie() {
283
+ const cookieStore = await cookies();
284
+ cookieStore.delete({
285
+ name: AUTH_COOKIE_NAME,
286
+ ...COOKIE_OPTIONS
287
+ });
288
+ }
289
+ }
290
+ const authService = new AuthService();
291
+ export {
292
+ authService
293
+ };
294
+ //# sourceMappingURL=auth.service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/services/auth.service.ts"],"sourcesContent":["import { cookies } from \"next/headers\";\r\n\r\nimport { api } from \"../../../infra/api/client\";\r\nimport { ApiError } from \"../../../infra/api/types\";\r\nimport {\r\n ClientInfo,\r\n ForgotPasswordRequest,\r\n ForgotPasswordResponse,\r\n GeoLocation,\r\n LoginApiResponse,\r\n LoginRequest,\r\n LoginResponse,\r\n LogoutApiResponse,\r\n LogoutRequest,\r\n LogoutResponse,\r\n RegisterApiRequest,\r\n RegisterApiResponse,\r\n RegisterRequest,\r\n RegisterResponse,\r\n ResendVerificationRequest,\r\n ResendVerificationResponse,\r\n ResetPasswordRequest,\r\n ResetPasswordResponse,\r\n SearchPlansApiResponse,\r\n SessionKeepRequest,\r\n SessionKeepResponse,\r\n TwoFactorApiResponse,\r\n TwoFactorRequest,\r\n TwoFactorResponse,\r\n VerifyEmailRequest,\r\n VerifyEmailResponse,\r\n} from \"../schema\";\r\n\r\nconst AUTH_COOKIE_NAME = \"greatapps\";\r\nconst COOKIE_MAX_AGE = 60 * 60 * 24 * 30;\r\n\r\nconst COOKIE_OPTIONS = {\r\n httpOnly: true,\r\n secure: process.env.NODE_ENV === \"production\",\r\n sameSite: \"lax\" as const,\r\n path: \"/\",\r\n domain: process.env.DOMAIN_COOKIE,\r\n};\r\n\r\nclass AuthService {\r\n async login(\r\n credentials: LoginRequest,\r\n clientInfo: ClientInfo\r\n ): Promise<LoginResponse> {\r\n const response = await api.apps.post<LoginApiResponse>(\"/auth/login\", {\r\n email: credentials.email,\r\n password: credentials.password,\r\n source: credentials?.source,\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n timezone: clientInfo.timezone,\r\n agent: clientInfo.agent,\r\n });\r\n\r\n console.log(\"[AuthService.login] response\", JSON.stringify(response));\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || \"E-mail ou senha incorretos\",\r\n response.code || \"LOGIN_FAILED\",\r\n 401\r\n );\r\n }\r\n\r\n if (!response.cookie) {\r\n throw new ApiError(\r\n \"Resposta de autenticação inválida\",\r\n \"INVALID_RESPONSE\",\r\n 500\r\n );\r\n }\r\n\r\n if (response.two_factor_required) {\r\n return { result: 'two_factor_required', cookie: response.cookie };\r\n }\r\n\r\n await this.setAuthCookie(response.cookie);\r\n\r\n const [{ userService }, { accountService }] = await Promise.all([\r\n import('../../users/services/user.service'),\r\n import('../../accounts/services/account.service'),\r\n ]);\r\n const [user, account] = await Promise.all([\r\n userService.findById(),\r\n accountService.findCurrentAccount(),\r\n ]);\r\n\r\n return {\r\n result: 'success',\r\n user,\r\n account,\r\n accessToken: response.cookie,\r\n refreshToken: \"\",\r\n expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1000).toISOString(),\r\n };\r\n }\r\n\r\n async verifyTwoFactor(\r\n cookie: string,\r\n code: string,\r\n clientInfo: ClientInfo\r\n ): Promise<TwoFactorResponse> {\r\n const payload: TwoFactorRequest = {\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n timezone: clientInfo.timezone,\r\n agent: clientInfo.agent,\r\n cookie,\r\n code,\r\n };\r\n\r\n const response = await api.apps.post<TwoFactorApiResponse>(\r\n \"/auth/code\",\r\n payload\r\n );\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\"Código 2FA inválido\", \"TWO_FACTOR_FAILED\", 401);\r\n }\r\n\r\n if (!response?.data?.cookie) {\r\n throw new ApiError(\r\n \"Resposta de autenticação inválida após 2FA\",\r\n \"INVALID_RESPONSE\",\r\n 500\r\n );\r\n }\r\n\r\n await this.setAuthCookie(response.data.cookie);\r\n\r\n return { status: 1 };\r\n }\r\n async register(data: RegisterRequest, clientInfo: ClientInfo): Promise<RegisterResponse> {\r\n const today = new Date();\r\n const trialEndDate = new Date(today);\r\n trialEndDate.setDate(today.getDate() + 7); // 7 dias de trial\r\n\r\n const idPlan = await this.resolvePlanId(data.idPlan);\r\n\r\n const payload: RegisterApiRequest = {\r\n name: data.accountName,\r\n bussiness_type: data.businessType ?? 0,\r\n language: \"pt-br\",\r\n timezone: \"America/Sao_Paulo\",\r\n currency: \"BRL\",\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n agent: clientInfo.agent,\r\n user: {\r\n id_api: \"\",\r\n name: data.name,\r\n last_name: data.lastName || \"\",\r\n rg: data.rg || \"\",\r\n cpf: data.cpf || \"\",\r\n gender: data.gender,\r\n email: data.email,\r\n phone: data.phone,\r\n password: data.password,\r\n profile: \"owner\",\r\n language: \"pt-br\",\r\n },\r\n subscription: {\r\n type: \"trial\",\r\n id_cupom: data.couponCode || \"\",\r\n id_plan: idPlan,\r\n due_date: trialEndDate.toISOString().split(\"T\")[0],\r\n id_product: 1,\r\n },\r\n };\r\n\r\n const response = await api.apps.post<RegisterApiResponse>(\r\n \"/accounts\",\r\n payload\r\n );\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || \"Erro ao criar conta\",\r\n \"REGISTER_FAILED\",\r\n 400\r\n );\r\n }\r\n\r\n if (!response.data || response.data.length === 0) {\r\n throw new ApiError(\r\n \"Resposta de registro inválida\",\r\n \"INVALID_RESPONSE\",\r\n 500\r\n );\r\n }\r\n\r\n if (!response.cookie) {\r\n throw new ApiError(\r\n \"Resposta de autenticação inválida\",\r\n \"INVALID_RESPONSE\",\r\n 500\r\n );\r\n }\r\n\r\n const accountData = response.data[0];\r\n\r\n await this.setAuthCookie(response.cookie);\r\n\r\n const [{ userService }, { accountService }] = await Promise.all([\r\n import('../../users/services/user.service'),\r\n import('../../accounts/services/account.service'),\r\n ]);\r\n const [user, account] = await Promise.all([\r\n userService.findById(),\r\n accountService.findCurrentAccount(),\r\n ]);\r\n\r\n return {\r\n user,\r\n account,\r\n accessToken: response.cookie,\r\n refreshToken: \"\",\r\n expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1000).toISOString(),\r\n requiresEmailVerification: !accountData.verified,\r\n };\r\n }\r\n\r\n async logout(clientInfo: ClientInfo): Promise<LogoutResponse> {\r\n const cookie = await this.getToken();\r\n\r\n if (!cookie) {\r\n throw new ApiError(\r\n \"Usuário não autenticado\",\r\n \"NOT_AUTHENTICATED_LOGOUT\",\r\n 401\r\n );\r\n }\r\n\r\n const payload: LogoutRequest = {\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n timezone: clientInfo.timezone,\r\n agent: clientInfo.agent,\r\n cookie,\r\n };\r\n\r\n try {\r\n const response = await api.apps.post<LogoutApiResponse>(\r\n \"/auth/logout\",\r\n payload\r\n );\r\n\r\n if (response.status === 0) {\r\n throw new ApiError(\r\n response.message || \"Erro ao realizar logout\",\r\n response.code || \"LOGOUT_FAILED\",\r\n 400\r\n );\r\n }\r\n } finally {\r\n await this.removeAuthCookie();\r\n }\r\n\r\n return {\r\n success: true,\r\n };\r\n }\r\n\r\n async forgotPassword(\r\n _data: ForgotPasswordRequest\r\n ): Promise<ForgotPasswordResponse> {\r\n throw new ApiError(\r\n \"Recuperação de senha não implementada\",\r\n \"NOT_IMPLEMENTED\",\r\n 501\r\n );\r\n }\r\n\r\n async resetPassword(\r\n _data: ResetPasswordRequest\r\n ): Promise<ResetPasswordResponse> {\r\n throw new ApiError(\r\n \"Redefinição de senha não implementada\",\r\n \"NOT_IMPLEMENTED\",\r\n 501\r\n );\r\n }\r\n\r\n async verifyEmail(_data: VerifyEmailRequest): Promise<VerifyEmailResponse> {\r\n throw new ApiError(\r\n \"Verificação de email não implementada\",\r\n \"NOT_IMPLEMENTED\",\r\n 501\r\n );\r\n }\r\n\r\n async resendVerification(\r\n _data: ResendVerificationRequest\r\n ): Promise<ResendVerificationResponse> {\r\n throw new ApiError(\r\n \"Reenvio de verificação não implementado\",\r\n \"NOT_IMPLEMENTED\",\r\n 501\r\n );\r\n }\r\n\r\n async validateSession(clientInfo: ClientInfo): Promise<boolean> {\r\n const cookie = await this.getToken();\r\n\r\n if (!cookie) {\r\n return false;\r\n }\r\n\r\n try {\r\n const payload: SessionKeepRequest = {\r\n location: clientInfo.location,\r\n ip: clientInfo.ip,\r\n timezone: clientInfo.timezone,\r\n agent: clientInfo.agent,\r\n cookie,\r\n };\r\n\r\n const response = await api.apps.post<SessionKeepResponse>(\r\n \"/auth/keep\",\r\n payload\r\n );\r\n\r\n return response.status === 1;\r\n } catch (error) {\r\n console.error(\"[AuthService] validateSession error\", error);\r\n return false;\r\n }\r\n }\r\n\r\n async isAuthenticated(): Promise<boolean> {\r\n const token = await this.getToken();\r\n return !!token;\r\n }\r\n\r\n async getToken(): Promise<string | undefined> {\r\n if (process.env.DUMMY_AUTH_TOKEN) return process.env.DUMMY_AUTH_TOKEN;\r\n const cookieStore = await cookies();\r\n return cookieStore.get(AUTH_COOKIE_NAME)?.value;\r\n }\r\n\r\n private async resolvePlanId(idPlan?: number | string): Promise<number> {\r\n if (idPlan === undefined || idPlan === null) return 1;\r\n if (typeof idPlan === 'number') return idPlan;\r\n\r\n const response = await api.apps.get<SearchPlansApiResponse>(\r\n `/plans?search=${encodeURIComponent(idPlan)}`\r\n );\r\n\r\n if (response.status === 0 || !response.data || response.data.length === 0) {\r\n throw new ApiError(\r\n `Plano \"${idPlan}\" não encontrado`,\r\n \"PLAN_NOT_FOUND\",\r\n 404\r\n );\r\n }\r\n\r\n return response.data[0].id;\r\n }\r\n\r\n private async setAuthCookie(token: string): Promise<void> {\r\n const cookieStore = await cookies();\r\n cookieStore.set(AUTH_COOKIE_NAME, token, {\r\n ...COOKIE_OPTIONS,\r\n maxAge: COOKIE_MAX_AGE,\r\n });\r\n }\r\n\r\n async removeAuthCookie(): Promise<void> {\r\n const cookieStore = await cookies();\r\n cookieStore.delete({\r\n name: AUTH_COOKIE_NAME,\r\n ...COOKIE_OPTIONS,\r\n });\r\n }\r\n}\r\n\r\nexport const authService = new Au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AQ;AAAA,IACV,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,mBAAkC;AACtC,UAAM,cAAc,MAAM,QAAQ;AAClC,gBAAY,OAAO;AAAA,MACjB,MAAM;AAAA,MACN,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;AAEO,MAAM,cAAc,IAAI,YAAY;","names":[]}
@@ -0,0 +1,24 @@
1
+ import "server-only";
2
+ import { cookies } from "next/headers";
3
+ import { ApiError } from "../../../infra/api/types";
4
+ const AUTH_COOKIE_NAME = "greatapps";
5
+ async function getUserContext() {
6
+ const cookieStore = await cookies();
7
+ const token = process.env.DUMMY_AUTH_TOKEN || cookieStore.get(AUTH_COOKIE_NAME)?.value;
8
+ if (!token) {
9
+ throw new ApiError("Usu\xE1rio n\xE3o autenticado", "NOT_AUTHENTICATED_GUC", 401);
10
+ }
11
+ try {
12
+ const payload = JSON.parse(atob(token.split(".")[1]));
13
+ return {
14
+ id_account: payload.id_account,
15
+ id_user: payload.id_user
16
+ };
17
+ } catch {
18
+ throw new ApiError("Token inv\xE1lido", "INVALID_TOKEN", 401);
19
+ }
20
+ }
21
+ export {
22
+ getUserContext
23
+ };
24
+ //# sourceMappingURL=get-user-context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/utils/get-user-context.ts"],"sourcesContent":["import 'server-only';\r\n\r\nimport { cookies } from 'next/headers';\r\nimport { ApiError } from '../../../infra/api/types';\r\nimport { JWTPayload } from '../../users/schema';\r\n\r\nconst AUTH_COOKIE_NAME = 'greatapps';\r\n\r\nexport async function getUserContext(): Promise<{\r\n id_account: number;\r\n id_user: number;\r\n}> {\r\n const cookieStore = await cookies();\r\n const token = process.env.DUMMY_AUTH_TOKEN || cookieStore.get(AUTH_COOKIE_NAME)?.value;\r\n\r\n if (!token) {\r\n throw new ApiError('Usuário não autenticado', 'NOT_AUTHENTICATED_GUC', 401);\r\n }\r\n\r\n try {\r\n const payload = JSON.parse(atob(token.split('.')[1])) as JWTPayload;\r\n\r\n return {\r\n id_account: payload.id_account,\r\n id_user: payload.id_user,\r\n };\r\n } catch {\r\n throw new ApiError('Token inválido', 'INVALID_TOKEN', 401);\r\n }\r\n}\r\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAGzB,MAAM,mBAAmB;AAEzB,eAAsB,iBAGnB;AACD,QAAM,cAAc,MAAM,QAAQ;AAClC,QAAM,QAAQ,QAAQ,IAAI,oBAAoB,YAAY,IAAI,gBAAgB,GAAG;AAEjF,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,SAAS,iCAA2B,yBAAyB,GAAG;AAAA,EAC5E;AAEA,MAAI;AACF,UAAM,UAAU,KAAK,MAAM,KAAK,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;AAEpD,WAAO;AAAA,MACL,YAAY,QAAQ;AAAA,MACpB,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF,QAAQ;AACN,UAAM,IAAI,SAAS,qBAAkB,iBAAiB,GAAG;AAAA,EAC3D;AACF;","names":[]}
@@ -0,0 +1,10 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { iaCreditsService } from "../services/ia-credits.service";
4
+ async function listIaCreditsAction(subscriptionId) {
5
+ return safeServerAction(() => iaCreditsService.listOperations(subscriptionId));
6
+ }
7
+ export {
8
+ listIaCreditsAction
9
+ };
10
+ //# sourceMappingURL=list-ia-credits.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/ia-credits/actions/list-ia-credits.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { iaCreditsService } from '../services/ia-credits.service';\n\nexport async function listIaCreditsAction(subscriptionId: number | string) {\n return safeServerAction(() => iaCreditsService.listOperations(subscriptionId));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAEjC,eAAsB,oBAAoB,gBAAiC;AACzE,SAAO,iBAAiB,MAAM,iBAAiB,eAAe,cAAc,CAAC;AAC/E;","names":[]}