@mdxui/auth 1.1.0 → 1.4.0
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 +128 -1
- package/dist/{auth-Ba2f778e.d.ts → auth-maeYSYU_.d.ts} +4 -1
- package/dist/hooks/index.d.ts +92 -2
- package/dist/hooks/index.js +84 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-Bl4BwORF.d.ts → index-BOMpMKyG.d.ts} +105 -2
- package/dist/index.d.ts +8 -3
- package/dist/index.js +1651 -36
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +3 -2
- package/dist/providers/index.js +85 -2
- 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/types-8tixck1H.d.ts +123 -0
- package/dist/vault/index.d.ts +192 -0
- package/dist/vault/index.js +692 -0
- package/dist/vault/index.js.map +1 -0
- package/dist/widgets/index.d.ts +1 -1
- package/package.json +27 -13
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, ComponentType, Component } from 'react';
|
|
3
|
+
import { LucideIcon } from 'lucide-react';
|
|
4
|
+
import { ThemeMode, AuthShellConfig, RouteGroup, ProtectedRoute } from 'mdxui';
|
|
5
|
+
export { AuthShellConfig, ProtectedRoute, RouteGroup, ThemeMode } from 'mdxui';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Shell Type Definitions
|
|
10
|
+
*
|
|
11
|
+
* Extended types for the auth shell that build on mdxui base types.
|
|
12
|
+
* These types include React-specific fields (ReactNode, ComponentType)
|
|
13
|
+
* that cannot be represented in Zod schemas.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Identity configuration for WorkOS AuthKit
|
|
18
|
+
*
|
|
19
|
+
* Configures the authentication provider including client ID,
|
|
20
|
+
* dev mode settings, and unauthenticated behavior.
|
|
21
|
+
*/
|
|
22
|
+
interface AuthShellIdentity {
|
|
23
|
+
/** WorkOS client ID */
|
|
24
|
+
clientId: string;
|
|
25
|
+
/** Optional API hostname override */
|
|
26
|
+
apiHostname?: string;
|
|
27
|
+
/** Enable dev mode for local development */
|
|
28
|
+
devMode?: boolean;
|
|
29
|
+
/** Redirect URI after authentication */
|
|
30
|
+
redirectUri?: string;
|
|
31
|
+
/** Whether authentication is required (default: true) */
|
|
32
|
+
required?: boolean;
|
|
33
|
+
/** Behavior when unauthenticated */
|
|
34
|
+
onUnauthenticated?: 'landing' | 'redirect' | 'allow' | 'signIn';
|
|
35
|
+
/** Custom landing page component */
|
|
36
|
+
landingComponent?: ReactNode;
|
|
37
|
+
/** Custom loading component */
|
|
38
|
+
loadingComponent?: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Branding configuration
|
|
42
|
+
*
|
|
43
|
+
* Defines the app's branding including name, logo, and tagline.
|
|
44
|
+
* Logo accepts a React element for flexibility (SVG, img, etc).
|
|
45
|
+
*/
|
|
46
|
+
interface AuthShellBranding {
|
|
47
|
+
/** Application name */
|
|
48
|
+
name: string;
|
|
49
|
+
/** Logo element (React component or element) */
|
|
50
|
+
logo?: ReactNode;
|
|
51
|
+
/** Collapsed logo for icon-only sidebar state */
|
|
52
|
+
logoCollapsed?: ReactNode;
|
|
53
|
+
/** Tagline or description */
|
|
54
|
+
tagline?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Route with React component
|
|
58
|
+
*
|
|
59
|
+
* Extends the base ProtectedRoute from mdxui with React-specific
|
|
60
|
+
* fields that can't be represented in Zod schemas.
|
|
61
|
+
*/
|
|
62
|
+
interface AuthAppRoute extends Omit<ProtectedRoute, 'icon'> {
|
|
63
|
+
/** React component to render for this route */
|
|
64
|
+
component: ComponentType;
|
|
65
|
+
/** Lucide icon component */
|
|
66
|
+
icon?: LucideIcon;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Full application configuration
|
|
70
|
+
*
|
|
71
|
+
* Combines all configuration needed to set up an authenticated
|
|
72
|
+
* application shell with routing, branding, and identity.
|
|
73
|
+
*/
|
|
74
|
+
interface AuthAppConfig {
|
|
75
|
+
/** Base path for all routes (default: '') */
|
|
76
|
+
basePath?: string;
|
|
77
|
+
/** Branding configuration */
|
|
78
|
+
branding: AuthShellBranding;
|
|
79
|
+
/** Theme configuration */
|
|
80
|
+
theme?: {
|
|
81
|
+
/** Theme mode (light, dark, system) */
|
|
82
|
+
mode?: ThemeMode;
|
|
83
|
+
};
|
|
84
|
+
/** Identity/auth configuration */
|
|
85
|
+
identity: AuthShellIdentity;
|
|
86
|
+
/** Auth shell configuration (from mdxui) */
|
|
87
|
+
auth?: AuthShellConfig;
|
|
88
|
+
/** Route groups for navigation organization */
|
|
89
|
+
groups?: RouteGroup[];
|
|
90
|
+
/** Application routes (defaults to standard account/developer/admin routes) */
|
|
91
|
+
routes?: AuthAppRoute[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Props for AuthShell component
|
|
95
|
+
*/
|
|
96
|
+
interface AuthShellProps {
|
|
97
|
+
/** Shell content */
|
|
98
|
+
children: ReactNode;
|
|
99
|
+
/** Custom content for sidebar header */
|
|
100
|
+
sidebarHeaderContent?: ReactNode;
|
|
101
|
+
/** Custom content for main header */
|
|
102
|
+
headerContent?: ReactNode;
|
|
103
|
+
/** Breadcrumb items */
|
|
104
|
+
breadcrumbs?: Array<{
|
|
105
|
+
label: string;
|
|
106
|
+
href?: string;
|
|
107
|
+
}>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Props for AuthShellNav component
|
|
111
|
+
*/
|
|
112
|
+
interface AuthShellNavProps {
|
|
113
|
+
/** Custom content for sidebar header */
|
|
114
|
+
headerContent?: ReactNode;
|
|
115
|
+
/** Custom user menu (uses default if not provided) */
|
|
116
|
+
userMenu?: ReactNode;
|
|
117
|
+
/** Additional CSS class */
|
|
118
|
+
className?: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Props for AuthApp component
|
|
122
|
+
*
|
|
123
|
+
* Config is optional when environment variables are set:
|
|
124
|
+
* - VITE_WORKOS_CLIENT_ID (required)
|
|
125
|
+
* - VITE_WORKOS_REDIRECT_URI
|
|
126
|
+
* - VITE_WORKOS_API_HOSTNAME
|
|
127
|
+
* - VITE_WORKOS_DEV_MODE
|
|
128
|
+
* - VITE_APP_NAME
|
|
129
|
+
* - VITE_APP_TAGLINE
|
|
130
|
+
*/
|
|
131
|
+
interface AuthAppProps {
|
|
132
|
+
/**
|
|
133
|
+
* Application configuration
|
|
134
|
+
*
|
|
135
|
+
* Optional when VITE_WORKOS_CLIENT_ID environment variable is set.
|
|
136
|
+
* Explicit config values take precedence over environment variables.
|
|
137
|
+
*/
|
|
138
|
+
config?: Partial<AuthAppConfig>;
|
|
139
|
+
/** Custom content for main header */
|
|
140
|
+
headerContent?: ReactNode;
|
|
141
|
+
/** Custom content for sidebar header */
|
|
142
|
+
sidebarHeaderContent?: ReactNode;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Context value shape
|
|
147
|
+
*/
|
|
148
|
+
interface AuthShellConfigContextValue {
|
|
149
|
+
/** Full configuration */
|
|
150
|
+
config: AuthAppConfig;
|
|
151
|
+
/** All enabled routes */
|
|
152
|
+
routes: AuthAppRoute[];
|
|
153
|
+
/** Routes organized by group */
|
|
154
|
+
routesByGroup: Map<string, AuthAppRoute[]>;
|
|
155
|
+
/** Route groups sorted by order */
|
|
156
|
+
groups: RouteGroup[];
|
|
157
|
+
/** Branding configuration */
|
|
158
|
+
branding: AuthShellBranding;
|
|
159
|
+
/** Base path for routes */
|
|
160
|
+
basePath: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Props for AuthShellConfigProvider
|
|
164
|
+
*/
|
|
165
|
+
interface AuthShellConfigProviderProps {
|
|
166
|
+
/** Shell configuration */
|
|
167
|
+
config: AuthAppConfig;
|
|
168
|
+
/** Children to render */
|
|
169
|
+
children: ReactNode;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Provides shell configuration context to children
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```tsx
|
|
176
|
+
* <AuthShellConfigProvider config={config}>
|
|
177
|
+
* <AuthShell>
|
|
178
|
+
* <Outlet />
|
|
179
|
+
* </AuthShell>
|
|
180
|
+
* </AuthShellConfigProvider>
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
declare function AuthShellConfigProvider({ config, children }: AuthShellConfigProviderProps): react_jsx_runtime.JSX.Element;
|
|
184
|
+
/**
|
|
185
|
+
* Access the full shell configuration context
|
|
186
|
+
*
|
|
187
|
+
* @throws Error if used outside AuthShellConfigProvider
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```tsx
|
|
191
|
+
* function MyComponent() {
|
|
192
|
+
* const { config, routes, branding } = useAuthShellConfig()
|
|
193
|
+
* return <div>{branding.name}</div>
|
|
194
|
+
* }
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
declare function useAuthShellConfig(): AuthShellConfigContextValue;
|
|
198
|
+
/**
|
|
199
|
+
* Access enabled routes array
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```tsx
|
|
203
|
+
* function RouteList() {
|
|
204
|
+
* const routes = useAuthShellRoutes()
|
|
205
|
+
* return routes.map(r => <Link key={r.key} to={r.path}>{r.label}</Link>)
|
|
206
|
+
* }
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
declare function useAuthShellRoutes(): AuthAppRoute[];
|
|
210
|
+
/**
|
|
211
|
+
* Access routes organized by group
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```tsx
|
|
215
|
+
* function GroupedNav() {
|
|
216
|
+
* const { routesByGroup, groups } = useAuthShellRoutesByGroup()
|
|
217
|
+
* return groups.map(g => (
|
|
218
|
+
* <div key={g.id}>
|
|
219
|
+
* {g.label && <h3>{g.label}</h3>}
|
|
220
|
+
* {routesByGroup.get(g.id)?.map(r => <Link to={r.path}>{r.label}</Link>)}
|
|
221
|
+
* </div>
|
|
222
|
+
* ))
|
|
223
|
+
* }
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
declare function useAuthShellRoutesByGroup(): {
|
|
227
|
+
routesByGroup: Map<string, AuthAppRoute[]>;
|
|
228
|
+
groups: RouteGroup[];
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Access branding configuration
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```tsx
|
|
235
|
+
* function Header() {
|
|
236
|
+
* const branding = useAuthShellBranding()
|
|
237
|
+
* return (
|
|
238
|
+
* <header>
|
|
239
|
+
* {branding.logo}
|
|
240
|
+
* <span>{branding.name}</span>
|
|
241
|
+
* </header>
|
|
242
|
+
* )
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
declare function useAuthShellBranding(): AuthShellBranding;
|
|
247
|
+
/**
|
|
248
|
+
* Get full path with base path prefix
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```tsx
|
|
252
|
+
* function NavLink({ route }: { route: AuthAppRoute }) {
|
|
253
|
+
* const getFullPath = useAuthShellFullPath()
|
|
254
|
+
* return <Link to={getFullPath(route.path)}>{route.label}</Link>
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
declare function useAuthShellFullPath(): (path: string) => string;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* AuthShell - Main application shell layout
|
|
262
|
+
*
|
|
263
|
+
* Wraps content in authentication gate and provides
|
|
264
|
+
* sidebar navigation with header and main content area.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```tsx
|
|
268
|
+
* <AuthShellConfigProvider config={config}>
|
|
269
|
+
* <IdentityProvider clientId={config.identity.clientId}>
|
|
270
|
+
* <AuthShell breadcrumbs={[{ label: 'Dashboard' }]}>
|
|
271
|
+
* <Outlet />
|
|
272
|
+
* </AuthShell>
|
|
273
|
+
* </IdentityProvider>
|
|
274
|
+
* </AuthShellConfigProvider>
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
declare function AuthShell({ children, sidebarHeaderContent, headerContent, breadcrumbs, }: AuthShellProps): react_jsx_runtime.JSX.Element;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* AuthShellNav - Sidebar navigation component
|
|
281
|
+
*
|
|
282
|
+
* Renders navigation routes organized by group with branding
|
|
283
|
+
* header and user menu footer.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```tsx
|
|
287
|
+
* <AuthShellNav
|
|
288
|
+
* headerContent={<TeamSwitcher />}
|
|
289
|
+
* userMenu={<CustomUserMenu />}
|
|
290
|
+
* />
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
declare function AuthShellNav({ headerContent, userMenu, className }: AuthShellNavProps): react_jsx_runtime.JSX.Element;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Props for AuthAppProvider (providers only, no shell or routing)
|
|
297
|
+
*/
|
|
298
|
+
interface AuthAppProviderProps {
|
|
299
|
+
/**
|
|
300
|
+
* Application configuration
|
|
301
|
+
*
|
|
302
|
+
* Optional when VITE_WORKOS_CLIENT_ID environment variable is set.
|
|
303
|
+
*/
|
|
304
|
+
config?: Partial<AuthAppConfig>;
|
|
305
|
+
/** Children to render */
|
|
306
|
+
children: ReactNode;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* AuthAppProvider - Providers only wrapper
|
|
310
|
+
*
|
|
311
|
+
* Use this when you need to customize the shell layout or
|
|
312
|
+
* integrate with an existing routing setup.
|
|
313
|
+
*
|
|
314
|
+
* Provider hierarchy:
|
|
315
|
+
* - ThemeProvider (next-themes)
|
|
316
|
+
* - AuthShellConfigProvider
|
|
317
|
+
* - IdentityProvider (WorkOS AuthKit)
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```tsx
|
|
321
|
+
* <AuthAppProvider config={config}>
|
|
322
|
+
* <RouterProvider router={router}>
|
|
323
|
+
* <AuthShell>
|
|
324
|
+
* <Outlet />
|
|
325
|
+
* </AuthShell>
|
|
326
|
+
* </RouterProvider>
|
|
327
|
+
* </AuthAppProvider>
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```tsx
|
|
332
|
+
* // Zero-config with environment variables
|
|
333
|
+
* <AuthAppProvider>
|
|
334
|
+
* <MyApp />
|
|
335
|
+
* </AuthAppProvider>
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
declare function AuthAppProvider({ config, children }: AuthAppProviderProps): react_jsx_runtime.JSX.Element;
|
|
339
|
+
/**
|
|
340
|
+
* AuthApp - Complete app with built-in routing
|
|
341
|
+
*
|
|
342
|
+
* This is the recommended way to use AuthApp. Define your routes
|
|
343
|
+
* in the config and AuthApp handles routing automatically.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```tsx
|
|
347
|
+
* // Zero-config with environment variables
|
|
348
|
+
* // Set VITE_WORKOS_CLIENT_ID, VITE_APP_NAME in .env
|
|
349
|
+
* function App() {
|
|
350
|
+
* return <AuthApp />
|
|
351
|
+
* }
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```tsx
|
|
356
|
+
* import { AuthApp, type AuthAppConfig } from '@mdxui/auth/shell'
|
|
357
|
+
* import { Home, Settings, Users } from 'lucide-react'
|
|
358
|
+
*
|
|
359
|
+
* const config: AuthAppConfig = {
|
|
360
|
+
* branding: { name: 'My App' },
|
|
361
|
+
* identity: { clientId: 'client_xxx' },
|
|
362
|
+
* routes: [
|
|
363
|
+
* { key: 'home', label: 'Home', path: '/', icon: Home, component: HomePage },
|
|
364
|
+
* { key: 'settings', label: 'Settings', path: '/settings', icon: Settings, component: SettingsPage },
|
|
365
|
+
* { key: 'users', label: 'Users', path: '/users', icon: Users, component: UsersPage },
|
|
366
|
+
* ],
|
|
367
|
+
* }
|
|
368
|
+
*
|
|
369
|
+
* function App() {
|
|
370
|
+
* return <AuthApp config={config} />
|
|
371
|
+
* }
|
|
372
|
+
* ```
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```tsx
|
|
376
|
+
* // With custom header content (sidebar defaults to SidebarOrgSwitcher)
|
|
377
|
+
* <AuthApp
|
|
378
|
+
* config={config}
|
|
379
|
+
* headerContent={<ThemeSwitcher />}
|
|
380
|
+
* />
|
|
381
|
+
* ```
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```tsx
|
|
385
|
+
* // Override sidebar header with custom content
|
|
386
|
+
* <AuthApp
|
|
387
|
+
* config={config}
|
|
388
|
+
* sidebarHeaderContent={<MyCustomSwitcher />}
|
|
389
|
+
* />
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
declare function AuthApp({ config, headerContent, sidebarHeaderContent }: AuthAppProps): react_jsx_runtime.JSX.Element;
|
|
393
|
+
/**
|
|
394
|
+
* AuthAppWithChildren - App wrapper with shell but no routing
|
|
395
|
+
*
|
|
396
|
+
* Use this when you want the shell but handle routing yourself,
|
|
397
|
+
* or when you have simple static content.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```tsx
|
|
401
|
+
* // Zero-config with environment variables
|
|
402
|
+
* <AuthAppWithChildren>
|
|
403
|
+
* <Dashboard />
|
|
404
|
+
* </AuthAppWithChildren>
|
|
405
|
+
* ```
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```tsx
|
|
409
|
+
* // With your own router
|
|
410
|
+
* <AuthAppWithChildren config={config}>
|
|
411
|
+
* <Routes>
|
|
412
|
+
* <Route path="/" element={<Home />} />
|
|
413
|
+
* <Route path="/settings" element={<Settings />} />
|
|
414
|
+
* </Routes>
|
|
415
|
+
* </AuthAppWithChildren>
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```tsx
|
|
420
|
+
* // With static content
|
|
421
|
+
* <AuthAppWithChildren config={config}>
|
|
422
|
+
* <Dashboard />
|
|
423
|
+
* </AuthAppWithChildren>
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
declare function AuthAppWithChildren({ config, headerContent, sidebarHeaderContent, children, }: AuthAppProps & {
|
|
427
|
+
children: ReactNode;
|
|
428
|
+
}): react_jsx_runtime.JSX.Element;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Props for the Link component
|
|
432
|
+
*/
|
|
433
|
+
interface BreadcrumbLinkProps {
|
|
434
|
+
href: string;
|
|
435
|
+
children: react.ReactNode;
|
|
436
|
+
className?: string;
|
|
437
|
+
onClick?: () => void;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Single breadcrumb item configuration
|
|
441
|
+
*/
|
|
442
|
+
interface BreadcrumbItemConfig {
|
|
443
|
+
/** Display label */
|
|
444
|
+
label: string;
|
|
445
|
+
/** Route path - last item should not have href */
|
|
446
|
+
href?: string;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Props for the Breadcrumbs component
|
|
450
|
+
*/
|
|
451
|
+
interface BreadcrumbsProps {
|
|
452
|
+
/** Array of breadcrumb items */
|
|
453
|
+
items: BreadcrumbItemConfig[];
|
|
454
|
+
/** Custom link component (e.g., Next.js Link, TanStack Link). Defaults to WebLink */
|
|
455
|
+
LinkComponent?: react.ComponentType<BreadcrumbLinkProps>;
|
|
456
|
+
/** Additional class names */
|
|
457
|
+
className?: string;
|
|
458
|
+
/** Maximum items to show before collapsing */
|
|
459
|
+
maxItems?: number;
|
|
460
|
+
/** Custom separator element */
|
|
461
|
+
separator?: react.ReactNode;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Breadcrumbs provides navigation context showing the user's location.
|
|
465
|
+
*
|
|
466
|
+
* Features:
|
|
467
|
+
* - Router-agnostic - works with any Link component
|
|
468
|
+
* - Defaults to @mdxui/navigation/web WebLink for TanStack Router
|
|
469
|
+
* - Automatic collapse with dropdown for long paths
|
|
470
|
+
* - Accessible breadcrumb semantics
|
|
471
|
+
* - Custom separator support
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```tsx
|
|
475
|
+
* // With default WebLink (TanStack Router)
|
|
476
|
+
* <Breadcrumbs
|
|
477
|
+
* items={[
|
|
478
|
+
* { label: 'Home', href: '/' },
|
|
479
|
+
* { label: 'Users', href: '/users' },
|
|
480
|
+
* { label: 'John Doe' },
|
|
481
|
+
* ]}
|
|
482
|
+
* />
|
|
483
|
+
*
|
|
484
|
+
* // With Next.js Link
|
|
485
|
+
* import NextLink from 'next/link'
|
|
486
|
+
*
|
|
487
|
+
* <Breadcrumbs
|
|
488
|
+
* items={breadcrumbItems}
|
|
489
|
+
* LinkComponent={NextLink}
|
|
490
|
+
* />
|
|
491
|
+
*
|
|
492
|
+
* // With custom Link wrapper
|
|
493
|
+
* <Breadcrumbs
|
|
494
|
+
* items={breadcrumbItems}
|
|
495
|
+
* LinkComponent={({ href, children, className }) => (
|
|
496
|
+
* <MyCustomLink to={href} className={className}>{children}</MyCustomLink>
|
|
497
|
+
* )}
|
|
498
|
+
* />
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
declare function Breadcrumbs({ items, LinkComponent, className, maxItems, separator, }: BreadcrumbsProps): react_jsx_runtime.JSX.Element | null;
|
|
502
|
+
declare namespace Breadcrumbs {
|
|
503
|
+
var displayName: string;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Pre-wired OrganizationSwitcher for sidebar header.
|
|
508
|
+
*
|
|
509
|
+
* Automatically uses shell branding context - when the user belongs to an
|
|
510
|
+
* organization, shows the OrganizationSwitcher widget. When not in an
|
|
511
|
+
* organization, falls back to displaying the app branding (logo + name).
|
|
512
|
+
*
|
|
513
|
+
* This component is used by default in AuthApp and AuthAppWithChildren.
|
|
514
|
+
* You only need to explicitly pass it if using AuthShell directly or
|
|
515
|
+
* if you want to override the default with a custom component.
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```tsx
|
|
519
|
+
* // AuthApp uses SidebarOrgSwitcher by default - no config needed!
|
|
520
|
+
* import { AuthApp } from '@mdxui/auth/shell'
|
|
521
|
+
*
|
|
522
|
+
* <AuthApp config={config} />
|
|
523
|
+
* ```
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```tsx
|
|
527
|
+
* // With AuthShell directly (manual setup)
|
|
528
|
+
* import { AuthShell, SidebarOrgSwitcher } from '@mdxui/auth/shell'
|
|
529
|
+
*
|
|
530
|
+
* <AuthShell sidebarHeaderContent={<SidebarOrgSwitcher />}>
|
|
531
|
+
* <Outlet />
|
|
532
|
+
* </AuthShell>
|
|
533
|
+
* ```
|
|
534
|
+
*/
|
|
535
|
+
declare function SidebarOrgSwitcher(): react_jsx_runtime.JSX.Element;
|
|
536
|
+
|
|
537
|
+
/** Known widget names with custom error messages */
|
|
538
|
+
type KnownWidgetName = 'profile' | 'security' | 'sessions' | 'api-keys' | 'team' | 'integrations';
|
|
539
|
+
interface WidgetErrorBoundaryProps {
|
|
540
|
+
children: ReactNode;
|
|
541
|
+
/** Widget name for contextual error messages (known names get fun messages, others get a friendly default) */
|
|
542
|
+
widgetName?: KnownWidgetName | (string & {});
|
|
543
|
+
/** Custom fallback UI (overrides default error message) */
|
|
544
|
+
fallback?: ReactNode;
|
|
545
|
+
}
|
|
546
|
+
interface WidgetErrorBoundaryState {
|
|
547
|
+
hasError: boolean;
|
|
548
|
+
error?: Error;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Error boundary for WorkOS widgets.
|
|
552
|
+
* Catches rendering errors and displays a friendly, contextual fallback UI.
|
|
553
|
+
*/
|
|
554
|
+
declare class WidgetErrorBoundary extends Component<WidgetErrorBoundaryProps, WidgetErrorBoundaryState> {
|
|
555
|
+
constructor(props: WidgetErrorBoundaryProps);
|
|
556
|
+
static getDerivedStateFromError(error: Error): WidgetErrorBoundaryState;
|
|
557
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
558
|
+
render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Profile page that renders the UserProfile widget
|
|
563
|
+
*
|
|
564
|
+
* Displays user account information including name, email, and profile picture.
|
|
565
|
+
*/
|
|
566
|
+
declare function ProfilePage(): react_jsx_runtime.JSX.Element;
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Security page that renders the UserSecurity widget
|
|
570
|
+
*
|
|
571
|
+
* Allows users to manage password and MFA settings.
|
|
572
|
+
*/
|
|
573
|
+
declare function SecurityPage(): react_jsx_runtime.JSX.Element;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Sessions page that renders the UserSessions widget
|
|
577
|
+
*
|
|
578
|
+
* Displays active sessions and allows users to revoke them.
|
|
579
|
+
*/
|
|
580
|
+
declare function SessionsPage(): react_jsx_runtime.JSX.Element;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* API Keys page that renders the ApiKeys widget
|
|
584
|
+
*
|
|
585
|
+
* Allows users to create and manage their API keys.
|
|
586
|
+
*/
|
|
587
|
+
declare function ApiKeysPage(): react_jsx_runtime.JSX.Element;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Team page that renders the UsersManagement widget
|
|
591
|
+
*
|
|
592
|
+
* Requires organization membership and admin permissions to view.
|
|
593
|
+
*/
|
|
594
|
+
declare function TeamPage(): react_jsx_runtime.JSX.Element;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Integrations page that renders the Pipes widget
|
|
598
|
+
*
|
|
599
|
+
* Allows users to connect and manage third-party integrations.
|
|
600
|
+
*/
|
|
601
|
+
declare function IntegrationsPage(): react_jsx_runtime.JSX.Element;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Route Presets
|
|
605
|
+
*
|
|
606
|
+
* Default route configurations for AuthApp. These provide a zero-config
|
|
607
|
+
* experience - just provide branding and identity config to get started.
|
|
608
|
+
*/
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Default route groups for organizing navigation
|
|
612
|
+
*/
|
|
613
|
+
declare const defaultGroups: RouteGroup[];
|
|
614
|
+
/**
|
|
615
|
+
* Account management routes
|
|
616
|
+
*/
|
|
617
|
+
declare const accountRoutes: AuthAppRoute[];
|
|
618
|
+
/**
|
|
619
|
+
* Developer-focused routes
|
|
620
|
+
*/
|
|
621
|
+
declare const developerRoutes: AuthAppRoute[];
|
|
622
|
+
/**
|
|
623
|
+
* Admin/team management routes
|
|
624
|
+
*/
|
|
625
|
+
declare const adminRoutes: AuthAppRoute[];
|
|
626
|
+
/**
|
|
627
|
+
* Integration routes (optional, not included in defaults)
|
|
628
|
+
*/
|
|
629
|
+
declare const integrationRoutes: AuthAppRoute[];
|
|
630
|
+
/**
|
|
631
|
+
* Default routes - all standard routes combined
|
|
632
|
+
*
|
|
633
|
+
* Includes: account, developer, and admin routes
|
|
634
|
+
* Does NOT include: integrationRoutes (opt-in)
|
|
635
|
+
*/
|
|
636
|
+
declare const defaultRoutes: AuthAppRoute[];
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Environment Variable Configuration
|
|
640
|
+
*
|
|
641
|
+
* Reads configuration from environment variables for zero-config setup.
|
|
642
|
+
* Supports Vite's import.meta.env pattern for Cloudflare Workers Static Assets.
|
|
643
|
+
*
|
|
644
|
+
* Environment variables:
|
|
645
|
+
* - VITE_WORKOS_CLIENT_ID - WorkOS client ID (required for zero-config)
|
|
646
|
+
* - VITE_WORKOS_REDIRECT_URI - OAuth redirect URI
|
|
647
|
+
* - VITE_WORKOS_API_HOSTNAME - WorkOS API hostname override
|
|
648
|
+
* - VITE_WORKOS_DEV_MODE - Enable dev mode ("true" or "false")
|
|
649
|
+
* - VITE_APP_NAME - Application name for branding
|
|
650
|
+
* - VITE_APP_TAGLINE - Application tagline
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* ```bash
|
|
654
|
+
* # .env file
|
|
655
|
+
* VITE_WORKOS_CLIENT_ID=client_01JQYTRXK9ZPD8JPJTKDCRB656
|
|
656
|
+
* VITE_WORKOS_REDIRECT_URI=https://oauth.do/callback
|
|
657
|
+
* VITE_APP_NAME=OAuth.do
|
|
658
|
+
* ```
|
|
659
|
+
*/
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Get configuration from environment variables
|
|
663
|
+
*
|
|
664
|
+
* Returns a partial config that can be merged with explicit config.
|
|
665
|
+
* Missing required fields will cause runtime errors if not provided elsewhere.
|
|
666
|
+
*/
|
|
667
|
+
declare function getEnvConfig(): Partial<AuthAppConfig>;
|
|
668
|
+
/**
|
|
669
|
+
* Merge explicit config with environment config
|
|
670
|
+
*
|
|
671
|
+
* Explicit config takes precedence over environment variables.
|
|
672
|
+
*/
|
|
673
|
+
declare function mergeWithEnvConfig(config?: Partial<AuthAppConfig>): AuthAppConfig;
|
|
674
|
+
|
|
675
|
+
export { ApiKeysPage, AuthApp, type AuthAppConfig, type AuthAppProps, AuthAppProvider, type AuthAppRoute, AuthAppWithChildren, AuthShell, type AuthShellBranding, AuthShellConfigProvider, type AuthShellIdentity, AuthShellNav, type AuthShellNavProps, type AuthShellProps, type BreadcrumbItemConfig, type BreadcrumbLinkProps, Breadcrumbs, type BreadcrumbsProps, IntegrationsPage, ProfilePage, SecurityPage, SessionsPage, SidebarOrgSwitcher, TeamPage, WidgetErrorBoundary, accountRoutes, adminRoutes, defaultGroups, defaultRoutes, developerRoutes, getEnvConfig, integrationRoutes, mergeWithEnvConfig, useAuthShellBranding, useAuthShellConfig, useAuthShellFullPath, useAuthShellRoutes, useAuthShellRoutesByGroup };
|