@strands.gg/accui 0.0.5 → 0.0.7

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 CHANGED
@@ -8,9 +8,19 @@ Modern authentication UI components for Vue 3 with magic link support and OAuth
8
8
  - **OAuth Providers** - Dynamic OAuth provider discovery from API
9
9
  - **Vue 3 Composition API** - Built with modern Vue patterns
10
10
  - **TypeScript Support** - Full type safety
11
- - **Nuxt Module** - First-class Nuxt 3 support
11
+ - **Nuxt Module** - First-class Nuxt 3 support with auto-imports
12
12
  - **Customizable UI** - Consistent design system with Tailwind CSS
13
13
  - **Responsive Design** - Mobile-first approach
14
+ - **Route Protection** - Built-in middleware for authentication
15
+
16
+ ## 🆕 What's New in v0.0.6
17
+
18
+ - ✅ **Fixed Nuxt Module** - Complete rewrite with proper configuration
19
+ - ✅ **Magic Link Signup** - Passwordless authentication flow
20
+ - ✅ **Auto-imports** - Components and composables automatically available
21
+ - ✅ **Route Middleware** - Built-in `auth` and `guest` middleware
22
+ - ✅ **Updated Dependencies** - Vue 3.5.18, Vite 6.3.5, Node.js 22 support
23
+ - ✅ **Enhanced Documentation** - Complete setup guides and examples
14
24
 
15
25
  ## 📦 Installation
16
26
 
@@ -77,13 +87,183 @@ Add the module to your `nuxt.config.ts`:
77
87
  ```typescript
78
88
  export default defineNuxtConfig({
79
89
  modules: ['@strands.gg/accui/nuxt'],
80
- strandsAuth: {
81
- apiBaseUrl: 'https://your-api.com',
82
- // Other configuration options
90
+
91
+ // Public runtime configuration
92
+ runtimeConfig: {
93
+ public: {
94
+ strandsAuth: {
95
+ apiBaseUrl: 'https://accounts.strands.dev',
96
+ clientId: 'your-client-id',
97
+ onSignInUrl: '/dashboard',
98
+ onSignOutUrl: '/',
99
+ accentColor: '#EA00A8'
100
+ }
101
+ }
102
+ }
103
+ })
104
+ ```
105
+
106
+ **Available Configuration Options:**
107
+
108
+ ```typescript
109
+ interface StrandsAuthConfig {
110
+ // Required
111
+ apiBaseUrl?: string // Default: 'https://your-api.example.com'
112
+ clientId?: string // Required for production
113
+
114
+ // Navigation
115
+ onSignInUrl?: string // Default: '/dashboard'
116
+ onSignOutUrl?: string // Default: '/'
117
+ redirectUrl?: string // OAuth callback URL
118
+
119
+ // Styling
120
+ accentColor?: string // Default: '#EA00A8'
121
+
122
+ // Security & Performance
123
+ autoRefresh?: boolean // Default: true
124
+ refreshInterval?: number // Default: 4 (minutes)
125
+
126
+ // Route Protection
127
+ protectedRoutes?: string[] // Routes requiring authentication
128
+ guestOnlyRoutes?: string[] // Default: ['/auth', '/login', '/register']
129
+
130
+ // Development
131
+ devMode?: boolean // Default: false
132
+ }
133
+ ```
134
+
135
+ **Complete Configuration Example:**
136
+
137
+ ```typescript
138
+ export default defineNuxtConfig({
139
+ modules: ['@strands.gg/accui/nuxt'],
140
+
141
+ runtimeConfig: {
142
+ public: {
143
+ strandsAuth: {
144
+ // API Configuration
145
+ apiBaseUrl: 'https://accounts.strands.dev',
146
+ clientId: 'your-production-client-id',
147
+
148
+ // Navigation URLs
149
+ onSignInUrl: '/dashboard',
150
+ onSignOutUrl: '/welcome',
151
+ redirectUrl: '/auth/callback',
152
+
153
+ // Styling
154
+ accentColor: '#8b5cf6',
155
+
156
+ // Route Protection
157
+ protectedRoutes: [
158
+ '/dashboard/*',
159
+ '/profile',
160
+ '/settings/*',
161
+ '/admin/*'
162
+ ],
163
+ guestOnlyRoutes: [
164
+ '/auth',
165
+ '/login',
166
+ '/register',
167
+ '/welcome'
168
+ ],
169
+
170
+ // Token Management
171
+ autoRefresh: true,
172
+ refreshInterval: 4, // minutes
173
+
174
+ // Development
175
+ devMode: process.env.NODE_ENV === 'development'
176
+ }
177
+ }
83
178
  }
84
179
  })
85
180
  ```
