@greatapps/common 1.1.429 → 1.1.430

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 (477) 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 +129 -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 +182 -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 +91 -0
  24. package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -0
  25. package/dist/components/account/hooks/useConfigurationsModal.mjs +34 -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 +192 -0
  38. package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -0
  39. package/dist/components/account/sections/MyProfileSection.mjs +317 -0
  40. package/dist/components/account/sections/MyProfileSection.mjs.map +1 -0
  41. package/dist/components/account/sections/PreferencesSection.mjs +227 -0
  42. package/dist/components/account/sections/PreferencesSection.mjs.map +1 -0
  43. package/dist/components/account/sections/SecuritySection.mjs +31 -0
  44. package/dist/components/account/sections/SecuritySection.mjs.map +1 -0
  45. package/dist/components/embeds/CrispEmbed.mjs +89 -0
  46. package/dist/components/embeds/CrispEmbed.mjs.map +1 -0
  47. package/dist/components/embeds/FrillEmbed.mjs +107 -0
  48. package/dist/components/embeds/FrillEmbed.mjs.map +1 -0
  49. package/dist/components/handlers/SearchParamsHandler.mjs +24 -0
  50. package/dist/components/handlers/SearchParamsHandler.mjs.map +1 -0
  51. package/dist/components/layouts/AppMobileNavBar.mjs +60 -0
  52. package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -0
  53. package/dist/components/layouts/AppNavBar.mjs +37 -0
  54. package/dist/components/layouts/AppNavBar.mjs.map +1 -0
  55. package/dist/components/layouts/CollapsibleSidebar.mjs +65 -0
  56. package/dist/components/layouts/CollapsibleSidebar.mjs.map +1 -0
  57. package/dist/components/layouts/MainLayout.mjs +60 -0
  58. package/dist/components/layouts/MainLayout.mjs.map +1 -0
  59. package/dist/components/layouts/MdSideBarNavigation.mjs +54 -0
  60. package/dist/components/layouts/MdSideBarNavigation.mjs.map +1 -0
  61. package/dist/components/layouts/NavBar.mjs +152 -0
  62. package/dist/components/layouts/NavBar.mjs.map +1 -0
  63. package/dist/components/layouts/NavBarItem.mjs +23 -0
  64. package/dist/components/layouts/NavBarItem.mjs.map +1 -0
  65. package/dist/components/layouts/NotificationsPopover.mjs +97 -0
  66. package/dist/components/layouts/NotificationsPopover.mjs.map +1 -0
  67. package/dist/components/layouts/ProfilePopover.mjs +152 -0
  68. package/dist/components/layouts/ProfilePopover.mjs.map +1 -0
  69. package/dist/components/layouts/SideBarNavigation.mjs +63 -0
  70. package/dist/components/layouts/SideBarNavigation.mjs.map +1 -0
  71. package/dist/components/layouts/UsersSelectorPopover.mjs +210 -0
  72. package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -0
  73. package/dist/components/layouts/WhitelabelCodes.mjs +50 -0
  74. package/dist/components/layouts/WhitelabelCodes.mjs.map +1 -0
  75. package/dist/components/modals/BuyCreditsModal.mjs +281 -0
  76. package/dist/components/modals/BuyCreditsModal.mjs.map +1 -0
  77. package/dist/components/modals/ModalManager.mjs +19 -0
  78. package/dist/components/modals/ModalManager.mjs.map +1 -0
  79. package/dist/components/modals/Modals.mjs +20 -0
  80. package/dist/components/modals/Modals.mjs.map +1 -0
  81. package/dist/components/modals/PaidPlanRequiredModal.mjs +46 -0
  82. package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -0
  83. package/dist/components/modals/cards/AddCardModal.mjs +215 -0
  84. package/dist/components/modals/cards/AddCardModal.mjs.map +1 -0
  85. package/dist/components/modals/cards/CardFormFields.mjs +268 -0
  86. package/dist/components/modals/cards/CardFormFields.mjs.map +1 -0
  87. package/dist/components/navigation/AppNavigation.mjs +33 -0
  88. package/dist/components/navigation/AppNavigation.mjs.map +1 -0
  89. package/dist/components/navigation/AppNavigationContext.mjs +13 -0
  90. package/dist/components/navigation/AppNavigationContext.mjs.map +1 -0
  91. package/dist/components/navigation/CancelledSubscriptionBanner.mjs +52 -0
  92. package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -0
  93. package/dist/components/navigation/NavItem.mjs +41 -0
  94. package/dist/components/navigation/NavItem.mjs.map +1 -0
  95. package/dist/components/navigation/NavItemsContext.mjs +16 -0
  96. package/dist/components/navigation/NavItemsContext.mjs.map +1 -0
  97. package/dist/components/navigation/ProjectSelectorPopover.mjs +147 -0
  98. package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -0
  99. package/dist/components/navigation/shells/DesktopShell.mjs +11 -0
  100. package/dist/components/navigation/shells/DesktopShell.mjs.map +1 -0
  101. package/dist/components/navigation/shells/MdShell.mjs +11 -0
  102. package/dist/components/navigation/shells/MdShell.mjs.map +1 -0
  103. package/dist/components/navigation/shells/MobileShell.mjs +27 -0
  104. package/dist/components/navigation/shells/MobileShell.mjs.map +1 -0
  105. package/dist/components/navigation/shells/TabsMobileShell.mjs +61 -0
  106. package/dist/components/navigation/shells/TabsMobileShell.mjs.map +1 -0
  107. package/dist/components/navigation/subcomponents/BottomLinks.mjs +35 -0
  108. package/dist/components/navigation/subcomponents/BottomLinks.mjs.map +1 -0
  109. package/dist/components/navigation/subcomponents/CreditsCard.mjs +33 -0
  110. package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -0
  111. package/dist/components/navigation/subcomponents/NavItems.mjs +25 -0
  112. package/dist/components/navigation/subcomponents/NavItems.mjs.map +1 -0
  113. package/dist/components/navigation/subcomponents/PlanCard.mjs +25 -0
  114. package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -0
  115. package/dist/components/navigation/subcomponents/ProjectSelector.mjs +145 -0
  116. package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -0
  117. package/dist/components/navigation/types.mjs +1 -0
  118. package/dist/components/navigation/types.mjs.map +1 -0
  119. package/dist/components/pages/NotFoundPage.mjs +47 -0
  120. package/dist/components/pages/NotFoundPage.mjs.map +1 -0
  121. package/dist/components/pages/notifications/Notifications.mjs +159 -0
  122. package/dist/components/pages/notifications/Notifications.mjs.map +1 -0
  123. package/dist/components/ui/buttons/Button.mjs +52 -0
  124. package/dist/components/ui/buttons/Button.mjs.map +1 -0
  125. package/dist/components/ui/buttons/CancelButton.mjs +17 -0
  126. package/dist/components/ui/buttons/CancelButton.mjs.map +1 -0
  127. package/dist/components/ui/buttons/CopyButton.mjs +42 -0
  128. package/dist/components/ui/buttons/CopyButton.mjs.map +1 -0
  129. package/dist/components/ui/data-display/Accordion.mjs +76 -0
  130. package/dist/components/ui/data-display/Accordion.mjs.map +1 -0
  131. package/dist/components/ui/data-display/Badge.mjs +42 -0
  132. package/dist/components/ui/data-display/Badge.mjs.map +1 -0
  133. package/dist/components/ui/data-display/Card.mjs +92 -0
  134. package/dist/components/ui/data-display/Card.mjs.map +1 -0
  135. package/dist/components/ui/data-display/CardBrandIcons.mjs +484 -0
  136. package/dist/components/ui/data-display/CardBrandIcons.mjs.map +1 -0
  137. package/dist/components/ui/data-display/CardItem.mjs +67 -0
  138. package/dist/components/ui/data-display/CardItem.mjs.map +1 -0
  139. package/dist/components/ui/data-display/Pagination.mjs +118 -0
  140. package/dist/components/ui/data-display/Pagination.mjs.map +1 -0
  141. package/dist/components/ui/data-display/PaymentInfoCard.mjs +161 -0
  142. package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -0
  143. package/dist/components/ui/data-display/ScrollArea.mjs +62 -0
  144. package/dist/components/ui/data-display/ScrollArea.mjs.map +1 -0
  145. package/dist/components/ui/data-display/Separator.mjs +28 -0
  146. package/dist/components/ui/data-display/Separator.mjs.map +1 -0
  147. package/dist/components/ui/data-display/Table.mjs +116 -0
  148. package/dist/components/ui/data-display/Table.mjs.map +1 -0
  149. package/dist/components/ui/data-display/Tabs.mjs +69 -0
  150. package/dist/components/ui/data-display/Tabs.mjs.map +1 -0
  151. package/dist/components/ui/data-display/UserAvatar.mjs +49 -0
  152. package/dist/components/ui/data-display/UserAvatar.mjs.map +1 -0
  153. package/dist/components/ui/feedback/CircularProgress.mjs +71 -0
  154. package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -0
  155. package/dist/components/ui/feedback/DefaultCircularProgress.mjs +63 -0
  156. package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -0
  157. package/dist/components/ui/feedback/LoadingOverlay.mjs +19 -0
  158. package/dist/components/ui/feedback/LoadingOverlay.mjs.map +1 -0
  159. package/dist/components/ui/feedback/Progress.mjs +37 -0
  160. package/dist/components/ui/feedback/Progress.mjs.map +1 -0
  161. package/dist/components/ui/feedback/Skeleton.mjs +9 -0
  162. package/dist/components/ui/feedback/Skeleton.mjs.map +1 -0
  163. package/dist/components/ui/feedback/Toast.mjs +77 -0
  164. package/dist/components/ui/feedback/Toast.mjs.map +1 -0
  165. package/dist/components/ui/form/Calendar.mjs +204 -0
  166. package/dist/components/ui/form/Calendar.mjs.map +1 -0
  167. package/dist/components/ui/form/Checkbox.mjs +33 -0
  168. package/dist/components/ui/form/Checkbox.mjs.map +1 -0
  169. package/dist/components/ui/form/ComboboxField.mjs +130 -0
  170. package/dist/components/ui/form/ComboboxField.mjs.map +1 -0
  171. package/dist/components/ui/form/DatePicker.mjs +82 -0
  172. package/dist/components/ui/form/DatePicker.mjs.map +1 -0
  173. package/dist/components/ui/form/DateRangePicker.mjs +92 -0
  174. package/dist/components/ui/form/DateRangePicker.mjs.map +1 -0
  175. package/dist/components/ui/form/FormField.mjs +103 -0
  176. package/dist/components/ui/form/FormField.mjs.map +1 -0
  177. package/dist/components/ui/form/Input.mjs +21 -0
  178. package/dist/components/ui/form/Input.mjs.map +1 -0
  179. package/dist/components/ui/form/InputOtp.mjs +70 -0
  180. package/dist/components/ui/form/InputOtp.mjs.map +1 -0
  181. package/dist/components/ui/form/PhoneInput.mjs +176 -0
  182. package/dist/components/ui/form/PhoneInput.mjs.map +1 -0
  183. package/dist/components/ui/form/RadioGroup.mjs +37 -0
  184. package/dist/components/ui/form/RadioGroup.mjs.map +1 -0
  185. package/dist/components/ui/form/Select.mjs +179 -0
  186. package/dist/components/ui/form/Select.mjs.map +1 -0
  187. package/dist/components/ui/form/SelectField.mjs +80 -0
  188. package/dist/components/ui/form/SelectField.mjs.map +1 -0
  189. package/dist/components/ui/form/Switch.mjs +33 -0
  190. package/dist/components/ui/form/Switch.mjs.map +1 -0
  191. package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs +40 -0
  192. package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +1 -0
  193. package/dist/components/ui/form/TextAreaField.mjs +56 -0
  194. package/dist/components/ui/form/TextAreaField.mjs.map +1 -0
  195. package/dist/components/ui/form/Textarea.mjs +20 -0
  196. package/dist/components/ui/form/Textarea.mjs.map +1 -0
  197. package/dist/components/ui/overlay/Command.mjs +178 -0
  198. package/dist/components/ui/overlay/Command.mjs.map +1 -0
  199. package/dist/components/ui/overlay/Dialog.mjs +142 -0
  200. package/dist/components/ui/overlay/Dialog.mjs.map +1 -0
  201. package/dist/components/ui/overlay/Popover.mjs +46 -0
  202. package/dist/components/ui/overlay/Popover.mjs.map +1 -0
  203. package/dist/components/ui/overlay/Sheet.mjs +149 -0
  204. package/dist/components/ui/overlay/Sheet.mjs.map +1 -0
  205. package/dist/components/ui/overlay/Tooltip.mjs +57 -0
  206. package/dist/components/ui/overlay/Tooltip.mjs.map +1 -0
  207. package/dist/components/widgets/notifications/NotificationCard.mjs +54 -0
  208. package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -0
  209. package/dist/enums/AccountSectionType.mjs +11 -0
  210. package/dist/enums/AccountSectionType.mjs.map +1 -0
  211. package/dist/hooks/copy-to-clipboard.hook.mjs +52 -0
  212. package/dist/hooks/copy-to-clipboard.hook.mjs.map +1 -0
  213. package/dist/hooks/useCountdownTimer.mjs +29 -0
  214. package/dist/hooks/useCountdownTimer.mjs.map +1 -0
  215. package/dist/hooks/useDebounce.mjs +19 -0
  216. package/dist/hooks/useDebounce.mjs.map +1 -0
  217. package/dist/hooks/useDebounceState.mjs +12 -0
  218. package/dist/hooks/useDebounceState.mjs.map +1 -0
  219. package/dist/hooks/useDebouncedEffect.mjs +44 -0
  220. package/dist/hooks/useDebouncedEffect.mjs.map +1 -0
  221. package/dist/hooks/useIsMobile.mjs +18 -0
  222. package/dist/hooks/useIsMobile.mjs.map +1 -0
  223. package/dist/hooks/usePasswordVisibility.mjs +13 -0
  224. package/dist/hooks/usePasswordVisibility.mjs.map +1 -0
  225. package/dist/index.mjs +528 -0
  226. package/dist/index.mjs.map +1 -0
  227. package/dist/infra/api/client.mjs +162 -0
  228. package/dist/infra/api/client.mjs.map +1 -0
  229. package/dist/infra/api/types.mjs +31 -0
  230. package/dist/infra/api/types.mjs.map +1 -0
  231. package/dist/infra/utils/client-info.mjs +27 -0
  232. package/dist/infra/utils/client-info.mjs.map +1 -0
  233. package/dist/infra/utils/clsx.mjs +9 -0
  234. package/dist/infra/utils/clsx.mjs.map +1 -0
  235. package/dist/infra/utils/date.mjs +11 -0
  236. package/dist/infra/utils/date.mjs.map +1 -0
  237. package/dist/infra/utils/params.mjs +21 -0
  238. package/dist/infra/utils/params.mjs.map +1 -0
  239. package/dist/infra/utils/parser.mjs +24 -0
  240. package/dist/infra/utils/parser.mjs.map +1 -0
  241. package/dist/infra/utils/percentage.mjs +20 -0
  242. package/dist/infra/utils/percentage.mjs.map +1 -0
  243. package/dist/middleware.mjs +10 -0
  244. package/dist/middleware.mjs.map +1 -0
  245. package/dist/middlewares/chain.mjs +37 -0
  246. package/dist/middlewares/chain.mjs.map +1 -0
  247. package/dist/middlewares/create-auth-middleware.mjs +32 -0
  248. package/dist/middlewares/create-auth-middleware.mjs.map +1 -0
  249. package/dist/middlewares/types.mjs +11 -0
  250. package/dist/middlewares/types.mjs.map +1 -0
  251. package/dist/modules/accounts/actions/account-management.action.mjs +98 -0
  252. package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -0
  253. package/dist/modules/accounts/actions/find-current-account.action.mjs +10 -0
  254. package/dist/modules/accounts/actions/find-current-account.action.mjs.map +1 -0
  255. package/dist/modules/accounts/actions/list-currencies.action.mjs +10 -0
  256. package/dist/modules/accounts/actions/list-currencies.action.mjs.map +1 -0
  257. package/dist/modules/accounts/actions/list-timezones.action.mjs +10 -0
  258. package/dist/modules/accounts/actions/list-timezones.action.mjs.map +1 -0
  259. package/dist/modules/accounts/hooks/current-account.hook.mjs +24 -0
  260. package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -0
  261. package/dist/modules/accounts/hooks/useAccountManagement.mjs +71 -0
  262. package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -0
  263. package/dist/modules/accounts/hooks/useCurrencies.mjs +17 -0
  264. package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -0
  265. package/dist/modules/accounts/hooks/useTimezones.mjs +17 -0
  266. package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -0
  267. package/dist/modules/accounts/hooks/useViaCep.mjs +19 -0
  268. package/dist/modules/accounts/hooks/useViaCep.mjs.map +1 -0
  269. package/dist/modules/accounts/services/account.service.mjs +182 -0
  270. package/dist/modules/accounts/services/account.service.mjs.map +1 -0
  271. package/dist/modules/accounts/services/currency.service.mjs +24 -0
  272. package/dist/modules/accounts/services/currency.service.mjs.map +1 -0
  273. package/dist/modules/accounts/services/timezone.service.mjs +65 -0
  274. package/dist/modules/accounts/services/timezone.service.mjs.map +1 -0
  275. package/dist/modules/accounts/services/two-factor.service.mjs +78 -0
  276. package/dist/modules/accounts/services/two-factor.service.mjs.map +1 -0
  277. package/dist/modules/accounts/types.mjs +1 -0
  278. package/dist/modules/accounts/types.mjs.map +1 -0
  279. package/dist/modules/auth/actions/login.action.mjs +14 -0
  280. package/dist/modules/auth/actions/login.action.mjs.map +1 -0
  281. package/dist/modules/auth/actions/logout.action.mjs +14 -0
  282. package/dist/modules/auth/actions/logout.action.mjs.map +1 -0
  283. package/dist/modules/auth/actions/register.action.mjs +14 -0
  284. package/dist/modules/auth/actions/register.action.mjs.map +1 -0
  285. package/dist/modules/auth/actions/validate-session.action.mjs +48 -0
  286. package/dist/modules/auth/actions/validate-session.action.mjs.map +1 -0
  287. package/dist/modules/auth/actions/verify-two-factor.action.mjs +17 -0
  288. package/dist/modules/auth/actions/verify-two-factor.action.mjs.map +1 -0
  289. package/dist/modules/auth/hooks/login.hook.mjs +13 -0
  290. package/dist/modules/auth/hooks/login.hook.mjs.map +1 -0
  291. package/dist/modules/auth/hooks/logout.hook.mjs +13 -0
  292. package/dist/modules/auth/hooks/logout.hook.mjs.map +1 -0
  293. package/dist/modules/auth/hooks/register.hook.mjs +13 -0
  294. package/dist/modules/auth/hooks/register.hook.mjs.map +1 -0
  295. package/dist/modules/auth/hooks/useManagementPermissions.mjs +41 -0
  296. package/dist/modules/auth/hooks/useManagementPermissions.mjs.map +1 -0
  297. package/dist/modules/auth/hooks/useUserQuery.mjs +63 -0
  298. package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -0
  299. package/dist/modules/auth/schema.mjs +1 -0
  300. package/dist/modules/auth/schema.mjs.map +1 -0
  301. package/dist/modules/auth/services/auth.service.mjs +341 -0
  302. package/dist/modules/auth/services/auth.service.mjs.map +1 -0
  303. package/dist/modules/auth/types/management-permission.type.mjs +1 -0
  304. package/dist/modules/auth/types/management-permission.type.mjs.map +1 -0
  305. package/dist/modules/auth/utils/assert-management-permission.mjs +42 -0
  306. package/dist/modules/auth/utils/assert-management-permission.mjs.map +1 -0
  307. package/dist/modules/auth/utils/assert-management-subscription.mjs +33 -0
  308. package/dist/modules/auth/utils/assert-management-subscription.mjs.map +1 -0
  309. package/dist/modules/auth/utils/assert-paid-subscription.mjs +40 -0
  310. package/dist/modules/auth/utils/assert-paid-subscription.mjs.map +1 -0
  311. package/dist/modules/auth/utils/assert-subscription-addon.mjs +35 -0
  312. package/dist/modules/auth/utils/assert-subscription-addon.mjs.map +1 -0
  313. package/dist/modules/auth/utils/build-wl-override.mjs +27 -0
  314. package/dist/modules/auth/utils/build-wl-override.mjs.map +1 -0
  315. package/dist/modules/auth/utils/get-user-context.mjs +25 -0
  316. package/dist/modules/auth/utils/get-user-context.mjs.map +1 -0
  317. package/dist/modules/cards/actions/create-card.action.mjs +10 -0
  318. package/dist/modules/cards/actions/create-card.action.mjs.map +1 -0
  319. package/dist/modules/cards/actions/list-cards.action.mjs +10 -0
  320. package/dist/modules/cards/actions/list-cards.action.mjs.map +1 -0
  321. package/dist/modules/cards/hooks/cards.hook.mjs +16 -0
  322. package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -0
  323. package/dist/modules/cards/hooks/create-card.hook.mjs +18 -0
  324. package/dist/modules/cards/hooks/create-card.hook.mjs.map +1 -0
  325. package/dist/modules/cards/services/cards.service.mjs +44 -0
  326. package/dist/modules/cards/services/cards.service.mjs.map +1 -0
  327. package/dist/modules/cards/types.mjs +27 -0
  328. package/dist/modules/cards/types.mjs.map +1 -0
  329. package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs +10 -0
  330. package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs.map +1 -0
  331. package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +76 -0
  332. package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -0
  333. package/dist/modules/ia-credits/services/ia-credits.service.mjs +31 -0
  334. package/dist/modules/ia-credits/services/ia-credits.service.mjs.map +1 -0
  335. package/dist/modules/ia-credits/types.mjs +25 -0
  336. package/dist/modules/ia-credits/types.mjs.map +1 -0
  337. package/dist/modules/plans/actions/find-plan-by-id.action.mjs +10 -0
  338. package/dist/modules/plans/actions/find-plan-by-id.action.mjs.map +1 -0
  339. package/dist/modules/plans/hooks/use-has-plan-addon.hook.mjs +13 -0
  340. package/dist/modules/plans/hooks/use-has-plan-addon.hook.mjs.map +1 -0
  341. package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +15 -0
  342. package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -0
  343. package/dist/modules/plans/services/plans.service.mjs +34 -0
  344. package/dist/modules/plans/services/plans.service.mjs.map +1 -0
  345. package/dist/modules/plans/types/plan.type.mjs +20 -0
  346. package/dist/modules/plans/types/plan.type.mjs.map +1 -0
  347. package/dist/modules/projects/actions/add-project-user.action.mjs +10 -0
  348. package/dist/modules/projects/actions/add-project-user.action.mjs.map +1 -0
  349. package/dist/modules/projects/actions/list-all-account-users.action.mjs +10 -0
  350. package/dist/modules/projects/actions/list-all-account-users.action.mjs.map +1 -0
  351. package/dist/modules/projects/actions/list-available-users.action.mjs +10 -0
  352. package/dist/modules/projects/actions/list-available-users.action.mjs.map +1 -0
  353. package/dist/modules/projects/actions/list-project-users.action.mjs +10 -0
  354. package/dist/modules/projects/actions/list-project-users.action.mjs.map +1 -0
  355. package/dist/modules/projects/actions/remove-project-user.action.mjs +10 -0
  356. package/dist/modules/projects/actions/remove-project-user.action.mjs.map +1 -0
  357. package/dist/modules/projects/hooks/add-project-user.hook.mjs +61 -0
  358. package/dist/modules/projects/hooks/add-project-user.hook.mjs.map +1 -0
  359. package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +35 -0
  360. package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -0
  361. package/dist/modules/projects/hooks/list-available-users.hook.mjs +34 -0
  362. package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -0
  363. package/dist/modules/projects/hooks/list-project-users.hook.mjs +34 -0
  364. package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -0
  365. package/dist/modules/projects/hooks/remove-project-user.hook.mjs +61 -0
  366. package/dist/modules/projects/hooks/remove-project-user.hook.mjs.map +1 -0
  367. package/dist/modules/projects/services/project-users.service.mjs +96 -0
  368. package/dist/modules/projects/services/project-users.service.mjs.map +1 -0
  369. package/dist/modules/projects/types.mjs +23 -0
  370. package/dist/modules/projects/types.mjs.map +1 -0
  371. package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs +10 -0
  372. package/dist/modules/subscriptions/actions/calculate-subscription.action.mjs.map +1 -0
  373. package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs +10 -0
  374. package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs.map +1 -0
  375. package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs +12 -0
  376. package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs.map +1 -0
  377. package/dist/modules/subscriptions/constants/addons.constants.mjs +24 -0
  378. package/dist/modules/subscriptions/constants/addons.constants.mjs.map +1 -0
  379. package/dist/modules/subscriptions/constants/query-keys.constants.mjs +5 -0
  380. package/dist/modules/subscriptions/constants/query-keys.constants.mjs.map +1 -0
  381. package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs +13 -0
  382. package/dist/modules/subscriptions/hooks/calculate-subscription.hook.mjs.map +1 -0
  383. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +17 -0
  384. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -0
  385. package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +17 -0
  386. package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -0
  387. package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs +22 -0
  388. package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs.map +1 -0
  389. package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs +37 -0
  390. package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs.map +1 -0
  391. package/dist/modules/subscriptions/services/subscriptions.service.mjs +75 -0
  392. package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -0
  393. package/dist/modules/subscriptions/types/billing-period.type.mjs +1 -0
  394. package/dist/modules/subscriptions/types/billing-period.type.mjs.map +1 -0
  395. package/dist/modules/subscriptions/types/calculate-subscription.type.mjs +72 -0
  396. package/dist/modules/subscriptions/types/calculate-subscription.type.mjs.map +1 -0
  397. package/dist/modules/subscriptions/types/subscription.type.mjs +57 -0
  398. package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -0
  399. package/dist/modules/subscriptions/utils/build-plan-extras.mjs +37 -0
  400. package/dist/modules/subscriptions/utils/build-plan-extras.mjs.map +1 -0
  401. package/dist/modules/subscriptions/utils/has-subscription-expired.mjs +10 -0
  402. package/dist/modules/subscriptions/utils/has-subscription-expired.mjs.map +1 -0
  403. package/dist/modules/subscriptions/utils/periodicity.mjs +48 -0
  404. package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -0
  405. package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs +14 -0
  406. package/dist/modules/subscriptions/utils/resolve-plan-extras-prices.mjs.map +1 -0
  407. package/dist/modules/users/action/find-user-by-id.action.mjs +10 -0
  408. package/dist/modules/users/action/find-user-by-id.action.mjs.map +1 -0
  409. package/dist/modules/users/action/list-messages.action.mjs +13 -0
  410. package/dist/modules/users/action/list-messages.action.mjs.map +1 -0
  411. package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +10 -0
  412. package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -0
  413. package/dist/modules/users/action/mark-message-as-read.action.mjs +10 -0
  414. package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -0
  415. package/dist/modules/users/hooks/messages.hook.mjs +57 -0
  416. package/dist/modules/users/hooks/messages.hook.mjs.map +1 -0
  417. package/dist/modules/users/schema/messages.schema.mjs +21 -0
  418. package/dist/modules/users/schema/messages.schema.mjs.map +1 -0
  419. package/dist/modules/users/schema.mjs +11 -0
  420. package/dist/modules/users/schema.mjs.map +1 -0
  421. package/dist/modules/users/services/messages.service.mjs +35 -0
  422. package/dist/modules/users/services/messages.service.mjs.map +1 -0
  423. package/dist/modules/users/services/user.service.mjs +52 -0
  424. package/dist/modules/users/services/user.service.mjs.map +1 -0
  425. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs +21 -0
  426. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +1 -0
  427. package/dist/modules/whitelabel/actions/revalidate-whitelabel.action.mjs +19 -0
  428. package/dist/modules/whitelabel/actions/revalidate-whitelabel.action.mjs.map +1 -0
  429. package/dist/modules/whitelabel/schema.mjs +1 -0
  430. package/dist/modules/whitelabel/schema.mjs.map +1 -0
  431. package/dist/modules/whitelabel/services/whitelabel.service.mjs +146 -0
  432. package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +1 -0
  433. package/dist/modules/whitelabel/utils/normalize-hostname.mjs +35 -0
  434. package/dist/modules/whitelabel/utils/normalize-hostname.mjs.map +1 -0
  435. package/dist/providers/auth.provider.mjs +114 -0
  436. package/dist/providers/auth.provider.mjs.map +1 -0
  437. package/dist/providers/query.provider.mjs +99 -0
  438. package/dist/providers/query.provider.mjs.map +1 -0
  439. package/dist/providers/whitelabel.provider.mjs +42 -0
  440. package/dist/providers/whitelabel.provider.mjs.map +1 -0
  441. package/dist/server.mjs +111 -0
  442. package/dist/server.mjs.map +1 -0
  443. package/dist/store/useAccountModals.mjs +18 -0
  444. package/dist/store/useAccountModals.mjs.map +1 -0
  445. package/dist/store/useBuyCreditsModal.mjs +16 -0
  446. package/dist/store/useBuyCreditsModal.mjs.map +1 -0
  447. package/dist/store/useDesktopSidebarStore.mjs +39 -0
  448. package/dist/store/useDesktopSidebarStore.mjs.map +1 -0
  449. package/dist/store/useMdSidebarStore.mjs +28 -0
  450. package/dist/store/useMdSidebarStore.mjs.map +1 -0
  451. package/dist/store/useMobileNavbarSheet.mjs +14 -0
  452. package/dist/store/useMobileNavbarSheet.mjs.map +1 -0
  453. package/dist/store/useModalManager.mjs +75 -0
  454. package/dist/store/useModalManager.mjs.map +1 -0
  455. package/dist/store/usePaidPlanRequiredModal.mjs +14 -0
  456. package/dist/store/usePaidPlanRequiredModal.mjs.map +1 -0
  457. package/dist/utils/browser/clipboard.mjs +36 -0
  458. package/dist/utils/browser/clipboard.mjs.map +1 -0
  459. package/dist/utils/constants/br-states.mjs +33 -0
  460. package/dist/utils/constants/br-states.mjs.map +1 -0
  461. package/dist/utils/countries.mjs +219 -0
  462. package/dist/utils/countries.mjs.map +1 -0
  463. package/dist/utils/file/index.mjs +9 -0
  464. package/dist/utils/file/index.mjs.map +1 -0
  465. package/dist/utils/format/masks.mjs +67 -0
  466. package/dist/utils/format/masks.mjs.map +1 -0
  467. package/dist/utils/intl/locales.mjs +12 -0
  468. package/dist/utils/intl/locales.mjs.map +1 -0
  469. package/dist/utils/safeServerAction.mjs +16 -0
  470. package/dist/utils/safeServerAction.mjs.map +1 -0
  471. package/dist/utils/validators/account.mjs +27 -0
  472. package/dist/utils/validators/account.mjs.map +1 -0
  473. package/dist/utils/validators/common.mjs +47 -0
  474. package/dist/utils/validators/common.mjs.map +1 -0
  475. package/dist/utils/withAction.mjs +13 -0
  476. package/dist/utils/withAction.mjs.map +1 -0
  477. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/actions/login.action.ts"],"sourcesContent":["\"use server\";\r\n\r\nimport { safeServerAction } from \"../../../utils/safeServerAction\";\r\nimport { authService } from \"../services/auth.service\";\r\nimport { LoginRequest } from \"../schema\";\r\nimport { getClientInfoFromRequest } from \"../../../infra/utils/client-info\";\r\n\r\nexport async function loginAction(credentials: LoginRequest) {\r\n return safeServerAction(async () => {\r\n const clientInfo = await getClientInfoFromRequest();\r\n return authService.login(credentials, clientInfo);\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAE5B,SAAS,gCAAgC;AAEzC,eAAsB,YAAY,aAA2B;AAC3D,SAAO,iBAAiB,YAAY;AAClC,UAAM,aAAa,MAAM,yBAAyB;AAClD,WAAO,YAAY,MAAM,aAAa,UAAU;AAAA,EAClD,CAAC;AACH;","names":[]}
