@krak-stack/auth 0.1.8 → 0.1.9

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,10 @@
1
+ import type { apiKeyClient } from "@better-auth/api-key/client";
2
+ import type { organizationClient, twoFactorClient } from "better-auth/client/plugins";
3
+ import type { createAuthClient } from "better-auth/react";
4
+ export type AuthUiClient = ReturnType<typeof createAuthClient<{
5
+ plugins: [
6
+ ReturnType<typeof organizationClient>,
7
+ ReturnType<typeof twoFactorClient>,
8
+ ReturnType<typeof apiKeyClient>
9
+ ];
10
+ }>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,3 @@
1
1
  export { OrganizationSwitcher } from "./organization-switcher";
2
2
  export { UserButton } from "./user-button";
3
+ export type { AuthUiClient } from "./auth-client";
@@ -1,17 +1,12 @@
1
1
  import { type ComponentProps, type ReactNode } from "react";
2
2
  import { DropdownMenuContent } from "@/components/ui/dropdown-menu";
3
+ import type { AuthUiClient } from "./auth-client";
3
4
  type OrganizationSwitcherProps = {
5
+ authClient: AuthUiClient;
4
6
  side?: ComponentProps<typeof DropdownMenuContent>["side"];
5
7
  className?: string;
6
8
  renderUnauthenticated?: () => ReactNode;
7
- onChange?: (organization: OrganizationSummary) => void | Promise<void>;
8
9
  locked?: boolean;
9
10
  };
10
- type OrganizationSummary = {
11
- id: string;
12
- name: string;
13
- slug: string;
14
- metadata?: unknown;
15
- };
16
- export declare function OrganizationSwitcher({ side, className, renderUnauthenticated, onChange, locked, }: OrganizationSwitcherProps): import("react").JSX.Element;
11
+ export declare function OrganizationSwitcher({ authClient, side, className, renderUnauthenticated, locked, }: OrganizationSwitcherProps): import("react").JSX.Element;
17
12
  export {};
@@ -16,7 +16,6 @@ import { Separator } from "@/components/ui/separator";
16
16
  import { cn } from "@/lib/utils";
17
17
  import { m } from "@/paraglide/messages";
18
18
  import { getLocale } from "@/paraglide/runtime";
19
- import { centralAuthClient } from "@/services/auth/client/central";
20
19
  import { OrganizationMetadata, } from "@krak-stack/auth/schema";
21
20
  const slugify = (value) => value
22
21
  .trim()
@@ -149,10 +148,10 @@ const organizationMetadataFromForm = async (value) => {
149
148
  }
150
149
  return { translations };
151
150
  };
152
- export function OrganizationSwitcher({ side = "bottom", className, renderUnauthenticated, onChange, locked = false, }) {
153
- const session = centralAuthClient.useSession();
154
- const organizations = centralAuthClient.useListOrganizations();
155
- const activeOrganization = centralAuthClient.useActiveOrganization();
151
+ export function OrganizationSwitcher({ authClient, side = "bottom", className, renderUnauthenticated, locked = false, }) {
152
+ const session = authClient.useSession();
153
+ const organizations = authClient.useListOrganizations();
154
+ const activeOrganization = authClient.useActiveOrganization();
156
155
  const [dialog, setDialog] = useState(null);
157
156
  if (!session.data) {
158
157
  return _jsx(_Fragment, { children: renderUnauthenticated?.() });
@@ -177,30 +176,28 @@ export function OrganizationSwitcher({ side = "bottom", className, renderUnauthe
177
176
  : {}) }) }), hasOrganizationListItems ? _jsx(DropdownMenuSeparator, {}) : null, organizations.isPending ? (_jsx(DropdownMenuItem, { disabled: true, children: m.organization_loading() })) : null, organizations.error ? (_jsx(DropdownMenuItem, { disabled: true, children: organizations.error.message })) : null, !locked && selectableOrganizations.length ? (selectableOrganizations.map((organization) => {
178
177
  const display = organizationDisplay(organization);
179
178
  return (_jsx(DropdownMenuItem, { onClick: async () => {
180
- const result = await centralAuthClient.organization.setActive({
179
+ const result = await authClient.organization.setActive({
181
180
  organizationId: organization.id,
182
181
  });
183
- if (!result.error) {
182
+ if (!result.error)
184
183
  await refresh();
185
- await onChange?.(organization);
186
- }
187
184
  }, children: _jsx(AppBrand, { to: null, label: display.name, subtitle: display.subtitle, icon: Building2, className: "w-full text-left [&>div:first-child]:size-7", ...(display.logo ? { imageSrc: display.logo } : {}) }) }, organization.id));
188
185
  })) : !locked && !organizations.isPending ? (_jsx(DropdownMenuItem, { disabled: true, children: active
189
186
  ? m.organization_switcher_no_other_organizations()
190
187
  : m.organization_switcher_empty() })) : null, !locked ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: () => setDialog("create"), children: [_jsx(Building2, {}), m.organization_create_title()] })] })) : null, activeOrganization.data ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: () => setDialog("manage"), children: [_jsx(PencilIcon, {}), m.organization_switcher_manage()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("members"), children: [_jsx(Users, {}), m.organization_members_title()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] })] })) : null] }) })] }), _jsx(Dialog, { open: dialog === "create", onOpenChange: (open) => {
191
188
  setDialog((current) => open ? "create" : current === "create" ? null : current);
192
- }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() })] }), _jsx(Separator, {}), _jsx(CreateOrganizationSection, { onCreated: async () => {
189
+ }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() })] }), _jsx(Separator, {}), _jsx(CreateOrganizationSection, { authClient: authClient, onCreated: async () => {
193
190
  await refresh();
194
191
  setDialog(null);
195
192
  } })] }) }), _jsx(Dialog, { open: dialog === "manage", onOpenChange: (open) => {
196
193
  setDialog((current) => open ? "manage" : current === "manage" ? null : current);
197
- }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(EditOrganizationSection, { organization: activeOrganization.data, onUpdated: refresh })) : null] }) }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
194
+ }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(EditOrganizationSection, { authClient: authClient, organization: activeOrganization.data, onUpdated: refresh })) : null] }) }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
198
195
  setDialog((current) => open ? "members" : current === "members" ? null : current);
