@krak-stack/auth 0.2.14 → 0.2.16
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/components/admin-organization-form.js +1 -1
- package/dist/components/auth-provider.d.ts +2 -2
- package/dist/components/auth-provider.js +4 -1
- package/dist/components/member-required.js +1 -4
- package/dist/components/organization-switcher.js +5 -8
- package/dist/components/user-button.js +5 -7
- package/package.json +5 -2
|
@@ -153,5 +153,5 @@ export function AdminOrganizationForm({ organization, onClose, onSaved, }) {
|
|
|
153
153
|
height: 96,
|
|
154
154
|
suggestedWidth: 512,
|
|
155
155
|
suggestedHeight: 512,
|
|
156
|
-
} }), _jsx(form.parentId, { description: m.organization_parent_description, emptyLabel: m.organization_parent_empty, items: parentOptions, label: m.organization_parent,
|
|
156
|
+
} }), _jsx(form.parentId, { description: m.organization_parent_description, emptyLabel: m.organization_parent_empty, items: parentOptions, label: m.organization_parent, placeholder: m.organization_parent_none }), _jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form, children: m.form_submit })] }) })] }) }));
|
|
157
157
|
}
|
|
@@ -13,7 +13,6 @@ export declare class KrakstackAuthUnavailableError extends KrakstackAuthUnavaila
|
|
|
13
13
|
}
|
|
14
14
|
export type KrakstackAuthProviderProps = {
|
|
15
15
|
children: ReactNode;
|
|
16
|
-
locale?: KrakstackAuthLocale | undefined;
|
|
17
16
|
baseUrl?: string | undefined;
|
|
18
17
|
projectId?: string | null | undefined;
|
|
19
18
|
access?: ProjectAccessCatalog | undefined;
|
|
@@ -35,7 +34,8 @@ type ProjectConfigState = {
|
|
|
35
34
|
projectConfig: ExtraProjectPublicConfig | null;
|
|
36
35
|
};
|
|
37
36
|
export declare const resolveProjectConfigState: (result: AsyncResult.AsyncResult<ExtraProjectPublicConfig | null, unknown>) => ProjectConfigState;
|
|
38
|
-
export declare
|
|
37
|
+
export declare const resolveKrakstackAuthLocale: (locale: string) => KrakstackAuthLocale;
|
|
38
|
+
export declare function KrakstackAuthProvider({ children, baseUrl, projectId, access, accessLabels, }: KrakstackAuthProviderProps): import("react").JSX.Element;
|
|
39
39
|
export declare const useKrakstackAuth: () => KrakstackAuthContextValue | null;
|
|
40
40
|
export declare const useKrakstackAuthProjectConfig: () => {
|
|
41
41
|
readonly projectKey: string;
|
|
@@ -4,6 +4,7 @@ import { useRouterState } from "@tanstack/react-router";
|
|
|
4
4
|
import { Cause, Option, Schema } from "effect";
|
|
5
5
|
import { HttpApiError } from "effect/unstable/httpapi";
|
|
6
6
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
7
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
7
8
|
import { createContext, useContext, useEffect, useMemo, useRef, } from "react";
|
|
8
9
|
import { activeAuthOrganizationAtom, authSessionAtom } from "./auth-atoms.js";
|
|
9
10
|
import { authClientApi } from "./auth-client-api.js";
|
|
@@ -70,6 +71,7 @@ export const resolveProjectConfigState = (result) => {
|
|
|
70
71
|
}
|
|
71
72
|
return { status: "loading", error: null, projectConfig: null };
|
|
72
73
|
};
|
|
74
|
+
export const resolveKrakstackAuthLocale = (locale) => (locale.startsWith("fr") ? "fr" : "en");
|
|
73
75
|
const useProjectConfigState = (baseUrl, providedProjectId) => {
|
|
74
76
|
const searchString = useRouterState({
|
|
75
77
|
select: (state) => state.location.searchStr,
|
|
@@ -104,7 +106,8 @@ const useProjectConfigState = (baseUrl, providedProjectId) => {
|
|
|
104
106
|
const result = useAtomValue(projectConfigAtom);
|
|
105
107
|
return useMemo(() => resolveProjectConfigState(result), [result]);
|
|
106
108
|
};
|
|
107
|
-
export function KrakstackAuthProvider({ children,
|
|
109
|
+
export function KrakstackAuthProvider({ children, baseUrl, projectId, access, accessLabels, }) {
|
|
110
|
+
const locale = resolveKrakstackAuthLocale(useKrakstackLocale());
|
|
108
111
|
const searchString = useRouterState({
|
|
109
112
|
select: (state) => state.location.searchStr,
|
|
110
113
|
});
|
|
@@ -200,10 +200,7 @@ function MemberRequiredGate({ accessKey, baseUrl, contactEmail, children, locale
|
|
|
200
200
|
organization: displayName,
|
|
201
201
|
}) })] }), _jsxs(CardContent, { className: "space-y-3", children: [invitation ? (_jsx("p", { className: "text-muted-foreground text-sm", children: interpolate(invitationExpired
|
|
202
202
|
? m.member_required_invite_expired
|
|
203
|
-
: m.member_required_invite_found, { organization: displayName }) })) : (_jsx("p", { className: "text-muted-foreground text-sm", children: m.member_required_contact_description })), resolvedContactEmail ? (_jsxs("div", { className: "bg-muted/50 flex items-center justify-between gap-3 rounded-md border px-3 py-2 text-sm", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2 font-medium", children: [_jsx(Mail, { className: "text-muted-foreground size-4 shrink-0" }), _jsx("span", { className: "truncate", children: resolvedContactEmail })] }), _jsx(CopyButton, { value: resolvedContactEmail, valueDescription: resolvedContactEmail, variant: "ghost", className: "shrink-0",
|
|
204
|
-
copy: m.member_required_copy_email,
|
|
205
|
-
copied: m.member_required_copied_email,
|
|
206
|
-
} })] })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null] }), _jsx(CardFooter, { className: "flex flex-wrap gap-2", children: invitation && !invitationExpired ? (_jsxs(Button, { onClick: acceptInvitation, disabled: accepting, children: [accepting ? (_jsx(Loader2, { className: "size-4 animate-spin" })) : (_jsx(Check, { className: "size-4" })), accepting
|
|
203
|
+
: m.member_required_invite_found, { organization: displayName }) })) : (_jsx("p", { className: "text-muted-foreground text-sm", children: m.member_required_contact_description })), resolvedContactEmail ? (_jsxs("div", { className: "bg-muted/50 flex items-center justify-between gap-3 rounded-md border px-3 py-2 text-sm", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2 font-medium", children: [_jsx(Mail, { className: "text-muted-foreground size-4 shrink-0" }), _jsx("span", { className: "truncate", children: resolvedContactEmail })] }), _jsx(CopyButton, { value: resolvedContactEmail, valueDescription: resolvedContactEmail, variant: "ghost", className: "shrink-0", locale: locale })] })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null] }), _jsx(CardFooter, { className: "flex flex-wrap gap-2", children: invitation && !invitationExpired ? (_jsxs(Button, { onClick: acceptInvitation, disabled: accepting, children: [accepting ? (_jsx(Loader2, { className: "size-4 animate-spin" })) : (_jsx(Check, { className: "size-4" })), accepting
|
|
207
204
|
? m.member_required_accepting_invite
|
|
208
205
|
: m.member_required_accept_invite] })) : null })] }) }));
|
|
209
206
|
}
|
|
@@ -847,7 +847,7 @@ export function OrganizationSwitcher({ baseUrl: providedBaseUrl, side = "bottom"
|
|
|
847
847
|
}, children: [_jsx(Copy, {}), m.organization_copy_id()] }));
|
|
848
848
|
})(), canUpdateOrganization ? (_jsxs(DropdownMenuItem, { onClick: () => setDialog("manage"), children: [_jsx(PencilIcon, {}), m.organization_switcher_manage()] })) : null, _jsxs(DropdownMenuItem, { onClick: () => setDialog("members"), children: [_jsx(Users, {}), m.organization_members_title()] }), canManageApiKeys ? (_jsxs(DropdownMenuItem, { onClick: () => setDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] })) : null] })) : null] }) })] })), _jsx(Dialog, { open: dialog === "create" && canCreateOrganization, onOpenChange: (open) => {
|
|
849
849
|
setDialog((current) => open ? "create" : current === "create" ? null : current);
|
|
850
|
-
}, children: _jsx(CreateOrganizationSection, { header: _jsxs(DialogHeader, { className: "sm:flex-row sm:items-end sm:justify-between sm:gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() })] }), _jsx("div", { className: "mt-2 w-fit sm:mt-0", children: _jsx(EditingLocaleSwitcher, { value: editingOrganizationLocale, onValueChange: setEditingOrganizationLocale }) })] }), baseUrl: baseUrl, editingLocale: editingOrganizationLocale, onCreated: async (organization) => {
|
|
850
|
+
}, children: _jsx(CreateOrganizationSection, { header: _jsxs(DialogHeader, { className: "sm:flex-row sm:items-end sm:justify-between sm:gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() })] }), _jsx("div", { className: "mt-2 w-fit sm:mt-0", children: _jsx(EditingLocaleSwitcher, { locale: auth?.locale, value: editingOrganizationLocale, onValueChange: (value) => setEditingOrganizationLocale(value === "fr" ? "fr" : "en") }) })] }), baseUrl: baseUrl, editingLocale: editingOrganizationLocale, onCreated: async (organization) => {
|
|
851
851
|
setDialog(null);
|
|
852
852
|
let activated = false;
|
|
853
853
|
try {
|
|
@@ -864,14 +864,14 @@ export function OrganizationSwitcher({ baseUrl: providedBaseUrl, side = "bottom"
|
|
|
864
864
|
}
|
|
865
865
|
} }) }), _jsx(Dialog, { open: dialog === "manage" && canUpdateOrganization, onOpenChange: (open) => {
|
|
866
866
|
setDialog((current) => open ? "manage" : current === "manage" ? null : current);
|
|
867
|
-
}, children: activeOrganization && canUpdateOrganization ? (_jsx(EditOrganizationSection, { header: _jsxs(DialogHeader, { className: "sm:flex-row sm:items-end sm:justify-between sm:gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() })] }), _jsx("div", { className: "mt-2 w-fit sm:mt-0", children: _jsx(EditingLocaleSwitcher, { value: editingOrganizationLocale, onValueChange: setEditingOrganizationLocale }) })] }), baseUrl: baseUrl, editingLocale: editingOrganizationLocale, organization: activeOrganization })) : null }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
|
|
867
|
+
}, children: activeOrganization && canUpdateOrganization ? (_jsx(EditOrganizationSection, { header: _jsxs(DialogHeader, { className: "sm:flex-row sm:items-end sm:justify-between sm:gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() })] }), _jsx("div", { className: "mt-2 w-fit sm:mt-0", children: _jsx(EditingLocaleSwitcher, { locale: auth?.locale, value: editingOrganizationLocale, onValueChange: (value) => setEditingOrganizationLocale(value === "fr" ? "fr" : "en") }) })] }), baseUrl: baseUrl, editingLocale: editingOrganizationLocale, organization: activeOrganization })) : null }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
|
|
868
868
|
setDialog((current) => open ? "members" : current === "members" ? null : current);
|
|
869
869
|
}, children: _jsx(ScrollableDialogContent, { size: "4xl", children: activeOrganization ? (_jsx(OrganizationMembersManager, { baseUrl: baseUrl, canManageMembers: canManageApiKeys, organization: activeOrganization, currentUserId: session.user.id, active: dialog === "members", onLeft: () => {
|
|
870
870
|
setDialog(null);
|
|
871
871
|
onChange?.(null);
|
|
872
872
|
} })) : null }) }), _jsx(Dialog, { open: dialog === "apiKeys" && canManageApiKeys, onOpenChange: (open) => {
|
|
873
873
|
setDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
874
|
-
}, children: _jsx(ScrollableDialogContent, { size: "4xl", children: activeOrganization ? (_jsx(OrganizationApiKeyManager, { baseUrl: baseUrl, organization: activeOrganization, active: dialog === "apiKeys" && canManageApiKeys, permissionLabels: auth?.accessLabels ?? undefined, permissions: apiKeyPermissions ??
|
|
874
|
+
}, children: _jsx(ScrollableDialogContent, { size: "4xl", children: activeOrganization ? (_jsx(OrganizationApiKeyManager, { baseUrl: baseUrl, locale: auth?.locale ?? "en", organization: activeOrganization, active: dialog === "apiKeys" && canManageApiKeys, permissionLabels: auth?.accessLabels ?? undefined, permissions: apiKeyPermissions ??
|
|
875
875
|
auth?.access?.apiKeyPermissions.organization ??
|
|
876
876
|
{} })) : null }) }), _jsx(Dialog, { open: dialog === "invitations" && canViewOrganizationInvitations, onOpenChange: (open) => {
|
|
877
877
|
setDialog((current) => open ? "invitations" : current === "invitations" ? null : current);
|
|
@@ -1443,7 +1443,7 @@ const invitationRowActions = ({ m, cancellingInvitationId, onCancel, }) => [
|
|
|
1443
1443
|
onClick: onCancel,
|
|
1444
1444
|
},
|
|
1445
1445
|
];
|
|
1446
|
-
function OrganizationApiKeyManager({ baseUrl, organization, active, permissionLabels, permissions, }) {
|
|
1446
|
+
function OrganizationApiKeyManager({ baseUrl, locale, organization, active, permissionLabels, permissions, }) {
|
|
1447
1447
|
const m = useOrganizationMessages();
|
|
1448
1448
|
const hasOpened = useOpenedOnce(active);
|
|
1449
1449
|
const keysAtom = hasOpened
|
|
@@ -1547,10 +1547,7 @@ function OrganizationApiKeyManager({ baseUrl, organization, active, permissionLa
|
|
|
1547
1547
|
}, children: [_jsx(createForm.name, { label: m.user_api_key_name(), required: true }), _jsx(createForm.referrers, { label: m.user_api_key_referrers(), description: m.user_api_key_referrers_description(), placeholder: m.user_api_key_referrers_placeholder(), rows: 3 }), _jsx(ApiKeyPermissions, { clearAllLabel: m.user_api_key_permissions_clear_all(), description: m.user_api_key_permissions_description(), idPrefix: "organization-create", permissions: permissions, labels: permissionLabels, selectAllLabel: m.user_api_key_permissions_select_all(), selected: selectedPermissions, title: m.user_api_key_permissions(), onChange: togglePermission, onChangeAll: (ids, checked) => setSelectedPermissions((current) => ({
|
|
1548
1548
|
...current,
|
|
1549
1549
|
...Object.fromEntries(ids.map((id) => [id, checked])),
|
|
1550
|
-
})) }), _jsx(SubmitError, { result: createResult }), _jsx(SubmitButton, { form: createForm })] }) }) })) : null, creating && createdKey ? (_jsx("div", { className: "flex min-w-0 flex-col gap-3", children: _jsxs("div", { className: "bg-muted/50 flex min-w-0 items-center justify-between gap-3 rounded-md border px-3 py-2", children: [_jsx("code", { className: "block min-w-0 flex-1 overflow-x-auto text-sm whitespace-nowrap", children: createdKey }), _jsx(CopyButton, { className: "shrink-0",
|
|
1551
|
-
copied: m.user_api_key_copied(),
|
|
1552
|
-
copy: m.user_api_key_copy(),
|
|
1553
|
-
}, value: createdKey, variant: "ghost" })] }) })) : null, !creating && !editingKey && keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, !creating && !editingKey && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !creating && !editingKey ? (_jsx("div", { className: "max-w-full min-w-0", children: _jsx(DataTable, { columnDefs: apiKeyColumns({ m }), rowData: keys, features: {
|
|
1550
|
+
})) }), _jsx(SubmitError, { result: createResult }), _jsx(SubmitButton, { form: createForm })] }) }) })) : null, creating && createdKey ? (_jsx("div", { className: "flex min-w-0 flex-col gap-3", children: _jsxs("div", { className: "bg-muted/50 flex min-w-0 items-center justify-between gap-3 rounded-md border px-3 py-2", children: [_jsx("code", { className: "block min-w-0 flex-1 overflow-x-auto text-sm whitespace-nowrap", children: createdKey }), _jsx(CopyButton, { className: "shrink-0", locale: locale, value: createdKey, variant: "ghost" })] }) })) : null, !creating && !editingKey && keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, !creating && !editingKey && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !creating && !editingKey ? (_jsx("div", { className: "max-w-full min-w-0", children: _jsx(DataTable, { columnDefs: apiKeyColumns({ m }), rowData: keys, features: {
|
|
1554
1551
|
export: { baseName: `${organization.slug}-api-keys` },
|
|
1555
1552
|
gallery: false,
|
|
1556
1553
|
rowActions: {
|
|
@@ -648,7 +648,7 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
|
|
|
648
648
|
? m.user_two_factor_enabled()
|
|
649
649
|
: m.user_two_factor_disabled() })] }), hasTwoFactorEnabled(session?.user) ? (_jsx(AccountSecuritySettings, { baseUrl: resolvedBaseUrl, accountCache: accountCache, onSetup: setTotpSetup })) : (_jsx(Button, { type: "button", className: "self-start", onClick: () => setManagingTwoFactor(true), children: m.user_two_factor_enable_submit() }))] })] })) })] }) }), _jsx(Dialog, { open: canManageUserSettings && settingsDialog === "apiKeys", onOpenChange: (open) => {
|
|
650
650
|
setSettingsDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
651
|
-
}, children: _jsx(ScrollableDialogContent, { size: "4xl", children: _jsx(ApiKeyManager, { baseUrl: resolvedBaseUrl, active: settingsDialog === "apiKeys", permissionLabels: auth?.accessLabels ?? undefined, permissions: apiKeyPermissions ?? auth?.access?.apiKeyPermissions.user ?? {} }) }) }), isAdmin ? (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: settingsDialog === "adminUsers", onOpenChange: (open) => {
|
|
651
|
+
}, children: _jsx(ScrollableDialogContent, { size: "4xl", children: _jsx(ApiKeyManager, { baseUrl: resolvedBaseUrl, active: settingsDialog === "apiKeys", locale: auth?.locale ?? "en", permissionLabels: auth?.accessLabels ?? undefined, permissions: apiKeyPermissions ?? auth?.access?.apiKeyPermissions.user ?? {} }) }) }), isAdmin ? (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: settingsDialog === "adminUsers", onOpenChange: (open) => {
|
|
652
652
|
setSettingsDialog((current) => open ? "adminUsers" : current === "adminUsers" ? null : current);
|
|
653
653
|
}, children: _jsxs(ScrollableDialogContent, { size: "6xl", children: [_jsx(ScrollableDialogHeader, { 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(ScrollableDialogBody, { children: _jsx(AdminUsersTable, {}) })] }) }), _jsx(Dialog, { open: settingsDialog === "adminOrganizations", onOpenChange: (open) => {
|
|
654
654
|
setSettingsDialog((current) => open
|
|
@@ -803,6 +803,7 @@ const providerName = (providerId, m) => {
|
|
|
803
803
|
return providerId;
|
|
804
804
|
};
|
|
805
805
|
const UserForm = ({ defaultValues, error, onSubmit, }) => {
|
|
806
|
+
const auth = useKrakstackAuth();
|
|
806
807
|
const m = useUserButtonMessages();
|
|
807
808
|
const [editingLocale, setEditingLocale] = useState(getLocale());
|
|
808
809
|
const [form] = useState(() => FormReact.make(userFormBuilder, {
|
|
@@ -829,7 +830,7 @@ const UserForm = ({ defaultValues, error, onSubmit, }) => {
|
|
|
829
830
|
height: 96,
|
|
830
831
|
suggestedWidth: 512,
|
|
831
832
|
suggestedHeight: 512,
|
|
832
|
-
} }), _jsx(form.name, { label: m.user_form_name_label(), autoComplete: "name", required: true }), _jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h3", { className: "text-sm leading-none font-medium", children: m.user_contact_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_contact_description() })] }), _jsx(EditingLocaleSwitcher, { value: editingLocale, onValueChange: setEditingLocale })] }), _jsx(UserContactGroup, { title: m.user_contact_email_type(), children: _jsx(form.emails, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) })] })] }), _jsx(DialogFooter, { className: "-mx-6 -mb-6 border-t px-6 py-4", children: _jsxs("div", { className: "flex flex-col gap-3", children: [error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error })), _jsx(SubmitButton, { form: form })] }) })] }) }) }));
|
|
833
|
+
} }), _jsx(form.name, { label: m.user_form_name_label(), autoComplete: "name", required: true }), _jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h3", { className: "text-sm leading-none font-medium", children: m.user_contact_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_contact_description() })] }), _jsx(EditingLocaleSwitcher, { locale: auth?.locale, value: editingLocale, onValueChange: (value) => setEditingLocale(value === "fr" ? "fr" : "en") })] }), _jsx(UserContactGroup, { title: m.user_contact_email_type(), children: _jsx(form.emails, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) })] })] }), _jsx(DialogFooter, { className: "-mx-6 -mb-6 border-t px-6 py-4", children: _jsxs("div", { className: "flex flex-col gap-3", children: [error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error })), _jsx(SubmitButton, { form: form })] }) })] }) }) }));
|
|
833
834
|
};
|
|
834
835
|
const UserContactGroup = ({ children, title, }) => (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx("h4", { className: "text-sm font-medium", children: title }), children] }));
|
|
835
836
|
function AccountSecuritySettings({ baseUrl, accountCache, onSetup, }) {
|
|
@@ -924,7 +925,7 @@ function DisableTotpForm({ baseUrl, requirePassword, onDisabled, }) {
|
|
|
924
925
|
submit();
|
|
925
926
|
}, children: [requirePassword ? (_jsx(form.password, { label: m.user_field_password(), type: "password", autoComplete: "current-password", required: true })) : null, _jsx(SubmitError, { result: submitResult }), requirePassword ? (_jsx(SubmitButton, { form: form, children: m.user_confirm_password() })) : (_jsxs(Button, { type: "button", disabled: submitResult.waiting, onClick: () => submit(), children: [submitResult.waiting ? (_jsx(Loader2, { "data-icon": "inline-start", className: "animate-spin" })) : null, effectFormMessages().submit] }))] }) }));
|
|
926
927
|
}
|
|
927
|
-
function ApiKeyManager({ baseUrl, active, permissionLabels, permissions = {}, }) {
|
|
928
|
+
function ApiKeyManager({ baseUrl, active, locale, permissionLabels, permissions = {}, }) {
|
|
928
929
|
const m = useUserButtonMessages();
|
|
929
930
|
const hasOpened = useOpenedOnce(active);
|
|
930
931
|
const loadedKeysAtom = userApiKeysAtom(baseUrl);
|
|
@@ -1020,10 +1021,7 @@ function ApiKeyManager({ baseUrl, active, permissionLabels, permissions = {}, })
|
|
|
1020
1021
|
}, children: [_jsx(createForm.name, { label: m.user_api_key_name(), required: true }), _jsx(createForm.referrers, { label: m.user_api_key_referrers(), description: m.user_api_key_referrers_description(), placeholder: m.user_api_key_referrers_placeholder(), rows: 3 }), _jsx(ApiKeyPermissions, { clearAllLabel: m.user_api_key_permissions_clear_all(), description: m.user_api_key_permissions_description(), idPrefix: "user-create", permissions: permissions, labels: permissionLabels, selectAllLabel: m.user_api_key_permissions_select_all(), selected: selectedPermissions, title: m.user_api_key_permissions(), onChange: togglePermission, onChangeAll: (ids, checked) => setSelectedPermissions((current) => ({
|
|
1021
1022
|
...current,
|
|
1022
1023
|
...Object.fromEntries(ids.map((id) => [id, checked])),
|
|
1023
|
-
})) }), _jsx(SubmitError, { result: createSubmitResult }), _jsx(SubmitButton, { form: createForm })] }) }) })) : null, creating && createdKey ? (_jsx("div", { className: "flex min-w-0 flex-col gap-3", children: _jsxs("div", { className: "bg-muted/50 flex min-w-0 items-center justify-between gap-3 rounded-md border px-3 py-2", children: [_jsx("code", { className: "block min-w-0 flex-1 overflow-x-auto text-sm whitespace-nowrap", children: createdKey }), _jsx(CopyButton, { className: "shrink-0",
|
|
1024
|
-
copied: m.user_api_key_copied(),
|
|
1025
|
-
copy: m.user_api_key_copy(),
|
|
1026
|
-
}, value: createdKey, variant: "ghost" })] }) })) : null, !creating && !editingKey && keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, !creating && !editingKey && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !creating && !editingKey ? (_jsx("div", { className: "max-w-full min-w-0", children: _jsx(DataTable, { columnDefs: apiKeyColumns({ m }), rowData: keys, features: {
|
|
1024
|
+
})) }), _jsx(SubmitError, { result: createSubmitResult }), _jsx(SubmitButton, { form: createForm })] }) }) })) : null, creating && createdKey ? (_jsx("div", { className: "flex min-w-0 flex-col gap-3", children: _jsxs("div", { className: "bg-muted/50 flex min-w-0 items-center justify-between gap-3 rounded-md border px-3 py-2", children: [_jsx("code", { className: "block min-w-0 flex-1 overflow-x-auto text-sm whitespace-nowrap", children: createdKey }), _jsx(CopyButton, { className: "shrink-0", locale: locale, value: createdKey, variant: "ghost" })] }) })) : null, !creating && !editingKey && keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, !creating && !editingKey && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !creating && !editingKey ? (_jsx("div", { className: "max-w-full min-w-0", children: _jsx(DataTable, { columnDefs: apiKeyColumns({ m }), rowData: keys, features: {
|
|
1027
1025
|
export: { baseName: m.user_api_keys_export_file_name() },
|
|
1028
1026
|
gallery: false,
|
|
1029
1027
|
rowActions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Effect HttpApi clients and schemas for KrakStack Auth.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -76,11 +76,14 @@
|
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@effect/atom-react": "4.0.0-rc.112",
|
|
79
|
-
"@krak-stack/registry": "^0.1.32",
|
|
80
79
|
"@lucas-barake/effect-form-react": "0.26.0-beta.5",
|
|
81
80
|
"react-qr-code": "^2.2.0"
|
|
82
81
|
},
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@krak-stack/registry": "0.1.34"
|
|
84
|
+
},
|
|
83
85
|
"peerDependencies": {
|
|
86
|
+
"@krak-stack/registry": "^0.1.34",
|
|
84
87
|
"@tanstack/react-router": "^1.170.15",
|
|
85
88
|
"effect": "4.0.0-rc.112",
|
|
86
89
|
"input-otp": "^1.5.0",
|