@next-nest-auth/nextauth 0.1.2 → 0.1.4
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/README.md +1 -0
- package/package.json +7 -7
- package/src/auth.ts +10 -7
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ NODE_ENV=development
|
|
|
19
19
|
- `BASE_URL`: The URL of your Next.js frontend.
|
|
20
20
|
- `API_BASE_URL`: The URL of your NestJS backend.
|
|
21
21
|
- `NODE_ENV`: The environment mode (`development`, `production`).
|
|
22
|
+
- `AUTOEXPIRE_REFRESH_TOKEN`: (Optional) A boolean value to determine whether to automatically expire the refresh token or not. Default is `false`.
|
|
22
23
|
|
|
23
24
|
## Middleware Usage
|
|
24
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-nest-auth/nextauth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"type": "commonjs",
|
|
34
34
|
"description": "NextAuth is a frontend authentication package designed for Next.js applications, providing easy integration with NestJS-based backends. It supports login, session management, and token handling (including JWT and refresh tokens) to ensure secure user authentication. With customizable authentication flows and compatibility with multiple providers, NextAuth enables seamless integration between NestJS and Next.js apps.",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"axios": "^1.
|
|
36
|
+
"axios": "^1.13.2",
|
|
37
37
|
"js-cookie": "^3.0.5",
|
|
38
|
-
"jsonwebtoken": "^9.0.
|
|
38
|
+
"jsonwebtoken": "^9.0.3",
|
|
39
39
|
"jwt-decode": "^4.0.0",
|
|
40
|
-
"next": "^
|
|
40
|
+
"next": "^16.0.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/js-cookie": "^3.0.6",
|
|
44
|
-
"@types/node": "^
|
|
45
|
-
"@types/react": "^19.
|
|
46
|
-
"typescript": "^5.
|
|
44
|
+
"@types/node": "^24.10.1",
|
|
45
|
+
"@types/react": "^19.2.7",
|
|
46
|
+
"typescript": "^5.9.3"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"dist/",
|
package/src/auth.ts
CHANGED
|
@@ -70,13 +70,16 @@ export async function refreshToken(req: NextRequest) {
|
|
|
70
70
|
maxAge: convertToSeconds(response.accessTokenExpiresIn ?? ""),
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
if (!process.env.AUTOEXPIRE_REFRESH_TOKEN) {
|
|
74
|
+
res.cookies.set("refresh_token", response.refreshToken, {
|
|
75
|
+
httpOnly: true,
|
|
76
|
+
secure: process.env.NODE_ENV === "production",
|
|
77
|
+
sameSite: "strict",
|
|
78
|
+
path: "/",
|
|
79
|
+
maxAge: convertToSeconds(response.refreshTokenExpiresIn ?? ""),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
80
83
|
return res;
|
|
81
84
|
} catch (error) {
|
|
82
85
|
throw new Error(error);
|