199
- }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_members_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationMembersManager, { organization: activeOrganization.data, currentUserId: session.data.user.id })) : null] }) }), _jsx(Dialog, { open: dialog === "apiKeys", onOpenChange: (open) => {
196
+ }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_members_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationMembersManager, { authClient: authClient, organization: activeOrganization.data, currentUserId: session.data.user.id })) : null] }) }), _jsx(Dialog, { open: dialog === "apiKeys", onOpenChange: (open) => {
200
197
  setDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
201
- }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_api_keys_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationApiKeyManager, { organization: activeOrganization.data })) : null] }) })] }));
198
+ }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_api_keys_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationApiKeyManager, { authClient: authClient, organization: activeOrganization.data })) : null] }) })] }));
202
199
  }
203
- function EditOrganizationSection({ organization, onUpdated, }) {
200
+ function EditOrganizationSection({ authClient, organization, onUpdated, }) {
204
201
  const [editingLocale, setEditingLocale] = useState(currentOrganizationLocale());
205
202
  const defaultValues = organizationFormDefaults(organization);
206
203
  const form = useAppForm({
@@ -210,7 +207,7 @@ function EditOrganizationSection({ organization, onUpdated, }) {
210
207
  const name = value.name.trim();
211
208
  const slug = value.slug.trim().toLowerCase();
212
209
  const metadata = await organizationMetadataFromForm(value);
213
- const result = await centralAuthClient.organization.update({
210
+ const result = await authClient.organization.update({
214
211
  organizationId: organization.id,
215
212
  data: { name, slug, metadata },
216
213
  });
@@ -242,7 +239,7 @@ function EditOrganizationSection({ organization, onUpdated, }) {
242
239
  suggestedHeight: 512,
243
240
  } })) }), _jsx(form.AppField, { name: "frContactEmail", children: (field) => (_jsx(field.TextField, { label: m.organization_contact_email(), placeholder: "team@example.com", type: "email" })) }), _jsx(form.AppField, { name: "frLocation", children: (field) => (_jsx(field.TextField, { label: m.organization_location() })) })] })), _jsx(form.FormError, {}), _jsx(form.SubmitButton, {})] }) }) }));
244
241
  }
245
- function CreateOrganizationSection({ onCreated, }) {
242
+ function CreateOrganizationSection({ authClient, onCreated, }) {
246
243
  const [editingLocale, setEditingLocale] = useState(currentOrganizationLocale());
247
244
  const defaultValues = organizationFormDefaults();
248
245
  const form = useAppForm({
@@ -256,7 +253,7 @@ function CreateOrganizationSection({ onCreated, }) {
256
253
  name,
257
254
  slug,
258
255
  });
259
- const result = await centralAuthClient.organization.create({
256
+ const result = await authClient.organization.create({
260
257
  name,
261
258
  slug,
262
259
  metadata,
@@ -296,7 +293,7 @@ function OrganizationTranslationHeader({ locale, editingLocale, onEditingLocaleC
296
293
  : m.organization_translation_french();
297
294
  return (_jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: title }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_translation_description() })] }), _jsx(EditingLocaleSwitcher, { value: editingLocale, onValueChange: onEditingLocaleChange })] }));
298
295
  }
