@vc-shell/framework 1.1.91-alpha.5 → 1.1.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +2769 -1414
  2. package/core/api/platform.ts +9883 -9883
  3. package/core/composables/useNotifications/index.ts +1 -32
  4. package/core/composables/useSettings/index.ts +3 -8
  5. package/core/composables/useUser/index.ts +171 -74
  6. package/core/composables/useUserManagement/index.ts +25 -67
  7. package/core/interceptors/index.ts +56 -19
  8. package/core/plugins/signalR/index.ts +1 -27
  9. package/core/types/index.ts +0 -2
  10. package/dist/core/api/platform.d.ts +1 -1
  11. package/dist/core/api/platform.d.ts.map +1 -1
  12. package/dist/core/composables/useNotifications/index.d.ts.map +1 -1
  13. package/dist/core/composables/useSettings/index.d.ts.map +1 -1
  14. package/dist/core/composables/useUser/index.d.ts +9 -18
  15. package/dist/core/composables/useUser/index.d.ts.map +1 -1
  16. package/dist/core/composables/useUserManagement/index.d.ts +7 -7
  17. package/dist/core/composables/useUserManagement/index.d.ts.map +1 -1
  18. package/dist/core/interceptors/index.d.ts +1 -2
  19. package/dist/core/interceptors/index.d.ts.map +1 -1
  20. package/dist/core/plugins/signalR/index.d.ts +0 -2
  21. package/dist/core/plugins/signalR/index.d.ts.map +1 -1
  22. package/dist/core/types/index.d.ts +1 -1
  23. package/dist/core/types/index.d.ts.map +1 -1
  24. package/dist/framework.js +5682 -5832
  25. package/dist/index.css +1 -1
  26. package/dist/index.d.ts +0 -8
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/injection-keys.d.ts +1 -2
  29. package/dist/injection-keys.d.ts.map +1 -1
  30. package/dist/shared/components/app-switcher/composables/useAppSwitcher/index.d.ts.map +1 -1
  31. package/dist/shared/components/sign-in/useExternalProvider.d.ts +1 -1
  32. package/dist/shared/components/sign-in/useExternalProvider.d.ts.map +1 -1
  33. package/dist/shared/modules/dynamic/helpers/nodeBuilder.d.ts.map +1 -1
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
  36. package/dist/vendor-dompurify-BuxjWxA2.js +553 -0
  37. package/dist/{vendor-prosemirror-gapcursor-K-Pj0iVP.js → vendor-prosemirror-gapcursor-CoNzHXkd.js} +27 -24
  38. package/dist/{vendor-tiptap-core-B000Ay3n.js → vendor-tiptap-core-D6CfVeU0.js} +1838 -1502
  39. package/dist/{vendor-tiptap-extension-blockquote-CHW3QVCH.js → vendor-tiptap-extension-blockquote-C__lIvqD.js} +19 -6
  40. package/dist/{vendor-tiptap-extension-bold-DsNXR7l5.js → vendor-tiptap-extension-bold-DF2R0mPF.js} +13 -10
  41. package/dist/{vendor-tiptap-extension-code-block-DYMOFxJc.js → vendor-tiptap-extension-code-block-B52VzS4M.js} +34 -16
  42. package/dist/{vendor-tiptap-extension-code-BXPfZcyf.js → vendor-tiptap-extension-code-f7eg00IH.js} +11 -8
  43. package/dist/vendor-tiptap-extension-document-UgQIRckz.js +12 -0
  44. package/dist/{vendor-tiptap-extension-hard-break-DfxtqTYW.js → vendor-tiptap-extension-hard-break-CYVqzABZ.js} +11 -9
  45. package/dist/{vendor-tiptap-extension-heading-BqN9fEEm.js → vendor-tiptap-extension-heading-BWwbIXKs.js} +11 -5
  46. package/dist/{vendor-tiptap-extension-horizontal-rule-Dl1wmLAo.js → vendor-tiptap-extension-horizontal-rule-DjIwBCkJ.js} +14 -11
  47. package/dist/{vendor-tiptap-extension-image-Cv28QlbA.js → vendor-tiptap-extension-image-CSFiALl1.js} +18 -8
  48. package/dist/{vendor-tiptap-extension-italic-B3WETSCz.js → vendor-tiptap-extension-italic-S1BFBPoJ.js} +15 -12
  49. package/dist/{vendor-tiptap-extension-link-CTWD6W1U.js → vendor-tiptap-extension-link-BII63Ad6.js} +101 -90
  50. package/dist/vendor-tiptap-extension-list-BiUARt_K.js +707 -0
  51. package/dist/vendor-tiptap-extension-paragraph-C7nR_Mg3.js +41 -0
  52. package/dist/vendor-tiptap-extension-placeholder-BoHVyYJs.js +1 -0
  53. package/dist/vendor-tiptap-extension-strike-D13ERA3E.js +64 -0
  54. package/dist/vendor-tiptap-extension-table-DsqCGn0S.js +368 -0
  55. package/dist/vendor-tiptap-extension-table-cell-qeLCoF6c.js +1 -0
  56. package/dist/vendor-tiptap-extension-table-header-qeLCoF6c.js +1 -0
  57. package/dist/vendor-tiptap-extension-table-row-qeLCoF6c.js +1 -0
  58. package/dist/vendor-tiptap-extension-text-D2Ap05bS.js +13 -0
  59. package/dist/{vendor-tiptap-extension-text-style-BiLsi9B8.js → vendor-tiptap-extension-text-style-6WFGdn9L.js} +1 -1
  60. package/dist/{vendor-tiptap-extension-underline-Bz_pv2E0.js → vendor-tiptap-extension-underline-CiLvGtsw.js} +29 -4
  61. package/dist/{vendor-tiptap-extensions-Crh_nh74.js → vendor-tiptap-extensions-0qImmpYJ.js} +88 -87
  62. package/dist/{vendor-tiptap-markdown-bGlioql8.js → vendor-tiptap-markdown-Dh06r1Sk.js} +1 -1
  63. package/dist/{vendor-tiptap-starter-kit-B3fY431M.js → vendor-tiptap-starter-kit-CQMmSEis.js} +17 -17
  64. package/dist/{vendor-tiptap-vue-3-CqWn44-V.js → vendor-tiptap-vue-3-B0kPYa3w.js} +1 -1
  65. package/dist/{vendor-vueuse-components-sgKpNzof.js → vendor-vueuse-components-B0zqjNRW.js} +1 -1
  66. package/dist/{vendor-vueuse-core-D0cN7FqY.js → vendor-vueuse-core-CYgwn-B2.js} +10 -10
  67. package/dist/{vendor-vueuse-shared-Pt0UEStA.js → vendor-vueuse-shared-B_uDJJ6V.js} +19 -19
  68. package/package.json +5 -7
  69. package/shared/components/app-switcher/components/vc-app-switcher/vc-app-switcher.vue +2 -2
  70. package/shared/components/app-switcher/composables/useAppSwitcher/index.ts +1 -15
  71. package/shared/components/sign-in/useExternalProvider.ts +1 -11
  72. package/shared/modules/dynamic/helpers/nodeBuilder.ts +3 -11
  73. package/ui/components/organisms/vc-app/vc-app.vue +2 -20
  74. package/core/providers/README.md +0 -176
  75. package/core/providers/auth-provider-manager.ts +0 -74
  76. package/core/providers/auth-provider-utils.ts +0 -26
  77. package/core/providers/example-custom-auth-provider.ts +0 -162
  78. package/core/providers/index.ts +0 -3
  79. package/core/providers/platform-auth-provider.ts +0 -207
  80. package/core/types/auth-provider.ts +0 -40
  81. package/dist/core/providers/auth-provider-manager.d.ts +0 -34
  82. package/dist/core/providers/auth-provider-manager.d.ts.map +0 -1
  83. package/dist/core/providers/auth-provider-utils.d.ts +0 -17
  84. package/dist/core/providers/auth-provider-utils.d.ts.map +0 -1
  85. package/dist/core/providers/example-custom-auth-provider.d.ts +0 -45
  86. package/dist/core/providers/example-custom-auth-provider.d.ts.map +0 -1
  87. package/dist/core/providers/index.d.ts +0 -3
  88. package/dist/core/providers/index.d.ts.map +0 -1
  89. package/dist/core/providers/platform-auth-provider.d.ts +0 -34
  90. package/dist/core/providers/platform-auth-provider.d.ts.map +0 -1
  91. package/dist/core/types/auth-provider.d.ts +0 -27
  92. package/dist/core/types/auth-provider.d.ts.map +0 -1
  93. package/dist/vendor-dompurify-C-JbJ3KX.js +0 -536
  94. package/dist/vendor-tiptap-extension-document-Y-jQl_8Q.js +0 -9
  95. package/dist/vendor-tiptap-extension-list-Da9Xfgwa.js +0 -420
  96. package/dist/vendor-tiptap-extension-paragraph-CSda9k3a.js +0 -31
  97. package/dist/vendor-tiptap-extension-placeholder-MI_ltlp7.js +0 -1
  98. package/dist/vendor-tiptap-extension-strike-Di5VtsLj.js +0 -61
  99. package/dist/vendor-tiptap-extension-table-DYCEjlpp.js +0 -311
  100. package/dist/vendor-tiptap-extension-table-cell-D5DL87Xa.js +0 -1
  101. package/dist/vendor-tiptap-extension-table-header-D5DL87Xa.js +0 -1
  102. package/dist/vendor-tiptap-extension-table-row-D5DL87Xa.js +0 -1
  103. package/dist/vendor-tiptap-extension-text-8vtzSN60.js +0 -8
