@mdxui/auth 1.1.1 → 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.
- package/README.md +223 -0
- package/dist/{auth-Ba2f778e.d.ts → auth-maeYSYU_.d.ts} +4 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/{index-DGthQxCM.d.ts → index-BOMpMKyG.d.ts} +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +794 -4
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js +16 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.js +1 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/shell/index.d.ts +675 -0
- package/dist/shell/index.js +1025 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/widgets/index.d.ts +1 -1
- package/package.json +21 -14
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
|
|
@@ -46,7 +46,7 @@ interface AuthGateProps {
|
|
|
46
46
|
/** Component to show when not authenticated (landing page) */
|
|
47
47
|
landingComponent?: ReactNode;
|
|
48
48
|
/** What to do when unauthenticated */
|
|
49
|
-
onUnauthenticated?: 'landing' | 'redirect' | 'allow';
|
|
49
|
+
onUnauthenticated?: 'landing' | 'redirect' | 'allow' | 'signIn';
|
|
50
50
|
/** URL to redirect to when unauthenticated (if onUnauthenticated is 'redirect') */
|
|
51
51
|
redirectUrl?: string;
|
|
52
52
|
}
|
|
@@ -54,6 +54,9 @@ interface AuthGateProps {
|
|
|
54
54
|
* Props for WidgetsProvider
|
|
55
55
|
*
|
|
56
56
|
* Extends the schema type with React-specific fields.
|
|
57
|
+
*
|
|
58
|
+
* Note: Widgets always use api.workos.com - WorkOS custom domains do NOT
|
|
59
|
+
* support widget endpoints. Only authentication uses custom domains.
|
|
57
60
|
*/
|
|
58
61
|
interface WidgetsProviderProps {
|
|
59
62
|
/** Children to render */
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { useAuth } from '@workos-inc/authkit-react';
|
|
2
|
-
import { U as UseWidgetTokenOptions, b as UseWidgetTokenResult } from '../auth-
|
|
2
|
+
import { U as UseWidgetTokenOptions, b as UseWidgetTokenResult } from '../auth-maeYSYU_.js';
|
|
3
3
|
import { V as VaultItem, a as VaultField } from '../types-8tixck1H.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { I as IdentityProviderProps, A as AuthGateProps, W as WidgetsProviderProps } from './auth-
|
|
2
|
+
import { I as IdentityProviderProps, A as AuthGateProps, W as WidgetsProviderProps } from './auth-maeYSYU_.js';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import { V as VaultItem, a as VaultField } from './types-8tixck1H.js';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
export { A as AuthGate, I as IdentityProvider, a as IdentityProviderMinimal, d as VaultClient, e as VaultContextState, V as VaultProvider, f as VaultProviderProps, W as WidgetsProvider, u as useThemeDetection, b as useVaultContext, c as useVaultContextOptional } from './index-
|
|
1
|
+
export { A as AuthGate, I as IdentityProvider, a as IdentityProviderMinimal, d as VaultClient, e as VaultContextState, V as VaultProvider, f as VaultProviderProps, W as WidgetsProvider, u as useThemeDetection, b as useVaultContext, c as useVaultContextOptional } from './index-BOMpMKyG.js';
|
|
2
2
|
export { ApiKeys, OrganizationSwitcher, Pipes, UserProfile, UserSecurity, UserSessions, UsersManagement } from './widgets/index.js';
|
|
3
3
|
export { Secret, SecretForm, SecretsManager, SecretsManagerProps, VaultDeleteDialog, VaultEmptyState, VaultInputModal, VaultItemCard, VaultList } from './vault/index.js';
|
|
4
4
|
export { f as VaultDeleteDialogProps, g as VaultEmptyStateProps, a as VaultField, e as VaultInputModalProps, b as VaultIntegration, V as VaultItem, d as VaultItemCardProps, c as VaultListProps } from './types-8tixck1H.js';
|
|
5
5
|
export { SignInButton, SignOutButton, TeamSwitcher, UserMenu } from './components/index.js';
|
|
6
6
|
export { useAuth } from '@workos-inc/authkit-react';
|
|
7
7
|
export { UseVaultResult, useVault, useVaultOptional, useWidgetToken } from './hooks/index.js';
|
|
8
|
-
export { A as AuthGateProps, a as AuthToken, B as BaseWidgetProps, I as IdentityProviderProps, O as OrganizationWidgetProps, U as UseWidgetTokenOptions, b as UseWidgetTokenResult, W as WidgetsProviderProps } from './auth-
|
|
8
|
+
export { A as AuthGateProps, a as AuthToken, B as BaseWidgetProps, I as IdentityProviderProps, O as OrganizationWidgetProps, U as UseWidgetTokenOptions, b as UseWidgetTokenResult, W as WidgetsProviderProps } from './auth-maeYSYU_.js';
|
|
9
9
|
export { a as AuthOrganization, e as AuthOrganizationSchema, b as AuthSession, d as AuthSessionSchema, A as AuthUser, c as AuthUserSchema, I as Impersonator, f as ImpersonatorSchema } from './auth-organization-CN1WpGnL.js';
|
|
10
10
|
export { AppearanceSchema, AuthGatePropsSchema, AuthTokenSchema, BaseWidgetPropsSchema, IdentityProviderPropsSchema, OrganizationWidgetPropsSchema, RadiusSchema, ScalingSchema, UnauthenticatedActionSchema, UseWidgetTokenOptionsSchema, UseWidgetTokenResultSchema, WidgetsProviderPropsSchema } from './schemas/index.js';
|
|
11
|
+
export { ApiKeysPage, AuthApp, AuthAppConfig, AuthAppProps, AuthAppProvider, AuthAppRoute, AuthAppWithChildren, AuthShell, AuthShellBranding, AuthShellConfigProvider, AuthShellIdentity, AuthShellNav, AuthShellNavProps, AuthShellProps, BreadcrumbItemConfig, BreadcrumbLinkProps, Breadcrumbs, BreadcrumbsProps, IntegrationsPage, ProfilePage, SecurityPage, SessionsPage, SidebarOrgSwitcher, TeamPage, WidgetErrorBoundary, accountRoutes, adminRoutes, defaultGroups, defaultRoutes, developerRoutes, getEnvConfig, integrationRoutes, mergeWithEnvConfig, useAuthShellBranding, useAuthShellConfig, useAuthShellFullPath, useAuthShellRoutes, useAuthShellRoutesByGroup } from './shell/index.js';
|
|
12
|
+
export { AuthShellConfig, ProtectedRoute, RouteGroup, ThemeMode } from 'mdxui';
|
|
11
13
|
import 'react/jsx-runtime';
|
|
12
14
|
import 'react';
|
|
13
15
|
import 'zod/v4/core';
|
|
14
16
|
import 'zod';
|
|
17
|
+
import 'lucide-react';
|