academe-kit 0.8.5 → 0.8.6

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.cjs CHANGED
@@ -6028,30 +6028,27 @@ const getAccessTokenFromCookies = () => {
6028
6028
  const setCookie = (name, value, domain) => {
6029
6029
  if (typeof window === "undefined")
6030
6030
  return;
6031
- const cookieParts = [
6032
- `${name}=${value}`,
6033
- "path=/",
6034
- "secure",
6035
- "SameSite=None",
6036
- ];
6031
+ const cookieParts = [`${name}=${value}`, "path=/", "secure", "SameSite=None"];
6037
6032
  {
6038
6033
  cookieParts.push(`domain=${domain}`);
6039
6034
  }
6040
6035
  document.cookie = cookieParts.join("; ");
6041
6036
  };
6042
- const AcademeAuthProvider = ({ realm, hubUrl, children, clientId, keycloakUrl, apiBaseUrl, skipApiUserFetch, }) => {
6037
+ const AcademeAuthProvider = ({ realm, hubUrl, children, clientId, keycloakUrl, apiBaseUrl, redirectUri, skipApiUserFetch, }) => {
6043
6038
  const oidcConfig = {
6044
6039
  authority: `${keycloakUrl}/realms/${realm}`,
6045
6040
  client_id: clientId,
6046
- redirect_uri: typeof window !== "undefined"
6047
- ? window.location.origin
6048
- : process.env.NEXT_PUBLIC_REDIRECT_URI,
6041
+ redirect_uri: redirectUri ||
6042
+ (typeof window !== "undefined"
6043
+ ? window.location.origin
6044
+ : process.env.NEXT_PUBLIC_REDIRECT_URI),
6049
6045
  scope: "openid profile email",
6050
6046
  onSigninCallback: () => {
6051
6047
  window.history.replaceState({}, document.title, window.location.pathname);
6052
6048
  },
6053
6049
  automaticSilentRenew: true,
6054
6050
  };
6051
+ console.log("oidc ->", oidcConfig);
6055
6052
  return (jsxRuntime.jsx(AuthProvider, { ...oidcConfig, children: jsxRuntime.jsx(SecurityProvider, { hubUrl: hubUrl, apiBaseUrl: apiBaseUrl, skipApiUserFetch: skipApiUserFetch, children: children }) }));
6056
6053
  };
6057
6054
  const SecurityContext = React2.createContext({
@@ -6130,9 +6127,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6130
6127
  return;
6131
6128
  const handlePostMessage = (event) => {
6132
6129
  try {
6133
- const data = typeof event.data === "string"
6134
- ? JSON.parse(event.data)
6135
- : event.data;
6130
+ const data = typeof event.data === "string" ? JSON.parse(event.data) : event.data;
6136
6131
  if (data?.type === "KC_TOKEN_UPDATE" && data?.payload?.accessToken) {
6137
6132
  const newToken = data.payload.accessToken;
6138
6133
  console.log("[SecurityProvider] Received KC_TOKEN_UPDATE via postMessage");
@@ -6140,8 +6135,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6140
6135
  setAccessToken(newToken);
6141
6136
  }
6142
6137
  }
6143
- catch {
6144
- }
6138
+ catch { }
6145
6139
  };
6146
6140
  window.addEventListener("message", handlePostMessage);
6147
6141
  return () => {
@@ -6217,6 +6211,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6217
6211
  name: profile?.given_name || decodedAccessToken?.given_name || "",
6218
6212
  lastName: profile?.family_name || decodedAccessToken?.family_name || "",
6219
6213
  avatar_url: decodedAccessToken?.avatar_url,
6214
+ tm_token: decodedAccessToken?.tm_token,
6220
6215
  };
6221
6216
  }, [userProfile, decodedAccessToken]);
6222
6217
  const hasRealmRole = React2.useCallback((role) => {
@@ -9352,11 +9347,11 @@ const ProtectedApp = ({ children, requiredClientRoles, requiredRealmRoles, }) =>
9352
9347
  }
9353
9348
  if (requiredClientRoles &&
9354
9349
  !requiredClientRoles.roles.some((role) => hasClientRole(role, requiredClientRoles.clientId))) {
9355
- return (jsxRuntime.jsxs("div", { className: "flex flex-col w-screen h-screen items-center justify-center bg-background", children: [jsxRuntime.jsx(CircleAlert, { className: "size-10 text-primary " }), jsxRuntime.jsx("h1", { className: "text-2xl font-bold mt-4 text-center", children: "Oops, voc\u00EA n\u00E3o tem permiss\u00E3o para acessar aqui." }), jsxRuntime.jsx("span", { className: "text-center", children: "Se voc\u00EA acredita que isso \u00E9 um erro, entre em contato com o suporte." }), jsxRuntime.jsxs("div", { className: "flex gap-3 mt-4", children: [jsxRuntime.jsx(Button, { variant: "primary", size: "md", children: "Falar com o suporte" }), jsxRuntime.jsx(Button, { variant: "outline", size: "md", onClick: signOut, children: "Fazer logout" })] })] }));
9350
+ return (jsxRuntime.jsxs("div", { className: "flex flex-col w-screen h-screen items-center justify-center bg-background", children: [jsxRuntime.jsx(CircleAlert, { className: "size-10 text-primary " }), jsxRuntime.jsx("h1", { className: "text-2xl font-bold mt-4 text-center", children: "Oops, voc\u00EA n\u00E3o tem permiss\u00E3o para acessar aqui." }), jsxRuntime.jsx("span", { className: "text-center", children: "Se voc\u00EA acredita que isso \u00E9 um erro, entre em contato com o suporte." }), jsxRuntime.jsxs("div", { className: "flex gap-3 mt-4", children: [jsxRuntime.jsx(Button, { variant: "primary", size: "md", children: "Falar com o suporte" }), jsxRuntime.jsx(Button, { variant: "outline", size: "md", onClick: signOut, children: "Sair da conta" })] })] }));
9356
9351
  }
9357
9352
  if (requiredRealmRoles &&
9358
9353
  !requiredRealmRoles?.some((role) => hasRealmRole(role))) {
9359
- return (jsxRuntime.jsxs("div", { className: "flex flex-col w-screen h-screen items-center justify-center bg-background", children: [jsxRuntime.jsx(CircleAlert, { className: "size-10 text-primary " }), jsxRuntime.jsx("h1", { className: "text-2xl font-bold mt-4 text-center", children: "Oops, voc\u00EA n\u00E3o tem permiss\u00E3o para acessar aqui." }), jsxRuntime.jsx("span", { className: "text-center", children: "Se voc\u00EA acredita que isso \u00E9 um erro, entre em contato com o suporte." }), jsxRuntime.jsxs("div", { className: "flex gap-3 mt-4", children: [jsxRuntime.jsx(Button, { variant: "primary", size: "md", children: "Falar com o suporte" }), jsxRuntime.jsx(Button, { variant: "outline", size: "md", onClick: signOut, children: "Fazer logout" })] })] }));
9354
+ return (jsxRuntime.jsxs("div", { className: "flex flex-col w-screen h-screen items-center justify-center bg-background", children: [jsxRuntime.jsx(CircleAlert, { className: "size-10 text-primary " }), jsxRuntime.jsx("h1", { className: "text-2xl font-bold mt-4 text-center", children: "Oops, voc\u00EA n\u00E3o tem permiss\u00E3o para acessar aqui." }), jsxRuntime.jsx("span", { className: "text-center", children: "Se voc\u00EA acredita que isso \u00E9 um erro, entre em contato com o suporte." }), jsxRuntime.jsxs("div", { className: "flex gap-3 mt-4", children: [jsxRuntime.jsx(Button, { variant: "primary", size: "md", children: "Falar com o suporte" }), jsxRuntime.jsx(Button, { variant: "outline", size: "md", onClick: signOut, children: "Sair da conta" })] })] }));
9360
9355
  }
9361
9356
  return children;
9362
9357
  };