299
- function OrganizationMembersManager({ organization, currentUserId, }) {
296
+ function OrganizationMembersManager({ authClient, organization, currentUserId, }) {
300
297
  const [members, setMembers] = useState([]);
301
298
  const [invitations, setInvitations] = useState([]);
302
299
  const [error, setError] = useState(null);
@@ -307,10 +304,10 @@ function OrganizationMembersManager({ organization, currentUserId, }) {
307
304
  setLoading(true);
308
305
  setError(null);
309
306
  const [membersResult, invitationsResult] = await Promise.all([
310
- centralAuthClient.organization.listMembers({
307
+ authClient.organization.listMembers({
311
308
  query: { organizationId: organization.id },
312
309
  }),
313
- centralAuthClient.organization.listInvitations({
310
+ authClient.organization.listInvitations({
314
311
  query: { organizationId: organization.id },
315
312
  }),
316
313
  ]);
@@ -336,7 +333,7 @@ function OrganizationMembersManager({ organization, currentUserId, }) {
336
333
  defaultValues: { email: "", role: "member" },
337
334
  onSubmit: async ({ value, formApi }) => {
338
335
  formApi.setErrorMap({ onSubmit: undefined });
339
- const result = await centralAuthClient.organization.inviteMember({
336
+ const result = await authClient.organization.inviteMember({
340
337
  email: value.email.trim(),
341
338
  role: normalizeOrganizationRole(value.role),
342
339
  organizationId: organization.id,
@@ -357,7 +354,7 @@ function OrganizationMembersManager({ organization, currentUserId, }) {
357
354
  const updateRole = async (member, role) => {
358
355
  setUpdatingMemberId(member.id);
359
356
  setError(null);
360
- const result = await centralAuthClient.organization.updateMemberRole({
357
+ const result = await authClient.organization.updateMemberRole({
361
358
  memberId: member.id,
362
359
  role,
363
360
  organizationId: organization.id,
@@ -372,7 +369,7 @@ function OrganizationMembersManager({ organization, currentUserId, }) {
372
369
  const removeMember = async (member) => {
373
370
  setUpdatingMemberId(member.id);
374
371
  setError(null);
375
- const result = await centralAuthClient.organization.removeMember({
372
+ const result = await authClient.organization.removeMember({
376
373
  memberIdOrEmail: member.id,
377
374
  organizationId: organization.id,
378
375
  });
@@ -386,7 +383,7 @@ function OrganizationMembersManager({ organization, currentUserId, }) {
386
383
  const cancelInvitation = async (invitation) => {
387
384
  setCancellingInvitationId(invitation.id);
388
385
  setError(null);
389
- const result = await centralAuthClient.organization.cancelInvitation({
386
+ const result = await authClient.organization.cancelInvitation({
390
387
  invitationId: invitation.id,
391
388
  });
392
389
  setCancellingInvitationId(null);
@@ -481,7 +478,7 @@ const invitationColumns = ({ cancellingInvitationId, onCancel, }) => [
481
478
  },
482
479
  ]),
483
480
  ];
484
- function OrganizationApiKeyManager({ organization, }) {
481
+ function OrganizationApiKeyManager({ authClient, organization, }) {
485
482
  const [keys, setKeys] = useState([]);
486
483
  const [createdKey, setCreatedKey] = useState(null);
487
484
  const [error, setError] = useState(null);
@@ -489,7 +486,7 @@ function OrganizationApiKeyManager({ organization, }) {
489
486
  const loadKeys = useEffectEvent(async () => {
490
487
  setLoading(true);
491
488
  setError(null);
492
- const result = await centralAuthClient.apiKey.list({
489
+ const result = await authClient.apiKey.list({
493
490
  query: { configId: "organization", organizationId: organization.id },
494
491
  });
495
492
  if (result.error) {
@@ -508,7 +505,7 @@ function OrganizationApiKeyManager({ organization, }) {
508
505
  onSubmit: async ({ value, formApi }) => {
509
506
  formApi.setErrorMap({ onSubmit: undefined });
510
507
  setCreatedKey(null);
511
- const result = await centralAuthClient.apiKey.create({
508
+ const result = await authClient.apiKey.create({
512
509
  configId: "organization",
513
510
  organizationId: organization.id,
514
511
  name: value.name.trim(),
@@ -528,7 +525,7 @@ function OrganizationApiKeyManager({ organization, }) {
528
525
  },
529
526
  });
530
527
  const deleteKey = async (key) => {
531
- const result = await centralAuthClient.apiKey.delete({
528
+ const result = await authClient.apiKey.delete({
532
529
  configId: "organization",
533
530
  keyId: key.id,
534
531
  });
@@ -1,10 +1,12 @@
1
1
  import { type ComponentProps, type ReactNode } from "react";
2
2
  import { DropdownMenuContent } from "@/components/ui/dropdown-menu";
3
+ import type { AuthUiClient } from "./auth-client";
3
4
  type UserDropdownProps = {
5
+ authClient: AuthUiClient;
4
6
  signOutRedirect?: string;
5
7
  side?: ComponentProps<typeof DropdownMenuContent>["side"];
6
8
  renderUnauthenticated?: () => ReactNode;
7
9
  apiKeyPermissions?: Record<string, string[]>;
8
10
  };
9
- export declare const UserButton: ({ signOutRedirect, side, renderUnauthenticated, apiKeyPermissions, }: UserDropdownProps) => import("react").JSX.Element;
11
+ export declare const UserButton: ({ authClient, signOutRedirect, side, renderUnauthenticated, apiKeyPermissions, }: UserDropdownProps) => import("react").JSX.Element;
10
12
  export {};
@@ -3,7 +3,7 @@ import {} from "@tanstack/react-table";
3
3
  import { useNavigate, useRouterState, } from "@tanstack/react-router";
4
4
  import { Check, Copy, KeyRound, LogOutIcon, ShieldCheck, Trash2, UserCircleIcon, UserIcon, } from "lucide-react";
5
5
  import { QRCode } from "react-qr-code";
6
- import { useEffect, useState, } from "react";
6
+ import { useEffect, useEffectEvent, useState, } from "react";
7
7
  import { createDataTableActionsColumn, DataTable, } from "@/components/ui/data-table";
8
8
  import { AppBrand } from "@/components/ui/app-brand";
9
9
  import { useAppForm } from "@/components/ui/form";
@@ -15,8 +15,6 @@ import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLeg
15
15
  import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
16
16
  import { Separator } from "@/components/ui/separator";
17
17
  import { m } from "@/paraglide/messages";
18
- import { authClient } from "@/services/auth/client";
19
- import { centralAuthClient } from "@/services/auth/client/central";
20
18
  const isFile = (value) => value instanceof File;
21
19
  const authUrl = (path) => new URL(path, import.meta.env.VITE_KRAKSTACK_AUTH_URL ??
22
20
  globalThis.location?.origin ??
@@ -42,16 +40,14 @@ const presignUserImageUpload = async (file) => {
42
40
  }
43
41
  return { uploadUrl, url };
44
42
  };
45
- export const UserButton = ({ signOutRedirect = "/", side = "bottom", renderUnauthenticated, apiKeyPermissions, }) => {
43
+ export const UserButton = ({ authClient, signOutRedirect = "/", side = "bottom", renderUnauthenticated, apiKeyPermissions, }) => {
46
44
  const navigate = useNavigate();
47
45
  const currentSiteHref = useRouterState({
48
46
  select: (state) => `${import.meta.env.VITE_SITE_URL}${state.location.href}`,
49
47
  });
50
48
  const { data: session, isPending, refetch } = authClient.useSession();
51
- const centralSession = centralAuthClient.useSession();
52
49
  const [settingsDialog, setSettingsDialog] = useState(null);
53
50
  const [formError, setFormError] = useState(null);
54
- const [centralAuthError, setCentralAuthError] = useState(null);
55
51
  if (!session) {
56
52
  return _jsx(_Fragment, { children: renderUnauthenticated?.() });
57
53
  }
@@ -64,10 +60,7 @@ export const UserButton = ({ signOutRedirect = "/", side = "bottom", renderUnaut
64
60
  const redirectUrl = signOutRedirect.startsWith("http")
65
61
  ? signOutRedirect
66
62
  : `${import.meta.env.VITE_SITE_URL}${signOutRedirect.startsWith("/") ? signOutRedirect : `/${signOutRedirect}`}`;
67
- await Promise.allSettled([
68
- authClient.signOut(),
69
- centralAuthClient.signOut(),
70
- ]);
63
+ await authClient.signOut();
71
64
  await navigate({ href: redirectUrl });
72
65
  };
73
66
  const updateUser = async (values) => {
@@ -89,33 +82,19 @@ export const UserButton = ({ signOutRedirect = "/", side = "bottom", renderUnaut
89
82
  : typeof values.image === "string"
90
83
  ? values.image
91
84
  : null;
92
- const result = await centralAuthClient.updateUser({
85
+ const result = await authClient.updateUser({
93
86
  name: values.name.trim(),
94
87
  image: image?.trim() ?? "",
95
88
  });
96
89
  if (isAuthErrorResult(result)) {
97
90
  throw new Error(result.error.message || m.user_form_update_error());
98
91
  }
99
- await centralSession.refetch();
100
92
  await refetch();
101
93
  setSettingsDialog(null);
102
94
  };
103
- const reconnectCentralAuth = async () => {
104
- setCentralAuthError(null);
105
- const result = await authClient.signIn.oauth2({
106
- providerId: "krakstack-auth",
107
- callbackURL: currentSiteHref,
108
- });
109
- if (result.error) {
110
- setCentralAuthError(result.error.message ?? m.user_central_auth_reconnect_error());
111
- return;
112
- }
113
- if (result.data?.url)
114
- await navigate({ href: result.data.url });
115
- };
116
95
  return (_jsxs(_Fragment, { children: [_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "outline", size: "icon", children: [_jsx(UserIcon, { className: "size-4.5" }), _jsx("span", { className: "sr-only", children: m.user_button_aria_label() })] }) }), _jsx(DropdownMenuContent, { className: "w-56 rounded-lg", side: side, align: "end", sideOffset: 4, children: _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: _jsx(AppBrand, { to: null, label: displayName || displayEmail, subtitle: displayName ? displayEmail : m.user_button_account(), icon: UserIcon, className: "px-1 py-1.5 text-left text-sm", ...(displayImage ? { imageSrc: displayImage } : {}) }) }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { disabled: isPending, onClick: () => setSettingsDialog("account"), children: [_jsx(UserCircleIcon, {}), m.user_button_account()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("security"), children: [_jsx(ShieldCheck, {}), m.user_button_security()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: signOut, children: [_jsx(LogOutIcon, {}), m.user_button_logout()] })] }) })] }), _jsx(Dialog, { open: settingsDialog === "account", onOpenChange: (open) => {
117
96
  setSettingsDialog((current) => open ? "account" : current === "account" ? null : current);
118
- }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_form_title() }), _jsx(DialogDescription, { children: m.user_form_description() })] }), _jsx(Separator, {}), centralSession.isPending ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : !centralSession.data ? (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_central_auth_required() }), centralAuthError ? (_jsx("p", { className: "text-destructive text-sm", children: centralAuthError })) : null, _jsx(Button, { type: "button", className: "self-start", onClick: reconnectCentralAuth, children: m.user_central_auth_reconnect() })] })) : (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(UserForm, { defaultValues: {
97
+ }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_form_title() }), _jsx(DialogDescription, { children: m.user_form_description() })] }), _jsx(Separator, {}), isPending ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(UserForm, { defaultValues: {
119
98
  name: displayName ?? "",
120
99
  image: displayImage || null,
121
100
  }, error: formError, onSubmit: async (data) => {
@@ -127,22 +106,22 @@ export const UserButton = ({ signOutRedirect = "/", side = "bottom", renderUnaut
127
106
  ? error.message
128
107
  : m.user_form_update_error());
129
108
  }
130
- } }), _jsx(Separator, {}), _jsx(ConnectedAccounts, { currentSiteHref: currentSiteHref, navigate: navigate }), _jsx(Separator, {}), _jsx(PasswordSettings, {})] }))] }) }), _jsx(Dialog, { open: settingsDialog === "security", onOpenChange: (open) => {
109
+ } }), _jsx(Separator, {}), _jsx(ConnectedAccounts, { authClient: authClient, currentSiteHref: currentSiteHref, navigate: navigate }), _jsx(Separator, {}), _jsx(PasswordSettings, { authClient: authClient })] }))] }) }), _jsx(Dialog, { open: settingsDialog === "security", onOpenChange: (open) => {
131
110
  setSettingsDialog((current) => open ? "security" : current === "security" ? null : current);
132
- }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_security_title() }), _jsx(DialogDescription, { children: m.user_security_description() })] }), _jsx(Separator, {}), _jsx(AccountSecuritySettings, {})] }) }), _jsx(Dialog, { open: settingsDialog === "apiKeys", onOpenChange: (open) => {
111
+ }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_security_title() }), _jsx(DialogDescription, { children: m.user_security_description() })] }), _jsx(Separator, {}), _jsx(AccountSecuritySettings, { authClient: authClient })] }) }), _jsx(Dialog, { open: settingsDialog === "apiKeys", onOpenChange: (open) => {
133
112
  setSettingsDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
134
- }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_api_keys_title() }), _jsx(DialogDescription, { children: m.user_api_keys_description() })] }), _jsx(Separator, {}), _jsx(ApiKeyManager, { permissions: apiKeyPermissions ?? {} })] }) })] }));
113
+ }, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_api_keys_title() }), _jsx(DialogDescription, { children: m.user_api_keys_description() })] }), _jsx(Separator, {}), _jsx(ApiKeyManager, { authClient: authClient, permissions: apiKeyPermissions ?? {} })] }) })] }));
135
114
  };
