@habityzer/nuxt-symfony-kinde-layer 2.2.0 → 2.2.1

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +69 -34
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## [2.2.1](https://github.com/Habityzer/nuxt-symfony-kinde-layer/compare/v2.2.0...v2.2.1) (2026-02-13)
2
+
1
3
  # [2.2.0](https://github.com/Habityzer/nuxt-symfony-kinde-layer/compare/v2.1.4...v2.2.0) (2026-02-13)
2
4
 
3
5
 
package/README.md CHANGED
@@ -47,13 +47,13 @@ export default defineNuxtConfig({
47
47
  public: {
48
48
  apiBaseUrl: process.env.API_BASE_URL,
49
49
 
50
- // IMPORTANT: Expose auth config for middleware (must match kindeAuth below)
50
+ // Optional: Override layer defaults for auth config
51
51
  kindeAuth: {
52
52
  cookie: {
53
- prefix: 'myapp_' // Must match prefix in kindeAuth
53
+ prefix: 'myapp_' // Override default cookie prefix
54
54
  },
55
55
  middleware: {
56
- publicRoutes: ['/', '/blog', '/help']
56
+ publicRoutes: ['/', '/blog', '/help'] // Override default public routes
57
57
  }
58
58
  }
59
59
  }
@@ -61,17 +61,17 @@ export default defineNuxtConfig({
61
61
 
62
62
  // Configure Kinde authentication module
63
63
  kindeAuth: {
64
- authDomain: process.env.NUXT_KINDE_AUTH_DOMAIN,
65
- clientId: process.env.NUXT_KINDE_CLIENT_ID,
66
- clientSecret: process.env.NUXT_KINDE_CLIENT_SECRET,
67
- redirectURL: process.env.NUXT_KINDE_REDIRECT_URL,
68
- logoutRedirectURL: process.env.NUXT_KINDE_LOGOUT_REDIRECT_URL,
64
+ authDomain: process.env.KINDE_AUTH_DOMAIN,
65
+ clientId: process.env.KINDE_CLIENT_ID,
66
+ clientSecret: process.env.KINDE_CLIENT_SECRET,
67
+ redirectURL: process.env.KINDE_REDIRECT_URL,
68
+ logoutRedirectURL: process.env.KINDE_LOGOUT_REDIRECT_URL,
69
69
  postLoginRedirectURL: '/dashboard',
70
70
  cookie: {
71
- prefix: 'myapp_' // IMPORTANT: Must be unique per project to avoid cookie conflicts
71
+ prefix: 'myapp_' // IMPORTANT: Must match runtimeConfig.public.kindeAuth.cookie.prefix
72
72
  },
73
73
  middleware: {
74
- publicRoutes: ['/', '/blog', '/help'] // Must match publicRoutes in runtimeConfig.public
74
+ publicRoutes: ['/', '/blog', '/help'] // Must match runtimeConfig.public
75
75
  }
76
76
  }
77
77
  })
@@ -79,21 +79,32 @@ export default defineNuxtConfig({
79
79
 
80
80
  ### 2. Environment Variables
81
81
 
82
- Create a `.env` file:
82
+ Create a `.env` file in your project:
83
83
 
84
84
  ```bash
85
85
  # Symfony Backend
86
86
  API_BASE_URL=http://localhost:8000
87
87
 
88
- # Kinde Authentication
89
- NUXT_KINDE_AUTH_DOMAIN=https://your-domain.kinde.com
90
- NUXT_KINDE_CLIENT_ID=your-client-id
91
- NUXT_KINDE_CLIENT_SECRET=your-client-secret
92
- NUXT_KINDE_REDIRECT_URL=http://localhost:3000/api/kinde/callback
93
- NUXT_KINDE_LOGOUT_REDIRECT_URL=http://localhost:3000
94
- NUXT_KINDE_POST_LOGIN_REDIRECT_URL=/dashboard
88
+ # Kinde Authentication (required by @habityzer/nuxt-kinde-auth module)
89
+ KINDE_AUTH_DOMAIN=https://your-domain.kinde.com
90
+ KINDE_CLIENT_ID=your-client-id
91
+ KINDE_CLIENT_SECRET=your-client-secret
92
+ KINDE_REDIRECT_URL=http://localhost:3000/api/kinde/callback
93
+ KINDE_LOGOUT_REDIRECT_URL=http://localhost:3000
94
+
95
+ # Layer Configuration (optional - layer provides defaults)
96
+ NUXT_PUBLIC_AUTH_COOKIE_PREFIX=myapp_
97
+ NUXT_PUBLIC_AUTH_LOGIN_PATH=/api/kinde/login
98
+ NUXT_PUBLIC_AUTH_CLOCK_SKEW_SECONDS=300
99
+ NUXT_PUBLIC_AUTH_APP_TOKEN_PREFIX=Bearer
100
+ NUXT_PUBLIC_AUTH_E2E_TOKEN_COOKIE_NAME=kinde_token
101
+ NUXT_PUBLIC_AUTH_ID_TOKEN_NAME=id_token
102
+ NUXT_PUBLIC_AUTH_ACCESS_TOKEN_NAME=access_token
103
+ NUXT_PUBLIC_AUTH_REFRESH_TOKEN_NAME=refresh_token
95
104
  ```
96
105
 
106
+ **Note:** The layer provides sensible defaults for all `NUXT_PUBLIC_AUTH_*` variables. You only need to override them if you want different values. The `KINDE_*` variables are required.
107
+
97
108
  ### 3. Use the Auth Composable
98
109
 
99
110
  ```vue
@@ -158,9 +169,12 @@ const response = await getUsersApi()
158
169
  ### Files
159
170
 
160
171
  - `server/api/symfony/[...].ts` - Symfony API proxy with auth
172
+ - `server/middleware/auth-guard.ts` - Server-side authentication middleware
173
+ - `server/utils/auth-constants.ts` - Re-exports shared auth constants for server
161
174
  - `app/composables/useAuth.ts` - Authentication composable
162
- - `app/constants/auth.ts` - Auth constants
163
- - `app/middleware/auth.global.ts` - Global route protection
175
+ - `app/plugins/auth-guard.client.ts` - Client-side authentication guard
176
+ - `app/constants/auth.ts` - Re-exports shared auth constants for app
177
+ - `shared/auth-constants.ts` - Core authentication constants (source of truth)
164
178
 
165
179
  ## Configuration Options
166
180
 
@@ -266,16 +280,19 @@ Add these scripts to your project's `package.json`:
266
280
  pnpm install
267
281
  ```
268
282
 
269
- 2. **The project uses Husky for git hooks:**
270
- - Pre-commit: Automatically runs `pnpm lint` before each commit
271
- - Commit-msg: Validates commit message format (conventional commits)
272
-
273
- 3. **Run linter manually:**
283
+ 2. **Available scripts:**
274
284
  ```bash
275
- pnpm lint # Check for issues
276
- pnpm lint:fix # Auto-fix issues
285
+ pnpm dev # Run dev server with example env
286
+ pnpm build # Build the layer
287
+ pnpm lint # Check for linting issues
288
+ pnpm lint:fix # Auto-fix linting issues
289
+ pnpm release # Create semantic release (CI only)
277
290
  ```
278
291
 
292
+ 3. **Git hooks (via Husky):**
293
+ - Pre-commit: Automatically runs `pnpm lint` before each commit
294
+ - Commit-msg: Validates commit message format (conventional commits)
295
+
279
296
  4. **First time setup:**
280
297
  The pre-commit hook will automatically run `nuxt prepare` if needed (with placeholder environment variables).
281
298
 
@@ -354,16 +371,34 @@ If you get type mismatches between expected Hydra collections and plain arrays,
354
371
 
355
372
  ## Architecture & Design Decisions
356
373
 
357
- ### Why Constants Are Defined Inline in Server Code
374
+ ### Shared Constants Architecture
375
+
376
+ The layer uses a centralized constants file at `shared/auth-constants.ts` as the single source of truth for authentication configuration values (cookie names, token prefixes, etc.).
377
+
378
+ **Structure:**
379
+ - `shared/auth-constants.ts` - Core constants definitions
380
+ - `app/constants/auth.ts` - Re-exports for client-side code (supports `~/constants/auth` imports)
381
+ - `server/utils/auth-constants.ts` - Re-exports for server-side code (supports `#imports` and relative imports)
382
+
383
+ **Why this structure:**
384
+ - Single source of truth prevents drift between client and server values
385
+ - Re-export pattern works around Nuxt/Nitro bundling constraints
386
+ - Maintains clean import paths for consuming projects
387
+
388
+ ### Runtime Configuration
358
389
 
359
- You'll notice that auth constants (`E2E_TOKEN_COOKIE_NAME`, `APP_TOKEN_PREFIX`, `KINDE_ID_TOKEN_COOKIE_NAME`) are defined directly in the server files (`server/api/symfony/[...].ts`) rather than imported from a shared constants file.
390
+ The layer uses Nuxt's `runtimeConfig` to make authentication settings available to both server middleware and client code:
360
391
 
361
- **Reason**: Nitro's bundling process for server-side code doesn't support:
362
- - App aliases like `~` or `@` (these resolve to the consuming project's app directory, not the layer's)
363
- - Relative imports from external layers during the rollup bundling phase
364
- - The `#build` alias for accessing layer exports
392
+ **Implementation:**
393
+ 1. Constants are imported in `nuxt.config.ts` from `shared/auth-constants.ts`
394
+ 2. Environment variables override defaults (e.g., `NUXT_PUBLIC_AUTH_COOKIE_PREFIX`)
395
+ 3. Values are merged into `runtimeConfig.public.kindeAuth` for runtime access
396
+ 4. Both server middleware and client plugins read from runtime config
365
397
 
366
- **Solution**: We define these constants inline in server files while maintaining the shared `app/constants/auth.ts` for client-side code. This is a deliberate architectural choice to ensure reliable builds across all consuming projects.
398
+ This approach allows:
399
+ - Projects to override defaults via environment variables
400
+ - Type-safe access to configuration throughout the app
401
+ - Consistent behavior between development and production
367
402
 
368
403
  ### Cookie Prefix Configuration
369
404
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@habityzer/nuxt-symfony-kinde-layer",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Shared Nuxt layer for Symfony + Kinde authentication integration",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",