86
181
 
182
+ **Auto-imported Components & Composables:**
183
+
184
+ ```vue
185
+ <template>
186
+ <!-- Authentication Components (auto-imported) -->
187
+ <StrandsAuth @success="handleAuth" />
188
+ <StrandsSignIn @success="handleSignIn" />
189
+ <StrandsSignUp @success="handleSignUp" />
190
+ <StrandsPasswordReset @success="handleReset" />
191
+ <StrandsUserProfile />
192
+ <StrandsMFASetup />
193
+
194
+ <!-- Utility Components (auto-imported) -->
195
+ <SignedIn>
196
+ <p>Welcome back, {{ user?.firstName }}!</p>
197
+ <UiButton @click="signOut">Sign Out</UiButton>
198
+ </SignedIn>
199
+
200
+ <SignedOut>
201
+ <p>Please sign in to continue</p>
202
+ <StrandsAuth />
203
+ </SignedOut>
204
+
205
+ <!-- Configuration & Branding -->
206
+ <StrandsConfigProvider :config="customConfig">
207
+ <!-- Scoped configuration -->
208
+ </StrandsConfigProvider>
209
+
210
+ <StrandsSecuredFooter />
211
+ </template>
212
+
213
+ <script setup lang="ts">
214
+ // Composables are auto-imported in Nuxt
215
+ const { user, isAuthenticated, signOut, signIn } = useStrandsAuth()
216
+ const authUser = useAuthUser() // Reactive user object
217
+ const { isAuthenticated: authState, isLoading } = useAuthState()
218
+
219
+ // Event handlers
220
+ const handleAuth = (userData: any) => {
221
+ console.log('Authentication successful:', userData)
222
+ // User is automatically redirected based on onSignInUrl
223
+ }
224
+
225
+ const handleSignUp = (data: { email: string }) => {
226
+ console.log('Magic link sent to:', data.email)
227
+ // Show success message to user
228
+ }
229
+ </script>
230
+ ```
231
+
232
+ **Route Protection with Middleware:**
233
+
234
+ ```vue
235
+ <!-- pages/dashboard/index.vue -->
236
+ <script setup lang="ts">
237
+ // Protect this route - redirects to auth if not signed in
238
+ definePageMeta({
239
+ middleware: 'auth'
240
+ })
241
+ </script>
242
+
243
+ <template>
244
+ <div>
245
+ <h1>Dashboard</h1>
246
+ <p>Protected content here</p>
247
+ </div>
248
+ </template>
249
+ ```
250
+
251
+ ```vue
252
+ <!-- pages/auth.vue -->
253
+ <script setup lang="ts">
254
+ // Guest-only route - redirects away if already signed in
255
+ definePageMeta({
256
+ middleware: 'guest'
257
+ })
258
+ </script>
259
+
260
+ <template>
261
+ <div>
262
+ <StrandsAuth />
263
+ </div>
264
+ </template>
265
+ ```
266
+
87
267
  ## 🧩 Components
88
268
 
89
269
  ### Authentication Components
