@telicent-oss/ds 0.27.4 → 0.27.6

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/ds.js CHANGED
@@ -80471,6 +80471,13 @@ const FeatureMap = ({
80471
80471
  /* @__PURE__ */ jsx$1(FlexGridItem, { flexGrow: 0, p: 1, children: /* @__PURE__ */ jsx$1(LayerSelector, { ...styleSelector.props }) })
80472
80472
  ] }) }) }) });
80473
80473
  };
80474
+ var AuthEvent = /* @__PURE__ */ ((AuthEvent2) => {
80475
+ AuthEvent2["AUTHENTICATED"] = "authenticated";
80476
+ AuthEvent2["REAUTHENTICATED"] = "reauthenticated";
80477
+ AuthEvent2["USER_CHANGED"] = "user-changed";
80478
+ AuthEvent2["UNAUTHORIZED"] = "unauthorized";
80479
+ return AuthEvent2;
80480
+ })(AuthEvent || {});
80474
80481
  const listeners = /* @__PURE__ */ new Set();
80475
80482
  let lastMessage = null;
80476
80483
  const bc = new BroadcastChannel("auth-events");
@@ -80503,19 +80510,22 @@ const AuthModal = ({
80503
80510
  };
80504
80511
  useEffect(() => {
80505
80512
  const unsubscribe = onAuthEvent((event) => {
80506
- if (event === "unauthorized" && !alreadyTriggered.current) {
80513
+ if (event === AuthEvent.UNAUTHORIZED && !alreadyTriggered.current) {
80507
80514
  setIsOpen(true);
80508
80515
  alreadyTriggered.current = true;
80509
80516
  setTimeout(() => {
80510
80517
  alreadyTriggered.current = false;
80511
80518
  }, debounceMs);
80512
- } else if (event === "authorized") {
80519
+ } else if (event === AuthEvent.AUTHENTICATED || event === AuthEvent.REAUTHENTICATED) {
80513
80520
  setIsOpen(false);
80514
80521
  alreadyTriggered.current = false;
80515
80522
  }
80516
80523
  });
80517
80524
  return unsubscribe;
80518
80525
  }, []);
80526
+ const handleCloseClick = () => {
80527
+ setIsOpen(false);
80528
+ };
80519
80529
  return /* @__PURE__ */ jsx$1(Modal2, { hideCloseButton: true, onClose: () => {
80520
80530
  }, sx: {
80521
80531
  m: 2,
@@ -80535,9 +80545,31 @@ const AuthModal = ({
80535
80545
  /* @__PURE__ */ jsx$1(Text, { sx: {
80536
80546
  pt: 4
80537
80547
  }, children: "If you continue to have issues, contact your system administrator." }),
80538
- /* @__PURE__ */ jsx$1(Box, { ml: "auto", mt: 2, children: /* @__PURE__ */ jsx$1(Button2, { variant: "primary", onClick: handleLoginClick, size: "large", children: "Login" }) })
80548
+ /* @__PURE__ */ jsxs(FlexBox, { ml: "auto", mt: 2, gap: 1, direction: "row", children: [
80549
+ /* @__PURE__ */ jsx$1(Button2, { variant: "secondary", disableElevation: true, onClick: handleCloseClick, size: "large", children: "Close" }),
80550
+ /* @__PURE__ */ jsx$1(Button2, { variant: "primary", onClick: handleLoginClick, size: "large", children: "Login" })
80551
+ ] })
80539
80552
  ] }) });
80540
80553
  };
80554
+ const registerAuthSync = (queryClient2) => onAuthEvent((event) => {
80555
+ switch (event) {
80556
+ case AuthEvent.AUTHENTICATED:
80557
+ case AuthEvent.REAUTHENTICATED:
80558
+ queryClient2.refetchQueries({
80559
+ stale: true
80560
+ });
80561
+ break;
80562
+ case AuthEvent.USER_CHANGED:
80563
+ window.location.reload();
80564
+ break;
80565
+ }
80566
+ });
80567
+ const useAuthSync = (queryClient2) => {
80568
+ useEffect(() => {
80569
+ const unsubscribe = registerAuthSync(queryClient2);
80570
+ return unsubscribe;
80571
+ }, [queryClient2]);
80572
+ };
80541
80573
  function bind(fn2, thisArg) {
80542
80574
  return function wrap() {
80543
80575
  return fn2.apply(thisArg, arguments);
@@ -82937,7 +82969,7 @@ function withSessionHandling(instance, {
82937
82969
  exact: true
82938
82970
  }));
82939
82971
  }
82940
- broadcastChannel == null ? void 0 : broadcastChannel.postMessage("unauthorized");
82972
+ broadcastChannel == null ? void 0 : broadcastChannel.postMessage(AuthEvent.UNAUTHORIZED);
82941
82973
  }
82942
82974
  return Promise.reject(err);
82943
82975
  });
