@pagamio/frontend-commons-lib 0.8.175 → 0.8.183
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.
- package/lib/api/client.d.ts +88 -0
- package/lib/api/client.js +339 -0
- package/lib/api/context.d.ts +112 -0
- package/lib/api/context.js +105 -0
- package/lib/api/index.d.ts +4 -0
- package/lib/api/index.js +4 -0
- package/lib/api/swr.d.ts +46 -0
- package/lib/api/swr.js +124 -0
- package/lib/api/types.d.ts +145 -0
- package/lib/api/types.js +10 -0
- package/lib/auth/authenticators/AuthenticatorFactory.d.ts +25 -0
- package/lib/auth/authenticators/AuthenticatorFactory.js +32 -0
- package/lib/auth/authenticators/index.d.ts +7 -0
- package/lib/auth/authenticators/index.js +7 -0
- package/lib/auth/authenticators/processors/DefaultAuthenticatorProcessor.d.ts +21 -0
- package/lib/auth/authenticators/processors/DefaultAuthenticatorProcessor.js +26 -0
- package/lib/auth/authenticators/processors/StrapiAuthenticatorProcessor.d.ts +74 -0
- package/lib/auth/authenticators/processors/StrapiAuthenticatorProcessor.js +99 -0
- package/lib/auth/authenticators/types.d.ts +26 -0
- package/lib/auth/authenticators/types.js +9 -0
- package/lib/auth/components/AppBanner.d.ts +7 -0
- package/lib/auth/components/AppBanner.js +9 -0
- package/lib/auth/components/AuthCard.d.ts +8 -0
- package/lib/auth/components/AuthCard.js +14 -0
- package/lib/auth/components/AuthFormUtils.d.ts +58 -0
- package/lib/auth/components/AuthFormUtils.js +52 -0
- package/lib/auth/components/AuthPageLayout.d.ts +45 -0
- package/lib/auth/components/AuthPageLayout.js +12 -0
- package/lib/auth/components/ChangePasswordPage.d.ts +12 -0
- package/lib/auth/components/ChangePasswordPage.js +59 -0
- package/lib/auth/components/CustomerRegistrationPage.d.ts +50 -0
- package/lib/auth/components/CustomerRegistrationPage.js +140 -0
- package/lib/auth/components/ForgotPasswordPage.d.ts +38 -0
- package/lib/auth/components/ForgotPasswordPage.js +76 -0
- package/lib/auth/components/LoginPage.d.ts +73 -0
- package/lib/auth/components/LoginPage.js +115 -0
- package/lib/auth/components/LogoutButton.d.ts +30 -0
- package/lib/auth/components/LogoutButton.js +47 -0
- package/lib/auth/components/ResetPasswordPage.d.ts +42 -0
- package/lib/auth/components/ResetPasswordPage.js +88 -0
- package/lib/auth/components/hooks/useChangeUserPassword.d.ts +26 -0
- package/lib/auth/components/hooks/useChangeUserPassword.js +63 -0
- package/lib/auth/components/index.d.ts +8 -0
- package/lib/auth/components/index.js +7 -0
- package/lib/auth/context/AuthContext.d.ts +65 -0
- package/lib/auth/context/AuthContext.js +150 -0
- package/lib/auth/context/index.d.ts +1 -0
- package/lib/auth/context/index.js +1 -0
- package/lib/auth/index.d.ts +7 -0
- package/lib/auth/index.js +7 -0
- package/lib/auth/services/AuthService.d.ts +230 -0
- package/lib/auth/services/AuthService.js +475 -0
- package/lib/auth/services/LogoutService.d.ts +27 -0
- package/lib/auth/services/LogoutService.js +98 -0
- package/lib/auth/services/index.d.ts +2 -0
- package/lib/auth/services/index.js +2 -0
- package/lib/auth/shared/index.d.ts +1 -0
- package/lib/auth/shared/index.js +1 -0
- package/lib/auth/shared/layout/AuthPageLayout.d.ts +10 -0
- package/lib/auth/shared/layout/AuthPageLayout.js +16 -0
- package/lib/auth/shared/layout/index.d.ts +1 -0
- package/lib/auth/shared/layout/index.js +1 -0
- package/lib/auth/types/auth.types.d.ts +234 -0
- package/lib/auth/types/auth.types.js +14 -0
- package/lib/auth/types/index.d.ts +1 -0
- package/lib/auth/types/index.js +1 -0
- package/lib/auth/utils/TokenManager.d.ts +43 -0
- package/lib/auth/utils/TokenManager.js +171 -0
- package/lib/auth/utils/Transformers.d.ts +158 -0
- package/lib/auth/utils/Transformers.js +263 -0
- package/lib/auth/utils/errorDetection.d.ts +22 -0
- package/lib/auth/utils/errorDetection.js +190 -0
- package/lib/auth/utils/index.d.ts +3 -0
- package/lib/auth/utils/index.js +3 -0
- package/lib/components/charts/LineGraph.d.ts +15 -0
- package/lib/components/charts/LineGraph.js +131 -0
- package/lib/components/icons/Icon.d.ts +8 -0
- package/lib/components/icons/Icon.js +13 -0
- package/lib/components/icons/index.d.ts +2 -0
- package/lib/components/icons/index.js +2 -0
- package/lib/components/icons/types.d.ts +26 -0
- package/lib/components/icons/types.js +33 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +3 -0
- package/lib/components/layout/AppLayout.d.ts +34 -0
- package/lib/components/layout/AppLayout.js +19 -0
- package/lib/components/layout/AuthPageLayout.d.ts +13 -0
- package/lib/components/layout/AuthPageLayout.js +15 -0
- package/lib/components/layout/BreadcrumbNav.d.ts +2 -0
- package/lib/components/layout/BreadcrumbNav.js +10 -0
- package/lib/components/layout/LayoutContent.d.ts +6 -0
- package/lib/components/layout/LayoutContent.js +10 -0
- package/lib/components/layout/Navbar.d.ts +106 -0
- package/lib/components/layout/Navbar.js +66 -0
- package/lib/components/layout/PageHeader.d.ts +8 -0
- package/lib/components/layout/PageHeader.js +7 -0
- package/lib/components/layout/SessionExpiryModal.d.ts +10 -0
- package/lib/components/layout/SessionExpiryModal.js +9 -0
- package/lib/components/layout/Sidebar.d.ts +6 -0
- package/lib/components/layout/Sidebar.js +87 -0
- package/lib/components/layout/VerticalTabsLayout.d.ts +12 -0
- package/lib/components/layout/VerticalTabsLayout.js +14 -0
- package/lib/components/layout/index.d.ts +9 -0
- package/lib/components/layout/index.js +9 -0
- package/lib/components/ui/Avatar.d.ts +6 -0
- package/lib/components/ui/Avatar.js +11 -0
- package/lib/components/ui/AvatarIcon.d.ts +4 -0
- package/lib/components/ui/AvatarIcon.js +6 -0
- package/lib/components/ui/Button.d.ts +14 -0
- package/lib/components/ui/Button.js +30 -0
- package/lib/components/ui/Calendar.d.ts +9 -0
- package/lib/components/ui/Calendar.js +35 -0
- package/lib/components/ui/Card.d.ts +16 -0
- package/lib/components/ui/Card.js +6 -0
- package/lib/components/ui/Chart.d.ts +2 -0
- package/lib/components/ui/Chart.js +16 -0
- package/lib/components/ui/Checkbox.d.ts +4 -0
- package/lib/components/ui/Checkbox.js +8 -0
- package/lib/components/ui/Command.d.ts +80 -0
- package/lib/components/ui/Command.js +28 -0
- package/lib/components/ui/ContainedTab.d.ts +21 -0
- package/lib/components/ui/ContainedTab.js +37 -0
- package/lib/components/ui/DateFormat.d.ts +6 -0
- package/lib/components/ui/DateFormat.js +8 -0
- package/lib/components/ui/DatePicker.d.ts +14 -0
- package/lib/components/ui/DatePicker.js +91 -0
- package/lib/components/ui/DateRangeModal.d.ts +38 -0
- package/lib/components/ui/DateRangeModal.js +89 -0
- package/lib/components/ui/DetailsCard.d.ts +16 -0
- package/lib/components/ui/DetailsCard.js +14 -0
- package/lib/components/ui/DetailsPage.d.ts +36 -0
- package/lib/components/ui/DetailsPage.js +50 -0
- package/lib/components/ui/Dialog.d.ts +19 -0
- package/lib/components/ui/Dialog.js +22 -0
- package/lib/components/ui/EmptyState.d.ts +6 -0
- package/lib/components/ui/EmptyState.js +6 -0
- package/lib/components/ui/FilterComponent.d.ts +30 -0
- package/lib/components/ui/FilterComponent.js +80 -0
- package/lib/components/ui/FilterList.d.ts +52 -0
- package/lib/components/ui/FilterList.js +62 -0
- package/lib/components/ui/FilterSection.d.ts +31 -0
- package/lib/components/ui/FilterSection.js +21 -0
- package/lib/components/ui/FilterWrapper.d.ts +6 -0
- package/lib/components/ui/FilterWrapper.js +7 -0
- package/lib/components/ui/Form.d.ts +23 -0
- package/lib/components/ui/Form.js +62 -0
- package/lib/components/ui/HoverableValue.d.ts +7 -0
- package/lib/components/ui/HoverableValue.js +8 -0
- package/lib/components/ui/IconButton.d.ts +10 -0
- package/lib/components/ui/IconButton.js +10 -0
- package/lib/components/ui/ImageComponent.d.ts +8 -0
- package/lib/components/ui/ImageComponent.js +5 -0
- package/lib/components/ui/ImageUploader.d.ts +17 -0
- package/lib/components/ui/ImageUploader.js +144 -0
- package/lib/components/ui/Input.d.ts +4 -0
- package/lib/components/ui/Input.js +8 -0
- package/lib/components/ui/Label.d.ts +5 -0
- package/lib/components/ui/Label.js +9 -0
- package/lib/components/ui/Loader.d.ts +10 -0
- package/lib/components/ui/Loader.js +7 -0
- package/lib/components/ui/Modal.d.ts +72 -0
- package/lib/components/ui/Modal.js +31 -0
- package/lib/components/ui/MultiSelect.d.ts +16 -0
- package/lib/components/ui/MultiSelect.js +59 -0
- package/lib/components/ui/NotificationModal.d.ts +18 -0
- package/lib/components/ui/NotificationModal.js +40 -0
- package/lib/components/ui/PhoneInput.d.ts +12 -0
- package/lib/components/ui/PhoneInput.js +58 -0
- package/lib/components/ui/Popover.d.ts +7 -0
- package/lib/components/ui/Popover.js +10 -0
- package/lib/components/ui/Progress.d.ts +7 -0
- package/lib/components/ui/Progress.js +7 -0
- package/lib/components/ui/Radio.d.ts +5 -0
- package/lib/components/ui/Radio.js +14 -0
- package/lib/components/ui/RangeDatePicker.d.ts +78 -0
- package/lib/components/ui/RangeDatePicker.js +68 -0
- package/lib/components/ui/Select.d.ts +13 -0
- package/lib/components/ui/Select.js +57 -0
- package/lib/components/ui/Separator.d.ts +4 -0
- package/lib/components/ui/Separator.js +7 -0
- package/lib/components/ui/Sheet.d.ts +26 -0
- package/lib/components/ui/Sheet.js +37 -0
- package/lib/components/ui/StatusCell.d.ts +9 -0
- package/lib/components/ui/StatusCell.js +6 -0
- package/lib/components/ui/Switch.d.ts +10 -0
- package/lib/components/ui/Switch.js +22 -0
- package/lib/components/ui/Tab.d.ts +15 -0
- package/lib/components/ui/Tab.js +13 -0
- package/lib/components/ui/TableDownload.d.ts +11 -0
- package/lib/components/ui/TableDownload.js +82 -0
- package/lib/components/ui/TailwindIndicator.d.ts +1 -0
- package/lib/components/ui/TailwindIndicator.js +6 -0
- package/lib/components/ui/TextField.d.ts +60 -0
- package/lib/components/ui/TextField.js +42 -0
- package/lib/components/ui/Textarea.d.ts +5 -0
- package/lib/components/ui/Textarea.js +8 -0
- package/lib/components/ui/Toast.d.ts +12 -0
- package/lib/components/ui/Toast.js +25 -0
- package/lib/components/ui/UploadField.d.ts +15 -0
- package/lib/components/ui/UploadField.js +45 -0
- package/lib/components/ui/VerticalTab.d.ts +16 -0
- package/lib/components/ui/VerticalTab.js +13 -0
- package/lib/components/ui/index.d.ts +49 -0
- package/lib/components/ui/index.js +47 -0
- package/lib/context/BreadcrumbContext.d.ts +28 -0
- package/lib/context/BreadcrumbContext.js +238 -0
- package/lib/context/FormEngineDrawerProvider.d.ts +21 -0
- package/lib/context/FormEngineDrawerProvider.js +38 -0
- package/lib/context/MultiFormEngineDrawerProvider.d.ts +25 -0
- package/lib/context/MultiFormEngineDrawerProvider.js +89 -0
- package/lib/context/SidebarContext.d.ts +65 -0
- package/lib/context/SidebarContext.js +47 -0
- package/lib/context/ToastContext.d.ts +17 -0
- package/lib/context/ToastContext.js +29 -0
- package/lib/context/index.d.ts +5 -0
- package/lib/context/index.js +5 -0
- package/lib/dashboard-visuals/components/BaseChart.d.ts +55 -0
- package/lib/dashboard-visuals/components/BaseChart.js +201 -0
- package/lib/dashboard-visuals/components/CardWrapper.d.ts +10 -0
- package/lib/dashboard-visuals/components/CardWrapper.js +13 -0
- package/lib/dashboard-visuals/components/ChartDetailsModal.d.ts +57 -0
- package/lib/dashboard-visuals/components/ChartDetailsModal.js +27 -0
- package/lib/dashboard-visuals/components/ChartDetailsModalWrapper.d.ts +29 -0
- package/lib/dashboard-visuals/components/ChartDetailsModalWrapper.js +4 -0
- package/lib/dashboard-visuals/components/ChartFormatter.d.ts +22 -0
- package/lib/dashboard-visuals/components/ChartFormatter.js +46 -0
- package/lib/dashboard-visuals/components/ChartWrapper.d.ts +11 -0
- package/lib/dashboard-visuals/components/ChartWrapper.js +14 -0
- package/lib/dashboard-visuals/components/DashboardFilter.d.ts +8 -0
- package/lib/dashboard-visuals/components/DashboardFilter.js +17 -0
- package/lib/dashboard-visuals/components/DataTable.d.ts +3 -0
- package/lib/dashboard-visuals/components/DataTable.js +57 -0
- package/lib/dashboard-visuals/components/EmptyState.d.ts +6 -0
- package/lib/dashboard-visuals/components/EmptyState.js +6 -0
- package/lib/dashboard-visuals/components/ErrorState.d.ts +7 -0
- package/lib/dashboard-visuals/components/ErrorState.js +5 -0
- package/lib/dashboard-visuals/components/FilterComponentSkeleton.d.ts +3 -0
- package/lib/dashboard-visuals/components/FilterComponentSkeleton.js +11 -0
- package/lib/dashboard-visuals/components/Pagination.d.ts +10 -0
- package/lib/dashboard-visuals/components/Pagination.js +7 -0
- package/lib/dashboard-visuals/components/Switch.d.ts +8 -0
- package/lib/dashboard-visuals/components/Switch.js +10 -0
- package/lib/dashboard-visuals/components/TileSkeleton.d.ts +2 -0
- package/lib/dashboard-visuals/components/TileSkeleton.js +5 -0
- package/lib/dashboard-visuals/components/molecules/Analytics.d.ts +11 -0
- package/lib/dashboard-visuals/components/molecules/Analytics.js +9 -0
- package/lib/dashboard-visuals/components/molecules/DataGrid.d.ts +15 -0
- package/lib/dashboard-visuals/components/molecules/DataGrid.js +124 -0
- package/lib/dashboard-visuals/components/molecules/NoChartData.d.ts +6 -0
- package/lib/dashboard-visuals/components/molecules/NoChartData.js +6 -0
- package/lib/dashboard-visuals/components/molecules/VisualChart.d.ts +16 -0
- package/lib/dashboard-visuals/components/molecules/VisualChart.js +8 -0
- package/lib/dashboard-visuals/components/types.d.ts +62 -0
- package/lib/dashboard-visuals/components/types.js +1 -0
- package/lib/dashboard-visuals/hooks/useChartData.d.ts +15 -0
- package/lib/dashboard-visuals/hooks/useChartData.js +82 -0
- package/lib/dashboard-visuals/hooks/useTooltipFormatter.d.ts +13 -0
- package/lib/dashboard-visuals/hooks/useTooltipFormatter.js +10 -0
- package/lib/dashboard-visuals/index.d.ts +39 -0
- package/lib/dashboard-visuals/index.js +168 -0
- package/lib/dashboard-visuals/types/index.d.ts +83 -0
- package/lib/dashboard-visuals/types/index.js +1 -0
- package/lib/dashboard-visuals/types/metricDetailData.d.ts +25 -0
- package/lib/dashboard-visuals/types/metricDetailData.js +1 -0
- package/lib/dashboard-visuals/utils/api.d.ts +5 -0
- package/lib/dashboard-visuals/utils/api.js +6 -0
- package/lib/dashboard-visuals/utils/chartOptions.d.ts +481 -0
- package/lib/dashboard-visuals/utils/chartOptions.js +393 -0
- package/lib/dashboard-visuals/utils/chunkArray.d.ts +1 -0
- package/lib/dashboard-visuals/utils/chunkArray.js +7 -0
- package/lib/dashboard-visuals/utils/defaultColors.d.ts +1 -0
- package/lib/dashboard-visuals/utils/defaultColors.js +1 -0
- package/lib/dashboard-visuals/utils/formatUtil.d.ts +203 -0
- package/lib/dashboard-visuals/utils/formatUtil.js +472 -0
- package/lib/dashboard-visuals/utils/gridUtil.d.ts +11 -0
- package/lib/dashboard-visuals/utils/gridUtil.js +32 -0
- package/lib/dashboard-visuals/utils/index.d.ts +6 -0
- package/lib/dashboard-visuals/utils/index.js +6 -0
- package/lib/dashboard-visuals/utils/tooltipUtils.d.ts +11 -0
- package/lib/dashboard-visuals/utils/tooltipUtils.js +180 -0
- package/lib/dashboard-visuals/visualRegistry.d.ts +4 -0
- package/lib/dashboard-visuals/visualRegistry.js +41 -0
- package/lib/dashboard-visuals/visuals/BarChart.d.ts +58 -0
- package/lib/dashboard-visuals/visuals/BarChart.js +95 -0
- package/lib/dashboard-visuals/visuals/BarLineHybridChart.d.ts +33 -0
- package/lib/dashboard-visuals/visuals/BarLineHybridChart.js +60 -0
- package/lib/dashboard-visuals/visuals/BubbleChart.d.ts +25 -0
- package/lib/dashboard-visuals/visuals/BubbleChart.js +101 -0
- package/lib/dashboard-visuals/visuals/DistributionChart.d.ts +11 -0
- package/lib/dashboard-visuals/visuals/DistributionChart.js +48 -0
- package/lib/dashboard-visuals/visuals/DonutChart.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/DonutChart.js +105 -0
- package/lib/dashboard-visuals/visuals/GaugeChart.d.ts +32 -0
- package/lib/dashboard-visuals/visuals/GaugeChart.js +53 -0
- package/lib/dashboard-visuals/visuals/GroupedBarChart.d.ts +47 -0
- package/lib/dashboard-visuals/visuals/GroupedBarChart.js +131 -0
- package/lib/dashboard-visuals/visuals/HeatmapChart.d.ts +79 -0
- package/lib/dashboard-visuals/visuals/HeatmapChart.js +146 -0
- package/lib/dashboard-visuals/visuals/HorizontalBarChart.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/HorizontalBarChart.js +131 -0
- package/lib/dashboard-visuals/visuals/ItemPerformanceCard.d.ts +30 -0
- package/lib/dashboard-visuals/visuals/ItemPerformanceCard.js +31 -0
- package/lib/dashboard-visuals/visuals/LineChart.d.ts +56 -0
- package/lib/dashboard-visuals/visuals/LineChart.js +80 -0
- package/lib/dashboard-visuals/visuals/LineGraph.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/LineGraph.js +189 -0
- package/lib/dashboard-visuals/visuals/MetricSummaryCard.d.ts +14 -0
- package/lib/dashboard-visuals/visuals/MetricSummaryCard.js +8 -0
- package/lib/dashboard-visuals/visuals/MultiGaugeChart.d.ts +39 -0
- package/lib/dashboard-visuals/visuals/MultiGaugeChart.js +119 -0
- package/lib/dashboard-visuals/visuals/PieChart.d.ts +59 -0
- package/lib/dashboard-visuals/visuals/PieChart.js +194 -0
- package/lib/dashboard-visuals/visuals/SelectedEventTile.d.ts +14 -0
- package/lib/dashboard-visuals/visuals/SelectedEventTile.js +35 -0
- package/lib/dashboard-visuals/visuals/SpeedometerChart.d.ts +53 -0
- package/lib/dashboard-visuals/visuals/SpeedometerChart.js +94 -0
- package/lib/dashboard-visuals/visuals/Table.d.ts +26 -0
- package/lib/dashboard-visuals/visuals/Table.js +113 -0
- package/lib/dashboard-visuals/visuals/Tile.d.ts +16 -0
- package/lib/dashboard-visuals/visuals/Tile.js +16 -0
- package/lib/dashboard-visuals/visuals/TreeMap.d.ts +25 -0
- package/lib/dashboard-visuals/visuals/TreeMap.js +45 -0
- package/lib/dashboard-visuals/visuals/WaterfallChart.d.ts +52 -0
- package/lib/dashboard-visuals/visuals/WaterfallChart.js +266 -0
- package/lib/form-engine/Form.d.ts +4 -0
- package/lib/form-engine/Form.js +14 -0
- package/lib/form-engine/FormEngine.d.ts +3 -0
- package/lib/form-engine/FormEngine.js +121 -0
- package/lib/form-engine/components/FieldWrapper.d.ts +18 -0
- package/lib/form-engine/components/FieldWrapper.js +63 -0
- package/lib/form-engine/components/index.d.ts +2 -0
- package/lib/form-engine/components/index.js +2 -0
- package/lib/form-engine/components/inputs/card-expiry-input/CardExpiryInput.d.ts +16 -0
- package/lib/form-engine/components/inputs/card-expiry-input/CardExpiryInput.js +48 -0
- package/lib/form-engine/components/inputs/checkbox-input/CheckboxInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/checkbox-input/CheckboxInput.js +5 -0
- package/lib/form-engine/components/inputs/credit-card-input/CreditCardInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/credit-card-input/CreditCardInput.js +82 -0
- package/lib/form-engine/components/inputs/date-input/DateInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/date-input/DateInput.js +7 -0
- package/lib/form-engine/components/inputs/date-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/date-input/index.js +1 -0
- package/lib/form-engine/components/inputs/email-input/EmailInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/email-input/EmailInput.js +5 -0
- package/lib/form-engine/components/inputs/email-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/email-input/index.js +1 -0
- package/lib/form-engine/components/inputs/index.d.ts +13 -0
- package/lib/form-engine/components/inputs/index.js +13 -0
- package/lib/form-engine/components/inputs/label-input/LabelInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/label-input/LabelInput.js +7 -0
- package/lib/form-engine/components/inputs/label-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/label-input/index.js +1 -0
- package/lib/form-engine/components/inputs/multi-select-input/MultiSelectInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/multi-select-input/MultiSelectInput.js +5 -0
- package/lib/form-engine/components/inputs/number-input/NumberInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/number-input/NumberInput.js +5 -0
- package/lib/form-engine/components/inputs/number-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/number-input/index.js +1 -0
- package/lib/form-engine/components/inputs/password-input/PasswordInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/password-input/PasswordInput.js +9 -0
- package/lib/form-engine/components/inputs/password-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/password-input/index.js +1 -0
- package/lib/form-engine/components/inputs/radio-button/RadioInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/radio-button/RadioInput.js +6 -0
- package/lib/form-engine/components/inputs/radio-button/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/radio-button/index.js +1 -0
- package/lib/form-engine/components/inputs/select/SelectInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/select/SelectInput.js +6 -0
- package/lib/form-engine/components/inputs/select/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/select/index.js +1 -0
- package/lib/form-engine/components/inputs/textarea-input/TextareaInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/textarea-input/TextareaInput.js +5 -0
- package/lib/form-engine/components/inputs/textarea-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/textarea-input/index.js +1 -0
- package/lib/form-engine/components/inputs/time-input/TimeInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/time-input/TimeInput.js +5 -0
- package/lib/form-engine/components/inputs/time-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/time-input/index.js +1 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/ToggleSwitchInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/ToggleSwitchInput.js +7 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/index.js +1 -0
- package/lib/form-engine/components/inputs/upload-field/UploadFieldForm.d.ts +4 -0
- package/lib/form-engine/components/inputs/upload-field/UploadFieldForm.js +59 -0
- package/lib/form-engine/components/inputs/upload-field/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/upload-field/index.js +1 -0
- package/lib/form-engine/hooks/useFormPersistence.d.ts +11 -0
- package/lib/form-engine/hooks/useFormPersistence.js +46 -0
- package/lib/form-engine/index.d.ts +5 -0
- package/lib/form-engine/index.js +5 -0
- package/lib/form-engine/registry/RegisterComponents.d.ts +1 -0
- package/lib/form-engine/registry/RegisterComponents.js +35 -0
- package/lib/form-engine/registry/Registry.d.ts +5 -0
- package/lib/form-engine/registry/Registry.js +13 -0
- package/lib/form-engine/registry/index.d.ts +2 -0
- package/lib/form-engine/registry/index.js +2 -0
- package/lib/form-engine/types/index.d.ts +311 -0
- package/lib/form-engine/types/index.js +1 -0
- package/lib/helpers/index.d.ts +2 -0
- package/lib/helpers/index.js +2 -0
- package/lib/helpers/utils.d.ts +37 -0
- package/lib/helpers/utils.js +77 -0
- package/lib/helpers/validations.d.ts +80 -0
- package/lib/helpers/validations.js +39 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +30 -0
- package/lib/mocks/mockApiRequestsConfig.d.ts +2 -0
- package/lib/mocks/mockApiRequestsConfig.js +343 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/TopUpWalletContent.d.ts +14 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/TopUpWalletContent.js +40 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/index.d.ts +11 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/index.js +7 -0
- package/lib/pagamio-drawer/components/BaseDrawer.d.ts +11 -0
- package/lib/pagamio-drawer/components/BaseDrawer.js +10 -0
- package/lib/pagamio-drawer/components/DrawerContent.d.ts +27 -0
- package/lib/pagamio-drawer/components/DrawerContent.js +237 -0
- package/lib/pagamio-drawer/index.d.ts +22 -0
- package/lib/pagamio-drawer/index.js +133 -0
- package/lib/pagamio-table/data-table/ExportButton.d.ts +57 -0
- package/lib/pagamio-table/data-table/ExportButton.js +96 -0
- package/lib/pagamio-table/data-table/MantineCoreTable.d.ts +44 -0
- package/lib/pagamio-table/data-table/MantineCoreTable.js +129 -0
- package/lib/pagamio-table/data-table/Pagination.d.ts +10 -0
- package/lib/pagamio-table/data-table/Pagination.js +5 -0
- package/lib/pagamio-table/data-table/TableDownload.d.ts +8 -0
- package/lib/pagamio-table/data-table/TableDownload.js +81 -0
- package/lib/pagamio-table/data-table/TableToolbar.d.ts +3 -0
- package/lib/pagamio-table/data-table/TableToolbar.js +16 -0
- package/lib/pagamio-table/data-table/exportUtils.d.ts +42 -0
- package/lib/pagamio-table/data-table/exportUtils.js +782 -0
- package/lib/pagamio-table/data-table/index.d.ts +5 -0
- package/lib/pagamio-table/data-table/index.js +11 -0
- package/lib/pagamio-table/data-table/pdfExportUtils.d.ts +111 -0
- package/lib/pagamio-table/data-table/pdfExportUtils.js +113 -0
- package/lib/pagamio-table/data-table/types.d.ts +169 -0
- package/lib/pagamio-table/data-table/types.js +1 -0
- package/lib/pagamio-table/index.d.ts +4 -0
- package/lib/pagamio-table/index.js +4 -0
- package/lib/pagamio-table/utils/functionHelper.d.ts +12 -0
- package/lib/pagamio-table/utils/functionHelper.js +24 -0
- package/lib/pagamio-table/utils/index.d.ts +1 -0
- package/lib/pagamio-table/utils/index.js +1 -0
- package/lib/rbac/hooks.d.ts +39 -0
- package/lib/rbac/hooks.js +51 -0
- package/lib/rbac/index.d.ts +8 -0
- package/lib/rbac/index.js +11 -0
- package/lib/rbac/store.d.ts +24 -0
- package/lib/rbac/store.js +37 -0
- package/lib/rbac/types.d.ts +39 -0
- package/lib/rbac/types.js +4 -0
- package/lib/rbac/utils.d.ts +44 -0
- package/lib/rbac/utils.js +117 -0
- package/lib/shared/constants/index.d.ts +2 -0
- package/lib/shared/constants/index.js +2 -0
- package/lib/shared/hooks/index.d.ts +4 -0
- package/lib/shared/hooks/index.js +4 -0
- package/lib/shared/hooks/useAnyDrawerOpen.d.ts +4 -0
- package/lib/shared/hooks/useAnyDrawerOpen.js +18 -0
- package/lib/shared/hooks/useContainerWidth.d.ts +2 -0
- package/lib/shared/hooks/useContainerWidth.js +18 -0
- package/lib/shared/hooks/useImageUpload.d.ts +15 -0
- package/lib/shared/hooks/useImageUpload.js +66 -0
- package/lib/shared/hooks/useMediaQueries.d.ts +5 -0
- package/lib/shared/hooks/useMediaQueries.js +35 -0
- package/lib/shared/hooks/usePagamioTable.d.ts +158 -0
- package/lib/shared/hooks/usePagamioTable.js +475 -0
- package/lib/shared/hooks/useSessionTimer.d.ts +33 -0
- package/lib/shared/hooks/useSessionTimer.js +96 -0
- package/lib/shared/index.d.ts +4 -0
- package/lib/shared/index.js +4 -0
- package/lib/shared/types/index.d.ts +1 -0
- package/lib/shared/types/index.js +1 -0
- package/lib/shared/url/index.d.ts +9 -0
- package/lib/shared/url/index.js +20 -0
- package/lib/shared/utils/filterUtils.d.ts +5 -0
- package/lib/shared/utils/filterUtils.js +31 -0
- package/lib/shared/utils/functionHelper.d.ts +27 -0
- package/lib/shared/utils/functionHelper.js +124 -0
- package/lib/shared/utils/index.d.ts +2 -0
- package/lib/shared/utils/index.js +2 -0
- package/lib/shared/utils/localStorage.d.ts +53 -0
- package/lib/shared/utils/localStorage.js +139 -0
- package/lib/styles.css +6247 -0
- package/lib/translations/components/LocaleSwitcher.d.ts +7 -0
- package/lib/translations/components/LocaleSwitcher.js +18 -0
- package/lib/translations/components/index.d.ts +1 -0
- package/lib/translations/components/index.js +1 -0
- package/lib/translations/context/TranslationContext.d.ts +5 -0
- package/lib/translations/context/TranslationContext.js +151 -0
- package/lib/translations/context/index.d.ts +1 -0
- package/lib/translations/context/index.js +1 -0
- package/lib/translations/hooks/index.d.ts +2 -0
- package/lib/translations/hooks/index.js +2 -0
- package/lib/translations/hooks/useLibTranslations.d.ts +7 -0
- package/lib/translations/hooks/useLibTranslations.js +46 -0
- package/lib/translations/hooks/useTranslation.d.ts +7 -0
- package/lib/translations/hooks/useTranslation.js +11 -0
- package/lib/translations/index.d.ts +91 -0
- package/lib/translations/index.js +11 -0
- package/lib/translations/locales/en.json +21 -0
- package/lib/translations/locales/es.json +21 -0
- package/lib/translations/locales/fr.json +21 -0
- package/lib/translations/locales/pt.json +21 -0
- package/lib/translations/types/index.d.ts +24 -0
- package/lib/translations/types/index.js +1 -0
- package/lib/translations/utils/index.d.ts +6 -0
- package/lib/translations/utils/index.js +25 -0
- package/package.json +9 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface LogoutOptions {
|
|
2
|
+
clearStorage?: boolean;
|
|
3
|
+
invalidateSession?: boolean;
|
|
4
|
+
onLogoutSuccess?: () => void;
|
|
5
|
+
onLogoutError?: (error: Error) => void;
|
|
6
|
+
logoutEndpoint?: string;
|
|
7
|
+
storageKeys?: string[];
|
|
8
|
+
customCleanup?: () => Promise<void> | void;
|
|
9
|
+
}
|
|
10
|
+
interface LogoutServiceConfig {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
refreshEndpoint: string;
|
|
13
|
+
logoutEndpoint?: string;
|
|
14
|
+
storageKeys?: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare class LogoutService {
|
|
17
|
+
private readonly tokenManager;
|
|
18
|
+
private readonly options;
|
|
19
|
+
private readonly baseUrl;
|
|
20
|
+
constructor(config: LogoutServiceConfig);
|
|
21
|
+
logout(options?: Partial<LogoutOptions>): Promise<boolean>;
|
|
22
|
+
private invalidateServerSession;
|
|
23
|
+
private clearBrowserCache;
|
|
24
|
+
}
|
|
25
|
+
declare const createLogoutService: (config: LogoutServiceConfig) => LogoutService;
|
|
26
|
+
export { createLogoutService };
|
|
27
|
+
export type { LogoutOptions, LogoutServiceConfig };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Logout service that handles cleanup operations during user logout
|
|
3
|
+
*/
|
|
4
|
+
import { removeLocalStorageItems } from '../../shared';
|
|
5
|
+
import { TokenManager } from '../utils';
|
|
6
|
+
const defaultLogoutOptions = {
|
|
7
|
+
clearStorage: true,
|
|
8
|
+
invalidateSession: true,
|
|
9
|
+
logoutEndpoint: '/api/auth/logout',
|
|
10
|
+
storageKeys: ['user', 'rememberMe'],
|
|
11
|
+
};
|
|
12
|
+
export class LogoutService {
|
|
13
|
+
tokenManager;
|
|
14
|
+
options;
|
|
15
|
+
baseUrl;
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.baseUrl = config.baseUrl;
|
|
18
|
+
this.tokenManager = new TokenManager({
|
|
19
|
+
baseUrl: this.baseUrl,
|
|
20
|
+
refreshEndpoint: '/auth/refresh', // Default refresh endpoint
|
|
21
|
+
});
|
|
22
|
+
this.options = {
|
|
23
|
+
...defaultLogoutOptions,
|
|
24
|
+
logoutEndpoint: config.logoutEndpoint ?? defaultLogoutOptions.logoutEndpoint,
|
|
25
|
+
storageKeys: config.storageKeys ?? defaultLogoutOptions.storageKeys,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async logout(options) {
|
|
29
|
+
const currentOptions = { ...this.options, ...options };
|
|
30
|
+
const { clearStorage, invalidateSession, logoutEndpoint, storageKeys, onLogoutSuccess, onLogoutError, customCleanup, } = currentOptions;
|
|
31
|
+
try {
|
|
32
|
+
const cleanupTasks = [];
|
|
33
|
+
// Clear tokens
|
|
34
|
+
this.tokenManager.clearAllTokens();
|
|
35
|
+
// Clear localStorage
|
|
36
|
+
if (clearStorage && storageKeys?.length) {
|
|
37
|
+
removeLocalStorageItems(storageKeys);
|
|
38
|
+
}
|
|
39
|
+
// Invalidate server session
|
|
40
|
+
if (invalidateSession && logoutEndpoint) {
|
|
41
|
+
const { token } = this.tokenManager.getAccessToken();
|
|
42
|
+
if (token) {
|
|
43
|
+
cleanupTasks.push(this.invalidateServerSession(logoutEndpoint, token));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Run custom cleanup if provided
|
|
47
|
+
if (customCleanup) {
|
|
48
|
+
const cleanup = customCleanup();
|
|
49
|
+
if (cleanup instanceof Promise) {
|
|
50
|
+
cleanupTasks.push(cleanup);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Clear browser cache
|
|
54
|
+
cleanupTasks.push(this.clearBrowserCache());
|
|
55
|
+
await Promise.all(cleanupTasks);
|
|
56
|
+
onLogoutSuccess?.();
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const logoutError = error instanceof Error ? error : new Error('Logout failed');
|
|
61
|
+
onLogoutError?.(logoutError);
|
|
62
|
+
throw logoutError;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async invalidateServerSession(endpoint, token) {
|
|
66
|
+
const fullEndpoint = endpoint.startsWith('http') ? endpoint : `${this.baseUrl}${endpoint}`;
|
|
67
|
+
const response = await fetch(fullEndpoint, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: {
|
|
70
|
+
Authorization: `Bearer ${token}`,
|
|
71
|
+
'Content-Type': 'application/json',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
throw new Error(`Failed to invalidate session: ${response.statusText}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async clearBrowserCache() {
|
|
79
|
+
if (typeof window === 'undefined')
|
|
80
|
+
return;
|
|
81
|
+
// Clear service worker registrations
|
|
82
|
+
if ('serviceWorker' in navigator) {
|
|
83
|
+
const registrations = await navigator.serviceWorker.getRegistrations();
|
|
84
|
+
await Promise.all(registrations.map((registration) => registration.unregister()));
|
|
85
|
+
}
|
|
86
|
+
// Clear browser cache
|
|
87
|
+
if ('caches' in window) {
|
|
88
|
+
const keys = await caches.keys();
|
|
89
|
+
await Promise.all(keys.map((key) => caches.delete(key)));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Create default instance with baseUrl from window.location.origin
|
|
94
|
+
const createLogoutService = (config) => {
|
|
95
|
+
return new LogoutService(config);
|
|
96
|
+
};
|
|
97
|
+
// Export the create function and types
|
|
98
|
+
export { createLogoutService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './layout';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './layout';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface AuthPageLayoutProps {
|
|
2
|
+
title: string;
|
|
3
|
+
subtitle: string;
|
|
4
|
+
errorMessage: string | null;
|
|
5
|
+
showLogo?: boolean;
|
|
6
|
+
renderInAppLayout?: boolean;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare const AuthPageLayout: React.FC<AuthPageLayoutProps>;
|
|
10
|
+
export default AuthPageLayout;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Card } from 'flowbite-react';
|
|
4
|
+
const AuthPageLayout = ({ title, subtitle, errorMessage, showLogo = true, renderInAppLayout = false, children, }) => {
|
|
5
|
+
return (_jsxs("div", { className: `mx-auto flex w-full max-w-[640px] flex-col items-center justify-center px-4 py-8 sm:px-6 ${renderInAppLayout ? 'h-[calc(100vh-64px)]' : 'min-h-screen md:h-screen'}`, children: [showLogo && (_jsx("img", { alt: "Pagamio Logo", src: "/images/pagamio-full-colored-logo.svg", width: 280, height: 250, className: "mb-[2.5em]" })), _jsxs(Card, { horizontal: true, className: "w-full p-2 sm:p-3", theme: {
|
|
6
|
+
root: {
|
|
7
|
+
children: 'my-auto w-full gap-0 space-y-6 p-4 sm:p-6 lg:p-12',
|
|
8
|
+
},
|
|
9
|
+
img: {
|
|
10
|
+
horizontal: {
|
|
11
|
+
on: 'hidden w-2/3 rounded-l-lg md:w-96 md:p-0 lg:block',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
}, children: [_jsxs("div", { className: "space-y-2", children: [_jsx("h2", { className: "text-[1.5em] sm:text-[1.875em] font-bold text-gray-900 dark:text-white", children: title }), _jsx("p", { className: "text-[1em] font-medium text-gray-600 dark:text-white", children: subtitle })] }), errorMessage && (_jsx("div", { className: "mt-4 rounded border border-red-400 bg-red-100 p-2 text-red-700", children: errorMessage })), children] })] }));
|
|
15
|
+
};
|
|
16
|
+
export default AuthPageLayout;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AuthLayout } from './AuthPageLayout';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AuthLayout } from './AuthPageLayout';
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Core type definitions for the authentication system.
|
|
3
|
+
* This file contains all the base types and interfaces that can be extended
|
|
4
|
+
* for specific authentication implementations.
|
|
5
|
+
*/
|
|
6
|
+
declare enum RoleNameProps {
|
|
7
|
+
ROLE_ADMIN = "ROLE_ADMIN",
|
|
8
|
+
ROLE_VENDOR = "ROLE_VENDOR",
|
|
9
|
+
ROLE_MERCHANT = "ROLE_MERCHANT",
|
|
10
|
+
ROLE_PROMOTER = "ROLE_PROMOTER",
|
|
11
|
+
ROLE_ARTIST = "ROLE_ARTIST"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generic token structure containing essential token information
|
|
15
|
+
*/
|
|
16
|
+
export interface BaseTokenInfo {
|
|
17
|
+
token: string;
|
|
18
|
+
expiresIn: number;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generic user properties that should be present in all implementations
|
|
23
|
+
*/
|
|
24
|
+
export interface BaseUserInfo {
|
|
25
|
+
id: number | string;
|
|
26
|
+
userName: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generic authentication credentials interface
|
|
31
|
+
* Can be extended to include specific credential requirements
|
|
32
|
+
*/
|
|
33
|
+
export interface BaseAuthCredentials {
|
|
34
|
+
username?: string;
|
|
35
|
+
password?: string;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Core authentication state interface
|
|
40
|
+
*/
|
|
41
|
+
export interface BaseAuthState {
|
|
42
|
+
isAuthenticated: boolean;
|
|
43
|
+
isLoading: boolean;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generic error structure for authentication errors
|
|
48
|
+
*/
|
|
49
|
+
export interface BaseAuthError {
|
|
50
|
+
code: string;
|
|
51
|
+
message: string;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Customizable type generator for specific authentication implementations
|
|
56
|
+
* @template TRole - Role type extending BaseRole
|
|
57
|
+
* @template TPermission - Permission type extending BasePermission
|
|
58
|
+
* @template TPermission - Permission type extending string
|
|
59
|
+
* @template TErrorCode - Error code type extending string
|
|
60
|
+
* @template TTokenInfo - Token info type extending BaseTokenInfo
|
|
61
|
+
* @template TCredentials - Credentials type extending BaseAuthCredentials
|
|
62
|
+
* @template TError - Error type extending BaseAuthError
|
|
63
|
+
*/
|
|
64
|
+
export type CustomAuthConfig<TRole extends string = string, TPermission extends string = string, TErrorCode extends string = string, TUserInfo extends BaseUserInfo = BaseUserInfo, TTokenInfo extends BaseTokenInfo = BaseTokenInfo, TCredentials extends BaseAuthCredentials = BaseAuthCredentials, TError extends BaseAuthError = BaseAuthError> = {
|
|
65
|
+
UserInfo: TUserInfo;
|
|
66
|
+
TokenInfo: TTokenInfo;
|
|
67
|
+
Credentials: TCredentials;
|
|
68
|
+
Error: TError;
|
|
69
|
+
Role: TRole;
|
|
70
|
+
Permission: TPermission;
|
|
71
|
+
ErrorCode: TErrorCode;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Type generator for authentication response
|
|
75
|
+
* @template T - CustomAuthConfig type
|
|
76
|
+
*/
|
|
77
|
+
export type AuthResponse<T extends CustomAuthConfig> = {
|
|
78
|
+
user: T['UserInfo'];
|
|
79
|
+
auth: {
|
|
80
|
+
accessToken: T['TokenInfo'];
|
|
81
|
+
refreshToken?: T['TokenInfo'];
|
|
82
|
+
};
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
};
|
|
85
|
+
export type ExtractUserInfo<T extends CustomAuthConfig> = T['UserInfo'];
|
|
86
|
+
export type ExtractAuthError<T extends CustomAuthConfig> = T['Error'];
|
|
87
|
+
export type PartialAuthConfig<T extends CustomAuthConfig> = {
|
|
88
|
+
[K in keyof T]?: Partial<T[K]>;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Generic transformer interface for handling different authentication API response formats.
|
|
92
|
+
* Implements the Strategy pattern to allow multiple response format handlers.
|
|
93
|
+
*
|
|
94
|
+
* @template T - Type extending CustomAuthConfig that defines the shape of user info, token info, and credentials
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* class MyApiTransformer implements ApiResponseTransformer<MyAuthConfig> {
|
|
99
|
+
* canHandle(response: any): boolean {
|
|
100
|
+
* return response.hasOwnProperty('mySpecificField');
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* transform(response: any): AuthResponse<MyAuthConfig> {
|
|
104
|
+
* // Transform API response to AuthResponse format
|
|
105
|
+
* return {
|
|
106
|
+
* user: { ... },
|
|
107
|
+
* auth: { ... }
|
|
108
|
+
* };
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export interface ApiResponseTransformer<T extends CustomAuthConfig> {
|
|
114
|
+
/**
|
|
115
|
+
* Transforms raw API response into standardized AuthResponse format
|
|
116
|
+
* @param response - Raw API response data
|
|
117
|
+
* @param remember
|
|
118
|
+
* @returns Standardized auth response matching the generic type T
|
|
119
|
+
*/
|
|
120
|
+
transform(response: any, remember?: boolean): AuthResponse<T>;
|
|
121
|
+
/**
|
|
122
|
+
* Determines if this transformer can handle the given response format
|
|
123
|
+
* @param response - Raw API response data to check
|
|
124
|
+
* @returns True if this transformer can handle the response format
|
|
125
|
+
*/
|
|
126
|
+
canHandle(response: any): boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Authentication configuration for the Events application.
|
|
130
|
+
* Defines the structure of user information, token data, and login credentials
|
|
131
|
+
* specific to the Events app authentication flow.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const authService = createAuthService<EventsAppAuthConfig>({
|
|
136
|
+
* baseUrl: 'https://api.events.example.com',
|
|
137
|
+
* endpoints: {
|
|
138
|
+
* login: '/auth/login',
|
|
139
|
+
* // ...other endpoints
|
|
140
|
+
* }
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export interface EventsAppAuthConfig extends CustomAuthConfig {
|
|
145
|
+
/** User information structure for Events app */
|
|
146
|
+
UserInfo: {
|
|
147
|
+
/** Unique identifier for the user */
|
|
148
|
+
id: string;
|
|
149
|
+
/** Username used for authentication */
|
|
150
|
+
userName: string;
|
|
151
|
+
/** User's first name */
|
|
152
|
+
firstName: string;
|
|
153
|
+
/** User's last name */
|
|
154
|
+
lastName: string;
|
|
155
|
+
/** Array of role identifiers assigned to the user */
|
|
156
|
+
roles: string[];
|
|
157
|
+
/** Primary role name */
|
|
158
|
+
roleName: RoleNameProps;
|
|
159
|
+
/** Description of the user's role */
|
|
160
|
+
roleDesc: string;
|
|
161
|
+
/** Associated vendor identifier */
|
|
162
|
+
vendorId: number;
|
|
163
|
+
/** Optional promoter identifier */
|
|
164
|
+
promoterId: number | null;
|
|
165
|
+
/** Company name associated with the user */
|
|
166
|
+
company: string;
|
|
167
|
+
/** IQ Retail access flag */
|
|
168
|
+
hasIQRetailAccess?: boolean;
|
|
169
|
+
};
|
|
170
|
+
/** Token information structure */
|
|
171
|
+
TokenInfo: {
|
|
172
|
+
/** JWT or other authentication token */
|
|
173
|
+
token: string;
|
|
174
|
+
/** Token expiration time in seconds */
|
|
175
|
+
expiresIn: number;
|
|
176
|
+
};
|
|
177
|
+
/** Login credentials structure */
|
|
178
|
+
Credentials: {
|
|
179
|
+
/** Username for authentication */
|
|
180
|
+
username: string;
|
|
181
|
+
/** User's password */
|
|
182
|
+
password: string;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Authentication configuration for the VAS (Value Added Services) application.
|
|
187
|
+
* Defines the structure of user information, token data, and login credentials
|
|
188
|
+
* specific to the VAS app authentication flow.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* const authService = createAuthService<VasAppAuthConfig>({
|
|
193
|
+
* baseUrl: 'https://api.vas.example.com',
|
|
194
|
+
* endpoints: {
|
|
195
|
+
* login: '/auth/login',
|
|
196
|
+
* // ...other endpoints
|
|
197
|
+
* }
|
|
198
|
+
* });
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
export interface VasAppAuthConfig extends CustomAuthConfig {
|
|
202
|
+
/** User information structure for VAS app */
|
|
203
|
+
UserInfo: {
|
|
204
|
+
/** Numeric user identifier */
|
|
205
|
+
id: number;
|
|
206
|
+
/** Username used for authentication */
|
|
207
|
+
userName: string;
|
|
208
|
+
/** Array of role identifiers assigned to the user */
|
|
209
|
+
roles: string[];
|
|
210
|
+
/** Secondary user identifier */
|
|
211
|
+
userId: number;
|
|
212
|
+
/** User type (e.g., PARTNER_USER, VENDOR_USER) */
|
|
213
|
+
userType: string;
|
|
214
|
+
/** User type identifier from backend */
|
|
215
|
+
userTypeId: string;
|
|
216
|
+
/** Flag indicating if the user has an associated wallet */
|
|
217
|
+
hasWallet: boolean;
|
|
218
|
+
};
|
|
219
|
+
/** Token information structure */
|
|
220
|
+
TokenInfo: {
|
|
221
|
+
/** JWT or other authentication token */
|
|
222
|
+
token: string;
|
|
223
|
+
/** Token expiration time in seconds */
|
|
224
|
+
expiresIn: number;
|
|
225
|
+
};
|
|
226
|
+
/** Login credentials structure */
|
|
227
|
+
Credentials: {
|
|
228
|
+
/** Username for authentication */
|
|
229
|
+
username: string;
|
|
230
|
+
/** User's password */
|
|
231
|
+
password: string;
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Core type definitions for the authentication system.
|
|
3
|
+
* This file contains all the base types and interfaces that can be extended
|
|
4
|
+
* for specific authentication implementations.
|
|
5
|
+
*/
|
|
6
|
+
var RoleNameProps;
|
|
7
|
+
(function (RoleNameProps) {
|
|
8
|
+
RoleNameProps["ROLE_ADMIN"] = "ROLE_ADMIN";
|
|
9
|
+
RoleNameProps["ROLE_VENDOR"] = "ROLE_VENDOR";
|
|
10
|
+
RoleNameProps["ROLE_MERCHANT"] = "ROLE_MERCHANT";
|
|
11
|
+
RoleNameProps["ROLE_PROMOTER"] = "ROLE_PROMOTER";
|
|
12
|
+
RoleNameProps["ROLE_ARTIST"] = "ROLE_ARTIST";
|
|
13
|
+
})(RoleNameProps || (RoleNameProps = {}));
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth.types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth.types';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type CustomAuthConfig } from '../types';
|
|
2
|
+
interface CookieOptions {
|
|
3
|
+
expires?: number;
|
|
4
|
+
path?: string;
|
|
5
|
+
secure?: boolean;
|
|
6
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
7
|
+
domain?: string;
|
|
8
|
+
}
|
|
9
|
+
interface TokenManagerConfig {
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
refreshEndpoint: string;
|
|
12
|
+
cookieOptions?: Partial<CookieOptions>;
|
|
13
|
+
}
|
|
14
|
+
export declare class TokenManager<T extends CustomAuthConfig> {
|
|
15
|
+
private readonly cookieOptions;
|
|
16
|
+
private readonly baseUrl;
|
|
17
|
+
private readonly refreshEndpoint;
|
|
18
|
+
constructor(config: TokenManagerConfig);
|
|
19
|
+
setAccessToken(tokenInfo: T['TokenInfo']): void;
|
|
20
|
+
getAccessToken(): {
|
|
21
|
+
token: string | undefined;
|
|
22
|
+
expiresAt: number | null;
|
|
23
|
+
};
|
|
24
|
+
setRefreshToken(tokenInfo: T['TokenInfo']): void;
|
|
25
|
+
getRefreshToken(): string | undefined;
|
|
26
|
+
refreshTokens(): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Handles setting both access and refresh tokens with proper expiry
|
|
29
|
+
*/
|
|
30
|
+
handleSetAccessAndRefreshTokens(accessToken: string, refreshToken: string | undefined, accessTokenExpiresIn: number, refreshTokenExpiresIn?: number): void;
|
|
31
|
+
clearAllTokens(): void;
|
|
32
|
+
isAccessTokenExpired(): boolean;
|
|
33
|
+
handleAuthTokens(authResponse: {
|
|
34
|
+
accessToken: T['TokenInfo'];
|
|
35
|
+
refreshToken?: T['TokenInfo'];
|
|
36
|
+
}): void;
|
|
37
|
+
private setCookie;
|
|
38
|
+
private getCookie;
|
|
39
|
+
private removeCookie;
|
|
40
|
+
}
|
|
41
|
+
export declare const createTokenManager: <T extends CustomAuthConfig>(config: TokenManagerConfig) => TokenManager<T>;
|
|
42
|
+
export declare const useTokenManager: <T extends CustomAuthConfig>(config: TokenManagerConfig) => TokenManager<T>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Token management utility for handling authentication tokens
|
|
3
|
+
*/
|
|
4
|
+
import Cookies from 'js-cookie';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
const TOKEN_CONFIG = {
|
|
7
|
+
ACCESS_TOKEN: {
|
|
8
|
+
name: 'accessToken',
|
|
9
|
+
defaultExpiry: 1 / 24,
|
|
10
|
+
path: '/',
|
|
11
|
+
secure: true,
|
|
12
|
+
sameSite: 'strict',
|
|
13
|
+
},
|
|
14
|
+
REFRESH_TOKEN: {
|
|
15
|
+
name: 'refreshToken',
|
|
16
|
+
defaultExpiry: 7,
|
|
17
|
+
path: '/',
|
|
18
|
+
secure: true,
|
|
19
|
+
sameSite: 'strict',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export class TokenManager {
|
|
23
|
+
cookieOptions;
|
|
24
|
+
baseUrl;
|
|
25
|
+
refreshEndpoint;
|
|
26
|
+
constructor(config) {
|
|
27
|
+
this.cookieOptions = {
|
|
28
|
+
secure: true,
|
|
29
|
+
sameSite: 'strict',
|
|
30
|
+
path: '/',
|
|
31
|
+
...config.cookieOptions,
|
|
32
|
+
};
|
|
33
|
+
this.baseUrl = config.baseUrl;
|
|
34
|
+
this.refreshEndpoint = config.refreshEndpoint;
|
|
35
|
+
}
|
|
36
|
+
setAccessToken(tokenInfo) {
|
|
37
|
+
const expiryInDays = tokenInfo.expiresIn / (24 * 3600);
|
|
38
|
+
this.setCookie(TOKEN_CONFIG.ACCESS_TOKEN.name, tokenInfo.token, {
|
|
39
|
+
expires: expiryInDays,
|
|
40
|
+
});
|
|
41
|
+
const expiresAt = Date.now() + tokenInfo.expiresIn * 1000;
|
|
42
|
+
this.setCookie(`${TOKEN_CONFIG.ACCESS_TOKEN.name}ExpiresAt`, String(expiresAt), {
|
|
43
|
+
expires: expiryInDays,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getAccessToken() {
|
|
47
|
+
const token = this.getCookie(TOKEN_CONFIG.ACCESS_TOKEN.name);
|
|
48
|
+
const expiresAtStr = this.getCookie(`${TOKEN_CONFIG.ACCESS_TOKEN.name}ExpiresAt`);
|
|
49
|
+
const expiresAt = expiresAtStr ? parseInt(expiresAtStr, 10) : null;
|
|
50
|
+
return { token, expiresAt };
|
|
51
|
+
}
|
|
52
|
+
setRefreshToken(tokenInfo) {
|
|
53
|
+
const expiryInDays = tokenInfo.expiresIn / (24 * 3600);
|
|
54
|
+
this.setCookie(TOKEN_CONFIG.REFRESH_TOKEN.name, tokenInfo.token, {
|
|
55
|
+
expires: expiryInDays,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
getRefreshToken() {
|
|
59
|
+
return this.getCookie(TOKEN_CONFIG.REFRESH_TOKEN.name);
|
|
60
|
+
}
|
|
61
|
+
async refreshTokens() {
|
|
62
|
+
try {
|
|
63
|
+
const oldRefreshToken = this.getRefreshToken();
|
|
64
|
+
if (!oldRefreshToken) {
|
|
65
|
+
this.clearAllTokens();
|
|
66
|
+
throw new Error('No refresh token available');
|
|
67
|
+
}
|
|
68
|
+
const response = await fetch(`${this.baseUrl}${this.refreshEndpoint}`, {
|
|
69
|
+
method: 'POST',
|
|
70
|
+
headers: {
|
|
71
|
+
'Content-Type': 'application/json',
|
|
72
|
+
},
|
|
73
|
+
body: JSON.stringify({ refreshToken: oldRefreshToken }),
|
|
74
|
+
});
|
|
75
|
+
const data = await response.json();
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(data.error || 'Failed to refresh token');
|
|
78
|
+
}
|
|
79
|
+
const { accessToken, refreshToken: newRefreshToken, accessTokenExpiresIn, refreshTokenExpiresIn } = data;
|
|
80
|
+
this.handleAuthTokens({
|
|
81
|
+
accessToken: {
|
|
82
|
+
token: accessToken,
|
|
83
|
+
expiresIn: accessTokenExpiresIn,
|
|
84
|
+
},
|
|
85
|
+
...(newRefreshToken && refreshTokenExpiresIn
|
|
86
|
+
? {
|
|
87
|
+
refreshToken: {
|
|
88
|
+
token: newRefreshToken,
|
|
89
|
+
expiresIn: refreshTokenExpiresIn,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
: {}),
|
|
93
|
+
});
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error('Token refresh failed:', error);
|
|
98
|
+
this.clearAllTokens();
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Handles setting both access and refresh tokens with proper expiry
|
|
104
|
+
*/
|
|
105
|
+
handleSetAccessAndRefreshTokens(accessToken, refreshToken, accessTokenExpiresIn, refreshTokenExpiresIn) {
|
|
106
|
+
// Set access token
|
|
107
|
+
this.handleAuthTokens({
|
|
108
|
+
accessToken: {
|
|
109
|
+
token: accessToken,
|
|
110
|
+
expiresIn: accessTokenExpiresIn,
|
|
111
|
+
},
|
|
112
|
+
...(refreshToken && refreshTokenExpiresIn
|
|
113
|
+
? {
|
|
114
|
+
refreshToken: {
|
|
115
|
+
token: refreshToken,
|
|
116
|
+
expiresIn: refreshTokenExpiresIn,
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
: {}),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
clearAllTokens() {
|
|
123
|
+
this.removeCookie(TOKEN_CONFIG.ACCESS_TOKEN.name);
|
|
124
|
+
this.removeCookie(`${TOKEN_CONFIG.ACCESS_TOKEN.name}ExpiresAt`);
|
|
125
|
+
this.removeCookie(TOKEN_CONFIG.REFRESH_TOKEN.name);
|
|
126
|
+
}
|
|
127
|
+
isAccessTokenExpired() {
|
|
128
|
+
const { expiresAt } = this.getAccessToken();
|
|
129
|
+
if (!expiresAt)
|
|
130
|
+
return true;
|
|
131
|
+
return Date.now() >= expiresAt - 30000;
|
|
132
|
+
}
|
|
133
|
+
handleAuthTokens(authResponse) {
|
|
134
|
+
this.setAccessToken(authResponse.accessToken);
|
|
135
|
+
if (authResponse.refreshToken) {
|
|
136
|
+
this.setRefreshToken(authResponse.refreshToken);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
setCookie(name, value, options = {}) {
|
|
140
|
+
if (typeof window === 'undefined')
|
|
141
|
+
return;
|
|
142
|
+
const finalOptions = {
|
|
143
|
+
...this.cookieOptions,
|
|
144
|
+
...options,
|
|
145
|
+
};
|
|
146
|
+
try {
|
|
147
|
+
Cookies.set(name, value, finalOptions);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
console.error(`Error setting cookie ${name}:`, error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
getCookie(name) {
|
|
154
|
+
if (typeof window === 'undefined')
|
|
155
|
+
return undefined;
|
|
156
|
+
return Cookies.get(name);
|
|
157
|
+
}
|
|
158
|
+
removeCookie(name, options = {}) {
|
|
159
|
+
if (typeof window === 'undefined')
|
|
160
|
+
return;
|
|
161
|
+
Cookies.remove(name, { ...this.cookieOptions, ...options });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Standalone token manager instance creation
|
|
165
|
+
export const createTokenManager = (config) => {
|
|
166
|
+
return new TokenManager(config);
|
|
167
|
+
};
|
|
168
|
+
// React hook for using token manager
|
|
169
|
+
export const useTokenManager = (config) => {
|
|
170
|
+
return useMemo(() => new TokenManager(config), [config]);
|
|
171
|
+
};
|