nextauthz 1.1.7 → 1.1.9
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 +9 -19
- package/dist/index.d.ts +9 -19
- package/dist/index.js +15 -1800
- package/dist/index.mjs +32 -1825
- package/package.json +13 -9
- package/src/RoleGuard.tsx +3 -6
- package/src/index.ts +9 -7
- package/src/myAuth.ts +0 -4
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextauthz",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
10
|
-
"dev": "tsup src/index.ts --watch"
|
|
9
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --external react --external react-dom --external zustand --external next",
|
|
10
|
+
"dev": "tsup src/index.ts --watch --external react --external react-dom --external zustand --external next"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
13
|
"author": "",
|
|
@@ -15,12 +15,16 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/react": "^19.2.14",
|
|
17
17
|
"@types/react-dom": "^19.2.3",
|
|
18
|
-
"typescript": "^5.9.3"
|
|
18
|
+
"typescript": "^5.9.3",
|
|
19
|
+
"tsup": "^8.5.1"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
23
|
+
"react-dom": "^18.2.0 || ^19.0.0",
|
|
24
|
+
"next": "^16.0.0",
|
|
25
|
+
"zustand": "^5.0.0"
|
|
19
26
|
},
|
|
20
27
|
"dependencies": {
|
|
21
|
-
"
|
|
22
|
-
"react-token-manager": "^1.0.7",
|
|
23
|
-
"tsup": "^8.5.1",
|
|
24
|
-
"zustand": "^5.0.11"
|
|
28
|
+
"react-token-manager": "^1.0.7"
|
|
25
29
|
}
|
|
26
|
-
}
|
|
30
|
+
}
|
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 {
|
|
5
|
+
import { useAuth } from '.'
|
|
6
6
|
|
|
7
7
|
type RoleGuardProps = {
|
|
8
8
|
children: React.ReactNode
|
|
@@ -10,15 +10,12 @@ type RoleGuardProps = {
|
|
|
10
10
|
redirectTo?: string
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const RoleGuard
|
|
13
|
+
const RoleGuard = ({
|
|
14
14
|
children,
|
|
15
15
|
allowedRoles,
|
|
16
16
|
redirectTo = '/unauthorized',
|
|
17
|
-
}) => {
|
|
18
|
-
// ✅ Destructure useAuth INSIDE the component
|
|
19
|
-
const { useAuth } = auth
|
|
17
|
+
}: RoleGuardProps) => {
|
|
20
18
|
const { user, loading } = useAuth()
|
|
21
|
-
|
|
22
19
|
const router = useRouter()
|
|
23
20
|
const [isChecking, setIsChecking] = useState(true)
|
|
24
21
|
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
'use client'
|
|
3
|
+
|
|
1
4
|
import { createAuthContext } from './AuthProvider'
|
|
5
|
+
export { default as AuthGuard } from './AuthGuard'
|
|
6
|
+
export { default as RoleGuard } from './RoleGuard'
|
|
2
7
|
|
|
3
|
-
export type User =
|
|
4
|
-
[key: string]: any
|
|
5
|
-
}
|
|
8
|
+
export type User = any
|
|
6
9
|
|
|
7
|
-
//
|
|
10
|
+
// Factory function for app
|
|
8
11
|
export function createAppAuth(
|
|
9
12
|
storage: 'localStorage' | 'sessionStorage' | 'cookie' = 'cookie'
|
|
10
13
|
) {
|
|
11
14
|
return createAuthContext<User>({ storage })
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
export { default as RoleGuard } from './RoleGuard'
|
|
17
|
+
// Default instance (optional)
|
|
18
|
+
export const { AuthProvider, useAuth } = createAppAuth()
|
package/src/myAuth.ts
DELETED