@mdxui/auth 1.1.1 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +223 -0
- package/dist/{auth-Ba2f778e.d.ts → auth-maeYSYU_.d.ts} +4 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/{index-DGthQxCM.d.ts → index-BOMpMKyG.d.ts} +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +794 -4
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js +16 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.js +1 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/shell/index.d.ts +675 -0
- package/dist/shell/index.js +1025 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/widgets/index.d.ts +1 -1
- package/package.json +21 -14
package/dist/index.js
CHANGED
|
@@ -125,6 +125,7 @@ function IdentityProviderMinimal({
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// src/providers/auth-gate.tsx
|
|
128
|
+
import { useEffect as useEffect2, useRef } from "react";
|
|
128
129
|
import { useAuth } from "@workos-inc/authkit-react";
|
|
129
130
|
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
130
131
|
function DefaultLoadingComponent() {
|
|
@@ -157,7 +158,19 @@ function AuthGate({
|
|
|
157
158
|
onUnauthenticated = "landing",
|
|
158
159
|
redirectUrl
|
|
159
160
|
}) {
|
|
160
|
-
const { user, isLoading } = useAuth();
|
|
161
|
+
const { user, isLoading, signIn } = useAuth();
|
|
162
|
+
const signInCalled = useRef(false);
|
|
163
|
+
useEffect2(() => {
|
|
164
|
+
if (onUnauthenticated === "signIn" && !isLoading && !user && !signInCalled.current) {
|
|
165
|
+
signInCalled.current = true;
|
|
166
|
+
signIn();
|
|
167
|
+
}
|
|
168
|
+
}, [onUnauthenticated, isLoading, user, signIn]);
|
|
169
|
+
useEffect2(() => {
|
|
170
|
+
if (user) {
|
|
171
|
+
signInCalled.current = false;
|
|
172
|
+
}
|
|
173
|
+
}, [user]);
|
|
161
174
|
if (!required) {
|
|
162
175
|
return /* @__PURE__ */ jsx3(Fragment, { children });
|
|
163
176
|
}
|
|
@@ -168,6 +181,8 @@ function AuthGate({
|
|
|
168
181
|
return /* @__PURE__ */ jsx3(Fragment, { children });
|
|
169
182
|
}
|
|
170
183
|
switch (onUnauthenticated) {
|
|
184
|
+
case "signIn":
|
|
185
|
+
return /* @__PURE__ */ jsx3(Fragment, { children: loadingComponent ?? /* @__PURE__ */ jsx3(DefaultLoadingComponent, {}) });
|
|
171
186
|
case "redirect":
|
|
172
187
|
if (redirectUrl && typeof window !== "undefined") {
|
|
173
188
|
window.location.href = redirectUrl;
|
|
@@ -1142,7 +1157,7 @@ function TeamSwitcher({
|
|
|
1142
1157
|
import { useAuth as useAuth6 } from "@workos-inc/authkit-react";
|
|
1143
1158
|
|
|
1144
1159
|
// src/hooks/use-widget-token.ts
|
|
1145
|
-
import { useCallback, useEffect as
|
|
1160
|
+
import { useCallback, useEffect as useEffect4, useState as useState6 } from "react";
|
|
1146
1161
|
function useWidgetToken({
|
|
1147
1162
|
widget,
|
|
1148
1163
|
organizationId,
|
|
@@ -1171,7 +1186,7 @@ function useWidgetToken({
|
|
|
1171
1186
|
setLoading(false);
|
|
1172
1187
|
}
|
|
1173
1188
|
}, [widget, organizationId, endpoint]);
|
|
1174
|
-
|
|
1189
|
+
useEffect4(() => {
|
|
1175
1190
|
fetchToken();
|
|
1176
1191
|
}, [fetchToken]);
|
|
1177
1192
|
return { token, loading, error, refetch: fetchToken };
|
|
@@ -1308,7 +1323,7 @@ var IdentityProviderPropsSchema = z4.object({
|
|
|
1308
1323
|
redirectUri: z4.string().url().optional().describe("Redirect URI after authentication")
|
|
1309
1324
|
/** Note: onRedirectCallback and children are React-specific, not in schema */
|
|
1310
1325
|
});
|
|
1311
|
-
var UnauthenticatedActionSchema = z4.enum(["landing", "redirect", "allow"]);
|
|
1326
|
+
var UnauthenticatedActionSchema = z4.enum(["landing", "redirect", "allow", "signIn"]);
|
|
1312
1327
|
var AuthGatePropsSchema = z4.object({
|
|
1313
1328
|
/** Whether authentication is required (default: true) */
|
|
1314
1329
|
required: z4.boolean().optional().describe("Whether authentication is required"),
|
|
@@ -1366,29 +1381,790 @@ var UseWidgetTokenResultSchema = z5.object({
|
|
|
1366
1381
|
error: z5.string().nullable().describe("Error message if fetch failed")
|
|
1367
1382
|
/** Note: refetch function is React-specific, not in schema */
|
|
1368
1383
|
});
|
|
1384
|
+
|
|
1385
|
+
// src/shell/config-context.tsx
|
|
1386
|
+
import { createContext as createContext2, useContext as useContext2, useMemo as useMemo4 } from "react";
|
|
1387
|
+
|
|
1388
|
+
// src/shell/route-presets.ts
|
|
1389
|
+
import { Key as Key3, Monitor, Plug, Shield, User, Users } from "lucide-react";
|
|
1390
|
+
|
|
1391
|
+
// src/shell/components/breadcrumbs.tsx
|
|
1392
|
+
import { WebLink } from "@mdxui/navigation/web";
|
|
1393
|
+
import {
|
|
1394
|
+
Breadcrumb,
|
|
1395
|
+
BreadcrumbEllipsis,
|
|
1396
|
+
BreadcrumbItem,
|
|
1397
|
+
BreadcrumbLink,
|
|
1398
|
+
BreadcrumbList,
|
|
1399
|
+
BreadcrumbPage,
|
|
1400
|
+
BreadcrumbSeparator
|
|
1401
|
+
} from "@mdxui/primitives/breadcrumb";
|
|
1402
|
+
import {
|
|
1403
|
+
DropdownMenu as DropdownMenu2,
|
|
1404
|
+
DropdownMenuContent as DropdownMenuContent2,
|
|
1405
|
+
DropdownMenuItem as DropdownMenuItem2,
|
|
1406
|
+
DropdownMenuTrigger as DropdownMenuTrigger2
|
|
1407
|
+
} from "@mdxui/primitives/dropdown-menu";
|
|
1408
|
+
import * as React3 from "react";
|
|
1409
|
+
import { jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1410
|
+
function DefaultLink({ href, children, className }) {
|
|
1411
|
+
return /* @__PURE__ */ jsx23(WebLink, { to: href, className, children });
|
|
1412
|
+
}
|
|
1413
|
+
function Breadcrumbs({
|
|
1414
|
+
items,
|
|
1415
|
+
LinkComponent = DefaultLink,
|
|
1416
|
+
className,
|
|
1417
|
+
maxItems = 4,
|
|
1418
|
+
separator
|
|
1419
|
+
}) {
|
|
1420
|
+
if (!items || items.length === 0) {
|
|
1421
|
+
return null;
|
|
1422
|
+
}
|
|
1423
|
+
const shouldCollapse = items.length > maxItems;
|
|
1424
|
+
const visibleItems = shouldCollapse ? [items[0], ...items.slice(-(maxItems - 1))] : items;
|
|
1425
|
+
const hiddenItems = shouldCollapse ? items.slice(1, -(maxItems - 1)) : [];
|
|
1426
|
+
return /* @__PURE__ */ jsx23(Breadcrumb, { className, children: /* @__PURE__ */ jsx23(BreadcrumbList, { children: visibleItems.map((item, index) => {
|
|
1427
|
+
const isLast = index === visibleItems.length - 1;
|
|
1428
|
+
const isFirst = index === 0;
|
|
1429
|
+
if (shouldCollapse && isFirst) {
|
|
1430
|
+
return /* @__PURE__ */ jsxs10(React3.Fragment, { children: [
|
|
1431
|
+
/* @__PURE__ */ jsx23(BreadcrumbItem, { children: item.href ? /* @__PURE__ */ jsx23(BreadcrumbLink, { asChild: true, children: /* @__PURE__ */ jsx23(LinkComponent, { href: item.href, children: item.label }) }) : /* @__PURE__ */ jsx23(BreadcrumbPage, { children: item.label }) }),
|
|
1432
|
+
/* @__PURE__ */ jsx23(BreadcrumbSeparator, { children: separator }),
|
|
1433
|
+
/* @__PURE__ */ jsx23(BreadcrumbItem, { children: /* @__PURE__ */ jsxs10(DropdownMenu2, { children: [
|
|
1434
|
+
/* @__PURE__ */ jsx23(
|
|
1435
|
+
DropdownMenuTrigger2,
|
|
1436
|
+
{
|
|
1437
|
+
className: "flex items-center gap-1 hover:text-foreground",
|
|
1438
|
+
"aria-label": "Show hidden breadcrumbs",
|
|
1439
|
+
children: /* @__PURE__ */ jsx23(BreadcrumbEllipsis, { className: "size-4" })
|
|
1440
|
+
}
|
|
1441
|
+
),
|
|
1442
|
+
/* @__PURE__ */ jsx23(DropdownMenuContent2, { align: "start", children: hiddenItems.map((hiddenItem) => /* @__PURE__ */ jsx23(DropdownMenuItem2, { asChild: true, children: /* @__PURE__ */ jsx23(LinkComponent, { href: hiddenItem.href || "#", children: hiddenItem.label }) }, hiddenItem.label)) })
|
|
1443
|
+
] }) }),
|
|
1444
|
+
/* @__PURE__ */ jsx23(BreadcrumbSeparator, { children: separator })
|
|
1445
|
+
] }, item.label);
|
|
1446
|
+
}
|
|
1447
|
+
return /* @__PURE__ */ jsxs10(React3.Fragment, { children: [
|
|
1448
|
+
/* @__PURE__ */ jsx23(BreadcrumbItem, { children: isLast ? /* @__PURE__ */ jsx23(BreadcrumbPage, { children: item.label }) : item.href ? /* @__PURE__ */ jsx23(BreadcrumbLink, { asChild: true, children: /* @__PURE__ */ jsx23(LinkComponent, { href: item.href, children: item.label }) }) : /* @__PURE__ */ jsx23(BreadcrumbPage, { children: item.label }) }),
|
|
1449
|
+
!isLast && /* @__PURE__ */ jsx23(BreadcrumbSeparator, { children: separator })
|
|
1450
|
+
] }, item.label);
|
|
1451
|
+
}) }) });
|
|
1452
|
+
}
|
|
1453
|
+
Breadcrumbs.displayName = "Breadcrumbs";
|
|
1454
|
+
|
|
1455
|
+
// src/shell/components/sidebar-org-switcher.tsx
|
|
1456
|
+
import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1457
|
+
function SidebarOrgSwitcher() {
|
|
1458
|
+
const branding = useAuthShellBranding();
|
|
1459
|
+
return /* @__PURE__ */ jsx24(
|
|
1460
|
+
TeamSwitcher,
|
|
1461
|
+
{
|
|
1462
|
+
renderNoOrganization: () => /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 px-2", children: [
|
|
1463
|
+
branding.logo && /* @__PURE__ */ jsx24("div", { className: "flex-shrink-0", children: branding.logo }),
|
|
1464
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-0.5 leading-none", children: [
|
|
1465
|
+
/* @__PURE__ */ jsx24("span", { className: "font-semibold", children: branding.name }),
|
|
1466
|
+
branding.tagline && /* @__PURE__ */ jsx24("span", { className: "text-xs text-muted-foreground", children: branding.tagline })
|
|
1467
|
+
] })
|
|
1468
|
+
] })
|
|
1469
|
+
}
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
// src/shell/components/widget-error-boundary.tsx
|
|
1474
|
+
import { Component } from "react";
|
|
1475
|
+
import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1476
|
+
var widgetErrorMessages = {
|
|
1477
|
+
profile: "Your profile is camera shy right now...",
|
|
1478
|
+
security: "Security settings are being extra secure (maybe too secure)...",
|
|
1479
|
+
sessions: "Your sessions are having a session of their own...",
|
|
1480
|
+
"api-keys": "Your API keys are playing hide and seek...",
|
|
1481
|
+
team: "Your team members wandered off for a moment...",
|
|
1482
|
+
integrations: "Your integrations are having connection issues (ironic, we know)..."
|
|
1483
|
+
};
|
|
1484
|
+
var uppercaseWords = /* @__PURE__ */ new Set(["api", "sso", "mfa", "oauth", "jwt", "url", "id"]);
|
|
1485
|
+
function formatWidgetName(widgetName) {
|
|
1486
|
+
return widgetName.split("-").map((word) => {
|
|
1487
|
+
const lower = word.toLowerCase();
|
|
1488
|
+
if (uppercaseWords.has(lower)) {
|
|
1489
|
+
return word.toUpperCase();
|
|
1490
|
+
}
|
|
1491
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
1492
|
+
}).join(" ");
|
|
1493
|
+
}
|
|
1494
|
+
function getErrorMessage(widgetName) {
|
|
1495
|
+
if (!widgetName) {
|
|
1496
|
+
return "Something went wrong loading this widget.";
|
|
1497
|
+
}
|
|
1498
|
+
const knownMessage = widgetErrorMessages[widgetName];
|
|
1499
|
+
if (knownMessage) {
|
|
1500
|
+
return knownMessage;
|
|
1501
|
+
}
|
|
1502
|
+
return `Something went wrong loading your ${formatWidgetName(widgetName)}...`;
|
|
1503
|
+
}
|
|
1504
|
+
var WidgetErrorBoundary = class extends Component {
|
|
1505
|
+
constructor(props) {
|
|
1506
|
+
super(props);
|
|
1507
|
+
this.state = { hasError: false };
|
|
1508
|
+
}
|
|
1509
|
+
static getDerivedStateFromError(error) {
|
|
1510
|
+
return { hasError: true, error };
|
|
1511
|
+
}
|
|
1512
|
+
componentDidCatch(error, errorInfo) {
|
|
1513
|
+
console.error("[WidgetErrorBoundary] Widget error:", error, errorInfo);
|
|
1514
|
+
}
|
|
1515
|
+
render() {
|
|
1516
|
+
if (this.state.hasError) {
|
|
1517
|
+
if (this.props.fallback) {
|
|
1518
|
+
return this.props.fallback;
|
|
1519
|
+
}
|
|
1520
|
+
const message = getErrorMessage(this.props.widgetName);
|
|
1521
|
+
return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-center justify-center gap-2 rounded-[var(--radius-md)] border border-dashed py-12", children: [
|
|
1522
|
+
/* @__PURE__ */ jsx25("p", { className: "text-muted-foreground text-sm", children: message }),
|
|
1523
|
+
/* @__PURE__ */ jsx25("p", { className: "text-muted-foreground/60 text-xs", children: "Try refreshing the page." })
|
|
1524
|
+
] });
|
|
1525
|
+
}
|
|
1526
|
+
return this.props.children;
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1529
|
+
|
|
1530
|
+
// src/shell/pages/profile-page.tsx
|
|
1531
|
+
import { jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1532
|
+
function ProfilePage() {
|
|
1533
|
+
const { user, getAccessToken, isLoading } = useAuth6();
|
|
1534
|
+
if (isLoading) {
|
|
1535
|
+
return /* @__PURE__ */ jsx26("div", { className: "flex items-center justify-center py-12 text-muted-foreground", children: "Loading..." });
|
|
1536
|
+
}
|
|
1537
|
+
if (!user) {
|
|
1538
|
+
return /* @__PURE__ */ jsxs13("div", { className: "container max-w-4xl py-8", children: [
|
|
1539
|
+
/* @__PURE__ */ jsxs13("div", { className: "mb-8", children: [
|
|
1540
|
+
/* @__PURE__ */ jsx26("h1", { className: "text-2xl font-semibold tracking-tight", children: "Profile" }),
|
|
1541
|
+
/* @__PURE__ */ jsx26("p", { className: "text-muted-foreground", children: "Manage your account information" })
|
|
1542
|
+
] }),
|
|
1543
|
+
/* @__PURE__ */ jsx26("div", { className: "flex items-center justify-center rounded-[var(--radius-md)] border border-dashed py-24", children: /* @__PURE__ */ jsx26("p", { className: "text-muted-foreground text-sm", children: "Please sign in to view your profile." }) })
|
|
1544
|
+
] });
|
|
1545
|
+
}
|
|
1546
|
+
return /* @__PURE__ */ jsxs13("div", { className: "container max-w-4xl py-8", children: [
|
|
1547
|
+
/* @__PURE__ */ jsxs13("div", { className: "mb-8", children: [
|
|
1548
|
+
/* @__PURE__ */ jsx26("h1", { className: "text-2xl font-semibold tracking-tight", children: "Profile" }),
|
|
1549
|
+
/* @__PURE__ */ jsx26("p", { className: "text-muted-foreground", children: "Manage your account information" })
|
|
1550
|
+
] }),
|
|
1551
|
+
/* @__PURE__ */ jsx26(WidgetErrorBoundary, { widgetName: "profile", children: /* @__PURE__ */ jsx26(UserProfile, { authToken: getAccessToken }) })
|
|
1552
|
+
] });
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
// src/shell/pages/security-page.tsx
|
|
1556
|
+
import { jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1557
|
+
function SecurityPage() {
|
|
1558
|
+
const { user, getAccessToken, isLoading } = useAuth6();
|
|
1559
|
+
if (isLoading) {
|
|
1560
|
+
return /* @__PURE__ */ jsx27("div", { className: "flex items-center justify-center py-12 text-muted-foreground", children: "Loading..." });
|
|
1561
|
+
}
|
|
1562
|
+
if (!user) {
|
|
1563
|
+
return /* @__PURE__ */ jsxs14("div", { className: "container max-w-4xl py-8", children: [
|
|
1564
|
+
/* @__PURE__ */ jsxs14("div", { className: "mb-8", children: [
|
|
1565
|
+
/* @__PURE__ */ jsx27("h1", { className: "text-2xl font-semibold tracking-tight", children: "Security" }),
|
|
1566
|
+
/* @__PURE__ */ jsx27("p", { className: "text-muted-foreground", children: "Manage your password and authentication settings" })
|
|
1567
|
+
] }),
|
|
1568
|
+
/* @__PURE__ */ jsx27("div", { className: "flex items-center justify-center rounded-[var(--radius-md)] border border-dashed py-24", children: /* @__PURE__ */ jsx27("p", { className: "text-muted-foreground text-sm", children: "Please sign in to manage your security settings." }) })
|
|
1569
|
+
] });
|
|
1570
|
+
}
|
|
1571
|
+
return /* @__PURE__ */ jsxs14("div", { className: "container max-w-4xl py-8", children: [
|
|
1572
|
+
/* @__PURE__ */ jsxs14("div", { className: "mb-8", children: [
|
|
1573
|
+
/* @__PURE__ */ jsx27("h1", { className: "text-2xl font-semibold tracking-tight", children: "Security" }),
|
|
1574
|
+
/* @__PURE__ */ jsx27("p", { className: "text-muted-foreground", children: "Manage your password and authentication settings" })
|
|
1575
|
+
] }),
|
|
1576
|
+
/* @__PURE__ */ jsx27(WidgetErrorBoundary, { widgetName: "security", children: /* @__PURE__ */ jsx27(UserSecurity, { authToken: getAccessToken }) })
|
|
1577
|
+
] });
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
// src/shell/pages/sessions-page.tsx
|
|
1581
|
+
import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1582
|
+
function SessionsPage() {
|
|
1583
|
+
const { user, getAccessToken, isLoading } = useAuth6();
|
|
1584
|
+
if (isLoading) {
|
|
1585
|
+
return /* @__PURE__ */ jsx28("div", { className: "flex items-center justify-center py-12 text-muted-foreground", children: "Loading..." });
|
|
1586
|
+
}
|
|
1587
|
+
if (!user) {
|
|
1588
|
+
return /* @__PURE__ */ jsxs15("div", { className: "container max-w-4xl py-8", children: [
|
|
1589
|
+
/* @__PURE__ */ jsxs15("div", { className: "mb-8", children: [
|
|
1590
|
+
/* @__PURE__ */ jsx28("h1", { className: "text-2xl font-semibold tracking-tight", children: "Sessions" }),
|
|
1591
|
+
/* @__PURE__ */ jsx28("p", { className: "text-muted-foreground", children: "View and manage your active sessions" })
|
|
1592
|
+
] }),
|
|
1593
|
+
/* @__PURE__ */ jsx28("div", { className: "flex items-center justify-center rounded-[var(--radius-md)] border border-dashed py-24", children: /* @__PURE__ */ jsx28("p", { className: "text-muted-foreground text-sm", children: "Please sign in to view your sessions." }) })
|
|
1594
|
+
] });
|
|
1595
|
+
}
|
|
1596
|
+
return /* @__PURE__ */ jsxs15("div", { className: "container max-w-4xl py-8", children: [
|
|
1597
|
+
/* @__PURE__ */ jsxs15("div", { className: "mb-8", children: [
|
|
1598
|
+
/* @__PURE__ */ jsx28("h1", { className: "text-2xl font-semibold tracking-tight", children: "Sessions" }),
|
|
1599
|
+
/* @__PURE__ */ jsx28("p", { className: "text-muted-foreground", children: "View and manage your active sessions" })
|
|
1600
|
+
] }),
|
|
1601
|
+
/* @__PURE__ */ jsx28(WidgetErrorBoundary, { widgetName: "sessions", children: /* @__PURE__ */ jsx28(UserSessions, { authToken: getAccessToken }) })
|
|
1602
|
+
] });
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
// src/shell/pages/api-keys-page.tsx
|
|
1606
|
+
import { jsx as jsx29, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1607
|
+
function ApiKeysPage() {
|
|
1608
|
+
const { user, getAccessToken, isLoading } = useAuth6();
|
|
1609
|
+
if (isLoading) {
|
|
1610
|
+
return /* @__PURE__ */ jsx29("div", { className: "flex items-center justify-center py-12 text-muted-foreground", children: "Loading..." });
|
|
1611
|
+
}
|
|
1612
|
+
if (!user) {
|
|
1613
|
+
return /* @__PURE__ */ jsxs16("div", { className: "container max-w-4xl py-8", children: [
|
|
1614
|
+
/* @__PURE__ */ jsxs16("div", { className: "mb-8", children: [
|
|
1615
|
+
/* @__PURE__ */ jsx29("h1", { className: "text-2xl font-semibold tracking-tight", children: "API Keys" }),
|
|
1616
|
+
/* @__PURE__ */ jsx29("p", { className: "text-muted-foreground", children: "Create and manage your API keys" })
|
|
1617
|
+
] }),
|
|
1618
|
+
/* @__PURE__ */ jsx29("div", { className: "flex items-center justify-center rounded-[var(--radius-md)] border border-dashed py-24", children: /* @__PURE__ */ jsx29("p", { className: "text-muted-foreground text-sm", children: "Please sign in to manage your API keys." }) })
|
|
1619
|
+
] });
|
|
1620
|
+
}
|
|
1621
|
+
return /* @__PURE__ */ jsxs16("div", { className: "container max-w-4xl py-8", children: [
|
|
1622
|
+
/* @__PURE__ */ jsxs16("div", { className: "mb-8", children: [
|
|
1623
|
+
/* @__PURE__ */ jsx29("h1", { className: "text-2xl font-semibold tracking-tight", children: "API Keys" }),
|
|
1624
|
+
/* @__PURE__ */ jsx29("p", { className: "text-muted-foreground", children: "Create and manage your API keys" })
|
|
1625
|
+
] }),
|
|
1626
|
+
/* @__PURE__ */ jsx29(WidgetErrorBoundary, { widgetName: "api-keys", children: /* @__PURE__ */ jsx29(ApiKeys, { authToken: getAccessToken }) })
|
|
1627
|
+
] });
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
// src/shell/pages/team-page.tsx
|
|
1631
|
+
import { jsx as jsx30, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1632
|
+
function TeamPage() {
|
|
1633
|
+
const { user, getAccessToken, isLoading, organizationId, permissions } = useAuth6();
|
|
1634
|
+
const hasOrganization = !!organizationId;
|
|
1635
|
+
const canManageTeam = hasOrganization && permissions?.includes("widgets:users-table:manage");
|
|
1636
|
+
if (isLoading) {
|
|
1637
|
+
return /* @__PURE__ */ jsx30("div", { className: "flex items-center justify-center py-12 text-muted-foreground", children: "Loading..." });
|
|
1638
|
+
}
|
|
1639
|
+
if (!user) {
|
|
1640
|
+
return /* @__PURE__ */ jsxs17("div", { className: "container max-w-4xl py-8", children: [
|
|
1641
|
+
/* @__PURE__ */ jsxs17("div", { className: "mb-8", children: [
|
|
1642
|
+
/* @__PURE__ */ jsx30("h1", { className: "text-2xl font-semibold tracking-tight", children: "Team" }),
|
|
1643
|
+
/* @__PURE__ */ jsx30("p", { className: "text-muted-foreground", children: "Manage your team members and invitations" })
|
|
1644
|
+
] }),
|
|
1645
|
+
/* @__PURE__ */ jsx30("div", { className: "flex items-center justify-center rounded-[var(--radius-md)] border border-dashed py-24", children: /* @__PURE__ */ jsx30("p", { className: "text-muted-foreground text-sm", children: "Please sign in to manage your team." }) })
|
|
1646
|
+
] });
|
|
1647
|
+
}
|
|
1648
|
+
if (!hasOrganization) {
|
|
1649
|
+
return /* @__PURE__ */ jsxs17("div", { className: "container max-w-4xl py-8", children: [
|
|
1650
|
+
/* @__PURE__ */ jsxs17("div", { className: "mb-8", children: [
|
|
1651
|
+
/* @__PURE__ */ jsx30("h1", { className: "text-2xl font-semibold tracking-tight", children: "Team" }),
|
|
1652
|
+
/* @__PURE__ */ jsx30("p", { className: "text-muted-foreground", children: "Manage your team members and invitations" })
|
|
1653
|
+
] }),
|
|
1654
|
+
/* @__PURE__ */ jsx30("div", { className: "flex items-center justify-center rounded-[var(--radius-md)] border border-dashed py-24", children: /* @__PURE__ */ jsx30("p", { className: "text-muted-foreground text-sm", children: "You need to be part of an organization to manage team members." }) })
|
|
1655
|
+
] });
|
|
1656
|
+
}
|
|
1657
|
+
if (!canManageTeam) {
|
|
1658
|
+
return /* @__PURE__ */ jsxs17("div", { className: "container max-w-4xl py-8", children: [
|
|
1659
|
+
/* @__PURE__ */ jsxs17("div", { className: "mb-8", children: [
|
|
1660
|
+
/* @__PURE__ */ jsx30("h1", { className: "text-2xl font-semibold tracking-tight", children: "Team" }),
|
|
1661
|
+
/* @__PURE__ */ jsx30("p", { className: "text-muted-foreground", children: "Manage your team members and invitations" })
|
|
1662
|
+
] }),
|
|
1663
|
+
/* @__PURE__ */ jsx30("div", { className: "flex items-center justify-center rounded-[var(--radius-md)] border border-dashed py-24", children: /* @__PURE__ */ jsx30("p", { className: "text-muted-foreground text-sm", children: "You need admin permissions to manage team members." }) })
|
|
1664
|
+
] });
|
|
1665
|
+
}
|
|
1666
|
+
return /* @__PURE__ */ jsxs17("div", { className: "container max-w-4xl py-8", children: [
|
|
1667
|
+
/* @__PURE__ */ jsxs17("div", { className: "mb-8", children: [
|
|
1668
|
+
/* @__PURE__ */ jsx30("h1", { className: "text-2xl font-semibold tracking-tight", children: "Team" }),
|
|
1669
|
+
/* @__PURE__ */ jsx30("p", { className: "text-muted-foreground", children: "Manage your team members and invitations" })
|
|
1670
|
+
] }),
|
|
1671
|
+
/* @__PURE__ */ jsx30(WidgetErrorBoundary, { widgetName: "team", children: /* @__PURE__ */ jsx30(UsersManagement, { authToken: getAccessToken }) })
|
|
1672
|
+
] });
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
// src/shell/pages/integrations-page.tsx
|
|
1676
|
+
import { jsx as jsx31, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1677
|
+
function IntegrationsPage() {
|
|
1678
|
+
const { user, getAccessToken, isLoading } = useAuth6();
|
|
1679
|
+
if (isLoading) {
|
|
1680
|
+
return /* @__PURE__ */ jsx31("div", { className: "flex items-center justify-center py-12 text-muted-foreground", children: "Loading..." });
|
|
1681
|
+
}
|
|
1682
|
+
if (!user) {
|
|
1683
|
+
return /* @__PURE__ */ jsxs18("div", { className: "container max-w-4xl py-8", children: [
|
|
1684
|
+
/* @__PURE__ */ jsxs18("div", { className: "mb-8", children: [
|
|
1685
|
+
/* @__PURE__ */ jsx31("h1", { className: "text-2xl font-semibold tracking-tight", children: "Integrations" }),
|
|
1686
|
+
/* @__PURE__ */ jsx31("p", { className: "text-muted-foreground", children: "Connect and manage third-party services" })
|
|
1687
|
+
] }),
|
|
1688
|
+
/* @__PURE__ */ jsx31("div", { className: "flex items-center justify-center rounded-[var(--radius-md)] border border-dashed py-24", children: /* @__PURE__ */ jsx31("p", { className: "text-muted-foreground text-sm", children: "Please sign in to manage your integrations." }) })
|
|
1689
|
+
] });
|
|
1690
|
+
}
|
|
1691
|
+
return /* @__PURE__ */ jsxs18("div", { className: "container max-w-4xl py-8", children: [
|
|
1692
|
+
/* @__PURE__ */ jsxs18("div", { className: "mb-8", children: [
|
|
1693
|
+
/* @__PURE__ */ jsx31("h1", { className: "text-2xl font-semibold tracking-tight", children: "Integrations" }),
|
|
1694
|
+
/* @__PURE__ */ jsx31("p", { className: "text-muted-foreground", children: "Connect and manage third-party services" })
|
|
1695
|
+
] }),
|
|
1696
|
+
/* @__PURE__ */ jsx31(WidgetErrorBoundary, { widgetName: "integrations", children: /* @__PURE__ */ jsx31(Pipes, { authToken: getAccessToken }) })
|
|
1697
|
+
] });
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
// src/shell/route-presets.ts
|
|
1701
|
+
var defaultGroups = [
|
|
1702
|
+
{ id: "main", order: 0 },
|
|
1703
|
+
{ id: "account", label: "Account", order: 10 },
|
|
1704
|
+
{ id: "developer", label: "Developer", order: 20 },
|
|
1705
|
+
{ id: "admin", label: "Admin", order: 30 }
|
|
1706
|
+
];
|
|
1707
|
+
var accountRoutes = [
|
|
1708
|
+
{
|
|
1709
|
+
key: "profile",
|
|
1710
|
+
path: "/profile",
|
|
1711
|
+
label: "Profile",
|
|
1712
|
+
group: "account",
|
|
1713
|
+
icon: User,
|
|
1714
|
+
component: ProfilePage,
|
|
1715
|
+
enabled: true,
|
|
1716
|
+
public: false
|
|
1717
|
+
},
|
|
1718
|
+
{
|
|
1719
|
+
key: "security",
|
|
1720
|
+
path: "/security",
|
|
1721
|
+
label: "Security",
|
|
1722
|
+
group: "account",
|
|
1723
|
+
icon: Shield,
|
|
1724
|
+
component: SecurityPage,
|
|
1725
|
+
enabled: true,
|
|
1726
|
+
public: false
|
|
1727
|
+
},
|
|
1728
|
+
{
|
|
1729
|
+
key: "sessions",
|
|
1730
|
+
path: "/sessions",
|
|
1731
|
+
label: "Sessions",
|
|
1732
|
+
group: "account",
|
|
1733
|
+
icon: Monitor,
|
|
1734
|
+
component: SessionsPage,
|
|
1735
|
+
enabled: true,
|
|
1736
|
+
public: false
|
|
1737
|
+
}
|
|
1738
|
+
];
|
|
1739
|
+
var developerRoutes = [
|
|
1740
|
+
{
|
|
1741
|
+
key: "api-keys",
|
|
1742
|
+
path: "/api-keys",
|
|
1743
|
+
label: "API Keys",
|
|
1744
|
+
group: "developer",
|
|
1745
|
+
icon: Key3,
|
|
1746
|
+
component: ApiKeysPage,
|
|
1747
|
+
enabled: true,
|
|
1748
|
+
public: false
|
|
1749
|
+
}
|
|
1750
|
+
];
|
|
1751
|
+
var adminRoutes = [
|
|
1752
|
+
{
|
|
1753
|
+
key: "team",
|
|
1754
|
+
path: "/team",
|
|
1755
|
+
label: "Team",
|
|
1756
|
+
group: "admin",
|
|
1757
|
+
icon: Users,
|
|
1758
|
+
component: TeamPage,
|
|
1759
|
+
enabled: true,
|
|
1760
|
+
public: false
|
|
1761
|
+
}
|
|
1762
|
+
];
|
|
1763
|
+
var integrationRoutes = [
|
|
1764
|
+
{
|
|
1765
|
+
key: "integrations",
|
|
1766
|
+
path: "/integrations",
|
|
1767
|
+
label: "Integrations",
|
|
1768
|
+
group: "developer",
|
|
1769
|
+
icon: Plug,
|
|
1770
|
+
component: IntegrationsPage,
|
|
1771
|
+
enabled: true,
|
|
1772
|
+
public: false
|
|
1773
|
+
}
|
|
1774
|
+
];
|
|
1775
|
+
var defaultRoutes = [
|
|
1776
|
+
...accountRoutes,
|
|
1777
|
+
...developerRoutes,
|
|
1778
|
+
...adminRoutes
|
|
1779
|
+
];
|
|
1780
|
+
|
|
1781
|
+
// src/shell/config-context.tsx
|
|
1782
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
1783
|
+
var AuthShellConfigContext = createContext2(null);
|
|
1784
|
+
function AuthShellConfigProvider({ config, children }) {
|
|
1785
|
+
const value = useMemo4(() => {
|
|
1786
|
+
const routes = config.routes ?? defaultRoutes;
|
|
1787
|
+
const enabledRoutes = routes.filter((route) => route.enabled !== false);
|
|
1788
|
+
const groups = [...config.groups ?? defaultGroups].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
1789
|
+
const routesByGroup = /* @__PURE__ */ new Map();
|
|
1790
|
+
for (const group of groups) {
|
|
1791
|
+
routesByGroup.set(group.id, []);
|
|
1792
|
+
}
|
|
1793
|
+
for (const route of enabledRoutes) {
|
|
1794
|
+
const groupId = route.group ?? "main";
|
|
1795
|
+
const groupRoutes = routesByGroup.get(groupId) ?? [];
|
|
1796
|
+
groupRoutes.push(route);
|
|
1797
|
+
routesByGroup.set(groupId, groupRoutes);
|
|
1798
|
+
}
|
|
1799
|
+
for (const [groupId, routes2] of routesByGroup) {
|
|
1800
|
+
routesByGroup.set(
|
|
1801
|
+
groupId,
|
|
1802
|
+
routes2.sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
|
|
1803
|
+
);
|
|
1804
|
+
}
|
|
1805
|
+
return {
|
|
1806
|
+
config,
|
|
1807
|
+
routes: enabledRoutes,
|
|
1808
|
+
routesByGroup,
|
|
1809
|
+
groups,
|
|
1810
|
+
branding: config.branding,
|
|
1811
|
+
basePath: config.basePath ?? ""
|
|
1812
|
+
};
|
|
1813
|
+
}, [config]);
|
|
1814
|
+
return /* @__PURE__ */ jsx32(AuthShellConfigContext.Provider, { value, children });
|
|
1815
|
+
}
|
|
1816
|
+
function useAuthShellConfig() {
|
|
1817
|
+
const context = useContext2(AuthShellConfigContext);
|
|
1818
|
+
if (!context) {
|
|
1819
|
+
throw new Error("useAuthShellConfig must be used within AuthShellConfigProvider");
|
|
1820
|
+
}
|
|
1821
|
+
return context;
|
|
1822
|
+
}
|
|
1823
|
+
function useAuthShellRoutes() {
|
|
1824
|
+
const { routes } = useAuthShellConfig();
|
|
1825
|
+
return routes;
|
|
1826
|
+
}
|
|
1827
|
+
function useAuthShellRoutesByGroup() {
|
|
1828
|
+
const { routesByGroup, groups } = useAuthShellConfig();
|
|
1829
|
+
return { routesByGroup, groups };
|
|
1830
|
+
}
|
|
1831
|
+
function useAuthShellBranding() {
|
|
1832
|
+
const { branding } = useAuthShellConfig();
|
|
1833
|
+
return branding;
|
|
1834
|
+
}
|
|
1835
|
+
function useAuthShellFullPath() {
|
|
1836
|
+
const { basePath } = useAuthShellConfig();
|
|
1837
|
+
return useMemo4(() => {
|
|
1838
|
+
return (path) => {
|
|
1839
|
+
if (!basePath) return path;
|
|
1840
|
+
if (path === "/") return basePath || "/";
|
|
1841
|
+
return `${basePath}${path}`;
|
|
1842
|
+
};
|
|
1843
|
+
}, [basePath]);
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
// src/shell/auth-shell.tsx
|
|
1847
|
+
import { Separator } from "@mdxui/primitives/separator";
|
|
1848
|
+
import {
|
|
1849
|
+
SidebarInset,
|
|
1850
|
+
SidebarProvider,
|
|
1851
|
+
SidebarTrigger
|
|
1852
|
+
} from "@mdxui/primitives/sidebar";
|
|
1853
|
+
import { Toaster } from "@mdxui/primitives/sonner";
|
|
1854
|
+
|
|
1855
|
+
// src/shell/auth-shell-nav.tsx
|
|
1856
|
+
import { useAuth as useAuth7 } from "@workos-inc/authkit-react";
|
|
1857
|
+
import { useIsActive, WebLink as WebLink2 } from "@mdxui/navigation/web";
|
|
1858
|
+
import {
|
|
1859
|
+
Sidebar,
|
|
1860
|
+
SidebarContent,
|
|
1861
|
+
SidebarFooter,
|
|
1862
|
+
SidebarGroup,
|
|
1863
|
+
SidebarGroupContent,
|
|
1864
|
+
SidebarGroupLabel,
|
|
1865
|
+
SidebarHeader,
|
|
1866
|
+
SidebarMenu,
|
|
1867
|
+
SidebarMenuButton,
|
|
1868
|
+
SidebarMenuItem,
|
|
1869
|
+
SidebarRail
|
|
1870
|
+
} from "@mdxui/primitives/sidebar";
|
|
1871
|
+
import { SidebarUser } from "@mdxui/primitives/sidebar-user";
|
|
1872
|
+
import { Fragment as Fragment4, jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1873
|
+
function NavItem({ route, getFullPath }) {
|
|
1874
|
+
const fullPath = getFullPath(route.path);
|
|
1875
|
+
const isActive = useIsActive(fullPath, { partial: fullPath !== "/" });
|
|
1876
|
+
const Icon = route.icon;
|
|
1877
|
+
return /* @__PURE__ */ jsx33(SidebarMenuItem, { children: /* @__PURE__ */ jsx33(SidebarMenuButton, { asChild: true, isActive, tooltip: route.label, children: /* @__PURE__ */ jsxs19(WebLink2, { to: fullPath, children: [
|
|
1878
|
+
Icon && /* @__PURE__ */ jsx33(Icon, { className: "size-4" }),
|
|
1879
|
+
/* @__PURE__ */ jsx33("span", { children: route.label })
|
|
1880
|
+
] }) }) });
|
|
1881
|
+
}
|
|
1882
|
+
function BrandingHeader({ headerContent }) {
|
|
1883
|
+
const branding = useAuthShellBranding();
|
|
1884
|
+
if (headerContent) {
|
|
1885
|
+
return /* @__PURE__ */ jsx33(Fragment4, { children: headerContent });
|
|
1886
|
+
}
|
|
1887
|
+
return /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2 px-2", children: [
|
|
1888
|
+
branding.logo && /* @__PURE__ */ jsx33("div", { className: "flex-shrink-0", children: branding.logo }),
|
|
1889
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex flex-col gap-0.5 leading-none", children: [
|
|
1890
|
+
/* @__PURE__ */ jsx33("span", { className: "font-semibold", children: branding.name }),
|
|
1891
|
+
branding.tagline && /* @__PURE__ */ jsx33("span", { className: "text-xs text-muted-foreground", children: branding.tagline })
|
|
1892
|
+
] })
|
|
1893
|
+
] });
|
|
1894
|
+
}
|
|
1895
|
+
function DefaultUserMenu() {
|
|
1896
|
+
const { user, signOut } = useAuth7();
|
|
1897
|
+
if (!user) return null;
|
|
1898
|
+
const displayName = user.firstName ? `${user.firstName}${user.lastName ? ` ${user.lastName}` : ""}` : user.email ?? "User";
|
|
1899
|
+
return /* @__PURE__ */ jsx33(
|
|
1900
|
+
SidebarUser,
|
|
1901
|
+
{
|
|
1902
|
+
user: {
|
|
1903
|
+
name: displayName,
|
|
1904
|
+
email: user.email ?? "",
|
|
1905
|
+
avatar: user.profilePictureUrl ?? void 0
|
|
1906
|
+
},
|
|
1907
|
+
onSignOut: () => signOut()
|
|
1908
|
+
}
|
|
1909
|
+
);
|
|
1910
|
+
}
|
|
1911
|
+
function AuthShellNav({ headerContent, userMenu, className }) {
|
|
1912
|
+
const { routesByGroup, groups } = useAuthShellRoutesByGroup();
|
|
1913
|
+
const getFullPath = useAuthShellFullPath();
|
|
1914
|
+
return /* @__PURE__ */ jsxs19(Sidebar, { collapsible: "icon", className, children: [
|
|
1915
|
+
/* @__PURE__ */ jsx33(SidebarHeader, { children: /* @__PURE__ */ jsx33(BrandingHeader, { headerContent }) }),
|
|
1916
|
+
/* @__PURE__ */ jsx33(SidebarContent, { children: groups.map((group) => {
|
|
1917
|
+
const routes = routesByGroup.get(group.id);
|
|
1918
|
+
if (!routes || routes.length === 0) return null;
|
|
1919
|
+
return /* @__PURE__ */ jsxs19(SidebarGroup, { children: [
|
|
1920
|
+
group.label && /* @__PURE__ */ jsx33(SidebarGroupLabel, { children: group.label }),
|
|
1921
|
+
/* @__PURE__ */ jsx33(SidebarGroupContent, { children: /* @__PURE__ */ jsx33(SidebarMenu, { children: routes.map((route) => /* @__PURE__ */ jsx33(NavItem, { route, getFullPath }, route.key)) }) })
|
|
1922
|
+
] }, group.id);
|
|
1923
|
+
}) }),
|
|
1924
|
+
/* @__PURE__ */ jsx33(SidebarFooter, { children: userMenu ?? /* @__PURE__ */ jsx33(DefaultUserMenu, {}) }),
|
|
1925
|
+
/* @__PURE__ */ jsx33(SidebarRail, {})
|
|
1926
|
+
] });
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
// src/shell/auth-shell.tsx
|
|
1930
|
+
import { jsx as jsx34, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1931
|
+
function DefaultHeader({
|
|
1932
|
+
breadcrumbs,
|
|
1933
|
+
headerContent
|
|
1934
|
+
}) {
|
|
1935
|
+
return /* @__PURE__ */ jsxs20("header", { className: "relative flex h-16 shrink-0 items-center gap-2 border-b bg-background transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12", children: [
|
|
1936
|
+
/* @__PURE__ */ jsxs20("div", { className: "z-10 flex shrink-0 items-center gap-2 bg-background px-4", children: [
|
|
1937
|
+
/* @__PURE__ */ jsx34(SidebarTrigger, { className: "-ml-1" }),
|
|
1938
|
+
/* @__PURE__ */ jsx34(Separator, { orientation: "vertical", className: "mr-2 h-4" }),
|
|
1939
|
+
breadcrumbs && breadcrumbs.length > 0 && /* @__PURE__ */ jsx34(Breadcrumbs, { items: breadcrumbs })
|
|
1940
|
+
] }),
|
|
1941
|
+
headerContent && /* @__PURE__ */ jsx34("div", { className: "flex flex-1 items-center px-4 xl:absolute xl:inset-0 xl:justify-center", children: /* @__PURE__ */ jsx34("div", { className: "w-full max-w-md", children: headerContent }) })
|
|
1942
|
+
] });
|
|
1943
|
+
}
|
|
1944
|
+
function AuthShell({
|
|
1945
|
+
children,
|
|
1946
|
+
sidebarHeaderContent,
|
|
1947
|
+
headerContent,
|
|
1948
|
+
breadcrumbs
|
|
1949
|
+
}) {
|
|
1950
|
+
const { config } = useAuthShellConfig();
|
|
1951
|
+
const { identity, auth } = config;
|
|
1952
|
+
return /* @__PURE__ */ jsxs20(
|
|
1953
|
+
AuthGate,
|
|
1954
|
+
{
|
|
1955
|
+
required: identity.required ?? auth?.requireAuth ?? true,
|
|
1956
|
+
onUnauthenticated: identity.onUnauthenticated ?? auth?.onUnauthenticated ?? "landing",
|
|
1957
|
+
loadingComponent: identity.loadingComponent,
|
|
1958
|
+
landingComponent: identity.landingComponent,
|
|
1959
|
+
children: [
|
|
1960
|
+
/* @__PURE__ */ jsxs20(SidebarProvider, { children: [
|
|
1961
|
+
/* @__PURE__ */ jsx34(AuthShellNav, { headerContent: sidebarHeaderContent }),
|
|
1962
|
+
/* @__PURE__ */ jsxs20(SidebarInset, { children: [
|
|
1963
|
+
/* @__PURE__ */ jsx34(DefaultHeader, { breadcrumbs, headerContent }),
|
|
1964
|
+
/* @__PURE__ */ jsx34("main", { className: "flex-1 overflow-auto p-4", children })
|
|
1965
|
+
] })
|
|
1966
|
+
] }),
|
|
1967
|
+
/* @__PURE__ */ jsx34(Toaster, {})
|
|
1968
|
+
]
|
|
1969
|
+
}
|
|
1970
|
+
);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
// src/shell/auth-app.tsx
|
|
1974
|
+
import { useMemo as useMemo5 } from "react";
|
|
1975
|
+
import { ThemeProvider } from "next-themes";
|
|
1976
|
+
import { createWebRouter, RouterProvider, WebOutlet } from "@mdxui/navigation/web";
|
|
1977
|
+
|
|
1978
|
+
// src/shell/env-config.ts
|
|
1979
|
+
function getEnvVar(key) {
|
|
1980
|
+
if (typeof import.meta !== "undefined" && import.meta.env) {
|
|
1981
|
+
return import.meta.env[key];
|
|
1982
|
+
}
|
|
1983
|
+
if (typeof process !== "undefined" && process.env) {
|
|
1984
|
+
return process.env[key];
|
|
1985
|
+
}
|
|
1986
|
+
return void 0;
|
|
1987
|
+
}
|
|
1988
|
+
function getEnvConfig() {
|
|
1989
|
+
const clientId = getEnvVar("VITE_WORKOS_CLIENT_ID");
|
|
1990
|
+
const redirectUri = getEnvVar("VITE_WORKOS_REDIRECT_URI");
|
|
1991
|
+
const apiHostname = getEnvVar("VITE_WORKOS_API_HOSTNAME");
|
|
1992
|
+
const devModeStr = getEnvVar("VITE_WORKOS_DEV_MODE");
|
|
1993
|
+
const appName = getEnvVar("VITE_APP_NAME");
|
|
1994
|
+
const appTagline = getEnvVar("VITE_APP_TAGLINE");
|
|
1995
|
+
const identity = clientId ? {
|
|
1996
|
+
clientId,
|
|
1997
|
+
...redirectUri && { redirectUri },
|
|
1998
|
+
...apiHostname && { apiHostname },
|
|
1999
|
+
...devModeStr && { devMode: devModeStr === "true" }
|
|
2000
|
+
} : void 0;
|
|
2001
|
+
const branding = appName ? {
|
|
2002
|
+
name: appName,
|
|
2003
|
+
...appTagline && { tagline: appTagline }
|
|
2004
|
+
} : void 0;
|
|
2005
|
+
return {
|
|
2006
|
+
...identity && { identity },
|
|
2007
|
+
...branding && { branding }
|
|
2008
|
+
};
|
|
2009
|
+
}
|
|
2010
|
+
function mergeWithEnvConfig(config) {
|
|
2011
|
+
const envConfig = getEnvConfig();
|
|
2012
|
+
const branding = {
|
|
2013
|
+
name: config?.branding?.name ?? envConfig.branding?.name ?? "App",
|
|
2014
|
+
...config?.branding?.logo && { logo: config.branding.logo },
|
|
2015
|
+
...config?.branding?.logoCollapsed && { logoCollapsed: config.branding.logoCollapsed },
|
|
2016
|
+
tagline: config?.branding?.tagline ?? envConfig.branding?.tagline
|
|
2017
|
+
};
|
|
2018
|
+
const envIdentity = envConfig.identity;
|
|
2019
|
+
const configIdentity = config?.identity;
|
|
2020
|
+
if (!envIdentity?.clientId && !configIdentity?.clientId) {
|
|
2021
|
+
throw new Error(
|
|
2022
|
+
"AuthApp: Missing clientId. Either provide config.identity.clientId or set VITE_WORKOS_CLIENT_ID environment variable."
|
|
2023
|
+
);
|
|
2024
|
+
}
|
|
2025
|
+
const identity = {
|
|
2026
|
+
clientId: configIdentity?.clientId ?? envIdentity?.clientId ?? "",
|
|
2027
|
+
...configIdentity?.redirectUri ?? envIdentity?.redirectUri ? { redirectUri: configIdentity?.redirectUri ?? envIdentity?.redirectUri } : {},
|
|
2028
|
+
...configIdentity?.apiHostname ?? envIdentity?.apiHostname ? { apiHostname: configIdentity?.apiHostname ?? envIdentity?.apiHostname } : {},
|
|
2029
|
+
...configIdentity?.devMode ?? envIdentity?.devMode ? { devMode: configIdentity?.devMode ?? envIdentity?.devMode } : {},
|
|
2030
|
+
...configIdentity?.required !== void 0 ? { required: configIdentity.required } : {},
|
|
2031
|
+
...configIdentity?.onUnauthenticated ? { onUnauthenticated: configIdentity.onUnauthenticated } : {},
|
|
2032
|
+
...configIdentity?.landingComponent ? { landingComponent: configIdentity.landingComponent } : {},
|
|
2033
|
+
...configIdentity?.loadingComponent ? { loadingComponent: configIdentity.loadingComponent } : {}
|
|
2034
|
+
};
|
|
2035
|
+
return {
|
|
2036
|
+
branding,
|
|
2037
|
+
identity,
|
|
2038
|
+
...config?.basePath && { basePath: config.basePath },
|
|
2039
|
+
...config?.theme && { theme: config.theme },
|
|
2040
|
+
...config?.auth && { auth: config.auth },
|
|
2041
|
+
...config?.groups && { groups: config.groups },
|
|
2042
|
+
...config?.routes && { routes: config.routes }
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
// src/shell/auth-app.tsx
|
|
2047
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
2048
|
+
function AuthAppProvider({ config, children }) {
|
|
2049
|
+
const resolvedConfig = useMemo5(() => mergeWithEnvConfig(config), [config]);
|
|
2050
|
+
const { identity, theme } = resolvedConfig;
|
|
2051
|
+
return /* @__PURE__ */ jsx35(
|
|
2052
|
+
ThemeProvider,
|
|
2053
|
+
{
|
|
2054
|
+
attribute: "class",
|
|
2055
|
+
defaultTheme: theme?.mode ?? "system",
|
|
2056
|
+
enableSystem: true,
|
|
2057
|
+
disableTransitionOnChange: true,
|
|
2058
|
+
children: /* @__PURE__ */ jsx35(AuthShellConfigProvider, { config: resolvedConfig, children: /* @__PURE__ */ jsx35(
|
|
2059
|
+
IdentityProvider,
|
|
2060
|
+
{
|
|
2061
|
+
clientId: identity.clientId,
|
|
2062
|
+
apiHostname: identity.apiHostname,
|
|
2063
|
+
devMode: identity.devMode,
|
|
2064
|
+
redirectUri: identity.redirectUri,
|
|
2065
|
+
children
|
|
2066
|
+
}
|
|
2067
|
+
) })
|
|
2068
|
+
}
|
|
2069
|
+
);
|
|
2070
|
+
}
|
|
2071
|
+
function convertRoutesToConfig(routes, basePath) {
|
|
2072
|
+
const config = {};
|
|
2073
|
+
for (const route of routes) {
|
|
2074
|
+
if (route.enabled === false) continue;
|
|
2075
|
+
const fullPath = basePath ? `${basePath}${route.path}` : route.path;
|
|
2076
|
+
config[route.key] = {
|
|
2077
|
+
path: fullPath,
|
|
2078
|
+
component: route.component,
|
|
2079
|
+
meta: {
|
|
2080
|
+
label: route.label,
|
|
2081
|
+
icon: route.icon,
|
|
2082
|
+
group: route.group,
|
|
2083
|
+
public: route.public,
|
|
2084
|
+
requiredRoles: route.requiredRoles,
|
|
2085
|
+
requiredPermissions: route.requiredPermissions
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
return config;
|
|
2090
|
+
}
|
|
2091
|
+
function createRootLayout(headerContent, sidebarHeaderContent) {
|
|
2092
|
+
const resolvedSidebarContent = sidebarHeaderContent ?? /* @__PURE__ */ jsx35(SidebarOrgSwitcher, {});
|
|
2093
|
+
return function RootLayout() {
|
|
2094
|
+
return /* @__PURE__ */ jsx35(AuthShell, { headerContent, sidebarHeaderContent: resolvedSidebarContent, children: /* @__PURE__ */ jsx35(WebOutlet, {}) });
|
|
2095
|
+
};
|
|
2096
|
+
}
|
|
2097
|
+
function AuthApp({ config, headerContent, sidebarHeaderContent }) {
|
|
2098
|
+
const mergedConfig = useMemo5(() => mergeWithEnvConfig(config), [config]);
|
|
2099
|
+
const routes = mergedConfig.routes ?? defaultRoutes;
|
|
2100
|
+
const groups = mergedConfig.groups ?? defaultGroups;
|
|
2101
|
+
const resolvedConfig = useMemo5(
|
|
2102
|
+
() => ({ ...mergedConfig, routes, groups }),
|
|
2103
|
+
[mergedConfig, routes, groups]
|
|
2104
|
+
);
|
|
2105
|
+
const router = useMemo5(() => {
|
|
2106
|
+
const routeConfig = convertRoutesToConfig(routes, mergedConfig.basePath);
|
|
2107
|
+
const RootLayout = createRootLayout(headerContent, sidebarHeaderContent);
|
|
2108
|
+
return createWebRouter(routeConfig, {
|
|
2109
|
+
rootComponent: RootLayout,
|
|
2110
|
+
basepath: mergedConfig.basePath || void 0
|
|
2111
|
+
});
|
|
2112
|
+
}, [routes, mergedConfig.basePath, headerContent, sidebarHeaderContent]);
|
|
2113
|
+
return /* @__PURE__ */ jsx35(AuthAppProvider, { config: resolvedConfig, children: /* @__PURE__ */ jsx35(RouterProvider, { router }) });
|
|
2114
|
+
}
|
|
2115
|
+
function AuthAppWithChildren({
|
|
2116
|
+
config,
|
|
2117
|
+
headerContent,
|
|
2118
|
+
sidebarHeaderContent,
|
|
2119
|
+
children
|
|
2120
|
+
}) {
|
|
2121
|
+
const mergedConfig = useMemo5(() => mergeWithEnvConfig(config), [config]);
|
|
2122
|
+
const routes = mergedConfig.routes ?? defaultRoutes;
|
|
2123
|
+
const groups = mergedConfig.groups ?? defaultGroups;
|
|
2124
|
+
const resolvedConfig = useMemo5(
|
|
2125
|
+
() => ({ ...mergedConfig, routes, groups }),
|
|
2126
|
+
[mergedConfig, routes, groups]
|
|
2127
|
+
);
|
|
2128
|
+
const resolvedSidebarContent = sidebarHeaderContent ?? /* @__PURE__ */ jsx35(SidebarOrgSwitcher, {});
|
|
2129
|
+
return /* @__PURE__ */ jsx35(AuthAppProvider, { config: resolvedConfig, children: /* @__PURE__ */ jsx35(AuthShell, { headerContent, sidebarHeaderContent: resolvedSidebarContent, children }) });
|
|
2130
|
+
}
|
|
1369
2131
|
export {
|
|
1370
2132
|
ApiKeys,
|
|
2133
|
+
ApiKeysPage,
|
|
1371
2134
|
AppearanceSchema,
|
|
2135
|
+
AuthApp,
|
|
2136
|
+
AuthAppProvider,
|
|
2137
|
+
AuthAppWithChildren,
|
|
1372
2138
|
AuthGate,
|
|
1373
2139
|
AuthGatePropsSchema,
|
|
1374
2140
|
AuthOrganizationSchema,
|
|
1375
2141
|
AuthSessionSchema,
|
|
2142
|
+
AuthShell,
|
|
2143
|
+
AuthShellConfigProvider,
|
|
2144
|
+
AuthShellNav,
|
|
1376
2145
|
AuthTokenSchema,
|
|
1377
2146
|
AuthUserSchema,
|
|
1378
2147
|
BaseWidgetPropsSchema,
|
|
2148
|
+
Breadcrumbs,
|
|
1379
2149
|
IdentityProvider,
|
|
1380
2150
|
IdentityProviderMinimal,
|
|
1381
2151
|
IdentityProviderPropsSchema,
|
|
1382
2152
|
ImpersonatorSchema,
|
|
2153
|
+
IntegrationsPage,
|
|
1383
2154
|
OrganizationSwitcher,
|
|
1384
2155
|
OrganizationWidgetPropsSchema,
|
|
1385
2156
|
Pipes,
|
|
2157
|
+
ProfilePage,
|
|
1386
2158
|
RadiusSchema,
|
|
1387
2159
|
ScalingSchema,
|
|
1388
2160
|
SecretForm,
|
|
1389
2161
|
SecretsManager,
|
|
2162
|
+
SecurityPage,
|
|
2163
|
+
SessionsPage,
|
|
2164
|
+
SidebarOrgSwitcher,
|
|
1390
2165
|
SignInButton,
|
|
1391
2166
|
SignOutButton,
|
|
2167
|
+
TeamPage,
|
|
1392
2168
|
TeamSwitcher,
|
|
1393
2169
|
UnauthenticatedActionSchema,
|
|
1394
2170
|
UseWidgetTokenOptionsSchema,
|
|
@@ -1404,9 +2180,23 @@ export {
|
|
|
1404
2180
|
VaultItemCard,
|
|
1405
2181
|
VaultList,
|
|
1406
2182
|
VaultProvider,
|
|
2183
|
+
WidgetErrorBoundary,
|
|
1407
2184
|
WidgetsProvider,
|
|
1408
2185
|
WidgetsProviderPropsSchema,
|
|
2186
|
+
accountRoutes,
|
|
2187
|
+
adminRoutes,
|
|
2188
|
+
defaultGroups,
|
|
2189
|
+
defaultRoutes,
|
|
2190
|
+
developerRoutes,
|
|
2191
|
+
getEnvConfig,
|
|
2192
|
+
integrationRoutes,
|
|
2193
|
+
mergeWithEnvConfig,
|
|
1409
2194
|
useAuth6 as useAuth,
|
|
2195
|
+
useAuthShellBranding,
|
|
2196
|
+
useAuthShellConfig,
|
|
2197
|
+
useAuthShellFullPath,
|
|
2198
|
+
useAuthShellRoutes,
|
|
2199
|
+
useAuthShellRoutesByGroup,
|
|
1410
2200
|
useThemeDetection,
|
|
1411
2201
|
useVault,
|
|
1412
2202
|
useVaultContext,
|