@klauswuestefeld/jux-web 2024.12.9 → 2025.2.11

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
@@ -311,7 +311,7 @@ var juxWeb = (function (exports) {
311
311
  requestRunning = false;
312
312
  }
313
313
  });
314
- const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "query", handleUnauthorized) => {
314
+ const post = (endpoint, params, onSuccess, onError, onRedirect, requestType = "query", handleUnauthorized) => {
315
315
  const options = {
316
316
  method: 'POST',
317
317
  headers: {
@@ -319,9 +319,13 @@ var juxWeb = (function (exports) {
319
319
  'Content-Type': 'application/json',
320
320
  }
321
321
  };
322
- if (body) {
322
+ if (params) {
323
+ let content = params;
324
+ if (!(params instanceof File)) {
325
+ content = JSON.stringify(params);
326
+ }
323
327
  // @ts-ignore
324
- options.body = JSON.stringify(body);
328
+ options.body = content;
325
329
  }
326
330
  return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect, requestType, handleUnauthorized);
327
331
  };
@@ -14513,11 +14517,13 @@ var juxWeb = (function (exports) {
14513
14517
  // setSuperToken();
14514
14518
  onUserLogin();
14515
14519
  };
14516
- const clearSession = () => {
14520
+ const clearSession = (itemsToSave) => {
14517
14521
  // onUserChanged(null);
14518
14522
  // TODO: find a better way to preserve backend-url
14519
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) }));
14520
14525
  localStorage.clear();
14526
+ savedItems === null || savedItems === void 0 ? void 0 : savedItems.forEach((item) => localStorage.setItem(item.key, item.value));
14521
14527
  setBackendUrl(backendUrl);
14522
14528
  // @ts-ignore
14523
14529
  window.store = {};
@@ -14947,6 +14953,7 @@ var juxWeb = (function (exports) {
14947
14953
  };
14948
14954
 
14949
14955
  exports.chosenLanguage = chosenLanguage;
14956
+ exports.clearSession = clearSession;
14950
14957
  exports.command = command;
14951
14958
  exports.getTranslation = getTranslation;
14952
14959
  exports.handleJuxEvent = handleJuxEvent;
@@ -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
@@ -310,7 +310,7 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
310
310
  requestRunning = false;
311
311
  }
312
312
  });
313
- const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "query", handleUnauthorized) => {
313
+ const post = (endpoint, params, onSuccess, onError, onRedirect, requestType = "query", handleUnauthorized) => {
314
314
  const options = {
315
315
  method: 'POST',
316
316
  headers: {
@@ -318,9 +318,13 @@ const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "que
318
318
  'Content-Type': 'application/json',
319
319
  }
320
320
  };
321
- if (body) {
321
+ if (params) {
322
+ let content = params;
323
+ if (!(params instanceof File)) {
324
+ content = JSON.stringify(params);
325
+ }
322
326
  // @ts-ignore
323
- options.body = JSON.stringify(body);
327
+ options.body = content;
324
328
  }
325
329
  return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect, requestType, handleUnauthorized);
326
330
  };
@@ -998,11 +1002,13 @@ const onTokenAcquired = (token, onUserLogin) => {
998
1002
  // setSuperToken();
999
1003
  onUserLogin();
1000
1004
  };
1001
- const clearSession = () => {
1005
+ const clearSession = (itemsToSave) => {
1002
1006
  // onUserChanged(null);
1003
1007
  // TODO: find a better way to preserve backend-url
1004
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) }));
1005
1010
  localStorage.clear();
1011
+ savedItems === null || savedItems === void 0 ? void 0 : savedItems.forEach((item) => localStorage.setItem(item.key, item.value));
1006
1012
  setBackendUrl(backendUrl);
1007
1013
  // @ts-ignore
1008
1014
  window.store = {};
@@ -1431,4 +1437,4 @@ const command = (element, endpoint, onResult, params, onError, onRedirect) => {
1431
1437
  element.dispatchEvent(new JuxEvent('command', 'POST', endpoint, onResult, params, onError, onRedirect));
1432
1438
  };
1433
1439
 
1434
- export { chosenLanguage, command, getTranslation, handleJuxEvent, handleMagicLinkRequest, initLanguage, initSession, loginButton, loginPage, magicLinkModal, onMicrosoftSignIn, query, reloadWithLanguageOverride, requestMagicLink };
1440
+ export { chosenLanguage, clearSession, command, getTranslation, handleJuxEvent, handleMagicLinkRequest, initLanguage, initSession, loginButton, loginPage, magicLinkModal, onMicrosoftSignIn, query, reloadWithLanguageOverride, requestMagicLink };
package/dist/main.js CHANGED
@@ -334,7 +334,7 @@ const backendRequest = (url_1, options_1, onSuccess_1, onError_1, onRedirect_1,
334
334
  requestRunning = false;
335
335
  }
336
336
  });
337
- const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "query", handleUnauthorized) => {
337
+ const post = (endpoint, params, onSuccess, onError, onRedirect, requestType = "query", handleUnauthorized) => {
338
338
  const options = {
339
339
  method: 'POST',
340
340
  headers: {
@@ -342,9 +342,13 @@ const post = (endpoint, body, onSuccess, onError, onRedirect, requestType = "que
342
342
  'Content-Type': 'application/json',
343
343
  }
344
344
  };
345
- if (body) {
345
+ if (params) {
346
+ let content = params;
347
+ if (!(params instanceof File)) {
348
+ content = JSON.stringify(params);
349
+ }
346
350
  // @ts-ignore
347
- options.body = JSON.stringify(body);
351
+ options.body = content;
348
352
  }
349
353
  return backendRequest(getApiUrl() + endpoint, options, onSuccess, onError, onRedirect, requestType, handleUnauthorized);
350
354
  };
@@ -1022,11 +1026,13 @@ const onTokenAcquired = (token, onUserLogin) => {
1022
1026
  // setSuperToken();
1023
1027
  onUserLogin();
1024
1028
  };
1025
- const clearSession = () => {
1029
+ const clearSession = (itemsToSave) => {
1026
1030
  // onUserChanged(null);
1027
1031
  // TODO: find a better way to preserve backend-url
1028
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) }));
1029
1034
  localStorage.clear();
1035
+ savedItems === null || savedItems === void 0 ? void 0 : savedItems.forEach((item) => localStorage.setItem(item.key, item.value));
1030
1036
  setBackendUrl(backendUrl);
1031
1037
  // @ts-ignore
1032
1038
  window.store = {};
@@ -1456,6 +1462,7 @@ const command = (element, endpoint, onResult, params, onError, onRedirect) => {
1456
1462
  };
1457
1463
 
1458
1464
  exports.chosenLanguage = chosenLanguage;
1465
+ exports.clearSession = clearSession;
1459
1466
  exports.command = command;
1460
1467
  exports.getTranslation = getTranslation;
1461
1468
  exports.handleJuxEvent = handleJuxEvent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klauswuestefeld/jux-web",
3
- "version": "2024.12.9",
3
+ "version": "2025.02.11",
4
4
  "author": "Jux.House",
5
5
  "license": "Copyrighted",
6
6
  "description": "",