@@ -0,0 +1,14 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
4
+ import { authService } from "../services/auth.service";
5
+ async function logoutAction() {
6
+ return safeServerAction(async () => {
7
+ const clientInfo = await getClientInfoFromRequest();
8
+ return authService.logout(clientInfo);
9
+ });
10
+ }
11
+ export {
12
+ logoutAction
13
+ };
14
+ //# sourceMappingURL=logout.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/actions/logout.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { safeServerAction } from '../../../utils/safeServerAction';\r\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\r\nimport { authService } from '../services/auth.service';\r\n\r\nexport async function logoutAction() {\r\n return safeServerAction(async () => {\r\n const clientInfo = await getClientInfoFromRequest();\r\n return authService.logout(clientInfo);\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,gCAAgC;AACzC,SAAS,mBAAmB;AAE5B,eAAsB,eAAe;AACnC,SAAO,iBAAiB,YAAY;AAClC,UAAM,aAAa,MAAM,yBAAyB;AAClD,WAAO,YAAY,OAAO,UAAU;AAAA,EACtC,CAAC;AACH;","names":[]}
@@ -0,0 +1,14 @@
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 registerAction(data) {
6
+ return safeServerAction(async () => {
7
+ const clientInfo = await getClientInfoFromRequest();
8
+ return authService.register(data, clientInfo);
9
+ });
10
+ }
11
+ export {
12
+ registerAction
13
+ };
14
+ //# sourceMappingURL=register.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/actions/register.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { safeServerAction } from '../../../utils/safeServerAction';\r\nimport { RegisterRequest } from '../schema';\r\nimport { authService } from '../services/auth.service';\r\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\r\n\r\nexport async function registerAction(data: RegisterRequest) {\r\n return safeServerAction(async () => {\r\n const clientInfo = await getClientInfoFromRequest();\r\n return authService.register(data, clientInfo);\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,wBAAwB;AAEjC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AAEzC,eAAsB,eAAe,MAAuB;AAC1D,SAAO,iBAAiB,YAAY;AAClC,UAAM,aAAa,MAAM,yBAAyB;AAClD,WAAO,YAAY,SAAS,MAAM,UAAU;AAAA,EAC9C,CAAC;AACH;","names":[]}
@@ -0,0 +1,48 @@
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
+ if (!referer) {
10
+ redirect("/login");
11
+ return;
12
+ }
13
+ const url = new URL(referer);
14
+ if (["/login", "/register", "/forgot-password"].includes(url.pathname)) {
15
+ return;
16
+ }
17
+ const loginUrl = new URL("/login", url.origin);
18
+ loginUrl.searchParams.set("redirect", url.pathname + url.search);
19
+ redirect(loginUrl.toString());
20
+ }
21
+ async function validateSessionAction() {
22
+ if (process.env.DUMMY_AUTH_TOKEN) return true;
23
+ const cookieStore = await cookies();
24
+ const cookie = cookieStore.get("greatapps")?.value;
25
+ if (!cookie) {
26
+ await redirectToLogin();
27
+ return false;
28
+ }
29
+ try {
30
+ const clientInfo = await getClientInfoFromRequest();
31
+ const isValid = await authService.validateSession(clientInfo);
32
+ if (!isValid) {
33
+ await authService.removeAuthCookie();
34
+ await redirectToLogin();
35
+ return false;
36
+ }
37
+ return true;
38
+ } catch (error) {
39
+ console.error("[validateSessionAction] Error:", error);
40
+ await authService.removeAuthCookie();
41
+ await redirectToLogin();
42
+ return false;
43
+ }
44
+ }
45
+ export {
46
+ validateSessionAction
47
+ };
48
+ //# sourceMappingURL=validate-session.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/actions/validate-session.action.ts"],"sourcesContent":["'use server';\n\nimport { redirect } from 'next/navigation';\nimport { cookies, headers } from 'next/headers';\nimport { authService } from '../services/auth.service';\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\n\nasync function redirectToLogin() {\n const h = await headers();\n const referer = h.get('referer');\n\n if (!referer) {\n redirect('/login');\n return;\n }\n\n const url = new URL(referer);\n\n if (['/login', '/register', '/forgot-password'].includes(url.pathname)) {\n return;\n }\n\n const loginUrl = new URL('/login', url.origin);\n loginUrl.searchParams.set('redirect', url.pathname + url.search);\n redirect(loginUrl.toString());\n}\n\nexport async function validateSessionAction(): Promise<boolean> {\n if (process.env.DUMMY_AUTH_TOKEN) return true;\n\n const cookieStore = await cookies();\n const cookie = cookieStore.get('greatapps')?.value;\n\n if (!cookie) {\n await redirectToLogin();\n return false;\n }\n\n try {\n const clientInfo = await getClientInfoFromRequest();\n const isValid = await authService.validateSession(clientInfo);\n\n if (!isValid) {\n await authService.removeAuthCookie();\n await redirectToLogin();\n return false;\n }\n\n return true;\n } catch (error) {\n console.error('[validateSessionAction] Error:', error);\n await authService.removeAuthCookie();\n await redirectToLogin();\n return false;\n }\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,SAAS,eAAe;AACjC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AAEzC,eAAe,kBAAkB;AAC/B,QAAM,IAAI,MAAM,QAAQ;AACxB,QAAM,UAAU,EAAE,IAAI,SAAS;AAE/B,MAAI,CAAC,SAAS;AACZ,aAAS,QAAQ;AACjB;AAAA,EACF;AAEA,QAAM,MAAM,IAAI,IAAI,OAAO;AAE3B,MAAI,CAAC,UAAU,aAAa,kBAAkB,EAAE,SAAS,IAAI,QAAQ,GAAG;AACtE;AAAA,EACF;AAEA,QAAM,WAAW,IAAI,IAAI,UAAU,IAAI,MAAM;AAC7C,WAAS,aAAa,IAAI,YAAY,IAAI,WAAW,IAAI,MAAM;AAC/D,WAAS,SAAS,SAAS,CAAC;AAC9B;AAEA,eAAsB,wBAA0C;AAC9D,MAAI,QAAQ,IAAI,iBAAkB,QAAO;AAEzC,QAAM,cAAc,MAAM,QAAQ;AAClC,QAAM,SAAS,YAAY,IAAI,WAAW,GAAG;AAE7C,MAAI,CAAC,QAAQ;AACX,UAAM,gBAAgB;AACtB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,aAAa,MAAM,yBAAyB;AAClD,UAAM,UAAU,MAAM,YAAY,gBAAgB,UAAU;AAE5D,QAAI,CAAC,SAAS;AACZ,YAAM,YAAY,iBAAiB;AACnC,YAAM,gBAAgB;AACtB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,kCAAkC,KAAK;AACrD,UAAM,YAAY,iBAAiB;AACnC,UAAM,gBAAgB;AACtB,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -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, window) {
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, window !== void 0 ? { window } : void 0);
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, window?: number) {\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, window !== undefined ? { window } : undefined);\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AAEzC,eAAsB,sBAAsB,QAAgB,MAAc,QAAiB;AACzF,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,YAAY,WAAW,SAAY,EAAE,OAAO,IAAI,MAAS;AAAA,EAC3G,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,41 @@
1
+ "use client";
2
+ import { UserProfile } from "../../users/schema";
3
+ import { useAuth } from "../../../providers/auth.provider";
4
+ function useManagementPermissions() {
5
+ const { user } = useAuth();
6
+ const profile = user?.profile;
7
+ const isAdmin = profile === UserProfile.admin;
8
+ const isOwner = profile === UserProfile.owner;
9
+ const isOwnerOrAdmin = isOwner || isAdmin;
10
+ const isViewer = profile === UserProfile.viewer;
11
+ const isCollaborator = profile === UserProfile.collaborator;
12
+ const canManage = !isViewer;
13
+ const hasPermission = (permission) => {
14
+ switch (permission) {
15
+ case "manage_pages":
16
+ case "manage_redirects":
17
+ case "manage_ab_tests":
18
+ case "restore_pages":
19
+ return !isViewer;
20
+ case "manage_domains":
21
+ case "manage_projects":
22
+ return isOwnerOrAdmin;
23
+ default:
24
+ return false;
25
+ }
26
+ };
27
+ return {
28
+ profile,
29
+ isAdmin,
30
+ isOwner,
31
+ isOwnerOrAdmin,
32
+ isViewer,
33
+ isCollaborator,
34
+ canManage,
35
+ hasPermission
36
+ };
37
+ }
38
+ export {
39
+ useManagementPermissions
40
+ };
41
+ //# sourceMappingURL=useManagementPermissions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/auth/hooks/useManagementPermissions.ts"],"sourcesContent":["'use client';\n\nimport { UserProfile } from '../../users/schema';\nimport { useAuth } from '../../../providers/auth.provider';\nimport type { ManagementPermission } from '../types/management-permission.type';\n\nexport { type ManagementPermission } from '../types/management-permission.type';\n\nexport function useManagementPermissions() {\n const { user } = useAuth();\n const profile = user?.profile;\n\n const isAdmin = profile === UserProfile.admin;\n const isOwner = profile === UserProfile.owner;\n const isOwnerOrAdmin = isOwner || isAdmin;\n const isViewer = profile === UserProfile.viewer;\n const isCollaborator = profile === UserProfile.collaborator;\n const canManage = !isViewer;\n\n const hasPermission = (permission: ManagementPermission) => {\n switch (permission) {\n case 'manage_pages':\n case 'manage_redirects':\n case 'manage_ab_tests':\n case 'restore_pages':\n return !isViewer;\n case 'manage_domains':\n case 'manage_projects':\n return isOwnerOrAdmin;\n default:\n return false;\n }\n };\n\n return {\n profile,\n isAdmin,\n isOwner,\n isOwnerOrAdmin,\n isViewer,\n isCollaborator,\n canManage,\n hasPermission,\n };\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AAKjB,SAAS,2BAA2B;AACzC,QAAM,EAAE,KAAK,IAAI,QAAQ;AACzB,QAAM,UAAU,MAAM;AAEtB,QAAM,UAAU,YAAY,YAAY;AACxC,QAAM,UAAU,YAAY,YAAY;AACxC,QAAM,iBAAiB,WAAW;AAClC,QAAM,WAAW,YAAY,YAAY;AACzC,QAAM,iBAAiB,YAAY,YAAY;AAC/C,QAAM,YAAY,CAAC;AAEnB,QAAM,gBAAgB,CAAC,eAAqC;AAC1D,YAAQ,YAAY;AAAA,MAClB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AACH,eAAO,CAAC;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","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, window }) => {
38
+ const { verifyTwoFactorAction } = await import("../actions/verify-two-factor.action");
39
+ return withAction(() => verifyTwoFactorAction(cookie, code, window))();
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, window }: { cookie: string; code: string; window?: number }) => {\r\n const { verifyTwoFactorAction } = await import('../actions/verify-two-factor.action');\r\n return withAction(() => verifyTwoFactorAction(cookie, code, window))();\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,MAAM,OAAO,MAAyD;AACjG,YAAM,EAAE,sBAAsB,IAAI,MAAM,OAAO,qCAAqC;AACpF,aAAO,WAAW,MAAM,sBAAsB,QAAQ,MAAM,MAAM,CAAC,EAAE;AAAA,IACvE;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,341 @@
1
+ import { cookies } from "next/headers";
2
+ import { api } from "../../../infra/api/client";
3
+ import { ApiError } from "../../../infra/api/types";
4
+ import { whitelabelService } from "../../whitelabel/services/whitelabel.service";
5
+ import { buildWlOverrideFromJwt } from "../utils/build-wl-override";
6
+ import { findWhitelabel } from "../../../server";
7
+ const AUTH_COOKIE_NAME = "greatapps";
8
+ const COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
9
+ const COOKIE_OPTIONS = {
10
+ httpOnly: true,
11
+ secure: process.env.NODE_ENV === "production",
12
+ sameSite: "lax",
13
+ path: "/"
14
+ };
15
+ class AuthService {
16
+ async login(credentials, clientInfo) {
17
+ let requestConfig;
18
+ if (credentials.id_wl) {
19
+ const wlToken = await whitelabelService.getTokenByWhitelabelId(
20
+ credentials.id_wl
21
+ );
22
+ requestConfig = { whiteLabelId: credentials.id_wl, authToken: wlToken };
23
+ }
24
+ const response = await api.apps.post(
25
+ "/auth/login",
26
+ {
27
+ email: credentials.email,
28
+ password: credentials.password,
29
+ source: credentials?.source,
30
+ location: clientInfo.location,
31
+ ip: clientInfo.ip,
32
+ timezone: clientInfo.timezone,
33
+ agent: clientInfo.agent
34
+ },
35
+ requestConfig
36
+ );
37
+ if (response.status === 0) {
38
+ throw new ApiError(
39
+ response.message || "E-mail ou senha incorretos",
40
+ response.code || "LOGIN_FAILED",
41
+ 401
42
+ );
43
+ }
44
+ if (!response.cookie) {
45
+ throw new ApiError(
46
+ "Resposta de autentica\xE7\xE3o inv\xE1lida",
47
+ "INVALID_RESPONSE",
48
+ 500
49
+ );
50
+ }
51
+ if (response.two_factor_required) {
52
+ return { result: "two_factor_required", cookie: response.cookie, twoFactorMode: response.two_factor_required };
53
+ }
54
+ await this.setAuthCookie(response.cookie);
55
+ const [{ userService }, { accountService }] = await Promise.all([
56
+ import("../../users/services/user.service"),
57
+ import("../../accounts/services/account.service")
58
+ ]);
59
+ const [user, account] = await Promise.all([
60
+ userService.findById(
61
+ requestConfig ? { authToken: requestConfig.authToken } : void 0
62
+ ),
63
+ accountService.findCurrentAccount(requestConfig)
64
+ ]);
65
+ return {
66
+ result: "success",
67
+ user,
68
+ account,
69
+ accessToken: response.cookie,
70
+ refreshToken: "",
71
+ expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1e3).toISOString()
72
+ };
73
+ }
74
+ async verifyTwoFactor(cookie, code, clientInfo, options) {
75
+ const payload = {
76
+ location: clientInfo.location,
77
+ ip: clientInfo.ip,
78
+ timezone: clientInfo.timezone,
79
+ agent: clientInfo.agent,
80
+ cookie,
81
+ code
82
+ };
83
+ const endpoint = options?.window !== void 0 ? `/auth/code?window=${options.window}` : "/auth/code";
84
+ const response = await api.apps.post(
85
+ endpoint,
86
+ payload
87
+ );
88
+ if (response.status === 0) {
89
+ throw new ApiError("C\xF3digo 2FA inv\xE1lido", "TWO_FACTOR_FAILED", 401);
90
+ }
91
+ if (!response?.data?.cookie) {
92
+ throw new ApiError(
93
+ "Resposta de autentica\xE7\xE3o inv\xE1lida ap\xF3s 2FA",
94
+ "INVALID_RESPONSE",
95
+ 500
96
+ );
97
+ }
98
+ await this.setAuthCookie(response.data.cookie);
99
+ return { status: 1 };
100
+ }
101
+ async register(data, clientInfo) {
102
+ const today = /* @__PURE__ */ new Date();
103
+ const trialEndDate = new Date(today);
104
+ trialEndDate.setDate(today.getDate() + 7);
105
+ const idPlan = await this.resolvePlanId(data.idPlan);
106
+ const payload = {
107
+ name: data.accountName,
108
+ bussiness_type: data.businessType ?? 0,
109
+ language: "pt-br",
110
+ timezone: "America/Sao_Paulo",
111
+ currency: "BRL",
112
+ location: clientInfo.location,
113
+ ip: clientInfo.ip,
114
+ agent: clientInfo.agent,
115
+ user: {
116
+ id_api: "",
117
+ name: data.name,
118
+ last_name: data.lastName || "",
119
+ rg: data.rg || "",
120
+ cpf: data.cpf || "",
121
+ gender: data.gender,
122
+ email: data.email,
123
+ phone: data.phone,
124
+ password: data.password,
125
+ profile: "owner",
126
+ language: "pt-br"
127
+ },
128
+ subscription: idPlan == -1 || idPlan == void 0 ? {
129
+ type: "free",
130
+ id_cupom: data.couponCode || "",
131
+ id_plan: 5,
132
+ // Plano Free (ID fixo)
133
+ id_product: 1
134
+ } : {
135
+ type: "trial",
136
+ id_cupom: data.couponCode || "",
137
+ id_plan: idPlan,
138
+ due_date: trialEndDate.toISOString().split("T")[0],
139
+ id_product: 1
140
+ }
141
+ };
142
+ const response = await api.apps.post(
143
+ "/accounts",
144
+ payload
145
+ );
146
+ if (response.status === 0) {
147
+ throw new ApiError(
148
+ response.message || "Erro ao criar conta",
149
+ "REGISTER_FAILED",
150
+ 400
151
+ );
152
+ }
153
+ if (!response.data || response.data.length === 0) {
154
+ throw new ApiError(
155
+ "Resposta de registro inv\xE1lida",
156
+ "INVALID_RESPONSE",
157
+ 500
158
+ );
159
+ }
160
+ if (!response.cookie) {
161
+ throw new ApiError(
162
+ "Resposta de autentica\xE7\xE3o inv\xE1lida",
163
+ "INVALID_RESPONSE",
164
+ 500
165
+ );
166
+ }
167
+ const accountData = response.data[0];
168
+ await this.setAuthCookie(response.cookie);
169
+ const [{ userService }, { accountService }] = await Promise.all([
170
+ import("../../users/services/user.service"),
171
+ import("../../accounts/services/account.service")
172
+ ]);
173
+ const [user, account] = await Promise.all([
174
+ userService.findById(),
175
+ accountService.findCurrentAccount()
176
+ ]);
177
+ return {
178
+ user,
179
+ account,
180
+ accessToken: response.cookie,
181
+ refreshToken: "",
182
+ expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1e3).toISOString(),
183
+ requiresEmailVerification: !accountData.verified
184
+ };
185
+ }
186
+ async logout(clientInfo) {
187
+ const cookie = await this.getToken();
188
+ if (!cookie) {
189
+ throw new ApiError(
190
+ "Usu\xE1rio n\xE3o autenticado",
191
+ "NOT_AUTHENTICATED_LOGOUT",
192
+ 401
193
+ );
194
+ }
195
+ const payload = {
196
+ location: clientInfo.location,
197
+ ip: clientInfo.ip,
198
+ timezone: clientInfo.timezone,
199
+ agent: clientInfo.agent,
200
+ cookie
201
+ };
202
+ try {
203
+ const response = await api.apps.post(
204
+ "/auth/logout",
205
+ payload
206
+ );
207
+ if (response.status === 0) {
208
+ throw new ApiError(
209
+ response.message || "Erro ao realizar logout",
210
+ response.code || "LOGOUT_FAILED",
211
+ 400
212
+ );
213
+ }
214
+ } finally {
215
+ await this.removeAuthCookie();
216
+ }
217
+ return {
218
+ success: true
219
+ };
220
+ }
221
+ async forgotPassword(_data) {
222
+ throw new ApiError(
223
+ "Recupera\xE7\xE3o de senha n\xE3o implementada",
224
+ "NOT_IMPLEMENTED",
225
+ 501
226
+ );
227
+ }
228
+ async resetPassword(_data) {
229
+ throw new ApiError(
230
+ "Redefini\xE7\xE3o de senha n\xE3o implementada",
231
+ "NOT_IMPLEMENTED",
232
+ 501
233
+ );
234
+ }
235
+ async verifyEmail(_data) {
236
+ throw new ApiError(
237
+ "Verifica\xE7\xE3o de email n\xE3o implementada",
238
+ "NOT_IMPLEMENTED",
239
+ 501
240
+ );
241
+ }
242
+ async resendVerification(_data) {
243
+ throw new ApiError(
244
+ "Reenvio de verifica\xE7\xE3o n\xE3o implementado",
245
+ "NOT_IMPLEMENTED",
246
+ 501
247
+ );
248
+ }
249
+ async validateSession(clientInfo) {
250
+ const cookie = await this.getToken();
251
+ if (!cookie) {
252
+ return false;
253
+ }
254
+ try {
255
+ const requestConfig = await buildWlOverrideFromJwt(cookie);
256
+ const payload = {
257
+ location: clientInfo.location,
258
+ ip: clientInfo.ip,
259
+ timezone: clientInfo.timezone,
260
+ agent: clientInfo.agent,
261
+ cookie
262
+ };
263
+ const response = await api.apps.post(
264
+ "/auth/keep",
265
+ payload,
266
+ requestConfig
267
+ );
268
+ return response.status === 1;
269
+ } catch (error) {
270
+ console.error("[AuthService] validateSession error", error);
271
+ return false;
272
+ }
273
+ }
274
+ async isAuthenticated() {
275
+ const token = await this.getToken();
276
+ return !!token;
277
+ }
278
+ async getToken() {
279
+ if (process.env.DUMMY_AUTH_TOKEN) return process.env.DUMMY_AUTH_TOKEN;
280
+ const cookieStore = await cookies();
281
+ return cookieStore.get(AUTH_COOKIE_NAME)?.value;
282
+ }
283
+ async resolvePlanId(idPlan) {
284
+ if (typeof idPlan === "number" || Number(idPlan)) return Number(idPlan);
285
+ if (typeof idPlan === "string") {
286
+ const response = await api.apps.get(
287
+ `/plans?search=${encodeURIComponent(idPlan)}`
288
+ );
289
+ if (response.status === 1 && response.data?.length) {
290
+ return response.data[0].id;
291
+ }
292
+ throw new ApiError(
293
+ `Plano "${idPlan}" n\xE3o encontrado`,
294
+ "PLAN_NOT_FOUND",
295
+ 404
296
+ );
297
+ }
298
+ return -1;
299
+ }
300
+ async setAuthCookie(token) {
301
+ const cookieStore = await cookies();
302
+ const whitelabel = await findWhitelabel().catch(() => null);
303
+ const cookieDomain = this.normalizeCookieDomain(whitelabel?.domain);
304
+ cookieStore.set(AUTH_COOKIE_NAME, token, {
305
+ ...COOKIE_OPTIONS,
306
+ ...cookieDomain ? { domain: cookieDomain } : {},
307
+ maxAge: COOKIE_MAX_AGE
308
+ });
309
+ }
310
+ async removeAuthCookie() {
311
+ const cookieStore = await cookies();
312
+ const whitelabel = await findWhitelabel().catch(() => null);
313
+ const cookieDomain = this.normalizeCookieDomain(whitelabel?.domain);
314
+ cookieStore.delete({
315
+ name: AUTH_COOKIE_NAME,
316
+ ...COOKIE_OPTIONS,
317
+ ...cookieDomain ? { domain: cookieDomain } : {}
318
+ });
319
+ }
320
+ normalizeCookieDomain(domain) {
321
+ if (!domain) return void 0;
322
+ const normalized = domain.trim();
323
+ if (!normalized) return void 0;
324
+ const rawHost = (() => {
325
+ try {
326
+ return new URL(normalized).hostname;
327
+ } catch {
328
+ return normalized.replace(/^https?:\/\//i, "").replace(/^www\./i, "").split("/")[0].split(":")[0];
329
+ }
330
+ })();
331
+ if (!rawHost || rawHost === "localhost") {
332
+ return void 0;
333
+ }
334
+ return rawHost.startsWith(".") ? rawHost : `.${rawHost}`;
335
+ }
336
+ }
337
+ const authService = new AuthService();
338
+ export {
339
+ authService
340
+ };
341
+ //# sourceMappingURL=auth.service.mjs.map