136
- function ConnectedAccounts({ currentSiteHref, navigate, }) {
115
+ function ConnectedAccounts({ authClient, currentSiteHref, navigate, }) {
137
116
  const [accounts, setAccounts] = useState([]);
138
117
  const [error, setError] = useState(null);
139
118
  const [loading, setLoading] = useState(true);
140
119
  const [isLinking, setIsLinking] = useState(false);
141
120
  const [revokingAccount, setRevokingAccount] = useState(null);
142
- const loadAccounts = async () => {
121
+ const loadAccounts = useEffectEvent(async () => {
143
122
  setLoading(true);
144
123
  setError(null);
145
- const result = await centralAuthClient.listAccounts();
124
+ const result = await authClient.listAccounts();
146
125
  if (result.error) {
147
126
  setError(result.error.message ?? m.user_accounts_load_error());
148
127
  setLoading(false);
@@ -150,7 +129,7 @@ function ConnectedAccounts({ currentSiteHref, navigate, }) {
150
129
  }
151
130
  setAccounts(result.data ?? []);
152
131
  setLoading(false);
153
- };
132
+ });
154
133
  useEffect(() => {
155
134
  void loadAccounts();
156
135
  }, []);
@@ -160,7 +139,7 @@ function ConnectedAccounts({ currentSiteHref, navigate, }) {
160
139
  const linkGoogle = async () => {
161
140
  setError(null);
162
141
  setIsLinking(true);
163
- const result = await centralAuthClient.linkSocial({
142
+ const result = await authClient.linkSocial({
164
143
  provider: "google",
165
144
  callbackURL: currentSiteHref,
166
145
  });
@@ -177,7 +156,7 @@ function ConnectedAccounts({ currentSiteHref, navigate, }) {
177
156
  };
178
157
  const revokeAccount = async (account) => {
179
158
  setError(null);
180
- const result = await centralAuthClient.unlinkAccount({
159
+ const result = await authClient.unlinkAccount({
181
160
  providerId: account.providerId,
182
161
  accountId: account.accountId,
183
162
  });
@@ -188,22 +167,22 @@ function ConnectedAccounts({ currentSiteHref, navigate, }) {
188
167
  setRevokingAccount(null);
189
168
  await loadAccounts();
190
169
  };
191
- return (_jsxs("section", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h2", { className: "text-sm leading-none font-medium", children: m.user_accounts_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_accounts_description() })] }), loading ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : null, _jsx(AccountProviderRow, { initial: "G", title: m.user_account_google_title(), description: m.user_account_google_description(), account: googleAccount, connected: Boolean(googleAccount), canRevoke: canRevokeAccount, connectLabel: m.user_account_google_connect(), revokeLabel: m.user_account_revoke(), onlyMethodLabel: m.user_account_only_method(), isConnecting: isLinking, renderDisconnected: undefined, onConnect: linkGoogle, onRevoke: (account) => setRevokingAccount(account) }), revokingAccount ? (_jsx(RevokeAccountForm, { account: revokingAccount, requirePassword: hasPassword, onCancel: () => setRevokingAccount(null), onRevoke: revokeAccount })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null] }));
170
+ return (_jsxs("section", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h2", { className: "text-sm leading-none font-medium", children: m.user_accounts_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_accounts_description() })] }), loading ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : null, _jsx(AccountProviderRow, { initial: "G", title: m.user_account_google_title(), description: m.user_account_google_description(), account: googleAccount, connected: Boolean(googleAccount), canRevoke: canRevokeAccount, connectLabel: m.user_account_google_connect(), revokeLabel: m.user_account_revoke(), onlyMethodLabel: m.user_account_only_method(), isConnecting: isLinking, renderDisconnected: undefined, onConnect: linkGoogle, onRevoke: (account) => setRevokingAccount(account) }), revokingAccount ? (_jsx(RevokeAccountForm, { authClient: authClient, account: revokingAccount, requirePassword: hasPassword, onCancel: () => setRevokingAccount(null), onRevoke: revokeAccount })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null] }));
192
171
  }
193
172
  function AccountProviderRow({ initial, title, description, account, connected, canRevoke, connectLabel, revokeLabel, onlyMethodLabel, isConnecting, renderDisconnected, onConnect, onRevoke, }) {
194
173
  return (_jsx("div", { className: "flex flex-col gap-3 rounded-lg border p-4", children: _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3", children: [_jsx("span", { className: "bg-background flex size-9 shrink-0 items-center justify-center rounded-full border text-sm font-semibold", children: initial }), _jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("p", { className: "font-medium", children: title }), _jsx(Badge, { variant: connected ? "default" : "secondary", children: connected
195
174
  ? m.user_account_connected()
196
175
  : m.user_account_not_connected() })] }), _jsx("p", { className: "text-muted-foreground text-sm", children: description })] })] }), connected && account ? (_jsx(Button, { type: "button", variant: "outline", disabled: !canRevoke, onClick: () => onRevoke(account), children: canRevoke ? revokeLabel : onlyMethodLabel })) : renderDisconnected ? (renderDisconnected) : (_jsx(Button, { type: "button", variant: "outline", disabled: isConnecting, onClick: onConnect, children: connectLabel }))] }) }));
