nextauthz 1.0.6 → 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
@@ -1791,7 +1791,7 @@ var useAuthStore = (0, import_zustand.create)((set) => ({
1791
1791
  var import_jsx_runtime = __toESM(require_jsx_runtime());
1792
1792
  function createAuthContext(options) {
1793
1793
  const AuthContext = (0, import_react.createContext)(null);
1794
- const AuthProvider2 = ({ children }) => {
1794
+ const AuthProvider = ({ children }) => {
1795
1795
  const storageType = options?.storage || "cookie";
1796
1796
  (0, import_react.useEffect)(() => {
1797
1797
  (0, import_react_token_manager.configureTokenManager)({ storage: storageType });
@@ -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: AuthProvider2, useAuth: useAuth2 };
1858
+ return { AuthProvider, useAuth };
1859
1859
  }
1860
1860
 
1861
1861
  // src/AuthGuard.tsx
@@ -1917,7 +1917,7 @@ var import_react3 = __toESM(require_react());
1917
1917
  var import_navigation2 = require("next/navigation");
1918
1918
 
1919
1919
  // src/myAuth.ts
1920
- var { AuthProvider, useAuth } = createAppAuth();
1920
+ var auth = createAppAuth();
1921
1921
 
1922
1922
  // src/RoleGuard.tsx
1923
1923
  var import_jsx_runtime3 = __toESM(require_jsx_runtime());
@@ -1926,6 +1926,7 @@ var RoleGuard = ({
1926
1926
  allowedRoles,
1927
1927
  redirectTo = "/unauthorized"
1928
1928
  }) => {
1929
+ const { useAuth } = auth;
1929
1930
  const { user, loading } = useAuth();
1930
1931
  const router = (0, import_navigation2.useRouter)();
1931
1932
  const [isChecking, setIsChecking] = (0, import_react3.useState)(true);
package/dist/index.mjs CHANGED
@@ -1775,7 +1775,7 @@ var useAuthStore = create((set) => ({
1775
1775
  var import_jsx_runtime = __toESM(require_jsx_runtime());
1776
1776
  function createAuthContext(options) {
1777
1777
  const AuthContext = (0, import_react.createContext)(null);
1778
- const AuthProvider2 = ({ children }) => {
1778
+ const AuthProvider = ({ children }) => {
1779
1779
  const storageType = options?.storage || "cookie";
1780
1780
  (0, import_react.useEffect)(() => {
1781
1781
  configureTokenManager({ storage: storageType });
@@ -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: AuthProvider2, useAuth: useAuth2 };
1842
+ return { AuthProvider, useAuth };
1843
1843
  }
1844
1844
 
1845
1845
  // src/AuthGuard.tsx
@@ -1901,7 +1901,7 @@ var import_react3 = __toESM(require_react());
1901
1901
  import { useRouter as useRouter2 } from "next/navigation";
1902
1902
 
1903
1903
  // src/myAuth.ts
1904
- var { AuthProvider, useAuth } = createAppAuth();
1904
+ var auth = createAppAuth();
1905
1905
 
1906
1906
  // src/RoleGuard.tsx
1907
1907
  var import_jsx_runtime3 = __toESM(require_jsx_runtime());
@@ -1910,6 +1910,7 @@ var RoleGuard = ({
1910
1910
  allowedRoles,
1911
1911
  redirectTo = "/unauthorized"
1912
1912
  }) => {
1913
+ const { useAuth } = auth;
1913
1914
  const { user, loading } = useAuth();
1914
1915
  const router = useRouter2();
1915
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.6",
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React, { useEffect, useState } from 'react'
4
4
  import { useRouter } from 'next/navigation'
5
- import { useAuth } from './myAuth'
5
+ import { auth } from './myAuth'
6
6
 
7
7
  type RoleGuardProps = {
8
8
  children: React.ReactNode
@@ -10,12 +10,15 @@ type RoleGuardProps = {
10
10
  redirectTo?: string
11
11
  }
12
12
 
13
- const RoleGuard = ({
13
+ const RoleGuard: React.FC<RoleGuardProps> = ({
14
14
  children,
15
15
  allowedRoles,
16
16
  redirectTo = '/unauthorized',
17
- }: RoleGuardProps) => {
17
+ }) => {
18
+ // ✅ Destructure useAuth INSIDE the component
19
+ const { useAuth } = auth
18
20
  const { user, loading } = useAuth()
21
+
19
22
  const router = useRouter()
20
23
  const [isChecking, setIsChecking] = useState(true)
21
24
 
package/src/myAuth.ts CHANGED
@@ -1,7 +1,4 @@
1
- import { createAppAuth } from "."
2
-
3
-
4
- export type User = any
5
-
6
- // Create typed AuthProvider and useAuth hook
7
- export const { AuthProvider, useAuth } = createAppAuth()
1
+ // myAuth.ts
2
+ 'use client'
3
+ import { createAppAuth } from '.'
4
+ export const auth = createAppAuth() // { AuthProvider, useAuth }