@strands.gg/accui 0.0.4 → 0.0.5
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 +249 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,49 +1,278 @@
|
|
|
1
1
|
# @strands.gg/accui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modern authentication UI components for Vue 3 with magic link support and OAuth integration.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 🚀 Features
|
|
6
|
+
|
|
7
|
+
- **Magic Link Authentication** - Passwordless signup flow
|
|
8
|
+
- **OAuth Providers** - Dynamic OAuth provider discovery from API
|
|
9
|
+
- **Vue 3 Composition API** - Built with modern Vue patterns
|
|
10
|
+
- **TypeScript Support** - Full type safety
|
|
11
|
+
- **Nuxt Module** - First-class Nuxt 3 support
|
|
12
|
+
- **Customizable UI** - Consistent design system with Tailwind CSS
|
|
13
|
+
- **Responsive Design** - Mobile-first approach
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
6
16
|
|
|
7
17
|
```bash
|
|
8
18
|
npm install @strands.gg/accui
|
|
9
19
|
```
|
|
10
20
|
|
|
11
|
-
|
|
21
|
+
### Import Styles
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
// Import the CSS in your main.js or app.vue
|
|
25
|
+
import '@strands.gg/accui/style.css'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 🎯 Quick Start
|
|
29
|
+
|
|
30
|
+
### Basic Vue 3 Usage
|
|
12
31
|
|
|
13
32
|
```vue
|
|
14
33
|
<template>
|
|
15
34
|
<div>
|
|
35
|
+
<!-- Combined Auth Component with tabs -->
|
|
36
|
+
<StrandsAuth
|
|
37
|
+
@success="handleSuccess"
|
|
38
|
+
@error="handleError"
|
|
39
|
+
redirect-url="/dashboard"
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
<!-- Or use individual components -->
|
|
16
43
|
<StrandsSignIn @success="handleSignInSuccess" />
|
|
44
|
+
<StrandsSignUp @success="handleSignUpSuccess" />
|
|
17
45
|
</div>
|
|
18
46
|
</template>
|
|
19
47
|
|
|
20
48
|
<script setup lang="ts">
|
|
21
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
StrandsAuth,
|
|
51
|
+
StrandsSignIn,
|
|
52
|
+
StrandsSignUp,
|
|
53
|
+
useStrandsAuth
|
|
54
|
+
} from "@strands.gg/accui"
|
|
55
|
+
|
|
56
|
+
// Access auth state globally
|
|
57
|
+
const { user, isAuthenticated, signOut } = useStrandsAuth()
|
|
58
|
+
|
|
59
|
+
const handleSuccess = (userData: any) => {
|
|
60
|
+
console.log("Authentication successful:", userData)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const handleError = (error: string) => {
|
|
64
|
+
console.error("Authentication error:", error)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const handleSignUpSuccess = (data: { email: string }) => {
|
|
68
|
+
console.log("Magic link sent to:", data.email)
|
|
69
|
+
}
|
|
70
|
+
</script>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Nuxt 3 Module
|
|
74
|
+
|
|
75
|
+
Add the module to your `nuxt.config.ts`:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
export default defineNuxtConfig({
|
|
79
|
+
modules: ['@strands.gg/accui/nuxt'],
|
|
80
|
+
strandsAuth: {
|
|
81
|
+
apiBaseUrl: 'https://your-api.com',
|
|
82
|
+
// Other configuration options
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 🧩 Components
|
|
88
|
+
|
|
89
|
+
### Authentication Components
|
|
90
|
+
|
|
91
|
+
| Component | Description | Use Case |
|
|
92
|
+
|-----------|-------------|----------|
|
|
93
|
+
| `StrandsAuth` | Combined auth with tabs | All-in-one solution |
|
|
94
|
+
| `StrandsSignIn` | Email + password sign in | Traditional login |
|
|
95
|
+
| `StrandsSignUp` | Magic link signup | Passwordless registration |
|
|
96
|
+
| `StrandsPasswordReset` | Password reset form | Recovery flow |
|
|
97
|
+
| `StrandsUserProfile` | Profile management | User settings |
|
|
98
|
+
| `StrandsMFASetup` | Multi-factor auth setup | Security enhancement |
|
|
99
|
+
|
|
100
|
+
### Utility Components
|
|
101
|
+
|
|
102
|
+
| Component | Description |
|
|
103
|
+
|-----------|-------------|
|
|
104
|
+
| `SignedIn` | Conditional rendering for authenticated users |
|
|
105
|
+
| `SignedOut` | Conditional rendering for unauthenticated users |
|
|
106
|
+
| `StrandsConfigProvider` | Scoped configuration provider |
|
|
107
|
+
| `StrandsLogo` | Strands branding logo |
|
|
108
|
+
| `StrandsSecuredFooter` | "Secured by Strands" footer |
|
|
109
|
+
|
|
110
|
+
### UI Components
|
|
111
|
+
|
|
112
|
+
| Component | Description | Props |
|
|
113
|
+
|-----------|-------------|-------|
|
|
114
|
+
| `UiButton` | Styled button | `variant`, `size`, `loading`, `disabled` |
|
|
115
|
+
| `UiInput` | Form input field | `type`, `label`, `error`, `placeholder` |
|
|
116
|
+
| `UiCard` | Container card | `variant`, `shadow`, `padding` |
|
|
117
|
+
| `UiTabs` | Tab navigation | `tabs`, `modelValue` |
|
|
118
|
+
| `UiAlert` | Status messages | `variant`, `message` |
|
|
119
|
+
| `UiLink` | Styled link | `variant`, `size` |
|
|
120
|
+
|
|
121
|
+
## 🔧 Composables
|
|
122
|
+
|
|
123
|
+
### `useStrandsAuth()`
|
|
124
|
+
|
|
125
|
+
Global authentication state management:
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const {
|
|
129
|
+
user, // Current user object
|
|
130
|
+
isAuthenticated, // Boolean auth status
|
|
131
|
+
isLoading, // Loading state
|
|
132
|
+
signOut, // Sign out function
|
|
133
|
+
refreshUser // Refresh user data
|
|
134
|
+
} = useStrandsAuth()
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### `useStrandsConfig()`
|
|
138
|
+
|
|
139
|
+
Configuration management:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const {
|
|
143
|
+
config, // Current configuration
|
|
144
|
+
getUrl // Helper to build API URLs
|
|
145
|
+
} = useStrandsConfig()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### `useOAuthProviders()`
|
|
149
|
+
|
|
150
|
+
OAuth provider management:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const {
|
|
154
|
+
enabledProviders, // Available OAuth providers
|
|
155
|
+
loading, // Loading state
|
|
156
|
+
error, // Error state
|
|
157
|
+
fetchProviders, // Fetch providers from API
|
|
158
|
+
redirectToProvider // Initiate OAuth flow
|
|
159
|
+
} = useOAuthProviders()
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## 🎨 Magic Link Flow
|
|
163
|
+
|
|
164
|
+
The signup component uses a modern magic link approach:
|
|
165
|
+
|
|
166
|
+
```vue
|
|
167
|
+
<template>
|
|
168
|
+
<!-- User enters email only -->
|
|
169
|
+
<StrandsSignUp @success="handleMagicLinkSent" />
|
|
170
|
+
</template>
|
|
171
|
+
|
|
172
|
+
<script setup lang="ts">
|
|
173
|
+
// User receives magic link via email
|
|
174
|
+
// Clicking link completes registration
|
|
175
|
+
const handleMagicLinkSent = (data: { email: string }) => {
|
|
176
|
+
// Show success message
|
|
177
|
+
console.log(`Magic link sent to ${data.email}`)
|
|
178
|
+
}
|
|
179
|
+
</script>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 🔐 Configuration
|
|
183
|
+
|
|
184
|
+
### Global Configuration
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { setStrandsConfig } from '@strands.gg/accui'
|
|
22
188
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
189
|
+
setStrandsConfig({
|
|
190
|
+
apiBaseUrl: 'https://your-api.com',
|
|
191
|
+
clientId: 'your-client-id',
|
|
192
|
+
// Additional options
|
|
193
|
+
})
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Scoped Configuration
|
|
197
|
+
|
|
198
|
+
```vue
|
|
199
|
+
<template>
|
|
200
|
+
<StrandsConfigProvider :config="scopedConfig">
|
|
201
|
+
<StrandsAuth />
|
|
202
|
+
</StrandsConfigProvider>
|
|
203
|
+
</template>
|
|
204
|
+
|
|
205
|
+
<script setup lang="ts">
|
|
206
|
+
const scopedConfig = {
|
|
207
|
+
apiBaseUrl: 'https://different-api.com'
|
|
208
|
+
}
|
|
26
209
|
</script>
|
|
27
210
|
```
|
|
28
211
|
|
|
29
|
-
##
|
|
212
|
+
## 🎯 OAuth Integration
|
|
213
|
+
|
|
214
|
+
OAuth providers are dynamically loaded from your API endpoint:
|
|
215
|
+
|
|
216
|
+
```javascript
|
|
217
|
+
// GET /api/v1/oauth/providers
|
|
218
|
+
{
|
|
219
|
+
"providers": [
|
|
220
|
+
{
|
|
221
|
+
"id": "google",
|
|
222
|
+
"name": "Google",
|
|
223
|
+
"displayName": "Google",
|
|
224
|
+
"iconUrl": "https://example.com/google-icon.svg",
|
|
225
|
+
"enabled": true
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## 📱 Responsive Design
|
|
232
|
+
|
|
233
|
+
All components are mobile-first and responsive:
|
|
30
234
|
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
235
|
+
- **Mobile**: Optimized touch targets and layouts
|
|
236
|
+
- **Tablet**: Adaptive spacing and sizing
|
|
237
|
+
- **Desktop**: Full-featured experience
|
|
238
|
+
|
|
239
|
+
## 🎨 Theming
|
|
240
|
+
|
|
241
|
+
Components use CSS custom properties for theming:
|
|
242
|
+
|
|
243
|
+
```css
|
|
244
|
+
:root {
|
|
245
|
+
--strands-primary: #your-brand-color;
|
|
246
|
+
--strands-secondary: #your-secondary-color;
|
|
247
|
+
/* Additional theme variables */
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## 📋 TypeScript Support
|
|
252
|
+
|
|
253
|
+
Full TypeScript definitions included:
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
import type {
|
|
257
|
+
StrandsUser,
|
|
258
|
+
StrandsSession,
|
|
259
|
+
StrandsAuthConfig,
|
|
260
|
+
ButtonVariant,
|
|
261
|
+
InputType
|
|
262
|
+
} from '@strands.gg/accui'
|
|
263
|
+
```
|
|
37
264
|
|
|
38
|
-
##
|
|
265
|
+
## 🔧 Requirements
|
|
39
266
|
|
|
40
|
-
-
|
|
267
|
+
- **Vue**: 3.5+
|
|
268
|
+
- **Node**: 16+
|
|
269
|
+
- **TypeScript**: 5+ (optional but recommended)
|
|
41
270
|
|
|
42
|
-
##
|
|
271
|
+
## 📄 License
|
|
43
272
|
|
|
44
|
-
|
|
273
|
+
MIT © Strands Services Limited
|
|
45
274
|
|
|
46
|
-
|
|
275
|
+
---
|
|
47
276
|
|
|
48
|
-
|
|
277
|
+
**Need help?** Check out our [documentation](https://docs.strands.gg) or open an issue on GitHub.
|
|
49
278
|
|