@@ -84298,6 +84330,7 @@ export {
84298
84330
  AppChrome,
84299
84331
  AppSwitch,
84300
84332
  AppSwitchLibrarySchema,
84333
+ AuthEvent,
84301
84334
  AuthModal,
84302
84335
  BinIcon,
84303
84336
  Button2 as Button,
@@ -84432,11 +84465,13 @@ export {
84432
84465
  loggerLevelOrder,
84433
84466
  onAuthEvent,
84434
84467
  parseOrThrowWithInput,
84468
+ registerAuthSync,
84435
84469
  renderErrorToHtml,
84436
84470
  requestWipe,
84437
84471
  setupWipe,
84438
84472
  toStringEncoded,
84439
84473
  uriComponentCodec,
84474
+ useAuthSync,
84440
84475
  useDebounce,
84441
84476
  useExtendedTheme,
84442
84477
  useFloatingPanels
package/dist/ds.umd.cjs CHANGED
@@ -80489,6 +80489,13 @@ uniform ${i3} ${s4} u_${a3};
80489
80489
  /* @__PURE__ */ jsx$1(FlexGridItem, { flexGrow: 0, p: 1, children: /* @__PURE__ */ jsx$1(LayerSelector, { ...styleSelector.props }) })
80490
80490
  ] }) }) }) });
80491
80491
  };
80492
+ var AuthEvent = /* @__PURE__ */ ((AuthEvent2) => {
80493
+ AuthEvent2["AUTHENTICATED"] = "authenticated";
80494
+ AuthEvent2["REAUTHENTICATED"] = "reauthenticated";
80495
+ AuthEvent2["USER_CHANGED"] = "user-changed";
80496
+ AuthEvent2["UNAUTHORIZED"] = "unauthorized";
80497
+ return AuthEvent2;
80498
+ })(AuthEvent || {});
80492
80499
  const listeners = /* @__PURE__ */ new Set();
80493
80500
  let lastMessage = null;
80494
80501
  const bc = new BroadcastChannel("auth-events");
@@ -80521,19 +80528,22 @@ uniform ${i3} ${s4} u_${a3};
80521
80528
  };
80522
80529
  React$2.useEffect(() => {
80523
80530
  const unsubscribe = onAuthEvent((event) => {
80524
- if (event === "unauthorized" && !alreadyTriggered.current) {
80531
+ if (event === AuthEvent.UNAUTHORIZED && !alreadyTriggered.current) {
80525
80532
  setIsOpen(true);
80526
80533
  alreadyTriggered.current = true;
80527
80534
  setTimeout(() => {
80528
80535
  alreadyTriggered.current = false;
80529
80536
  }, debounceMs);
80530
- } else if (event === "authorized") {
80537
+ } else if (event === AuthEvent.AUTHENTICATED || event === AuthEvent.REAUTHENTICATED) {
80531
80538
  setIsOpen(false);
80532
80539
  alreadyTriggered.current = false;
80533
80540
  }
80534
80541
  });
80535
80542
  return unsubscribe;
80536
80543
  }, []);
80544
+ const handleCloseClick = () => {
80545
+ setIsOpen(false);
80546
+ };
80537
80547
  return /* @__PURE__ */ jsx$1(Modal, { hideCloseButton: true, onClose: () => {
80538
80548
  }, sx: {
80539
80549
  m: 2,
@@ -80553,9 +80563,31 @@ uniform ${i3} ${s4} u_${a3};
80553
80563
  /* @__PURE__ */ jsx$1(Text, { sx: {
80554
80564
  pt: 4
80555
80565
  }, children: "If you continue to have issues, contact your system administrator." }),
80556
- /* @__PURE__ */ jsx$1(Box, { ml: "auto", mt: 2, children: /* @__PURE__ */ jsx$1(Button, { variant: "primary", onClick: handleLoginClick, size: "large", children: "Login" }) })
80566
+ /* @__PURE__ */ jsxs(FlexBox, { ml: "auto", mt: 2, gap: 1, direction: "row", children: [
80567
+ /* @__PURE__ */ jsx$1(Button, { variant: "secondary", disableElevation: true, onClick: handleCloseClick, size: "large", children: "Close" }),
80568
+ /* @__PURE__ */ jsx$1(Button, { variant: "primary", onClick: handleLoginClick, size: "large", children: "Login" })
80569
+ ] })
80557
80570
  ] }) });
80558
80571
  };
80572
+ const registerAuthSync = (queryClient2) => onAuthEvent((event) => {
80573
+ switch (event) {
80574
+ case AuthEvent.AUTHENTICATED:
80575
+ case AuthEvent.REAUTHENTICATED:
80576
+ queryClient2.refetchQueries({
80577
+ stale: true
80578
+ });
80579
+ break;
80580
+ case AuthEvent.USER_CHANGED:
80581
+ window.location.reload();
80582
+ break;
80583
+ }
80584
+ });
80585
+ const useAuthSync = (queryClient2) => {
80586
+ React$2.useEffect(() => {
80587
+ const unsubscribe = registerAuthSync(queryClient2);
80588
+ return unsubscribe;
80589
+ }, [queryClient2]);
80590
+ };
80559
80591
  function bind(fn, thisArg) {
80560
80592
  return function wrap() {
80561
80593
  return fn.apply(thisArg, arguments);
@@ -82955,7 +82987,7 @@ uniform ${i3} ${s4} u_${a3};
82955
82987
  exact: true
82956
82988
  }));
