@klauswuestefeld/jux-web 2024.12.17 → 2025.5.24
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 +18 -5
- package/dist/login/session.d.ts +1 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.esm.js +18 -6
- package/dist/main.js +18 -5
- package/package.json +1 -1
package/dist/jux-web.js
CHANGED
|
@@ -14517,11 +14517,13 @@ var juxWeb = (function (exports) {
|
|
|
14517
14517
|
// setSuperToken();
|
|
14518
14518
|
onUserLogin();
|
|
14519
14519
|
};
|
|
14520
|
-
const clearSession = () => {
|
|
14520
|
+
const clearSession = (itemsToSave) => {
|
|
14521
14521
|
// onUserChanged(null);
|
|
14522
14522
|
// TODO: find a better way to preserve backend-url
|
|
14523
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) }));
|
|
14524
14525
|
localStorage.clear();
|
|
14526
|
+
savedItems === null || savedItems === void 0 ? void 0 : savedItems.forEach((item) => localStorage.setItem(item.key, item.value));
|
|
14525
14527
|
setBackendUrl(backendUrl);
|
|
14526
14528
|
// @ts-ignore
|
|
14527
14529
|
window.store = {};
|
|
@@ -14548,13 +14550,23 @@ var juxWeb = (function (exports) {
|
|
|
14548
14550
|
Array.from(clientApp.children).forEach(el => el.remove());
|
|
14549
14551
|
clientApp.appendChild(page);
|
|
14550
14552
|
};
|
|
14551
|
-
const
|
|
14553
|
+
const getBaseElementHref = () => {
|
|
14554
|
+
const baseElement = document.getElementsByTagName('base')[0];
|
|
14555
|
+
if (!baseElement)
|
|
14556
|
+
return null;
|
|
14557
|
+
return baseElement.href || null;
|
|
14558
|
+
};
|
|
14559
|
+
const produceSSORedirectURI = () => {
|
|
14560
|
+
const baseElementHref = getBaseElementHref();
|
|
14561
|
+
if (baseElementHref)
|
|
14562
|
+
return baseElementHref;
|
|
14552
14563
|
const { protocol, host } = window.location;
|
|
14553
|
-
return protocol + '//' + host + '/
|
|
14564
|
+
return protocol + '//' + host + '/';
|
|
14554
14565
|
};
|
|
14566
|
+
const getSSORedirectURI = () => produceSSORedirectURI() + 'callback';
|
|
14555
14567
|
const handleSSOLogin = () => {
|
|
14556
14568
|
const onSuccess = (authEndpoint) => {
|
|
14557
|
-
const authUrl = authEndpoint + `&redirect_uri=${
|
|
14569
|
+
const authUrl = authEndpoint + `&redirect_uri=${getSSORedirectURI()}`;
|
|
14558
14570
|
window.location.replace(authUrl);
|
|
14559
14571
|
};
|
|
14560
14572
|
const onError = () => onAuthenticationFailure('login-failed');
|
|
@@ -14599,7 +14611,7 @@ var juxWeb = (function (exports) {
|
|
|
14599
14611
|
}
|
|
14600
14612
|
const ssoToken = extractTokenFromWindowLocation('code');
|
|
14601
14613
|
if (ssoToken) {
|
|
14602
|
-
validateSSOToken(ssoToken,
|
|
14614
|
+
validateSSOToken(ssoToken, getSSORedirectURI(), (res) => onAuthentication(onUserLogin, res, 'SSO Authentication'), (_res) => onAuthenticationFailure('login-failed'), (res) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
14603
14615
|
const jsonResponse = yield res.json();
|
|
14604
14616
|
const unauthorizedEmail = jsonResponse.email;
|
|
14605
14617
|
const onReturn = () => handleSSOLogin();
|
|
@@ -14951,6 +14963,7 @@ var juxWeb = (function (exports) {
|
|
|
14951
14963
|
};
|
|
14952
14964
|
|
|
14953
14965
|
exports.chosenLanguage = chosenLanguage;
|
|
14966
|
+
exports.clearSession = clearSession;
|
|
14954
14967
|
exports.command = command;
|
|
14955
14968
|
exports.getTranslation = getTranslation;
|
|
14956
14969
|
exports.handleJuxEvent = handleJuxEvent;
|
package/dist/login/session.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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;
|
|
3
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
5
|
export declare const onMicrosoftSignIn: (onUserLogin: any) => Promise<void>;
|
|
5
6
|
export declare const onGoogleSignIn: (onUserLogin: any) => void;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { chosenLanguage, reloadWithLanguageOverride, initLanguage, getTranslation } from './jux/language';
|
|
2
2
|
export { loginButton } from './login/login-button';
|
|
3
3
|
export { loginPage } from './login/login-page';
|
|
4
|
-
export { handleMagicLinkRequest, initSession, onMicrosoftSignIn } from './login/session';
|
|
4
|
+
export { handleMagicLinkRequest, initSession, onMicrosoftSignIn, clearSession } from './login/session';
|
|
5
5
|
export { handleJuxEvent, requestMagicLink } from './api-client';
|
|
6
6
|
export { magicLinkModal } from './login/magic-link-modal';
|
|
7
7
|
export { command, query } from './jux/jux-event';
|
package/dist/main.esm.js
CHANGED
|
@@ -1002,11 +1002,13 @@ const onTokenAcquired = (token, onUserLogin) => {
|
|
|
1002
1002
|
// setSuperToken();
|
|
1003
1003
|
onUserLogin();
|
|
1004
1004
|
};
|
|
1005
|
-
const clearSession = () => {
|
|
1005
|
+
const clearSession = (itemsToSave) => {
|
|
1006
1006
|
// onUserChanged(null);
|
|
1007
1007
|
// TODO: find a better way to preserve backend-url
|
|
1008
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) }));
|
|
1009
1010
|
localStorage.clear();
|
|
1011
|
+
savedItems === null || savedItems === void 0 ? void 0 : savedItems.forEach((item) => localStorage.setItem(item.key, item.value));
|
|
1010
1012
|
setBackendUrl(backendUrl);
|
|
1011
1013
|
// @ts-ignore
|
|
1012
1014
|
window.store = {};
|
|
@@ -1033,13 +1035,23 @@ const displayPage = (clientApp, page) => {
|
|
|
1033
1035
|
Array.from(clientApp.children).forEach(el => el.remove());
|
|
1034
1036
|
clientApp.appendChild(page);
|
|
1035
1037
|
};
|
|
1036
|
-
const
|
|
1038
|
+
const getBaseElementHref = () => {
|
|
1039
|
+
const baseElement = document.getElementsByTagName('base')[0];
|
|
1040
|
+
if (!baseElement)
|
|
1041
|
+
return null;
|
|
1042
|
+
return baseElement.href || null;
|
|
1043
|
+
};
|
|
1044
|
+
const produceSSORedirectURI = () => {
|
|
1045
|
+
const baseElementHref = getBaseElementHref();
|
|
1046
|
+
if (baseElementHref)
|
|
1047
|
+
return baseElementHref;
|
|
1037
1048
|
const { protocol, host } = window.location;
|
|
1038
|
-
return protocol + '//' + host + '/
|
|
1049
|
+
return protocol + '//' + host + '/';
|
|
1039
1050
|
};
|
|
1051
|
+
const getSSORedirectURI = () => produceSSORedirectURI() + 'callback';
|
|
1040
1052
|
const handleSSOLogin = () => {
|
|
1041
1053
|
const onSuccess = (authEndpoint) => {
|
|
1042
|
-
const authUrl = authEndpoint + `&redirect_uri=${
|
|
1054
|
+
const authUrl = authEndpoint + `&redirect_uri=${getSSORedirectURI()}`;
|
|
1043
1055
|
window.location.replace(authUrl);
|
|
1044
1056
|
};
|
|
1045
1057
|
const onError = () => onAuthenticationFailure('login-failed');
|
|
@@ -1084,7 +1096,7 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError,
|
|
|
1084
1096
|
}
|
|
1085
1097
|
const ssoToken = extractTokenFromWindowLocation('code');
|
|
1086
1098
|
if (ssoToken) {
|
|
1087
|
-
validateSSOToken(ssoToken,
|
|
1099
|
+
validateSSOToken(ssoToken, getSSORedirectURI(), (res) => onAuthentication(onUserLogin, res, 'SSO Authentication'), (_res) => onAuthenticationFailure('login-failed'), (res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1088
1100
|
const jsonResponse = yield res.json();
|
|
1089
1101
|
const unauthorizedEmail = jsonResponse.email;
|
|
1090
1102
|
const onReturn = () => handleSSOLogin();
|
|
@@ -1435,4 +1447,4 @@ const command = (element, endpoint, onResult, params, onError, onRedirect) => {
|
|
|
1435
1447
|
element.dispatchEvent(new JuxEvent('command', 'POST', endpoint, onResult, params, onError, onRedirect));
|
|
1436
1448
|
};
|
|
1437
1449
|
|
|
1438
|
-
export { chosenLanguage, command, getTranslation, handleJuxEvent, handleMagicLinkRequest, initLanguage, initSession, loginButton, loginPage, magicLinkModal, onMicrosoftSignIn, query, reloadWithLanguageOverride, requestMagicLink };
|
|
1450
|
+
export { chosenLanguage, clearSession, command, getTranslation, handleJuxEvent, handleMagicLinkRequest, initLanguage, initSession, loginButton, loginPage, magicLinkModal, onMicrosoftSignIn, query, reloadWithLanguageOverride, requestMagicLink };
|
package/dist/main.js
CHANGED
|
@@ -1026,11 +1026,13 @@ const onTokenAcquired = (token, onUserLogin) => {
|
|
|
1026
1026
|
// setSuperToken();
|
|
1027
1027
|
onUserLogin();
|
|
1028
1028
|
};
|
|
1029
|
-
const clearSession = () => {
|
|
1029
|
+
const clearSession = (itemsToSave) => {
|
|
1030
1030
|
// onUserChanged(null);
|
|
1031
1031
|
// TODO: find a better way to preserve backend-url
|
|
1032
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) }));
|
|
1033
1034
|
localStorage.clear();
|
|
1035
|
+
savedItems === null || savedItems === void 0 ? void 0 : savedItems.forEach((item) => localStorage.setItem(item.key, item.value));
|
|
1034
1036
|
setBackendUrl(backendUrl);
|
|
1035
1037
|
// @ts-ignore
|
|
1036
1038
|
window.store = {};
|
|
@@ -1057,13 +1059,23 @@ const displayPage = (clientApp, page) => {
|
|
|
1057
1059
|
Array.from(clientApp.children).forEach(el => el.remove());
|
|
1058
1060
|
clientApp.appendChild(page);
|
|
1059
1061
|
};
|
|
1060
|
-
const
|
|
1062
|
+
const getBaseElementHref = () => {
|
|
1063
|
+
const baseElement = document.getElementsByTagName('base')[0];
|
|
1064
|
+
if (!baseElement)
|
|
1065
|
+
return null;
|
|
1066
|
+
return baseElement.href || null;
|
|
1067
|
+
};
|
|
1068
|
+
const produceSSORedirectURI = () => {
|
|
1069
|
+
const baseElementHref = getBaseElementHref();
|
|
1070
|
+
if (baseElementHref)
|
|
1071
|
+
return baseElementHref;
|
|
1061
1072
|
const { protocol, host } = window.location;
|
|
1062
|
-
return protocol + '//' + host + '/
|
|
1073
|
+
return protocol + '//' + host + '/';
|
|
1063
1074
|
};
|
|
1075
|
+
const getSSORedirectURI = () => produceSSORedirectURI() + 'callback';
|
|
1064
1076
|
const handleSSOLogin = () => {
|
|
1065
1077
|
const onSuccess = (authEndpoint) => {
|
|
1066
|
-
const authUrl = authEndpoint + `&redirect_uri=${
|
|
1078
|
+
const authUrl = authEndpoint + `&redirect_uri=${getSSORedirectURI()}`;
|
|
1067
1079
|
window.location.replace(authUrl);
|
|
1068
1080
|
};
|
|
1069
1081
|
const onError = () => onAuthenticationFailure('login-failed');
|
|
@@ -1108,7 +1120,7 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError,
|
|
|
1108
1120
|
}
|
|
1109
1121
|
const ssoToken = extractTokenFromWindowLocation('code');
|
|
1110
1122
|
if (ssoToken) {
|
|
1111
|
-
validateSSOToken(ssoToken,
|
|
1123
|
+
validateSSOToken(ssoToken, getSSORedirectURI(), (res) => onAuthentication(onUserLogin, res, 'SSO Authentication'), (_res) => onAuthenticationFailure('login-failed'), (res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1112
1124
|
const jsonResponse = yield res.json();
|
|
1113
1125
|
const unauthorizedEmail = jsonResponse.email;
|
|
1114
1126
|
const onReturn = () => handleSSOLogin();
|
|
@@ -1460,6 +1472,7 @@ const command = (element, endpoint, onResult, params, onError, onRedirect) => {
|
|
|
1460
1472
|
};
|
|
1461
1473
|
|
|
1462
1474
|
exports.chosenLanguage = chosenLanguage;
|
|
1475
|
+
exports.clearSession = clearSession;
|
|
1463
1476
|
exports.command = command;
|
|
1464
1477
|
exports.getTranslation = getTranslation;
|
|
1465
1478
|
exports.handleJuxEvent = handleJuxEvent;
|