@strands.gg/accui 0.0.6 → 0.0.8

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,22 @@ 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.7
17
+
18
+ - ✅ **Auto-Import Styles** - Styles automatically imported with components (no manual CSS import needed)
19
+ - ✅ **Custom Styling Control** - `autoImportStyles: false` option for developers who want full styling control
20
+ - ✅ **Enhanced Nuxt Integration** - CSS automatically included in Nuxt builds
21
+ - ✅ **Simplified Setup** - Just install and use, styles are handled automatically
22
+ - ✅ **Fixed Nuxt Module** - Complete rewrite with proper configuration
23
+ - ✅ **Magic Link Signup** - Passwordless authentication flow
24
+ - ✅ **Auto-imports** - Components and composables automatically available
25
+ - ✅ **Route Middleware** - Built-in `auth` and `guest` middleware
26
+ - ✅ **Updated Dependencies** - Vue 3.5.18, Vite 6.3.5, Node.js 22 support
14
27
 
15
28
  ## 📦 Installation
16
29
 
@@ -18,13 +31,25 @@ Modern authentication UI components for Vue 3 with magic link support and OAuth
18
31
  npm install @strands.gg/accui
19
32
  ```
20
33
 
21
- ### Import Styles
34
+ ### Styles Auto-Import
35
+
36
+ **Styles are automatically imported!** No manual CSS import needed.
37
+
38
+ - **Vue 3**: Styles load automatically when you import any component
39
+ - **Nuxt 3**: Styles are automatically included when you add the module
40
+
41
+ <details>
42
+ <summary>Manual CSS Import (if needed)</summary>
43
+
44
+ If you need to manually import styles for any reason:
22
45
 
23
46
  ```javascript
24
47
  // Import the CSS in your main.js or app.vue
25
48
  import '@strands.gg/accui/style.css'
26
49
  ```
27
50
 
51
+ </details>
52
+
28
53
  ## 🎯 Quick Start
29
54
 
30
55
  ### Basic Vue 3 Usage
@@ -52,6 +77,7 @@ import {
52
77
  StrandsSignUp,
53
78
  useStrandsAuth
54
79
  } from "@strands.gg/accui"
80
+ // Styles are automatically imported! ✨
55
81
 
56
82
  // Access auth state globally
57
83
  const { user, isAuthenticated, signOut } = useStrandsAuth()
@@ -74,16 +100,188 @@ const handleSignUpSuccess = (data: { email: string }) => {
74
100
 
75
101
  Add the module to your `nuxt.config.ts`:
76
102
 
103
+ ```typescript
104
+ export default defineNuxtConfig({
105
+ modules: ['@strands.gg/accui/nuxt'], // Styles auto-imported! ✨
106
+
107
+ // Public runtime configuration
108
+ runtimeConfig: {
109
+ public: {
110
+ strandsAuth: {
111
+ apiBaseUrl: 'https://accounts.strands.dev',
112
+ clientId: 'your-client-id',
113
+ onSignInUrl: '/dashboard',
114
+ onSignOutUrl: '/',
115
+ accentColor: '#EA00A8'
116
+ }
117
+ }
118
+ }
119
+ })
120
+ ```
121
+
122
+ **Available Configuration Options:**
123
+
124
+ ```typescript
125
+ interface StrandsAuthConfig {
126
+ // Required
127
+ apiBaseUrl?: string // Default: 'https://your-api.example.com'
128
+ clientId?: string // Required for production
129
+
130
+ // Navigation
131
+ onSignInUrl?: string // Default: '/dashboard'
132
+ onSignOutUrl?: string // Default: '/'
133
+ redirectUrl?: string // OAuth callback URL
134
+
135
+ // Styling
136
+ accentColor?: string // Default: '#EA00A8'
137
+ autoImportStyles?: boolean // Default: true (disable for custom styling)
138
+
139
+ // Security & Performance
140
+ autoRefresh?: boolean // Default: true
141
+ refreshInterval?: number // Default: 4 (minutes)
142
+
143
+ // Route Protection
144
+ protectedRoutes?: string[] // Routes requiring authentication
145
+ guestOnlyRoutes?: string[] // Default: ['/auth', '/login', '/register']
146
+
147
+ // Development
148
+ devMode?: boolean // Default: false
149
+ }
150
+ ```
151
+
152
+ **Complete Configuration Example:**
153
+
77
154
  ```typescript
