@klauswuestefeld/jux-web 2025.5.24-1 → 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;
@@ -14518,12 +14525,12 @@ var juxWeb = (function (exports) {
14518
14525
  onUserLogin();
14519
14526
  };
14520
14527
  const clearSession = () => {
14521
- localStorage.removeItem('token');
14528
+ removeLocalStorageItem('token');
14522
14529
  // @ts-ignore
14523
14530
  window.store = {};
14524
14531
  };
14525
14532
  const onAuthenticationFailure = (msg) => {
14526
- localStorage.removeItem('token');
14533
+ removeLocalStorageItem('token');
14527
14534
  // displayPage(Page.LOGIN);
14528
14535
  alert(getTranslation(msg));
14529
14536
  };
@@ -14534,7 +14541,7 @@ var juxWeb = (function (exports) {
14534
14541
  // @ts-ignore
14535
14542
  window.store.currentUser = user;
14536
14543
  if (type === 'Token Authentication') {
14537
- user.token = localStorage.getItem('token');
14544
+ user.token = getLocalStorageItem('token');
14538
14545
  }
14539
14546
  onTokenAcquired(user.token, onUserLogin);
14540
14547
  // mixpanelIdentify(user);
@@ -14566,7 +14573,7 @@ var juxWeb = (function (exports) {
14566
14573
  const onError = () => onAuthenticationFailure('login-failed');
14567
14574
  getSSOAuthorizationEndpoint(onSuccess, onError);
14568
14575
  };
14569
- const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
14576
+ const initSession = ({ clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint, urlPrefix }) => {
14570
14577
  // if (startNewDemo()) {
14571
14578
  // initDemo(setBackendToken, onAuthentication);
14572
14579
  // return;
@@ -14582,6 +14589,8 @@ var juxWeb = (function (exports) {
14582
14589
  window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
14583
14590
  // @ts-ignore
14584
14591
  window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
14592
+ if (urlPrefix)
14593
+ setUrlPrefix(urlPrefix);
14585
14594
  const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
14586
14595
  if (signInToken) {
14587
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
3
  export declare const clearSession: () => 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;
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;
@@ -1003,12 +1010,12 @@ const onTokenAcquired = (token, onUserLogin) => {
1003
1010
  onUserLogin();
1004
1011
  };
1005
1012
  const clearSession = () => {
1006
- localStorage.removeItem('token');
1013
+ removeLocalStorageItem('token');
1007
1014
  // @ts-ignore
1008
1015
  window.store = {};
1009
1016
  };
1010
1017
  const onAuthenticationFailure = (msg) => {
1011
- localStorage.removeItem('token');
1018
+ removeLocalStorageItem('token');
1012
1019
  // displayPage(Page.LOGIN);
1013
1020
  alert(getTranslation(msg));
1014
1021
  };
@@ -1019,7 +1026,7 @@ const onAuthentication = (onUserLogin, user, type) => {
1019
1026
  // @ts-ignore
1020
1027
  window.store.currentUser = user;
1021
1028
  if (type === 'Token Authentication') {
1022
- user.token = localStorage.getItem('token');
1029
+ user.token = getLocalStorageItem('token');
1023
1030
  }
1024
1031
  onTokenAcquired(user.token, onUserLogin);
1025
1032
  // mixpanelIdentify(user);
@@ -1051,7 +1058,7 @@ const handleSSOLogin = () => {
1051
1058
  const onError = () => onAuthenticationFailure('login-failed');
1052
1059
  getSSOAuthorizationEndpoint(onSuccess, onError);
1053
1060
  };
1054
- const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
1061
+ const initSession = ({ clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint, urlPrefix }) => {
1055
1062
  // if (startNewDemo()) {
1056
1063
  // initDemo(setBackendToken, onAuthentication);
1057
1064
  // return;
@@ -1067,6 +1074,8 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError,
1067
1074
  window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
1068
1075
  // @ts-ignore
1069
1076
  window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
1077
+ if (urlPrefix)
1078
+ setUrlPrefix(urlPrefix);
1070
1079
  const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
1071
1080
  if (signInToken) {
1072
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;
@@ -1027,12 +1034,12 @@ const onTokenAcquired = (token, onUserLogin) => {
1027
1034
  onUserLogin();
1028
1035
  };
1029
1036
  const clearSession = () => {
1030
- localStorage.removeItem('token');
1037
+ removeLocalStorageItem('token');
1031
1038
  // @ts-ignore
1032
1039
  window.store = {};
1033
1040
  };
1034
1041
  const onAuthenticationFailure = (msg) => {
1035
- localStorage.removeItem('token');
1042
+ removeLocalStorageItem('token');
1036
1043
  // displayPage(Page.LOGIN);
1037
1044
  alert(getTranslation(msg));
1038
1045
  };
@@ -1043,7 +1050,7 @@ const onAuthentication = (onUserLogin, user, type) => {
1043
1050
  // @ts-ignore
1044
1051
  window.store.currentUser = user;
1045
1052
  if (type === 'Token Authentication') {
1046
- user.token = localStorage.getItem('token');
1053
+ user.token = getLocalStorageItem('token');
1047
1054
  }
1048
1055
  onTokenAcquired(user.token, onUserLogin);
1049
1056
  // mixpanelIdentify(user);
@@ -1075,7 +1082,7 @@ const handleSSOLogin = () => {
1075
1082
  const onError = () => onAuthenticationFailure('login-failed');
1076
1083
  getSSOAuthorizationEndpoint(onSuccess, onError);
1077
1084
  };
1078
- const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
1085
+ const initSession = ({ clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint, urlPrefix }) => {
1079
1086
  // if (startNewDemo()) {
1080
1087
  // initDemo(setBackendToken, onAuthentication);
1081
1088
  // return;
@@ -1091,6 +1098,8 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError,
1091
1098
  window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
1092
1099
  // @ts-ignore
1093
1100
  window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
1101
+ if (urlPrefix)
1102
+ setUrlPrefix(urlPrefix);
1094
1103
  const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
1095
1104
  if (signInToken) {
1096
1105
  const onOpenMagicLink = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klauswuestefeld/jux-web",
3
- "version": "2025.5.24-1",
3
+ "version": "2025.5.28",
4
4
  "author": "Jux.House",
5
5
  "license": "Copyrighted",
6
6
  "description": "",