82957
82989
  }
82958
- broadcastChannel == null ? void 0 : broadcastChannel.postMessage("unauthorized");
82990
+ broadcastChannel == null ? void 0 : broadcastChannel.postMessage(AuthEvent.UNAUTHORIZED);
82959
82991
  }
82960
82992
  return Promise.reject(err);
82961
82993
  });
@@ -84320,6 +84352,7 @@ uniform ${i3} ${s4} u_${a3};
84320
84352
  exports2.AppChrome = AppChrome;
84321
84353
  exports2.AppSwitch = AppSwitch;
84322
84354
  exports2.AppSwitchLibrarySchema = AppSwitchLibrarySchema;
84355
+ exports2.AuthEvent = AuthEvent;
84323
84356
  exports2.AuthModal = AuthModal;
84324
84357
  exports2.BinIcon = BinIcon;
84325
84358
  exports2.Button = Button;
@@ -84454,11 +84487,13 @@ uniform ${i3} ${s4} u_${a3};
84454
84487
  exports2.loggerLevelOrder = loggerLevelOrder;
84455
84488
  exports2.onAuthEvent = onAuthEvent;
84456
84489
  exports2.parseOrThrowWithInput = parseOrThrowWithInput;
84490
+ exports2.registerAuthSync = registerAuthSync;
84457
84491
  exports2.renderErrorToHtml = renderErrorToHtml;
84458
84492
  exports2.requestWipe = requestWipe;
84459
84493
  exports2.setupWipe = setupWipe;
84460
84494
  exports2.toStringEncoded = toStringEncoded;
84461
84495
  exports2.uriComponentCodec = uriComponentCodec;
84496
+ exports2.useAuthSync = useAuthSync;
84462
84497
  exports2.useDebounce = useDebounce;
84463
84498
  exports2.useExtendedTheme = useExtendedTheme;
84464
84499
  exports2.useFloatingPanels = useFloatingPanels;
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="webworker" />
2
- console.info("sw.js version: 0.27.4");
2
+ console.info("sw.js version: 0.27.6");
3
3
  self.addEventListener("install", () => self.skipWaiting());
4
4
  self.addEventListener("activate", (event) =>
5
5
  event.waitUntil(self.clients.claim())
@@ -1,4 +1,8 @@
1
- type AuthEvent = "unauthorized" | "authorized";
1
+ export declare enum AuthEvent {
2
+ AUTHENTICATED = "authenticated",
3
+ REAUTHENTICATED = "reauthenticated",
4
+ USER_CHANGED = "user-changed",
5
+ UNAUTHORIZED = "unauthorized"
6
+ }
2
7
  export declare function onAuthEvent(callback: (event: AuthEvent) => void): () => void;
3
8
  export declare function broadcastAuthEvent(event: AuthEvent): void;
4
- export {};
@@ -1,10 +1,10 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { QueryClient } from '@tanstack/react-query';
2
+ import { QueryClient, QueryKey } from '@tanstack/react-query';
3
3
 
4
4
  export interface SessionHandlingConfig {
5
5
  queryClient?: QueryClient;
6
6
  broadcastChannel?: BroadcastChannel;
7
- keysToInvalidate?: string[];
7
+ keysToInvalidate?: QueryKey[];
8
8
  }
9
9
  export interface AuthConfig {
10
10
  getToken: () => string | null;
@@ -0,0 +1,4 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+
3
+ export declare const registerAuthSync: (queryClient: QueryClient) => () => void;
4
+ export declare const useAuthSync: (queryClient: QueryClient) => void;
@@ -15,6 +15,7 @@ export * from './v1/components/utils/index';
15
15
  export * from './component-library/Map';
16
16
  export * from './candidate-packages/authorize-flow/AuthModal';
17
17
  export * from './candidate-packages/authorize-flow/broadcastChannelService';
18
+ export * from './candidate-packages/authorize-flow/useAuthSync';
18
19
  export * from './candidate-packages/authorize-flow';
19
20
  export { getCodec, type Codec, base64Codec, uriComponentCodec, ENCODE_SEARCH_PARAMS_MODES_Schema, type ENCODE_SEARCH_PARAMS_MODES_Type, toStringEncoded, type URLSearchParamsInit, GRAPH_APP, type LoggerLevelString, type LoggerLevel, loggerLevelOrder, Logger, } from './candidate-packages/utils-lib/src/index';
20
21
  export { setupWipe, WipeConfigSchema, type WipeConfig, } from './candidate-packages/logout-syncer/setupWipe';
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "https://github.com/telicent-oss/telicent-ds.git"
8
8
  },
9
9
  "type": "module",
10
- "version": "0.27.4",
10
+ "version": "0.27.6",
11
11
  "private": false,
12
12
  "dependencies": {
13
13
  "@emotion/react": "^11.10.6",