@orsetra/shared-auth 1.1.6 → 1.1.7

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.
@@ -24,6 +24,7 @@ const ZitadelContext = createContext<ZitadelContextType | undefined>(undefined)
24
24
  export interface ZitadelProviderProps {
25
25
  children: ReactNode
26
26
  config: ZitadelConfig
27
+ /** Render the action button shown inside the session-expired modal. Receives the sign-in handler. */
27
28
  renderSessionExpiredAction?: (onReauthenticate: () => void) => ReactNode
28
29
  }
29
30
 
@@ -42,6 +43,7 @@ export function ZitadelProvider({ children, config, renderSessionExpiredAction }
42
43
  try {
43
44
  ZitadelAuthService.configureAuth(config)
44
45
  ZitadelAuthService.onSessionExpired = () => setSessionExpired(true)
46
+ ZitadelAuthService.onUserSignedOut = () => ZitadelAuthService.signIn()
45
47
  setIsConfigured(true)
46
48
 
47
49
  const isAuthenticated = await ZitadelAuthService.isAuthenticated()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-auth",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Shared authentication utilities for Orsetra platform using Zitadel",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",
@@ -68,6 +68,9 @@ function createZitadelAuth(zitadelConfig: ZitadelConfig): ZitadelAuth {
68
68
  localStorage.removeItem(key);
69
69
  }
70
70
  });
71
+ // Session invalidated server-side (revocation, sign-out from another tab, IDP session ended)
72
+ // → redirect immediately, no modal
73
+ ZitadelAuthService.onUserSignedOut?.();
71
74
  });
72
75
 
73
76
  userManager.events.addAccessTokenExpired(() => {
@@ -95,7 +98,10 @@ function createZitadelAuth(zitadelConfig: ZitadelConfig): ZitadelAuth {
95
98
 
96
99
  export class ZitadelAuthService {
97
100
  private static zitadelAuth: ZitadelAuth | null = null;
101
+ /** Fired when the access token expires and silent renew fails — show a modal. */
98
102
  static onSessionExpired: (() => void) | null = null;
103
+ /** Fired when the IDP invalidates the session (server logout, revocation, other tab sign-out) — redirect immediately. */
104
+ static onUserSignedOut: (() => void) | null = null;
99
105
 
100
106
  static configureAuth(config: ZitadelConfig) {
101
107
  this.zitadelAuth = createZitadelAuth(config);