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.js
CHANGED
|
@@ -3279,10 +3279,23 @@ exports.GLOBAL_ROLES = void 0;
|
|
|
3279
3279
|
GLOBAL_ROLES["GUARDIAN"] = "guardian";
|
|
3280
3280
|
})(exports.GLOBAL_ROLES || (exports.GLOBAL_ROLES = {}));
|
|
3281
3281
|
|
|
3282
|
+
// --------------------------------------------------------
|
|
3283
|
+
// 1. SINGLETON: Variável declarada FORA do componente
|
|
3284
|
+
// Isso garante que ela sobreviva a re-renders do React
|
|
3285
|
+
// --------------------------------------------------------
|
|
3286
|
+
let globalKeycloak;
|
|
3282
3287
|
const AcademeAuthProvider = ({ realm, hubUrl, children, clientId, keycloakUrl, apiBaseUrl, initOptions, skipApiUserFetch, }) => {
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3288
|
+
// 2. Inicialização: Só cria se ainda não existir (Singleton)
|
|
3289
|
+
if (!globalKeycloak) {
|
|
3290
|
+
console.log("🦁 [AcademeAuthProvider] Criando Instância Única do Keycloak");
|
|
3291
|
+
globalKeycloak = new Keycloak({ clientId, realm, url: keycloakUrl });
|
|
3292
|
+
}
|
|
3293
|
+
// Mantemos o initOptions memorizado, mas forçamos o logging para debug
|
|
3294
|
+
const keycloakInitOptions = React.useMemo(() => ({
|
|
3295
|
+
...initOptions,
|
|
3296
|
+
enableLogging: true, // <-- Importante para vermos o fluxo no console
|
|
3297
|
+
}), [initOptions]);
|
|
3298
|
+
return (jsxRuntime.jsx(ReactKeycloakProvider, { authClient: globalKeycloak, initOptions: keycloakInitOptions, children: jsxRuntime.jsx(SecurityProvider, { hubUrl: hubUrl, apiBaseUrl: apiBaseUrl, skipApiUserFetch: skipApiUserFetch, children: children }) }));
|
|
3286
3299
|
};
|
|
3287
3300
|
const SecurityContext = React.createContext({
|
|
3288
3301
|
isInitialized: false,
|
|
@@ -3322,6 +3335,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
|
|
|
3322
3335
|
setIsInitialized(initialized);
|
|
3323
3336
|
}, [initialized]);
|
|
3324
3337
|
React.useEffect(() => {
|
|
3338
|
+
// @ts-ignore
|
|
3325
3339
|
window.accessToken = keycloak.token;
|
|
3326
3340
|
}, [keycloak.token]);
|
|
3327
3341
|
const getKeycloakUser = React.useCallback(() => {
|