@orsetra/shared-ui 1.10.17 → 1.10.18

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,5 +1,11 @@
1
1
  import { Interceptors } from "./http-client";
2
2
 
3
+ // The Zitadel authority itself — a 401 straight from the identity provider (as opposed to our
4
+ // own API backend) means the session is truly invalid there; no retry or token refresh will
5
+ // help, only a full re-authentication. Each app already bakes this in via NEXT_PUBLIC_ZITADEL_AUTHORITY
6
+ // (this file ships as source into every app's own Next.js build, so the env var is inlined
7
+ // per-app exactly as it is in the services that call this authority directly).
8
+ const ZITADEL_AUTHORITY = process.env.NEXT_PUBLIC_ZITADEL_AUTHORITY;
3
9
 
4
10
  export const interceptors: Interceptors = {
5
11
  onResponse: (response: any) => {
@@ -7,6 +13,10 @@ export const interceptors: Interceptors = {
7
13
  },
8
14
  onResponseError: (error: any) => {
9
15
  if (error.response?.status === 401 && typeof window !== 'undefined') {
16
+ const requestBaseUrl: string | undefined = error.config?.baseURL;
17
+ if (ZITADEL_AUTHORITY && requestBaseUrl === ZITADEL_AUTHORITY) {
18
+ window.dispatchEvent(new CustomEvent('auth-unauthorized'));
19
+ }
10
20
  window.dispatchEvent(new CustomEvent('http-unauthorized'));
11
21
  }
12
22
  return Promise.reject(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.10.17",
3
+ "version": "1.10.18",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",