@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/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":["/**\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":";AAQA,SAAS,SAAS;AAClB,SAAS,0BAA0B;AAkB5B,IAAM,iBAAiB,mBAAmB,OAAO;AAAA;AAAA,EAEtD,IAAI,EAAE,OAAO,EAAE,SAAS,qBAAqB;AAAA;AAAA,EAG7C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,eAAe;AAAA;AAAA,EAGlD,eAAe,EAAE,QAAQ,EAAE,SAAS,2BAA2B;AAAA;AAAA,EAG/D,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,4BAA4B;AAAA,EACtE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,uBAAuB;AAAA,EACjE,cAAc,EACX,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,wBAAwB;AACtC,CAAC;;;ACxCD,SAAS,KAAAA,UAAS;AAClB,SAAS,qBAAqB;AAKvB,IAAM,qBAAqBA,GAAE,OAAO;AAAA;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AO;AAAA;AAAA,EAExE,gBAAgBA,GACb,OAAO,EACP,SAAS,EACT,SAAS,wCAAwC;AACtD,CAAC;AASM,IAAM,8BAA8BA,GAAE,OAAO;AAAA;AAAA,EAElD,QAAQA,GAAE,OAAO,EAAE,SAAS,gCAAgC;AAAA;AAAA,EAE5D,gBAAgBA,GACb,OAAO,EACP,SAAS,EACT,SAAS,wCAAwC;AAAA;AAAA,EAEpD,UAAUA,GACP,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,2CAA2C;AACzD,CAAC;AAOM,IAAM,6BAA6BA,GAAE,OAAO;AAAA;AAAA,EAEjD,OAAOA,GAAE,OAAO,EAAE,SAAS,EAAE,SAAS,mBAAmB;AAAA;AAAA,EAEzD,SAASA,GAAE,QAAQ,EAAE,SAAS,gCAAgC;AAAA;AAAA,EAE9D,OAAOA,GAAE,OAAO,EAAE,SAAS,EAAE,SAAS,+BAA+B;AAAA;AAEvE,CAAC;","names":["z","z","z","z"]}
@@ -0,0 +1,5 @@
1
+ export { A as AuthGateProps, a as AuthToken, B as BaseWidgetProps, I as IdentityProviderProps, O as OrganizationWidgetProps, U as UseWidgetTokenOptions, b as UseWidgetTokenResult, W as WidgetsProviderProps } from '../auth-Ba2f778e.js';
2
+ export { a as AuthOrganization, b as AuthSession, A as AuthUser, I as Impersonator } from '../auth-organization-CN1WpGnL.js';
3
+ import 'react';
4
+ import 'zod/v4/core';
5
+ import 'zod';
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,250 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { B as BaseWidgetProps } from '../auth-Ba2f778e.js';
3
+ import 'react';
4
+
5
+ /**
6
+ * User Profile Widget
7
+ *
8
+ * Displays and allows editing of user profile information:
9
+ * - Profile picture
10
+ * - Name and email
11
+ * - Connected accounts (OAuth providers)
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * // With AuthKit (recommended)
16
+ * import { useAuth } from '@mdxui/auth'
17
+ * import { UserProfile } from '@mdxui/auth/widgets'
18
+ *
19
+ * function ProfilePage() {
20
+ * const { getAccessToken } = useAuth()
21
+ * return <UserProfile authToken={getAccessToken} />
22
+ * }
23
+ * ```
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * // With string token
28
+ * <UserProfile authToken={myToken} />
29
+ * ```
30
+ */
31
+ declare function UserProfile({ authToken, className }: BaseWidgetProps): react_jsx_runtime.JSX.Element;
32
+
33
+ /**
34
+ * User Security Widget
35
+ *
36
+ * Allows users to manage their security settings:
37
+ * - Password management
38
+ * - Multi-factor authentication (MFA)
39
+ * - Connected authentication methods
40
+ * - Security keys
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * // With AuthKit (recommended)
45
+ * import { useAuth } from '@mdxui/auth'
46
+ * import { UserSecurity } from '@mdxui/auth/widgets'
47
+ *
48
+ * function SecurityPage() {
49
+ * const { getAccessToken } = useAuth()
50
+ * return <UserSecurity authToken={getAccessToken} />
51
+ * }
52
+ * ```
53
+ */
54
+ declare function UserSecurity({ authToken, className }: BaseWidgetProps): react_jsx_runtime.JSX.Element;
55
+
56
+ /**
57
+ * Props for UserSessions with function token (no currentSessionId needed)
58
+ */
59
+ interface UserSessionsWithFunctionTokenProps {
60
+ /** Auth token getter function */
61
+ authToken: () => Promise<string>;
62
+ /** CSS class name */
63
+ className?: string;
64
+ }
65
+ /**
66
+ * Props for UserSessions with string token (currentSessionId required)
67
+ */
68
+ interface UserSessionsWithStringTokenProps {
69
+ /** Auth token string */
70
+ authToken: string;
71
+ /** Current session ID (required when using string token) */
72
+ currentSessionId: string;
73
+ /** CSS class name */
74
+ className?: string;
75
+ }
76
+ type UserSessionsProps = UserSessionsWithFunctionTokenProps | UserSessionsWithStringTokenProps;
77
+ /**
78
+ * User Sessions Widget
79
+ *
80
+ * Displays and manages active user sessions:
81
+ * - View all active sessions
82
+ * - See session details (device, location, last active)
83
+ * - Revoke sessions
84
+ *
85
+ * @example
86
+ * ```tsx
87
+ * // With AuthKit (recommended) - no currentSessionId needed
88
+ * import { useAuth } from '@mdxui/auth'
89
+ * import { UserSessions } from '@mdxui/auth/widgets'
90
+ *
91
+ * function SessionsPage() {
92
+ * const { getAccessToken } = useAuth()
93
+ * return <UserSessions authToken={getAccessToken} />
94
+ * }
95
+ * ```
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * // With string token - currentSessionId required
100
+ * <UserSessions authToken={token} currentSessionId={sessionId} />
101
+ * ```
102
+ */
103
+ declare function UserSessions(props: UserSessionsProps): react_jsx_runtime.JSX.Element;
104
+
105
+ /**
106
+ * API Keys Widget
107
+ *
108
+ * Displays and manages API keys:
109
+ * - Create new API keys with specific permissions
110
+ * - View existing API keys
111
+ * - Revoke API keys
112
+ *
113
+ * Requires the `widgets:api-keys:manage` permission.
114
+ * Organization context is derived from the auth token.
115
+ *
116
+ * @example
117
+ * ```tsx
118
+ * // With AuthKit (recommended)
119
+ * import { useAuth } from '@mdxui/auth'
120
+ * import { ApiKeys } from '@mdxui/auth/widgets'
121
+ *
122
+ * function ApiKeysPage() {
123
+ * const { getAccessToken } = useAuth()
124
+ * return <ApiKeys authToken={getAccessToken} />
125
+ * }
126
+ * ```
127
+ */
128
+ declare function ApiKeys({ authToken, className }: BaseWidgetProps): react_jsx_runtime.JSX.Element;
129
+
130
+ interface UsersManagementProps extends BaseWidgetProps {
131
+ /**
132
+ * Organization ID for scoping the user management.
133
+ *
134
+ * This is typically used to verify organization context in the parent component.
135
+ * The actual organization scope comes from the auth token.
136
+ */
137
+ organizationId?: string;
138
+ }
139
+ /**
140
+ * Users Management Widget (Team Page)
141
+ *
142
+ * Allows organization admins to manage team members:
143
+ * - View organization members
144
+ * - Invite new members
145
+ * - Update member roles
146
+ * - Remove members
147
+ *
148
+ * Requires the `widgets:users-table:manage` permission and organization context.
149
+ *
150
+ * @example
151
+ * ```tsx
152
+ * // With AuthKit (recommended)
153
+ * import { useAuth } from '@mdxui/auth'
154
+ * import { UsersManagement } from '@mdxui/auth/widgets'
155
+ *
156
+ * function TeamPage() {
157
+ * const { getAccessToken, organizationId, permissions } = useAuth()
158
+ *
159
+ * if (!organizationId) {
160
+ * return <p>You need to be in an organization.</p>
161
+ * }
162
+ *
163
+ * if (!permissions?.includes('widgets:users-table:manage')) {
164
+ * return <p>You need admin permissions.</p>
165
+ * }
166
+ *
167
+ * return (
168
+ * <UsersManagement
169
+ * authToken={getAccessToken}
170
+ * organizationId={organizationId}
171
+ * />
172
+ * )
173
+ * }
174
+ * ```
175
+ */
176
+ declare function UsersManagement({ authToken, organizationId: _organizationId, className, }: UsersManagementProps): react_jsx_runtime.JSX.Element;
177
+
178
+ /**
179
+ * Pipes Widget (Integrations)
180
+ *
181
+ * Allows users to manage third-party integrations:
182
+ * - Connect external services
183
+ * - View connected integrations
184
+ * - Manage integration settings
185
+ * - Disconnect integrations
186
+ *
187
+ * @example
188
+ * ```tsx
189
+ * // With AuthKit (recommended)
190
+ * import { useAuth } from '@mdxui/auth'
191
+ * import { Pipes } from '@mdxui/auth/widgets'
192
+ *
193
+ * function IntegrationsPage() {
194
+ * const { getAccessToken } = useAuth()
195
+ * return <Pipes authToken={getAccessToken} />
196
+ * }
197
+ * ```
198
+ */
199
+ declare function Pipes({ authToken, className }: BaseWidgetProps): react_jsx_runtime.JSX.Element;
200
+
201
+ type OrganizationSwitcherVariant = 'ghost' | 'outline';
202
+ interface OrganizationSwitcherProps {
203
+ /** Auth token getter function */
204
+ authToken: () => Promise<string>;
205
+ /**
206
+ * Function to switch to a different organization.
207
+ * Receives an object with organizationId.
208
+ */
209
+ switchToOrganization: (args: {
210
+ organizationId: string;
211
+ }) => void | Promise<void>;
212
+ /** Visual variant of the switcher */
213
+ variant?: OrganizationSwitcherVariant;
214
+ /** Custom organization label */
215
+ organizationLabel?: string | null;
216
+ /** Where to truncate long organization names */
217
+ truncateBehavior?: 'right' | 'middle';
218
+ /** CSS class name */
219
+ className?: string;
220
+ }
221
+ /**
222
+ * Organization Switcher Widget
223
+ *
224
+ * Allows users to switch between organizations they belong to.
225
+ *
226
+ * @example
227
+ * ```tsx
228
+ * import { useAuth } from '@mdxui/auth'
229
+ * import { OrganizationSwitcher } from '@mdxui/auth/widgets'
230
+ *
231
+ * function OrgSwitcher() {
232
+ * const { getAccessToken, switchToOrganization } = useAuth()
233
+ *
234
+ * // Adapt the function signature
235
+ * const handleSwitch = ({ organizationId }: { organizationId: string }) => {
236
+ * return switchToOrganization(organizationId)
237
+ * }
238
+ *
239
+ * return (
240
+ * <OrganizationSwitcher
241
+ * authToken={getAccessToken}
242
+ * switchToOrganization={handleSwitch}
243
+ * />
244
+ * )
245
+ * }
246
+ * ```
247
+ */
248
+ declare function OrganizationSwitcher({ authToken, switchToOrganization, variant, organizationLabel, truncateBehavior, className, }: OrganizationSwitcherProps): react_jsx_runtime.JSX.Element;
249
+
250
+ export { ApiKeys, OrganizationSwitcher, Pipes, UserProfile, UserSecurity, UserSessions, UsersManagement };
@@ -0,0 +1,79 @@
1
+ // src/widgets/user-profile.tsx
2
+ import { UserProfile as WorkOSUserProfile } from "@workos-inc/widgets";
3
+ import { jsx } from "react/jsx-runtime";
4
+ function UserProfile({ authToken, className }) {
5
+ return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(WorkOSUserProfile, { authToken }) });
6
+ }
7
+
8
+ // src/widgets/user-security.tsx
9
+ import { UserSecurity as WorkOSUserSecurity } from "@workos-inc/widgets";
10
+ import { jsx as jsx2 } from "react/jsx-runtime";
11
+ function UserSecurity({ authToken, className }) {
12
+ return /* @__PURE__ */ jsx2("div", { className, children: /* @__PURE__ */ jsx2(WorkOSUserSecurity, { authToken }) });
13
+ }
14
+
15
+ // src/widgets/user-sessions.tsx
16
+ import { UserSessions as WorkOSUserSessions } from "@workos-inc/widgets";
17
+ import { jsx as jsx3 } from "react/jsx-runtime";
18
+ function UserSessions(props) {
19
+ const { className, ...rest } = props;
20
+ return /* @__PURE__ */ jsx3("div", { className, children: /* @__PURE__ */ jsx3(WorkOSUserSessions, { ...rest }) });
21
+ }
22
+
23
+ // src/widgets/api-keys.tsx
24
+ import { ApiKeys as WorkOSApiKeys } from "@workos-inc/widgets";
25
+ import { jsx as jsx4 } from "react/jsx-runtime";
26
+ function ApiKeys({ authToken, className }) {
27
+ return /* @__PURE__ */ jsx4("div", { className, children: /* @__PURE__ */ jsx4(WorkOSApiKeys, { authToken }) });
28
+ }
29
+
30
+ // src/widgets/users-management.tsx
31
+ import { UsersManagement as WorkOSUsersManagement } from "@workos-inc/widgets";
32
+ import { jsx as jsx5 } from "react/jsx-runtime";
33
+ function UsersManagement({
34
+ authToken,
35
+ organizationId: _organizationId,
36
+ className
37
+ }) {
38
+ return /* @__PURE__ */ jsx5("div", { className, children: /* @__PURE__ */ jsx5(WorkOSUsersManagement, { authToken }) });
39
+ }
40
+
41
+ // src/widgets/pipes.tsx
42
+ import { Pipes as WorkOSPipes } from "@workos-inc/widgets";
43
+ import { jsx as jsx6 } from "react/jsx-runtime";
44
+ function Pipes({ authToken, className }) {
45
+ return /* @__PURE__ */ jsx6("div", { className, children: /* @__PURE__ */ jsx6(WorkOSPipes, { authToken }) });
46
+ }
47
+
48
+ // src/widgets/organization-switcher.tsx
49
+ import { OrganizationSwitcher as WorkOSOrganizationSwitcher } from "@workos-inc/widgets";
50
+ import { jsx as jsx7 } from "react/jsx-runtime";
51
+ function OrganizationSwitcher({
52
+ authToken,
53
+ switchToOrganization,
54
+ variant,
55
+ organizationLabel,
56
+ truncateBehavior,
57
+ className
58
+ }) {
59
+ return /* @__PURE__ */ jsx7("div", { className, children: /* @__PURE__ */ jsx7(
60
+ WorkOSOrganizationSwitcher,
61
+ {
62
+ authToken,
63
+ switchToOrganization,
64
+ variant,
65
+ organizationLabel,
66
+ truncateBehavior
67
+ }
68
+ ) });
69
+ }
70
+ export {
71
+ ApiKeys,
72
+ OrganizationSwitcher,
73
+ Pipes,
74
+ UserProfile,
75
+ UserSecurity,
76
+ UserSessions,
77
+ UsersManagement
78
+ };
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../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"],"sourcesContent":["'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"],"mappings":";AAEA,SAAS,eAAe,yBAAyB;AAgC3C;AAHC,SAAS,YAAY,EAAE,WAAW,UAAU,GAAoB;AACrE,SACE,oBAAC,SAAI,WACH,8BAAC,qBAAkB,WAAsB,GAC3C;AAEJ;;;ACnCA,SAAS,gBAAgB,0BAA0B;AA2B7C,gBAAAA,YAAA;AAHC,SAA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
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@mdxui/auth",
3
+ "version": "1.1.0",
4
+ "description": "Authentication components and WorkOS AuthKit wrappers for mdxui",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "license": "MIT",
8
+ "author": "dot.do",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/dot-do/ui.git",
12
+ "directory": "packages/auth"
13
+ },
14
+ "homepage": "https://mdxui.dev",
15
+ "bugs": {
16
+ "url": "https://github.com/dot-do/ui/issues"
17
+ },
18
+ "keywords": [
19
+ "mdxui",
20
+ "react",
21
+ "auth",
22
+ "authentication",
23
+ "workos",
24
+ "authkit",
25
+ "identity"
26
+ ],
27
+ "main": "./dist/index.js",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js"
34
+ },
35
+ "./providers": {
36
+ "types": "./dist/providers/index.d.ts",
37
+ "import": "./dist/providers/index.js"
38
+ },
39
+ "./widgets": {
40
+ "types": "./dist/widgets/index.d.ts",
41
+ "import": "./dist/widgets/index.js"
42
+ },
43
+ "./components": {
44
+ "types": "./dist/components/index.d.ts",
45
+ "import": "./dist/components/index.js"
46
+ },
47
+ "./hooks": {
48
+ "types": "./dist/hooks/index.d.ts",
49
+ "import": "./dist/hooks/index.js"
50
+ },
51
+ "./types": {
52
+ "types": "./dist/types/index.d.ts",
53
+ "import": "./dist/types/index.js"
54
+ },
55
+ "./schemas": {
56
+ "types": "./dist/schemas/index.d.ts",
57
+ "import": "./dist/schemas/index.js"
58
+ }
59
+ },
60
+ "files": [
61
+ "dist",
62
+ "README.md"
63
+ ],
64
+ "devDependencies": {
65
+ "@testing-library/jest-dom": "^6.6.3",
66
+ "@testing-library/react": "^16.3.0",
67
+ "@types/react": "^19.2.7",
68
+ "@types/react-dom": "^19.2.3",
69
+ "@vitejs/plugin-react": "^5.1.2",
70
+ "jsdom": "^26.1.0",
71
+ "tsup": "^8.0.0",
72
+ "typescript": "5.9.3",
73
+ "vitest": "^3.2.4",
74
+ "@mdxui/typescript-config": "6.0.0"
75
+ },
76
+ "dependencies": {
77
+ "@workos-inc/authkit-react": "^0.16.0",
78
+ "@workos-inc/widgets": "^1.7.2",
79
+ "zod": "^4.3.5",
80
+ "mdxui": "6.0.0"
81
+ },
82
+ "peerDependencies": {
83
+ "react": "^18.0.0 || ^19.0.0",
84
+ "react-dom": "^18.0.0 || ^19.0.0"
85
+ },
86
+ "publishConfig": {
87
+ "access": "public"
88
+ },
89
+ "scripts": {
90
+ "build": "tsup",
91
+ "test": "vitest",
92
+ "test:run": "vitest run",
93
+ "typecheck": "tsc --noEmit",
94
+ "clean": "rm -rf dist .turbo node_modules"
95
+ }
96
+ }