academe-kit 0.3.2 → 0.3.3
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.esm.js +17 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3259,10 +3259,23 @@ var GLOBAL_ROLES;
|
|
|
3259
3259
|
GLOBAL_ROLES["GUARDIAN"] = "guardian";
|
|
3260
3260
|
})(GLOBAL_ROLES || (GLOBAL_ROLES = {}));
|
|
3261
3261
|
|
|
3262
|
+
// --------------------------------------------------------
|
|
3263
|
+
// 1. SINGLETON: Variável declarada FORA do componente
|
|
3264
|
+
// Isso garante que ela sobreviva a re-renders do React
|
|
3265
|
+
// --------------------------------------------------------
|
|
3266
|
+
let globalKeycloak;
|
|
3262
3267
|
const AcademeAuthProvider = ({ realm, hubUrl, children, clientId, keycloakUrl, apiBaseUrl, initOptions, skipApiUserFetch, }) => {
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3268
|
+
// 2. Inicialização: Só cria se ainda não existir (Singleton)
|
|
3269
|
+
if (!globalKeycloak) {
|
|
3270
|
+
console.log("🦁 [AcademeAuthProvider] Criando Instância Única do Keycloak");
|
|
3271
|
+
globalKeycloak = new Keycloak({ clientId, realm, url: keycloakUrl });
|
|
3272
|
+
}
|
|
3273
|
+
// Mantemos o initOptions memorizado, mas forçamos o logging para debug
|
|
3274
|
+
const keycloakInitOptions = useMemo(() => ({
|
|
3275
|
+
...initOptions,
|
|
3276
|
+
enableLogging: true, // <-- Importante para vermos o fluxo no console
|
|
3277
|
+
}), [initOptions]);
|
|
3278
|
+
return (jsx(ReactKeycloakProvider, { authClient: globalKeycloak, initOptions: keycloakInitOptions, children: jsx(SecurityProvider, { hubUrl: hubUrl, apiBaseUrl: apiBaseUrl, skipApiUserFetch: skipApiUserFetch, children: children }) }));
|
|
3266
3279
|
};
|
|
3267
3280
|
const SecurityContext = createContext({
|
|
3268
3281
|
isInitialized: false,
|
|
@@ -3302,6 +3315,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
|
|
|
3302
3315
|
setIsInitialized(initialized);
|
|
3303
3316
|
}, [initialized]);
|
|
3304
3317
|
useEffect(() => {
|
|
3318
|
+
// @ts-ignore
|
|
3305
3319
|
window.accessToken = keycloak.token;
|
|
3306
3320
|
}, [keycloak.token]);
|
|
3307
3321
|
const getKeycloakUser = useCallback(() => {
|