nextauthz 1.0.7 → 1.0.8

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.mts CHANGED
@@ -36,7 +36,7 @@ type RoleGuardProps = {
36
36
  allowedRoles: string[];
37
37
  redirectTo?: string;
38
38
  };
39
- declare const RoleGuard: ({ children, allowedRoles, redirectTo, }: RoleGuardProps) => react_jsx_runtime.JSX.Element;
39
+ declare const RoleGuard: React__default.FC<RoleGuardProps>;
40
40
 
41
41
  type User = {
42
42
  [key: string]: any;
package/dist/index.d.ts CHANGED
@@ -36,7 +36,7 @@ type RoleGuardProps = {
36
36
  allowedRoles: string[];
37
37
  redirectTo?: string;
38
38
  };
39
- declare const RoleGuard: ({ children, allowedRoles, redirectTo, }: RoleGuardProps) => react_jsx_runtime.JSX.Element;
39
+ declare const RoleGuard: React__default.FC<RoleGuardProps>;
40
40
 
41
41
  type User = {
42
42
  [key: string]: any;
package/dist/index.js CHANGED
@@ -1850,12 +1850,12 @@ function createAuthContext(options) {
1850
1850
  }
1851
1851
  );
1852
1852
  };
1853
- const useAuth2 = () => {
1853
+ const useAuth = () => {
1854
1854
  const ctx = (0, import_react.useContext)(AuthContext);
1855
1855
  if (!ctx) throw new Error("useAuth must be used inside AuthProvider");
1856
1856
  return ctx;
1857
1857
  };
1858
- return { AuthProvider, useAuth: useAuth2 };
1858
+ return { AuthProvider, useAuth };
1859
1859
  }
1860
1860
 
1861
1861
  // src/AuthGuard.tsx
@@ -1921,12 +1921,12 @@ var auth = createAppAuth();
1921
1921
 
1922
1922
  // src/RoleGuard.tsx
1923
1923
  var import_jsx_runtime3 = __toESM(require_jsx_runtime());
1924
- var { useAuth } = auth;
1925
1924
  var RoleGuard = ({
1926
1925
  children,
1927
1926
  allowedRoles,
1928
1927
  redirectTo = "/unauthorized"
1929
1928
  }) => {
1929
+ const { useAuth } = auth;
1930
1930
  const { user, loading } = useAuth();
1931
1931
  const router = (0, import_navigation2.useRouter)();
1932
1932
  const [isChecking, setIsChecking] = (0, import_react3.useState)(true);
package/dist/index.mjs CHANGED
@@ -1834,12 +1834,12 @@ function createAuthContext(options) {
1834
1834
  }
1835
1835
  );
1836
1836
  };
1837
- const useAuth2 = () => {
1837
+ const useAuth = () => {
1838
1838
  const ctx = (0, import_react.useContext)(AuthContext);
1839
1839
  if (!ctx) throw new Error("useAuth must be used inside AuthProvider");
1840
1840
  return ctx;
1841
1841
  };
1842
- return { AuthProvider, useAuth: useAuth2 };
1842
+ return { AuthProvider, useAuth };
1843
1843
  }
1844
1844
 
1845
1845
  // src/AuthGuard.tsx
@@ -1905,12 +1905,12 @@ var auth = createAppAuth();
1905
1905
 
1906
1906
  // src/RoleGuard.tsx
1907
1907
  var import_jsx_runtime3 = __toESM(require_jsx_runtime());
1908
- var { useAuth } = auth;
1909
1908
  var RoleGuard = ({
1910
1909
  children,
1911
1910
  allowedRoles,
1912
1911
  redirectTo = "/unauthorized"
1913
1912
  }) => {
1913
+ const { useAuth } = auth;
1914
1914
  const { user, loading } = useAuth();
1915
1915
  const router = useRouter2();
1916
1916
  const [isChecking, setIsChecking] = (0, import_react3.useState)(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextauthz",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/RoleGuard.tsx CHANGED
@@ -10,14 +10,15 @@ type RoleGuardProps = {
10
10
  redirectTo?: string
11
11
  }
12
12
 
13
- const { useAuth } = auth
14
-
15
- const RoleGuard = ({
13
+ const RoleGuard: React.FC<RoleGuardProps> = ({
16
14
  children,
17
15
  allowedRoles,
18
16
  redirectTo = '/unauthorized',
19
- }: RoleGuardProps) => {
17
+ }) => {
18
+ // ✅ Destructure useAuth INSIDE the component
19
+ const { useAuth } = auth
20
20
  const { user, loading } = useAuth()
21
+
21
22
  const router = useRouter()
22
23
  const [isChecking, setIsChecking] = useState(true)
23
24
 
package/src/myAuth.ts CHANGED
@@ -1,9 +1,4 @@
1
1
  // myAuth.ts
2
2
  'use client'
3
-
4
3
  import { createAppAuth } from '.'
5
-
6
- export type User = any
7
-
8
- // Export the factory
9
4
  export const auth = createAppAuth() // { AuthProvider, useAuth }