@mdxui/auth 1.4.0 → 1.4.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 (2) hide show
  1. package/README.md +223 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,6 +10,83 @@ pnpm add @mdxui/auth
10
10
 
11
11
  ## Quick Start
12
12
 
13
+ ### Zero-Config AuthApp (Recommended)
14
+
15
+ The easiest way to get started - just set environment variables:
16
+
17
+ ```bash
18
+ # .env
19
+ VITE_WORKOS_CLIENT_ID=client_xxx
20
+ VITE_APP_NAME=My App
21
+ ```
22
+
23
+ ```tsx
24
+ import { AuthApp } from '@mdxui/auth/shell'
25
+
26
+ function App() {
27
+ return <AuthApp />
28
+ }
29
+ ```
30
+
31
+ That's it! You get a complete authenticated app with:
32
+ - Sidebar navigation with org switcher
33
+ - Profile, Security, Sessions, API Keys, Team, and Integrations pages
34
+ - Error boundaries with friendly messages
35
+ - Theme support
36
+
37
+ ### With Explicit Config
38
+
39
+ ```tsx
40
+ import { AuthApp } from '@mdxui/auth/shell'
41
+
42
+ function App() {
43
+ return (
44
+ <AuthApp
45
+ config={{
46
+ branding: { name: 'My App' },
47
+ identity: {
48
+ clientId: 'client_xxx',
49
+ redirectUri: 'https://myapp.com/callback',
50
+ },
51
+ }}
52
+ />
53
+ )
54
+ }
55
+ ```
56
+
57
+ ### Custom Routes
58
+
59
+ ```tsx
60
+ import { AuthApp, accountRoutes, developerRoutes } from '@mdxui/auth/shell'
61
+ import { FileText } from 'lucide-react'
62
+ import { DocsPage } from './pages/DocsPage'
63
+
64
+ function App() {
65
+ return (
66
+ <AuthApp
67
+ config={{
68
+ branding: { name: 'My App' },
69
+ identity: { clientId: 'client_xxx' },
70
+ routes: [
71
+ ...accountRoutes, // Profile, Security, Sessions
72
+ ...developerRoutes, // API Keys
73
+ {
74
+ key: 'docs',
75
+ path: '/docs',
76
+ label: 'Documentation',
77
+ icon: FileText,
78
+ component: DocsPage,
79
+ group: 'developer',
80
+ },
81
+ ],
82
+ }}
83
+ />
84
+ )
85
+ }
86
+ ```
87
+
88
+ ### Traditional Setup (Without Shell)
89
+
13
90
  ```tsx
14
91
  import {
15
92
  IdentityProvider,
@@ -42,6 +119,11 @@ function Dashboard() {
42
119
 
43
120
  ## Features
44
121
 
122
+ - **Zero-Config AuthApp** - Complete authenticated app shell with environment variable support
123
+ - **Pre-built Pages** - Profile, Security, Sessions, API Keys, Team, and Integrations pages
124
+ - **Route Presets** - Composable route groups (`accountRoutes`, `developerRoutes`, `adminRoutes`)
125
+ - **SidebarOrgSwitcher** - Auto-wired org switcher with branding fallback
126
+ - **WidgetErrorBoundary** - Friendly, contextual error messages for widget failures
45
127
  - **Authentication Providers** - `IdentityProvider` and `AuthGate` for managing auth state
46
128
  - **WorkOS Widgets** - Pre-built components for user management (profile, security, API keys)
47
129
  - **Vault Components** - UI for managing encrypted secrets with `VaultProvider`
@@ -111,6 +193,56 @@ import type {
111
193
  } from '@mdxui/auth'
112
194
  ```
113
195
 