@@ -1,8 +1,6 @@
1
1
  import { PushNotification, PushNotificationClient } from "./../../api/platform";
2
- import { computed, ComputedRef, ref, onUnmounted, inject } from "vue";
2
+ import { computed, ComputedRef, ref, onUnmounted } from "vue";
3
3
  import * as _ from "lodash-es";
4
- import { AuthProviderKey } from "../../../injection-keys";
5
- import { shouldEnablePlatformFeatures } from "../../providers/auth-provider-utils";
6
4
 
7
5
  const notificationsClient = new PushNotificationClient();
8
6
 
@@ -31,10 +29,6 @@ const subscribers = new Map<
31
29
  let subscriberCounter = 0;
32
30
 
33
31
  export function useNotifications(notifyType?: string | string[]): INotifications {
34
- // Check if we're using a custom auth provider
35
- const authProvider = inject(AuthProviderKey);
36
- const isPlatformProvider = shouldEnablePlatformFeatures(authProvider);
37
-
38
32
  if (notifyType) {
39
33
  const types = Array.isArray(notifyType) ? notifyType : [notifyType];
40
34
 
@@ -55,12 +49,6 @@ export function useNotifications(notifyType?: string | string[]): INotifications
55
49
  }
56
50
 
57
51
  async function loadFromHistory(take = 10) {
58
- // Skip platform API calls for custom authentication providers
59
- if (!isPlatformProvider) {
60
- console.log("[useNotifications] Skipping loadFromHistory - custom authentication provider detected");
61
- return;
62
- }
63
-
64
52
  // TODO temporary workaround to get push notifications without base type
65
53
  try {
66
54
  const result = await fetch("/api/platform/pushnotifications", {
@@ -118,25 +106,6 @@ export function useNotifications(notifyType?: string | string[]): INotifications
118
106
  }
119
107
 
120
108
  async function markAllAsRead() {
121
- // Skip platform API calls for custom authentication providers
122
- if (!isPlatformProvider) {
123
- console.log("[useNotifications] Skipping markAllAsRead - custom authentication provider detected");
124
- // Still update local state
125
- notifications.value = notifications.value.map((x) => {
126
- if (x.isNew) {
127
- x.isNew = false;
128
- }
129
- return x;
130
- });
131
- pushNotifications.value = pushNotifications.value.map((x) => {
132
- if (x.isNew) {
133
- x.isNew = false;
134
- }
135
- return x;
136
- });
137
- return;
138
- }
139
-
140
109
  try {
141
110
  notifications.value = notifications.value.map((x) => {
142
111
  if (x.isNew) {
@@ -1,10 +1,8 @@
1
1
  import { useAsync } from "./../useAsync";
2
2
  import { useApiClient } from "./../useApiClient";
3
- import { computed, Ref, ref, ComputedRef, onMounted, inject } from "vue";
3
+ import { computed, Ref, ref, ComputedRef, onMounted } from "vue";
4
4
  import { SettingClient } from "./../../api/platform";
5
5
  import { useLoading } from "../useLoading";
6
- import { shouldEnablePlatformFeatures } from "../../providers/auth-provider-utils";
7
- import { AuthProviderKey } from "../../../injection-keys";
8
6
 
9
7
  interface IUISetting {
10
8
  contrast_logo?: string;
@@ -21,16 +19,13 @@ interface IUseSettings {
21
19
  }
22
20
 
23
21
  export function useSettings(): IUseSettings {
24
- // Check if we're using a custom auth provider
25
- const authProvider = inject(AuthProviderKey);
26
- const isPlatformProvider = shouldEnablePlatformFeatures(authProvider);
27
22
  const uiSettings = ref<IUISetting | undefined>();
28
23
  const customSettingsApplied = ref(false);
29
24
 
30
25
  const { getApiClient } = useApiClient(SettingClient);
31
26
 
32
27
  const { loading, action: getUiCustomizationSettings } = useAsync(async () => {
33
- if (customSettingsApplied.value || !isPlatformProvider) return;
28
+ if (customSettingsApplied.value) return;
34
29
 
35
30
  const result = await (await getApiClient()).getUICustomizationSetting();
36
31
  const settings = await JSON.parse(result.defaultValue ?? null);
@@ -56,7 +51,7 @@ export function useSettings(): IUseSettings {
56
51
  }
57
52
 
58
53
  onMounted(async () => {
59
- if (!uiSettings.value && !customSettingsApplied.value && isPlatformProvider) {
54
+ if (!uiSettings.value && !customSettingsApplied.value) {
60
55
  await getUiCustomizationSettings();
61
56
  }
62
57
  });
@@ -1,114 +1,211 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { computed, inject, ComputedRef, getCurrentInstance } from "vue";
2
+ import { computed, Ref, ref, ComputedRef } from "vue";
3
3
  import {
4
4
  UserDetail,
5
+ SecurityClient,
6
+ ResetPasswordConfirmRequest,
5
7
  SecurityResult,
8
+ ValidatePasswordResetTokenRequest,
6
9
  IdentityResult,
10
+ ChangePasswordRequest,
7
11
  LoginType,
12
+ LoginRequest,
8
13
  SignInResult,
9
- IUserDetail,
10
- ISecurityResult,
11
- ILoginType,
12
- IIdentityResult,
13
14
  } from "./../../api/platform";
14
- import { RequestPasswordResult, IAuthProvider } from "./../../types";
15
+ import { RequestPasswordResult } from "./../../types";
15
16
  import { createSharedComposable } from "@vueuse/core";
16
- import { AuthProviderKey } from "../../../injection-keys";
17
- import { authProviderManager } from "../../providers/auth-provider-manager";
17
+ import { useExternalProvider } from "../../../shared/components/sign-in/useExternalProvider";
18
18
 
19
- /**
20
- * Interface for the full internal API
21
- * @deprecated This interface is kept for backward compatibility but will be removed in future versions
22
- */
19
+ // Interface for the full internal API provided by _createInternalUserLogic
23
20
  export interface IUserInternalAPI {
24
- user: ComputedRef<IUserDetail | undefined>;
21
+ user: ComputedRef<UserDetail | undefined>;
25
22
  loading: ComputedRef<boolean>;
26
23
  isAdministrator: ComputedRef<boolean | undefined>;
27
- loadUser: () => Promise<IUserDetail>;
24
+ loadUser: () => Promise<UserDetail>;
28
25
  signIn: (username: string, password: string) => Promise<SignInResult | { succeeded: boolean; error?: any }>;
29
26
  signOut: () => Promise<void>;
30
27
  validateToken: (userId: string, token: string) => Promise<boolean>;
31
- validatePassword: (password: string) => Promise<IIdentityResult>;
32
- resetPasswordByToken: (userId: string, password: string, token: string) => Promise<ISecurityResult>;
28
+ validatePassword: (password: string) => Promise<IdentityResult>;
29
+ resetPasswordByToken: (userId: string, password: string, token: string) => Promise<SecurityResult>;
33
30
  requestPasswordReset: (loginOrEmail: string) => Promise<RequestPasswordResult>;
34
- changeUserPassword: (oldPassword: string, newPassword: string) => Promise<ISecurityResult | undefined>;
35
- getLoginType: () => Promise<ILoginType[]>;
31
+ changeUserPassword: (oldPassword: string, newPassword: string) => Promise<SecurityResult | undefined>;
32
+ getLoginType: () => Promise<LoginType[]>;
36
33
  isAuthenticated: ComputedRef<boolean>;
37
34
  }
38
35
 
39
36
  export interface IAppUserAPI {
40
- user: ComputedRef<IUserDetail | undefined>;
37
+ user: ComputedRef<UserDetail | undefined>;
41
38
  loading: ComputedRef<boolean>;
42
39
  isAuthenticated: ComputedRef<boolean>;
43
40
  isAdministrator: ComputedRef<boolean | undefined>;
44
- loadUser: () => Promise<IUserDetail>;
41
+ loadUser: () => Promise<UserDetail>;
45
42
  signOut: () => Promise<void>;
46
43
  }
47
44
 
48
- /**
49
- * Get auth provider with fallback to global instance
50
- * This allows composables to work before Vue app context is available
51
- * Priority: Vue DI > Global Manager (always has default PlatformAuthProvider)
52
- */
53
- function getAuthProvider(): IAuthProvider {
54
- // Try to get from Vue DI first (preferred method for components)
55
- const instance = getCurrentInstance();
56
- if (instance) {
57
- const injectedProvider = inject(AuthProviderKey, null);
58
- if (injectedProvider) {
59
- return injectedProvider;
45
+ const user: Ref<UserDetail | undefined> = ref();
46
+
47
+ export function _createInternalUserLogic(): IUserInternalAPI {
48
+ const loading: Ref<boolean> = ref(false);
49
+
50
+ const { storage: externalSignInStorage, signOut: externalSignOut } = useExternalProvider();
51
+
52
+ const securityClient = new SecurityClient();
53
+
54
+ const isAuthenticated = computed(() => user.value?.userName != null);
55
+
56
+ async function validateToken(userId: string, token: string): Promise<boolean> {
57
+ let result = false;
58
+ try {
59
+ loading.value = true;
60
+ result = await securityClient.validatePasswordResetToken(userId, {
61
+ token,
62
+ } as ValidatePasswordResetTokenRequest);
63
+ } catch (e) {
64
+ //TODO: log error
65
+ } finally {
66
+ loading.value = false;
60
67
  }
68
+ return result;
61
69
  }
62
70
 
63
- // Fallback to global provider (always available with default PlatformAuthProvider)
64
- return authProviderManager.getProvider();
65
- }
71
+ async function validatePassword(password: string): Promise<IdentityResult> {
72
+ return securityClient.validatePassword(password);
73
+ }
66
74
 
67
- /**
68
- * Internal user logic - delegates to auth provider
69
- * @deprecated This function is kept for backward compatibility but will be removed in future versions
70
- * Use auth provider directly or useUser/useUserManagement composables
71
- */
72
- export function _createInternalUserLogic(): IUserInternalAPI {
73
- const authProvider = getAuthProvider();
75
+ async function resetPasswordByToken(userId: string, password: string, token: string): Promise<SecurityResult> {
76
+ return securityClient.resetPasswordByToken(userId, {
77
+ newPassword: password,
78
+ token,
79
+ } as ResetPasswordConfirmRequest);
80
+ }
81
+
82
+ async function signIn(
83
+ username: string,
84
+ password: string,
85
+ ): Promise<SignInResult | { succeeded: boolean; error?: any; status?: number }> {
86
+ console.debug(`[@vc-shell/framework#_createInternalUserLogic:signIn] - Entry point`);
87
+ try {
88
+ loading.value = true;
89
+ const result = await securityClient.login(new LoginRequest({ userName: username, password }));
90
+ return await securityClient
91
+ .getCurrentUser()
92
+ .then((res) => {
93
+ if (res) {
94
+ user.value = res;
95
+ return result;
96
+ }
97
+ throw { succeeded: false };
98
+ })
99
+ .catch((e) => {
100
+ throw e;
101
+ });
102
+ } catch (e: any) {
103
+ //TODO: log error
104
+ console.log(e);
105
+ return { succeeded: false, error: e.message, status: e.status };
106
+ } finally {
107
+ loading.value = false;
108
+ }
109
+ }
110
+
111
+ async function signOut(): Promise<void> {
112
+ console.debug(`[@vc-shell/framework#_createInternalUserLogic:signOut] - Entry point`);
113
+
114
+ user.value = undefined;
115
+
116
+ if (externalSignInStorage.value?.providerType) {
117
+ await externalSignOut(externalSignInStorage.value.providerType);
118
+ } else {
119
+ securityClient.logout();
120
+ }
121
+ }
122
+
123
+ async function loadUser(): Promise<UserDetail> {
124
+ console.debug(`[@vc-shell/framework#_createInternalUserLogic:loadUser] - Entry point`);
125
+
126
+ try {
127
+ loading.value = true;
128
+ user.value = await securityClient.getCurrentUser();
129
+ console.log("[_createInternalUserLogic]: an user details has been loaded", user.value);
130
+ } catch (e: any) {
131
+ console.error(e);
132
+ } finally {
133
+ loading.value = false;
134
+ }
135
+
136
+ return { ...user.value } as UserDetail;
137
+ }
138
+
139
+ async function requestPasswordReset(loginOrEmail: string): Promise<RequestPasswordResult> {
140
+ try {
141
+ loading.value = true;
142
+ await securityClient.requestPasswordReset(loginOrEmail);
143
+ return { succeeded: true };
144
+ } catch (e) {
145
+ //TODO: log error
146
+ return { succeeded: false, error: e as string };
147
+ } finally {
148
+ loading.value = false;
149
+ }
150
+ }
151
+
152
+ async function changeUserPassword(oldPassword: string, newPassword: string): Promise<SecurityResult | undefined> {
153
+ let result;
154
+
155
+ try {
156
+ loading.value = true;
157
+ const command = new ChangePasswordRequest({
158
+ oldPassword,
159
+ newPassword,
160
+ });
161
+
162
+ result = await securityClient.changeCurrentUserPassword(command);
163
+ } catch (e: any) {
164
+ return { succeeded: false, errors: [e.message] } as SecurityResult;
165
+ } finally {
166
+ loading.value = false;
167
+ }
168
+
169
+ return result;
170
+ }
171
+
172
+ async function getLoginType() {
173
+ let result: LoginType[] | null = null;
174
+ try {
175
+ result = await securityClient.getLoginTypes();
176
+ } catch (e) {
177
+ console.error(e);
178
+ throw e;
179
+ }
180
+
181
+ return result;
182
+ }
74
183
 
75
184
  return {
76
- user: authProvider.user,
77
- loading: authProvider.loading,
78
- isAdministrator: authProvider.isAdministrator,
79
- isAuthenticated: authProvider.isAuthenticated,
80
- loadUser: authProvider.loadUser.bind(authProvider),
81
- signIn: authProvider.signIn.bind(authProvider),
82
- signOut: authProvider.signOut.bind(authProvider),
83
- validateToken: authProvider.validateToken.bind(authProvider),
84
- validatePassword: authProvider.validatePassword.bind(authProvider),
85
- resetPasswordByToken: authProvider.resetPasswordByToken.bind(authProvider),
86
- requestPasswordReset: authProvider.requestPasswordReset.bind(authProvider),
87
- changeUserPassword: authProvider.changeUserPassword.bind(authProvider),
88
- getLoginType: authProvider.getLoginType.bind(authProvider),
185
+ user: computed(() => user.value),
186
+ loading: computed(() => loading.value),
187
+ isAdministrator: computed(() => user.value?.isAdministrator),
188
+ isAuthenticated,
189
+ loadUser,
190
+ signIn,
191
+ signOut,
192
+ validateToken,
193
+ validatePassword,
194
+ resetPasswordByToken,
195
+ requestPasswordReset,
196
+ changeUserPassword,
197
+ getLoginType,
89
198
  };
90
199
  }
91
200
 
92
201
  export const useUser = createSharedComposable((): IAppUserAPI => {
93
- // Get provider dynamically on each access to ensure correct provider is used
94
- // This is important because custom auth providers may be set after composable creation
95
-
202
+ const internals = _createInternalUserLogic();
96
203
  return {
97
- // Computed properties should get provider dynamically
98
- get user() {
99
- return getAuthProvider().user;
100
- },
101
- get loading() {
102
- return getAuthProvider().loading;
103
- },
104
- get isAuthenticated() {
105
- return getAuthProvider().isAuthenticated;
106
- },
107
- get isAdministrator() {
108
- return getAuthProvider().isAdministrator;
109
- },
110
- // Methods get provider dynamically on each call
111
- loadUser: () => getAuthProvider().loadUser(),
112
- signOut: () => getAuthProvider().signOut(),
204
+ user: internals.user,
205
+ loading: internals.loading,
206
+ isAuthenticated: internals.isAuthenticated,
207
+ isAdministrator: internals.isAdministrator,
208
+ loadUser: internals.loadUser,
209
+ signOut: internals.signOut,
113
210
  };
114
211
  });
@@ -1,87 +1,45 @@
1
- import { inject, ComputedRef, getCurrentInstance } from "vue";
1
+ import { computed, ComputedRef } from "vue";
2
2
  import { createSharedComposable } from "@vueuse/core";
3
- import {
4
- SecurityResult,
5
- IdentityResult,
6
- LoginType,
7
- UserDetail,
8
- SignInResult,
9
- IUserDetail,
10
- IIdentityResult,
11
- ISecurityResult,
12
- ILoginType,
13
- } from "./../../api/platform";
14
- import { RequestPasswordResult, IAuthProvider } from "./../../types";
15
- import { AuthProviderKey } from "../../../injection-keys";
16
- import { authProviderManager } from "../../providers/auth-provider-manager";
3
+ import { _createInternalUserLogic, IUserInternalAPI } from "../useUser"; // Import the internal logic
4
+ import { SecurityResult, IdentityResult, LoginType, UserDetail, SignInResult } from "./../../api/platform";
5
+ import { RequestPasswordResult } from "./../../types";
17
6
 
18
7
  // Interface for the API exposed by useUserManagement (for framework/admin use)
19
8
  export interface IUserManagementAPI {
20
- user: ComputedRef<IUserDetail | undefined>;
9
+ user: ComputedRef<UserDetail | undefined>;
21
10
  loading: ComputedRef<boolean>;
22
11
  isAdministrator: ComputedRef<boolean | undefined>;
23
12
  isAuthenticated: ComputedRef<boolean>;
24
13
  // Methods specific to user management
25
14
  validateToken: (userId: string, token: string) => Promise<boolean>;
26
- validatePassword: (password: string) => Promise<IIdentityResult>;
27
- resetPasswordByToken: (userId: string, password: string, token: string) => Promise<ISecurityResult>;
28
- getLoginType: () => Promise<ILoginType[]>;
29
- loadUser: () => Promise<IUserDetail>;
15
+ validatePassword: (password: string) => Promise<IdentityResult>;
16
+ resetPasswordByToken: (userId: string, password: string, token: string) => Promise<SecurityResult>;
17
+ getLoginType: () => Promise<LoginType[]>;
18
+ loadUser: () => Promise<UserDetail>;
30
19
  requestPasswordReset: (loginOrEmail: string) => Promise<RequestPasswordResult>;
31
- changeUserPassword: (oldPassword: string, newPassword: string) => Promise<ISecurityResult | undefined>;
20
+ changeUserPassword: (oldPassword: string, newPassword: string) => Promise<SecurityResult | undefined>;
32
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
22
  signIn: (username: string, password: string) => Promise<SignInResult | { succeeded: boolean; error?: any }>;
34
23
  signOut: () => Promise<void>;
35
24
  }
36
25
 
37
- /**
38
- * Get auth provider with fallback to global instance
39
- * This allows composables to work before Vue app context is available
40
- * Priority: Vue DI > Global Manager (always has default PlatformAuthProvider)
41
- */
42
- function getAuthProvider(): IAuthProvider {
43
- // Try to get from Vue DI first (preferred method for components)
44
- const instance = getCurrentInstance();
45
- if (instance) {
46
- const injectedProvider = inject(AuthProviderKey, null);
47
- if (injectedProvider) {
48
- return injectedProvider;
49
- }
50
- }
51
-
52
- // Fallback to global provider (always available with default PlatformAuthProvider)
53
- return authProviderManager.getProvider();
54
- }
55
-
56
26
  export const useUserManagement = createSharedComposable((): IUserManagementAPI => {
57
- // Get provider dynamically on each access to ensure correct provider is used
58
- // This is important because custom auth providers may be set after composable creation
27
+ // Utilize the same internal logic instance
28
+ const internals: IUserInternalAPI = _createInternalUserLogic();
59
29
 
60
30
  return {
61
- // Computed properties should get provider dynamically
62
- get user() {
63
- return getAuthProvider().user;
64
- },
65
- get loading() {
66
- return getAuthProvider().loading;
67
- },
68
- get isAdministrator() {
69
- return getAuthProvider().isAdministrator;
70
- },
71
- get isAuthenticated() {
72
- return getAuthProvider().isAuthenticated;
73
- },
74
- // Methods get provider dynamically on each call
75
- validateToken: (userId: string, token: string) => getAuthProvider().validateToken(userId, token),
76
- validatePassword: (password: string) => getAuthProvider().validatePassword(password),
77
- resetPasswordByToken: (userId: string, password: string, token: string) =>
78
- getAuthProvider().resetPasswordByToken(userId, password, token),
79
- getLoginType: () => getAuthProvider().getLoginType(),
80
- loadUser: () => getAuthProvider().loadUser(),
81
- requestPasswordReset: (loginOrEmail: string) => getAuthProvider().requestPasswordReset(loginOrEmail),
82
- changeUserPassword: (oldPassword: string, newPassword: string) =>
83
- getAuthProvider().changeUserPassword(oldPassword, newPassword),
84
- signIn: (username: string, password: string) => getAuthProvider().signIn(username, password),
85
- signOut: () => getAuthProvider().signOut(),
31
+ user: internals.user,
32
+ loading: internals.loading,
33
+ isAdministrator: internals.isAdministrator,
34
+ isAuthenticated: internals.isAuthenticated,
35
+ validateToken: internals.validateToken,
36
+ validatePassword: internals.validatePassword,
37
+ resetPasswordByToken: internals.resetPasswordByToken,
38
+ getLoginType: internals.getLoginType,
39
+ loadUser: internals.loadUser,
40
+ requestPasswordReset: internals.requestPasswordReset,
41
+ changeUserPassword: internals.changeUserPassword,
42
+ signIn: internals.signIn,
43
+ signOut: internals.signOut,
86
44
  };
87
45
  });
@@ -1,33 +1,70 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import { Router } from "vue-router";
3
+ import { useUserManagement } from "../composables/useUserManagement";
2
4
  import { notification } from "../../shared";
3
- import { IAuthProvider } from "../types/auth-provider";
4
5
 
5
- export function registerInterceptors(router: Router, authProvider: IAuthProvider) {
6
+ export function registerInterceptors(router: Router) {
6
7
  const { fetch: originalFetch } = window;
8
+ const { signOut, isAuthenticated } = useUserManagement();
7
9
 
8
10
  window.fetch = async (...args) => {
9
11
  /**
10
- * Intercepts fetch requests to handle authentication errors.
11
- * Note: Demo mode should be handled by the auth provider itself, not by global interceptors.
12
+ * Overrides the global `fetch` function to handle API calls in demo mode.
13
+ * If `window.__DEMO_MODE__` is true, the fetch is cancelled and a warning is logged.
14
+ * Otherwise, the original `fetch` function is called.
15
+ * @param args - The arguments passed to the `fetch` function.
16
+ * @returns A promise that resolves to the response from the API call.
12
17
  */
13
- const response = await originalFetch(...args);
14
-
15
- /**
16
- * If the response is unauthorized, logout the user
17
- */
18
- if (response.status === 401) {
19
- //logout user
20
- if (authProvider.isAuthenticated.value) {
21
- authProvider.signOut().then(() => {
22
- redirect(router);
23
- notification.error(
24
- "Access Denied: Your session has expired or you do not have the necessary permissions.\nPlease log in again or contact the administrator for assistance.",
18
+ if (window.__DEMO_MODE__) {
19
+ console.warn("CANCELLED FETCH WHILE IN __DEMO_MODE__: ", ...args);
20
+ console.warn("Please logout and add APP_PLATFORM_URL into .env file of your application to enable API calls");
21
+ return new Promise((resolve: any) => {
22
+ /**
23
+ * This conditions are mocking login, currentuser API calls for demo purposes.
24
+ */
25
+ if (args[0] === "/api/platform/security/login") {
26
+ resolve({
27
+ status: 200,
28
+ text: async () => JSON.stringify({ succeeded: true }),
29
+ });
30
+ } else if (args[0] === "/api/platform/security/currentuser") {
31
+ notification.warning(
32
+ "You are currently in DEMO mode until the first page refresh. \n All API calls are disabled. Please add APP_PLATFORM_URL to your application's .env file to enable API calls.",
33
+ {
34
+ timeout: 10000,
35
+ },
25
36
  );
26
- });
37
+ resolve({
38
+ status: 200,
39
+ text: async () => JSON.stringify({ id: "demo_user_id", userName: "DEMO_USER" }),
40
+ });
41
+ } else {
42
+ resolve({
43
+ status: 200,
44
+ text: async () => JSON.stringify({}),
45
+ });
46
+ }
47
+ });
48
+ } else {
49
+ const response = await originalFetch(...args);
50
+
51
+ /**
52
+ * If the response is unauthorized, logout the user
53
+ */
54
+ if (response.status === 401) {
55
+ //logout user
56
+ if (isAuthenticated.value) {
57
+ signOut().then(() => {
58
+ redirect(router);
59
+ notification.error(
60
+ "Access Denied: Your session has expired or you do not have the necessary permissions.\nPlease log in again or contact the administrator for assistance.",
61
+ );
62
+ });
63
+ }
27
64
  }
28
- }
29
65
 
30
- return response;
66
+ return response;
67
+ }
31
68
  };
32
69
 
33
70
  return window.fetch;
@@ -1,12 +1,9 @@
1
- import { App, watch, ref, InjectionKey, inject } from "vue";
1
+ import { App, watch, ref, InjectionKey } from "vue";
2
2
  import { HubConnection, HubConnectionBuilder, LogLevel } from "@microsoft/signalr";
3
3
  import { PushNotification } from "../../api/platform";
4
4
  import { useNotifications } from "./../../composables/useNotifications";
5
5
  import { useUserManagement } from "../../composables/useUserManagement";
6
6
  import { useCypressSignalRMock } from "cypress-signalr-mock";
7
- import { AuthProviderKey } from "../../../injection-keys";
8
- import { IAuthProvider } from "../../types/auth-provider";
9
- import { shouldEnablePlatformFeatures } from "../../providers/auth-provider-utils";
10
7
 
11
8
  const { addNotification } = useNotifications();
12
9
  const currentCreator = ref<string | undefined>();
@@ -34,31 +31,8 @@ export const signalR = {
34
31
  app: App,
35
32
  options?: {
36
33
  creator?: string;
37
- authProvider?: IAuthProvider;
38
34
  },
39
35
  ) {
40
- // Check if we should enable SignalR (only for platform providers)
41
- const authProvider = options?.authProvider;
42
-
43
- console.log("[SignalR] Auth provider: ", authProvider);
44
-
45
- // Check if platform features should be enabled
46
- if (!shouldEnablePlatformFeatures(authProvider)) {
47
- console.log("[SignalR] Skipping initialization - custom authentication provider detected");
48
- console.log("[SignalR] SignalR is only available with platform authentication");
49
-
50
- // Provide empty implementations to prevent errors
51
- app.config.globalProperties.$updateSignalRCreator = () => {
52
- console.warn("[SignalR] Not available with custom authentication provider");
53
- };
54
- app.provide(updateSignalRCreatorSymbol, () => {
55
- console.warn("[SignalR] Not available with custom authentication provider");
56
- });
57
-
58
- return;
59
- }
60
-
61
- console.log("[SignalR] Initializing with platform authentication");
62
36
  currentCreator.value = options?.creator;
63
37
  const { isAuthenticated } = useUserManagement();
64
38
  let reconnect = false;
@@ -233,5 +233,3 @@ export interface MenuItemConfig {
233
233
  inGroupPriority?: number;
234
234
  permissions?: string | string[];
235
235
  }
236
-
237
- export * from "./auth-provider";
@@ -1197,7 +1197,7 @@ export interface IIdentityError {
1197
1197
  }
1198
1198
  export declare class IdentityResult implements IIdentityResult {
1199
1199
  readonly succeeded?: boolean;
1200
- readonly errors?: IIdentityError[] | undefined;
1200
+ readonly errors?: IdentityError[] | undefined;
1201
1201
  constructor(data?: IIdentityResult);
1202
1202
  init(_data?: any): void;
1203
1203
  static fromJS(data: any): IdentityResult;