78
155
  export default defineNuxtConfig({
79
156
  modules: ['@strands.gg/accui/nuxt'],
80
- strandsAuth: {
81
- apiBaseUrl: 'https://your-api.com',
82
- // Other configuration options
157
+
158
+ runtimeConfig: {
159
+ public: {
160
+ strandsAuth: {
161
+ // API Configuration
162
+ apiBaseUrl: 'https://accounts.strands.dev',
163
+ clientId: 'your-production-client-id',
164
+
165
+ // Navigation URLs
166
+ onSignInUrl: '/dashboard',
167
+ onSignOutUrl: '/welcome',
168
+ redirectUrl: '/auth/callback',
169
+
170
+ // Styling
171
+ accentColor: '#8b5cf6',
172
+ autoImportStyles: true, // Set to false for custom styling
173
+
174
+ // Route Protection
175
+ protectedRoutes: [
176
+ '/dashboard/*',
177
+ '/profile',
178
+ '/settings/*',
179
+ '/admin/*'
180
+ ],
181
+ guestOnlyRoutes: [
182
+ '/auth',
183
+ '/login',
184
+ '/register',
185
+ '/welcome'
186
+ ],
187
+
188
+ // Token Management
189
+ autoRefresh: true,
190
+ refreshInterval: 4, // minutes
191
+
192
+ // Development
193
+ devMode: process.env.NODE_ENV === 'development'
194
+ }
195
+ }
83
196
  }
84
197
  })
85
198
  ```
86
199
 
200
+ **Auto-imported Components & Composables:**
201
+
202
+ ```vue
203
+ <template>
204
+ <!-- Authentication Components (auto-imported) -->
205
+ <StrandsAuth @success="handleAuth" />
206
+ <StrandsSignIn @success="handleSignIn" />
207
+ <StrandsSignUp @success="handleSignUp" />
208
+ <StrandsPasswordReset @success="handleReset" />
209
+ <StrandsUserProfile />
210
+ <StrandsMFASetup />
211
+
212
+ <!-- Utility Components (auto-imported) -->
213
+ <SignedIn>
214
+ <p>Welcome back, {{ user?.firstName }}!</p>
215
+ <UiButton @click="signOut">Sign Out</UiButton>
216
+ </SignedIn>
217
+
218
+ <SignedOut>
219
+ <p>Please sign in to continue</p>
220
+ <StrandsAuth />
221
+ </SignedOut>
222
+
223
+ <!-- Configuration & Branding -->
224
+ <StrandsConfigProvider :config="customConfig">
225
+ <!-- Scoped configuration -->
226
+ </StrandsConfigProvider>
227
+
228
+ <StrandsSecuredFooter />
229
+ </template>
230
+
231
+ <script setup lang="ts">
232
+ // Composables are auto-imported in Nuxt
233
+ const { user, isAuthenticated, signOut, signIn } = useStrandsAuth()
234
+ const authUser = useAuthUser() // Reactive user object
235
+ const { isAuthenticated: authState, isLoading } = useAuthState()
236
+
237
+ // Event handlers
238
+ const handleAuth = (userData: any) => {
239
+ console.log('Authentication successful:', userData)
240
+ // User is automatically redirected based on onSignInUrl
241
+ }
242
+
243
+ const handleSignUp = (data: { email: string }) => {
244
+ console.log('Magic link sent to:', data.email)
245
+ // Show success message to user
246
+ }
247
+ </script>
248
+ ```
249
+
250
+ **Route Protection with Middleware:**
251
+
252
+ ```vue
253
+ <!-- pages/dashboard/index.vue -->
254
+ <script setup lang="ts">
255
+ // Protect this route - redirects to auth if not signed in
256
+ definePageMeta({
257
+ middleware: 'auth'
258
+ })
259
+ </script>
260
+
261
+ <template>
262
+ <div>
263
+ <h1>Dashboard</h1>
264
+ <p>Protected content here</p>
265
+ </div>
266
+ </template>
267
+ ```
268
+
269
+ ```vue
270
+ <!-- pages/auth.vue -->
271
+ <script setup lang="ts">
272
+ // Guest-only route - redirects away if already signed in
273
+ definePageMeta({
274
+ middleware: 'guest'
275
+ })
276
+ </script>
277
+
278
+ <template>
279
+ <div>
280
+ <StrandsAuth />
281
+ </div>
282
+ </template>
283
+ ```
284
+
87
285
  ## 🧩 Components
88
286
 
89
287
  ### Authentication Components
@@ -118,7 +316,77 @@ export default defineNuxtConfig({
118
316
  | `UiAlert` | Status messages | `variant`, `message` |
119
317
  | `UiLink` | Styled link | `variant`, `size` |
120
318
 
121
- ## 🔧 Composables
319
+ ## Nuxt Module Features
320
+
321
+ The Nuxt module provides a complete authentication solution with:
322
+
323
+ ### ✨ **Auto-Registration**
324
+ - **Components**: All authentication and UI components are automatically imported
325
+ - **Composables**: Authentication state management available globally
326
+ - **Middleware**: Route protection built-in (`auth`, `guest`, global middleware)
327
+ - **Types**: Full TypeScript support with auto-completion
328
+ - **Styles**: CSS automatically included in your Nuxt build
329
+
330
+ ### 🎨 **Auto-Import Styles**
331
+ The Nuxt module automatically includes all necessary CSS:
332
+ ```typescript
333
+ // Automatically added to your project:
334
+ // - Main component styles (@strands.gg/accui/style.css)
335
+ // - Custom accent color variables
336
+ // - Responsive design classes
337
+ // - Dark/light mode support
338
+ ```
339
+
340
+ **Custom Styling (Disable Auto-Import):**
341
+ ```typescript
342
+ export default defineNuxtConfig({
343
+ modules: ['@strands.gg/accui/nuxt'],
344
+ runtimeConfig: {
345
+ public: {
346
+ strandsAuth: {
347
+ apiBaseUrl: 'https://accounts.strands.dev',
348
+ clientId: 'your-client-id',
349
+ autoImportStyles: false, // Disable auto-import
350
+ // ... other options
351
+ }
352
+ }
353
+ },
354
+ // Manually control CSS imports
355
+ css: [
356
+ // Import only base styles
357
+ '@strands.gg/accui/style.css',
358
+ // Or use your own custom styles
359
+ '~/assets/css/custom-auth.css'
360
+ ]
361
+ })
362
+ ```
363
+
364
+ ### 🔒 **Route Protection**
365
+ ```typescript
366
+ // Automatic protection based on configuration
367
+ protectedRoutes: ['/dashboard/*', '/profile', '/settings/*']
368
+ guestOnlyRoutes: ['/auth', '/login', '/register']
369
+ ```
370
+
371
+ ### 🎨 **Styling Integration**
372
+ - Custom CSS variables for theming
373
+ - Configurable accent colors
374
+ - TailwindCSS compatibility
375
+ - Dark/light mode support
376
+
377
+ ### ⚡ **Performance Optimized**
378
+ - Client-side hydration with SSR support
379
+ - Automatic token refresh
380
+ - Minimal bundle size impact
381
+ - Tree-shaking optimized
382
+
383
+ ### 🛠️ **Developer Experience**
384
+ - Hot reload support
385
+ - Development mode with debug logging
386
+ - TypeScript definitions included
387
+ - Comprehensive error handling
388
+
389
+ ## �🔧 Composables
122
390
 
123
391
  ### `useStrandsAuth()`
124
392
 
@@ -236,6 +504,82 @@ All components are mobile-first and responsive:
236
504
  - **Tablet**: Adaptive spacing and sizing
237
505
  - **Desktop**: Full-featured experience
238
506
 
507
+ ## 🔧 Troubleshooting
508
+
509
+ ### Nuxt Module Issues
510
+
511
+ **Module not found:**
512
+ ```bash
513
+ npm install @strands.gg/accui
514
+ # Ensure module is in nuxt.config.ts modules array
515
+ ```
516
+
517
+ **TypeScript errors:**
518
+ ```typescript
519
+ // Add type declaration in nuxt.config.ts
520
+ declare module '@nuxt/schema' {
521
+ interface RuntimeConfig {
522
+ public: {
523
+ strandsAuth: StrandsAuthConfig
524
+ }
525
+ }
526
+ }
527
+ ```
528
+
529
+ **Components not auto-importing:**
530
+ ```typescript
531
+ // Verify module configuration
532
+ modules: ['@strands.gg/accui/nuxt']
533
+ ```
534
+
535
+ **Styles not loading:**
536
+ ```typescript
537
+ // Check if auto-import is enabled (default: true)
538
+ runtimeConfig: {
539
+ public: {
540
+ strandsAuth: {
541
+ autoImportStyles: true // Enable auto-import
542
+ }
543
+ }
544
+ }
545
+
546
+ // Or manually import styles:
547
+ export default defineNuxtConfig({
548
+ css: ['@strands.gg/accui/style.css'] // Manual import
549
+ })
550
+
551
+ // For completely custom styling:
552
+ runtimeConfig: {
553
+ public: {
554
+ strandsAuth: {
555
+ autoImportStyles: false // Disable auto-import
556
+ }
557
+ }
558
+ }
559
+ ```
560
+
561
+ **Middleware not working:**
562
+ ```vue
563
+ <!-- Ensure pages are in pages/ directory -->
564
+ <script setup lang="ts">
565
+ definePageMeta({
566
+ middleware: 'auth' // or 'guest'
567
+ })
568
+ </script>
569
+ ```
570
+
571
+ ### Common Issues
572
+
573
+ **Build errors:**
574
+ - Ensure Node.js 16+ is installed
575
+ - Clear `.nuxt` and `node_modules`, reinstall dependencies
576
+ - Check for conflicting CSS frameworks
577
+
578
+ **Runtime errors:**
579
+ - Verify `apiBaseUrl` and `clientId` configuration
580
+ - Check browser console for detailed error messages
581
+ - Enable `devMode: true` for debugging
582
+
239
583
  ## 🎨 Theming
240
584
 
241
585
  Components use CSS custom properties for theming:
@@ -267,6 +611,7 @@ import type {
267
611
  - **Vue**: 3.5+
268
612
  - **Node**: 16+
269
613
  - **TypeScript**: 5+ (optional but recommended)
614
+ - **Nuxt**: 3.0+ (for Nuxt module)
270
615
 
271
616
  ## 📄 License
272
617
 
@@ -0,0 +1,6 @@
1
+ import { App } from 'vue';
2
+ export declare function autoImportStyles(): void;
3
+ export declare const StrandsStylesPlugin: {
4
+ install(app: App): void;
5
+ };
6
+ //# sourceMappingURL=auto-import-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-import-styles.d.ts","sourceRoot":"","sources":["../../../apps/accounts-ui/src/auto-import-styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAKzB,wBAAgB,gBAAgB,SAU/B;AAGD,eAAO,MAAM,mBAAmB;iBACjB,GAAG;CAIjB,CAAA"}
@@ -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
@@ -63,6 +53,12 @@ export interface StrandsAuthConfig {
63
53
  * @default false
64
54
  */
65
55
  devMode?: boolean;
56
+ /**
57
+ * Automatically import CSS styles
58
+ * Set to false if you want to manually import styles or use custom styling
59
+ * @default true
60
+ */
61
+ styles?: boolean;
66
62
  }
67
63
  declare const _default: import('@nuxt/schema').NuxtModule<StrandsAuthConfig, StrandsAuthConfig, false>;
68
64
  export default _default;
@@ -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;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;;AAED,wBAoIE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strands.gg/accui",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Strands Authentication UI Components",
5
5
  "type": "module",
6
6
  "main": "./dist/strands-auth-ui.umd.js",
@@ -12,7 +12,7 @@
12
12
  "import": "./dist/strands-auth-ui.es.js",
13
13
  "require": "./dist/strands-auth-ui.umd.js"
14
14
  },
15
- "./style.css": "./dist/style.css",
15
+ "./style.css": "./dist/accui.css",
16
16
  "./nuxt": {
17
17
  "types": "./dist/nuxt.d.ts",
18
18
  "import": "./dist/nuxt.d.ts"