@liorian/sdk 0.28.0-alpha.56010ca
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/README.md +483 -0
- package/package.json +94 -0
- package/schemas/module.schema.json +818 -0
- package/src/application/index.ts +3 -0
- package/src/application/module-instance.ts +36 -0
- package/src/application/service/auth-api-service.ts +291 -0
- package/src/application/service/auth-user.service.ts +108 -0
- package/src/application/service/index.ts +12 -0
- package/src/application/service/module-activation-api.service.ts +105 -0
- package/src/application/service/notifications-api-service.ts +38 -0
- package/src/application/service/notifications-push.service.ts +299 -0
- package/src/application/service/notifications-socket-service.ts +76 -0
- package/src/application/service/organizations-api-service.ts +104 -0
- package/src/application/service/otp-api-service.ts +11 -0
- package/src/application/service/storage-api-service.ts +77 -0
- package/src/application/service/storefront-api.service.ts +72 -0
- package/src/application/service/user-preferences-api.service.ts +57 -0
- package/src/domain/config/app.config.ts +35 -0
- package/src/domain/config/auth.config.ts +30 -0
- package/src/domain/config/index.ts +4 -0
- package/src/domain/config/logo.config.ts +17 -0
- package/src/domain/entities/activities.interface.ts +18 -0
- package/src/domain/entities/catalog.interface.ts +96 -0
- package/src/domain/entities/index.ts +13 -0
- package/src/domain/entities/media.ts +22 -0
- package/src/domain/entities/module-activation.interface.ts +173 -0
- package/src/domain/entities/module.interface.ts +101 -0
- package/src/domain/entities/notification.interface.ts +23 -0
- package/src/domain/entities/objectable.type.ts +3 -0
- package/src/domain/entities/organization.interface.ts +81 -0
- package/src/domain/entities/user-auth.interface.ts +17 -0
- package/src/domain/entities/user-phone.interface.ts +11 -0
- package/src/domain/entities/user-profile.interface.ts +23 -0
- package/src/domain/entities/user.interface.ts +79 -0
- package/src/domain/enums/coloring.enum.ts +6 -0
- package/src/domain/enums/domains.enum.ts +282 -0
- package/src/domain/enums/index.ts +8 -0
- package/src/domain/enums/module-category.enum.ts +57 -0
- package/src/domain/enums/module.enum.ts +97 -0
- package/src/domain/enums/routine.enum.ts +12 -0
- package/src/domain/enums/user-profile.enum.ts +25 -0
- package/src/domain/enums/user-status.enum.ts +7 -0
- package/src/domain/index.ts +6 -0
- package/src/domain/typing/auth-caches.ts +12 -0
- package/src/domain/typing/auth-oauth.types.ts +172 -0
- package/src/domain/typing/devise.ts +2 -0
- package/src/domain/typing/index.ts +10 -0
- package/src/domain/typing/response.ts +30 -0
- package/src/domain/typing/routine.types.ts +113 -0
- package/src/domain/typing/session.interface.ts +28 -0
- package/src/domain/typing/statisticals.ts +11 -0
- package/src/domain/typing/user-media-upload.ts +9 -0
- package/src/domain/typing/values.ts +6 -0
- package/src/index.tsx +168 -0
- package/src/infrastructure/capabilities/cache-storage/capability.ts +129 -0
- package/src/infrastructure/capabilities/cache-storage/enum.ts +5 -0
- package/src/infrastructure/capabilities/cache-storage/index.ts +4 -0
- package/src/infrastructure/capabilities/cache-storage/types.ts +13 -0
- package/src/infrastructure/capabilities/index.ts +3 -0
- package/src/infrastructure/capabilities/stackable/capability.ts +55 -0
- package/src/infrastructure/capabilities/stackable/index.ts +3 -0
- package/src/infrastructure/capabilities/stackable/types.ts +24 -0
- package/src/infrastructure/common-classname.constant.ts +4 -0
- package/src/infrastructure/data/countries.ts +208 -0
- package/src/infrastructure/data/gender.ts +5 -0
- package/src/infrastructure/data/index.ts +3 -0
- package/src/infrastructure/dataset/index.ts +3 -0
- package/src/infrastructure/dataset/sign-in.dataset.ts +21 -0
- package/src/infrastructure/dataset/sign-up.dataset.ts +64 -0
- package/src/infrastructure/hooks/index.ts +10 -0
- package/src/infrastructure/hooks/use-activity-lock-draft.ts +69 -0
- package/src/infrastructure/hooks/use-auth.ts +24 -0
- package/src/infrastructure/hooks/use-elastic-interaction.ts +180 -0
- package/src/infrastructure/hooks/use-is-desktop.ts +25 -0
- package/src/infrastructure/hooks/use-is-tauri.ts +17 -0
- package/src/infrastructure/hooks/use-mobile.ts +19 -0
- package/src/infrastructure/hooks/use-notifications.ts +128 -0
- package/src/infrastructure/hooks/use-recent-colors.ts +113 -0
- package/src/infrastructure/hooks/use-recent-modules.ts +76 -0
- package/src/infrastructure/index.tsx +11 -0
- package/src/infrastructure/library/design-system.ts +95 -0
- package/src/infrastructure/library/index.tsx +5 -0
- package/src/infrastructure/library/motion-utils.ts +77 -0
- package/src/infrastructure/library/motion.tsx +31 -0
- package/src/infrastructure/library/scroll-progress.tsx +93 -0
- package/src/infrastructure/providers/auth-guard.provider.tsx +47 -0
- package/src/infrastructure/providers/auth.provider.tsx +168 -0
- package/src/infrastructure/providers/index.tsx +8 -0
- package/src/infrastructure/providers/module-usage.provider.tsx +95 -0
- package/src/infrastructure/providers/modules-guard.provider.tsx +64 -0
- package/src/infrastructure/providers/modules-routines.provider.tsx +33 -0
- package/src/infrastructure/providers/modules-switcher.provider.tsx +25 -0
- package/src/infrastructure/providers/query.provider.tsx +27 -0
- package/src/infrastructure/routines/__tests__/routine.test.ts +368 -0
- package/src/infrastructure/routines/index.tsx +3 -0
- package/src/infrastructure/routines/routine.hook.ts +121 -0
- package/src/infrastructure/routines/routine.ts +283 -0
- package/src/infrastructure/routines/routine.tsx +283 -0
- package/src/infrastructure/stores/activity-lock.store.ts +22 -0
- package/src/infrastructure/stores/auth-user-connected.store.ts +24 -0
- package/src/infrastructure/stores/dataset.store.ts +106 -0
- package/src/infrastructure/stores/index.ts +6 -0
- package/src/infrastructure/stores/module.store.ts +266 -0
- package/src/infrastructure/stores/upload.store.ts +198 -0
- package/src/infrastructure/utilities/access-label.util.ts +158 -0
- package/src/infrastructure/utilities/activities.util.tsx +54 -0
- package/src/infrastructure/utilities/activity-lock.service.ts +263 -0
- package/src/infrastructure/utilities/activity-tracker.service.ts +205 -0
- package/src/infrastructure/utilities/api-service.ts +237 -0
- package/src/infrastructure/utilities/auth-logout.util.ts +23 -0
- package/src/infrastructure/utilities/classname.util.ts +7 -0
- package/src/infrastructure/utilities/encryption.service.ts +125 -0
- package/src/infrastructure/utilities/form-snapshot.service.ts +304 -0
- package/src/infrastructure/utilities/format.util.ts +40 -0
- package/src/infrastructure/utilities/index.tsx +23 -0
- package/src/infrastructure/utilities/media-label.service.ts +47 -0
- package/src/infrastructure/utilities/modules.ts +11 -0
- package/src/infrastructure/utilities/permission.util.ts +22 -0
- package/src/infrastructure/utilities/push-permission.util.ts +43 -0
- package/src/infrastructure/utilities/route-access.ts +38 -0
- package/src/infrastructure/utilities/socket-service.ts +123 -0
- package/src/infrastructure/utilities/sso-auth.util.ts +188 -0
- package/src/infrastructure/utilities/stringable.util.ts +16 -0
- package/src/infrastructure/utilities/strings.util.ts +18 -0
- package/src/infrastructure/utilities/tauri.util.ts +15 -0
- package/src/infrastructure/utilities/utils.ts +6 -0
- package/src/infrastructure/utilities/values.ts +5 -0
- package/src/presentation/8starlabs-ui/button.tsx +94 -0
- package/src/presentation/8starlabs-ui/flip-clock.tsx +368 -0
- package/src/presentation/8starlabs-ui/heatmap.tsx +430 -0
- package/src/presentation/8starlabs-ui/hooks/index.tsx +2 -0
- package/src/presentation/8starlabs-ui/hooks/use-mobile.ts +21 -0
- package/src/presentation/8starlabs-ui/index.tsx +20 -0
- package/src/presentation/8starlabs-ui/json-viewer.tsx +972 -0
- package/src/presentation/8starlabs-ui/marquee.tsx +134 -0
- package/src/presentation/8starlabs-ui/partition-bar.tsx +198 -0
- package/src/presentation/8starlabs-ui/scroll-fade.tsx +158 -0
- package/src/presentation/8starlabs-ui/status-indicator.tsx +86 -0
- package/src/presentation/8starlabs-ui/system-banner.tsx +50 -0
- package/src/presentation/8starlabs-ui/timeline.tsx +576 -0
- package/src/presentation/8starlabs-ui/transport-badge.tsx +249 -0
- package/src/presentation/8starlabs-ui/ui/copy-button.tsx +60 -0
- package/src/presentation/8starlabs-ui/ui/index.tsx +2 -0
- package/src/presentation/analytics-section.tsx +85 -0
- package/src/presentation/app-sidebar.tsx +234 -0
- package/src/presentation/charts/area-widget.chart-skeleton.tsx +61 -0
- package/src/presentation/charts/area-widget.chart.tsx +128 -0
- package/src/presentation/charts/chart-widgets.types.ts +81 -0
- package/src/presentation/charts/index.tsx +16 -0
- package/src/presentation/charts/line-widget.chart-skeleton.tsx +64 -0
- package/src/presentation/charts/line-widget.chart.tsx +105 -0
- package/src/presentation/charts/pie-widget.chart-skeleton.tsx +56 -0
- package/src/presentation/charts/pie-widget.chart.tsx +168 -0
- package/src/presentation/charts/radar-widget.chart-skeleton.tsx +67 -0
- package/src/presentation/charts/radar-widget.chart.tsx +80 -0
- package/src/presentation/charts/radial-stacked-widget.chart-skeleton.tsx +66 -0
- package/src/presentation/charts/radial-stacked-widget.chart.tsx +120 -0
- package/src/presentation/charts/radial-widget.chart-skeleton.tsx +61 -0
- package/src/presentation/charts/radial-widget.chart.tsx +87 -0
- package/src/presentation/charts/tooltip-widget.chart-skeleton.tsx +64 -0
- package/src/presentation/charts/tooltip-widget.chart.tsx +89 -0
- package/src/presentation/components/activity-actions.tsx +20 -0
- package/src/presentation/components/activity-container.tsx +55 -0
- package/src/presentation/components/activity-content.tsx +20 -0
- package/src/presentation/components/activity-descriptor-parser.tsx +37 -0
- package/src/presentation/components/activity-header.tsx +20 -0
- package/src/presentation/components/activity-loader.tsx +19 -0
- package/src/presentation/components/activity-title.tsx +32 -0
- package/src/presentation/components/activity.tsx +22 -0
- package/src/presentation/components/auth/index.tsx +4 -0
- package/src/presentation/components/auth/sso-callback.view.tsx +44 -0
- package/src/presentation/components/auth/sso-disconnect.view.tsx +41 -0
- package/src/presentation/components/auth/sso-sign-in.view.tsx +29 -0
- package/src/presentation/components/auth-lock-screen.tsx +309 -0
- package/src/presentation/components/auth-session.view.tsx +17 -0
- package/src/presentation/components/data-table.tsx +814 -0
- package/src/presentation/components/dynamic-icon.tsx +16 -0
- package/src/presentation/components/floating-upload.tsx +291 -0
- package/src/presentation/components/index.tsx +40 -0
- package/src/presentation/components/local-time.tsx +170 -0
- package/src/presentation/components/markdown-parser.tsx +201 -0
- package/src/presentation/components/message-scroller.tsx +131 -0
- package/src/presentation/components/module-first-access-config.view.tsx +181 -0
- package/src/presentation/components/module-first-access-pending.view.tsx +38 -0
- package/src/presentation/components/module-guard.tsx +34 -0
- package/src/presentation/components/modules-first-access.guard.tsx +88 -0
- package/src/presentation/components/modules-guard-forbidden.tsx +46 -0
- package/src/presentation/components/notification-details.modal.tsx +145 -0
- package/src/presentation/components/notification-item.tsx +127 -0
- package/src/presentation/components/notifications-popover.tsx +128 -0
- package/src/presentation/components/push-notifications.provider.tsx +65 -0
- package/src/presentation/components/upload-progress-dialog.tsx +140 -0
- package/src/presentation/components/waiting-bar.tsx +22 -0
- package/src/presentation/components/waiting-section.tsx +15 -0
- package/src/presentation/components/waiting.tsx +14 -0
- package/src/presentation/data-grid/data-grid-empty.tsx +24 -0
- package/src/presentation/data-grid/data-grid-search-engine.tsx +32 -0
- package/src/presentation/data-grid/data-grid.tsx +892 -0
- package/src/presentation/data-grid/index.tsx +4 -0
- package/src/presentation/form-screen.tsx +95 -0
- package/src/presentation/icons/custom.tsx +20 -0
- package/src/presentation/icons/glyphIcons.tsx +53 -0
- package/src/presentation/icons/icons.enum.ts +4 -0
- package/src/presentation/icons/icons.util.ts +6 -0
- package/src/presentation/icons/index.tsx +8 -0
- package/src/presentation/icons/lucide.tsx +17 -0
- package/src/presentation/icons/remix.tsx +33 -0
- package/src/presentation/icons/types.ts +27 -0
- package/src/presentation/index.tsx +45 -0
- package/src/presentation/modals/components/ModalBox.tsx +74 -0
- package/src/presentation/modals/components/ModalPortal.tsx +31 -0
- package/src/presentation/modals/components/ModalStepper.tsx +319 -0
- package/src/presentation/modals/components/ModalWrapper.tsx +65 -0
- package/src/presentation/modals/components/index.tsx +5 -0
- package/src/presentation/modals/hooks/index.ts +2 -0
- package/src/presentation/modals/hooks/useModal.ts +38 -0
- package/src/presentation/modals/index.tsx +5 -0
- package/src/presentation/modals/stores/index.ts +2 -0
- package/src/presentation/modals/stores/useModalStore.ts +90 -0
- package/src/presentation/modals/types/index.ts +2 -0
- package/src/presentation/modals/types/modal.type.ts +33 -0
- package/src/presentation/module-menubar.tsx +300 -0
- package/src/presentation/module-widget.tsx +233 -0
- package/src/presentation/nav-documents.tsx +89 -0
- package/src/presentation/nav-main.tsx +62 -0
- package/src/presentation/nav-secondary.tsx +41 -0
- package/src/presentation/nav-user.tsx +109 -0
- package/src/presentation/permission-action-badge.tsx +35 -0
- package/src/presentation/reui/index.tsx +3 -0
- package/src/presentation/reui/stepper.tsx +508 -0
- package/src/presentation/reui/timeline.tsx +226 -0
- package/src/presentation/sheets/index.tsx +2 -0
- package/src/presentation/sheets/legacy-sheet-header.tsx +0 -0
- package/src/presentation/sheets/legacy-sheet.tsx +37 -0
- package/src/presentation/size.enum.ts +19 -0
- package/src/presentation/system/index.tsx +3 -0
- package/src/presentation/system/logo.theme.tsx +21 -0
- package/src/presentation/system/types.ts +10 -0
- package/src/presentation/theme/index.tsx +6 -0
- package/src/presentation/theme/prefer-color-scheme.tsx +50 -0
- package/src/presentation/theme/switch-color-scheme.tsx +16 -0
- package/src/presentation/theme/theme-switcher-button.tsx +20 -0
- package/src/presentation/theme/theme.enum.ts +4 -0
- package/src/presentation/theme/theme.store.ts +87 -0
- package/src/presentation/themes/index.tsx +2 -0
- package/src/presentation/themes/katon/dashboard-layout.tsx +1080 -0
- package/src/presentation/themes/katon/edge-section.tsx +19 -0
- package/src/presentation/themes/katon/header-menubar.tsx +270 -0
- package/src/presentation/themes/katon/header-modules-available.tsx +44 -0
- package/src/presentation/themes/katon/header-modules-recents.tsx +52 -0
- package/src/presentation/themes/katon/header-modules-store.tsx +25 -0
- package/src/presentation/themes/katon/header-options.tsx +13 -0
- package/src/presentation/themes/katon/header-organization-select.tsx +146 -0
- package/src/presentation/themes/katon/header-routines.tsx +74 -0
- package/src/presentation/themes/katon/header-tasks-connected-user.tsx +150 -0
- package/src/presentation/themes/katon/index.tsx +16 -0
- package/src/presentation/themes/katon/main-wrapper.tsx +34 -0
- package/src/presentation/themes/katon/module-item-link.tsx +32 -0
- package/src/presentation/themes/katon/view-frame.tsx +25 -0
- package/src/presentation/themes/katon/view-helmet.tsx +53 -0
- package/src/presentation/themes/katon/view-status.tsx +32 -0
- package/src/presentation/themes/katon/view-wrapper.tsx +15 -0
- package/src/presentation/themes/katon/view.tsx +42 -0
- package/src/presentation/ui/accordion-multiselect.tsx +206 -0
- package/src/presentation/ui/accordion.tsx +81 -0
- package/src/presentation/ui/alert-dialog.tsx +199 -0
- package/src/presentation/ui/alert.tsx +76 -0
- package/src/presentation/ui/aspect-ratio.tsx +11 -0
- package/src/presentation/ui/attachment.tsx +204 -0
- package/src/presentation/ui/avatar.tsx +112 -0
- package/src/presentation/ui/badge.tsx +49 -0
- package/src/presentation/ui/breadcrumb.tsx +122 -0
- package/src/presentation/ui/bubble.tsx +125 -0
- package/src/presentation/ui/button-group.tsx +83 -0
- package/src/presentation/ui/button.tsx +87 -0
- package/src/presentation/ui/calendar.tsx +222 -0
- package/src/presentation/ui/card.tsx +106 -0
- package/src/presentation/ui/carousel.tsx +242 -0
- package/src/presentation/ui/chart.tsx +373 -0
- package/src/presentation/ui/checkbox.tsx +33 -0
- package/src/presentation/ui/clickable.tsx +58 -0
- package/src/presentation/ui/collapsible.tsx +33 -0
- package/src/presentation/ui/color-swatch-selector.tsx +81 -0
- package/src/presentation/ui/combobox.tsx +299 -0
- package/src/presentation/ui/command.tsx +195 -0
- package/src/presentation/ui/context-menu.tsx +263 -0
- package/src/presentation/ui/dialog.tsx +168 -0
- package/src/presentation/ui/direction.tsx +22 -0
- package/src/presentation/ui/drawer.tsx +134 -0
- package/src/presentation/ui/dropdown-menu.tsx +269 -0
- package/src/presentation/ui/empty.tsx +104 -0
- package/src/presentation/ui/field.tsx +238 -0
- package/src/presentation/ui/granularity-selector.tsx +58 -0
- package/src/presentation/ui/hover-card.tsx +44 -0
- package/src/presentation/ui/index.tsx +74 -0
- package/src/presentation/ui/input-group.tsx +156 -0
- package/src/presentation/ui/input-otp.tsx +87 -0
- package/src/presentation/ui/input.tsx +19 -0
- package/src/presentation/ui/item.tsx +196 -0
- package/src/presentation/ui/kpi-card.tsx +203 -0
- package/src/presentation/ui/label-selector.tsx +100 -0
- package/src/presentation/ui/label.tsx +24 -0
- package/src/presentation/ui/legacy-birth-date-input.tsx +43 -0
- package/src/presentation/ui/legacy-color-picker/index.tsx +42 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.content.tsx +37 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.context.tsx +42 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.hex-input.tsx +97 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.picker.tsx +266 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.presets.ts +22 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.quick-list.tsx +49 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.recent.tsx +43 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.swatches.tsx +111 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.trigger.tsx +128 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.tsx +110 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.types.ts +1 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.utils.ts +114 -0
- package/src/presentation/ui/legacy-country-input.tsx +171 -0
- package/src/presentation/ui/legacy-gender-input.tsx +22 -0
- package/src/presentation/ui/legacy-input.tsx +106 -0
- package/src/presentation/ui/legacy-phone-input.tsx +213 -0
- package/src/presentation/ui/legacy-select-input.tsx +114 -0
- package/src/presentation/ui/legacy-text-area.tsx +111 -0
- package/src/presentation/ui/list-items.tsx +59 -0
- package/src/presentation/ui/marker.tsx +69 -0
- package/src/presentation/ui/media-player/index.tsx +12 -0
- package/src/presentation/ui/media-player/media-player.context.tsx +36 -0
- package/src/presentation/ui/media-player/media-player.tsx +167 -0
- package/src/presentation/ui/media-player/player-controls.tsx +207 -0
- package/src/presentation/ui/media-player/players/audio-player.tsx +78 -0
- package/src/presentation/ui/media-player/players/index.tsx +4 -0
- package/src/presentation/ui/media-player/players/video-player.tsx +193 -0
- package/src/presentation/ui/media-player/players/voice-note-player.tsx +108 -0
- package/src/presentation/ui/media-player/use-media-player.hook.ts +263 -0
- package/src/presentation/ui/menubar.tsx +281 -0
- package/src/presentation/ui/message.tsx +92 -0
- package/src/presentation/ui/navigation-menu.tsx +172 -0
- package/src/presentation/ui/pagination.tsx +129 -0
- package/src/presentation/ui/popover.tsx +89 -0
- package/src/presentation/ui/progress.tsx +31 -0
- package/src/presentation/ui/resizable.tsx +50 -0
- package/src/presentation/ui/select.tsx +192 -0
- package/src/presentation/ui/separator.tsx +28 -0
- package/src/presentation/ui/sheet.tsx +147 -0
- package/src/presentation/ui/sidebar.tsx +702 -0
- package/src/presentation/ui/skeleton.tsx +13 -0
- package/src/presentation/ui/slide-to-confirm.tsx +129 -0
- package/src/presentation/ui/slider.tsx +59 -0
- package/src/presentation/ui/sonner.tsx +58 -0
- package/src/presentation/ui/switch.tsx +33 -0
- package/src/presentation/ui/table.tsx +116 -0
- package/src/presentation/ui/tabs.tsx +90 -0
- package/src/presentation/ui/text-gradient.tsx +84 -0
- package/src/presentation/ui/textarea.tsx +18 -0
- package/src/presentation/ui/timeline-steps.tsx +235 -0
- package/src/presentation/ui/toggle-group.tsx +89 -0
- package/src/presentation/ui/toggle.tsx +47 -0
- package/src/presentation/ui/tooltip.tsx +57 -0
- package/src/presentation/uploading/index.tsx +3 -0
- package/src/presentation/uploading/media-upload-field.tsx +152 -0
- package/src/presentation/uploading/storage-media.tsx +210 -0
- package/src/styles.css +403 -0
- package/src/themes.css +1038 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {ModuleDeclarationInterface, ModuleInstanceInterface} from "../domain/entities/module.interface";
|
|
2
|
+
import {useModuleStore} from "../infrastructure/stores/module.store";
|
|
3
|
+
|
|
4
|
+
export class ModuleInstance implements ModuleInstanceInterface {
|
|
5
|
+
|
|
6
|
+
protected declaration!: ModuleDeclarationInterface;
|
|
7
|
+
|
|
8
|
+
constructor(public readonly identifier: string) {
|
|
9
|
+
this.initialize();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
protected initialize() {
|
|
13
|
+
const {modules} = useModuleStore.getState();
|
|
14
|
+
const find = modules.find(
|
|
15
|
+
module => module.key === this.identifier || module.identifier === this.identifier
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (!find)
|
|
19
|
+
throw new Error(`Module with identifier ${this.identifier} not found`);
|
|
20
|
+
|
|
21
|
+
this.declaration = find;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getOption<K extends keyof ModuleDeclarationInterface>(key: K): ModuleDeclarationInterface[K] {
|
|
25
|
+
return this.declaration[key];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get options(): ModuleDeclarationInterface {
|
|
29
|
+
return this.declaration;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setOption<K extends keyof ModuleDeclarationInterface>(key: K, value: ModuleDeclarationInterface[K]): this {
|
|
33
|
+
this.declaration[key] = value;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import {ApiService} from "../../infrastructure/utilities/api-service";
|
|
2
|
+
import {AuthUserService} from "./auth-user.service";
|
|
3
|
+
import {
|
|
4
|
+
type CreateUserAccountInterface,
|
|
5
|
+
type CreateUserSessionInterface
|
|
6
|
+
} from "../../domain/typing/session.interface";
|
|
7
|
+
import {
|
|
8
|
+
UserAuthResponseInterface,
|
|
9
|
+
UserAuthSessionCheckingResponseInterface
|
|
10
|
+
} from "../../domain/entities/user-auth.interface";
|
|
11
|
+
import {FetchResponseInterface} from "../../domain/typing/response";
|
|
12
|
+
import {AuthConfig} from "../../domain/config/auth.config";
|
|
13
|
+
import type {
|
|
14
|
+
AuthFactor,
|
|
15
|
+
AuthMethod,
|
|
16
|
+
AuthorizeClient,
|
|
17
|
+
AuthorizeParams,
|
|
18
|
+
AuthorizePasskeyOptions,
|
|
19
|
+
AuthorizedApplication,
|
|
20
|
+
ConsentResolution,
|
|
21
|
+
CreateOAuthClientInput,
|
|
22
|
+
EnrollTotpResponse,
|
|
23
|
+
MfaChallengeResponse,
|
|
24
|
+
MfaVerifyResponse,
|
|
25
|
+
OAuthClient,
|
|
26
|
+
OAuthScope,
|
|
27
|
+
OtpChannel,
|
|
28
|
+
OtpCreateResponse,
|
|
29
|
+
RecoveryCodesResponse,
|
|
30
|
+
ScopeDescriptor,
|
|
31
|
+
UserInfo,
|
|
32
|
+
WebAuthnOptions,
|
|
33
|
+
} from "../../domain/typing/auth-oauth.types";
|
|
34
|
+
|
|
35
|
+
/** Décapsule le payload `data` de l'enveloppe Raiton `{message, data, status}`. */
|
|
36
|
+
async function unwrap<T>(promise: Promise<{data: FetchResponseInterface<T>}>): Promise<T> {
|
|
37
|
+
const response = await promise;
|
|
38
|
+
return response?.data?.data as T;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Décodage base64url → ArrayBuffer (WebAuthn exige des BufferSource côté navigateur). */
|
|
42
|
+
function base64UrlToBuffer(base64Url: string): ArrayBuffer {
|
|
43
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
44
|
+
const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), '=');
|
|
45
|
+
const binary = atob(padded);
|
|
46
|
+
const bytes = new Uint8Array(binary.length);
|
|
47
|
+
for (let i = 0; i < binary.length; i++) {
|
|
48
|
+
bytes[i] = binary.charCodeAt(i);
|
|
49
|
+
}
|
|
50
|
+
return bytes.buffer;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Convertit un BufferSource WebAuthn en tableau de bytes (sérialisable en JSON pour l'API). */
|
|
54
|
+
export function webauthnBytes(value: ArrayBufferView | ArrayBuffer | null | undefined): number[] | undefined {
|
|
55
|
+
if (value == null) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const buffer = value instanceof ArrayBuffer
|
|
59
|
+
? value
|
|
60
|
+
: (value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength) as ArrayBuffer);
|
|
61
|
+
return Array.from(new Uint8Array(buffer));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Prépare les options WebAuthn reçues de l'API pour `navigator.credentials` (challenge → ArrayBuffer). */
|
|
65
|
+
function prepareWebAuthnOptions<T extends WebAuthnOptions>(options: T): T {
|
|
66
|
+
if (typeof options.challenge === 'string' && options.challenge.length > 0) {
|
|
67
|
+
options.challenge = base64UrlToBuffer(options.challenge);
|
|
68
|
+
}
|
|
69
|
+
if (options.user && typeof options.user.id === 'string' && options.user.id.length > 0) {
|
|
70
|
+
options.user.id = new TextEncoder().encode(options.user.id);
|
|
71
|
+
}
|
|
72
|
+
return options;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class AuthApiService extends ApiService {
|
|
76
|
+
static async fetchAvailableSessions() {
|
|
77
|
+
// Les tokens/infos de l'utilisateur doivent être disponibles en local
|
|
78
|
+
// avant de vérifier la validité de la session.
|
|
79
|
+
await AuthUserService.ready();
|
|
80
|
+
const token = AuthUserService.getToken();
|
|
81
|
+
const device = AuthUserService.getDevice();
|
|
82
|
+
|
|
83
|
+
if (!token) return undefined;
|
|
84
|
+
return this.post<FetchResponseInterface<UserAuthSessionCheckingResponseInterface>>(`/auth/sessions`, {
|
|
85
|
+
token,
|
|
86
|
+
device
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static async signIn(payload: CreateUserSessionInterface & { identifierType?: 'email' | 'phone' | 'username' }) {
|
|
91
|
+
const { identifierType, ...rest } = payload;
|
|
92
|
+
const body: Record<string, string | undefined> = { password: rest.password };
|
|
93
|
+
|
|
94
|
+
if (identifierType === 'email') {
|
|
95
|
+
body.email = rest.username;
|
|
96
|
+
} else if (identifierType === 'phone') {
|
|
97
|
+
body.phone = rest.username;
|
|
98
|
+
body.prefix = rest.prefix;
|
|
99
|
+
} else {
|
|
100
|
+
body.username = rest.username;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return await this.post<FetchResponseInterface<UserAuthResponseInterface>>(`${AuthConfig.routes.login}`, body)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static async signUp(payload: CreateUserAccountInterface) {
|
|
107
|
+
return await this.post<FetchResponseInterface<UserAuthResponseInterface>>(`${AuthConfig.routes.register}`, payload)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Vérifie le mot de passe de l'utilisateur actuellement connecté (session valide).
|
|
112
|
+
* Aucune nouvelle session n'est créée : utilisé notamment pour déverrouiller l'écran.
|
|
113
|
+
*/
|
|
114
|
+
static async verifyPassword(password: string) {
|
|
115
|
+
return await this.post<FetchResponseInterface<{valid: boolean}>>('/auth/verify-password', {password})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static async checkPhone(phone: string) {
|
|
119
|
+
return await this.get<FetchResponseInterface<any>>(`${AuthConfig.routes.verifyPhone}`, {phone})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static async verifyPhone(payload: { phone: string; code: string }) {
|
|
123
|
+
return await this.post<FetchResponseInterface<any>>(`${AuthConfig.routes.verifyPhone}`, payload)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* ----------------------------- MFA / challenge ----------------------- */
|
|
127
|
+
|
|
128
|
+
/** Déclenche un challenge MFA et liste les facteurs activés. */
|
|
129
|
+
static async mfaChallenge(): Promise<MfaChallengeResponse> {
|
|
130
|
+
return unwrap(this.post<FetchResponseInterface<MfaChallengeResponse>>('/mfa/challenge', {}));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static async listFactors(): Promise<AuthFactor[]> {
|
|
134
|
+
const res = await this.mfaChallenge();
|
|
135
|
+
return res.factors ?? [];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* ----------------------------- TOTP ---------------------------------- */
|
|
139
|
+
|
|
140
|
+
static async totpEnroll(issuer?: string): Promise<EnrollTotpResponse> {
|
|
141
|
+
return unwrap(this.post<FetchResponseInterface<EnrollTotpResponse>>('/mfa/totp/enroll', {issuer}));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
static async totpVerify(code: string): Promise<MfaVerifyResponse> {
|
|
145
|
+
return unwrap(this.post<FetchResponseInterface<MfaVerifyResponse>>('/mfa/totp/verify', {code}));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* ----------------------------- WebAuthn ------------------------------ */
|
|
149
|
+
|
|
150
|
+
static async webauthnRegisterOptions(deviceName?: string): Promise<WebAuthnOptions> {
|
|
151
|
+
const options = await unwrap(this.post<FetchResponseInterface<WebAuthnOptions>>('/mfa/webauthn/register/options', {deviceName}));
|
|
152
|
+
return prepareWebAuthnOptions(options);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static async webauthnRegisterVerify(attestationResponse: unknown): Promise<MfaVerifyResponse> {
|
|
156
|
+
return unwrap(this.post<FetchResponseInterface<MfaVerifyResponse>>('/mfa/webauthn/register/verify', {attestationResponse}));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static async webauthnAuthnOptions(): Promise<WebAuthnOptions> {
|
|
160
|
+
const options = await unwrap(this.post<FetchResponseInterface<WebAuthnOptions>>('/mfa/webauthn/authenticate/options', {}));
|
|
161
|
+
return prepareWebAuthnOptions(options);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
static async webauthnAuthnVerify(assertionResponse: unknown): Promise<MfaVerifyResponse> {
|
|
165
|
+
return unwrap(this.post<FetchResponseInterface<MfaVerifyResponse>>('/mfa/webauthn/authenticate/verify', {assertionResponse}));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* ----------------------------- Récupération -------------------------- */
|
|
169
|
+
|
|
170
|
+
static async recoveryCodesGenerate(): Promise<RecoveryCodesResponse> {
|
|
171
|
+
return unwrap(this.post<FetchResponseInterface<RecoveryCodesResponse>>('/mfa/recovery-codes/generate', {}));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static async recoveryVerify(code: string): Promise<MfaVerifyResponse> {
|
|
175
|
+
return unwrap(this.post<FetchResponseInterface<MfaVerifyResponse>>('/mfa/recovery/verify', {code}));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* ----------------------------- OTP (email / SMS) --------------------- */
|
|
179
|
+
|
|
180
|
+
static async otpRequest(channel: OtpChannel, identifier: string): Promise<OtpCreateResponse> {
|
|
181
|
+
return unwrap(this.post<FetchResponseInterface<OtpCreateResponse>>('/otp/create', {
|
|
182
|
+
...(channel === 'email' ? {email: identifier} : {phone: identifier}),
|
|
183
|
+
channel: channel === 'email' ? 'EMAIL' : 'SMS',
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
static async otpValidate(channel: OtpChannel, identifier: string, code: string): Promise<MfaVerifyResponse> {
|
|
188
|
+
return unwrap(this.post<FetchResponseInterface<MfaVerifyResponse>>('/otp/validate', {
|
|
189
|
+
...(channel === 'email' ? {email: identifier} : {phone: identifier}),
|
|
190
|
+
code,
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* ----------------------------- Consentement OAuth -------------------- */
|
|
195
|
+
|
|
196
|
+
static async describeAuthorize(params: AuthorizeParams): Promise<{client: AuthorizeClient; requestedScopes: ScopeDescriptor[]; alreadyAuthorized: boolean; canConsent: boolean}> {
|
|
197
|
+
return unwrap(this.post<FetchResponseInterface<{client: AuthorizeClient; requestedScopes: ScopeDescriptor[]; alreadyAuthorized: boolean; canConsent: boolean}>>('/oauth/authorize/describe', params));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
static async authorizeDecision(params: AuthorizeParams & {approved: boolean}): Promise<ConsentResolution> {
|
|
201
|
+
return unwrap(this.post<FetchResponseInterface<ConsentResolution>>('/oauth/authorize', params));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
static async authorizeVerify(params: AuthorizeParams & {code: string}): Promise<ConsentResolution> {
|
|
205
|
+
return unwrap(this.post<FetchResponseInterface<ConsentResolution>>('/oauth/authorize/verify', params));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
static async sendOtp(): Promise<{sent: boolean; channel: string}> {
|
|
209
|
+
return unwrap(this.post<FetchResponseInterface<{sent: boolean; channel: string}>>('/oauth/authorize/otp', {}));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
static async passkeyOptions(): Promise<AuthorizePasskeyOptions> {
|
|
213
|
+
const options = await unwrap(this.get<FetchResponseInterface<AuthorizePasskeyOptions>>('/oauth/authorize/passkey/options'));
|
|
214
|
+
if (typeof options.challenge === 'string' && options.challenge.length > 0) {
|
|
215
|
+
options.challenge = base64UrlToBuffer(options.challenge);
|
|
216
|
+
}
|
|
217
|
+
return options;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
static async enablePasskey(): Promise<{enabled: boolean}> {
|
|
221
|
+
return unwrap(this.post<FetchResponseInterface<{enabled: boolean}>>('/oauth/authorize/passkey/enable', {}));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
static async passkeyVerify(params: AuthorizeParams & {credentialId: string; assertionResponse: unknown}): Promise<ConsentResolution> {
|
|
225
|
+
return unwrap(this.post<FetchResponseInterface<ConsentResolution>>('/oauth/authorize/passkey/verify', params));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* --------------------------- Apps autorisées ------------------------- */
|
|
229
|
+
|
|
230
|
+
static async userinfo(): Promise<UserInfo> {
|
|
231
|
+
return unwrap(this.get<FetchResponseInterface<UserInfo>>('/oauth/userinfo'));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
static async listConsents(): Promise<AuthorizedApplication[]> {
|
|
235
|
+
return unwrap(this.get<FetchResponseInterface<AuthorizedApplication[]>>('/oauth/user/consents'));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
static async revokeConsent(consentId: string): Promise<void> {
|
|
239
|
+
return unwrap(this.delete<FetchResponseInterface<void>>(`/oauth/user/consents/${consentId}`));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* ----------------------- Catalogue des scopes ----------------------- */
|
|
243
|
+
|
|
244
|
+
static async listScopes(): Promise<OAuthScope[]> {
|
|
245
|
+
return unwrap(this.get<FetchResponseInterface<OAuthScope[]>>('/oauth/scopes'));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static async createScope(payload: Partial<OAuthScope> & {name: string}): Promise<OAuthScope> {
|
|
249
|
+
return unwrap(this.post<FetchResponseInterface<OAuthScope>>('/oauth/scopes', payload));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
static async updateScope(id: string, payload: Partial<OAuthScope>): Promise<OAuthScope> {
|
|
253
|
+
return unwrap(this.put<FetchResponseInterface<OAuthScope>>(`/oauth/scopes/${id}`, payload));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
static async deleteScope(id: string): Promise<void> {
|
|
257
|
+
return unwrap(this.delete<FetchResponseInterface<void>>(`/oauth/scopes/${id}`));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/* --------------------- Applications pré-enregistrées ----------------- */
|
|
261
|
+
|
|
262
|
+
static async listOAuthClients(): Promise<OAuthClient[]> {
|
|
263
|
+
return unwrap(this.get<FetchResponseInterface<OAuthClient[]>>('/oauth/clients'));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
static async getOAuthClient(id: string): Promise<OAuthClient> {
|
|
267
|
+
return unwrap(this.get<FetchResponseInterface<OAuthClient>>(`/oauth/clients/${id}`));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
static async createOAuthClient(payload: CreateOAuthClientInput): Promise<OAuthClient> {
|
|
271
|
+
return unwrap(this.post<FetchResponseInterface<OAuthClient>>('/oauth/clients', payload));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
static async updateOAuthClient(id: string, payload: Partial<CreateOAuthClientInput> & {status?: string}): Promise<OAuthClient> {
|
|
275
|
+
return unwrap(this.put<FetchResponseInterface<OAuthClient>>(`/oauth/clients/${id}`, payload));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
static async deleteOAuthClient(id: string): Promise<void> {
|
|
279
|
+
return unwrap(this.delete<FetchResponseInterface<void>>(`/oauth/clients/${id}`));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* --------------------------- Méthodes MFA ---------------------------- */
|
|
283
|
+
|
|
284
|
+
static async listMethods(): Promise<AuthMethod[]> {
|
|
285
|
+
return unwrap(this.get<FetchResponseInterface<AuthMethod[]>>('/mfa/methods'));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
static async removeMethod(methodId: string): Promise<void> {
|
|
289
|
+
return unwrap(this.delete<FetchResponseInterface<void>>(`/mfa/methods/${methodId}`));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import {CacheStorageCapability} from "../../infrastructure/capabilities/cache-storage/capability";
|
|
4
|
+
import {AuthCacheInterface} from "../../domain/typing/auth-caches";
|
|
5
|
+
import {CacheStorageType} from "../../infrastructure/capabilities/cache-storage/enum";
|
|
6
|
+
import {UserInterface} from "../../domain/entities/user.interface";
|
|
7
|
+
import {UserAuthResponseInterface} from "../../domain/entities/user-auth.interface";
|
|
8
|
+
import {OrganizationInterface} from "../../domain/entities/organization.interface";
|
|
9
|
+
import {AuthConfig} from "../../domain/config/auth.config";
|
|
10
|
+
|
|
11
|
+
const instance = new CacheStorageCapability<AuthCacheInterface>(AuthConfig.storages.sessionKey, CacheStorageType.LOCAL);
|
|
12
|
+
|
|
13
|
+
const setCookie = (name: string, value: string, days = 7) => {
|
|
14
|
+
if (typeof document === 'undefined') return;
|
|
15
|
+
const date = new Date();
|
|
16
|
+
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
17
|
+
const expires = "; expires=" + date.toUTCString();
|
|
18
|
+
document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/; SameSite=Strict";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const deleteCookie = (name: string) => {
|
|
22
|
+
if (typeof document === 'undefined') return;
|
|
23
|
+
document.cookie = name + '=; Max-Age=-99999999; path=/;';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class AuthUserService {
|
|
27
|
+
|
|
28
|
+
/** Attend que les données locales (token, user, …) soient chargées avant toute lecture. */
|
|
29
|
+
static async ready(): Promise<AuthCacheInterface> {
|
|
30
|
+
return instance.ready();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static getUser(): UserInterface | null {
|
|
34
|
+
return instance.get('user') ?? null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static getToken(): string | null {
|
|
38
|
+
return instance.get('token') ?? null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static getDevice(): string | null {
|
|
42
|
+
return instance.get('device') ?? null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static getOrganizations(): OrganizationInterface[] {
|
|
46
|
+
return instance.get('organizations') ?? [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static getCurrentOrganization(): OrganizationInterface | null {
|
|
50
|
+
return instance.get('currentOrganization') ?? null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static getApiKey(): string | null {
|
|
54
|
+
return instance.get('apiKey') ?? null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static isAuthenticated(): boolean {
|
|
58
|
+
return !!this.getToken();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static async setUser(user: UserInterface) {
|
|
62
|
+
await instance.set('user', user).save();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static async setToken(token: string) {
|
|
66
|
+
await instance.set('token', token).save();
|
|
67
|
+
setCookie('token', token);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async setDevice(device: string) {
|
|
71
|
+
await instance.set('device', device).save();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static async setOrganizations(organizations: OrganizationInterface[]) {
|
|
75
|
+
await instance.set('organizations', organizations).save();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static async setCurrentOrganization(organization: OrganizationInterface) {
|
|
79
|
+
await instance.set('currentOrganization', organization).save();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static async setApiKey(apiKey: string) {
|
|
83
|
+
await instance.set('apiKey', apiKey).save();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static async setSession(payload: UserAuthResponseInterface) {
|
|
87
|
+
const {user, token, device, organizations} = payload;
|
|
88
|
+
instance
|
|
89
|
+
.set('user', user)
|
|
90
|
+
.set('token', token)
|
|
91
|
+
.set('device', device)
|
|
92
|
+
.set('organizations', organizations);
|
|
93
|
+
|
|
94
|
+
await instance.save();
|
|
95
|
+
setCookie('token', token);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static async clear() {
|
|
99
|
+
await instance.clear().save();
|
|
100
|
+
deleteCookie('token');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static getCsrfToken(): string | null {
|
|
104
|
+
if (typeof document === 'undefined') return null;
|
|
105
|
+
const match = document.cookie.match(/(?:^|;\s*)_csrf=([^;]*)/);
|
|
106
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @liorian/sdk/application/service — API / application services.
|
|
2
|
+
export * from "./auth-api-service";
|
|
3
|
+
export * from "./auth-user.service";
|
|
4
|
+
export * from "./module-activation-api.service";
|
|
5
|
+
export * from "./storefront-api.service";
|
|
6
|
+
export * from "./notifications-api-service";
|
|
7
|
+
export * from "./notifications-push.service";
|
|
8
|
+
export * from "./notifications-socket-service";
|
|
9
|
+
export * from "./organizations-api-service";
|
|
10
|
+
export * from "./otp-api-service";
|
|
11
|
+
export * from "./storage-api-service";
|
|
12
|
+
export * from "./user-preferences-api.service";
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {ApiService} from "../../infrastructure/utilities/api-service";
|
|
2
|
+
import {FetchResponseInterface} from "../../domain/typing/response";
|
|
3
|
+
import {
|
|
4
|
+
ActivateModulePayloadInterface,
|
|
5
|
+
ModuleActivationInterface,
|
|
6
|
+
ModuleStoreActivationResultInterface,
|
|
7
|
+
ModuleStoreConfigInterface,
|
|
8
|
+
ModuleStoreSyncPayloadInterface,
|
|
9
|
+
ModuleStoreSyncResultInterface,
|
|
10
|
+
ModuleUsageAnalyticsInterface,
|
|
11
|
+
ModuleUsageRecordPayloadInterface,
|
|
12
|
+
ValidateActivationResponseInterface
|
|
13
|
+
} from "../../domain/entities/module-activation.interface";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Service API pour l'activation des modules (runtime cœur).
|
|
17
|
+
*
|
|
18
|
+
* Cible `liorian-api-core` (base `/module-activation`) : activation,
|
|
19
|
+
* validation, clés sérielles, synchronisation et analytics d'usage.
|
|
20
|
+
* Le catalogue public est porté par {@link StorefrontApiService} (`/catalog`).
|
|
21
|
+
*/
|
|
22
|
+
export class ModuleActivationApiService extends ApiService {
|
|
23
|
+
|
|
24
|
+
/** Activer un module pour une organisation */
|
|
25
|
+
static async activateModule(organizationId: string, payload: ActivateModulePayloadInterface) {
|
|
26
|
+
return await this.post<FetchResponseInterface<ModuleStoreActivationResultInterface>>(
|
|
27
|
+
`/module-activation/organizations/${organizationId}/activate`,
|
|
28
|
+
payload
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Valider l'activation d'un module pour une organisation */
|
|
33
|
+
static async validateActivation(organizationId: string, moduleIdentifier: string) {
|
|
34
|
+
return await this.get<FetchResponseInterface<ValidateActivationResponseInterface>>(
|
|
35
|
+
`/module-activation/organizations/${organizationId}/modules/${moduleIdentifier}/validate`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Lister les modules activés pour une organisation */
|
|
40
|
+
static async getOrganizationModules(organizationId: string) {
|
|
41
|
+
return await this.get<FetchResponseInterface<ModuleActivationInterface[]>>(
|
|
42
|
+
`/module-activation/organizations/${organizationId}/modules`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Désactiver un module pour une organisation */
|
|
47
|
+
static async deactivateModule(organizationId: string, moduleIdentifier: string) {
|
|
48
|
+
return await this.delete(
|
|
49
|
+
`/module-activation/organizations/${organizationId}/modules/${moduleIdentifier}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Lister les clés série d'un module */
|
|
54
|
+
static async getSerialKeys(moduleIdentifier: string) {
|
|
55
|
+
return await this.get(`/module-activation/modules/${moduleIdentifier}/serial-keys`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Créer une clé série pour un module (SuperAdmin) */
|
|
59
|
+
static async createSerialKey(moduleIdentifier: string) {
|
|
60
|
+
return await this.post(`/module-activation/modules/${moduleIdentifier}/serial-keys`, {});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Supprimer une clé série (SuperAdmin) */
|
|
64
|
+
static async deleteSerialKey(keyId: string) {
|
|
65
|
+
return await this.delete(`/module-activation/serial-keys/${keyId}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Récupérer la configuration d'un module pour une organisation */
|
|
69
|
+
static async getModuleConfig(organizationId: string, moduleIdentifier: string) {
|
|
70
|
+
return await this.get<FetchResponseInterface<ModuleStoreConfigInterface>>(
|
|
71
|
+
`/module-activation/organizations/${organizationId}/modules/${moduleIdentifier}/config`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Sauvegarder la configuration d'un module pour une organisation */
|
|
76
|
+
static async saveModuleConfig(organizationId: string, moduleIdentifier: string, settings: Record<string, string>) {
|
|
77
|
+
return await this.post<FetchResponseInterface<ModuleStoreConfigInterface>>(
|
|
78
|
+
`/module-activation/organizations/${organizationId}/modules/${moduleIdentifier}/config`,
|
|
79
|
+
{settings}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Synchroniser l'état local des modules avec le backend */
|
|
84
|
+
static async syncModules(organizationId: string, payload: ModuleStoreSyncPayloadInterface) {
|
|
85
|
+
return await this.post<FetchResponseInterface<ModuleStoreSyncResultInterface>>(
|
|
86
|
+
`/module-activation/organizations/${organizationId}/modules/sync`,
|
|
87
|
+
payload
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Enregistrer l'usage d'un module (temps + fréquence) — respecte le consentement de partage */
|
|
92
|
+
static async recordModuleUsage(organizationId: string, payload: ModuleUsageRecordPayloadInterface) {
|
|
93
|
+
return await this.post<FetchResponseInterface<{consented: boolean; tracked: boolean}>>(
|
|
94
|
+
`/module-activation/analytics/usage`,
|
|
95
|
+
payload
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Récupérer les analytics d'usage des modules (scope : organization | user) */
|
|
100
|
+
static async getModuleUsageAnalytics(organizationId: string, scope: 'organization' | 'user' = 'organization') {
|
|
101
|
+
return await this.get<FetchResponseInterface<ModuleUsageAnalyticsInterface>>(
|
|
102
|
+
`/module-activation/analytics/usage?scope=${scope}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {ApiService} from "../../infrastructure/utilities/api-service";
|
|
2
|
+
import {PaginationWithSearchOptions} from "../../domain/typing/response";
|
|
3
|
+
|
|
4
|
+
export interface PushSubscriptionKeys {
|
|
5
|
+
p256dh: string;
|
|
6
|
+
auth: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PushSubscriptionPayload {
|
|
10
|
+
endpoint: string;
|
|
11
|
+
keys: PushSubscriptionKeys;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class NotificationsApiService extends ApiService {
|
|
15
|
+
static async getAll(options?: PaginationWithSearchOptions & { read?: boolean }) {
|
|
16
|
+
return await this.get('/notifications/', options);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static async getAllByOrganization(id: string, options?: PaginationWithSearchOptions & { read?: boolean }) {
|
|
20
|
+
return await this.get(`/notifications/organizations/${id}`, options);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static async markAsRead(id: string) {
|
|
24
|
+
return await this.patch(`/notifications/${id}/read`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static async getAnalytics() {
|
|
28
|
+
return await this.get('/notifications/analytics');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static async savePushSubscription(subscription: PushSubscriptionPayload) {
|
|
32
|
+
return await this.post('/notifications/push-subscription', subscription);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static async removePushSubscription(endpoint: string) {
|
|
36
|
+
return await this.delete('/notifications/push-subscription', {endpoint});
|
|
37
|
+
}
|
|
38
|
+
}
|