@krak-stack/auth 0.1.39 → 0.1.40

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.
@@ -1,8 +1,9 @@
1
1
  import type { apiKeyClient } from "@better-auth/api-key/client";
2
- import type { emailOTPClient, genericOAuthClient, lastLoginMethodClient, organizationClient, twoFactorClient } from "better-auth/client/plugins";
2
+ import type { adminClient, emailOTPClient, genericOAuthClient, lastLoginMethodClient, organizationClient, twoFactorClient } from "better-auth/client/plugins";
3
3
  import type { createAuthClient } from "better-auth/react";
4
4
  export type AuthUiClient = ReturnType<typeof createAuthClient<{
5
5
  plugins: [
6
+ ReturnType<typeof adminClient>,
6
7
  ReturnType<typeof emailOTPClient>,
7
8
  ReturnType<typeof lastLoginMethodClient>,
8
9
  ReturnType<typeof organizationClient>,
@@ -12,23 +12,24 @@ export type KrakstackAuthProviderProps = {
12
12
  export type KrakstackAuthContextValue = {
13
13
  locale: KrakstackAuthLocale;
14
14
  baseUrl?: string | undefined;
15
+ projectId?: string | null | undefined;
15
16
  authClient: AuthUiClient;
16
17
  projectConfig: ExtraProjectPublicConfig | null;
17
18
  };
18
19
  export declare function KrakstackAuthProvider({ children, locale, baseUrl, projectId, authClient, }: KrakstackAuthProviderProps): import("react").JSX.Element;
19
20
  export declare const useKrakstackAuth: () => KrakstackAuthContextValue | null;
20
- export declare const useKrakstackAuthProjectConfig: () => {
21
- readonly projectKey: string;
22
- readonly name: string | null;
23
- readonly logoUrl: string | null;
24
- readonly authDomain: string | null;
25
- readonly rootDomain: string | null;
26
- readonly themeCss: string | null;
27
- readonly authOptions: {
28
- readonly emailPassword: boolean;
29
- readonly emailOtp: boolean;
30
- readonly google: boolean;
31
- readonly signUp: boolean;
32
- readonly signUpName: boolean;
33
- };
34
- } | null;
21
+ export declare const useKrakstackAuthProjectConfig: () => import("effect/Schema").Struct.ReadonlySide<{
22
+ readonly projectKey: import("effect/Schema").String;
23
+ readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
24
+ readonly logoUrl: import("effect/Schema").NullOr<import("effect/Schema").String>;
25
+ readonly authDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
26
+ readonly rootDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
27
+ readonly themeCss: import("effect/Schema").NullOr<import("effect/Schema").String>;
28
+ readonly authOptions: import("effect/Schema").Struct<{
29
+ readonly emailPassword: import("effect/Schema").Boolean;
30
+ readonly emailOtp: import("effect/Schema").Boolean;
31
+ readonly google: import("effect/Schema").Boolean;
32
+ readonly signUp: import("effect/Schema").Boolean;
33
+ readonly signUpName: import("effect/Schema").Boolean;
34
+ }>;
35
+ }, "Type"> | null;
@@ -2,14 +2,26 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { apiKeyClient } from "@better-auth/api-key/client";
3
3
  import { useAtomSuspense } from "@effect/atom-react";
4
4
  import { useRouterState } from "@tanstack/react-router";
5
- import { emailOTPClient, genericOAuthClient, lastLoginMethodClient, organizationClient, twoFactorClient, } from "better-auth/client/plugins";
5
+ import { adminClient, emailOTPClient, genericOAuthClient, lastLoginMethodClient, organizationClient, twoFactorClient, } from "better-auth/client/plugins";
6
6
  import { createAuthClient } from "better-auth/react";
7
- import { createContext, useContext, useMemo } from "react";
7
+ import { createContext, useContext, useEffect, useMemo, } from "react";
8
8
  import { authApiClient } from "./auth-api-client";
9
9
  const KrakstackAuthContext = createContext(null);
10
+ const PROJECT_CONTEXT_COOKIE = "krakstack-auth.project_context";
11
+ const setProjectContextCookie = (projectId) => {
12
+ if (typeof document === "undefined")
13
+ return;
14
+ const secure = window.location.protocol === "https:" ? "; Secure" : "";
15
+ if (!projectId) {
16
+ document.cookie = `${PROJECT_CONTEXT_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
17
+ return;
18
+ }
19
+ document.cookie = `${PROJECT_CONTEXT_COOKIE}=${encodeURIComponent(projectId)}; Path=/; Max-Age=600; SameSite=Lax${secure}`;
20
+ };
10
21
  const createAuthUiClient = (baseUrl) => createAuthClient({
11
22
  ...(baseUrl ? { baseURL: baseUrl } : {}),
12
23
  plugins: [
24
+ adminClient(),
13
25
  emailOTPClient(),
14
26
  lastLoginMethodClient(),
15
27
  organizationClient(),
@@ -70,9 +82,22 @@ const useProjectConfig = (baseUrl, providedProjectId) => {
70
82
  return result.value;
71
83
  };
72
84
  export function KrakstackAuthProvider({ children, locale = "en", baseUrl, projectId, authClient, }) {
85
+ const searchString = useRouterState({
86
+ select: (state) => state.location.searchStr,
87
+ });
88
+ const resolvedProjectId = projectId ?? getSearchParam(searchString, "projectId");
73
89
  const resolvedAuthClient = useMemo(() => authClient ?? createAuthUiClient(baseUrl), [authClient, baseUrl]);
74
90
  const projectConfig = useProjectConfig(baseUrl, projectId);
75
- const value = useMemo(() => ({ authClient: resolvedAuthClient, baseUrl, locale, projectConfig }), [resolvedAuthClient, baseUrl, locale, projectConfig]);
91
+ useEffect(() => {
92
+ setProjectContextCookie(resolvedProjectId);
93
+ }, [resolvedProjectId]);
94
+ const value = useMemo(() => ({
95
+ authClient: resolvedAuthClient,
96
+ baseUrl,
97
+ locale,
98
+ projectId: resolvedProjectId,
99
+ projectConfig,
100
+ }), [resolvedAuthClient, baseUrl, locale, resolvedProjectId, projectConfig]);
76
101
  return (_jsx(KrakstackAuthContext.Provider, { value: value, children: children }));
77
102
  }
78
103
  export const useKrakstackAuth = () => useContext(KrakstackAuthContext);
@@ -2,6 +2,9 @@ export { KrakstackAuthProvider, useKrakstackAuth, useKrakstackAuthProjectConfig,
2
2
  export { OrganizationSwitcher } from "./organization-switcher";
3
3
  export { ResetPassword, Signin, Signup, TwoFactor } from "./auth-forms";
4
4
  export { UserButton } from "./user-button";
5
+ export { AdminOrganizationsTable } from "./admin-organizations";
6
+ export { AdminOrganizationForm } from "./admin-organization-form";
7
+ export { AdminUsersTable, useAdminUsersTotal } from "./admin-users";
5
8
  export type { KrakstackAuthContextValue, KrakstackAuthLocale, KrakstackAuthProviderProps, } from "./auth-provider";
6
9
  export type { OrganizationSwitcherDialog } from "./organization-switcher";
7
10
  export type { UserButtonDialog } from "./user-button";
@@ -2,3 +2,6 @@ export { KrakstackAuthProvider, useKrakstackAuth, useKrakstackAuthProjectConfig,
2
2
  export { OrganizationSwitcher } from "./organization-switcher";
3
3
  export { ResetPassword, Signin, Signup, TwoFactor } from "./auth-forms";
4
4
  export { UserButton } from "./user-button";
5
+ export { AdminOrganizationsTable } from "./admin-organizations";
6
+ export { AdminOrganizationForm } from "./admin-organization-form";
7
+ export { AdminUsersTable, useAdminUsersTotal } from "./admin-users";
@@ -52,10 +52,15 @@ declare const messages: {
52
52
  readonly user_api_keys_load_error: "Could not load API keys.";
53
53
  readonly user_api_keys_title: "API keys";
54
54
  readonly user_button_account: "Account";
55
+ readonly user_button_admin_organizations: "Organizations";
56
+ readonly user_button_admin_organizations_description: "Review and manage organizations.";
57
+ readonly user_button_admin_users: "Users";
58
+ readonly user_button_admin_users_description: "Review and manage users.";
55
59
  readonly user_button_api_keys: "API keys";
56
60
  readonly user_button_aria_label: "Open user menu";
57
61
  readonly user_button_logout: "Log out";
58
62
  readonly user_button_security: "Security";
63
+ readonly user_button_stop_impersonating: "Stop impersonating";
59
64
  readonly user_delete: "Delete";
60
65
  readonly user_field_password: "Password";
61
66
  readonly user_form_description: "Update the profile details associated with your account.";
@@ -134,10 +139,15 @@ declare const messages: {
134
139
  readonly user_api_keys_load_error: "Impossible de charger les clés API.";
135
140
  readonly user_api_keys_title: "Clés API";
136
141
  readonly user_button_account: "Compte";
142
+ readonly user_button_admin_organizations: "Organisations";
143
+ readonly user_button_admin_organizations_description: "Consultez et gérez les organisations.";
144
+ readonly user_button_admin_users: "Utilisateurs";
145
+ readonly user_button_admin_users_description: "Consultez et gérez les utilisateurs.";
137
146
  readonly user_button_api_keys: "Clés API";
138
147
  readonly user_button_aria_label: "Ouvrir le menu utilisateur";
139
148
  readonly user_button_logout: "Se déconnecter";
140
149
  readonly user_button_security: "Sécurité";
150
+ readonly user_button_stop_impersonating: "Arrêter l'imitation";
141
151
  readonly user_delete: "Supprimer";
142
152
  readonly user_field_password: "Mot de passe";
143
153
  readonly user_form_description: "Mettez à jour les informations de profil associées à votre compte.";
@@ -182,6 +192,6 @@ type UserDropdownProps = {
182
192
  dialog?: UserButtonDialog | null;
183
193
  onDialogChange?: (dialog: UserButtonDialog | null) => void;
184
194
  };
185
- export type UserButtonDialog = "account" | "security" | "apiKeys";
195
+ export type UserButtonDialog = "account" | "security" | "apiKeys" | "adminUsers" | "adminOrganizations";
186
196
  export declare const UserButton: ({ authClient, baseUrl, signOutRedirect, side, defaultDialog, hideTrigger, renderUnauthenticated, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }: UserDropdownProps) => import("react").JSX.Element;
187
197
  export {};
@@ -4,7 +4,7 @@ import {} from "@tanstack/react-table";
4
4
  import { useNavigate, useRouterState, } from "@tanstack/react-router";
5
5
  import { Effect, Schema } from "effect";
6
6
  import { AsyncResult, Atom } from "effect/unstable/reactivity";
7
- import { Check, Copy, KeyRound, LogOutIcon, ShieldCheck, Trash2, UserCircleIcon, UserIcon, } from "lucide-react";
7
+ import { Check, Copy, Building2, KeyRound, LogOutIcon, ShieldCheck, StopCircle, Trash2, UserCircleIcon, Users, UserIcon, } from "lucide-react";
8
8
  import { QRCode } from "react-qr-code";
9
9
  import { createContext, useContext, useState, } from "react";
10
10
  import { DataTable } from "@/components/ui/data-table";
@@ -23,6 +23,13 @@ import { createApiKey } from "./api-key";
23
23
  import { useOpenedOnce } from "./hooks";
24
24
  import { ExtraUploadedAsset } from "../extra/schema";
25
25
  import { assetPath, assetUrl } from "./utils";
26
+ import { AdminOrganizationsTable } from "./admin-organizations";
27
+ import { AdminUsersTable } from "./admin-users";
28
+ const defaultAdminTableSearch = {
29
+ page: 0,
30
+ pageSize: 10,
31
+ globalFilter: "",
32
+ };
26
33
  const messages = {
27
34
  en: {
28
35
  api_key_rate_limit_notice: "API keys are subject to the same rate limits as your account.",
@@ -74,10 +81,15 @@ const messages = {
74
81
  user_api_keys_load_error: "Could not load API keys.",
75
82
  user_api_keys_title: "API keys",
76
83
  user_button_account: "Account",
84
+ user_button_admin_organizations: "Organizations",
85
+ user_button_admin_organizations_description: "Review and manage organizations.",
86
+ user_button_admin_users: "Users",
87
+ user_button_admin_users_description: "Review and manage users.",
77
88
  user_button_api_keys: "API keys",
78
89
  user_button_aria_label: "Open user menu",
79
90
  user_button_logout: "Log out",
80
91
  user_button_security: "Security",
92
+ user_button_stop_impersonating: "Stop impersonating",
81
93
  user_delete: "Delete",
82
94
  user_field_password: "Password",
83
95
  user_form_description: "Update the profile details associated with your account.",
@@ -156,10 +168,15 @@ const messages = {
156
168
  user_api_keys_load_error: "Impossible de charger les clés API.",
157
169
  user_api_keys_title: "Clés API",
158
170
  user_button_account: "Compte",
171
+ user_button_admin_organizations: "Organisations",
172
+ user_button_admin_organizations_description: "Consultez et gérez les organisations.",
173
+ user_button_admin_users: "Utilisateurs",
174
+ user_button_admin_users_description: "Consultez et gérez les utilisateurs.",
159
175
  user_button_api_keys: "Clés API",
160
176
  user_button_aria_label: "Ouvrir le menu utilisateur",
161
177
  user_button_logout: "Se déconnecter",
162
178
  user_button_security: "Sécurité",
179
+ user_button_stop_impersonating: "Arrêter l'imitation",
163
180
  user_delete: "Supprimer",
164
181
  user_field_password: "Mot de passe",
165
182
  user_form_description: "Mettez à jour les informations de profil associées à votre compte.",
@@ -208,6 +225,12 @@ const userButtonMessageFns = (labels) => new Proxy({}, {
208
225
  });
209
226
  const UserButtonMessagesContext = createContext(userButtonMessageFns(userButtonMessages()));
210
227
  const useUserButtonMessages = () => useContext(UserButtonMessagesContext);
228
+ const hasRole = (role, roles) => typeof role === "string" &&
229
+ role.split(",").some((item) => roles.includes(item.trim().toLowerCase()));
230
+ const hasAdminRole = (user) => typeof user === "object" &&
231
+ user !== null &&
232
+ "role" in user &&
233
+ hasRole(user.role, ["admin"]);
211
234
  const isFile = (value) => value instanceof File;
212
235
  const decodeUploadedAsset = Schema.decodeUnknownPromise(ExtraUploadedAsset);
213
236
  const uploadUserImageAsset = async (file, m, uploadUserImage) => {
@@ -253,8 +276,15 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
253
276
  const currentSiteHref = useRouterState({
254
277
  select: (state) => `${import.meta.env.VITE_SITE_URL}${state.location.href}`,
255
278
  });
279
+ const adminTableSearch = useRouterState({
280
+ select: (state) => ({
281
+ ...defaultAdminTableSearch,
282
+ ...state.location.search,
283
+ }),
284
+ });
256
285
  const { data: session, isPending, refetch } = authClient.useSession();
257
286
  const [uncontrolledDialog, setUncontrolledDialog] = useState(defaultDialog);
287
+ const [isStoppingImpersonation, setIsStoppingImpersonation] = useState(false);
258
288
  const settingsDialog = controlledDialog !== undefined ? controlledDialog : uncontrolledDialog;
259
289
  const [formError, setFormError] = useState(null);
260
290
  const shouldLoadAccounts = Boolean(session) &&
@@ -292,6 +322,8 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
292
322
  const displayName = session.user.name.trim();
293
323
  const displayEmail = session.user.email.trim();
294
324
  const displayImage = assetUrl(session.user.image, baseUrl);
325
+ const isImpersonating = Boolean(session.session.impersonatedBy);
326
+ const isAdmin = hasAdminRole(session.user);
295
327
  const signOut = async () => {
296
328
  const redirectUrl = signOutRedirect.startsWith("http")
297
329
  ? signOutRedirect
@@ -299,6 +331,17 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
299
331
  await authClient.signOut();
300
332
  await navigate({ href: redirectUrl });
301
333
  };
334
+ const stopImpersonating = async () => {
335
+ setIsStoppingImpersonation(true);
336
+ try {
337
+ await authClient.admin.stopImpersonating();
338
+ await refetch();
339
+ await navigate({ href: currentSiteHref });
340
+ }
341
+ finally {
342
+ setIsStoppingImpersonation(false);
343
+ }
344
+ };
302
345
  const updateUser = async (values) => {
303
346
  setFormError(null);
304
347
  const imageFile = isFile(values.image) ? values.image : null;
@@ -320,7 +363,7 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
320
363
  await refetch();
321
364
  setSettingsDialog(null);
322
365
  };
323
- return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "outline", size: "icon", children: [displayImage ? (_jsx("img", { src: displayImage, alt: displayName || displayEmail, className: "size-full rounded-md object-cover" })) : (_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) => {
366
+ return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "outline", size: "icon", children: [displayImage ? (_jsx("img", { src: displayImage, alt: displayName || displayEmail, className: "size-full rounded-md object-cover" })) : (_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, {}), isAdmin || isImpersonating ? (_jsxs(_Fragment, { children: [isAdmin ? (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("adminUsers"), children: [_jsx(Users, {}), m.user_button_admin_users()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("adminOrganizations"), children: [_jsx(Building2, {}), m.user_button_admin_organizations()] })] })) : null, isImpersonating ? (_jsxs(DropdownMenuItem, { disabled: isStoppingImpersonation, onClick: stopImpersonating, children: [_jsx(StopCircle, {}), m.user_button_stop_impersonating()] })) : null, _jsx(DropdownMenuSeparator, {})] })) : null, _jsxs(DropdownMenuItem, { onClick: signOut, children: [_jsx(LogOutIcon, {}), m.user_button_logout()] })] }) })] })), _jsx(Dialog, { open: settingsDialog === "account", onOpenChange: (open) => {
324
367
  setSettingsDialog((current) => open ? "account" : current === "account" ? null : current);
325
368
  }, 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: {
326
369
  name: displayName ?? "",
@@ -338,7 +381,15 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
338
381
  setSettingsDialog((current) => open ? "security" : current === "security" ? null : current);
339
382
  }, 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, {}), _jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(PasswordSettings, { authClient: authClient, baseUrl: baseUrl, accountCache: accountCache }), _jsx(Separator, {}), _jsx(AccountSecuritySettings, { authClient: authClient, accountCache: accountCache })] })] }) }), _jsx(Dialog, { open: settingsDialog === "apiKeys", onOpenChange: (open) => {
340
383
  setSettingsDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
341
- }, 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, active: settingsDialog === "apiKeys", permissions: apiKeyPermissions ?? {} })] }) })] }));
384
+ }, 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, active: settingsDialog === "apiKeys", permissions: apiKeyPermissions ?? {} })] }) }), isAdmin ? (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: settingsDialog === "adminUsers", onOpenChange: (open) => {
385
+ setSettingsDialog((current) => open ? "adminUsers" : current === "adminUsers" ? null : current);
386
+ }, children: _jsxs(DialogContent, { className: "flex h-[85vh] flex-col overflow-y-auto sm:max-w-6xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_button_admin_users() }), _jsx(DialogDescription, { children: m.user_button_admin_users_description() })] }), _jsx(Separator, {}), _jsx("div", { className: "min-h-0 flex-1", children: _jsx(AdminUsersTable, { search: adminTableSearch }) })] }) }), _jsx(Dialog, { open: settingsDialog === "adminOrganizations", onOpenChange: (open) => {
387
+ setSettingsDialog((current) => open
388
+ ? "adminOrganizations"
389
+ : current === "adminOrganizations"
390
+ ? null
391
+ : current);
392
+ }, children: _jsxs(DialogContent, { className: "flex h-[85vh] flex-col overflow-y-auto sm:max-w-6xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_button_admin_organizations() }), _jsx(DialogDescription, { children: m.user_button_admin_organizations_description() })] }), _jsx(Separator, {}), _jsx("div", { className: "min-h-0 flex-1", children: _jsx(AdminOrganizationsTable, { search: adminTableSearch }) })] }) })] })) : null] }));
342
393
  };
343
394
  function ConnectedAccounts({ authClient, baseUrl, accountCache, googleEnabled, currentSiteHref, navigate, }) {
344
395
  const m = useUserButtonMessages();
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { AuthApi } from "./api";
3
3
  export { AuthService, type AuthServiceLayerOptions } from "./service";
4
4
  export { AuthClientConfig } from "./config";
5
5
  export { proxyAuthRequest } from "./server/proxy";
6
- export { OrganizationSwitcher, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, UserButton, type AuthUiClient, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type UserButtonDialog, } from "./components";
6
+ export { OrganizationSwitcher, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, type AuthUiClient, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type UserButtonDialog, useAdminUsersTotal, } from "./components";
7
7
  export * as BetterAuth from "./better-auth";
8
8
  export * as Extra from "./extra";
9
9
  export * as Server from "./server";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ export { AuthApi } from "./api";
3
3
  export { AuthService } from "./service";
4
4
  export { AuthClientConfig } from "./config";
5
5
  export { proxyAuthRequest } from "./server/proxy";
6
- export { OrganizationSwitcher, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, UserButton, } from "./components";
6
+ export { OrganizationSwitcher, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, useAdminUsersTotal, } from "./components";
7
7
  export * as BetterAuth from "./better-auth";
8
8
  export * as Extra from "./extra";
9
9
  export * as Server from "./server";
@@ -127,7 +127,11 @@ export declare const ServerDomainsApiGroup: HttpApiGroup.HttpApiGroup<"domains",
127
127
  readonly hostname: import("effect/Schema").String;
128
128
  readonly rootHostname: import("effect/Schema").String;
129
129
  readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
130
+ readonly projectName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
131
+ readonly projectLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
130
132
  readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
133
+ readonly organizationName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
134
+ readonly organizationLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
131
135
  readonly hostnameId: import("effect/Schema").String;
132
136
  readonly managed: import("effect/Schema").Boolean;
133
137
  readonly active: import("effect/Schema").Boolean;
@@ -140,7 +144,11 @@ export declare const ServerDomainsApiGroup: HttpApiGroup.HttpApiGroup<"domains",
140
144
  readonly hostname: import("effect/Schema").String;
141
145
  readonly rootHostname: import("effect/Schema").String;
142
146
  readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
147
+ readonly projectName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
148
+ readonly projectLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
143
149
  readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
150
+ readonly organizationName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
151
+ readonly organizationLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
144
152
  readonly hostnameId: import("effect/Schema").String;
145
153
  readonly managed: import("effect/Schema").Boolean;
146
154
  readonly active: import("effect/Schema").Boolean;
@@ -153,7 +161,11 @@ export declare const ServerDomainsApiGroup: HttpApiGroup.HttpApiGroup<"domains",
153
161
  readonly hostname: import("effect/Schema").String;
154
162
  readonly rootHostname: import("effect/Schema").String;
155
163
  readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
164
+ readonly projectName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
165
+ readonly projectLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
156
166
  readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
167
+ readonly organizationName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
168
+ readonly organizationLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
157
169
  readonly hostnameId: import("effect/Schema").String;
158
170
  readonly managed: import("effect/Schema").Boolean;
159
171
  readonly active: import("effect/Schema").Boolean;
@@ -166,7 +178,11 @@ export declare const ServerDomainsApiGroup: HttpApiGroup.HttpApiGroup<"domains",
166
178
  readonly hostname: import("effect/Schema").String;
167
179
  readonly rootHostname: import("effect/Schema").String;
168
180
  readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
181
+ readonly projectName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
182
+ readonly projectLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
169
183
  readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
184
+ readonly organizationName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
185
+ readonly organizationLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
170
186
  readonly hostnameId: import("effect/Schema").String;
171
187
  readonly managed: import("effect/Schema").Boolean;
172
188
  readonly active: import("effect/Schema").Boolean;
@@ -192,7 +208,11 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
192
208
  readonly hostname: import("effect/Schema").String;
193
209
  readonly rootHostname: import("effect/Schema").String;
194
210
  readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
211
+ readonly projectName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
212
+ readonly projectLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
195
213
  readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
214
+ readonly organizationName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
215
+ readonly organizationLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
196
216
  readonly hostnameId: import("effect/Schema").String;
197
217
  readonly managed: import("effect/Schema").Boolean;
198
218
  readonly active: import("effect/Schema").Boolean;
@@ -205,7 +225,11 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
205
225
  readonly hostname: import("effect/Schema").String;
206
226
  readonly rootHostname: import("effect/Schema").String;
207
227
  readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
228
+ readonly projectName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
229
+ readonly projectLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
208
230
  readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
231
+ readonly organizationName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
232
+ readonly organizationLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
209
233
  readonly hostnameId: import("effect/Schema").String;
210
234
  readonly managed: import("effect/Schema").Boolean;
211
235
  readonly active: import("effect/Schema").Boolean;
@@ -218,7 +242,11 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
218
242
  readonly hostname: import("effect/Schema").String;
219
243
  readonly rootHostname: import("effect/Schema").String;
220
244
  readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
245
+ readonly projectName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
246
+ readonly projectLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
221
247
  readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
248
+ readonly organizationName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
249
+ readonly organizationLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
222
250
  readonly hostnameId: import("effect/Schema").String;
223
251
  readonly managed: import("effect/Schema").Boolean;
224
252
  readonly active: import("effect/Schema").Boolean;
@@ -231,7 +259,11 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
231
259
  readonly hostname: import("effect/Schema").String;
232
260
  readonly rootHostname: import("effect/Schema").String;
233
261
  readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
262
+ readonly projectName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
263
+ readonly projectLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
234
264
  readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
265
+ readonly organizationName: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
266
+ readonly organizationLogo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
235
267
  readonly hostnameId: import("effect/Schema").String;
236
268
  readonly managed: import("effect/Schema").Boolean;
237
269
  readonly active: import("effect/Schema").Boolean;
@@ -81,7 +81,11 @@ export declare const ServerDomain: Schema.Struct<{
81
81
  readonly hostname: Schema.String;
82
82
  readonly rootHostname: Schema.String;
83
83
  readonly projectId: Schema.NullOr<Schema.String>;
84
+ readonly projectName: Schema.optional<Schema.NullOr<Schema.String>>;
85
+ readonly projectLogo: Schema.optional<Schema.NullOr<Schema.String>>;
84
86
  readonly organizationId: Schema.NullOr<Schema.String>;
87
+ readonly organizationName: Schema.optional<Schema.NullOr<Schema.String>>;
88
+ readonly organizationLogo: Schema.optional<Schema.NullOr<Schema.String>>;
85
89
  readonly hostnameId: Schema.String;
86
90
  readonly managed: Schema.Boolean;
87
91
  readonly active: Schema.Boolean;
@@ -84,7 +84,11 @@ export const ServerDomain = Schema.Struct({
84
84
  hostname: Schema.String,
85
85
  rootHostname: Schema.String,
86
86
  projectId: Schema.NullOr(Schema.String),
87
+ projectName: Schema.optional(Schema.NullOr(Schema.String)),
88
+ projectLogo: Schema.optional(Schema.NullOr(Schema.String)),
87
89
  organizationId: Schema.NullOr(Schema.String),
90
+ organizationName: Schema.optional(Schema.NullOr(Schema.String)),
91
+ organizationLogo: Schema.optional(Schema.NullOr(Schema.String)),
88
92
  hostnameId: Schema.String,
89
93
  managed: Schema.Boolean,
90
94
  active: Schema.Boolean,
@@ -100,7 +104,11 @@ export const ServerDomain = Schema.Struct({
100
104
  hostname: "auth.institute.example.com",
101
105
  rootHostname: "institute.example.com",
102
106
  projectId: "kokobi",
107
+ projectName: "Kokobi",
108
+ projectLogo: "https://example.com/kokobi.svg",
103
109
  organizationId: "org_1",
110
+ organizationName: "Institute Example",
111
+ organizationLogo: "https://example.com/institute.svg",
104
112
  hostnameId: "cloudflare-hostname-id",
105
113
  managed: true,
106
114
  active: false,