@@ -118,7 +298,42 @@ export default defineNuxtConfig({
118
298
  | `UiAlert` | Status messages | `variant`, `message` |
119
299
  | `UiLink` | Styled link | `variant`, `size` |
120
300
 
121
- ## 🔧 Composables
301
+ ## Nuxt Module Features
302
+
303
+ The Nuxt module provides a complete authentication solution with:
304
+
305
+ ### ✨ **Auto-Registration**
306
+ - **Components**: All authentication and UI components are automatically imported
307
+ - **Composables**: Authentication state management available globally
308
+ - **Middleware**: Route protection built-in (`auth`, `guest`, global middleware)
309
+ - **Types**: Full TypeScript support with auto-completion
310
+
311
+ ### 🔒 **Route Protection**
312
+ ```typescript
313
+ // Automatic protection based on configuration
314
+ protectedRoutes: ['/dashboard/*', '/profile', '/settings/*']
315
+ guestOnlyRoutes: ['/auth', '/login', '/register']
316
+ ```
317
+
318
+ ### 🎨 **Styling Integration**
319
+ - Custom CSS variables for theming
320
+ - Configurable accent colors
321
+ - TailwindCSS compatibility
322
+ - Dark/light mode support
323
+
324
+ ### ⚡ **Performance Optimized**
325
+ - Client-side hydration with SSR support
326
+ - Automatic token refresh
327
+ - Minimal bundle size impact
328
+ - Tree-shaking optimized
329
+
330
+ ### 🛠️ **Developer Experience**
331
+ - Hot reload support
332
+ - Development mode with debug logging
333
+ - TypeScript definitions included
334
+ - Comprehensive error handling
335
+
336
+ ## �🔧 Composables
122
337
 
123
338
  ### `useStrandsAuth()`
124
339
 
@@ -236,6 +451,56 @@ All components are mobile-first and responsive:
236
451
  - **Tablet**: Adaptive spacing and sizing
237
452
  - **Desktop**: Full-featured experience
238
453
 
454
+ ## 🔧 Troubleshooting
455
+
456
+ ### Nuxt Module Issues
457
+
458
+ **Module not found:**
459
+ ```bash
460
+ npm install @strands.gg/accui
461
+ # Ensure module is in nuxt.config.ts modules array
462
+ ```
463
+
464
+ **TypeScript errors:**
465
+ ```typescript
466
+ // Add type declaration in nuxt.config.ts
467
+ declare module '@nuxt/schema' {
468
+ interface RuntimeConfig {
469
+ public: {
470
+ strandsAuth: StrandsAuthConfig
471
+ }
472
+ }
473
+ }
474
+ ```
475
+
476
+ **Components not auto-importing:**
477
+ ```typescript
478
+ // Verify module configuration
479
+ modules: ['@strands.gg/accui/nuxt']
480
+ ```
481
+
482
+ **Middleware not working:**
483
+ ```vue
484
+ <!-- Ensure pages are in pages/ directory -->
485
+ <script setup lang="ts">
486
+ definePageMeta({
487
+ middleware: 'auth' // or 'guest'
488
+ })
489
+ </script>
490
+ ```
491
+
492
+ ### Common Issues
493
+
494
+ **Build errors:**
495
+ - Ensure Node.js 16+ is installed
496
+ - Clear `.nuxt` and `node_modules`, reinstall dependencies
497
+ - Check for conflicting CSS frameworks
498
+
499
+ **Runtime errors:**
500
+ - Verify `apiBaseUrl` and `clientId` configuration
501
+ - Check browser console for detailed error messages
502
+ - Enable `devMode: true` for debugging
503
+
239
504
  ## 🎨 Theming
240
505
 
241
506
  Components use CSS custom properties for theming:
@@ -267,6 +532,7 @@ import type {
267
532
  - **Vue**: 3.5+
268
533
  - **Node**: 16+
269
534
  - **TypeScript**: 5+ (optional but recommended)
535
+ - **Nuxt**: 3.0+ (for Nuxt module)
270
536
 
271
537
  ## 📄 License
272
538
 
@@ -3,15 +3,11 @@ export interface StrandsAuthConfig {
3
3
  * Base URL for the Strands Auth API
4
4
  * @default 'https://your-api.example.com'
5
5
  */
6
- baseUrl?: string;
6
+ apiBaseUrl?: string;
7
7
  /**
8
- * Application ID for Strands Auth
8
+ * Client ID for authentication
9
9
  */
10
- applicationId?: string;
11
- /**
12
- * Public key for client-side authentication
13
- */
14
- publicKey?: string;
10
+ clientId?: string;
15
11
  /**
16
12
  * Primary accent color for the auth components
17
13
  * @default '#EA00A8'
@@ -32,12 +28,6 @@ export interface StrandsAuthConfig {
32
28
  * @default '/'
33
29
  */
34
30
  onSignOutUrl?: string;
35
- /**
36
- * OAuth providers to enable
37
- * @deprecated OAuth providers are now dynamically fetched from API
38
- * @default []
39
- */
40
- oauthProviders?: string[];
41
31
  /**
42
32
  * Enable automatic token refresh
43
33
  * @default true
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../apps/accounts-ui/src/nuxt/module.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IAEzB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAE1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAE1B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;;AAED,wBAyHE"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../apps/accounts-ui/src/nuxt/module.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAE1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAE1B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;;AAED,wBAyHE"}