create-nuxt-base 1.1.2 → 1.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/.github/workflows/publish.yml +1 -1
- package/AUTH.md +16 -14
- package/CHANGELOG.md +13 -11
- package/README.md +5 -5
- package/nuxt-base-template/README.md +11 -11
- package/nuxt-base-template/app/composables/use-better-auth.ts +242 -60
- package/nuxt-base-template/app/lib/auth-client.ts +8 -11
- package/nuxt-base-template/app/lib/auth-state.ts +206 -0
- package/nuxt-base-template/app/middleware/admin.global.ts +27 -7
- package/nuxt-base-template/app/middleware/auth.global.ts +23 -6
- package/nuxt-base-template/app/middleware/guest.global.ts +22 -7
- package/nuxt-base-template/app/pages/app/index.vue +3 -17
- package/nuxt-base-template/app/pages/auth/2fa.vue +38 -6
- package/nuxt-base-template/app/pages/auth/login.vue +13 -20
- package/nuxt-base-template/app/pages/auth/register.vue +5 -8
- package/nuxt-base-template/app/plugins/auth-interceptor.client.ts +23 -15
- package/nuxt-base-template/server/api/iam/[...path].ts +12 -4
- package/package.json +2 -2
package/AUTH.md
CHANGED
|
@@ -7,12 +7,12 @@ This document describes the Better Auth integration in the nuxt-base-starter tem
|
|
|
7
7
|
The template uses [Better Auth](https://www.better-auth.com/) for authentication with the following features:
|
|
8
8
|
|
|
9
9
|
| Feature | Status | Description |
|
|
10
|
-
|
|
11
|
-
| Email & Password | ✅
|
|
12
|
-
| Two-Factor Auth (2FA) | ✅
|
|
13
|
-
| Passkey (WebAuthn) | ✅
|
|
14
|
-
| Session Management | ✅
|
|
15
|
-
| Password Hashing | ✅
|
|
10
|
+
| --------------------- | ------ | -------------------------------------- |
|
|
11
|
+
| Email & Password | ✅ | Standard email/password authentication |
|
|
12
|
+
| Two-Factor Auth (2FA) | ✅ | TOTP-based 2FA with backup codes |
|
|
13
|
+
| Passkey (WebAuthn) | ✅ | Passwordless authentication |
|
|
14
|
+
| Session Management | ✅ | Cookie-based sessions with SSR support |
|
|
15
|
+
| Password Hashing | ✅ | Client-side SHA256 hashing |
|
|
16
16
|
|
|
17
17
|
## Architecture
|
|
18
18
|
|
|
@@ -44,7 +44,7 @@ The template uses [Better Auth](https://www.better-auth.com/) for authentication
|
|
|
44
44
|
## Files
|
|
45
45
|
|
|
46
46
|
| File | Purpose |
|
|
47
|
-
|
|
47
|
+
| ------------------------------------ | -------------------------------- |
|
|
48
48
|
| `app/lib/auth-client.ts` | Better Auth client configuration |
|
|
49
49
|
| `app/composables/use-better-auth.ts` | Auth state management composable |
|
|
50
50
|
| `app/pages/auth/login.vue` | Login page |
|
|
@@ -153,8 +153,8 @@ import { createBetterAuthClient } from '~/lib/auth-client';
|
|
|
153
153
|
// Create a custom client
|
|
154
154
|
const customClient = createBetterAuthClient({
|
|
155
155
|
baseURL: 'https://api.example.com',
|
|
156
|
-
basePath: '/auth',
|
|
157
|
-
twoFactorRedirectPath: '/login/2fa',
|
|
156
|
+
basePath: '/auth', // Default: '/iam'
|
|
157
|
+
twoFactorRedirectPath: '/login/2fa', // Default: '/auth/2fa'
|
|
158
158
|
enableAdmin: false,
|
|
159
159
|
enableTwoFactor: true,
|
|
160
160
|
enablePasskey: true,
|
|
@@ -174,6 +174,7 @@ const hashedPassword = await sha256(plainPassword);
|
|
|
174
174
|
```
|
|
175
175
|
|
|
176
176
|
**Why client-side hashing?**
|
|
177
|
+
|
|
177
178
|
1. Prevents plain text passwords in network logs
|
|
178
179
|
2. Works with nest-server's `normalizePasswordForIam()` which detects SHA256 hashes
|
|
179
180
|
3. Server re-hashes with bcrypt for storage
|
|
@@ -183,7 +184,7 @@ const hashedPassword = await sha256(plainPassword);
|
|
|
183
184
|
Sessions are stored in cookies for SSR compatibility:
|
|
184
185
|
|
|
185
186
|
| Cookie | Purpose |
|
|
186
|
-
|
|
187
|
+
| --------------------------- | -------------------------- |
|
|
187
188
|
| `auth-state` | User data (SSR-compatible) |
|
|
188
189
|
| `token` | Session token |
|
|
189
190
|
| `better-auth.session_token` | Better Auth native cookie |
|
|
@@ -200,6 +201,7 @@ fetchOptions: {
|
|
|
200
201
|
```
|
|
201
202
|
|
|
202
203
|
**Backend CORS Configuration:**
|
|
204
|
+
|
|
203
205
|
```typescript
|
|
204
206
|
// In nest-server config
|
|
205
207
|
cors: {
|
|
@@ -215,7 +217,7 @@ The following endpoints are provided by the nest-server backend:
|
|
|
215
217
|
### Authentication
|
|
216
218
|
|
|
217
219
|
| Endpoint | Method | Description |
|
|
218
|
-
|
|
220
|
+
| -------------------- | ------ | --------------------------- |
|
|
219
221
|
| `/iam/sign-in/email` | POST | Email/password sign in |
|
|
220
222
|
| `/iam/sign-up/email` | POST | Email/password registration |
|
|
221
223
|
| `/iam/sign-out` | POST | Sign out |
|
|
@@ -224,7 +226,7 @@ The following endpoints are provided by the nest-server backend:
|
|
|
224
226
|
### Passkey (WebAuthn)
|
|
225
227
|
|
|
226
228
|
| Endpoint | Method | Description |
|
|
227
|
-
|
|
229
|
+
| -------------------------------------------- | ------ | ------------------------ |
|
|
228
230
|
| `/iam/passkey/generate-register-options` | GET | Get registration options |
|
|
229
231
|
| `/iam/passkey/verify-registration` | POST | Verify registration |
|
|
230
232
|
| `/iam/passkey/generate-authenticate-options` | GET | Get auth options |
|
|
@@ -235,7 +237,7 @@ The following endpoints are provided by the nest-server backend:
|
|
|
235
237
|
### Two-Factor Authentication
|
|
236
238
|
|
|
237
239
|
| Endpoint | Method | Description |
|
|
238
|
-
|
|
240
|
+
| ------------------------------------ | ------ | ------------------ |
|
|
239
241
|
| `/iam/two-factor/enable` | POST | Enable 2FA |
|
|
240
242
|
| `/iam/two-factor/disable` | POST | Disable 2FA |
|
|
241
243
|
| `/iam/two-factor/verify-totp` | POST | Verify TOTP code |
|
|
@@ -267,7 +269,7 @@ The passkey response only contains the session, not the user. Call `validateSess
|
|
|
267
269
|
|
|
268
270
|
```typescript
|
|
269
271
|
if (result.data?.session) {
|
|
270
|
-
await validateSession();
|
|
272
|
+
await validateSession(); // Fetches user data
|
|
271
273
|
}
|
|
272
274
|
```
|
|
273
275
|
|
package/CHANGELOG.md
CHANGED
|
@@ -2,29 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.2.0](https://github.com/lenneTech/nuxt-base-starter/compare/v1.1.2...v1.2.0) (2026-01-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **auth:** add Cookie/JWT dual-mode authentication with automatic fallback ([8005425](https://github.com/lenneTech/nuxt-base-starter/commit/800542585dc22c1710f8bf587ee8371458454c79))
|
|
11
|
+
|
|
5
12
|
### [1.1.2](https://github.com/lenneTech/nuxt-base-starter/compare/v1.1.1...v1.1.2) (2026-01-22)
|
|
6
13
|
|
|
7
14
|
### [1.1.1](https://github.com/lenneTech/nuxt-base-starter/compare/v1.1.0...v1.1.1) (2026-01-20)
|
|
8
15
|
|
|
9
|
-
|
|
10
16
|
### Bug Fixes
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
- **auth:** auto-login after registration and improved passkey handling ([625128b](https://github.com/lenneTech/nuxt-base-starter/commit/625128b18fe812c141859946c196f8efb0738dca))
|
|
19
|
+
- **auth:** improve 2FA UX and document dev-mode proxy requirements ([4c4b1f4](https://github.com/lenneTech/nuxt-base-starter/commit/4c4b1f4d8b77fa93469ccc1a31d4f3292cc7c724))
|
|
14
20
|
|
|
15
21
|
## [1.1.0](https://github.com/lenneTech/nuxt-base-starter/compare/v1.0.3...v1.1.0) (2026-01-20)
|
|
16
22
|
|
|
17
|
-
|
|
18
23
|
### Features
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
- add complete Better-Auth integration with Passkey support and comprehensive documentation ([e0d470c](https://github.com/lenneTech/nuxt-base-starter/commit/e0d470c8229c37bed2948d929676620f344f4878))
|
|
21
26
|
|
|
22
27
|
## [1.2.0](https://github.com/lenneTech/nuxt-base-starter/compare/v1.0.3...v1.2.0) (2026-01-20)
|
|
23
28
|
|
|
24
|
-
|
|
25
29
|
### Features
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
- add complete Better-Auth integration with Passkey support and comprehensive documentation ([70fbec1](https://github.com/lenneTech/nuxt-base-starter/commit/70fbec14e38673c5185195fe05f0cd82bf72a800))
|
|
28
32
|
|
|
29
33
|
## [1.1.0](https://github.com/lenneTech/nuxt-base-starter/compare/v1.0.3...v1.1.0) (2026-01-20)
|
|
30
34
|
|
|
@@ -32,19 +36,17 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
32
36
|
|
|
33
37
|
### [1.0.2](https://github.com/lenneTech/nuxt-base-starter/compare/v1.0.1...v1.0.2) (2026-01-12)
|
|
34
38
|
|
|
35
|
-
|
|
36
39
|
### Bug Fixes
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
- add repository field in package.json ([1f43eae](https://github.com/lenneTech/nuxt-base-starter/commit/1f43eae4445b2f8a54cf4442c79be1bd55cf711c))
|
|
39
42
|
|
|
40
43
|
### [1.0.1](https://github.com/lenneTech/nuxt-base-starter/compare/v1.0.0...v1.0.1) (2026-01-12)
|
|
41
44
|
|
|
42
45
|
## [1.0.0](https://github.com/lenneTech/nuxt-base-starter/compare/v0.3.17...v1.0.0) (2026-01-12)
|
|
43
46
|
|
|
44
|
-
|
|
45
47
|
### Bug Fixes
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
- **DEV-609:** removed duplicate public folder inside app ([#10](https://github.com/lenneTech/nuxt-base-starter/issues/10)) ([25fe0fe](https://github.com/lenneTech/nuxt-base-starter/commit/25fe0fe3c53bc3400373d9c3f0a4b6705952171b))
|
|
48
50
|
|
|
49
51
|
### [0.3.17](https://github.com/lenneTech/nuxt-base-starter/compare/v0.3.16...v0.3.17) (2025-10-17)
|
|
50
52
|
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ The development server starts at **http://localhost:3001**
|
|
|
17
17
|
### Core Framework
|
|
18
18
|
|
|
19
19
|
| Technology | Version | Description |
|
|
20
|
-
|
|
20
|
+
| ------------ | ------- | ------------------------------------- |
|
|
21
21
|
| Nuxt | 4.x | Vue 3 meta-framework with SSR support |
|
|
22
22
|
| TypeScript | 5.9.x | Strict type checking enabled |
|
|
23
23
|
| Tailwind CSS | 4.x | Utility-first CSS with Vite plugin |
|
|
@@ -28,7 +28,7 @@ The development server starts at **http://localhost:3001**
|
|
|
28
28
|
Complete authentication system using [Better Auth](https://www.better-auth.com/):
|
|
29
29
|
|
|
30
30
|
| Feature | Description |
|
|
31
|
-
|
|
31
|
+
| ------------------ | ----------------------------------------------------- |
|
|
32
32
|
| Email/Password | Standard auth with client-side SHA256 hashing |
|
|
33
33
|
| Two-Factor (2FA) | TOTP-based 2FA with backup codes |
|
|
34
34
|
| Passkey/WebAuthn | Passwordless authentication (Touch ID, Face ID, etc.) |
|
|
@@ -42,7 +42,7 @@ Pre-built auth pages: login, register, forgot-password, reset-password, 2fa
|
|
|
42
42
|
### State & Data
|
|
43
43
|
|
|
44
44
|
| Package | Purpose |
|
|
45
|
-
|
|
45
|
+
| --------------------- | --------------------------- |
|
|
46
46
|
| Pinia | State management |
|
|
47
47
|
| VueUse | Vue composition utilities |
|
|
48
48
|
| @hey-api/client-fetch | Type-safe API client |
|
|
@@ -57,7 +57,7 @@ Pre-built auth pages: login, register, forgot-password, reset-password, 2fa
|
|
|
57
57
|
### Developer Experience
|
|
58
58
|
|
|
59
59
|
| Tool | Purpose |
|
|
60
|
-
|
|
60
|
+
| ------------------ | ---------------------------------- |
|
|
61
61
|
| OxLint | Fast linting |
|
|
62
62
|
| OxFmt | Code formatting |
|
|
63
63
|
| Playwright | E2E testing |
|
|
@@ -104,7 +104,7 @@ my-project/
|
|
|
104
104
|
## Available Scripts
|
|
105
105
|
|
|
106
106
|
| Script | Description |
|
|
107
|
-
|
|
107
|
+
| ------------------------ | -------------------------------------- |
|
|
108
108
|
| `npm run dev` | Start development server |
|
|
109
109
|
| `npm run build` | Build for production |
|
|
110
110
|
| `npm run preview` | Preview production build |
|
|
@@ -91,17 +91,17 @@ npm run generate-types
|
|
|
91
91
|
|
|
92
92
|
## Tech Stack
|
|
93
93
|
|
|
94
|
-
| Technology
|
|
95
|
-
|
|
96
|
-
| Nuxt
|
|
97
|
-
| TypeScript
|
|
98
|
-
| Tailwind CSS
|
|
99
|
-
| NuxtUI
|
|
100
|
-
| Pinia
|
|
101
|
-
| Better Auth
|
|
102
|
-
| Playwright
|
|
103
|
-
| @hey-api/client-fetch | 0.13.x
|
|
104
|
-
| Valibot
|
|
94
|
+
| Technology | Version | Description |
|
|
95
|
+
| --------------------- | ------- | -------------------------------- |
|
|
96
|
+
| Nuxt | 4.2.x | Vue 3 meta-framework with SSR |
|
|
97
|
+
| TypeScript | 5.9.x | Strict type checking |
|
|
98
|
+
| Tailwind CSS | 4.1.x | Utility-first CSS (Vite plugin) |
|
|
99
|
+
| NuxtUI | 4.3.x | Component library with dark mode |
|
|
100
|
+
| Pinia | 0.11.x | State management |
|
|
101
|
+
| Better Auth | 1.4.x | Authentication framework |
|
|
102
|
+
| Playwright | 1.57.x | E2E testing |
|
|
103
|
+
| @hey-api/client-fetch | 0.13.x | Type-safe API client |
|
|
104
|
+
| Valibot | 1.2.x | Schema validation |
|
|
105
105
|
|
|
106
106
|
## Key Features
|
|
107
107
|
|