academe-kit 0.7.5 → 0.7.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.
package/dist/index.d.ts CHANGED
@@ -20691,7 +20691,7 @@ type SecurityContextType = {
20691
20691
  isInitialized: boolean;
20692
20692
  isTokenReady: boolean;
20693
20693
  isAuthenticated: () => boolean;
20694
- signOut: () => void | null;
20694
+ signOut: () => Promise<void> | void | null;
20695
20695
  goToLogin: (options?: KeycloakLoginOptions | undefined) => void;
20696
20696
  user: AcademeUser | null;
20697
20697
  refreshUserData: () => Promise<void>;
package/dist/index.esm.js CHANGED
@@ -6305,7 +6305,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6305
6305
  setIsRefreshing(false);
6306
6306
  }, [getKeycloakUser, services, skipApiUserFetch]);
6307
6307
  // --- 5. Ações de Auth ---
6308
- const signOut = useCallback(() => {
6308
+ const signOut = useCallback(async () => {
6309
6309
  console.log("[KC LOGOUT!]");
6310
6310
  setCurrentUser(null);
6311
6311
  setAccessToken(undefined);
@@ -6319,10 +6319,18 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6319
6319
  sessionStorage.clear();
6320
6320
  localStorage.removeItem(`oidc.user:${auth.settings.authority}:${auth.settings.client_id}`);
6321
6321
  auth.removeUser();
6322
- auth.signoutRedirect({
6323
- id_token_hint: auth.user?.id_token,
6324
- });
6325
6322
  auth.clearStaleState();
6323
+ // Fazer logout silencioso no Keycloak e redirecionar para login
6324
+ try {
6325
+ await auth.signoutSilent({
6326
+ id_token_hint: auth.user?.id_token,
6327
+ });
6328
+ }
6329
+ catch (error) {
6330
+ console.debug("[KC LOGOUT] Silent signout failed, redirecting to login anyway:", error);
6331
+ }
6332
+ // Redirecionar para a tela de login
6333
+ auth.signinRedirect();
6326
6334
  }, [auth]);
6327
6335
  const hasSchool = useCallback((schoolId) => {
6328
6336
  if (hasRealmRole(GLOBAL_ROLES.ADMIN_ACADEME)) {
@@ -6336,7 +6344,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6336
6344
  }, []);
6337
6345
  // Memoizar o value do context para evitar re-renders desnecessários
6338
6346
  const contextValue = useMemo(() => ({
6339
- isInitialized: !isLoading || isRefreshing,
6347
+ isInitialized: !isLoading || isRefreshing || !!accessToken,
6340
6348
  isTokenReady,
6341
6349
  user: currentUser,
6342
6350
  refreshUserData,