@k3-tech/react-kit 0.0.72 → 0.0.73
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/dist/index.js +1 -1
- package/package.json +5 -1
- package/.babelrc +0 -12
- package/.storybook/main.ts +0 -22
- package/.storybook/preview.ts +0 -198
- package/Dockerfile.storybook +0 -43
- package/biome.json +0 -10
- package/components.json +0 -20
- package/dist/chunks/index.js +0 -5168
- package/dist/chunks/ort.bundle.min.js +0 -4
- package/dist/chunks/ort.webgpu.bundle.min.js +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/Can.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/RequireAuth.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/ShowWhenAuthenticated.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/ShowWhenError.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/ShowWhenLoading.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/ShowWhenUnauthenticated.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/withPermission.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/action-hooks.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/core-hooks.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/permission-hooks.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/token-hooks.d.ts.map +0 -1
- package/dist/kit/builder/auth/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/providers/AuthProvider.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/adapter-config.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/adapter.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/core.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/middleware.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/permissions.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/state.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/storage.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/token-manager.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/utils.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/auth-adapter.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/apollo-link.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/axios.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/fetch.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/graphql.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/rest.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/urql-exchange.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/permission-checker.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/browser.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/cookie.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/encryption.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/env.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/factory.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/memory.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/token-manager.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTable.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTableColumnHeader.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTableFilterPanel.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTablePagination.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTableViewOptions.d.ts.map +0 -1
- package/dist/kit/builder/data-table/index.d.ts.map +0 -1
- package/dist/kit/builder/data-table/types.d.ts.map +0 -1
- package/dist/kit/builder/data-table/utils/dotAccessor.d.ts.map +0 -1
- package/dist/kit/builder/dialog/index.d.ts.map +0 -1
- package/dist/kit/builder/dialog/provider.d.ts.map +0 -1
- package/dist/kit/builder/form/components/FormBuilder.d.ts.map +0 -1
- package/dist/kit/builder/form/components/FormBuilderActions.d.ts.map +0 -1
- package/dist/kit/builder/form/components/FormBuilderContext.d.ts.map +0 -1
- package/dist/kit/builder/form/components/FormBuilderField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/ArrayField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/AutocompleteField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/CheckboxField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DateField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DatePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DateRangePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DateTimePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DateTimeRangePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/FileField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/MonthPickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/MonthRangePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/NumberField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/ObjectField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/RadioField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/SelectField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/SwitchField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/TextField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/TextareaField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/TimePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/TimeRangePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/index.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/types.d.ts.map +0 -1
- package/dist/kit/builder/form/components/index.d.ts.map +0 -1
- package/dist/kit/builder/form/components/sectionNodes.d.ts.map +0 -1
- package/dist/kit/builder/form/hooks/useFormBuilder.d.ts.map +0 -1
- package/dist/kit/builder/form/index.d.ts.map +0 -1
- package/dist/kit/builder/form/types.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/common-forms.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/dependencies.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/field-factories.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/index.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/section-factories.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/transformers.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/validations.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/validators.d.ts.map +0 -1
- package/dist/kit/builder/page/Page.d.ts.map +0 -1
- package/dist/kit/builder/page/PageBackButton.d.ts.map +0 -1
- package/dist/kit/builder/page/index.d.ts.map +0 -1
- package/dist/kit/builder/section/SectionBuilder.d.ts.map +0 -1
- package/dist/kit/builder/section/SectionContainer.d.ts.map +0 -1
- package/dist/kit/builder/section/index.d.ts.map +0 -1
- package/dist/kit/builder/section/types.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/context.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/hooks.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/index.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/provider.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/renderer.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/types.d.ts.map +0 -1
- package/dist/kit/components/autocomplete/Autocomplete.d.ts.map +0 -1
- package/dist/kit/components/autocomplete/index.d.ts.map +0 -1
- package/dist/kit/components/autocomplete/types.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/DataTableHeader.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/DebouncedFilterField.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/FilterFieldRenderer.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/index.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/types.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/urlSerialization.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/useDataTableHeaderUrl.d.ts.map +0 -1
- package/dist/kit/components/datepicker/DatePicker.d.ts.map +0 -1
- package/dist/kit/components/datepicker/DateRangePicker.d.ts.map +0 -1
- package/dist/kit/components/datepicker/index.d.ts.map +0 -1
- package/dist/kit/components/datetimepicker/DateTimePicker.d.ts.map +0 -1
- package/dist/kit/components/datetimepicker/DateTimeRangePicker.d.ts.map +0 -1
- package/dist/kit/components/datetimepicker/index.d.ts.map +0 -1
- package/dist/kit/components/fileuploader/FileUploader.d.ts.map +0 -1
- package/dist/kit/components/fileuploader/image-preprocess.d.ts.map +0 -1
- package/dist/kit/components/fileuploader/index.d.ts.map +0 -1
- package/dist/kit/components/fileuploader/types.d.ts.map +0 -1
- package/dist/kit/components/forminfo/FormInfoError.d.ts.map +0 -1
- package/dist/kit/components/forminfo/index.d.ts.map +0 -1
- package/dist/kit/components/info-tooltip/InfoTooltip.d.ts.map +0 -1
- package/dist/kit/components/keyboard/Keyboard.d.ts.map +0 -1
- package/dist/kit/components/keyboard/index.d.ts.map +0 -1
- package/dist/kit/components/login/Login.d.ts.map +0 -1
- package/dist/kit/components/login/index.d.ts.map +0 -1
- package/dist/kit/components/monthpicker/MonthInput.d.ts.map +0 -1
- package/dist/kit/components/monthpicker/MonthPicker.d.ts.map +0 -1
- package/dist/kit/components/monthpicker/MonthRangeInput.d.ts.map +0 -1
- package/dist/kit/components/monthpicker/MonthRangePicker.d.ts.map +0 -1
- package/dist/kit/components/numpad/Numpad.d.ts.map +0 -1
- package/dist/kit/components/numpad/index.d.ts.map +0 -1
- package/dist/kit/components/timepicker/TimePicker.d.ts.map +0 -1
- package/dist/kit/components/timepicker/TimeRangePicker.d.ts.map +0 -1
- package/dist/kit/components/timepicker/index.d.ts.map +0 -1
- package/dist/kit/layouts/admin/components/AdminLayout.d.ts.map +0 -1
- package/dist/kit/layouts/admin/components/ThemeToggle.d.ts.map +0 -1
- package/dist/kit/layouts/admin/hooks/menu.d.ts.map +0 -1
- package/dist/kit/layouts/admin/providers/AdminMenuProvider.d.ts.map +0 -1
- package/dist/kit/layouts/admin/types/index.d.ts.map +0 -1
- package/dist/kit/providers/ThemeProvider.d.ts.map +0 -1
- package/dist/shadcn/hooks/use-mobile.d.ts.map +0 -1
- package/dist/shadcn/lib/utils.d.ts.map +0 -1
- package/dist/shadcn/ui/accordion.d.ts.map +0 -1
- package/dist/shadcn/ui/alert-dialog.d.ts.map +0 -1
- package/dist/shadcn/ui/alert.d.ts.map +0 -1
- package/dist/shadcn/ui/aspect-ratio.d.ts.map +0 -1
- package/dist/shadcn/ui/avatar.d.ts.map +0 -1
- package/dist/shadcn/ui/badge.d.ts.map +0 -1
- package/dist/shadcn/ui/breadcrumb.d.ts.map +0 -1
- package/dist/shadcn/ui/button.d.ts.map +0 -1
- package/dist/shadcn/ui/calendar.d.ts.map +0 -1
- package/dist/shadcn/ui/card.d.ts.map +0 -1
- package/dist/shadcn/ui/carousel.d.ts.map +0 -1
- package/dist/shadcn/ui/chart.d.ts.map +0 -1
- package/dist/shadcn/ui/checkbox.d.ts.map +0 -1
- package/dist/shadcn/ui/collapsible.d.ts.map +0 -1
- package/dist/shadcn/ui/command.d.ts.map +0 -1
- package/dist/shadcn/ui/context-menu.d.ts.map +0 -1
- package/dist/shadcn/ui/dialog.d.ts.map +0 -1
- package/dist/shadcn/ui/drawer.d.ts.map +0 -1
- package/dist/shadcn/ui/dropdown-menu.d.ts.map +0 -1
- package/dist/shadcn/ui/form.d.ts.map +0 -1
- package/dist/shadcn/ui/hover-card.d.ts.map +0 -1
- package/dist/shadcn/ui/input-otp.d.ts.map +0 -1
- package/dist/shadcn/ui/input.d.ts.map +0 -1
- package/dist/shadcn/ui/label.d.ts.map +0 -1
- package/dist/shadcn/ui/menubar.d.ts.map +0 -1
- package/dist/shadcn/ui/navigation-menu.d.ts.map +0 -1
- package/dist/shadcn/ui/pagination.d.ts.map +0 -1
- package/dist/shadcn/ui/popover.d.ts.map +0 -1
- package/dist/shadcn/ui/progress.d.ts.map +0 -1
- package/dist/shadcn/ui/radio-group.d.ts.map +0 -1
- package/dist/shadcn/ui/resizable.d.ts.map +0 -1
- package/dist/shadcn/ui/scroll-area.d.ts.map +0 -1
- package/dist/shadcn/ui/select.d.ts.map +0 -1
- package/dist/shadcn/ui/separator.d.ts.map +0 -1
- package/dist/shadcn/ui/sheet.d.ts.map +0 -1
- package/dist/shadcn/ui/sidebar.d.ts.map +0 -1
- package/dist/shadcn/ui/skeleton.d.ts.map +0 -1
- package/dist/shadcn/ui/slider.d.ts.map +0 -1
- package/dist/shadcn/ui/sonner.d.ts.map +0 -1
- package/dist/shadcn/ui/switch.d.ts.map +0 -1
- package/dist/shadcn/ui/table.d.ts.map +0 -1
- package/dist/shadcn/ui/tabs.d.ts.map +0 -1
- package/dist/shadcn/ui/textarea.d.ts.map +0 -1
- package/dist/shadcn/ui/toggle-group.d.ts.map +0 -1
- package/dist/shadcn/ui/toggle.d.ts.map +0 -1
- package/dist/shadcn/ui/tooltip.d.ts.map +0 -1
- package/src/index.ts +0 -100
- package/src/kit/builder/auth/components/Can.tsx +0 -27
- package/src/kit/builder/auth/components/RequireAuth.tsx +0 -78
- package/src/kit/builder/auth/components/ShowWhenAuthenticated.tsx +0 -10
- package/src/kit/builder/auth/components/ShowWhenError.tsx +0 -10
- package/src/kit/builder/auth/components/ShowWhenLoading.tsx +0 -10
- package/src/kit/builder/auth/components/ShowWhenUnauthenticated.tsx +0 -10
- package/src/kit/builder/auth/components/withPermission.tsx +0 -23
- package/src/kit/builder/auth/hooks/action-hooks.ts +0 -34
- package/src/kit/builder/auth/hooks/core-hooks.ts +0 -65
- package/src/kit/builder/auth/hooks/index.ts +0 -4
- package/src/kit/builder/auth/hooks/permission-hooks.ts +0 -43
- package/src/kit/builder/auth/hooks/token-hooks.ts +0 -25
- package/src/kit/builder/auth/index.ts +0 -132
- package/src/kit/builder/auth/providers/AuthProvider.tsx +0 -131
- package/src/kit/builder/auth/types/adapter-config.ts +0 -44
- package/src/kit/builder/auth/types/adapter.ts +0 -132
- package/src/kit/builder/auth/types/core.ts +0 -27
- package/src/kit/builder/auth/types/index.ts +0 -9
- package/src/kit/builder/auth/types/middleware.ts +0 -20
- package/src/kit/builder/auth/types/permissions.ts +0 -23
- package/src/kit/builder/auth/types/state.ts +0 -16
- package/src/kit/builder/auth/types/storage.ts +0 -21
- package/src/kit/builder/auth/types/token-manager.ts +0 -9
- package/src/kit/builder/auth/types/utils.ts +0 -55
- package/src/kit/builder/auth/utils/auth-adapter.ts +0 -437
- package/src/kit/builder/auth/utils/client-adapters/apollo-link.ts +0 -30
- package/src/kit/builder/auth/utils/client-adapters/axios.ts +0 -61
- package/src/kit/builder/auth/utils/client-adapters/fetch.ts +0 -48
- package/src/kit/builder/auth/utils/client-adapters/graphql.ts +0 -60
- package/src/kit/builder/auth/utils/client-adapters/index.ts +0 -6
- package/src/kit/builder/auth/utils/client-adapters/rest.ts +0 -60
- package/src/kit/builder/auth/utils/client-adapters/urql-exchange.ts +0 -76
- package/src/kit/builder/auth/utils/permission-checker.ts +0 -150
- package/src/kit/builder/auth/utils/storage/browser.ts +0 -99
- package/src/kit/builder/auth/utils/storage/cookie.ts +0 -116
- package/src/kit/builder/auth/utils/storage/encryption.ts +0 -80
- package/src/kit/builder/auth/utils/storage/env.ts +0 -2
- package/src/kit/builder/auth/utils/storage/factory.ts +0 -37
- package/src/kit/builder/auth/utils/storage/index.ts +0 -6
- package/src/kit/builder/auth/utils/storage/memory.ts +0 -15
- package/src/kit/builder/auth/utils/token-manager.ts +0 -55
- package/src/kit/builder/data-table/components/DataTable.tsx +0 -662
- package/src/kit/builder/data-table/components/DataTableColumnHeader.tsx +0 -67
- package/src/kit/builder/data-table/components/DataTableFilterPanel.tsx +0 -160
- package/src/kit/builder/data-table/components/DataTablePagination.tsx +0 -135
- package/src/kit/builder/data-table/components/DataTableViewOptions.tsx +0 -51
- package/src/kit/builder/data-table/index.ts +0 -6
- package/src/kit/builder/data-table/types.ts +0 -44
- package/src/kit/builder/data-table/utils/dotAccessor.ts +0 -6
- package/src/kit/builder/dialog/index.ts +0 -6
- package/src/kit/builder/dialog/provider.tsx +0 -170
- package/src/kit/builder/form/components/FormBuilder.tsx +0 -333
- package/src/kit/builder/form/components/FormBuilderActions.tsx +0 -78
- package/src/kit/builder/form/components/FormBuilderContext.tsx +0 -52
- package/src/kit/builder/form/components/FormBuilderField.tsx +0 -476
- package/src/kit/builder/form/components/fields/ArrayField.tsx +0 -312
- package/src/kit/builder/form/components/fields/AutocompleteField.tsx +0 -99
- package/src/kit/builder/form/components/fields/CheckboxField.tsx +0 -78
- package/src/kit/builder/form/components/fields/DateField.tsx +0 -55
- package/src/kit/builder/form/components/fields/DatePickerField.tsx +0 -48
- package/src/kit/builder/form/components/fields/DateRangePickerField.tsx +0 -72
- package/src/kit/builder/form/components/fields/DateTimePickerField.tsx +0 -55
- package/src/kit/builder/form/components/fields/DateTimeRangePickerField.tsx +0 -65
- package/src/kit/builder/form/components/fields/FileField.tsx +0 -38
- package/src/kit/builder/form/components/fields/MonthPickerField.tsx +0 -34
- package/src/kit/builder/form/components/fields/MonthRangePickerField.tsx +0 -42
- package/src/kit/builder/form/components/fields/NumberField.tsx +0 -88
- package/src/kit/builder/form/components/fields/ObjectField.tsx +0 -35
- package/src/kit/builder/form/components/fields/RadioField.tsx +0 -48
- package/src/kit/builder/form/components/fields/SelectField.tsx +0 -47
- package/src/kit/builder/form/components/fields/SwitchField.tsx +0 -76
- package/src/kit/builder/form/components/fields/TextField.tsx +0 -26
- package/src/kit/builder/form/components/fields/TextareaField.tsx +0 -21
- package/src/kit/builder/form/components/fields/TimePickerField.tsx +0 -36
- package/src/kit/builder/form/components/fields/TimeRangePickerField.tsx +0 -44
- package/src/kit/builder/form/components/fields/index.ts +0 -21
- package/src/kit/builder/form/components/fields/types.ts +0 -18
- package/src/kit/builder/form/components/index.ts +0 -3
- package/src/kit/builder/form/components/sectionNodes.tsx +0 -148
- package/src/kit/builder/form/hooks/useFormBuilder.ts +0 -457
- package/src/kit/builder/form/index.ts +0 -4
- package/src/kit/builder/form/types.ts +0 -294
- package/src/kit/builder/form/utils/common-forms.ts +0 -68
- package/src/kit/builder/form/utils/dependencies.ts +0 -56
- package/src/kit/builder/form/utils/field-factories.ts +0 -177
- package/src/kit/builder/form/utils/index.ts +0 -17
- package/src/kit/builder/form/utils/section-factories.ts +0 -38
- package/src/kit/builder/form/utils/transformers.ts +0 -100
- package/src/kit/builder/form/utils/validations.ts +0 -22
- package/src/kit/builder/form/utils/validators.ts +0 -20
- package/src/kit/builder/page/Page.tsx +0 -205
- package/src/kit/builder/page/PageBackButton.tsx +0 -52
- package/src/kit/builder/page/index.ts +0 -1
- package/src/kit/builder/section/SectionBuilder.tsx +0 -443
- package/src/kit/builder/section/SectionContainer.tsx +0 -85
- package/src/kit/builder/section/index.ts +0 -2
- package/src/kit/builder/section/types.ts +0 -83
- package/src/kit/builder/stack-dialog/context.ts +0 -15
- package/src/kit/builder/stack-dialog/hooks.ts +0 -13
- package/src/kit/builder/stack-dialog/index.ts +0 -12
- package/src/kit/builder/stack-dialog/provider.tsx +0 -51
- package/src/kit/builder/stack-dialog/renderer.tsx +0 -36
- package/src/kit/builder/stack-dialog/types.ts +0 -34
- package/src/kit/components/autocomplete/Autocomplete.tsx +0 -732
- package/src/kit/components/autocomplete/index.ts +0 -3
- package/src/kit/components/autocomplete/types.ts +0 -27
- package/src/kit/components/data-table-headers/DataTableHeader.tsx +0 -158
- package/src/kit/components/data-table-headers/DebouncedFilterField.tsx +0 -83
- package/src/kit/components/data-table-headers/FilterFieldRenderer.tsx +0 -194
- package/src/kit/components/data-table-headers/index.ts +0 -6
- package/src/kit/components/data-table-headers/types.ts +0 -89
- package/src/kit/components/data-table-headers/urlSerialization.ts +0 -173
- package/src/kit/components/data-table-headers/useDataTableHeaderUrl.ts +0 -107
- package/src/kit/components/datepicker/DatePicker.tsx +0 -173
- package/src/kit/components/datepicker/DateRangePicker.tsx +0 -526
- package/src/kit/components/datepicker/index.ts +0 -2
- package/src/kit/components/datetimepicker/DateTimePicker.tsx +0 -420
- package/src/kit/components/datetimepicker/DateTimeRangePicker.tsx +0 -676
- package/src/kit/components/datetimepicker/index.ts +0 -2
- package/src/kit/components/fileuploader/FileUploader.tsx +0 -880
- package/src/kit/components/fileuploader/image-preprocess.ts +0 -253
- package/src/kit/components/fileuploader/index.ts +0 -4
- package/src/kit/components/fileuploader/types.ts +0 -94
- package/src/kit/components/forminfo/FormInfoError.tsx +0 -135
- package/src/kit/components/forminfo/index.ts +0 -1
- package/src/kit/components/info-tooltip/InfoTooltip.tsx +0 -18
- package/src/kit/components/keyboard/Keyboard.tsx +0 -916
- package/src/kit/components/keyboard/index.ts +0 -4
- package/src/kit/components/login/Login.tsx +0 -141
- package/src/kit/components/login/index.ts +0 -1
- package/src/kit/components/monthpicker/MonthInput.tsx +0 -131
- package/src/kit/components/monthpicker/MonthPicker.tsx +0 -224
- package/src/kit/components/monthpicker/MonthRangeInput.tsx +0 -153
- package/src/kit/components/monthpicker/MonthRangePicker.tsx +0 -409
- package/src/kit/components/numpad/Numpad.tsx +0 -377
- package/src/kit/components/numpad/index.ts +0 -4
- package/src/kit/components/timepicker/TimePicker.tsx +0 -319
- package/src/kit/components/timepicker/TimeRangePicker.tsx +0 -368
- package/src/kit/components/timepicker/index.ts +0 -2
- package/src/kit/layouts/admin/components/AdminLayout.tsx +0 -419
- package/src/kit/layouts/admin/components/ThemeToggle.tsx +0 -54
- package/src/kit/layouts/admin/hooks/menu.ts +0 -32
- package/src/kit/layouts/admin/providers/AdminMenuProvider.tsx +0 -78
- package/src/kit/layouts/admin/types/index.ts +0 -26
- package/src/kit/providers/ThemeProvider.tsx +0 -90
- package/src/kit/themes/base.css +0 -11
- package/src/kit/themes/clean-slate.css +0 -155
- package/src/kit/themes/default.css +0 -197
- package/src/kit/themes/minimal-modern.css +0 -155
- package/src/kit/themes/spotify.css +0 -164
- package/src/shadcn/hooks/use-mobile.ts +0 -21
- package/src/shadcn/lib/utils.ts +0 -6
- package/src/shadcn/ui/accordion.tsx +0 -66
- package/src/shadcn/ui/alert-dialog.tsx +0 -157
- package/src/shadcn/ui/alert.tsx +0 -66
- package/src/shadcn/ui/aspect-ratio.tsx +0 -11
- package/src/shadcn/ui/avatar.tsx +0 -53
- package/src/shadcn/ui/badge.tsx +0 -46
- package/src/shadcn/ui/breadcrumb.tsx +0 -111
- package/src/shadcn/ui/button.tsx +0 -59
- package/src/shadcn/ui/calendar.tsx +0 -217
- package/src/shadcn/ui/card.tsx +0 -92
- package/src/shadcn/ui/carousel.tsx +0 -240
- package/src/shadcn/ui/chart.tsx +0 -353
- package/src/shadcn/ui/checkbox.tsx +0 -32
- package/src/shadcn/ui/collapsible.tsx +0 -33
- package/src/shadcn/ui/command.tsx +0 -184
- package/src/shadcn/ui/context-menu.tsx +0 -252
- package/src/shadcn/ui/dialog.tsx +0 -146
- package/src/shadcn/ui/drawer.tsx +0 -135
- package/src/shadcn/ui/dropdown-menu.tsx +0 -257
- package/src/shadcn/ui/form.tsx +0 -168
- package/src/shadcn/ui/hover-card.tsx +0 -44
- package/src/shadcn/ui/input-otp.tsx +0 -77
- package/src/shadcn/ui/input.tsx +0 -21
- package/src/shadcn/ui/label.tsx +0 -24
- package/src/shadcn/ui/menubar.tsx +0 -276
- package/src/shadcn/ui/navigation-menu.tsx +0 -168
- package/src/shadcn/ui/pagination.tsx +0 -128
- package/src/shadcn/ui/popover.tsx +0 -48
- package/src/shadcn/ui/progress.tsx +0 -31
- package/src/shadcn/ui/radio-group.tsx +0 -45
- package/src/shadcn/ui/resizable.tsx +0 -56
- package/src/shadcn/ui/scroll-area.tsx +0 -58
- package/src/shadcn/ui/select.tsx +0 -185
- package/src/shadcn/ui/separator.tsx +0 -28
- package/src/shadcn/ui/sheet.tsx +0 -139
- package/src/shadcn/ui/sidebar.tsx +0 -726
- package/src/shadcn/ui/skeleton.tsx +0 -13
- package/src/shadcn/ui/slider.tsx +0 -63
- package/src/shadcn/ui/sonner.tsx +0 -37
- package/src/shadcn/ui/switch.tsx +0 -31
- package/src/shadcn/ui/table.tsx +0 -134
- package/src/shadcn/ui/tabs.tsx +0 -66
- package/src/shadcn/ui/textarea.tsx +0 -18
- package/src/shadcn/ui/toggle-group.tsx +0 -73
- package/src/shadcn/ui/toggle.tsx +0 -47
- package/src/shadcn/ui/tooltip.tsx +0 -61
- package/src/stories/FileUploader.stories.tsx +0 -185
- package/src/stories/kit/builder/DataTable.Basic.stories.tsx +0 -71
- package/src/stories/kit/builder/DataTable.Filters.stories.tsx +0 -98
- package/src/stories/kit/builder/DataTable.Pagination.stories.tsx +0 -73
- package/src/stories/kit/builder/DataTable.SelectionAndActions.stories.tsx +0 -77
- package/src/stories/kit/builder/DataTable.Sorting.stories.tsx +0 -67
- package/src/stories/kit/builder/Dialog.stories.tsx +0 -90
- package/src/stories/kit/builder/Form.ArrayLayouts.stories.tsx +0 -177
- package/src/stories/kit/builder/Form.Autocomplete.stories.tsx +0 -220
- package/src/stories/kit/builder/Form.Basic.stories.tsx +0 -79
- package/src/stories/kit/builder/Form.Complex.stories.tsx +0 -569
- package/src/stories/kit/builder/Form.DateTime.stories.tsx +0 -70
- package/src/stories/kit/builder/Form.Dynamic.stories.tsx +0 -926
- package/src/stories/kit/builder/Form.Files.stories.tsx +0 -136
- package/src/stories/kit/builder/Form.MultipleFormBuilder.stories.tsx +0 -377
- package/src/stories/kit/builder/Form.Pickers.stories.tsx +0 -75
- package/src/stories/kit/builder/Form.Simple.stories.tsx +0 -91
- package/src/stories/kit/builder/Form.Time.stories.tsx +0 -68
- package/src/stories/kit/builder/Page.stories.tsx +0 -115
- package/src/stories/kit/builder/Section.stories.tsx +0 -282
- package/src/stories/kit/components/Autocomplete.stories.tsx +0 -313
- package/src/stories/kit/components/DatePicker.stories.tsx +0 -195
- package/src/stories/kit/components/DateRangePicker.stories.tsx +0 -195
- package/src/stories/kit/components/Keyboard.stories.tsx +0 -263
- package/src/stories/kit/components/Login.stories.tsx +0 -167
- package/src/stories/kit/components/MonthPicker.stories.tsx +0 -100
- package/src/stories/kit/components/MonthRangePicker.stories.tsx +0 -117
- package/src/stories/kit/components/Numpad.stories.tsx +0 -195
- package/src/stories/kit/components/TimePicker.stories.tsx +0 -71
- package/src/stories/kit/components/TimeRangePicker.stories.tsx +0 -43
- package/src/stories/kit/layouts/admin/AdminLayout.Basic.stories.tsx +0 -118
- package/src/stories/kit/layouts/admin/AdminLayout.Collapsible.stories.tsx +0 -81
- package/src/stories/kit/layouts/admin/AdminLayout.Complex.stories.tsx +0 -251
- package/src/stories/kit/layouts/admin/AdminLayout.CustomSidebarHeaderComponent.stories.tsx +0 -80
- package/src/stories/kit/layouts/admin/AdminLayout.CustomSidebarTitleAndIcon.stories.tsx +0 -70
- package/src/stories/kit/layouts/admin/AdminLayout.HeaderSlots.stories.tsx +0 -87
- package/src/stories/shadcn/ui/Accordion.stories.tsx +0 -117
- package/src/stories/shadcn/ui/Alert.stories.tsx +0 -36
- package/src/stories/shadcn/ui/AlertDialog.stories.tsx +0 -73
- package/src/stories/shadcn/ui/AspectRatio.stories.tsx +0 -58
- package/src/stories/shadcn/ui/Avatar.stories.tsx +0 -26
- package/src/stories/shadcn/ui/Badge.stories.tsx +0 -28
- package/src/stories/shadcn/ui/Breadcrumb.stories.tsx +0 -47
- package/src/stories/shadcn/ui/Button.stories.tsx +0 -51
- package/src/stories/shadcn/ui/Calendar.stories.tsx +0 -33
- package/src/stories/shadcn/ui/Card.stories.tsx +0 -39
- package/src/stories/shadcn/ui/Carousel.stories.tsx +0 -37
- package/src/stories/shadcn/ui/Chart.stories.tsx +0 -72
- package/src/stories/shadcn/ui/Checkbox.stories.tsx +0 -64
- package/src/stories/shadcn/ui/Collapsible.stories.tsx +0 -40
- package/src/stories/shadcn/ui/Command.stories.tsx +0 -53
- package/src/stories/shadcn/ui/ContextMenu.stories.tsx +0 -67
- package/src/stories/shadcn/ui/Dialog.stories.tsx +0 -45
- package/src/stories/shadcn/ui/Drawer.stories.tsx +0 -49
- package/src/stories/shadcn/ui/DropdownMenu.stories.tsx +0 -75
- package/src/stories/shadcn/ui/Form.stories.tsx +0 -93
- package/src/stories/shadcn/ui/HoverCard.stories.tsx +0 -43
- package/src/stories/shadcn/ui/Input.stories.tsx +0 -41
- package/src/stories/shadcn/ui/InputOtp.stories.tsx +0 -39
- package/src/stories/shadcn/ui/Label.stories.tsx +0 -29
- package/src/stories/shadcn/ui/Menubar.stories.tsx +0 -87
- package/src/stories/shadcn/ui/NavigationMenu.stories.tsx +0 -78
- package/src/stories/shadcn/ui/Pagination.stories.tsx +0 -51
- package/src/stories/shadcn/ui/Popover.stories.tsx +0 -53
- package/src/stories/shadcn/ui/Progress.stories.tsx +0 -30
- package/src/stories/shadcn/ui/RadioGroup.stories.tsx +0 -31
- package/src/stories/shadcn/ui/Resizable.stories.tsx +0 -55
- package/src/stories/shadcn/ui/ScrollArea.stories.tsx +0 -84
- package/src/stories/shadcn/ui/Select.stories.tsx +0 -61
- package/src/stories/shadcn/ui/Separator.stories.tsx +0 -35
- package/src/stories/shadcn/ui/Sheet.stories.tsx +0 -48
- package/src/stories/shadcn/ui/Sidebar.stories.tsx +0 -131
- package/src/stories/shadcn/ui/Skeleton.stories.tsx +0 -23
- package/src/stories/shadcn/ui/Slider.stories.tsx +0 -21
- package/src/stories/shadcn/ui/Sonner.stories.tsx +0 -49
- package/src/stories/shadcn/ui/Switch.stories.tsx +0 -28
- package/src/stories/shadcn/ui/Table.stories.tsx +0 -374
- package/src/stories/shadcn/ui/Tabs.stories.tsx +0 -31
- package/src/stories/shadcn/ui/Textarea.stories.tsx +0 -42
- package/src/stories/shadcn/ui/Toggle.stories.tsx +0 -44
- package/src/stories/shadcn/ui/ToggleGroup.stories.tsx +0 -28
- package/src/stories/shadcn/ui/Tooltip.stories.tsx +0 -30
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -52
- package/tsconfig.spec.json +0 -38
- package/tsconfig.tsbuildinfo +0 -1
- package/vite.config.ts +0 -93
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import { createMemoryStorage } from './storage';
|
|
2
|
-
import { createTokenManager } from './token-manager';
|
|
3
|
-
import {
|
|
4
|
-
checkPermissions,
|
|
5
|
-
checkRoles,
|
|
6
|
-
evaluatePermissionRule,
|
|
7
|
-
expandPermissions,
|
|
8
|
-
expandRoles,
|
|
9
|
-
} from './permission-checker';
|
|
10
|
-
import type {
|
|
11
|
-
AuthAdapter,
|
|
12
|
-
AuthAdapterConfig,
|
|
13
|
-
AuthAdapterState,
|
|
14
|
-
AuthAdapterSubscriber,
|
|
15
|
-
AuthSession,
|
|
16
|
-
AuthStatus,
|
|
17
|
-
PermissionPolicy,
|
|
18
|
-
PermissionRule,
|
|
19
|
-
} from '../types';
|
|
20
|
-
|
|
21
|
-
const unique = <T>(values: T[]): T[] => {
|
|
22
|
-
return Array.from(new Set(values));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Enhanced Authentication Adapter
|
|
27
|
-
*
|
|
28
|
-
* Features:
|
|
29
|
-
* - Token management with auto-refresh
|
|
30
|
-
* - Permission and role hierarchies
|
|
31
|
-
* - Middleware support
|
|
32
|
-
* - Retry logic
|
|
33
|
-
* - Advanced permission checking (AND/OR policies)
|
|
34
|
-
* - Session persistence
|
|
35
|
-
*/
|
|
36
|
-
export function createAuthAdapter<
|
|
37
|
-
TUser = unknown,
|
|
38
|
-
TRole extends string = string,
|
|
39
|
-
TPermission extends string = string,
|
|
40
|
-
TSession extends AuthSession<TUser, TRole, TPermission> = AuthSession<
|
|
41
|
-
TUser,
|
|
42
|
-
TRole,
|
|
43
|
-
TPermission
|
|
44
|
-
>,
|
|
45
|
-
TCredentials = unknown,
|
|
46
|
-
>(
|
|
47
|
-
config: AuthAdapterConfig<TUser, TRole, TPermission, TSession, TCredentials>,
|
|
48
|
-
): AuthAdapter<TUser, TRole, TPermission, TSession, TCredentials> {
|
|
49
|
-
// ============================================================================
|
|
50
|
-
// Configuration & State
|
|
51
|
-
// ============================================================================
|
|
52
|
-
|
|
53
|
-
const storage = config.storage ?? createMemoryStorage<TSession>();
|
|
54
|
-
const tokenManager =
|
|
55
|
-
config.tokenManager ??
|
|
56
|
-
createTokenManager({
|
|
57
|
-
refreshThreshold: config.refreshThreshold ?? 300,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const subscribers = new Set<
|
|
61
|
-
AuthAdapterSubscriber<TSession, TUser, TRole, TPermission>
|
|
62
|
-
>();
|
|
63
|
-
|
|
64
|
-
const resolveUser =
|
|
65
|
-
config.resolveUser ?? ((session: TSession | null) => session?.user ?? null);
|
|
66
|
-
const resolveRoles =
|
|
67
|
-
config.resolveRoles ??
|
|
68
|
-
((session: TSession | null) =>
|
|
69
|
-
session?.roles?.filter((role): role is TRole => role != null) ?? []);
|
|
70
|
-
const resolvePermissions =
|
|
71
|
-
config.resolvePermissions ??
|
|
72
|
-
((session: TSession | null) =>
|
|
73
|
-
session?.permissions?.filter(
|
|
74
|
-
(permission): permission is TPermission => permission != null,
|
|
75
|
-
) ?? []);
|
|
76
|
-
|
|
77
|
-
let state: AuthAdapterState<TSession, TUser, TRole, TPermission> = {
|
|
78
|
-
status: 'idle',
|
|
79
|
-
session: null,
|
|
80
|
-
user: null,
|
|
81
|
-
roles: [],
|
|
82
|
-
permissions: [],
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
let autoRefreshCleanup: (() => void) | null = null;
|
|
86
|
-
|
|
87
|
-
// ============================================================================
|
|
88
|
-
// Middleware Execution
|
|
89
|
-
// ============================================================================
|
|
90
|
-
|
|
91
|
-
const executeMiddleware = async <
|
|
92
|
-
T extends keyof NonNullable<typeof config.middleware>[number],
|
|
93
|
-
>(
|
|
94
|
-
hook: T,
|
|
95
|
-
...args: Parameters<
|
|
96
|
-
NonNullable<NonNullable<typeof config.middleware>[number][T]>
|
|
97
|
-
>
|
|
98
|
-
): Promise<void> => {
|
|
99
|
-
if (!config.middleware) return;
|
|
100
|
-
|
|
101
|
-
for (const middleware of config.middleware) {
|
|
102
|
-
const fn = middleware[hook];
|
|
103
|
-
if (fn) {
|
|
104
|
-
try {
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
-
await (fn as any)(...args);
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.error(`[auth2] Middleware error in ${String(hook)}:`, error);
|
|
109
|
-
if (middleware.onError) {
|
|
110
|
-
await middleware.onError(error);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// ============================================================================
|
|
118
|
-
// State Management
|
|
119
|
-
// ============================================================================
|
|
120
|
-
|
|
121
|
-
const notify = () => {
|
|
122
|
-
for (const listener of subscribers) listener(state);
|
|
123
|
-
config.onStateChange?.(state);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const setState = (
|
|
127
|
-
next: AuthAdapterState<TSession, TUser, TRole, TPermission>,
|
|
128
|
-
) => {
|
|
129
|
-
state = next;
|
|
130
|
-
notify();
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const computeState = (
|
|
134
|
-
session: TSession | null,
|
|
135
|
-
status: AuthStatus,
|
|
136
|
-
error?: unknown,
|
|
137
|
-
): AuthAdapterState<TSession, TUser, TRole, TPermission> => {
|
|
138
|
-
const user = resolveUser(session);
|
|
139
|
-
const baseRoles = resolveRoles(session);
|
|
140
|
-
const basePermissions = resolvePermissions(session);
|
|
141
|
-
|
|
142
|
-
// Apply hierarchies
|
|
143
|
-
const roles = unique(expandRoles(baseRoles, config.roleHierarchy));
|
|
144
|
-
const permissions = unique(
|
|
145
|
-
expandPermissions(basePermissions, config.permissionHierarchy),
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
const tokenExpiresIn = session?.expiresAt
|
|
149
|
-
? tokenManager.getTimeUntilExpiry(session.expiresAt)
|
|
150
|
-
: undefined;
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
status,
|
|
154
|
-
session,
|
|
155
|
-
user,
|
|
156
|
-
roles,
|
|
157
|
-
permissions,
|
|
158
|
-
error,
|
|
159
|
-
lastRefresh: Date.now(),
|
|
160
|
-
tokenExpiresIn,
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// ============================================================================
|
|
165
|
-
// Storage Operations
|
|
166
|
-
// ============================================================================
|
|
167
|
-
|
|
168
|
-
const readStorage = async () => {
|
|
169
|
-
const stored = await Promise.resolve(storage.get());
|
|
170
|
-
return stored ?? null;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
const writeStorage = async (next: TSession | null) => {
|
|
174
|
-
if (next === null) {
|
|
175
|
-
await Promise.resolve(storage.clear());
|
|
176
|
-
} else {
|
|
177
|
-
await Promise.resolve(storage.set(next));
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
// ============================================================================
|
|
182
|
-
// Auto-Refresh Management
|
|
183
|
-
// ============================================================================
|
|
184
|
-
|
|
185
|
-
const setupAutoRefresh = () => {
|
|
186
|
-
if (autoRefreshCleanup) {
|
|
187
|
-
autoRefreshCleanup();
|
|
188
|
-
autoRefreshCleanup = null;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (!config.autoRefresh || !config.refresh || !state.session?.expiresAt) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (tokenManager.scheduleRefresh) {
|
|
196
|
-
autoRefreshCleanup = tokenManager.scheduleRefresh(() => {
|
|
197
|
-
refresh().catch((error) => {
|
|
198
|
-
console.error('[auth2] Auto-refresh failed:', error);
|
|
199
|
-
});
|
|
200
|
-
}, state.session.expiresAt);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// ============================================================================
|
|
205
|
-
// Session Management
|
|
206
|
-
// ============================================================================
|
|
207
|
-
|
|
208
|
-
const setSession = async (
|
|
209
|
-
session: TSession | null,
|
|
210
|
-
statusOverride?: AuthStatus,
|
|
211
|
-
error?: unknown,
|
|
212
|
-
) => {
|
|
213
|
-
await writeStorage(session);
|
|
214
|
-
const status: AuthStatus =
|
|
215
|
-
statusOverride ?? (session ? 'authenticated' : 'unauthenticated');
|
|
216
|
-
const nextState = computeState(session, status, error);
|
|
217
|
-
setState(nextState);
|
|
218
|
-
|
|
219
|
-
setupAutoRefresh();
|
|
220
|
-
|
|
221
|
-
return nextState;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const sync = async () => {
|
|
225
|
-
setState({ ...state, status: 'loading' });
|
|
226
|
-
try {
|
|
227
|
-
const session =
|
|
228
|
-
(await config.loadSession?.()) ?? (await readStorage()) ?? null;
|
|
229
|
-
|
|
230
|
-
// Check if session is expired
|
|
231
|
-
if (session?.expiresAt && tokenManager.isExpired(session.expiresAt)) {
|
|
232
|
-
// Try to refresh if possible
|
|
233
|
-
if (config.refresh && session.refreshToken) {
|
|
234
|
-
try {
|
|
235
|
-
const refreshed = await config.refresh(session);
|
|
236
|
-
return await setSession(refreshed, 'authenticated');
|
|
237
|
-
} catch {
|
|
238
|
-
// Refresh failed, session is expired
|
|
239
|
-
await executeMiddleware('onSessionExpired');
|
|
240
|
-
return await setSession(null, 'unauthenticated');
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
await executeMiddleware('onSessionExpired');
|
|
245
|
-
return await setSession(null, 'unauthenticated');
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return await setSession(
|
|
249
|
-
session,
|
|
250
|
-
session ? 'authenticated' : 'unauthenticated',
|
|
251
|
-
);
|
|
252
|
-
} catch (error) {
|
|
253
|
-
await executeMiddleware('onError', error);
|
|
254
|
-
return await setSession(null, 'error', error);
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
// ============================================================================
|
|
259
|
-
// Retry Logic
|
|
260
|
-
// ============================================================================
|
|
261
|
-
|
|
262
|
-
const withRetry = async <T>(
|
|
263
|
-
fn: () => Promise<T>,
|
|
264
|
-
context: string,
|
|
265
|
-
): Promise<T> => {
|
|
266
|
-
const maxRetries = config.retryConfig?.maxRetries ?? 0;
|
|
267
|
-
const retryDelay = config.retryConfig?.retryDelay ?? 1000;
|
|
268
|
-
const shouldRetry = config.retryConfig?.retryOn;
|
|
269
|
-
|
|
270
|
-
let lastError: unknown;
|
|
271
|
-
|
|
272
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
273
|
-
try {
|
|
274
|
-
return await fn();
|
|
275
|
-
} catch (error) {
|
|
276
|
-
lastError = error;
|
|
277
|
-
|
|
278
|
-
const isLastAttempt = attempt === maxRetries;
|
|
279
|
-
const shouldRetryError = shouldRetry ? shouldRetry(error) : false;
|
|
280
|
-
|
|
281
|
-
if (isLastAttempt || !shouldRetryError) {
|
|
282
|
-
throw error;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
console.warn(
|
|
286
|
-
`[auth2] ${context} failed (attempt ${attempt + 1}/${maxRetries + 1}), retrying...`,
|
|
287
|
-
);
|
|
288
|
-
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
throw lastError;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
// ============================================================================
|
|
296
|
-
// Authentication Operations
|
|
297
|
-
// ============================================================================
|
|
298
|
-
|
|
299
|
-
const refresh = async () => {
|
|
300
|
-
const refreshFn = config.refresh;
|
|
301
|
-
const currentSession = state.session;
|
|
302
|
-
|
|
303
|
-
if (!refreshFn) return state;
|
|
304
|
-
if (!currentSession) return state;
|
|
305
|
-
|
|
306
|
-
try {
|
|
307
|
-
const refreshed = await withRetry(
|
|
308
|
-
() => refreshFn(currentSession),
|
|
309
|
-
'refresh',
|
|
310
|
-
);
|
|
311
|
-
const nextState = await setSession(refreshed, 'authenticated');
|
|
312
|
-
await executeMiddleware('onRefresh', nextState);
|
|
313
|
-
return nextState;
|
|
314
|
-
} catch (error) {
|
|
315
|
-
await executeMiddleware('onError', error);
|
|
316
|
-
return await setSession(state.session, 'error', error);
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
const login = async (credentials: TCredentials) => {
|
|
321
|
-
const loginFn = config.login;
|
|
322
|
-
if (!loginFn) throw new Error('Auth adapter login is not configured');
|
|
323
|
-
|
|
324
|
-
setState({ ...state, status: 'loading' });
|
|
325
|
-
|
|
326
|
-
try {
|
|
327
|
-
await executeMiddleware('onBeforeLogin', credentials);
|
|
328
|
-
|
|
329
|
-
const session = await withRetry(() => loginFn(credentials), 'login');
|
|
330
|
-
|
|
331
|
-
const nextState = await setSession(session, 'authenticated');
|
|
332
|
-
await executeMiddleware('onAfterLogin', nextState);
|
|
333
|
-
|
|
334
|
-
return nextState;
|
|
335
|
-
} catch (error) {
|
|
336
|
-
await executeMiddleware('onError', error);
|
|
337
|
-
await setSession(null, 'error', error);
|
|
338
|
-
throw error;
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
const logout = async () => {
|
|
343
|
-
const current = state.session;
|
|
344
|
-
|
|
345
|
-
try {
|
|
346
|
-
await executeMiddleware('onBeforeLogout');
|
|
347
|
-
await config.logout?.(current ?? null);
|
|
348
|
-
} finally {
|
|
349
|
-
if (autoRefreshCleanup) {
|
|
350
|
-
autoRefreshCleanup();
|
|
351
|
-
autoRefreshCleanup = null;
|
|
352
|
-
}
|
|
353
|
-
await setSession(null, 'unauthenticated');
|
|
354
|
-
await executeMiddleware('onAfterLogout');
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
// ============================================================================
|
|
359
|
-
// Permission Checking
|
|
360
|
-
// ============================================================================
|
|
361
|
-
|
|
362
|
-
const hasRole = (
|
|
363
|
-
target: TRole | TRole[],
|
|
364
|
-
options?: { requireAll?: boolean },
|
|
365
|
-
): boolean => {
|
|
366
|
-
return checkRoles(state.roles, target, options);
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
const hasPermission = (
|
|
370
|
-
target: TPermission | TPermission[] | PermissionPolicy<TPermission>,
|
|
371
|
-
options?: { requireAll?: boolean },
|
|
372
|
-
): boolean => {
|
|
373
|
-
return checkPermissions(state.permissions, target, options);
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const can = (rule: PermissionRule<TRole, TPermission>): boolean => {
|
|
377
|
-
return evaluatePermissionRule(state.roles, state.permissions, rule);
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
// ============================================================================
|
|
381
|
-
// Token Management
|
|
382
|
-
// ============================================================================
|
|
383
|
-
|
|
384
|
-
const getToken = (): string | null => {
|
|
385
|
-
return state.session?.accessToken ?? null;
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
const isTokenExpired = (): boolean => {
|
|
389
|
-
return tokenManager.isExpired(state.session?.expiresAt);
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
const getTimeUntilExpiry = (): number => {
|
|
393
|
-
return tokenManager.getTimeUntilExpiry(state.session?.expiresAt);
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
const scheduleAutoRefresh = (): (() => void) => {
|
|
397
|
-
setupAutoRefresh();
|
|
398
|
-
return () => {
|
|
399
|
-
if (autoRefreshCleanup) {
|
|
400
|
-
autoRefreshCleanup();
|
|
401
|
-
autoRefreshCleanup = null;
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
// ============================================================================
|
|
407
|
-
// API
|
|
408
|
-
// ============================================================================
|
|
409
|
-
|
|
410
|
-
const api: AuthAdapter<TUser, TRole, TPermission, TSession, TCredentials> = {
|
|
411
|
-
getState: () => state,
|
|
412
|
-
subscribe: (listener) => {
|
|
413
|
-
subscribers.add(listener);
|
|
414
|
-
return () => {
|
|
415
|
-
subscribers.delete(listener);
|
|
416
|
-
};
|
|
417
|
-
},
|
|
418
|
-
sync,
|
|
419
|
-
login: config.login ? login : undefined,
|
|
420
|
-
logout,
|
|
421
|
-
refresh: async () => {
|
|
422
|
-
return await refresh();
|
|
423
|
-
},
|
|
424
|
-
setSession: async (session) => {
|
|
425
|
-
return await setSession(session);
|
|
426
|
-
},
|
|
427
|
-
hasRole,
|
|
428
|
-
hasPermission,
|
|
429
|
-
can,
|
|
430
|
-
getToken,
|
|
431
|
-
isTokenExpired,
|
|
432
|
-
getTimeUntilExpiry,
|
|
433
|
-
scheduleAutoRefresh,
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
return api;
|
|
437
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export function createApolloAuthLink(
|
|
2
|
-
getToken: () => string | null,
|
|
3
|
-
options?: {
|
|
4
|
-
tokenType?: string
|
|
5
|
-
},
|
|
6
|
-
) {
|
|
7
|
-
const tokenType = options?.tokenType ?? 'Bearer'
|
|
8
|
-
|
|
9
|
-
// This requires @apollo/client to be installed
|
|
10
|
-
// We'll return a function that creates the link to avoid direct dependency
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
return (ApolloLink: any) => {
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
return new ApolloLink((operation: any, forward: any) => {
|
|
15
|
-
const token = getToken()
|
|
16
|
-
|
|
17
|
-
if (token) {
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
operation.setContext(({ headers = {} }: any) => ({
|
|
20
|
-
headers: {
|
|
21
|
-
...headers,
|
|
22
|
-
authorization: `${tokenType} ${token}`,
|
|
23
|
-
},
|
|
24
|
-
}))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return forward(operation)
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export function createAxiosAuthInterceptor(
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
-
axiosInstance: any,
|
|
4
|
-
getToken: () => string | null,
|
|
5
|
-
options?: {
|
|
6
|
-
tokenType?: string
|
|
7
|
-
onTokenExpired?: () => void
|
|
8
|
-
refreshToken?: () => Promise<void>
|
|
9
|
-
},
|
|
10
|
-
) {
|
|
11
|
-
const tokenType = options?.tokenType ?? 'Bearer'
|
|
12
|
-
|
|
13
|
-
// Request interceptor
|
|
14
|
-
axiosInstance.interceptors.request.use(
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
async (config: any) => {
|
|
17
|
-
const token = getToken()
|
|
18
|
-
if (token) {
|
|
19
|
-
config.headers.Authorization = `${tokenType} ${token}`
|
|
20
|
-
}
|
|
21
|
-
return config
|
|
22
|
-
},
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
(error: any) => Promise.reject(error),
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
// Response interceptor for token refresh
|
|
28
|
-
if (options?.refreshToken) {
|
|
29
|
-
axiosInstance.interceptors.response.use(
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
(response: any) => response,
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
async (error: any) => {
|
|
34
|
-
const originalRequest = error.config
|
|
35
|
-
|
|
36
|
-
// If token expired and we haven't retried yet
|
|
37
|
-
if (
|
|
38
|
-
error.response?.status === 401 &&
|
|
39
|
-
!originalRequest._retry &&
|
|
40
|
-
options.refreshToken
|
|
41
|
-
) {
|
|
42
|
-
originalRequest._retry = true
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
await options.refreshToken()
|
|
46
|
-
const token = getToken()
|
|
47
|
-
if (token) {
|
|
48
|
-
originalRequest.headers.Authorization = `${tokenType} ${token}`
|
|
49
|
-
}
|
|
50
|
-
return axiosInstance(originalRequest)
|
|
51
|
-
} catch (refreshError) {
|
|
52
|
-
options.onTokenExpired?.()
|
|
53
|
-
return Promise.reject(refreshError)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return Promise.reject(error)
|
|
58
|
-
},
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export function createAuthFetch(
|
|
2
|
-
getToken: () => string | null,
|
|
3
|
-
options?: {
|
|
4
|
-
tokenType?: string
|
|
5
|
-
onTokenExpired?: () => void
|
|
6
|
-
refreshToken?: () => Promise<void>
|
|
7
|
-
},
|
|
8
|
-
): typeof fetch {
|
|
9
|
-
const tokenType = options?.tokenType ?? 'Bearer'
|
|
10
|
-
|
|
11
|
-
return async (
|
|
12
|
-
input: RequestInfo | URL,
|
|
13
|
-
init?: RequestInit,
|
|
14
|
-
): Promise<Response> => {
|
|
15
|
-
const token = getToken()
|
|
16
|
-
const headers = new Headers(init?.headers)
|
|
17
|
-
|
|
18
|
-
if (token) {
|
|
19
|
-
headers.set('Authorization', `${tokenType} ${token}`)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const response = await fetch(input, {
|
|
23
|
-
...init,
|
|
24
|
-
headers,
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
// Handle token expiration
|
|
28
|
-
if (response.status === 401 && options?.refreshToken) {
|
|
29
|
-
try {
|
|
30
|
-
await options.refreshToken()
|
|
31
|
-
const newToken = getToken()
|
|
32
|
-
|
|
33
|
-
if (newToken) {
|
|
34
|
-
headers.set('Authorization', `${tokenType} ${newToken}`)
|
|
35
|
-
return await fetch(input, {
|
|
36
|
-
...init,
|
|
37
|
-
headers,
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
} catch (error) {
|
|
41
|
-
options.onTokenExpired?.()
|
|
42
|
-
throw error
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return response
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { AuthAdapterConfig, AuthSession, GraphQLAuthClient } from '../../types'
|
|
2
|
-
|
|
3
|
-
export type GraphQLClientAdapterOptions<
|
|
4
|
-
TUser = unknown,
|
|
5
|
-
TRole extends string = string,
|
|
6
|
-
TPermission extends string = string,
|
|
7
|
-
TSession extends AuthSession<TUser, TRole, TPermission> = AuthSession<
|
|
8
|
-
TUser,
|
|
9
|
-
TRole,
|
|
10
|
-
TPermission
|
|
11
|
-
>,
|
|
12
|
-
TCredentials = unknown,
|
|
13
|
-
> = {
|
|
14
|
-
client: GraphQLAuthClient<TSession, TCredentials>
|
|
15
|
-
resolveUser?: (session: TSession | null) => TUser | null
|
|
16
|
-
resolveRoles?: (session: TSession | null) => TRole[]
|
|
17
|
-
resolvePermissions?: (session: TSession | null) => TPermission[]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function createGraphQLAuthAdapter<
|
|
21
|
-
TUser = unknown,
|
|
22
|
-
TRole extends string = string,
|
|
23
|
-
TPermission extends string = string,
|
|
24
|
-
TSession extends AuthSession<TUser, TRole, TPermission> = AuthSession<
|
|
25
|
-
TUser,
|
|
26
|
-
TRole,
|
|
27
|
-
TPermission
|
|
28
|
-
>,
|
|
29
|
-
TCredentials = unknown,
|
|
30
|
-
>(
|
|
31
|
-
options: GraphQLClientAdapterOptions<
|
|
32
|
-
TUser,
|
|
33
|
-
TRole,
|
|
34
|
-
TPermission,
|
|
35
|
-
TSession,
|
|
36
|
-
TCredentials
|
|
37
|
-
>,
|
|
38
|
-
): Partial<
|
|
39
|
-
AuthAdapterConfig<TUser, TRole, TPermission, TSession, TCredentials>
|
|
40
|
-
> {
|
|
41
|
-
return {
|
|
42
|
-
login: options.client.login,
|
|
43
|
-
logout: options.client.logout,
|
|
44
|
-
refresh: options.client.refresh
|
|
45
|
-
? async (session: TSession) => {
|
|
46
|
-
if (!session.refreshToken) {
|
|
47
|
-
throw new Error('No refresh token available')
|
|
48
|
-
}
|
|
49
|
-
if (!options.client.refresh) {
|
|
50
|
-
throw new Error('Refresh function not provided')
|
|
51
|
-
}
|
|
52
|
-
return await options.client.refresh(session.refreshToken)
|
|
53
|
-
}
|
|
54
|
-
: undefined,
|
|
55
|
-
loadSession: options.client.getCurrentUser,
|
|
56
|
-
resolveUser: options.resolveUser,
|
|
57
|
-
resolveRoles: options.resolveRoles,
|
|
58
|
-
resolvePermissions: options.resolvePermissions,
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { AuthAdapterConfig, AuthSession, RESTAuthClient } from '../../types'
|
|
2
|
-
|
|
3
|
-
export type RESTClientAdapterOptions<
|
|
4
|
-
TUser = unknown,
|
|
5
|
-
TRole extends string = string,
|
|
6
|
-
TPermission extends string = string,
|
|
7
|
-
TSession extends AuthSession<TUser, TRole, TPermission> = AuthSession<
|
|
8
|
-
TUser,
|
|
9
|
-
TRole,
|
|
10
|
-
TPermission
|
|
11
|
-
>,
|
|
12
|
-
TCredentials = unknown,
|
|
13
|
-
> = {
|
|
14
|
-
client: RESTAuthClient<TSession, TCredentials>
|
|
15
|
-
resolveUser?: (session: TSession | null) => TUser | null
|
|
16
|
-
resolveRoles?: (session: TSession | null) => TRole[]
|
|
17
|
-
resolvePermissions?: (session: TSession | null) => TPermission[]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function createRESTAuthAdapter<
|
|
21
|
-
TUser = unknown,
|
|
22
|
-
TRole extends string = string,
|
|
23
|
-
TPermission extends string = string,
|
|
24
|
-
TSession extends AuthSession<TUser, TRole, TPermission> = AuthSession<
|
|
25
|
-
TUser,
|
|
26
|
-
TRole,
|
|
27
|
-
TPermission
|
|
28
|
-
>,
|
|
29
|
-
TCredentials = unknown,
|
|
30
|
-
>(
|
|
31
|
-
options: RESTClientAdapterOptions<
|
|
32
|
-
TUser,
|
|
33
|
-
TRole,
|
|
34
|
-
TPermission,
|
|
35
|
-
TSession,
|
|
36
|
-
TCredentials
|
|
37
|
-
>,
|
|
38
|
-
): Partial<
|
|
39
|
-
AuthAdapterConfig<TUser, TRole, TPermission, TSession, TCredentials>
|
|
40
|
-
> {
|
|
41
|
-
return {
|
|
42
|
-
login: options.client.login,
|
|
43
|
-
logout: options.client.logout,
|
|
44
|
-
refresh: options.client.refresh
|
|
45
|
-
? async (session: TSession) => {
|
|
46
|
-
if (!session.refreshToken) {
|
|
47
|
-
throw new Error('No refresh token available')
|
|
48
|
-
}
|
|
49
|
-
if (!options.client.refresh) {
|
|
50
|
-
throw new Error('Refresh function not provided')
|
|
51
|
-
}
|
|
52
|
-
return await options.client.refresh(session.refreshToken)
|
|
53
|
-
}
|
|
54
|
-
: undefined,
|
|
55
|
-
loadSession: options.client.getCurrentUser,
|
|
56
|
-
resolveUser: options.resolveUser,
|
|
57
|
-
resolveRoles: options.resolveRoles,
|
|
58
|
-
resolvePermissions: options.resolvePermissions,
|
|
59
|
-
}
|
|
60
|
-
}
|