196
+ ### Shell Exports (`@mdxui/auth/shell`)
197
+
198
+ Complete authenticated app shell with routing:
199
+
200
+ ```tsx
201
+ import {
202
+ // App Components
203
+ AuthApp, // Zero-config app with built-in routing
204
+ AuthAppWithChildren, // App shell without routing (bring your own)
205
+ AuthAppProvider, // Providers only (for custom layouts)
206
+ AuthShell, // Shell layout component
207
+ AuthShellNav, // Navigation component
208
+
209
+ // Shell Components
210
+ SidebarOrgSwitcher, // Org switcher with branding fallback
211
+ WidgetErrorBoundary, // Error boundary with friendly messages
212
+ Breadcrumbs, // Breadcrumb navigation
213
+
214
+ // Pre-built Pages
215
+ ProfilePage, // User profile management
216
+ SecurityPage, // Password and MFA settings
217
+ SessionsPage, // Active sessions management
218
+ ApiKeysPage, // API key management
219
+ TeamPage, // Team member management (requires org)
220
+ IntegrationsPage, // Third-party integrations
221
+
222
+ // Route Presets
223
+ defaultRoutes, // All default routes
224
+ defaultGroups, // Default route groups
225
+ accountRoutes, // Profile, Security, Sessions
226
+ developerRoutes, // API Keys
227
+ adminRoutes, // Team management
228
+ integrationRoutes, // Integrations
229
+
230
+ // Config Hooks
231
+ useAuthShellConfig,
232
+ useAuthShellRoutes,
233
+ useAuthShellBranding,
234
+ } from '@mdxui/auth/shell'
235
+
236
+ // Types
237
+ import type {
238
+ AuthAppConfig,
239
+ AuthAppProps,
240
+ AuthAppRoute,
241
+ AuthShellBranding,
242
+ AuthShellIdentity,
243
+ } from '@mdxui/auth/shell'
244
+ ```
245
+
114
246
  ### Subpath Exports
115
247
 
116
248
  For more granular imports:
@@ -194,6 +326,97 @@ const sessionResult = AuthSessionSchema.safeParse({
194
326
  })
195
327
  ```
196
328
 
329
+ ## AuthApp (Shell)
330
+
331
+ ### Zero-Config with Environment Variables
332
+
333
+ AuthApp can read configuration from environment variables, perfect for Cloudflare Workers Static Assets:
334
+
335
+ ```bash
336
+ # .env
337
+ VITE_WORKOS_CLIENT_ID=client_xxx # Required
338
+ VITE_WORKOS_REDIRECT_URI=https://... # Optional
339
+ VITE_WORKOS_API_HOSTNAME=auth.apis.do # Optional
340
+ VITE_WORKOS_DEV_MODE=true # Optional
341
+ VITE_APP_NAME=My App # Optional (defaults to "App")
342
+ VITE_APP_TAGLINE=Best app ever # Optional
343
+ ```
344
+
345
+ ```tsx
346
+ import { AuthApp } from '@mdxui/auth/shell'
347
+
348
+ // That's it - reads config from env vars
349
+ function App() {
350
+ return <AuthApp />
351
+ }
352
+ ```
353
+
354
+ ### Route Presets
355
+
356
+ Compose routes from presets:
357
+
358
+ ```tsx
359
+ import {
360
+ AuthApp,
361
+ accountRoutes, // Profile, Security, Sessions
362
+ developerRoutes, // API Keys
363
+ adminRoutes, // Team
364
+ integrationRoutes, // Integrations
365
+ defaultGroups,
366
+ } from '@mdxui/auth/shell'
367
+
368
+ function App() {
369
+ return (
370
+ <AuthApp
371
+ config={{
372
+ branding: { name: 'My App' },
373
+ identity: { clientId: 'client_xxx' },
374
+ groups: defaultGroups,
375
+ routes: [
376
+ ...accountRoutes,
377
+ ...developerRoutes,
378
+ // Exclude adminRoutes if you don't need team management
379
+ ],
380
+ }}
381
+ />
382
+ )
383
+ }
384
+ ```
385
+
386
+ ### WidgetErrorBoundary
387
+
388
+ Wraps WorkOS widgets with friendly error handling:
389
+
390
+ ```tsx
391
+ import { WidgetErrorBoundary } from '@mdxui/auth/shell'
392
+ import { UserProfile } from '@mdxui/auth/widgets'
393
+
394
+ function ProfilePage() {
395
+ return (
396
+ <WidgetErrorBoundary widgetName="profile">
397
+ <UserProfile authToken={getAccessToken} />
398
+ </WidgetErrorBoundary>
399
+ )
400
+ }
401
+ // On error: "Your profile is camera shy right now..."
402
+ // Unknown widgets: "Something went wrong loading your API Keys..."
403
+ ```
404
+
405
+ ### Custom Sidebar Header
406
+
407
+ ```tsx
408
+ import { AuthApp, SidebarOrgSwitcher } from '@mdxui/auth/shell'
409
+
410
+ // Default: SidebarOrgSwitcher is included automatically
411
+ <AuthApp config={config} />
412
+
413
+ // Custom header content
414
+ <AuthApp
415
+ config={config}
416
+ sidebarHeaderContent={<MyCustomHeader />}
417
+ />
418
+ ```
419
+
197
420
  ## Components
198
421
 
199
422
  ### IdentityProvider
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdxui/auth",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Authentication components and WorkOS AuthKit wrappers for mdxui",
5
5
  "type": "module",
6
6
  "sideEffects": false,