197
176
  }
198
- function PasswordSettings() {
177
+ function PasswordSettings({ authClient }) {
199
178
  const [accounts, setAccounts] = useState([]);
200
179
  const [error, setError] = useState(null);
201
180
  const [loading, setLoading] = useState(true);
202
181
  const [revokingAccount, setRevokingAccount] = useState(null);
203
- const loadAccounts = async () => {
182
+ const loadAccounts = useEffectEvent(async () => {
204
183
  setLoading(true);
205
184
  setError(null);
206
- const result = await centralAuthClient.listAccounts();
185
+ const result = await authClient.listAccounts();
207
186
  if (result.error) {
208
187
  setError(result.error.message ?? m.user_accounts_load_error());
209
188
  setLoading(false);
@@ -211,7 +190,7 @@ function PasswordSettings() {
211
190
  }
212
191
  setAccounts(result.data ?? []);
213
192
  setLoading(false);
214
- };
193
+ });
215
194
  useEffect(() => {
216
195
  void loadAccounts();
217
196
  }, []);
@@ -220,7 +199,7 @@ function PasswordSettings() {
220
199
  const canRevokeAccount = accounts.length > 1;
221
200
  const revokePassword = async (account) => {
222
201
  setError(null);
223
- const result = await centralAuthClient.unlinkAccount({
202
+ const result = await authClient.unlinkAccount({
224
203
  providerId: account.providerId,
225
204
  accountId: account.accountId,
226
205
  });
@@ -233,16 +212,16 @@ function PasswordSettings() {
233
212
  };
234
213
  return (_jsxs("section", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h2", { className: "text-sm leading-none font-medium", children: m.user_account_password_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_account_password_description() })] }), loading ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : null, hasPassword && passwordAccount ? (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("p", { className: "font-medium", children: m.user_account_password_title() }), _jsx(Badge, { children: m.user_account_connected() })] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_account_password_connected_description() })] }), _jsx(Button, { type: "button", variant: "outline", disabled: !canRevokeAccount, onClick: () => setRevokingAccount(passwordAccount), children: canRevokeAccount
235
214
  ? m.user_account_revoke()
236
- : m.user_account_only_method() })] }), revokingAccount ? (_jsx(RevokeAccountForm, { account: revokingAccount, requirePassword: true, onCancel: () => setRevokingAccount(null), onRevoke: revokePassword })) : null, _jsx(Separator, {}), _jsx(ChangePasswordForm, {})] })) : (_jsx(SetPasswordForm, { onSaved: loadAccounts })), error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null] }));
215
+ : m.user_account_only_method() })] }), revokingAccount ? (_jsx(RevokeAccountForm, { authClient: authClient, account: revokingAccount, requirePassword: true, onCancel: () => setRevokingAccount(null), onRevoke: revokePassword })) : null, _jsx(Separator, {}), _jsx(ChangePasswordForm, { authClient: authClient })] })) : (_jsx(SetPasswordForm, { authClient: authClient, onSaved: loadAccounts })), error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null] }));
237
216
  }
