@glinr/theauth-nextjs-auth 0.1.0 → 0.2.0
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 +9 -5
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
# @glinr/theauth-nextjs-auth
|
|
2
2
|
|
|
3
|
+
[npm](https://www.npmjs.com/package/@glinr/theauth-nextjs-auth) · [Source](https://github.com/glincker/theauth/tree/main/packages/adapters/nextjs-auth) · [All packages](https://github.com/glincker/theauth#packages)
|
|
4
|
+
|
|
3
5
|
Next.js 14/15/16 adapter for projects with an **external auth backend**. Handles cookies, proactive token refresh, CSRF double-submit, `getServerSession`, and middleware — all typed end-to-end.
|
|
4
6
|
|
|
7
|
+
Part of [theAuth](https://theauth.dev), open-source auth for AI agents and humans. Docs: [docs.theauth.dev](https://docs.theauth.dev).
|
|
8
|
+
|
|
5
9
|
## When to use this vs `@glinr/theauth-nextjs`
|
|
6
10
|
|
|
7
11
|
| | `@glinr/theauth-nextjs-auth` | `@glinr/theauth-nextjs` |
|
|
8
12
|
|---|---|---|
|
|
9
|
-
| **Use case** | You have an external auth backend (Spring, Rails, Hono, Express, etc.) and need session management on the Next.js FE | You're using the
|
|
10
|
-
| **Auth source** | External REST API (`/api/auth/*`) | In-process
|
|
13
|
+
| **Use case** | You have an external auth backend (Spring, Rails, Hono, Express, etc.) and need session management on the Next.js FE | You're using the theAuth agent-management runtime with its built-in auth |
|
|
14
|
+
| **Auth source** | External REST API (`/api/auth/*`) | In-process theAuth SDK |
|
|
11
15
|
| **Zero deps on** | `@glinr/theauth` core, `@glinr/theauth-nextjs` | — |
|
|
12
|
-
| **Key exports** | `getServerSession`, `withAuth`, `refreshSession`, `fetchWithRefresh` | `
|
|
16
|
+
| **Key exports** | `getServerSession`, `withAuth`, `refreshSession`, `fetchWithRefresh` | `theAuthNextjs()` handler |
|
|
13
17
|
|
|
14
18
|
vs **next-auth**: next-auth requires a database adapter and runs auth in-process. Use `@glinr/theauth-nextjs-auth` when your backend already handles session state and you just want the FE plumbing.
|
|
15
19
|
|
|
@@ -18,7 +22,7 @@ vs **better-auth**: better-auth also runs in-process (or via a hosted service).
|
|
|
18
22
|
## Quickstart
|
|
19
23
|
|
|
20
24
|
```bash
|
|
21
|
-
pnpm add @glinr
|
|
25
|
+
pnpm add @glinr/theauth-nextjs-auth
|
|
22
26
|
```
|
|
23
27
|
|
|
24
28
|
### 1. Create your config
|
|
@@ -218,7 +222,7 @@ Uses the double-submit cookie pattern:
|
|
|
218
222
|
3. The backend compares header value vs. cookie value; they must match.
|
|
219
223
|
4. An attacker on a different origin cannot read the cookie → cannot forge the header.
|
|
220
224
|
|
|
221
|
-
`buildAuthHeaders` includes both `X-CSRF-Token` and a `Cookie` echo of the plain (non-`__Host-`) CSRF cookie name, matching
|
|
225
|
+
`buildAuthHeaders` includes both `X-CSRF-Token` and a `Cookie` echo of the plain (non-`__Host-`) CSRF cookie name, matching theAuth Spring backends that use a `CsrfDoubleSubmitFilter`.
|
|
222
226
|
|
|
223
227
|
## Cookie prefix policy
|
|
224
228
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glinr/theauth-nextjs-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Next.js adapter for TheAuth-style external auth backends — cookies, refresh, CSRF, getServerSession, middleware.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"middleware"
|
|
29
29
|
],
|
|
30
30
|
"license": "MIT",
|
|
31
|
-
"author": "TheAuth <support@
|
|
31
|
+
"author": "TheAuth <support@glinr.com>",
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
34
|
-
"url": "https://github.com/glincker/theauth.git",
|
|
34
|
+
"url": "git+https://github.com/glincker/theauth.git",
|
|
35
35
|
"directory": "packages/adapters/nextjs-auth"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -46,6 +46,13 @@
|
|
|
46
46
|
"tsup": "^8.0.0",
|
|
47
47
|
"vitest": "^3.0.0"
|
|
48
48
|
},
|
|
49
|
+
"homepage": "https://github.com/glincker/theauth/tree/main/packages/adapters/nextjs-auth#readme",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/glincker/theauth/issues"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
49
56
|
"scripts": {
|
|
50
57
|
"build": "tsup",
|
|
51
58
|
"typecheck": "tsc --noEmit",
|