@klauswuestefeld/jux-web 2024.11.12 → 2024.11.25
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/api-client.d.ts +3 -3
- package/dist/jux-web.js +29 -19
- package/dist/login/session.d.ts +0 -1
- package/dist/main.esm.js +29 -19
- package/dist/main.js +29 -19
- package/package.json +1 -1
package/dist/api-client.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare const setBackendUrl: (backendUrl: string) => void;
|
|
2
2
|
export declare const getBackendUrl: () => string;
|
|
3
3
|
export declare const handleJuxEvent: (ev: Event) => void;
|
|
4
|
-
export declare const backendRequest: (url: string, options: any, onSuccess: any, onError: any, onRedirect?: any, requestType?: string, handleUnauthorized?: () => void, retrial?: boolean, retrialNum?: number) => Promise<any>;
|
|
4
|
+
export declare const backendRequest: (url: string, options: any, onSuccess: any, onError: any, onRedirect?: any, requestType?: string, handleUnauthorized?: (res: any) => void, retrial?: boolean, retrialNum?: number) => Promise<any>;
|
|
5
5
|
export declare const backendPost: (endpoint: string, postContent: any, onJsonResponse: (response: any) => any, onHelpMessage: (message: string) => any) => void;
|
|
6
|
-
export declare const backendGet: (endpoint: string, params: any, onJsonResponse: (response: any) => any, onHelpMessage: (message: string) => any) => void;
|
|
6
|
+
export declare const backendGet: (endpoint: string, params: any, onJsonResponse: (response: any) => any, onHelpMessage: (message: string) => any, handleUnauthorized?: any) => void;
|
|
7
7
|
export declare const requestMagicLink: (data: any, onJsonResponse: (response: any) => any, onUnauthorized: () => void) => void;
|
|
8
8
|
export declare const openMagicLink: (magicToken: string, onJsonResponse: (response: any) => any, onHelpMessage: (message: string) => any) => void;
|
|
9
9
|
export declare const googleLogin: (token: string, onLogin: (response: any) => any, onLoginError: (message: string) => any) => void;
|
|
10
10
|
export declare const microsoftLogin: (token: string, onLogin: (response: any) => any, onLoginError: (message: string) => any) => void;
|
|
11
11
|
export declare const getSSOAuthorizationEndpoint: (onSuccess: (response: any) => any, onError: (message: string) => any) => void;
|
|
12
|
-
export declare const validateSSOToken: (token: string, redirectUri: string, onLogin: (response: any) => any, onError: (message: string) => any) => void;
|
|
12
|
+
export declare const validateSSOToken: (token: string, redirectUri: string, onLogin: (response: any) => any, onError: (message: string) => any, handleUnauthorized: (response: any) => void) => void;
|
|
13
13
|
export declare const getMXData: (domainName: string) => Promise<any>;
|
package/dist/jux-web.js
CHANGED
|
@@ -279,7 +279,8 @@ var juxWeb = (function (exports) {
|
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
if (response.status === 401) {
|
|
282
|
-
|
|
282
|
+
requestRunning = false;
|
|
283
|
+
handleUnauthorized(response);
|
|
283
284
|
return;
|
|
284
285
|
}
|
|
285
286
|
try {
|
|
@@ -319,7 +320,7 @@ var juxWeb = (function (exports) {
|
|
|
319
320
|
}
|
|
320
321
|
return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect, requestType);
|
|
321
322
|
};
|
|
322
|
-
const get = (endpoint, onSuccess, onError, onRedirect) => {
|
|
323
|
+
const get = (endpoint, onSuccess, onError, onRedirect, handleUnauthorized) => {
|
|
323
324
|
const options = {
|
|
324
325
|
method: 'GET',
|
|
325
326
|
headers: {
|
|
@@ -327,12 +328,12 @@ var juxWeb = (function (exports) {
|
|
|
327
328
|
'Content-Type': 'application/json',
|
|
328
329
|
}
|
|
329
330
|
};
|
|
330
|
-
return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect);
|
|
331
|
+
return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect, 'query', handleUnauthorized);
|
|
331
332
|
};
|
|
332
333
|
const backendPost = (endpoint, postContent, onJsonResponse, onHelpMessage) => {
|
|
333
334
|
post(endpoint, postContent, onJsonResponse, onHelpMessage);
|
|
334
335
|
};
|
|
335
|
-
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage) => {
|
|
336
|
+
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage, handleUnauthorized) => {
|
|
336
337
|
if (params) {
|
|
337
338
|
endpoint += '?';
|
|
338
339
|
Object.keys(params).forEach((k, i) => {
|
|
@@ -341,7 +342,7 @@ var juxWeb = (function (exports) {
|
|
|
341
342
|
endpoint += `${k}=${params[k]}`;
|
|
342
343
|
});
|
|
343
344
|
}
|
|
344
|
-
get(endpoint, onJsonResponse, onHelpMessage);
|
|
345
|
+
get(endpoint, onJsonResponse, onHelpMessage, null, handleUnauthorized);
|
|
345
346
|
};
|
|
346
347
|
const requestMagicLink = (data, onJsonResponse, onUnauthorized) => {
|
|
347
348
|
const { email, token } = data;
|
|
@@ -363,8 +364,8 @@ var juxWeb = (function (exports) {
|
|
|
363
364
|
const getSSOAuthorizationEndpoint = (onSuccess, onError) => {
|
|
364
365
|
backendGet('openid/authorization-endpoint', null, onSuccess, onError);
|
|
365
366
|
};
|
|
366
|
-
const validateSSOToken = (token, redirectUri, onLogin, onError) => {
|
|
367
|
-
backendGet('openid/callback', { code: token, 'redirect-uri': redirectUri }, onLogin, onError);
|
|
367
|
+
const validateSSOToken = (token, redirectUri, onLogin, onError, handleUnauthorized) => {
|
|
368
|
+
backendGet('openid/callback', { code: token, 'redirect-uri': redirectUri }, onLogin, onError, handleUnauthorized);
|
|
368
369
|
};
|
|
369
370
|
const getMXData = (domainName) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
370
371
|
try {
|
|
@@ -14344,6 +14345,14 @@ var juxWeb = (function (exports) {
|
|
|
14344
14345
|
const { protocol, host } = window.location;
|
|
14345
14346
|
return protocol + '//' + host + '/callback';
|
|
14346
14347
|
};
|
|
14348
|
+
const handleSSOLogin = () => {
|
|
14349
|
+
const onSuccess = (authEndpoint) => {
|
|
14350
|
+
const authUrl = authEndpoint + `&redirect_uri=${getSSOCallbackURI()}`;
|
|
14351
|
+
window.location.replace(authUrl);
|
|
14352
|
+
};
|
|
14353
|
+
const onError = () => onAuthenticationFailure('login-failed');
|
|
14354
|
+
getSSOAuthorizationEndpoint(onSuccess, onError);
|
|
14355
|
+
};
|
|
14347
14356
|
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
14348
14357
|
// if (startNewDemo()) {
|
|
14349
14358
|
// initDemo(setBackendToken, onAuthentication);
|
|
@@ -14383,7 +14392,19 @@ var juxWeb = (function (exports) {
|
|
|
14383
14392
|
}
|
|
14384
14393
|
const ssoToken = extractTokenFromWindowLocation('code');
|
|
14385
14394
|
if (ssoToken) {
|
|
14386
|
-
validateSSOToken(ssoToken, getSSOCallbackURI(), (res) => onAuthentication(onUserLogin, res, 'SSO Authentication'), () => onAuthenticationFailure('login-failed'))
|
|
14395
|
+
validateSSOToken(ssoToken, getSSOCallbackURI(), (res) => onAuthentication(onUserLogin, res, 'SSO Authentication'), (_res) => onAuthenticationFailure('login-failed'), (res) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
14396
|
+
const jsonResponse = yield res.json();
|
|
14397
|
+
const unauthorizedEmail = jsonResponse.email;
|
|
14398
|
+
const onReturn = () => handleSSOLogin();
|
|
14399
|
+
const page = unauthorizedMagicLinkRequestPage(backgroundImage, onReturn);
|
|
14400
|
+
const magicLinkEmail = page.querySelector('#magic-link-email');
|
|
14401
|
+
magicLinkEmail.textContent = unauthorizedEmail;
|
|
14402
|
+
displayPage(clientApp, page);
|
|
14403
|
+
}));
|
|
14404
|
+
return;
|
|
14405
|
+
}
|
|
14406
|
+
if (supportedLoginTypes.includes('SSO')) {
|
|
14407
|
+
handleSSOLogin();
|
|
14387
14408
|
return;
|
|
14388
14409
|
}
|
|
14389
14410
|
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, supportedLoginTypes));
|
|
@@ -14428,14 +14449,6 @@ var juxWeb = (function (exports) {
|
|
|
14428
14449
|
authSignIn(onUserLogin);
|
|
14429
14450
|
}, onCookieError);
|
|
14430
14451
|
};
|
|
14431
|
-
const handleSSOLogin = () => {
|
|
14432
|
-
const onSuccess = (authEndpoint) => {
|
|
14433
|
-
const authUrl = authEndpoint + `&redirect_uri=${getSSOCallbackURI()}`;
|
|
14434
|
-
window.location.replace(authUrl);
|
|
14435
|
-
};
|
|
14436
|
-
const onError = () => onAuthenticationFailure('login-failed');
|
|
14437
|
-
getSSOAuthorizationEndpoint(onSuccess, onError);
|
|
14438
|
-
};
|
|
14439
14452
|
const handleMagicLinkRequest = (token, onReturn, backgroundImage, currentPage, clientBody, email = '') => {
|
|
14440
14453
|
if (!email) {
|
|
14441
14454
|
const mailMagic = document.querySelector('#mail-magic');
|
|
@@ -14629,9 +14642,6 @@ var juxWeb = (function (exports) {
|
|
|
14629
14642
|
if (loginTypes.includes('Email')) {
|
|
14630
14643
|
section.appendChild(loginButton('Email', () => onEmailLoginRequest(clientApp, loginPage, onUserLogin, backgroundImg, loginTypes)));
|
|
14631
14644
|
}
|
|
14632
|
-
if (loginTypes.includes('SSO')) {
|
|
14633
|
-
section.appendChild(loginButton('SSO', () => handleSSOLogin()));
|
|
14634
|
-
}
|
|
14635
14645
|
};
|
|
14636
14646
|
const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
14637
14647
|
const content = [];
|
package/dist/login/session.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ export declare const onTokenAcquired: (token: string, onUserLogin: any) => void;
|
|
|
3
3
|
export declare const initSession: (clientApp: HTMLElement, supportedLoginTypes: string[], onUserLogin: any, backgroundImage: string, fetchUserBackendUrl: any, magicLinkRequestEndpoint: string | null, magicLinkAuthEndpoint: string | null) => void;
|
|
4
4
|
export declare const onMicrosoftSignIn: (onUserLogin: any) => Promise<void>;
|
|
5
5
|
export declare const onGoogleSignIn: (onUserLogin: any) => void;
|
|
6
|
-
export declare const handleSSOLogin: () => void;
|
|
7
6
|
export declare const handleMagicLinkRequest: (token: string | null, onReturn: any, backgroundImage: string, currentPage: HTMLElement, clientBody: HTMLElement, email?: string) => void;
|
package/dist/main.esm.js
CHANGED
|
@@ -278,7 +278,8 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
|
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
280
|
if (response.status === 401) {
|
|
281
|
-
|
|
281
|
+
requestRunning = false;
|
|
282
|
+
handleUnauthorized(response);
|
|
282
283
|
return;
|
|
283
284
|
}
|
|
284
285
|
try {
|
|
@@ -318,7 +319,7 @@ const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "que
|
|
|
318
319
|
}
|
|
319
320
|
return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect, requestType);
|
|
320
321
|
};
|
|
321
|
-
const get = (endpoint, onSuccess, onError, onRedirect) => {
|
|
322
|
+
const get = (endpoint, onSuccess, onError, onRedirect, handleUnauthorized) => {
|
|
322
323
|
const options = {
|
|
323
324
|
method: 'GET',
|
|
324
325
|
headers: {
|
|
@@ -326,12 +327,12 @@ const get = (endpoint, onSuccess, onError, onRedirect) => {
|
|
|
326
327
|
'Content-Type': 'application/json',
|
|
327
328
|
}
|
|
328
329
|
};
|
|
329
|
-
return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect);
|
|
330
|
+
return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect, 'query', handleUnauthorized);
|
|
330
331
|
};
|
|
331
332
|
const backendPost = (endpoint, postContent, onJsonResponse, onHelpMessage) => {
|
|
332
333
|
post(endpoint, postContent, onJsonResponse, onHelpMessage);
|
|
333
334
|
};
|
|
334
|
-
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage) => {
|
|
335
|
+
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage, handleUnauthorized) => {
|
|
335
336
|
if (params) {
|
|
336
337
|
endpoint += '?';
|
|
337
338
|
Object.keys(params).forEach((k, i) => {
|
|
@@ -340,7 +341,7 @@ const backendGet = (endpoint, params, onJsonResponse, onHelpMessage) => {
|
|
|
340
341
|
endpoint += `${k}=${params[k]}`;
|
|
341
342
|
});
|
|
342
343
|
}
|
|
343
|
-
get(endpoint, onJsonResponse, onHelpMessage);
|
|
344
|
+
get(endpoint, onJsonResponse, onHelpMessage, null, handleUnauthorized);
|
|
344
345
|
};
|
|
345
346
|
const requestMagicLink = (data, onJsonResponse, onUnauthorized) => {
|
|
346
347
|
const { email, token } = data;
|
|
@@ -362,8 +363,8 @@ const microsoftLogin = (token, onLogin, onLoginError) => {
|
|
|
362
363
|
const getSSOAuthorizationEndpoint = (onSuccess, onError) => {
|
|
363
364
|
backendGet('openid/authorization-endpoint', null, onSuccess, onError);
|
|
364
365
|
};
|
|
365
|
-
const validateSSOToken = (token, redirectUri, onLogin, onError) => {
|
|
366
|
-
backendGet('openid/callback', { code: token, 'redirect-uri': redirectUri }, onLogin, onError);
|
|
366
|
+
const validateSSOToken = (token, redirectUri, onLogin, onError, handleUnauthorized) => {
|
|
367
|
+
backendGet('openid/callback', { code: token, 'redirect-uri': redirectUri }, onLogin, onError, handleUnauthorized);
|
|
367
368
|
};
|
|
368
369
|
const getMXData = (domainName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
369
370
|
try {
|
|
@@ -1024,6 +1025,14 @@ const getSSOCallbackURI = () => {
|
|
|
1024
1025
|
const { protocol, host } = window.location;
|
|
1025
1026
|
return protocol + '//' + host + '/callback';
|
|
1026
1027
|
};
|
|
1028
|
+
const handleSSOLogin = () => {
|
|
1029
|
+
const onSuccess = (authEndpoint) => {
|
|
1030
|
+
const authUrl = authEndpoint + `&redirect_uri=${getSSOCallbackURI()}`;
|
|
1031
|
+
window.location.replace(authUrl);
|
|
1032
|
+
};
|
|
1033
|
+
const onError = () => onAuthenticationFailure('login-failed');
|
|
1034
|
+
getSSOAuthorizationEndpoint(onSuccess, onError);
|
|
1035
|
+
};
|
|
1027
1036
|
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
1028
1037
|
// if (startNewDemo()) {
|
|
1029
1038
|
// initDemo(setBackendToken, onAuthentication);
|
|
@@ -1063,7 +1072,19 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImag
|
|
|
1063
1072
|
}
|
|
1064
1073
|
const ssoToken = extractTokenFromWindowLocation('code');
|
|
1065
1074
|
if (ssoToken) {
|
|
1066
|
-
validateSSOToken(ssoToken, getSSOCallbackURI(), (res) => onAuthentication(onUserLogin, res, 'SSO Authentication'), () => onAuthenticationFailure('login-failed'))
|
|
1075
|
+
validateSSOToken(ssoToken, getSSOCallbackURI(), (res) => onAuthentication(onUserLogin, res, 'SSO Authentication'), (_res) => onAuthenticationFailure('login-failed'), (res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1076
|
+
const jsonResponse = yield res.json();
|
|
1077
|
+
const unauthorizedEmail = jsonResponse.email;
|
|
1078
|
+
const onReturn = () => handleSSOLogin();
|
|
1079
|
+
const page = unauthorizedMagicLinkRequestPage(backgroundImage, onReturn);
|
|
1080
|
+
const magicLinkEmail = page.querySelector('#magic-link-email');
|
|
1081
|
+
magicLinkEmail.textContent = unauthorizedEmail;
|
|
1082
|
+
displayPage(clientApp, page);
|
|
1083
|
+
}));
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (supportedLoginTypes.includes('SSO')) {
|
|
1087
|
+
handleSSOLogin();
|
|
1067
1088
|
return;
|
|
1068
1089
|
}
|
|
1069
1090
|
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, supportedLoginTypes));
|
|
@@ -1108,14 +1129,6 @@ const onGoogleSignIn = (onUserLogin) => {
|
|
|
1108
1129
|
authSignIn(onUserLogin);
|
|
1109
1130
|
}, onCookieError);
|
|
1110
1131
|
};
|
|
1111
|
-
const handleSSOLogin = () => {
|
|
1112
|
-
const onSuccess = (authEndpoint) => {
|
|
1113
|
-
const authUrl = authEndpoint + `&redirect_uri=${getSSOCallbackURI()}`;
|
|
1114
|
-
window.location.replace(authUrl);
|
|
1115
|
-
};
|
|
1116
|
-
const onError = () => onAuthenticationFailure('login-failed');
|
|
1117
|
-
getSSOAuthorizationEndpoint(onSuccess, onError);
|
|
1118
|
-
};
|
|
1119
1132
|
const handleMagicLinkRequest = (token, onReturn, backgroundImage, currentPage, clientBody, email = '') => {
|
|
1120
1133
|
if (!email) {
|
|
1121
1134
|
const mailMagic = document.querySelector('#mail-magic');
|
|
@@ -1309,9 +1322,6 @@ const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, loginTypes
|
|
|
1309
1322
|
if (loginTypes.includes('Email')) {
|
|
1310
1323
|
section.appendChild(loginButton('Email', () => onEmailLoginRequest(clientApp, loginPage, onUserLogin, backgroundImg, loginTypes)));
|
|
1311
1324
|
}
|
|
1312
|
-
if (loginTypes.includes('SSO')) {
|
|
1313
|
-
section.appendChild(loginButton('SSO', () => handleSSOLogin()));
|
|
1314
|
-
}
|
|
1315
1325
|
};
|
|
1316
1326
|
const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
1317
1327
|
const content = [];
|
package/dist/main.js
CHANGED
|
@@ -302,7 +302,8 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
|
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
304
|
if (response.status === 401) {
|
|
305
|
-
|
|
305
|
+
requestRunning = false;
|
|
306
|
+
handleUnauthorized(response);
|
|
306
307
|
return;
|
|
307
308
|
}
|
|
308
309
|
try {
|
|
@@ -342,7 +343,7 @@ const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "que
|
|
|
342
343
|
}
|
|
343
344
|
return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect, requestType);
|
|
344
345
|
};
|
|
345
|
-
const get = (endpoint, onSuccess, onError, onRedirect) => {
|
|
346
|
+
const get = (endpoint, onSuccess, onError, onRedirect, handleUnauthorized) => {
|
|
346
347
|
const options = {
|
|
347
348
|
method: 'GET',
|
|
348
349
|
headers: {
|
|
@@ -350,12 +351,12 @@ const get = (endpoint, onSuccess, onError, onRedirect) => {
|
|
|
350
351
|
'Content-Type': 'application/json',
|
|
351
352
|
}
|
|
352
353
|
};
|
|
353
|
-
return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect);
|
|
354
|
+
return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect, 'query', handleUnauthorized);
|
|
354
355
|
};
|
|
355
356
|
const backendPost = (endpoint, postContent, onJsonResponse, onHelpMessage) => {
|
|
356
357
|
post(endpoint, postContent, onJsonResponse, onHelpMessage);
|
|
357
358
|
};
|
|
358
|
-
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage) => {
|
|
359
|
+
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage, handleUnauthorized) => {
|
|
359
360
|
if (params) {
|
|
360
361
|
endpoint += '?';
|
|
361
362
|
Object.keys(params).forEach((k, i) => {
|
|
@@ -364,7 +365,7 @@ const backendGet = (endpoint, params, onJsonResponse, onHelpMessage) => {
|
|
|
364
365
|
endpoint += `${k}=${params[k]}`;
|
|
365
366
|
});
|
|
366
367
|
}
|
|
367
|
-
get(endpoint, onJsonResponse, onHelpMessage);
|
|
368
|
+
get(endpoint, onJsonResponse, onHelpMessage, null, handleUnauthorized);
|
|
368
369
|
};
|
|
369
370
|
const requestMagicLink = (data, onJsonResponse, onUnauthorized) => {
|
|
370
371
|
const { email, token } = data;
|
|
@@ -386,8 +387,8 @@ const microsoftLogin = (token, onLogin, onLoginError) => {
|
|
|
386
387
|
const getSSOAuthorizationEndpoint = (onSuccess, onError) => {
|
|
387
388
|
backendGet('openid/authorization-endpoint', null, onSuccess, onError);
|
|
388
389
|
};
|
|
389
|
-
const validateSSOToken = (token, redirectUri, onLogin, onError) => {
|
|
390
|
-
backendGet('openid/callback', { code: token, 'redirect-uri': redirectUri }, onLogin, onError);
|
|
390
|
+
const validateSSOToken = (token, redirectUri, onLogin, onError, handleUnauthorized) => {
|
|
391
|
+
backendGet('openid/callback', { code: token, 'redirect-uri': redirectUri }, onLogin, onError, handleUnauthorized);
|
|
391
392
|
};
|
|
392
393
|
const getMXData = (domainName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
393
394
|
try {
|
|
@@ -1048,6 +1049,14 @@ const getSSOCallbackURI = () => {
|
|
|
1048
1049
|
const { protocol, host } = window.location;
|
|
1049
1050
|
return protocol + '//' + host + '/callback';
|
|
1050
1051
|
};
|
|
1052
|
+
const handleSSOLogin = () => {
|
|
1053
|
+
const onSuccess = (authEndpoint) => {
|
|
1054
|
+
const authUrl = authEndpoint + `&redirect_uri=${getSSOCallbackURI()}`;
|
|
1055
|
+
window.location.replace(authUrl);
|
|
1056
|
+
};
|
|
1057
|
+
const onError = () => onAuthenticationFailure('login-failed');
|
|
1058
|
+
getSSOAuthorizationEndpoint(onSuccess, onError);
|
|
1059
|
+
};
|
|
1051
1060
|
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
1052
1061
|
// if (startNewDemo()) {
|
|
1053
1062
|
// initDemo(setBackendToken, onAuthentication);
|
|
@@ -1087,7 +1096,19 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImag
|
|
|
1087
1096
|
}
|
|
1088
1097
|
const ssoToken = extractTokenFromWindowLocation('code');
|
|
1089
1098
|
if (ssoToken) {
|
|
1090
|
-
validateSSOToken(ssoToken, getSSOCallbackURI(), (res) => onAuthentication(onUserLogin, res, 'SSO Authentication'), () => onAuthenticationFailure('login-failed'))
|
|
1099
|
+
validateSSOToken(ssoToken, getSSOCallbackURI(), (res) => onAuthentication(onUserLogin, res, 'SSO Authentication'), (_res) => onAuthenticationFailure('login-failed'), (res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1100
|
+
const jsonResponse = yield res.json();
|
|
1101
|
+
const unauthorizedEmail = jsonResponse.email;
|
|
1102
|
+
const onReturn = () => handleSSOLogin();
|
|
1103
|
+
const page = unauthorizedMagicLinkRequestPage(backgroundImage, onReturn);
|
|
1104
|
+
const magicLinkEmail = page.querySelector('#magic-link-email');
|
|
1105
|
+
magicLinkEmail.textContent = unauthorizedEmail;
|
|
1106
|
+
displayPage(clientApp, page);
|
|
1107
|
+
}));
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
if (supportedLoginTypes.includes('SSO')) {
|
|
1111
|
+
handleSSOLogin();
|
|
1091
1112
|
return;
|
|
1092
1113
|
}
|
|
1093
1114
|
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, supportedLoginTypes));
|
|
@@ -1132,14 +1153,6 @@ const onGoogleSignIn = (onUserLogin) => {
|
|
|
1132
1153
|
authSignIn(onUserLogin);
|
|
1133
1154
|
}, onCookieError);
|
|
1134
1155
|
};
|
|
1135
|
-
const handleSSOLogin = () => {
|
|
1136
|
-
const onSuccess = (authEndpoint) => {
|
|
1137
|
-
const authUrl = authEndpoint + `&redirect_uri=${getSSOCallbackURI()}`;
|
|
1138
|
-
window.location.replace(authUrl);
|
|
1139
|
-
};
|
|
1140
|
-
const onError = () => onAuthenticationFailure('login-failed');
|
|
1141
|
-
getSSOAuthorizationEndpoint(onSuccess, onError);
|
|
1142
|
-
};
|
|
1143
1156
|
const handleMagicLinkRequest = (token, onReturn, backgroundImage, currentPage, clientBody, email = '') => {
|
|
1144
1157
|
if (!email) {
|
|
1145
1158
|
const mailMagic = document.querySelector('#mail-magic');
|
|
@@ -1333,9 +1346,6 @@ const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, loginTypes
|
|
|
1333
1346
|
if (loginTypes.includes('Email')) {
|
|
1334
1347
|
section.appendChild(loginButton('Email', () => onEmailLoginRequest(clientApp, loginPage, onUserLogin, backgroundImg, loginTypes)));
|
|
1335
1348
|
}
|
|
1336
|
-
if (loginTypes.includes('SSO')) {
|
|
1337
|
-
section.appendChild(loginButton('SSO', () => handleSSOLogin()));
|
|
1338
|
-
}
|
|
1339
1349
|
};
|
|
1340
1350
|
const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
1341
1351
|
const content = [];
|