238
- function ChangePasswordForm() {
217
+ function ChangePasswordForm({ authClient }) {
239
218
  const [saved, setSaved] = useState(false);
240
219
  const form = useAppForm({
241
220
  defaultValues: { currentPassword: "", newPassword: "" },
242
221
  onSubmit: async ({ value, formApi }) => {
243
222
  setSaved(false);
244
223
  formApi.setErrorMap({ onSubmit: undefined });
245
- const result = await centralAuthClient.changePassword({
224
+ const result = await authClient.changePassword({
246
225
  currentPassword: value.currentPassword,
247
226
  newPassword: value.newPassword,
248
227
  });
@@ -265,12 +244,12 @@ function ChangePasswordForm() {
265
244
  form.handleSubmit();
266
245
  }, children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("h3", { className: "text-sm font-medium", children: m.user_account_password_change_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_account_password_change_description() })] }), _jsx(form.AppField, { name: "currentPassword", children: (field) => (_jsx(field.TextField, { label: m.user_account_current_password(), type: "password", autoComplete: "current-password", required: true })) }), _jsx(form.AppField, { name: "newPassword", children: (field) => (_jsx(field.TextField, { label: m.user_account_new_password(), type: "password", autoComplete: "new-password", required: true })) }), _jsx(form.FormError, {}), saved ? (_jsx("p", { className: "text-sm text-green-600", children: m.user_account_password_change_success() })) : null, _jsx(Button, { type: "submit", className: "self-start", children: m.user_account_password_change_submit() })] }) }));
