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