@klauswuestefeld/jux-web 2024.11.19 → 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.
@@ -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
- handleUnauthorized();
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 {
@@ -14391,7 +14392,15 @@ var juxWeb = (function (exports) {
14391
14392
  }
14392
14393
  const ssoToken = extractTokenFromWindowLocation('code');
14393
14394
  if (ssoToken) {
14394
- 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
+ }));
14395
14404
  return;
14396
14405
  }
14397
14406
  if (supportedLoginTypes.includes('SSO')) {
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
- handleUnauthorized();
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 {
@@ -1071,7 +1072,15 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImag
1071
1072
  }
1072
1073
  const ssoToken = extractTokenFromWindowLocation('code');
1073
1074
  if (ssoToken) {
1074
- 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
+ }));
1075
1084
  return;
1076
1085
  }
1077
1086
  if (supportedLoginTypes.includes('SSO')) {
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
- handleUnauthorized();
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 {
@@ -1095,7 +1096,15 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImag
1095
1096
  }
1096
1097
  const ssoToken = extractTokenFromWindowLocation('code');
1097
1098
  if (ssoToken) {
1098
- 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
+ }));
1099
1108
  return;
1100
1109
  }
1101
1110
  if (supportedLoginTypes.includes('SSO')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klauswuestefeld/jux-web",
3
- "version": "2024.11.19",
3
+ "version": "2024.11.25",
4
4
  "author": "Jux.House",
5
5
  "license": "Copyrighted",
6
6
  "description": "",