267
246
  }
268
- function SetPasswordForm({ onSaved }) {
247
+ function SetPasswordForm({ authClient, onSaved, }) {
269
248
  const form = useAppForm({
270
249
  defaultValues: { password: "" },
271
250
  onSubmit: async ({ value, formApi }) => {
272
251
  formApi.setErrorMap({ onSubmit: undefined });
273
- const result = await centralAuthClient.$fetch("/set-password", {
252
+ const result = await authClient.$fetch("/set-password", {
274
253
  method: "POST",
275
254
  body: { newPassword: value.password },
276
255
  });
@@ -293,13 +272,13 @@ function SetPasswordForm({ onSaved }) {
293
272
  form.handleSubmit();
294
273
  }, children: [_jsx(form.AppField, { name: "password", children: (field) => (_jsx(field.TextField, { label: m.user_account_new_password(), type: "password", autoComplete: "new-password", required: true })) }), _jsx(form.FormError, {}), _jsx(Button, { type: "submit", className: "self-start", children: m.user_account_password_set() })] }) }));
295
274
  }
296
- function RevokeAccountForm({ account, requirePassword, onCancel, onRevoke, }) {
275
+ function RevokeAccountForm({ authClient, account, requirePassword, onCancel, onRevoke, }) {
297
276
  const form = useAppForm({
298
277
  defaultValues: { password: "" },
299
278
  onSubmit: async ({ value, formApi }) => {
300
279
  formApi.setErrorMap({ onSubmit: undefined });
301
280
  if (requirePassword) {
302
- const verified = await centralAuthClient.$fetch("/verify-password", {
281
+ const verified = await authClient.$fetch("/verify-password", {
303
282
  method: "POST",
304
283
  body: { password: value.password },
305
284
  });
@@ -347,28 +326,28 @@ const UserForm = ({ defaultValues, error, onSubmit, }) => {
347
326
  suggestedHeight: 512,
348
327
  } })) }), _jsx(form.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.user_form_name_label(), autoComplete: "name", required: true })) }), error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error })), _jsx(form.SubmitButton, {})] }) })] }));
349
328
  };
350
- function AccountSecuritySettings() {
351
- const session = centralAuthClient.useSession();
329
+ function AccountSecuritySettings({ authClient }) {
330
+ const session = authClient.useSession();
352
331
  const [setup, setSetup] = useState(null);
353
332
  const [message, setMessage] = useState(null);
354
333
  const twoFactorEnabled = hasTwoFactorEnabled(session.data?.user);
355
334
  return (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h2", { className: "text-sm leading-none font-medium", children: m.user_two_factor_title() }), _jsx("p", { className: "text-muted-foreground text-xs", children: m.user_two_factor_description() })] }), _jsx(Badge, { variant: twoFactorEnabled ? "default" : "secondary", children: twoFactorEnabled
356
335
  ? m.user_two_factor_enabled()
357
- : m.user_two_factor_disabled() })] }), twoFactorEnabled ? (_jsx(DisableTotpForm, { onDisabled: async () => {
336
+ : m.user_two_factor_disabled() })] }), twoFactorEnabled ? (_jsx(DisableTotpForm, { authClient: authClient, onDisabled: async () => {
358
337
  setMessage(m.user_two_factor_disabled_message());
359
338
  await session.refetch();
360
- } })) : setup ? (_jsx(VerifyTotpSetup, { setup: setup, onVerified: async () => {
339
+ } })) : setup ? (_jsx(VerifyTotpSetup, { authClient: authClient, setup: setup, onVerified: async () => {
361
340
  setSetup(null);
362
341
  setMessage(m.user_two_factor_enabled_message());
363
342
  await session.refetch();
364
- } })) : (_jsx(EnableTotpForm, { onEnabled: setSetup })), message ? (_jsx("p", { className: "text-muted-foreground text-sm", children: message })) : null] }));
343
+ } })) : (_jsx(EnableTotpForm, { authClient: authClient, onEnabled: setSetup })), message ? (_jsx("p", { className: "text-muted-foreground text-sm", children: message })) : null] }));
365
344
  }
