diff --git a/dist/react.js b/dist/react.js
index 5ba3f33..8ff3875 100644
--- a/dist/react.js
+++ b/dist/react.js
@@ -643,16 +643,18 @@ function useHasRole(roles) {
function withAuth(WrappedComponent, options) {
return function AuthenticatedComponent(props) {
const { isAuthenticated, isLoading, user } = useAuth();
+ const LoadingComp = options?.LoadingComponent;
+ const UnauthorizedComp = options?.UnauthorizedComponent;
if (isLoading) {
- return options?.LoadingComponent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(options.LoadingComponent, {}) : null;
+ return LoadingComp ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingComp, {}) : null;
}
if (!isAuthenticated) {
- return options?.UnauthorizedComponent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(options.UnauthorizedComponent, {}) : null;
+ return UnauthorizedComp ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(UnauthorizedComp, {}) : null;
}
if (options?.roles && options.roles.length > 0) {
const hasRequiredRole = options.roles.some((role) => user?.roles?.includes(role));
if (!hasRequiredRole) {
- return options?.UnauthorizedComponent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(options.UnauthorizedComponent, {}) : null;
+ return UnauthorizedComp ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(UnauthorizedComp, {}) : null;
}
}
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WrappedComponent, { ...props });
diff --git a/dist/react.js.map b/dist/react.js.map
index 5d45f57..b08866e 100644
--- a/dist/react.js.map
+++ b/dist/react.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/react/index.tsx","../src/utils.ts","../src/storage.ts","../src/client.ts"],"sourcesContent":["/**\n * React bindings for Stuffle IAM SDK\n * \n * @example\n * ```tsx\n * import { StuffleIAMProvider, useAuth } from '@stuffle/iam-sdk/react';\n * \n * function App() {\n * return (\n *
Welcome, {user?.name}
\n * \n *(\n WrappedComponent: React.ComponentType
,\n options?: {\n /** Component to show while loading */\n LoadingComponent?: React.ComponentType;\n /** Component to show if not authenticated */\n UnauthorizedComponent?: React.ComponentType;\n /** Required roles */\n roles?: string[];\n }\n) {\n return function AuthenticatedComponent(props: P) {\n const { isAuthenticated, isLoading, user } = useAuth();\n\n if (isLoading) {\n return options?.LoadingComponent ? Welcome, {user?.name} (\n WrappedComponent: React.ComponentType ,\n options?: {\n /** Component to show while loading */\n LoadingComponent?: React.ComponentType;\n /** Component to show if not authenticated */\n UnauthorizedComponent?: React.ComponentType;\n /** Required roles */\n roles?: string[];\n }\n) {\n return function AuthenticatedComponent(props: P) {\n const { isAuthenticated, isLoading, user } = useAuth();\n\n const LoadingComp = options?.LoadingComponent;\n const UnauthorizedComp = options?.UnauthorizedComponent;\n\n if (isLoading) {\n return LoadingComp ? Welcome, {user?.name} (\n WrappedComponent: React.ComponentType ,\n options?: {\n /** Component to show while loading */\n LoadingComponent?: React.ComponentType;\n /** Component to show if not authenticated */\n UnauthorizedComponent?: React.ComponentType;\n /** Required roles */\n roles?: string[];\n }\n) {\n return function AuthenticatedComponent(props: P) {\n const { isAuthenticated, isLoading, user } = useAuth();\n\n if (isLoading) {\n return options?.LoadingComponent ? Welcome, {user?.name} (\n WrappedComponent: React.ComponentType ,\n options?: {\n /** Component to show while loading */\n LoadingComponent?: React.ComponentType;\n /** Component to show if not authenticated */\n UnauthorizedComponent?: React.ComponentType;\n /** Required roles */\n roles?: string[];\n }\n) {\n return function AuthenticatedComponent(props: P) {\n const { isAuthenticated, isLoading, user } = useAuth();\n\n const LoadingComp = options?.LoadingComponent;\n const UnauthorizedComp = options?.UnauthorizedComponent;\n\n if (isLoading) {\n return LoadingComp ?