nextauthz 1.0.3 → 1.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextauthz",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -32,15 +32,15 @@ export function createAuthContext<UserType>(options?: AuthContextOptions) {
32
32
  const AuthProvider = ({ children }: { children: ReactNode }) => {
33
33
  const storageType = options?.storage || 'cookie'
34
34
 
35
- // ✅ Configure token manager inside the component lifecycle
35
+ // ✅ Configure token manager on mount
36
36
  useEffect(() => {
37
37
  configureTokenManager({ storage: storageType })
38
38
  }, [storageType])
39
39
 
40
- const manager = useTokenManager()
40
+ const manager = useTokenManager() // ✅ inside component
41
+
41
42
  const [loading, setLoading] = useState(true)
42
43
 
43
- // Zustand state
44
44
  const rawUser = useAuthStore((state) => state.user)
45
45
  const error = useAuthStore((state) => state.error)
46
46
 
@@ -49,7 +49,6 @@ export function createAuthContext<UserType>(options?: AuthContextOptions) {
49
49
  // Restore user on mount
50
50
  useEffect(() => {
51
51
  const savedUser = manager.getSingleToken('user')
52
-
53
52
  if (savedUser) {
54
53
  try {
55
54
  const parsedUser = JSON.parse(savedUser)
@@ -62,7 +61,6 @@ export function createAuthContext<UserType>(options?: AuthContextOptions) {
62
61
  )
63
62
  }
64
63
  }
65
-
66
64
  setLoading(false)
67
65
  }, [manager])
68
66
 
@@ -72,10 +70,7 @@ export function createAuthContext<UserType>(options?: AuthContextOptions) {
72
70
  manager.setTokens({ user: JSON.stringify(userData) })
73
71
  }
74
72
 
75
- const login = (
76
- tokens: Record<string, string>,
77
- userData: UserType
78
- ) => {
73
+ const login = (tokens: Record<string, string>, userData: UserType) => {
79
74
  try {
80
75
  manager.setTokens(tokens)
81
76
  setUser(userData)