366
- function EnableTotpForm({ onEnabled, }) {
345
+ function EnableTotpForm({ authClient, onEnabled, }) {
367
346
  const form = useAppForm({
368
347
  defaultValues: { password: "" },
369
348
  onSubmit: async ({ value, formApi }) => {
370
349
  formApi.setErrorMap({ onSubmit: undefined });
371
- const result = await centralAuthClient.twoFactor.enable({
350
+ const result = await authClient.twoFactor.enable({
372
351
  password: value.password,
373
352
  });
374
353
  if (result.error || !result.data) {
@@ -392,12 +371,12 @@ function EnableTotpForm({ onEnabled, }) {
392
371
  form.handleSubmit();
393
372
  }, children: [_jsx(form.AppField, { name: "password", children: (field) => (_jsx(field.TextField, { label: m.user_field_password(), type: "password", autoComplete: "current-password", required: true })) }), _jsx(form.FormError, {}), _jsx(form.SubmitButton, {})] }) }));
394
373
  }
395
- function VerifyTotpSetup({ setup, onVerified, }) {
374
+ function VerifyTotpSetup({ authClient, setup, onVerified, }) {
396
375
  const form = useAppForm({
397
376
  defaultValues: { code: "" },
398
377
  onSubmit: async ({ value, formApi }) => {
399
378
  formApi.setErrorMap({ onSubmit: undefined });
400
- const result = await centralAuthClient.twoFactor.verifyTotp({
379
+ const result = await authClient.twoFactor.verifyTotp({
401
380
  code: value.code.trim(),
402
381
  });
403
382
  if (result.error) {
@@ -418,12 +397,12 @@ function VerifyTotpSetup({ setup, onVerified, }) {
418
397
  form.handleSubmit();
419
398
  }, children: [_jsx(form.AppField, { name: "code", children: (field) => (_jsx(field.TextField, { label: m.user_two_factor_code(), autoComplete: "one-time-code", inputMode: "numeric", required: true })) }), _jsx(form.FormError, {}), _jsx(form.SubmitButton, {})] }) })] }));
420
399
  }
421
- function DisableTotpForm({ onDisabled }) {
400
+ function DisableTotpForm({ authClient, onDisabled, }) {
422
401
  const form = useAppForm({
423
402
  defaultValues: { password: "" },
424
403
  onSubmit: async ({ value, formApi }) => {
425
404
  formApi.setErrorMap({ onSubmit: undefined });
426
- const result = await centralAuthClient.twoFactor.disable({
405
+ const result = await authClient.twoFactor.disable({
427
406
  password: value.password,
428
407
  });
429
408
  if (result.error) {
@@ -444,7 +423,7 @@ function DisableTotpForm({ onDisabled }) {
444
423
  form.handleSubmit();
445
424
  }, children: [_jsx(form.AppField, { name: "password", children: (field) => (_jsx(field.TextField, { label: m.user_field_password(), type: "password", autoComplete: "current-password", required: true })) }), _jsx(form.FormError, {}), _jsx(form.SubmitButton, {})] }) }));
446
425
  }
447
- function ApiKeyManager({ permissions = {}, }) {
426
+ function ApiKeyManager({ authClient, permissions = {}, }) {
448
427
  const [keys, setKeys] = useState([]);
449
428
  const [createdKey, setCreatedKey] = useState(null);
450
429
  const [copiedKey, setCopiedKey] = useState(false);
@@ -452,10 +431,10 @@ function ApiKeyManager({ permissions = {}, }) {
452
431
  const [loading, setLoading] = useState(true);
453
432
  const permissionOptions = getPermissionOptions(permissions);
454
433
  const [selectedPermissions, setSelectedPermissions] = useState({});
455
- const loadKeys = async () => {
434
+ const loadKeys = useEffectEvent(async () => {
456
435
  setLoading(true);
457
436
  setError(null);
458
- const result = await centralAuthClient.apiKey.list({
437
+ const result = await authClient.apiKey.list({
459
438
  query: { configId: "user" },
460
439
  });
461
440
  if (result.error) {
@@ -465,7 +444,7 @@ function ApiKeyManager({ permissions = {}, }) {
465
444
  }
466
445
  setKeys(result.data?.apiKeys ?? []);
467
446
  setLoading(false);
468
- };
447
+ });
469
448
  useEffect(() => {
470
449
  void loadKeys();
471
450
  }, []);
@@ -476,7 +455,7 @@ function ApiKeyManager({ permissions = {}, }) {
476
455
  setCreatedKey(null);
477
456
  setCopiedKey(false);
478
457
  const selectedPermissionObject = getSelectedPermissionObject(permissionOptions, selectedPermissions);
479
- const result = await centralAuthClient.$fetch("/create-api-key", {
458
+ const result = await authClient.$fetch("/create-api-key", {
480
459
  method: "POST",
481
460
  body: {
482
461
  configId: "user",
@@ -511,7 +490,7 @@ function ApiKeyManager({ permissions = {}, }) {
511
490
  window.setTimeout(() => setCopiedKey(false), 2000);
512
491
  };
513
492
  const deleteKey = async (key) => {
514
- const result = await centralAuthClient.apiKey.delete({
493
+ const result = await authClient.apiKey.delete({
515
494
  configId: "user",
516
495
  keyId: key.id,
517
496
  });
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "./schema";
2
2
  export { AuthClient, AuthClientConfig } from "./client";
3
- export { OrganizationSwitcher, UserButton } from "./components";
3
+ export { OrganizationSwitcher, UserButton, type AuthUiClient, } from "./components";
4
4
  export * as Backend from "./backend";
5
5
  export * as Frontend from "./frontend";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "./schema";
2
2
  export { AuthClient, AuthClientConfig } from "./client";
3
- export { OrganizationSwitcher, UserButton } from "./components";
3
+ export { OrganizationSwitcher, UserButton, } from "./components";
4
4
  export * as Backend from "./backend";
5
5
  export * as Frontend from "./frontend";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/auth",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Effect HttpApi clients and schemas for KrakStack Auth.",
5
5
  "license": "MIT",
6
6
  "files": [