@krak-stack/auth 0.1.38 → 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.
- package/dist/api.d.ts +22 -0
- package/dist/better-auth/api.d.ts +2 -0
- package/dist/better-auth/index.d.ts +1 -0
- package/dist/better-auth/schema.d.ts +1 -0
- package/dist/better-auth/schema.js +1 -0
- package/dist/components/admin-organization-form.d.ts +6 -0
- package/dist/components/admin-organization-form.js +136 -0
- package/dist/components/admin-organizations.d.ts +7 -0
- package/dist/components/admin-organizations.js +118 -0
- package/dist/components/admin-users.d.ts +8 -0
- package/dist/components/admin-users.js +265 -0
- package/dist/components/auth-api-client.d.ts +22 -0
- package/dist/components/auth-client.d.ts +3 -1
- package/dist/components/auth-forms.js +10 -24
- package/dist/components/auth-provider.d.ts +16 -15
- package/dist/components/auth-provider.js +51 -4
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/user-button.d.ts +11 -1
- package/dist/components/user-button.js +73 -15
- package/dist/extra/api.d.ts +2 -0
- package/dist/extra/index.d.ts +1 -0
- package/dist/extra/schema.d.ts +1 -0
- package/dist/extra/schema.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schema.d.ts +2 -0
- package/dist/schema.js +3 -0
- package/dist/server/api.d.ts +40 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +1 -0
- package/dist/server/middleware.d.ts +23 -0
- package/dist/server/middleware.js +40 -0
- package/dist/server/schema.d.ts +6 -0
- package/dist/server/schema.js +8 -0
- package/dist/service.d.ts +516 -437
- package/dist/service.js +96 -12
- package/package.json +1 -1
|
@@ -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";
|
|
@@ -18,10 +18,18 @@ import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLeg
|
|
|
18
18
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
19
19
|
import { Separator } from "@/components/ui/separator";
|
|
20
20
|
import { authApiClient } from "./auth-api-client";
|
|
21
|
+
import { useKrakstackAuthProjectConfig } from "./auth-provider";
|
|
21
22
|
import { createApiKey } from "./api-key";
|
|
22
23
|
import { useOpenedOnce } from "./hooks";
|
|
23
24
|
import { ExtraUploadedAsset } from "../extra/schema";
|
|
24
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
|
+
};
|
|
25
33
|
const messages = {
|
|
26
34
|
en: {
|
|
27
35
|
api_key_rate_limit_notice: "API keys are subject to the same rate limits as your account.",
|
|
@@ -73,10 +81,15 @@ const messages = {
|
|
|
73
81
|
user_api_keys_load_error: "Could not load API keys.",
|
|
74
82
|
user_api_keys_title: "API keys",
|
|
75
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.",
|
|
76
88
|
user_button_api_keys: "API keys",
|
|
77
89
|
user_button_aria_label: "Open user menu",
|
|
78
90
|
user_button_logout: "Log out",
|
|
79
91
|
user_button_security: "Security",
|
|
92
|
+
user_button_stop_impersonating: "Stop impersonating",
|
|
80
93
|
user_delete: "Delete",
|
|
81
94
|
user_field_password: "Password",
|
|
82
95
|
user_form_description: "Update the profile details associated with your account.",
|
|
@@ -155,10 +168,15 @@ const messages = {
|
|
|
155
168
|
user_api_keys_load_error: "Impossible de charger les clés API.",
|
|
156
169
|
user_api_keys_title: "Clés API",
|
|
157
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.",
|
|
158
175
|
user_button_api_keys: "Clés API",
|
|
159
176
|
user_button_aria_label: "Ouvrir le menu utilisateur",
|
|
160
177
|
user_button_logout: "Se déconnecter",
|
|
161
178
|
user_button_security: "Sécurité",
|
|
179
|
+
user_button_stop_impersonating: "Arrêter l'imitation",
|
|
162
180
|
user_delete: "Supprimer",
|
|
163
181
|
user_field_password: "Mot de passe",
|
|
164
182
|
user_form_description: "Mettez à jour les informations de profil associées à votre compte.",
|
|
@@ -207,6 +225,12 @@ const userButtonMessageFns = (labels) => new Proxy({}, {
|
|
|
207
225
|
});
|
|
208
226
|
const UserButtonMessagesContext = createContext(userButtonMessageFns(userButtonMessages()));
|
|
209
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"]);
|
|
210
234
|
const isFile = (value) => value instanceof File;
|
|
211
235
|
const decodeUploadedAsset = Schema.decodeUnknownPromise(ExtraUploadedAsset);
|
|
212
236
|
const uploadUserImageAsset = async (file, m, uploadUserImage) => {
|
|
@@ -219,6 +243,7 @@ const uploadUserImageAsset = async (file, m, uploadUserImage) => {
|
|
|
219
243
|
throw new Error(m.user_profile_image_upload_error());
|
|
220
244
|
}
|
|
221
245
|
};
|
|
246
|
+
const requiresPasswordForAccountRevoke = (accounts) => accounts.some((account) => account.providerId === "credential");
|
|
222
247
|
const userAccountsAtom = Atom.family((authClient) => Atom.keepAlive(Atom.make(Effect.tryPromise({
|
|
223
248
|
try: async () => {
|
|
224
249
|
const result = await authClient.listAccounts();
|
|
@@ -246,12 +271,20 @@ const emptyApiKeysAtom = Atom.make(Effect.succeed([]));
|
|
|
246
271
|
export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side = "bottom", defaultDialog = null, hideTrigger = false, renderUnauthenticated, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }) => {
|
|
247
272
|
const labels = userButtonMessages(messages);
|
|
248
273
|
const m = userButtonMessageFns(labels);
|
|
274
|
+
const projectConfig = useKrakstackAuthProjectConfig();
|
|
249
275
|
const navigate = useNavigate();
|
|
250
276
|
const currentSiteHref = useRouterState({
|
|
251
277
|
select: (state) => `${import.meta.env.VITE_SITE_URL}${state.location.href}`,
|
|
252
278
|
});
|
|
279
|
+
const adminTableSearch = useRouterState({
|
|
280
|
+
select: (state) => ({
|
|
281
|
+
...defaultAdminTableSearch,
|
|
282
|
+
...state.location.search,
|
|
283
|
+
}),
|
|
284
|
+
});
|
|
253
285
|
const { data: session, isPending, refetch } = authClient.useSession();
|
|
254
286
|
const [uncontrolledDialog, setUncontrolledDialog] = useState(defaultDialog);
|
|
287
|
+
const [isStoppingImpersonation, setIsStoppingImpersonation] = useState(false);
|
|
255
288
|
const settingsDialog = controlledDialog !== undefined ? controlledDialog : uncontrolledDialog;
|
|
256
289
|
const [formError, setFormError] = useState(null);
|
|
257
290
|
const shouldLoadAccounts = Boolean(session) &&
|
|
@@ -289,6 +322,8 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
|
|
|
289
322
|
const displayName = session.user.name.trim();
|
|
290
323
|
const displayEmail = session.user.email.trim();
|
|
291
324
|
const displayImage = assetUrl(session.user.image, baseUrl);
|
|
325
|
+
const isImpersonating = Boolean(session.session.impersonatedBy);
|
|
326
|
+
const isAdmin = hasAdminRole(session.user);
|
|
292
327
|
const signOut = async () => {
|
|
293
328
|
const redirectUrl = signOutRedirect.startsWith("http")
|
|
294
329
|
? signOutRedirect
|
|
@@ -296,6 +331,17 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
|
|
|
296
331
|
await authClient.signOut();
|
|
297
332
|
await navigate({ href: redirectUrl });
|
|
298
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
|
+
};
|
|
299
345
|
const updateUser = async (values) => {
|
|
300
346
|
setFormError(null);
|
|
301
347
|
const imageFile = isFile(values.image) ? values.image : null;
|
|
@@ -317,7 +363,7 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
|
|
|
317
363
|
await refetch();
|
|
318
364
|
setSettingsDialog(null);
|
|
319
365
|
};
|
|
320
|
-
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) => {
|
|
321
367
|
setSettingsDialog((current) => open ? "account" : current === "account" ? null : current);
|
|
322
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: {
|
|
323
369
|
name: displayName ?? "",
|
|
@@ -331,21 +377,35 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
|
|
|
331
377
|
? error.message
|
|
332
378
|
: m.user_form_update_error());
|
|
333
379
|
}
|
|
334
|
-
} }), _jsx(Separator, {}), _jsx(ConnectedAccounts, { authClient: authClient, baseUrl: baseUrl, accountCache: accountCache, currentSiteHref: currentSiteHref, navigate: navigate })] }))] }) }), _jsx(Dialog, { open: settingsDialog === "security", onOpenChange: (open) => {
|
|
380
|
+
} }), _jsx(Separator, {}), _jsx(ConnectedAccounts, { authClient: authClient, baseUrl: baseUrl, accountCache: accountCache, googleEnabled: projectConfig?.authOptions.google ?? true, currentSiteHref: currentSiteHref, navigate: navigate })] }))] }) }), _jsx(Dialog, { open: settingsDialog === "security", onOpenChange: (open) => {
|
|
335
381
|
setSettingsDialog((current) => open ? "security" : current === "security" ? null : current);
|
|
336
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) => {
|
|
337
383
|
setSettingsDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
338
|
-
}, 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] }));
|
|
339
393
|
};
|
|
340
|
-
function ConnectedAccounts({ authClient, baseUrl, accountCache, currentSiteHref, navigate, }) {
|
|
394
|
+
function ConnectedAccounts({ authClient, baseUrl, accountCache, googleEnabled, currentSiteHref, navigate, }) {
|
|
341
395
|
const m = useUserButtonMessages();
|
|
396
|
+
const [error, setError] = useState(null);
|
|
342
397
|
const [isLinking, setIsLinking] = useState(false);
|
|
343
398
|
const [revokingAccount, setRevokingAccount] = useState(null);
|
|
344
399
|
const accounts = accountCache.accounts ?? [];
|
|
345
400
|
const googleAccount = accounts.find((account) => account.providerId === "google");
|
|
346
|
-
const
|
|
347
|
-
const
|
|
401
|
+
const requirePassword = requiresPasswordForAccountRevoke(accounts);
|
|
402
|
+
const showGoogleAccount = googleEnabled || Boolean(googleAccount);
|
|
403
|
+
if (accountCache.accounts && (accounts.length === 0 || !showGoogleAccount)) {
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
348
406
|
const linkGoogle = async () => {
|
|
407
|
+
if (!googleEnabled)
|
|
408
|
+
return;
|
|
349
409
|
setError(null);
|
|
350
410
|
setIsLinking(true);
|
|
351
411
|
const result = await authClient.linkSocial({
|
|
@@ -376,13 +436,13 @@ function ConnectedAccounts({ authClient, baseUrl, accountCache, currentSiteHref,
|
|
|
376
436
|
setRevokingAccount(null);
|
|
377
437
|
await accountCache.reload();
|
|
378
438
|
};
|
|
379
|
-
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() })] }), accountCache.accounts ? (_jsxs(_Fragment, { children: [_jsx(AccountProviderRow, { icon: _jsx(GoogleLogo, {}), title: m.user_account_google_title(), description: m.user_account_google_description(), account: googleAccount, connected: Boolean(googleAccount),
|
|
439
|
+
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() })] }), accountCache.accounts ? (_jsxs(_Fragment, { children: [showGoogleAccount ? (_jsx(AccountProviderRow, { icon: _jsx(GoogleLogo, {}), title: m.user_account_google_title(), description: m.user_account_google_description(), account: googleAccount, connected: Boolean(googleAccount), connectLabel: m.user_account_google_connect(), revokeLabel: m.user_account_revoke(), isConnecting: isLinking, renderDisconnected: undefined, onConnect: linkGoogle, onRevoke: (account) => setRevokingAccount(account) })) : null, revokingAccount ? (_jsx(RevokeAccountForm, { baseUrl: baseUrl, account: revokingAccount, requirePassword: requirePassword, onCancel: () => setRevokingAccount(null), onRevoke: revokeAccount })) : null] })) : !accountCache.error ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : null, accountCache.error ? (_jsx("p", { className: "text-destructive text-sm", children: accountCache.error })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null] }));
|
|
380
440
|
}
|
|
381
|
-
function AccountProviderRow({ icon, title, description, account, connected,
|
|
441
|
+
function AccountProviderRow({ icon, title, description, account, connected, connectLabel, revokeLabel, isConnecting, renderDisconnected, onConnect, onRevoke, }) {
|
|
382
442
|
const m = useUserButtonMessages();
|
|
383
443
|
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: icon }), _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
|
|
384
444
|
? m.user_account_connected()
|
|
385
|
-
: m.user_account_not_connected() })] }), _jsx("p", { className: "text-muted-foreground text-sm", children: description })] })] }), connected && account ? (_jsx(Button, { type: "button", variant: "outline",
|
|
445
|
+
: m.user_account_not_connected() })] }), _jsx("p", { className: "text-muted-foreground text-sm", children: description })] })] }), connected && account ? (_jsx(Button, { type: "button", variant: "outline", onClick: () => onRevoke(account), children: revokeLabel })) : renderDisconnected ? (renderDisconnected) : (_jsx(Button, { type: "button", variant: "outline", disabled: isConnecting, onClick: onConnect, children: connectLabel }))] }) }));
|
|
386
446
|
}
|
|
387
447
|
function GoogleLogo() {
|
|
388
448
|
return (_jsxs("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", className: "size-5", children: [_jsx("path", { fill: "#4285F4", d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" }), _jsx("path", { fill: "#34A853", d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" }), _jsx("path", { fill: "#FBBC05", d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" }), _jsx("path", { fill: "#EA4335", d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84C6.71 7.31 9.14 5.38 12 5.38z" })] }));
|
|
@@ -394,7 +454,7 @@ function PasswordSettings({ authClient, baseUrl, accountCache, }) {
|
|
|
394
454
|
const accounts = accountCache.accounts ?? [];
|
|
395
455
|
const passwordAccount = accounts.find((account) => account.providerId === "credential");
|
|
396
456
|
const hasPassword = Boolean(passwordAccount);
|
|
397
|
-
const
|
|
457
|
+
const requirePassword = requiresPasswordForAccountRevoke(accounts);
|
|
398
458
|
const revokePassword = async (account) => {
|
|
399
459
|
setError(null);
|
|
400
460
|
const result = await authClient.unlinkAccount({
|
|
@@ -408,9 +468,7 @@ function PasswordSettings({ authClient, baseUrl, accountCache, }) {
|
|
|
408
468
|
setRevokingAccount(null);
|
|
409
469
|
await accountCache.reload();
|
|
410
470
|
};
|
|
411
|
-
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() })] }), accountCache.accounts && 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",
|
|
412
|
-
? m.user_account_revoke()
|
|
413
|
-
: m.user_account_only_method() })] }), revokingAccount ? (_jsx(RevokeAccountForm, { baseUrl: baseUrl, account: revokingAccount, requirePassword: true, onCancel: () => setRevokingAccount(null), onRevoke: revokePassword })) : null, _jsx(Separator, {}), _jsx(ChangePasswordForm, { authClient: authClient })] })) : accountCache.accounts ? (_jsx(SetPasswordForm, { authClient: authClient, onSaved: accountCache.reload })) : !accountCache.error ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : null, accountCache.error ? (_jsx("p", { className: "text-destructive text-sm", children: accountCache.error })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null] }));
|
|
471
|
+
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() })] }), accountCache.accounts && 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", onClick: () => setRevokingAccount(passwordAccount), children: m.user_account_revoke() })] }), revokingAccount ? (_jsx(RevokeAccountForm, { baseUrl: baseUrl, account: revokingAccount, requirePassword: requirePassword, onCancel: () => setRevokingAccount(null), onRevoke: revokePassword })) : null, _jsx(Separator, {}), _jsx(ChangePasswordForm, { authClient: authClient })] })) : accountCache.accounts ? (_jsx(SetPasswordForm, { authClient: authClient, onSaved: accountCache.reload })) : !accountCache.error ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : null, accountCache.error ? (_jsx("p", { className: "text-destructive text-sm", children: accountCache.error })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null] }));
|
|
414
472
|
}
|
|
415
473
|
function ChangePasswordForm({ authClient }) {
|
|
416
474
|
const m = useUserButtonMessages();
|
|
@@ -470,7 +528,7 @@ function SetPasswordForm({ authClient, onSaved, }) {
|
|
|
470
528
|
event.preventDefault();
|
|
471
529
|
event.stopPropagation();
|
|
472
530
|
form.handleSubmit();
|
|
473
|
-
}, 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(
|
|
531
|
+
}, 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(form.SubmitButton, { children: m.user_account_password_set() })] }) }));
|
|
474
532
|
}
|
|
475
533
|
function RevokeAccountForm({ baseUrl, account, requirePassword, onCancel, onRevoke, }) {
|
|
476
534
|
const m = useUserButtonMessages();
|
package/dist/extra/api.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
13
13
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
14
14
|
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
15
15
|
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
16
|
+
readonly rootHost: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
16
17
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
17
18
|
readonly projectKey: import("effect/Schema").String;
|
|
18
19
|
readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
@@ -80,6 +81,7 @@ export declare const ExtraApi: HttpApi.HttpApi<"ExtraApi", HttpApiGroup.HttpApiG
|
|
|
80
81
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
81
82
|
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
82
83
|
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
84
|
+
readonly rootHost: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
83
85
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
84
86
|
readonly projectKey: import("effect/Schema").String;
|
|
85
87
|
readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
package/dist/extra/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ declare const ExtraApiClient_base: AtomHttpApi.AtomHttpApiClient<ExtraApiClient,
|
|
|
11
11
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
12
12
|
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
13
13
|
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
14
|
+
readonly rootHost: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
14
15
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
15
16
|
readonly projectKey: import("effect/Schema").String;
|
|
16
17
|
readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
package/dist/extra/schema.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export declare const ExtraProjectPublicConfigQuery: Schema.Struct<{
|
|
|
73
73
|
readonly projectId: Schema.optional<Schema.String>;
|
|
74
74
|
readonly clientId: Schema.optional<Schema.String>;
|
|
75
75
|
readonly host: Schema.optional<Schema.String>;
|
|
76
|
+
readonly rootHost: Schema.optional<Schema.String>;
|
|
76
77
|
}>;
|
|
77
78
|
export declare const ExtraProjectAuthOptions: Schema.Struct<{
|
|
78
79
|
readonly emailPassword: Schema.Boolean;
|
package/dist/extra/schema.js
CHANGED
|
@@ -139,6 +139,7 @@ export const ExtraProjectPublicConfigQuery = Schema.Struct({
|
|
|
139
139
|
projectId: Schema.optional(Schema.String),
|
|
140
140
|
clientId: Schema.optional(Schema.String),
|
|
141
141
|
host: Schema.optional(Schema.String),
|
|
142
|
+
rootHost: Schema.optional(Schema.String),
|
|
142
143
|
}).annotate({
|
|
143
144
|
identifier: "ExtraProjectPublicConfigQuery",
|
|
144
145
|
title: "Extra project public config query",
|
|
@@ -147,6 +148,7 @@ export const ExtraProjectPublicConfigQuery = Schema.Struct({
|
|
|
147
148
|
{
|
|
148
149
|
projectId: "project-id",
|
|
149
150
|
host: "auth.example.com",
|
|
151
|
+
rootHost: "example.com",
|
|
150
152
|
clientId: "oauth-client-id",
|
|
151
153
|
},
|
|
152
154
|
],
|
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";
|
package/dist/schema.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const User: Schema.Struct<{
|
|
|
7
7
|
readonly image: Schema.NullOr<Schema.String>;
|
|
8
8
|
readonly role: Schema.NullOr<Schema.String>;
|
|
9
9
|
readonly banned: Schema.NullOr<Schema.Boolean>;
|
|
10
|
+
readonly lastLoginMethod: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
10
11
|
readonly createdAt: Schema.Date;
|
|
11
12
|
readonly updatedAt: Schema.Date;
|
|
12
13
|
}>;
|
|
@@ -72,6 +73,7 @@ export declare const Member: Schema.Struct<{
|
|
|
72
73
|
readonly image: Schema.NullOr<Schema.String>;
|
|
73
74
|
readonly role: Schema.NullOr<Schema.String>;
|
|
74
75
|
readonly banned: Schema.NullOr<Schema.Boolean>;
|
|
76
|
+
readonly lastLoginMethod: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
75
77
|
readonly createdAt: Schema.Date;
|
|
76
78
|
readonly updatedAt: Schema.Date;
|
|
77
79
|
}>;
|
package/dist/schema.js
CHANGED
|
@@ -7,6 +7,7 @@ export const User = Schema.Struct({
|
|
|
7
7
|
image: Schema.NullOr(Schema.String),
|
|
8
8
|
role: Schema.NullOr(Schema.String),
|
|
9
9
|
banned: Schema.NullOr(Schema.Boolean),
|
|
10
|
+
lastLoginMethod: Schema.optional(Schema.NullOr(Schema.String)),
|
|
10
11
|
createdAt: Schema.Date,
|
|
11
12
|
updatedAt: Schema.Date,
|
|
12
13
|
}).annotate({
|
|
@@ -22,6 +23,7 @@ export const User = Schema.Struct({
|
|
|
22
23
|
image: null,
|
|
23
24
|
role: "admin",
|
|
24
25
|
banned: false,
|
|
26
|
+
lastLoginMethod: "email-otp",
|
|
25
27
|
createdAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
26
28
|
updatedAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
27
29
|
},
|
|
@@ -168,6 +170,7 @@ export const Member = Schema.Struct({
|
|
|
168
170
|
image: null,
|
|
169
171
|
role: "admin",
|
|
170
172
|
banned: false,
|
|
173
|
+
lastLoginMethod: "email-otp",
|
|
171
174
|
createdAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
172
175
|
updatedAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
173
176
|
},
|
package/dist/server/api.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const ServerUsersApiGroup: HttpApiGroup.HttpApiGroup<"users", Htt
|
|
|
10
10
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
11
11
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
12
12
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
13
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
13
14
|
readonly createdAt: import("effect/Schema").Date;
|
|
14
15
|
readonly updatedAt: import("effect/Schema").Date;
|
|
15
16
|
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getUserActiveOrganization", "GET", "/organizations/user/:userId/active", HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
|
|
@@ -27,6 +28,7 @@ export declare const ServerUsersApiGroup: HttpApiGroup.HttpApiGroup<"users", Htt
|
|
|
27
28
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
28
29
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
29
30
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
31
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
30
32
|
readonly createdAt: import("effect/Schema").Date;
|
|
31
33
|
readonly updatedAt: import("effect/Schema").Date;
|
|
32
34
|
}>>;
|
|
@@ -49,6 +51,7 @@ export declare const ServerOrganizationsApiGroup: HttpApiGroup.HttpApiGroup<"org
|
|
|
49
51
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
50
52
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
51
53
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
54
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
52
55
|
readonly createdAt: import("effect/Schema").Date;
|
|
53
56
|
readonly updatedAt: import("effect/Schema").Date;
|
|
54
57
|
}>;
|
|
@@ -86,6 +89,7 @@ export declare const ServerOrganizationsApiGroup: HttpApiGroup.HttpApiGroup<"org
|
|
|
86
89
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
87
90
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
88
91
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
92
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
89
93
|
readonly createdAt: import("effect/Schema").Date;
|
|
90
94
|
readonly updatedAt: import("effect/Schema").Date;
|
|
91
95
|
}>;
|
|
@@ -123,7 +127,11 @@ export declare const ServerDomainsApiGroup: HttpApiGroup.HttpApiGroup<"domains",
|
|
|
123
127
|
readonly hostname: import("effect/Schema").String;
|
|
124
128
|
readonly rootHostname: import("effect/Schema").String;
|
|
125
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>>;
|
|
126
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>>;
|
|
127
135
|
readonly hostnameId: import("effect/Schema").String;
|
|
128
136
|
readonly managed: import("effect/Schema").Boolean;
|
|
129
137
|
readonly active: import("effect/Schema").Boolean;
|
|
@@ -136,7 +144,11 @@ export declare const ServerDomainsApiGroup: HttpApiGroup.HttpApiGroup<"domains",
|
|
|
136
144
|
readonly hostname: import("effect/Schema").String;
|
|
137
145
|
readonly rootHostname: import("effect/Schema").String;
|
|
138
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>>;
|
|
139
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>>;
|
|
140
152
|
readonly hostnameId: import("effect/Schema").String;
|
|
141
153
|
readonly managed: import("effect/Schema").Boolean;
|
|
142
154
|
readonly active: import("effect/Schema").Boolean;
|
|
@@ -149,7 +161,11 @@ export declare const ServerDomainsApiGroup: HttpApiGroup.HttpApiGroup<"domains",
|
|
|
149
161
|
readonly hostname: import("effect/Schema").String;
|
|
150
162
|
readonly rootHostname: import("effect/Schema").String;
|
|
151
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>>;
|
|
152
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>>;
|
|
153
169
|
readonly hostnameId: import("effect/Schema").String;
|
|
154
170
|
readonly managed: import("effect/Schema").Boolean;
|
|
155
171
|
readonly active: import("effect/Schema").Boolean;
|
|
@@ -162,7 +178,11 @@ export declare const ServerDomainsApiGroup: HttpApiGroup.HttpApiGroup<"domains",
|
|
|
162
178
|
readonly hostname: import("effect/Schema").String;
|
|
163
179
|
readonly rootHostname: import("effect/Schema").String;
|
|
164
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>>;
|
|
165
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>>;
|
|
166
186
|
readonly hostnameId: import("effect/Schema").String;
|
|
167
187
|
readonly managed: import("effect/Schema").Boolean;
|
|
168
188
|
readonly active: import("effect/Schema").Boolean;
|
|
@@ -188,7 +208,11 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
188
208
|
readonly hostname: import("effect/Schema").String;
|
|
189
209
|
readonly rootHostname: import("effect/Schema").String;
|
|
190
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>>;
|
|
191
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>>;
|
|
192
216
|
readonly hostnameId: import("effect/Schema").String;
|
|
193
217
|
readonly managed: import("effect/Schema").Boolean;
|
|
194
218
|
readonly active: import("effect/Schema").Boolean;
|
|
@@ -201,7 +225,11 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
201
225
|
readonly hostname: import("effect/Schema").String;
|
|
202
226
|
readonly rootHostname: import("effect/Schema").String;
|
|
203
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>>;
|
|
204
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>>;
|
|
205
233
|
readonly hostnameId: import("effect/Schema").String;
|
|
206
234
|
readonly managed: import("effect/Schema").Boolean;
|
|
207
235
|
readonly active: import("effect/Schema").Boolean;
|
|
@@ -214,7 +242,11 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
214
242
|
readonly hostname: import("effect/Schema").String;
|
|
215
243
|
readonly rootHostname: import("effect/Schema").String;
|
|
216
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>>;
|
|
217
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>>;
|
|
218
250
|
readonly hostnameId: import("effect/Schema").String;
|
|
219
251
|
readonly managed: import("effect/Schema").Boolean;
|
|
220
252
|
readonly active: import("effect/Schema").Boolean;
|
|
@@ -227,7 +259,11 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
227
259
|
readonly hostname: import("effect/Schema").String;
|
|
228
260
|
readonly rootHostname: import("effect/Schema").String;
|
|
229
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>>;
|
|
230
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>>;
|
|
231
267
|
readonly hostnameId: import("effect/Schema").String;
|
|
232
268
|
readonly managed: import("effect/Schema").Boolean;
|
|
233
269
|
readonly active: import("effect/Schema").Boolean;
|
|
@@ -258,6 +294,7 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
258
294
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
259
295
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
260
296
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
297
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
261
298
|
readonly createdAt: import("effect/Schema").Date;
|
|
262
299
|
readonly updatedAt: import("effect/Schema").Date;
|
|
263
300
|
}>;
|
|
@@ -295,6 +332,7 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
295
332
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
296
333
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
297
334
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
335
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
298
336
|
readonly createdAt: import("effect/Schema").Date;
|
|
299
337
|
readonly updatedAt: import("effect/Schema").Date;
|
|
300
338
|
}>;
|
|
@@ -330,6 +368,7 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
330
368
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
331
369
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
332
370
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
371
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
333
372
|
readonly createdAt: import("effect/Schema").Date;
|
|
334
373
|
readonly updatedAt: import("effect/Schema").Date;
|
|
335
374
|
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getUserActiveOrganization", "GET", "/api/organizations/user/:userId/active", HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
|
|
@@ -347,6 +386,7 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
347
386
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
348
387
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
349
388
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
389
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
350
390
|
readonly createdAt: import("effect/Schema").Date;
|
|
351
391
|
readonly updatedAt: import("effect/Schema").Date;
|
|
352
392
|
}>>;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { AuthService } from "../service";
|
|
2
|
+
export type { AuthSession, AuthSessionWithOrganization, AuthSessionWithUser, AuthSessionWithUserAndOrganization, } from "../service";
|
|
2
3
|
export { AuthClientConfig } from "../config";
|
|
3
4
|
export { ServerApi, ServerOrganizationsApiGroup, ServerUsersApiGroup, } from "./api";
|
|
4
5
|
export { proxyAuthRequest } from "./proxy";
|
|
6
|
+
export { ApiKeySecurity, AuthMiddleware, makeAuthenticationLive, } from "./middleware";
|
|
7
|
+
export type { AuthenticationLiveOptions } from "./middleware";
|
|
5
8
|
export type { ServerActiveOrganization, ServerMembersResponse, ServerOrganizationsResponse, ServerUsersResponse, } from "./schema";
|
|
6
9
|
export type { Member, Organization, OrganizationMetadata, User, } from "../schema";
|
package/dist/server/index.js
CHANGED
|
@@ -2,3 +2,4 @@ export { AuthService } from "../service";
|
|
|
2
2
|
export { AuthClientConfig } from "../config";
|
|
3
3
|
export { ServerApi, ServerOrganizationsApiGroup, ServerUsersApiGroup, } from "./api";
|
|
4
4
|
export { proxyAuthRequest } from "./proxy";
|
|
5
|
+
export { ApiKeySecurity, AuthMiddleware, makeAuthenticationLive, } from "./middleware";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { HttpApiError, HttpApiMiddleware, HttpApiSecurity } from "effect/unstable/httpapi";
|
|
3
|
+
import { AuthService, type AuthServiceLayerOptions } from "../service";
|
|
4
|
+
export declare const ApiKeySecurity: HttpApiSecurity.ApiKey;
|
|
5
|
+
declare const AuthMiddleware_base: HttpApiMiddleware.ServiceClass<AuthMiddleware, "@krak-stack/auth/AuthMiddleware", {
|
|
6
|
+
requires: never;
|
|
7
|
+
provides: AuthService;
|
|
8
|
+
error: typeof HttpApiError.Unauthorized;
|
|
9
|
+
clientError: never;
|
|
10
|
+
requiredForClient: false;
|
|
11
|
+
security: {
|
|
12
|
+
readonly apiKey: HttpApiSecurity.ApiKey;
|
|
13
|
+
};
|
|
14
|
+
}, HttpApiMiddleware.HttpApiMiddlewareSecurity<{
|
|
15
|
+
readonly apiKey: HttpApiSecurity.ApiKey;
|
|
16
|
+
}, AuthService, typeof HttpApiError.Unauthorized, never>>;
|
|
17
|
+
export declare class AuthMiddleware extends AuthMiddleware_base {
|
|
18
|
+
}
|
|
19
|
+
export type AuthenticationLiveOptions = AuthServiceLayerOptions & {
|
|
20
|
+
readonly authLayer?: Layer.Layer<AuthService, unknown>;
|
|
21
|
+
};
|
|
22
|
+
export declare const makeAuthenticationLive: (options?: AuthenticationLiveOptions | Layer.Layer<AuthService, unknown>) => Layer.Layer<AuthMiddleware, never, never>;
|
|
23
|
+
export {};
|