@klauswuestefeld/jux-web 2025.5.24 → 2025.5.28

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/jux-web.js CHANGED
@@ -1,6 +1,13 @@
1
1
  var juxWeb = (function (exports) {
2
2
  'use strict';
3
3
 
4
+ let urlPrefix;
5
+ const setUrlPrefix = (s) => urlPrefix = s;
6
+ const getLocalStorageKey = (k) => urlPrefix ? `${urlPrefix}_${k}` : k;
7
+ const getLocalStorageItem = (k) => localStorage.getItem(getLocalStorageKey(k));
8
+ const setLocalStorageItem = (k, v) => localStorage.setItem(getLocalStorageKey(k), v);
9
+ const removeLocalStorageItem = (k) => localStorage.removeItem(getLocalStorageKey(k));
10
+
4
11
  const getBrowserLanguage = () => {
5
12
  const result = (navigator.languages && navigator.languages.length)
6
13
  ? navigator.languages[0]
@@ -9,9 +16,9 @@ var juxWeb = (function (exports) {
9
16
  };
10
17
  const OVERRIDE_KEY = 'jux.language.override';
11
18
  let translations = {};
12
- const chosenLanguage = localStorage.getItem(OVERRIDE_KEY) || getBrowserLanguage();
19
+ const chosenLanguage = getLocalStorageItem(OVERRIDE_KEY) || getBrowserLanguage();
13
20
  const reloadWithLanguageOverride = (lang) => {
14
- localStorage.setItem(OVERRIDE_KEY, lang);
21
+ setLocalStorageItem(OVERRIDE_KEY, lang);
15
22
  location.reload();
16
23
  };
17
24
  // @ts-ignore
@@ -148,9 +155,9 @@ var juxWeb = (function (exports) {
148
155
  return token;
149
156
  };
150
157
 
151
- const setBackendUrl = (backendUrl) => localStorage.setItem('backend-url', backendUrl);
158
+ const setBackendUrl = (backendUrl) => setLocalStorageItem('backend-url', backendUrl);
152
159
  //@ts-ignore
153
- const getBackendUrl = () => process.env.BACKEND_URL || localStorage.getItem('backend-url');
160
+ const getBackendUrl = () => process.env.BACKEND_URL || getLocalStorageItem('backend-url');
154
161
  //@ts-ignore
155
162
  const getSecondaryBackendUrl = () => process.env.STAGING_BACKEND_URL || getBackendUrl();
156
163
  const getApiUrl = () => getBackendUrl() + 'api/';
@@ -195,7 +202,7 @@ var juxWeb = (function (exports) {
195
202
  (_b = document.querySelector('.reconnect-spinner')) === null || _b === void 0 ? void 0 : _b.remove();
196
203
  };
197
204
  const defaultHandleUnauthorized = () => {
198
- localStorage.removeItem('token');
205
+ removeLocalStorageItem('token');
199
206
  alert(getTranslation('session-expired-msg'));
200
207
  location.reload();
201
208
  // googleAuthSignOut(); TODO
@@ -14502,12 +14509,12 @@ var juxWeb = (function (exports) {
14502
14509
  // @ts-ignore
14503
14510
  window.store.backendToken = token;
14504
14511
  if (token) {
14505
- localStorage.setItem('token', token);
14512
+ setLocalStorageItem('token', token);
14506
14513
  }
14507
14514
  };
14508
14515
  const getBackendToken = () => {
14509
14516
  var _a;
14510
- const token = (_a = localStorage.getItem('token')) !== null && _a !== void 0 ? _a : '';
14517
+ const token = (_a = getLocalStorageItem('token')) !== null && _a !== void 0 ? _a : '';
14511
14518
  // @ts-ignore
14512
14519
  window.store.backendToken = token;
14513
14520
  return token;
@@ -14517,19 +14524,13 @@ var juxWeb = (function (exports) {
14517
14524
  // setSuperToken();
14518
14525
  onUserLogin();
14519
14526
  };
14520
- const clearSession = (itemsToSave) => {
14521
- // onUserChanged(null);
14522
- // TODO: find a better way to preserve backend-url
14523
- const backendUrl = getBackendUrl(); // Preserve backend, since the authentication was succcessfull
14524
- const savedItems = itemsToSave === null || itemsToSave === void 0 ? void 0 : itemsToSave.map((item) => ({ key: item, value: localStorage.getItem(item) }));
14525
- localStorage.clear();
14526
- savedItems === null || savedItems === void 0 ? void 0 : savedItems.forEach((item) => localStorage.setItem(item.key, item.value));
14527
- setBackendUrl(backendUrl);
14527
+ const clearSession = () => {
14528
+ removeLocalStorageItem('token');
14528
14529
  // @ts-ignore
14529
14530
  window.store = {};
14530
14531
  };
14531
14532
  const onAuthenticationFailure = (msg) => {
14532
- localStorage.removeItem('token');
14533
+ removeLocalStorageItem('token');
14533
14534
  // displayPage(Page.LOGIN);
14534
14535
  alert(getTranslation(msg));
14535
14536
  };
@@ -14540,7 +14541,7 @@ var juxWeb = (function (exports) {
14540
14541
  // @ts-ignore
14541
14542
  window.store.currentUser = user;
14542
14543
  if (type === 'Token Authentication') {
14543
- user.token = localStorage.getItem('token');
14544
+ user.token = getLocalStorageItem('token');
14544
14545
  }
14545
14546
  onTokenAcquired(user.token, onUserLogin);
14546
14547
  // mixpanelIdentify(user);
@@ -14572,7 +14573,7 @@ var juxWeb = (function (exports) {
14572
14573
  const onError = () => onAuthenticationFailure('login-failed');
14573
14574
  getSSOAuthorizationEndpoint(onSuccess, onError);
14574
14575
  };
14575
- const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
14576
+ const initSession = ({ clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint, urlPrefix }) => {
14576
14577
  // if (startNewDemo()) {
14577
14578
  // initDemo(setBackendToken, onAuthentication);
14578
14579
  // return;
@@ -14588,6 +14589,8 @@ var juxWeb = (function (exports) {
14588
14589
  window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
14589
14590
  // @ts-ignore
14590
14591
  window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
14592
+ if (urlPrefix)
14593
+ setUrlPrefix(urlPrefix);
14591
14594
  const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
14592
14595
  if (signInToken) {
14593
14596
  const onOpenMagicLink = () => {
@@ -0,0 +1,4 @@
1
+ export declare const setUrlPrefix: (s: string) => string;
2
+ export declare const getLocalStorageItem: (k: string) => string | null;
3
+ export declare const setLocalStorageItem: (k: string, v: string) => void;
4
+ export declare const removeLocalStorageItem: (k: string) => void;
@@ -1,8 +1,20 @@
1
1
  export declare const setBackendToken: (token: string) => void;
2
2
  export declare const onTokenAcquired: (token: string, onUserLogin: any) => void;
3
- export declare const clearSession: (itemsToSave?: string[]) => void;
4
- export declare const initSession: (clientApp: HTMLElement, supportedLoginTypes: string[], onUserLogin: any, onLoginError: any, backgroundImage: string, fetchUserBackendUrl: any, magicLinkRequestEndpoint: string | null, magicLinkAuthEndpoint: string | null) => void;
3
+ export declare const clearSession: () => void;
4
+ interface InitSessionParams {
5
+ clientApp: HTMLElement;
6
+ supportedLoginTypes: string[];
7
+ onUserLogin: any;
8
+ onLoginError: any;
9
+ backgroundImage: string;
10
+ fetchUserBackendUrl: any;
11
+ magicLinkRequestEndpoint: string | null;
12
+ magicLinkAuthEndpoint: string | null;
13
+ urlPrefix: string;
14
+ }
15
+ export declare const initSession: ({ clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint, urlPrefix }: InitSessionParams) => void;
5
16
  export declare const onMicrosoftSignIn: (onUserLogin: any) => Promise<void>;
6
17
  export declare const onGoogleSignIn: (onUserLogin: any) => void;
7
18
  export declare const onAuthPasswordLogin: (credentials: any, onUserLogin: any, onLoginError: any, onReturn: any, clientApp: HTMLElement, backgroundImg: string) => void;
8
19
  export declare const handleMagicLinkRequest: (token: string | null, onReturn: any, backgroundImage: string, currentPage: HTMLElement, clientBody: HTMLElement, email?: string) => void;
20
+ export {};
package/dist/main.esm.js CHANGED
@@ -1,5 +1,12 @@
1
1
  import * as msal from '@azure/msal-browser';
2
2
 
3
+ let urlPrefix;
4
+ const setUrlPrefix = (s) => urlPrefix = s;
5
+ const getLocalStorageKey = (k) => urlPrefix ? `${urlPrefix}_${k}` : k;
6
+ const getLocalStorageItem = (k) => localStorage.getItem(getLocalStorageKey(k));
7
+ const setLocalStorageItem = (k, v) => localStorage.setItem(getLocalStorageKey(k), v);
8
+ const removeLocalStorageItem = (k) => localStorage.removeItem(getLocalStorageKey(k));
9
+
3
10
  const getBrowserLanguage = () => {
4
11
  const result = (navigator.languages && navigator.languages.length)
5
12
  ? navigator.languages[0]
@@ -8,9 +15,9 @@ const getBrowserLanguage = () => {
8
15
  };
9
16
  const OVERRIDE_KEY = 'jux.language.override';
10
17
  let translations = {};
11
- const chosenLanguage = localStorage.getItem(OVERRIDE_KEY) || getBrowserLanguage();
18
+ const chosenLanguage = getLocalStorageItem(OVERRIDE_KEY) || getBrowserLanguage();
12
19
  const reloadWithLanguageOverride = (lang) => {
13
- localStorage.setItem(OVERRIDE_KEY, lang);
20
+ setLocalStorageItem(OVERRIDE_KEY, lang);
14
21
  location.reload();
15
22
  };
16
23
  // @ts-ignore
@@ -147,9 +154,9 @@ const extractTokenFromWindowLocation = (tokenParam, additionalParam = '') => {
147
154
  return token;
148
155
  };
149
156
 
150
- const setBackendUrl = (backendUrl) => localStorage.setItem('backend-url', backendUrl);
157
+ const setBackendUrl = (backendUrl) => setLocalStorageItem('backend-url', backendUrl);
151
158
  //@ts-ignore
152
- const getBackendUrl = () => process.env.BACKEND_URL || localStorage.getItem('backend-url');
159
+ const getBackendUrl = () => process.env.BACKEND_URL || getLocalStorageItem('backend-url');
153
160
  //@ts-ignore
154
161
  const getSecondaryBackendUrl = () => process.env.STAGING_BACKEND_URL || getBackendUrl();
155
162
  const getApiUrl = () => getBackendUrl() + 'api/';
@@ -194,7 +201,7 @@ const removeOverlay = () => {
194
201
  (_b = document.querySelector('.reconnect-spinner')) === null || _b === void 0 ? void 0 : _b.remove();
195
202
  };
196
203
  const defaultHandleUnauthorized = () => {
197
- localStorage.removeItem('token');
204
+ removeLocalStorageItem('token');
198
205
  alert(getTranslation('session-expired-msg'));
199
206
  location.reload();
200
207
  // googleAuthSignOut(); TODO
@@ -987,12 +994,12 @@ const setBackendToken = (token) => {
987
994
  // @ts-ignore
988
995
  window.store.backendToken = token;
989
996
  if (token) {
990
- localStorage.setItem('token', token);
997
+ setLocalStorageItem('token', token);
991
998
  }
992
999
  };
993
1000
  const getBackendToken = () => {
994
1001
  var _a;
995
- const token = (_a = localStorage.getItem('token')) !== null && _a !== void 0 ? _a : '';
1002
+ const token = (_a = getLocalStorageItem('token')) !== null && _a !== void 0 ? _a : '';
996
1003
  // @ts-ignore
997
1004
  window.store.backendToken = token;
998
1005
  return token;
@@ -1002,19 +1009,13 @@ const onTokenAcquired = (token, onUserLogin) => {
1002
1009
  // setSuperToken();
1003
1010
  onUserLogin();
1004
1011
  };
1005
- const clearSession = (itemsToSave) => {
1006
- // onUserChanged(null);
1007
- // TODO: find a better way to preserve backend-url
1008
- const backendUrl = getBackendUrl(); // Preserve backend, since the authentication was succcessfull
1009
- const savedItems = itemsToSave === null || itemsToSave === void 0 ? void 0 : itemsToSave.map((item) => ({ key: item, value: localStorage.getItem(item) }));
1010
- localStorage.clear();
1011
- savedItems === null || savedItems === void 0 ? void 0 : savedItems.forEach((item) => localStorage.setItem(item.key, item.value));
1012
- setBackendUrl(backendUrl);
1012
+ const clearSession = () => {
1013
+ removeLocalStorageItem('token');
1013
1014
  // @ts-ignore
1014
1015
  window.store = {};
1015
1016
  };
1016
1017
  const onAuthenticationFailure = (msg) => {
1017
- localStorage.removeItem('token');
1018
+ removeLocalStorageItem('token');
1018
1019
  // displayPage(Page.LOGIN);
1019
1020
  alert(getTranslation(msg));
1020
1021
  };
@@ -1025,7 +1026,7 @@ const onAuthentication = (onUserLogin, user, type) => {
1025
1026
  // @ts-ignore
1026
1027
  window.store.currentUser = user;
1027
1028
  if (type === 'Token Authentication') {
1028
- user.token = localStorage.getItem('token');
1029
+ user.token = getLocalStorageItem('token');
1029
1030
  }
1030
1031
  onTokenAcquired(user.token, onUserLogin);
1031
1032
  // mixpanelIdentify(user);
@@ -1057,7 +1058,7 @@ const handleSSOLogin = () => {
1057
1058
  const onError = () => onAuthenticationFailure('login-failed');
1058
1059
  getSSOAuthorizationEndpoint(onSuccess, onError);
1059
1060
  };
1060
- const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
1061
+ const initSession = ({ clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint, urlPrefix }) => {
1061
1062
  // if (startNewDemo()) {
1062
1063
  // initDemo(setBackendToken, onAuthentication);
1063
1064
  // return;
@@ -1073,6 +1074,8 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError,
1073
1074
  window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
1074
1075
  // @ts-ignore
1075
1076
  window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
1077
+ if (urlPrefix)
1078
+ setUrlPrefix(urlPrefix);
1076
1079
  const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
1077
1080
  if (signInToken) {
1078
1081
  const onOpenMagicLink = () => {
package/dist/main.js CHANGED
@@ -24,6 +24,13 @@ function _interopNamespace(e) {
24
24
 
25
25
  var msal__namespace = /*#__PURE__*/_interopNamespace(msal);
26
26
 
27
+ let urlPrefix;
28
+ const setUrlPrefix = (s) => urlPrefix = s;
29
+ const getLocalStorageKey = (k) => urlPrefix ? `${urlPrefix}_${k}` : k;
30
+ const getLocalStorageItem = (k) => localStorage.getItem(getLocalStorageKey(k));
31
+ const setLocalStorageItem = (k, v) => localStorage.setItem(getLocalStorageKey(k), v);
32
+ const removeLocalStorageItem = (k) => localStorage.removeItem(getLocalStorageKey(k));
33
+
27
34
  const getBrowserLanguage = () => {
28
35
  const result = (navigator.languages && navigator.languages.length)
29
36
  ? navigator.languages[0]
@@ -32,9 +39,9 @@ const getBrowserLanguage = () => {
32
39
  };
33
40
  const OVERRIDE_KEY = 'jux.language.override';
34
41
  let translations = {};
35
- const chosenLanguage = localStorage.getItem(OVERRIDE_KEY) || getBrowserLanguage();
42
+ const chosenLanguage = getLocalStorageItem(OVERRIDE_KEY) || getBrowserLanguage();
36
43
  const reloadWithLanguageOverride = (lang) => {
37
- localStorage.setItem(OVERRIDE_KEY, lang);
44
+ setLocalStorageItem(OVERRIDE_KEY, lang);
38
45
  location.reload();
39
46
  };
40
47
  // @ts-ignore
@@ -171,9 +178,9 @@ const extractTokenFromWindowLocation = (tokenParam, additionalParam = '') => {
171
178
  return token;
172
179
  };
173
180
 
174
- const setBackendUrl = (backendUrl) => localStorage.setItem('backend-url', backendUrl);
181
+ const setBackendUrl = (backendUrl) => setLocalStorageItem('backend-url', backendUrl);
175
182
  //@ts-ignore
176
- const getBackendUrl = () => process.env.BACKEND_URL || localStorage.getItem('backend-url');
183
+ const getBackendUrl = () => process.env.BACKEND_URL || getLocalStorageItem('backend-url');
177
184
  //@ts-ignore
178
185
  const getSecondaryBackendUrl = () => process.env.STAGING_BACKEND_URL || getBackendUrl();
179
186
  const getApiUrl = () => getBackendUrl() + 'api/';
@@ -218,7 +225,7 @@ const removeOverlay = () => {
218
225
  (_b = document.querySelector('.reconnect-spinner')) === null || _b === void 0 ? void 0 : _b.remove();
219
226
  };
220
227
  const defaultHandleUnauthorized = () => {
221
- localStorage.removeItem('token');
228
+ removeLocalStorageItem('token');
222
229
  alert(getTranslation('session-expired-msg'));
223
230
  location.reload();
224
231
  // googleAuthSignOut(); TODO
@@ -1011,12 +1018,12 @@ const setBackendToken = (token) => {
1011
1018
  // @ts-ignore
1012
1019
  window.store.backendToken = token;
1013
1020
  if (token) {
1014
- localStorage.setItem('token', token);
1021
+ setLocalStorageItem('token', token);
1015
1022
  }
1016
1023
  };
1017
1024
  const getBackendToken = () => {
1018
1025
  var _a;
1019
- const token = (_a = localStorage.getItem('token')) !== null && _a !== void 0 ? _a : '';
1026
+ const token = (_a = getLocalStorageItem('token')) !== null && _a !== void 0 ? _a : '';
1020
1027
  // @ts-ignore
1021
1028
  window.store.backendToken = token;
1022
1029
  return token;
@@ -1026,19 +1033,13 @@ const onTokenAcquired = (token, onUserLogin) => {
1026
1033
  // setSuperToken();
1027
1034
  onUserLogin();
1028
1035
  };
1029
- const clearSession = (itemsToSave) => {
1030
- // onUserChanged(null);
1031
- // TODO: find a better way to preserve backend-url
1032
- const backendUrl = getBackendUrl(); // Preserve backend, since the authentication was succcessfull
1033
- const savedItems = itemsToSave === null || itemsToSave === void 0 ? void 0 : itemsToSave.map((item) => ({ key: item, value: localStorage.getItem(item) }));
1034
- localStorage.clear();
1035
- savedItems === null || savedItems === void 0 ? void 0 : savedItems.forEach((item) => localStorage.setItem(item.key, item.value));
1036
- setBackendUrl(backendUrl);
1036
+ const clearSession = () => {
1037
+ removeLocalStorageItem('token');
1037
1038
  // @ts-ignore
1038
1039
  window.store = {};
1039
1040
  };
1040
1041
  const onAuthenticationFailure = (msg) => {
1041
- localStorage.removeItem('token');
1042
+ removeLocalStorageItem('token');
1042
1043
  // displayPage(Page.LOGIN);
1043
1044
  alert(getTranslation(msg));
1044
1045
  };
@@ -1049,7 +1050,7 @@ const onAuthentication = (onUserLogin, user, type) => {
1049
1050
  // @ts-ignore
1050
1051
  window.store.currentUser = user;
1051
1052
  if (type === 'Token Authentication') {
1052
- user.token = localStorage.getItem('token');
1053
+ user.token = getLocalStorageItem('token');
1053
1054
  }
1054
1055
  onTokenAcquired(user.token, onUserLogin);
1055
1056
  // mixpanelIdentify(user);
@@ -1081,7 +1082,7 @@ const handleSSOLogin = () => {
1081
1082
  const onError = () => onAuthenticationFailure('login-failed');
1082
1083
  getSSOAuthorizationEndpoint(onSuccess, onError);
1083
1084
  };
1084
- const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
1085
+ const initSession = ({ clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint, urlPrefix }) => {
1085
1086
  // if (startNewDemo()) {
1086
1087
  // initDemo(setBackendToken, onAuthentication);
1087
1088
  // return;
@@ -1097,6 +1098,8 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError,
1097
1098
  window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
1098
1099
  // @ts-ignore
1099
1100
  window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
1101
+ if (urlPrefix)
1102
+ setUrlPrefix(urlPrefix);
1100
1103
  const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
1101
1104
  if (signInToken) {
1102
1105
  const onOpenMagicLink = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klauswuestefeld/jux-web",
3
- "version": "2025.5.24",
3
+ "version": "2025.5.28",
4
4
  "author": "Jux.House",
5
5
  "license": "Copyrighted",
6
6
  "description": "",