@mdxui/auth 1.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/providers/identity-provider.tsx","../src/providers/widgets-provider.tsx","../src/providers/auth-gate.tsx","../src/widgets/user-profile.tsx","../src/widgets/user-security.tsx","../src/widgets/user-sessions.tsx","../src/widgets/api-keys.tsx","../src/widgets/users-management.tsx","../src/widgets/pipes.tsx","../src/widgets/organization-switcher.tsx","../src/components/sign-in-button.tsx","../src/components/sign-out-button.tsx","../src/components/user-menu.tsx","../src/components/team-switcher.tsx","../src/hooks/use-auth.ts","../src/hooks/use-widget-token.ts","../src/schemas/auth-user.ts","../src/schemas/auth-session.ts","../src/schemas/auth-organization.ts","../src/schemas/provider-props.ts","../src/schemas/widget-props.ts"],"sourcesContent":["'use client'\n\nimport { AuthKitProvider } from '@workos-inc/authkit-react'\nimport type { IdentityProviderProps } from '../types/auth'\nimport { WidgetsProvider } from './widgets-provider'\n\n/**\n * Identity provider that wraps your app with WorkOS AuthKit authentication.\n *\n * This provider sets up authentication context for your application and\n * automatically includes the WidgetsProvider for WorkOS widgets.\n *\n * @example\n * ```tsx\n * import { IdentityProvider } from '@mdxui/auth'\n *\n * function App() {\n * return (\n * <IdentityProvider\n * clientId=\"client_xxx\"\n * devMode={process.env.NODE_ENV === 'development'}\n * >\n * <YourApp />\n * </IdentityProvider>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom redirect URI\n * <IdentityProvider\n * clientId=\"client_xxx\"\n * redirectUri=\"https://app.example.com/dashboard\"\n * onRedirectCallback={() => {\n * // Custom callback after auth redirect\n * }}\n * >\n * <YourApp />\n * </IdentityProvider>\n * ```\n */\nexport function IdentityProvider({\n clientId,\n apiHostname,\n devMode,\n redirectUri,\n onRedirectCallback,\n children,\n}: IdentityProviderProps) {\n // Build redirect URI - defaults to current origin\n const resolvedRedirectUri =\n redirectUri ??\n (typeof window !== 'undefined' ? window.location.origin : undefined)\n\n // Default redirect callback - clear auth params from URL\n const handleRedirectCallback =\n onRedirectCallback ??\n (() => {\n if (typeof window !== 'undefined') {\n const url = new URL(window.location.href)\n url.searchParams.delete('code')\n url.searchParams.delete('state')\n window.history.replaceState({}, '', url.pathname)\n }\n })\n\n return (\n <AuthKitProvider\n clientId={clientId}\n apiHostname={apiHostname}\n devMode={devMode}\n redirectUri={resolvedRedirectUri}\n onRedirectCallback={handleRedirectCallback}\n >\n <WidgetsProvider>{children}</WidgetsProvider>\n </AuthKitProvider>\n )\n}\n\n/**\n * Minimal identity provider without WidgetsProvider\n *\n * Use this if you want to set up widgets separately or don't need them.\n *\n * @example\n * ```tsx\n * import { IdentityProviderMinimal, WidgetsProvider } from '@mdxui/auth'\n *\n * function App() {\n * return (\n * <IdentityProviderMinimal clientId=\"client_xxx\">\n * <WidgetsProvider appearance=\"dark\">\n * <YourApp />\n * </WidgetsProvider>\n * </IdentityProviderMinimal>\n * )\n * }\n * ```\n */\nexport function IdentityProviderMinimal({\n clientId,\n apiHostname,\n devMode,\n redirectUri,\n onRedirectCallback,\n children,\n}: IdentityProviderProps) {\n const resolvedRedirectUri =\n redirectUri ??\n (typeof window !== 'undefined' ? window.location.origin : undefined)\n\n const handleRedirectCallback =\n onRedirectCallback ??\n (() => {\n if (typeof window !== 'undefined') {\n const url = new URL(window.location.href)\n url.searchParams.delete('code')\n url.searchParams.delete('state')\n window.history.replaceState({}, '', url.pathname)\n }\n })\n\n return (\n <AuthKitProvider\n clientId={clientId}\n apiHostname={apiHostname}\n devMode={devMode}\n redirectUri={resolvedRedirectUri}\n onRedirectCallback={handleRedirectCallback}\n >\n {children}\n </AuthKitProvider>\n )\n}\n","'use client'\n\nimport { WorkOsWidgets } from '@workos-inc/widgets'\nimport { useEffect, useState } from 'react'\nimport type { WidgetsProviderProps } from '../types/auth'\n\n/**\n * Hook to detect dark mode from document class or system preference\n *\n * @returns Object with isDark state and mounted flag\n *\n * @example\n * ```tsx\n * const { isDark, mounted } = useThemeDetection()\n * const appearance = mounted ? (isDark ? 'dark' : 'light') : 'inherit'\n * ```\n */\nexport function useThemeDetection() {\n const [mounted, setMounted] = useState(false)\n const [isDark, setIsDark] = useState(false)\n\n useEffect(() => {\n setMounted(true)\n\n const checkDarkMode = () => {\n const isDarkClass = document.documentElement.classList.contains('dark')\n const prefersDark = window.matchMedia(\n '(prefers-color-scheme: dark)'\n ).matches\n setIsDark(\n isDarkClass ||\n (!document.documentElement.classList.contains('light') && prefersDark)\n )\n }\n\n checkDarkMode()\n\n // Watch for class changes on html element\n const observer = new MutationObserver(checkDarkMode)\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class'],\n })\n\n // Watch for system preference changes\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')\n mediaQuery.addEventListener('change', checkDarkMode)\n\n return () => {\n observer.disconnect()\n mediaQuery.removeEventListener('change', checkDarkMode)\n }\n }, [])\n\n return { isDark, mounted }\n}\n\n/**\n * Provider for WorkOS widgets with automatic theme detection\n *\n * Wraps children with WorkOsWidgets context and automatically detects\n * light/dark mode from document classes or system preference.\n *\n * @example\n * ```tsx\n * import { WidgetsProvider } from '@mdxui/auth'\n * import { UserProfile } from '@mdxui/auth/widgets'\n *\n * function App() {\n * return (\n * <WidgetsProvider>\n * <UserProfile authToken={getAccessToken} />\n * </WidgetsProvider>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With explicit theme\n * <WidgetsProvider appearance=\"dark\" radius=\"large\">\n * <UserProfile authToken={token} />\n * </WidgetsProvider>\n * ```\n */\nexport function WidgetsProvider({\n children,\n appearance,\n radius = 'medium',\n scaling = '100%',\n}: WidgetsProviderProps) {\n const { isDark, mounted } = useThemeDetection()\n\n // Use provided appearance, or auto-detect from theme\n // Use \"inherit\" until mounted to avoid hydration mismatch\n const resolvedAppearance =\n appearance ?? (mounted ? (isDark ? 'dark' : 'light') : 'inherit')\n\n return (\n <WorkOsWidgets\n theme={{\n appearance: resolvedAppearance,\n radius,\n scaling,\n }}\n elements={{\n primaryButton: {\n variant: 'solid',\n },\n secondaryButton: {\n variant: 'outline',\n },\n }}\n >\n {children}\n </WorkOsWidgets>\n )\n}\n","'use client'\n\nimport { useAuth } from '@workos-inc/authkit-react'\nimport type { AuthGateProps } from '../types/auth'\n\n/**\n * Default loading component shown while checking authentication\n */\nfunction DefaultLoadingComponent() {\n return (\n <div className=\"min-h-screen bg-background flex items-center justify-center\">\n <div className=\"flex flex-col items-center gap-4\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n <p className=\"text-sm text-muted-foreground\">Loading...</p>\n </div>\n </div>\n )\n}\n\n/**\n * Default landing page component shown when user is not authenticated\n */\nfunction DefaultLandingPage() {\n const { signIn } = useAuth()\n\n return (\n <div className=\"min-h-screen bg-background flex flex-col items-center justify-center p-4\">\n <div className=\"text-center max-w-md\">\n <h1 className=\"text-3xl font-bold tracking-tight mb-4\">Welcome</h1>\n <p className=\"text-muted-foreground mb-8\">\n Sign in to access your dashboard.\n </p>\n <button\n type=\"button\"\n onClick={() => signIn()}\n className=\"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius-md)] text-sm font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-6\"\n >\n Sign In\n </button>\n </div>\n </div>\n )\n}\n\n/**\n * AuthGate handles authentication state and shows appropriate UI:\n * - Loading state while checking auth\n * - Landing page or redirect when not authenticated\n * - Children (protected content) when authenticated\n *\n * @example\n * ```tsx\n * import { AuthGate } from '@mdxui/auth'\n *\n * function App() {\n * return (\n * <AuthGate>\n * <ProtectedDashboard />\n * </AuthGate>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom components\n * <AuthGate\n * loadingComponent={<CustomSpinner />}\n * landingComponent={<CustomLandingPage />}\n * >\n * <Dashboard />\n * </AuthGate>\n * ```\n *\n * @example\n * ```tsx\n * // Allow unauthenticated access\n * <AuthGate required={false}>\n * <PublicContent />\n * </AuthGate>\n * ```\n *\n * @example\n * ```tsx\n * // Redirect to external URL when not authenticated\n * <AuthGate\n * onUnauthenticated=\"redirect\"\n * redirectUrl=\"https://marketing.example.com\"\n * >\n * <Dashboard />\n * </AuthGate>\n * ```\n */\nexport function AuthGate({\n children,\n required = true,\n loadingComponent,\n landingComponent,\n onUnauthenticated = 'landing',\n redirectUrl,\n}: AuthGateProps) {\n const { user, isLoading } = useAuth()\n\n // If auth is not required, always show children\n if (!required) {\n return <>{children}</>\n }\n\n // Show loading state while checking authentication\n if (isLoading) {\n return <>{loadingComponent ?? <DefaultLoadingComponent />}</>\n }\n\n // User is authenticated, show protected content\n if (user) {\n return <>{children}</>\n }\n\n // User is not authenticated - handle based on config\n switch (onUnauthenticated) {\n case 'redirect':\n // Redirect to external URL\n if (redirectUrl && typeof window !== 'undefined') {\n window.location.href = redirectUrl\n return (\n <div className=\"min-h-screen bg-background flex items-center justify-center\">\n <p className=\"text-sm text-muted-foreground\">Redirecting...</p>\n </div>\n )\n }\n // Fall through to landing if no redirect URL\n return <>{landingComponent ?? <DefaultLandingPage />}</>\n\n case 'allow':\n // Allow access even without auth (shows children)\n return <>{children}</>\n\n case 'landing':\n default:\n // Show landing page (custom or default)\n return <>{landingComponent ?? <DefaultLandingPage />}</>\n }\n}\n","'use client'\n\nimport { UserProfile as WorkOSUserProfile } from '@workos-inc/widgets'\nimport type { BaseWidgetProps } from '../types/auth'\n\n/**\n * User Profile Widget\n *\n * Displays and allows editing of user profile information:\n * - Profile picture\n * - Name and email\n * - Connected accounts (OAuth providers)\n *\n * @example\n * ```tsx\n * // With AuthKit (recommended)\n * import { useAuth } from '@mdxui/auth'\n * import { UserProfile } from '@mdxui/auth/widgets'\n *\n * function ProfilePage() {\n * const { getAccessToken } = useAuth()\n * return <UserProfile authToken={getAccessToken} />\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With string token\n * <UserProfile authToken={myToken} />\n * ```\n */\nexport function UserProfile({ authToken, className }: BaseWidgetProps) {\n return (\n <div className={className}>\n <WorkOSUserProfile authToken={authToken} />\n </div>\n )\n}\n","'use client'\n\nimport { UserSecurity as WorkOSUserSecurity } from '@workos-inc/widgets'\nimport type { BaseWidgetProps } from '../types/auth'\n\n/**\n * User Security Widget\n *\n * Allows users to manage their security settings:\n * - Password management\n * - Multi-factor authentication (MFA)\n * - Connected authentication methods\n * - Security keys\n *\n * @example\n * ```tsx\n * // With AuthKit (recommended)\n * import { useAuth } from '@mdxui/auth'\n * import { UserSecurity } from '@mdxui/auth/widgets'\n *\n * function SecurityPage() {\n * const { getAccessToken } = useAuth()\n * return <UserSecurity authToken={getAccessToken} />\n * }\n * ```\n */\nexport function UserSecurity({ authToken, className }: BaseWidgetProps) {\n return (\n <div className={className}>\n <WorkOSUserSecurity authToken={authToken} />\n </div>\n )\n}\n","'use client'\n\nimport { UserSessions as WorkOSUserSessions } from '@workos-inc/widgets'\n\n/**\n * Props for UserSessions with function token (no currentSessionId needed)\n */\nexport interface UserSessionsWithFunctionTokenProps {\n /** Auth token getter function */\n authToken: () => Promise<string>\n /** CSS class name */\n className?: string\n}\n\n/**\n * Props for UserSessions with string token (currentSessionId required)\n */\nexport interface UserSessionsWithStringTokenProps {\n /** Auth token string */\n authToken: string\n /** Current session ID (required when using string token) */\n currentSessionId: string\n /** CSS class name */\n className?: string\n}\n\nexport type UserSessionsProps =\n | UserSessionsWithFunctionTokenProps\n | UserSessionsWithStringTokenProps\n\n/**\n * User Sessions Widget\n *\n * Displays and manages active user sessions:\n * - View all active sessions\n * - See session details (device, location, last active)\n * - Revoke sessions\n *\n * @example\n * ```tsx\n * // With AuthKit (recommended) - no currentSessionId needed\n * import { useAuth } from '@mdxui/auth'\n * import { UserSessions } from '@mdxui/auth/widgets'\n *\n * function SessionsPage() {\n * const { getAccessToken } = useAuth()\n * return <UserSessions authToken={getAccessToken} />\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With string token - currentSessionId required\n * <UserSessions authToken={token} currentSessionId={sessionId} />\n * ```\n */\nexport function UserSessions(props: UserSessionsProps) {\n const { className, ...rest } = props\n\n return (\n <div className={className}>\n <WorkOSUserSessions {...rest} />\n </div>\n )\n}\n","'use client'\n\nimport { ApiKeys as WorkOSApiKeys } from '@workos-inc/widgets'\nimport type { BaseWidgetProps } from '../types/auth'\n\n/**\n * API Keys Widget\n *\n * Displays and manages API keys:\n * - Create new API keys with specific permissions\n * - View existing API keys\n * - Revoke API keys\n *\n * Requires the `widgets:api-keys:manage` permission.\n * Organization context is derived from the auth token.\n *\n * @example\n * ```tsx\n * // With AuthKit (recommended)\n * import { useAuth } from '@mdxui/auth'\n * import { ApiKeys } from '@mdxui/auth/widgets'\n *\n * function ApiKeysPage() {\n * const { getAccessToken } = useAuth()\n * return <ApiKeys authToken={getAccessToken} />\n * }\n * ```\n */\nexport function ApiKeys({ authToken, className }: BaseWidgetProps) {\n return (\n <div className={className}>\n <WorkOSApiKeys authToken={authToken} />\n </div>\n )\n}\n","'use client'\n\nimport { UsersManagement as WorkOSUsersManagement } from '@workos-inc/widgets'\nimport type { BaseWidgetProps } from '../types/auth'\n\nexport interface UsersManagementProps extends BaseWidgetProps {\n /**\n * Organization ID for scoping the user management.\n *\n * This is typically used to verify organization context in the parent component.\n * The actual organization scope comes from the auth token.\n */\n organizationId?: string\n}\n\n/**\n * Users Management Widget (Team Page)\n *\n * Allows organization admins to manage team members:\n * - View organization members\n * - Invite new members\n * - Update member roles\n * - Remove members\n *\n * Requires the `widgets:users-table:manage` permission and organization context.\n *\n * @example\n * ```tsx\n * // With AuthKit (recommended)\n * import { useAuth } from '@mdxui/auth'\n * import { UsersManagement } from '@mdxui/auth/widgets'\n *\n * function TeamPage() {\n * const { getAccessToken, organizationId, permissions } = useAuth()\n *\n * if (!organizationId) {\n * return <p>You need to be in an organization.</p>\n * }\n *\n * if (!permissions?.includes('widgets:users-table:manage')) {\n * return <p>You need admin permissions.</p>\n * }\n *\n * return (\n * <UsersManagement\n * authToken={getAccessToken}\n * organizationId={organizationId}\n * />\n * )\n * }\n * ```\n */\nexport function UsersManagement({\n authToken,\n organizationId: _organizationId,\n className,\n}: UsersManagementProps) {\n return (\n <div className={className}>\n <WorkOSUsersManagement authToken={authToken} />\n </div>\n )\n}\n","'use client'\n\nimport { Pipes as WorkOSPipes } from '@workos-inc/widgets'\nimport type { BaseWidgetProps } from '../types/auth'\n\n/**\n * Pipes Widget (Integrations)\n *\n * Allows users to manage third-party integrations:\n * - Connect external services\n * - View connected integrations\n * - Manage integration settings\n * - Disconnect integrations\n *\n * @example\n * ```tsx\n * // With AuthKit (recommended)\n * import { useAuth } from '@mdxui/auth'\n * import { Pipes } from '@mdxui/auth/widgets'\n *\n * function IntegrationsPage() {\n * const { getAccessToken } = useAuth()\n * return <Pipes authToken={getAccessToken} />\n * }\n * ```\n */\nexport function Pipes({ authToken, className }: BaseWidgetProps) {\n return (\n <div className={className}>\n <WorkOSPipes authToken={authToken} />\n </div>\n )\n}\n","'use client'\n\nimport { OrganizationSwitcher as WorkOSOrganizationSwitcher } from '@workos-inc/widgets'\n\nexport type OrganizationSwitcherVariant = 'ghost' | 'outline'\n\nexport interface OrganizationSwitcherProps {\n /** Auth token getter function */\n authToken: () => Promise<string>\n /**\n * Function to switch to a different organization.\n * Receives an object with organizationId.\n */\n switchToOrganization: (args: { organizationId: string }) => void | Promise<void>\n /** Visual variant of the switcher */\n variant?: OrganizationSwitcherVariant\n /** Custom organization label */\n organizationLabel?: string | null\n /** Where to truncate long organization names */\n truncateBehavior?: 'right' | 'middle'\n /** CSS class name */\n className?: string\n}\n\n/**\n * Organization Switcher Widget\n *\n * Allows users to switch between organizations they belong to.\n *\n * @example\n * ```tsx\n * import { useAuth } from '@mdxui/auth'\n * import { OrganizationSwitcher } from '@mdxui/auth/widgets'\n *\n * function OrgSwitcher() {\n * const { getAccessToken, switchToOrganization } = useAuth()\n *\n * // Adapt the function signature\n * const handleSwitch = ({ organizationId }: { organizationId: string }) => {\n * return switchToOrganization(organizationId)\n * }\n *\n * return (\n * <OrganizationSwitcher\n * authToken={getAccessToken}\n * switchToOrganization={handleSwitch}\n * />\n * )\n * }\n * ```\n */\nexport function OrganizationSwitcher({\n authToken,\n switchToOrganization,\n variant,\n organizationLabel,\n truncateBehavior,\n className,\n}: OrganizationSwitcherProps) {\n return (\n <div className={className}>\n <WorkOSOrganizationSwitcher\n authToken={authToken}\n switchToOrganization={switchToOrganization}\n variant={variant}\n organizationLabel={organizationLabel}\n truncateBehavior={truncateBehavior}\n />\n </div>\n )\n}\n","'use client'\n\nimport { useAuth } from '@workos-inc/authkit-react'\nimport type { ReactNode, ButtonHTMLAttributes } from 'react'\n\nexport interface SignInButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> {\n /** Button content (defaults to \"Sign In\") */\n children?: ReactNode\n /** Custom onClick handler (in addition to signIn) */\n onSignIn?: () => void\n}\n\n/**\n * Sign In Button\n *\n * A simple button that triggers the WorkOS AuthKit sign-in flow.\n *\n * @example\n * ```tsx\n * import { SignInButton } from '@mdxui/auth'\n *\n * function Header() {\n * return (\n * <nav>\n * <SignInButton />\n * </nav>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom styling\n * <SignInButton className=\"bg-blue-500 text-white px-4 py-2 rounded\">\n * Get Started\n * </SignInButton>\n * ```\n */\nexport function SignInButton({\n children = 'Sign In',\n onSignIn,\n className,\n disabled,\n ...props\n}: SignInButtonProps) {\n const { signIn, isLoading } = useAuth()\n\n const handleClick = () => {\n onSignIn?.()\n signIn()\n }\n\n return (\n <button\n type=\"button\"\n onClick={handleClick}\n disabled={disabled || isLoading}\n className={\n className ??\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius-md)] text-sm font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 disabled:opacity-50 disabled:pointer-events-none'\n }\n {...props}\n >\n {children}\n </button>\n )\n}\n","'use client'\n\nimport { useAuth } from '@workos-inc/authkit-react'\nimport type { ReactNode, ButtonHTMLAttributes } from 'react'\n\nexport interface SignOutButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> {\n /** Button content (defaults to \"Sign Out\") */\n children?: ReactNode\n /** Custom onClick handler (in addition to signOut) */\n onSignOut?: () => void\n}\n\n/**\n * Sign Out Button\n *\n * A simple button that triggers the WorkOS AuthKit sign-out flow.\n *\n * @example\n * ```tsx\n * import { SignOutButton } from '@mdxui/auth'\n *\n * function Header() {\n * const { user } = useAuth()\n *\n * if (!user) return null\n *\n * return (\n * <nav>\n * <span>{user.email}</span>\n * <SignOutButton />\n * </nav>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom styling\n * <SignOutButton className=\"text-red-500 underline\">\n * Log out\n * </SignOutButton>\n * ```\n */\nexport function SignOutButton({\n children = 'Sign Out',\n onSignOut,\n className,\n disabled,\n ...props\n}: SignOutButtonProps) {\n const { signOut, isLoading } = useAuth()\n\n const handleClick = () => {\n onSignOut?.()\n signOut()\n }\n\n return (\n <button\n type=\"button\"\n onClick={handleClick}\n disabled={disabled || isLoading}\n className={\n className ??\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius-md)] text-sm font-medium transition-colors bg-secondary text-secondary-foreground hover:bg-secondary/80 h-10 px-4 disabled:opacity-50 disabled:pointer-events-none'\n }\n {...props}\n >\n {children}\n </button>\n )\n}\n","'use client'\n\nimport { useAuth } from '@workos-inc/authkit-react'\nimport type { ReactNode } from 'react'\n\nexport interface UserMenuProps {\n /** Custom render function for the trigger button */\n renderTrigger?: (props: {\n user: NonNullable<ReturnType<typeof useAuth>['user']>\n displayName: string\n initials: string\n }) => ReactNode\n /** Custom render function for the menu content */\n renderMenu?: (props: {\n user: NonNullable<ReturnType<typeof useAuth>['user']>\n displayName: string\n initials: string\n signOut: () => void\n }) => ReactNode\n /** Additional CSS class */\n className?: string\n}\n\n/**\n * Get initials from a name (first letter of first and last name)\n */\nfunction getInitials(name: string | undefined): string {\n if (!name) return '?'\n const parts = name.trim().split(/\\s+/)\n if (parts.length === 1) return parts[0].charAt(0).toUpperCase()\n return (\n parts[0].charAt(0) + parts[parts.length - 1].charAt(0)\n ).toUpperCase()\n}\n\n/**\n * User Menu Component\n *\n * A customizable user menu that displays user info and provides sign-out functionality.\n * This is a headless component - you provide the render functions to control the UI.\n *\n * For a pre-built menu with @mdxui/primitives, use the UserMenu from @mdxui/do or @mdxui/cockpit.\n *\n * @example\n * ```tsx\n * import { UserMenu } from '@mdxui/auth'\n *\n * function Header() {\n * return (\n * <UserMenu\n * renderTrigger={({ user, initials }) => (\n * <button className=\"flex items-center gap-2\">\n * <div className=\"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center\">\n * {user.profilePictureUrl ? (\n * <img src={user.profilePictureUrl} alt=\"\" className=\"rounded-full\" />\n * ) : (\n * initials\n * )}\n * </div>\n * <span>{user.firstName}</span>\n * </button>\n * )}\n * renderMenu={({ user, signOut }) => (\n * <div className=\"dropdown-menu\">\n * <div className=\"p-2\">\n * <p>{user.email}</p>\n * </div>\n * <button onClick={signOut}>Sign Out</button>\n * </div>\n * )}\n * />\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Simple usage with just a sign-out button\n * <UserMenu\n * renderTrigger={({ displayName }) => <span>{displayName}</span>}\n * renderMenu={({ signOut }) => <button onClick={signOut}>Sign Out</button>}\n * />\n * ```\n */\nexport function UserMenu({ renderTrigger, renderMenu, className }: UserMenuProps) {\n const { user, signOut, isLoading } = useAuth()\n\n if (isLoading) {\n return (\n <div className={className}>\n <div className=\"flex items-center gap-2 p-2\">\n <div className=\"h-8 w-8 animate-pulse rounded-full bg-muted\" />\n </div>\n </div>\n )\n }\n\n if (!user) {\n return null\n }\n\n const displayName = user.firstName\n ? `${user.firstName}${user.lastName ? ` ${user.lastName}` : ''}`\n : user.email\n\n const initials = getInitials(\n user.firstName ? `${user.firstName} ${user.lastName ?? ''}` : user.email\n )\n\n const triggerProps = { user, displayName, initials }\n const menuProps = { user, displayName, initials, signOut }\n\n // If no render functions provided, render a basic menu\n if (!renderTrigger && !renderMenu) {\n return (\n <div className={className}>\n <div className=\"flex items-center gap-2 p-2\">\n <div className=\"h-8 w-8 rounded-full bg-muted flex items-center justify-center text-sm font-medium\">\n {user.profilePictureUrl ? (\n <img\n src={user.profilePictureUrl}\n alt={displayName}\n className=\"h-full w-full rounded-full object-cover\"\n />\n ) : (\n initials\n )}\n </div>\n <div className=\"text-sm\">\n <p className=\"font-medium\">{displayName}</p>\n <p className=\"text-muted-foreground text-xs\">{user.email}</p>\n </div>\n <button\n type=\"button\"\n onClick={() => signOut()}\n className=\"ml-auto text-sm text-muted-foreground hover:text-foreground\"\n >\n Sign out\n </button>\n </div>\n </div>\n )\n }\n\n return (\n <div className={className}>\n {renderTrigger?.(triggerProps)}\n {renderMenu?.(menuProps)}\n </div>\n )\n}\n","'use client'\n\nimport { useAuth } from '@workos-inc/authkit-react'\nimport { OrganizationSwitcher } from '@workos-inc/widgets'\nimport type { ReactNode } from 'react'\n\nexport interface TeamSwitcherProps {\n /**\n * Render function for the wrapper when in an organization.\n * The OrganizationSwitcher widget will be rendered inside this wrapper.\n */\n renderWrapper?: (children: ReactNode) => ReactNode\n /**\n * Render function for when there is no organization.\n * If not provided, returns null.\n */\n renderNoOrganization?: () => ReactNode\n /** CSS class name for the organization switcher wrapper */\n className?: string\n}\n\n/**\n * TeamSwitcher component that uses WorkOS authentication.\n *\n * Shows the WorkOS OrganizationSwitcher widget when authenticated with an organization,\n * or a custom \"no organization\" component when not.\n *\n * This is a headless component - you provide render functions for the UI.\n * For a pre-built sidebar menu version, use your design system's sidebar components.\n *\n * @example\n * ```tsx\n * import { TeamSwitcher } from '@mdxui/auth'\n * import { SidebarMenu, SidebarMenuItem } from '@mdxui/primitives/sidebar'\n * import { Building2 } from 'lucide-react'\n *\n * function MyTeamSwitcher() {\n * return (\n * <TeamSwitcher\n * renderWrapper={(children) => (\n * <SidebarMenu>\n * <SidebarMenuItem>\n * <div className=\"organization-switcher-wrapper\">\n * {children}\n * </div>\n * </SidebarMenuItem>\n * </SidebarMenu>\n * )}\n * renderNoOrganization={() => (\n * <SidebarMenu>\n * <SidebarMenuItem>\n * <div className=\"flex items-center gap-2\">\n * <Building2 className=\"size-4\" />\n * <span>No Organization</span>\n * </div>\n * </SidebarMenuItem>\n * </SidebarMenu>\n * )}\n * />\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Simple usage without custom rendering\n * <TeamSwitcher className=\"my-org-switcher\" />\n * ```\n */\nexport function TeamSwitcher({\n renderWrapper,\n renderNoOrganization,\n className,\n}: TeamSwitcherProps) {\n const { getAccessToken, switchToOrganization, organizationId } = useAuth()\n\n // No organization - show custom component or null\n if (!organizationId) {\n return renderNoOrganization?.() ?? null\n }\n\n // Adapt switchToOrganization to the widget's expected signature\n const handleSwitchOrganization = ({\n organizationId,\n }: {\n organizationId: string\n }) => {\n return switchToOrganization({ organizationId })\n }\n\n // Render the OrganizationSwitcher widget with required wrapper class for styling\n const widget = (\n <div className={`organization-switcher-wrapper ${className ?? ''}`}>\n <OrganizationSwitcher\n authToken={getAccessToken}\n switchToOrganization={handleSwitchOrganization}\n />\n </div>\n )\n\n // Wrap in custom wrapper if provided\n return renderWrapper ? renderWrapper(widget) : widget\n}\n","'use client'\n\n/**\n * Re-export useAuth from WorkOS AuthKit\n *\n * This hook provides access to the authentication state and methods:\n * - user: The authenticated user object\n * - isLoading: Whether auth state is being loaded\n * - signIn: Function to initiate sign in\n * - signOut: Function to sign out\n * - getAccessToken: Function to get the current access token\n * - organizationId: Current organization ID (if in org context)\n * - permissions: User's permissions array\n *\n * @example\n * ```tsx\n * import { useAuth } from '@mdxui/auth'\n *\n * function MyComponent() {\n * const { user, isLoading, signIn, signOut, getAccessToken } = useAuth()\n *\n * if (isLoading) return <div>Loading...</div>\n * if (!user) return <button onClick={() => signIn()}>Sign In</button>\n *\n * return (\n * <div>\n * <p>Hello, {user.firstName}!</p>\n * <button onClick={() => signOut()}>Sign Out</button>\n * </div>\n * )\n * }\n * ```\n */\nexport { useAuth } from '@workos-inc/authkit-react'\n","'use client'\n\nimport { useCallback, useEffect, useState } from 'react'\nimport type { UseWidgetTokenOptions, UseWidgetTokenResult } from '../types/auth'\n\n/**\n * Hook to fetch authorization tokens for WorkOS widgets\n *\n * Use this hook when you need to fetch widget tokens from a backend endpoint,\n * typically for server-side auth scenarios. For client-side AuthKit usage,\n * you can use `getAccessToken` from `useAuth()` directly with widgets.\n *\n * @param options - Options for token fetching\n * @param options.widget - The widget type (user-profile, user-security, api-keys, etc.)\n * @param options.organizationId - Optional organization context\n * @param options.endpoint - Custom endpoint (default: /api/workos/widget-token)\n * @returns Token state and refetch function\n *\n * @example\n * ```tsx\n * // Server-side token fetching (via backend endpoint)\n * const { token, loading, error } = useWidgetToken({\n * widget: 'user-profile',\n * })\n *\n * if (loading) return <Spinner />\n * if (error) return <Error message={error} />\n * return <UserProfile authToken={token!} />\n * ```\n *\n * @example\n * ```tsx\n * // Client-side AuthKit (recommended - no backend needed)\n * import { useAuth } from '@mdxui/auth'\n * import { UserProfile } from '@mdxui/auth/widgets'\n *\n * const { getAccessToken } = useAuth()\n * return <UserProfile authToken={getAccessToken} />\n * ```\n */\nexport function useWidgetToken({\n widget,\n organizationId,\n endpoint = '/api/workos/widget-token',\n}: UseWidgetTokenOptions): UseWidgetTokenResult {\n const [token, setToken] = useState<string | null>(null)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState<string | null>(null)\n\n const fetchToken = useCallback(async () => {\n try {\n setLoading(true)\n setError(null)\n\n const params = new URLSearchParams({ widget })\n if (organizationId) {\n params.set('organizationId', organizationId)\n }\n\n const response = await fetch(`${endpoint}?${params}`)\n const data = await response.json()\n\n if (!response.ok) {\n throw new Error(data.error || 'Failed to fetch token')\n }\n\n setToken(data.token)\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Token fetch failed')\n } finally {\n setLoading(false)\n }\n }, [widget, organizationId, endpoint])\n\n useEffect(() => {\n fetchToken()\n }, [fetchToken])\n\n return { token, loading, error, refetch: fetchToken }\n}\n","/**\n * AuthUser Schema\n *\n * Extends mdxui's UserIdentitySchema with WorkOS-specific fields.\n * AuthUser is fully compatible with UserIdentity - it can be used\n * anywhere a UserIdentity is expected.\n */\n\nimport { z } from 'zod'\nimport { UserIdentitySchema } from 'mdxui/zod'\n\n/**\n * AuthUserSchema - Extended user identity for WorkOS AuthKit\n *\n * Extends UserIdentitySchema with WorkOS-specific fields like\n * verification status and timestamps.\n *\n * @example\n * ```tsx\n * import { AuthUserSchema } from '@mdxui/auth/schemas'\n *\n * const result = AuthUserSchema.safeParse(user)\n * if (result.success) {\n * console.log(result.data.emailVerified)\n * }\n * ```\n */\nexport const AuthUserSchema = UserIdentitySchema.extend({\n // Override to be more specific (WorkOS guarantees string ID)\n id: z.string().describe('User ID from WorkOS'),\n\n // WorkOS requires email (not optional like UserIdentity)\n email: z.string().email().describe('Email address'),\n\n // WorkOS-specific fields not in UserIdentity\n emailVerified: z.boolean().describe('Email verification status'),\n\n // Timestamps\n createdAt: z.string().datetime().describe('Account creation timestamp'),\n updatedAt: z.string().datetime().describe('Last update timestamp'),\n lastSignInAt: z\n .string()\n .datetime()\n .nullable()\n .optional()\n .describe('Last sign-in timestamp'),\n})\n\n/**\n * AuthUser type inferred from schema\n *\n * This type is compatible with UserIdentity - an AuthUser can be\n * assigned to a variable of type UserIdentity.\n */\nexport type AuthUser = z.infer<typeof AuthUserSchema>\n","/**\n * AuthSession Schema\n *\n * Extends mdxui's SessionSchema with WorkOS-specific fields.\n */\n\nimport { z } from 'zod'\nimport { SessionSchema } from 'mdxui/zod'\n\n/**\n * ImpersonatorSchema - Info about admin impersonating a user\n */\nexport const ImpersonatorSchema = z.object({\n /** Impersonator's email address */\n email: z.string().email().describe(\"Impersonator's email address\"),\n /** Reason for impersonation */\n reason: z.string().optional().describe('Reason for impersonation'),\n})\n\nexport type Impersonator = z.infer<typeof ImpersonatorSchema>\n\n/**\n * AuthSessionSchema - Extended session for WorkOS AuthKit\n *\n * Extends SessionSchema with WorkOS-specific fields like\n * impersonation support.\n *\n * @example\n * ```tsx\n * import { AuthSessionSchema } from '@mdxui/auth/schemas'\n *\n * const result = AuthSessionSchema.safeParse(session)\n * if (result.success && result.data.impersonator) {\n * console.log('Being impersonated by:', result.data.impersonator.email)\n * }\n * ```\n */\nexport const AuthSessionSchema = SessionSchema.extend({\n // Override userId to be string (WorkOS uses string IDs)\n userId: z.string().describe('User ID'),\n\n // WorkOS-specific: impersonation support\n impersonator: ImpersonatorSchema.optional().describe(\n 'Impersonator info (if being impersonated)',\n ),\n})\n\n/**\n * AuthSession type inferred from schema\n */\nexport type AuthSession = z.infer<typeof AuthSessionSchema>\n","/**\n * AuthOrganization Schema\n *\n * Organization type for WorkOS AuthKit.\n */\n\nimport { z } from 'zod'\n\n/**\n * AuthOrganizationSchema - WorkOS organization\n *\n * Represents an organization/workspace in WorkOS.\n *\n * @example\n * ```tsx\n * import { AuthOrganizationSchema } from '@mdxui/auth/schemas'\n *\n * const result = AuthOrganizationSchema.safeParse(org)\n * if (result.success) {\n * console.log('Organization:', result.data.name)\n * }\n * ```\n */\nexport const AuthOrganizationSchema = z.object({\n /** Organization ID */\n id: z.string().describe('Organization ID'),\n /** Organization display name */\n name: z.string().describe('Organization name'),\n /** Organization slug (URL-friendly identifier) */\n slug: z.string().optional().describe('Organization slug'),\n /** Organization logo URL */\n logoUrl: z.string().url().optional().describe('Organization logo URL'),\n /** Whether the organization is active */\n active: z.boolean().optional().describe('Whether organization is active'),\n /** Custom domains for the organization */\n domains: z\n .array(z.string())\n .optional()\n .describe('Custom domains for the organization'),\n /** Additional metadata */\n metadata: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Additional metadata'),\n})\n\n/**\n * AuthOrganization type inferred from schema\n */\nexport type AuthOrganization = z.infer<typeof AuthOrganizationSchema>\n","/**\n * Provider Props Schemas\n *\n * Zod schemas for authentication provider component props.\n */\n\nimport { z } from 'zod'\n\n/**\n * IdentityProviderPropsSchema - Props for IdentityProvider component\n */\nexport const IdentityProviderPropsSchema = z.object({\n /** WorkOS client ID */\n clientId: z.string().describe('WorkOS client ID'),\n /** Optional API hostname override */\n apiHostname: z.string().optional().describe('Optional API hostname override'),\n /** Enable dev mode for local development */\n devMode: z.boolean().optional().describe('Enable dev mode for local development'),\n /** Redirect URI after authentication */\n redirectUri: z.string().url().optional().describe('Redirect URI after authentication'),\n /** Note: onRedirectCallback and children are React-specific, not in schema */\n})\n\nexport type IdentityProviderPropsSchemaType = z.infer<typeof IdentityProviderPropsSchema>\n\n/**\n * UnauthenticatedActionSchema - What to do when unauthenticated\n */\nexport const UnauthenticatedActionSchema = z.enum(['landing', 'redirect', 'allow'])\n\nexport type UnauthenticatedAction = z.infer<typeof UnauthenticatedActionSchema>\n\n/**\n * AuthGatePropsSchema - Props for AuthGate component\n */\nexport const AuthGatePropsSchema = z.object({\n /** Whether authentication is required (default: true) */\n required: z.boolean().optional().describe('Whether authentication is required'),\n /** What to do when unauthenticated */\n onUnauthenticated: UnauthenticatedActionSchema.optional().describe(\n 'What to do when unauthenticated',\n ),\n /** URL to redirect to when unauthenticated (if onUnauthenticated is \"redirect\") */\n redirectUrl: z\n .string()\n .url()\n .optional()\n .describe('URL to redirect to when unauthenticated'),\n /** Note: children, loadingComponent, landingComponent are React-specific */\n})\n\nexport type AuthGatePropsSchemaType = z.infer<typeof AuthGatePropsSchema>\n\n/**\n * AppearanceSchema - Theme appearance mode\n */\nexport const AppearanceSchema = z.enum(['light', 'dark', 'inherit'])\n\nexport type Appearance = z.infer<typeof AppearanceSchema>\n\n/**\n * RadiusSchema - Border radius style\n */\nexport const RadiusSchema = z.enum(['none', 'small', 'medium', 'large', 'full'])\n\nexport type Radius = z.infer<typeof RadiusSchema>\n\n/**\n * ScalingSchema - Scaling factor\n */\nexport const ScalingSchema = z.enum(['90%', '95%', '100%', '105%', '110%'])\n\nexport type Scaling = z.infer<typeof ScalingSchema>\n\n/**\n * WidgetsProviderPropsSchema - Props for WidgetsProvider component\n */\nexport const WidgetsProviderPropsSchema = z.object({\n /** Theme appearance mode */\n appearance: AppearanceSchema.optional().describe('Theme appearance mode'),\n /** Border radius style */\n radius: RadiusSchema.optional().describe('Border radius style'),\n /** Scaling factor */\n scaling: ScalingSchema.optional().describe('Scaling factor'),\n /** Note: children is React-specific, not in schema */\n})\n\nexport type WidgetsProviderPropsSchemaType = z.infer<typeof WidgetsProviderPropsSchema>\n","/**\n * Widget Props Schemas\n *\n * Zod schemas for WorkOS widget component props.\n */\n\nimport { z } from 'zod'\n\n/**\n * AuthTokenSchema - Auth token type\n *\n * Can be a string or a function that returns a Promise<string>.\n * Functions are represented as 'function' string in schema validation\n * since Zod can't validate function signatures.\n */\nexport const AuthTokenSchema = z.union([\n z.string().describe('Static auth token'),\n z.literal('function').describe('Token getter function'),\n])\n\n// Note: The actual TypeScript type is more specific\nexport type AuthTokenSchemaType = z.infer<typeof AuthTokenSchema>\n\n/**\n * BaseWidgetPropsSchema - Common props for all widget wrappers\n */\nexport const BaseWidgetPropsSchema = z.object({\n /** Auth token for the widget (string or getter function) */\n authToken: z.string().describe('Auth token for the widget'),\n /** CSS class name */\n className: z.string().optional().describe('CSS class name'),\n})\n\nexport type BaseWidgetPropsSchemaType = z.infer<typeof BaseWidgetPropsSchema>\n\n/**\n * OrganizationWidgetPropsSchema - Props for widgets that support organization context\n */\nexport const OrganizationWidgetPropsSchema = BaseWidgetPropsSchema.extend({\n /** Organization ID for org-scoped widgets */\n organizationId: z\n .string()\n .optional()\n .describe('Organization ID for org-scoped widgets'),\n})\n\nexport type OrganizationWidgetPropsSchemaType = z.infer<\n typeof OrganizationWidgetPropsSchema\n>\n\n/**\n * UseWidgetTokenOptionsSchema - Props for useWidgetToken hook\n */\nexport const UseWidgetTokenOptionsSchema = z.object({\n /** Widget type to fetch token for */\n widget: z.string().describe('Widget type to fetch token for'),\n /** Organization ID for org-scoped widgets */\n organizationId: z\n .string()\n .optional()\n .describe('Organization ID for org-scoped widgets'),\n /** Custom endpoint for fetching widget token */\n endpoint: z\n .string()\n .url()\n .optional()\n .describe('Custom endpoint for fetching widget token'),\n})\n\nexport type UseWidgetTokenOptionsSchemaType = z.infer<typeof UseWidgetTokenOptionsSchema>\n\n/**\n * UseWidgetTokenResultSchema - Result from useWidgetToken hook\n */\nexport const UseWidgetTokenResultSchema = z.object({\n /** The fetched token */\n token: z.string().nullable().describe('The fetched token'),\n /** Whether token is being fetched */\n loading: z.boolean().describe('Whether token is being fetched'),\n /** Error message if fetch failed */\n error: z.string().nullable().describe('Error message if fetch failed'),\n /** Note: refetch function is React-specific, not in schema */\n})\n\nexport type UseWidgetTokenResultSchemaType = z.infer<typeof UseWidgetTokenResultSchema>\n"],"mappings":";AAEA,SAAS,uBAAuB;;;ACAhC,SAAS,qBAAqB;AAC9B,SAAS,WAAW,gBAAgB;AAgGhC;AAlFG,SAAS,oBAAoB;AAClC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,KAAK;AAE1C,YAAU,MAAM;AACd,eAAW,IAAI;AAEf,UAAM,gBAAgB,MAAM;AAC1B,YAAM,cAAc,SAAS,gBAAgB,UAAU,SAAS,MAAM;AACtE,YAAM,cAAc,OAAO;AAAA,QACzB;AAAA,MACF,EAAE;AACF;AAAA,QACE,eACG,CAAC,SAAS,gBAAgB,UAAU,SAAS,OAAO,KAAK;AAAA,MAC9D;AAAA,IACF;AAEA,kBAAc;AAGd,UAAM,WAAW,IAAI,iBAAiB,aAAa;AACnD,aAAS,QAAQ,SAAS,iBAAiB;AAAA,MACzC,YAAY;AAAA,MACZ,iBAAiB,CAAC,OAAO;AAAA,IAC3B,CAAC;AAGD,UAAM,aAAa,OAAO,WAAW,8BAA8B;AACnE,eAAW,iBAAiB,UAAU,aAAa;AAEnD,WAAO,MAAM;AACX,eAAS,WAAW;AACpB,iBAAW,oBAAoB,UAAU,aAA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AS,EAAE,SAAS,+BAA+B;AAAA;AAEvE,CAAC;","names":["jsx","jsx","jsx","jsx","jsx","jsx","jsx","jsx","jsx","useAuth","jsx","useAuth","jsx","useAuth","jsx","jsxs","useAuth","OrganizationSwitcher","jsx","organizationId","useAuth","useEffect","useState","z","z","z","z"]}
@@ -0,0 +1,4 @@
1
+ export { A as AuthGate, I as IdentityProvider, W as WidgetsProvider, u as useThemeDetection } from '../index-Bl4BwORF.js';
2
+ import 'react/jsx-runtime';
3
+ import '../auth-Ba2f778e.js';
4
+ import 'react';
@@ -0,0 +1,161 @@
1
+ // src/providers/identity-provider.tsx
2
+ import { AuthKitProvider } from "@workos-inc/authkit-react";
3
+
4
+ // src/providers/widgets-provider.tsx
5
+ import { WorkOsWidgets } from "@workos-inc/widgets";
6
+ import { useEffect, useState } from "react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ function useThemeDetection() {
9
+ const [mounted, setMounted] = useState(false);
10
+ const [isDark, setIsDark] = useState(false);
11
+ useEffect(() => {
12
+ setMounted(true);
13
+ const checkDarkMode = () => {
14
+ const isDarkClass = document.documentElement.classList.contains("dark");
15
+ const prefersDark = window.matchMedia(
16
+ "(prefers-color-scheme: dark)"
17
+ ).matches;
18
+ setIsDark(
19
+ isDarkClass || !document.documentElement.classList.contains("light") && prefersDark
20
+ );
21
+ };
22
+ checkDarkMode();
23
+ const observer = new MutationObserver(checkDarkMode);
24
+ observer.observe(document.documentElement, {
25
+ attributes: true,
26
+ attributeFilter: ["class"]
27
+ });
28
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
29
+ mediaQuery.addEventListener("change", checkDarkMode);
30
+ return () => {
31
+ observer.disconnect();
32
+ mediaQuery.removeEventListener("change", checkDarkMode);
33
+ };
34
+ }, []);
35
+ return { isDark, mounted };
36
+ }
37
+ function WidgetsProvider({
38
+ children,
39
+ appearance,
40
+ radius = "medium",
41
+ scaling = "100%"
42
+ }) {
43
+ const { isDark, mounted } = useThemeDetection();
44
+ const resolvedAppearance = appearance ?? (mounted ? isDark ? "dark" : "light" : "inherit");
45
+ return /* @__PURE__ */ jsx(
46
+ WorkOsWidgets,
47
+ {
48
+ theme: {
49
+ appearance: resolvedAppearance,
50
+ radius,
51
+ scaling
52
+ },
53
+ elements: {
54
+ primaryButton: {
55
+ variant: "solid"
56
+ },
57
+ secondaryButton: {
58
+ variant: "outline"
59
+ }
60
+ },
61
+ children
62
+ }
63
+ );
64
+ }
65
+
66
+ // src/providers/identity-provider.tsx
67
+ import { jsx as jsx2 } from "react/jsx-runtime";
68
+ function IdentityProvider({
69
+ clientId,
70
+ apiHostname,
71
+ devMode,
72
+ redirectUri,
73
+ onRedirectCallback,
74
+ children
75
+ }) {
76
+ const resolvedRedirectUri = redirectUri ?? (typeof window !== "undefined" ? window.location.origin : void 0);
77
+ const handleRedirectCallback = onRedirectCallback ?? (() => {
78
+ if (typeof window !== "undefined") {
79
+ const url = new URL(window.location.href);
80
+ url.searchParams.delete("code");
81
+ url.searchParams.delete("state");
82
+ window.history.replaceState({}, "", url.pathname);
83
+ }
84
+ });
85
+ return /* @__PURE__ */ jsx2(
86
+ AuthKitProvider,
87
+ {
88
+ clientId,
89
+ apiHostname,
90
+ devMode,
91
+ redirectUri: resolvedRedirectUri,
92
+ onRedirectCallback: handleRedirectCallback,
93
+ children: /* @__PURE__ */ jsx2(WidgetsProvider, { children })
94
+ }
95
+ );
96
+ }
97
+
98
+ // src/providers/auth-gate.tsx
99
+ import { useAuth } from "@workos-inc/authkit-react";
100
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
101
+ function DefaultLoadingComponent() {
102
+ return /* @__PURE__ */ jsx3("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-4", children: [
103
+ /* @__PURE__ */ jsx3("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }),
104
+ /* @__PURE__ */ jsx3("p", { className: "text-sm text-muted-foreground", children: "Loading..." })
105
+ ] }) });
106
+ }
107
+ function DefaultLandingPage() {
108
+ const { signIn } = useAuth();
109
+ return /* @__PURE__ */ jsx3("div", { className: "min-h-screen bg-background flex flex-col items-center justify-center p-4", children: /* @__PURE__ */ jsxs("div", { className: "text-center max-w-md", children: [
110
+ /* @__PURE__ */ jsx3("h1", { className: "text-3xl font-bold tracking-tight mb-4", children: "Welcome" }),
111
+ /* @__PURE__ */ jsx3("p", { className: "text-muted-foreground mb-8", children: "Sign in to access your dashboard." }),
112
+ /* @__PURE__ */ jsx3(
113
+ "button",
114
+ {
115
+ type: "button",
116
+ onClick: () => signIn(),
117
+ className: "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius-md)] text-sm font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-6",
118
+ children: "Sign In"
119
+ }
120
+ )
121
+ ] }) });
122
+ }
123
+ function AuthGate({
124
+ children,
125
+ required = true,
126
+ loadingComponent,
127
+ landingComponent,
128
+ onUnauthenticated = "landing",
129
+ redirectUrl
130
+ }) {
131
+ const { user, isLoading } = useAuth();
132
+ if (!required) {
133
+ return /* @__PURE__ */ jsx3(Fragment, { children });
134
+ }
135
+ if (isLoading) {
136
+ return /* @__PURE__ */ jsx3(Fragment, { children: loadingComponent ?? /* @__PURE__ */ jsx3(DefaultLoadingComponent, {}) });
137
+ }
138
+ if (user) {
139
+ return /* @__PURE__ */ jsx3(Fragment, { children });
140
+ }
141
+ switch (onUnauthenticated) {
142
+ case "redirect":
143
+ if (redirectUrl && typeof window !== "undefined") {
144
+ window.location.href = redirectUrl;
145
+ return /* @__PURE__ */ jsx3("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ jsx3("p", { className: "text-sm text-muted-foreground", children: "Redirecting..." }) });
146
+ }
147
+ return /* @__PURE__ */ jsx3(Fragment, { children: landingComponent ?? /* @__PURE__ */ jsx3(DefaultLandingPage, {}) });
148
+ case "allow":
149
+ return /* @__PURE__ */ jsx3(Fragment, { children });
150
+ case "landing":
151
+ default:
152
+ return /* @__PURE__ */ jsx3(Fragment, { children: landingComponent ?? /* @__PURE__ */ jsx3(DefaultLandingPage, {}) });
153
+ }
154
+ }
155
+ export {
156
+ AuthGate,
157
+ IdentityProvider,
158
+ WidgetsProvider,
159
+ useThemeDetection
160
+ };
161
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/providers/identity-provider.tsx","../../src/providers/widgets-provider.tsx","../../src/providers/auth-gate.tsx"],"sourcesContent":["'use client'\n\nimport { AuthKitProvider } from '@workos-inc/authkit-react'\nimport type { IdentityProviderProps } from '../types/auth'\nimport { WidgetsProvider } from './widgets-provider'\n\n/**\n * Identity provider that wraps your app with WorkOS AuthKit authentication.\n *\n * This provider sets up authentication context for your application and\n * automatically includes the WidgetsProvider for WorkOS widgets.\n *\n * @example\n * ```tsx\n * import { IdentityProvider } from '@mdxui/auth'\n *\n * function App() {\n * return (\n * <IdentityProvider\n * clientId=\"client_xxx\"\n * devMode={process.env.NODE_ENV === 'development'}\n * >\n * <YourApp />\n * </IdentityProvider>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom redirect URI\n * <IdentityProvider\n * clientId=\"client_xxx\"\n * redirectUri=\"https://app.example.com/dashboard\"\n * onRedirectCallback={() => {\n * // Custom callback after auth redirect\n * }}\n * >\n * <YourApp />\n * </IdentityProvider>\n * ```\n */\nexport function IdentityProvider({\n clientId,\n apiHostname,\n devMode,\n redirectUri,\n onRedirectCallback,\n children,\n}: IdentityProviderProps) {\n // Build redirect URI - defaults to current origin\n const resolvedRedirectUri =\n redirectUri ??\n (typeof window !== 'undefined' ? window.location.origin : undefined)\n\n // Default redirect callback - clear auth params from URL\n const handleRedirectCallback =\n onRedirectCallback ??\n (() => {\n if (typeof window !== 'undefined') {\n const url = new URL(window.location.href)\n url.searchParams.delete('code')\n url.searchParams.delete('state')\n window.history.replaceState({}, '', url.pathname)\n }\n })\n\n return (\n <AuthKitProvider\n clientId={clientId}\n apiHostname={apiHostname}\n devMode={devMode}\n redirectUri={resolvedRedirectUri}\n onRedirectCallback={handleRedirectCallback}\n >\n <WidgetsProvider>{children}</WidgetsProvider>\n </AuthKitProvider>\n )\n}\n\n/**\n * Minimal identity provider without WidgetsProvider\n *\n * Use this if you want to set up widgets separately or don't need them.\n *\n * @example\n * ```tsx\n * import { IdentityProviderMinimal, WidgetsProvider } from '@mdxui/auth'\n *\n * function App() {\n * return (\n * <IdentityProviderMinimal clientId=\"client_xxx\">\n * <WidgetsProvider appearance=\"dark\">\n * <YourApp />\n * </WidgetsProvider>\n * </IdentityProviderMinimal>\n * )\n * }\n * ```\n */\nexport function IdentityProviderMinimal({\n clientId,\n apiHostname,\n devMode,\n redirectUri,\n onRedirectCallback,\n children,\n}: IdentityProviderProps) {\n const resolvedRedirectUri =\n redirectUri ??\n (typeof window !== 'undefined' ? window.location.origin : undefined)\n\n const handleRedirectCallback =\n onRedirectCallback ??\n (() => {\n if (typeof window !== 'undefined') {\n const url = new URL(window.location.href)\n url.searchParams.delete('code')\n url.searchParams.delete('state')\n window.history.replaceState({}, '', url.pathname)\n }\n })\n\n return (\n <AuthKitProvider\n clientId={clientId}\n apiHostname={apiHostname}\n devMode={devMode}\n redirectUri={resolvedRedirectUri}\n onRedirectCallback={handleRedirectCallback}\n >\n {children}\n </AuthKitProvider>\n )\n}\n","'use client'\n\nimport { WorkOsWidgets } from '@workos-inc/widgets'\nimport { useEffect, useState } from 'react'\nimport type { WidgetsProviderProps } from '../types/auth'\n\n/**\n * Hook to detect dark mode from document class or system preference\n *\n * @returns Object with isDark state and mounted flag\n *\n * @example\n * ```tsx\n * const { isDark, mounted } = useThemeDetection()\n * const appearance = mounted ? (isDark ? 'dark' : 'light') : 'inherit'\n * ```\n */\nexport function useThemeDetection() {\n const [mounted, setMounted] = useState(false)\n const [isDark, setIsDark] = useState(false)\n\n useEffect(() => {\n setMounted(true)\n\n const checkDarkMode = () => {\n const isDarkClass = document.documentElement.classList.contains('dark')\n const prefersDark = window.matchMedia(\n '(prefers-color-scheme: dark)'\n ).matches\n setIsDark(\n isDarkClass ||\n (!document.documentElement.classList.contains('light') && prefersDark)\n )\n }\n\n checkDarkMode()\n\n // Watch for class changes on html element\n const observer = new MutationObserver(checkDarkMode)\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class'],\n })\n\n // Watch for system preference changes\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')\n mediaQuery.addEventListener('change', checkDarkMode)\n\n return () => {\n observer.disconnect()\n mediaQuery.removeEventListener('change', checkDarkMode)\n }\n }, [])\n\n return { isDark, mounted }\n}\n\n/**\n * Provider for WorkOS widgets with automatic theme detection\n *\n * Wraps children with WorkOsWidgets context and automatically detects\n * light/dark mode from document classes or system preference.\n *\n * @example\n * ```tsx\n * import { WidgetsProvider } from '@mdxui/auth'\n * import { UserProfile } from '@mdxui/auth/widgets'\n *\n * function App() {\n * return (\n * <WidgetsProvider>\n * <UserProfile authToken={getAccessToken} />\n * </WidgetsProvider>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With explicit theme\n * <WidgetsProvider appearance=\"dark\" radius=\"large\">\n * <UserProfile authToken={token} />\n * </WidgetsProvider>\n * ```\n */\nexport function WidgetsProvider({\n children,\n appearance,\n radius = 'medium',\n scaling = '100%',\n}: WidgetsProviderProps) {\n const { isDark, mounted } = useThemeDetection()\n\n // Use provided appearance, or auto-detect from theme\n // Use \"inherit\" until mounted to avoid hydration mismatch\n const resolvedAppearance =\n appearance ?? (mounted ? (isDark ? 'dark' : 'light') : 'inherit')\n\n return (\n <WorkOsWidgets\n theme={{\n appearance: resolvedAppearance,\n radius,\n scaling,\n }}\n elements={{\n primaryButton: {\n variant: 'solid',\n },\n secondaryButton: {\n variant: 'outline',\n },\n }}\n >\n {children}\n </WorkOsWidgets>\n )\n}\n","'use client'\n\nimport { useAuth } from '@workos-inc/authkit-react'\nimport type { AuthGateProps } from '../types/auth'\n\n/**\n * Default loading component shown while checking authentication\n */\nfunction DefaultLoadingComponent() {\n return (\n <div className=\"min-h-screen bg-background flex items-center justify-center\">\n <div className=\"flex flex-col items-center gap-4\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n <p className=\"text-sm text-muted-foreground\">Loading...</p>\n </div>\n </div>\n )\n}\n\n/**\n * Default landing page component shown when user is not authenticated\n */\nfunction DefaultLandingPage() {\n const { signIn } = useAuth()\n\n return (\n <div className=\"min-h-screen bg-background flex flex-col items-center justify-center p-4\">\n <div className=\"text-center max-w-md\">\n <h1 className=\"text-3xl font-bold tracking-tight mb-4\">Welcome</h1>\n <p className=\"text-muted-foreground mb-8\">\n Sign in to access your dashboard.\n </p>\n <button\n type=\"button\"\n onClick={() => signIn()}\n className=\"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius-md)] text-sm font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-6\"\n >\n Sign In\n </button>\n </div>\n </div>\n )\n}\n\n/**\n * AuthGate handles authentication state and shows appropriate UI:\n * - Loading state while checking auth\n * - Landing page or redirect when not authenticated\n * - Children (protected content) when authenticated\n *\n * @example\n * ```tsx\n * import { AuthGate } from '@mdxui/auth'\n *\n * function App() {\n * return (\n * <AuthGate>\n * <ProtectedDashboard />\n * </AuthGate>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom components\n * <AuthGate\n * loadingComponent={<CustomSpinner />}\n * landingComponent={<CustomLandingPage />}\n * >\n * <Dashboard />\n * </AuthGate>\n * ```\n *\n * @example\n * ```tsx\n * // Allow unauthenticated access\n * <AuthGate required={false}>\n * <PublicContent />\n * </AuthGate>\n * ```\n *\n * @example\n * ```tsx\n * // Redirect to external URL when not authenticated\n * <AuthGate\n * onUnauthenticated=\"redirect\"\n * redirectUrl=\"https://marketing.example.com\"\n * >\n * <Dashboard />\n * </AuthGate>\n * ```\n */\nexport function AuthGate({\n children,\n required = true,\n loadingComponent,\n landingComponent,\n onUnauthenticated = 'landing',\n redirectUrl,\n}: AuthGateProps) {\n const { user, isLoading } = useAuth()\n\n // If auth is not required, always show children\n if (!required) {\n return <>{children}</>\n }\n\n // Show loading state while checking authentication\n if (isLoading) {\n return <>{loadingComponent ?? <DefaultLoadingComponent />}</>\n }\n\n // User is authenticated, show protected content\n if (user) {\n return <>{children}</>\n }\n\n // User is not authenticated - handle based on config\n switch (onUnauthenticated) {\n case 'redirect':\n // Redirect to external URL\n if (redirectUrl && typeof window !== 'undefined') {\n window.location.href = redirectUrl\n return (\n <div className=\"min-h-screen bg-background flex items-center justify-center\">\n <p className=\"text-sm text-muted-foreground\">Redirecting...</p>\n </div>\n )\n }\n // Fall through to landing if no redirect URL\n return <>{landingComponent ?? <DefaultLandingPage />}</>\n\n case 'allow':\n // Allow access even without auth (shows children)\n return <>{children}</>\n\n case 'landing':\n default:\n // Show landing page (custom or default)\n return <>{landingComponent ?? <DefaultLandingPage />}</>\n }\n}\n"],"mappings":";AAEA,SAAS,uBAAuB;;;ACAhC,SAAS,qBAAqB;AAC9B,SAAS,WAAW,gBAAgB;AAgGhC;AAlFG,SAAS,oBAAoB;AAClC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,KAAK;AAE1C,YAAU,MAAM;AACd,eAAW,IAAI;AAEf,UAAM,gBAAgB,MAAM;AAC1B,YAAM,cAAc,SAAS,gBAAgB,UAAU,SAAS,MAAM;AACtE,YAAM,cAAc,OAAO;AAAA,QACzB;AAAA,MACF,EAAE;AACF;AAAA,QACE,eACG,CAAC,SAAS,gBAAgB,UAAU,SAAS,OAAO,KAAK;AAAA,MAC9D;AAAA,IACF;AAEA,kBAAc;AAGd,UAAM,WAAW,IAAI,iBAAiB,aAAa;AACnD,aAAS,QAAQ,SAAS,iBAAiB;AAAA,MACzC,YAAY;AAAA,MACZ,iBAAiB,CAAC,OAAO;AAAA,IAC3B,C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+DACb,0BAAAA,KAAC,OAAE,WAAU,iCAAgC,4BAAc,GAC7D;AAAA,MAEJ;AAEA,aAAO,gBAAAA,KAAA,YAAG,8BAAoB,gBAAAA,KAAC,sBAAmB,GAAG;AAAA,IAEvD,KAAK;AAEH,aAAO,gBAAAA,KAAA,YAAG,UAAS;AAAA,IAErB,KAAK;AAAA,IACL;AAEE,aAAO,gBAAAA,KAAA,YAAG,8BAAoB,gBAAAA,KAAC,sBAAmB,GAAG;AAAA,EACzD;AACF;","names":["jsx","jsx"]}
@@ -0,0 +1,151 @@
1
+ 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';
2
+ import { z } from 'zod';
3
+ import 'zod/v4/core';
4
+
5
+ /**
6
+ * Provider Props Schemas
7
+ *
8
+ * Zod schemas for authentication provider component props.
9
+ */
10
+
11
+ /**
12
+ * IdentityProviderPropsSchema - Props for IdentityProvider component
13
+ */
14
+ declare const IdentityProviderPropsSchema: z.ZodObject<{
15
+ clientId: z.ZodString;
16
+ apiHostname: z.ZodOptional<z.ZodString>;
17
+ devMode: z.ZodOptional<z.ZodBoolean>;
18
+ redirectUri: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strip>;
20
+ type IdentityProviderPropsSchemaType = z.infer<typeof IdentityProviderPropsSchema>;
21
+ /**
22
+ * UnauthenticatedActionSchema - What to do when unauthenticated
23
+ */
24
+ declare const UnauthenticatedActionSchema: z.ZodEnum<{
25
+ landing: "landing";
26
+ redirect: "redirect";
27
+ allow: "allow";
28
+ }>;
29
+ type UnauthenticatedAction = z.infer<typeof UnauthenticatedActionSchema>;
30
+ /**
31
+ * AuthGatePropsSchema - Props for AuthGate component
32
+ */
33
+ declare const AuthGatePropsSchema: z.ZodObject<{
34
+ required: z.ZodOptional<z.ZodBoolean>;
35
+ onUnauthenticated: z.ZodOptional<z.ZodEnum<{
36
+ landing: "landing";
37
+ redirect: "redirect";
38
+ allow: "allow";
39
+ }>>;
40
+ redirectUrl: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strip>;
42
+ type AuthGatePropsSchemaType = z.infer<typeof AuthGatePropsSchema>;
43
+ /**
44
+ * AppearanceSchema - Theme appearance mode
45
+ */
46
+ declare const AppearanceSchema: z.ZodEnum<{
47
+ light: "light";
48
+ dark: "dark";
49
+ inherit: "inherit";
50
+ }>;
51
+ type Appearance = z.infer<typeof AppearanceSchema>;
52
+ /**
53
+ * RadiusSchema - Border radius style
54
+ */
55
+ declare const RadiusSchema: z.ZodEnum<{
56
+ none: "none";
57
+ small: "small";
58
+ medium: "medium";
59
+ large: "large";
60
+ full: "full";
61
+ }>;
62
+ type Radius = z.infer<typeof RadiusSchema>;
63
+ /**
64
+ * ScalingSchema - Scaling factor
65
+ */
66
+ declare const ScalingSchema: z.ZodEnum<{
67
+ "90%": "90%";
68
+ "95%": "95%";
69
+ "100%": "100%";
70
+ "105%": "105%";
71
+ "110%": "110%";
72
+ }>;
73
+ type Scaling = z.infer<typeof ScalingSchema>;
74
+ /**
75
+ * WidgetsProviderPropsSchema - Props for WidgetsProvider component
76
+ */
77
+ declare const WidgetsProviderPropsSchema: z.ZodObject<{
78
+ appearance: z.ZodOptional<z.ZodEnum<{
79
+ light: "light";
80
+ dark: "dark";
81
+ inherit: "inherit";
82
+ }>>;
83
+ radius: z.ZodOptional<z.ZodEnum<{
84
+ none: "none";
85
+ small: "small";
86
+ medium: "medium";
87
+ large: "large";
88
+ full: "full";
89
+ }>>;
90
+ scaling: z.ZodOptional<z.ZodEnum<{
91
+ "90%": "90%";
92
+ "95%": "95%";
93
+ "100%": "100%";
94
+ "105%": "105%";
95
+ "110%": "110%";
96
+ }>>;
97
+ }, z.core.$strip>;
98
+ type WidgetsProviderPropsSchemaType = z.infer<typeof WidgetsProviderPropsSchema>;
99
+
100
+ /**
101
+ * Widget Props Schemas
102
+ *
103
+ * Zod schemas for WorkOS widget component props.
104
+ */
105
+
106
+ /**
107
+ * AuthTokenSchema - Auth token type
108
+ *
109
+ * Can be a string or a function that returns a Promise<string>.
110
+ * Functions are represented as 'function' string in schema validation
111
+ * since Zod can't validate function signatures.
112
+ */
113
+ declare const AuthTokenSchema: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"function">]>;
114
+ type AuthTokenSchemaType = z.infer<typeof AuthTokenSchema>;
115
+ /**
116
+ * BaseWidgetPropsSchema - Common props for all widget wrappers
117
+ */
118
+ declare const BaseWidgetPropsSchema: z.ZodObject<{
119
+ authToken: z.ZodString;
120
+ className: z.ZodOptional<z.ZodString>;
121
+ }, z.core.$strip>;
122
+ type BaseWidgetPropsSchemaType = z.infer<typeof BaseWidgetPropsSchema>;
123
+ /**
124
+ * OrganizationWidgetPropsSchema - Props for widgets that support organization context
125
+ */
126
+ declare const OrganizationWidgetPropsSchema: z.ZodObject<{
127
+ authToken: z.ZodString;
128
+ className: z.ZodOptional<z.ZodString>;
129
+ organizationId: z.ZodOptional<z.ZodString>;
130
+ }, z.core.$strip>;
131
+ type OrganizationWidgetPropsSchemaType = z.infer<typeof OrganizationWidgetPropsSchema>;
132
+ /**
133
+ * UseWidgetTokenOptionsSchema - Props for useWidgetToken hook
134
+ */
135
+ declare const UseWidgetTokenOptionsSchema: z.ZodObject<{
136
+ widget: z.ZodString;
137
+ organizationId: z.ZodOptional<z.ZodString>;
138
+ endpoint: z.ZodOptional<z.ZodString>;
139
+ }, z.core.$strip>;
140
+ type UseWidgetTokenOptionsSchemaType = z.infer<typeof UseWidgetTokenOptionsSchema>;
141
+ /**
142
+ * UseWidgetTokenResultSchema - Result from useWidgetToken hook
143
+ */
144
+ declare const UseWidgetTokenResultSchema: z.ZodObject<{
145
+ token: z.ZodNullable<z.ZodString>;
146
+ loading: z.ZodBoolean;
147
+ error: z.ZodNullable<z.ZodString>;
148
+ }, z.core.$strip>;
149
+ type UseWidgetTokenResultSchemaType = z.infer<typeof UseWidgetTokenResultSchema>;
150
+
151
+ export { type Appearance, AppearanceSchema, AuthGatePropsSchema, type AuthGatePropsSchemaType, AuthTokenSchema, type AuthTokenSchemaType, BaseWidgetPropsSchema, type BaseWidgetPropsSchemaType, IdentityProviderPropsSchema, type IdentityProviderPropsSchemaType, OrganizationWidgetPropsSchema, type OrganizationWidgetPropsSchemaType, type Radius, RadiusSchema, type Scaling, ScalingSchema, type UnauthenticatedAction, UnauthenticatedActionSchema, UseWidgetTokenOptionsSchema, type UseWidgetTokenOptionsSchemaType, UseWidgetTokenResultSchema, type UseWidgetTokenResultSchemaType, WidgetsProviderPropsSchema, type WidgetsProviderPropsSchemaType };
@@ -0,0 +1,143 @@
1
+ // src/schemas/auth-user.ts
2
+ import { z } from "zod";
3
+ import { UserIdentitySchema } from "mdxui/zod";
4
+ var AuthUserSchema = UserIdentitySchema.extend({
5
+ // Override to be more specific (WorkOS guarantees string ID)
6
+ id: z.string().describe("User ID from WorkOS"),
7
+ // WorkOS requires email (not optional like UserIdentity)
8
+ email: z.string().email().describe("Email address"),
9
+ // WorkOS-specific fields not in UserIdentity
10
+ emailVerified: z.boolean().describe("Email verification status"),
11
+ // Timestamps
12
+ createdAt: z.string().datetime().describe("Account creation timestamp"),
13
+ updatedAt: z.string().datetime().describe("Last update timestamp"),
14
+ lastSignInAt: z.string().datetime().nullable().optional().describe("Last sign-in timestamp")
15
+ });
16
+
17
+ // src/schemas/auth-session.ts
18
+ import { z as z2 } from "zod";
19
+ import { SessionSchema } from "mdxui/zod";
20
+ var ImpersonatorSchema = z2.object({
21
+ /** Impersonator's email address */
22
+ email: z2.string().email().describe("Impersonator's email address"),
23
+ /** Reason for impersonation */
24
+ reason: z2.string().optional().describe("Reason for impersonation")
25
+ });
26
+ var AuthSessionSchema = SessionSchema.extend({
27
+ // Override userId to be string (WorkOS uses string IDs)
28
+ userId: z2.string().describe("User ID"),
29
+ // WorkOS-specific: impersonation support
30
+ impersonator: ImpersonatorSchema.optional().describe(
31
+ "Impersonator info (if being impersonated)"
32
+ )
33
+ });
34
+
35
+ // src/schemas/auth-organization.ts
36
+ import { z as z3 } from "zod";
37
+ var AuthOrganizationSchema = z3.object({
38
+ /** Organization ID */
39
+ id: z3.string().describe("Organization ID"),
40
+ /** Organization display name */
41
+ name: z3.string().describe("Organization name"),
42
+ /** Organization slug (URL-friendly identifier) */
43
+ slug: z3.string().optional().describe("Organization slug"),
44
+ /** Organization logo URL */
45
+ logoUrl: z3.string().url().optional().describe("Organization logo URL"),
46
+ /** Whether the organization is active */
47
+ active: z3.boolean().optional().describe("Whether organization is active"),
48
+ /** Custom domains for the organization */
49
+ domains: z3.array(z3.string()).optional().describe("Custom domains for the organization"),
50
+ /** Additional metadata */
51
+ metadata: z3.record(z3.string(), z3.unknown()).optional().describe("Additional metadata")
52
+ });
53
+
54
+ // src/schemas/provider-props.ts
55
+ import { z as z4 } from "zod";
56
+ var IdentityProviderPropsSchema = z4.object({
57
+ /** WorkOS client ID */
58
+ clientId: z4.string().describe("WorkOS client ID"),
59
+ /** Optional API hostname override */
60
+ apiHostname: z4.string().optional().describe("Optional API hostname override"),
61
+ /** Enable dev mode for local development */
62
+ devMode: z4.boolean().optional().describe("Enable dev mode for local development"),
63
+ /** Redirect URI after authentication */
64
+ redirectUri: z4.string().url().optional().describe("Redirect URI after authentication")
65
+ /** Note: onRedirectCallback and children are React-specific, not in schema */
66
+ });
67
+ var UnauthenticatedActionSchema = z4.enum(["landing", "redirect", "allow"]);
68
+ var AuthGatePropsSchema = z4.object({
69
+ /** Whether authentication is required (default: true) */
70
+ required: z4.boolean().optional().describe("Whether authentication is required"),
71
+ /** What to do when unauthenticated */
72
+ onUnauthenticated: UnauthenticatedActionSchema.optional().describe(
73
+ "What to do when unauthenticated"
74
+ ),
75
+ /** URL to redirect to when unauthenticated (if onUnauthenticated is "redirect") */
76
+ redirectUrl: z4.string().url().optional().describe("URL to redirect to when unauthenticated")
77
+ /** Note: children, loadingComponent, landingComponent are React-specific */
78
+ });
79
+ var AppearanceSchema = z4.enum(["light", "dark", "inherit"]);
80
+ var RadiusSchema = z4.enum(["none", "small", "medium", "large", "full"]);
81
+ var ScalingSchema = z4.enum(["90%", "95%", "100%", "105%", "110%"]);
82
+ var WidgetsProviderPropsSchema = z4.object({
83
+ /** Theme appearance mode */
84
+ appearance: AppearanceSchema.optional().describe("Theme appearance mode"),
85
+ /** Border radius style */
86
+ radius: RadiusSchema.optional().describe("Border radius style"),
87
+ /** Scaling factor */
88
+ scaling: ScalingSchema.optional().describe("Scaling factor")
89
+ /** Note: children is React-specific, not in schema */
90
+ });
91
+
92
+ // src/schemas/widget-props.ts
93
+ import { z as z5 } from "zod";
94
+ var AuthTokenSchema = z5.union([
95
+ z5.string().describe("Static auth token"),
96
+ z5.literal("function").describe("Token getter function")
97
+ ]);
98
+ var BaseWidgetPropsSchema = z5.object({
99
+ /** Auth token for the widget (string or getter function) */
100
+ authToken: z5.string().describe("Auth token for the widget"),
101
+ /** CSS class name */
102
+ className: z5.string().optional().describe("CSS class name")
103
+ });
104
+ var OrganizationWidgetPropsSchema = BaseWidgetPropsSchema.extend({
105
+ /** Organization ID for org-scoped widgets */
106
+ organizationId: z5.string().optional().describe("Organization ID for org-scoped widgets")
107
+ });
108
+ var UseWidgetTokenOptionsSchema = z5.object({
109
+ /** Widget type to fetch token for */
110
+ widget: z5.string().describe("Widget type to fetch token for"),
111
+ /** Organization ID for org-scoped widgets */
112
+ organizationId: z5.string().optional().describe("Organization ID for org-scoped widgets"),
113
+ /** Custom endpoint for fetching widget token */
114
+ endpoint: z5.string().url().optional().describe("Custom endpoint for fetching widget token")
115
+ });
116
+ var UseWidgetTokenResultSchema = z5.object({
117
+ /** The fetched token */
118
+ token: z5.string().nullable().describe("The fetched token"),
119
+ /** Whether token is being fetched */
120
+ loading: z5.boolean().describe("Whether token is being fetched"),
121
+ /** Error message if fetch failed */
122
+ error: z5.string().nullable().describe("Error message if fetch failed")
123
+ /** Note: refetch function is React-specific, not in schema */
124
+ });
125
+ export {
126
+ AppearanceSchema,
127
+ AuthGatePropsSchema,
128
+ AuthOrganizationSchema,
129
+ AuthSessionSchema,
130
+ AuthTokenSchema,
131
+ AuthUserSchema,
132
+ BaseWidgetPropsSchema,
133
+ IdentityProviderPropsSchema,
134
+ ImpersonatorSchema,
135
+ OrganizationWidgetPropsSchema,
136
+ RadiusSchema,
137
+ ScalingSchema,
138
+ UnauthenticatedActionSchema,
139
+ UseWidgetTokenOptionsSchema,
140
+ UseWidgetTokenResultSchema,
141
+ WidgetsProviderPropsSchema
142
+ };
143
+ //# sourceMappingURL=index.js.map