@krak-stack/auth 0.2.12 → 0.2.14
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/admin/api.group.d.ts +4 -0
- package/dist/admin/schema.d.ts +3 -0
- package/dist/admin/schema.js +4 -1
- package/dist/api.d.ts +1394 -1380
- package/dist/auth/api.group.d.ts +46 -46
- package/dist/components/admin-organizations.d.ts +111 -1
- package/dist/components/admin-organizations.js +142 -26
- package/dist/components/admin-users.js +54 -78
- package/dist/components/associated-projects-notice.d.ts +6 -0
- package/dist/components/associated-projects-notice.js +24 -0
- package/dist/components/auth-atoms.d.ts +3 -3
- package/dist/components/auth-client-api.d.ts +55 -45
- package/dist/components/auth-forms.d.ts +1 -1
- package/dist/components/auth-forms.js +115 -33
- package/dist/components/auth-provider.d.ts +23 -0
- package/dist/components/auth-provider.js +68 -19
- package/dist/components/index.d.ts +4 -3
- package/dist/components/index.js +2 -2
- package/dist/components/organization-switcher.d.ts +4 -0
- package/dist/components/organization-switcher.js +47 -41
- package/dist/components/scrollable-dialog.d.ts +13 -0
- package/dist/components/scrollable-dialog.js +12 -0
- package/dist/components/user-button.d.ts +4 -0
- package/dist/components/user-button.js +75 -69
- package/dist/extra/api.group.d.ts +6 -1
- package/dist/extra/api.group.js +14 -1
- package/dist/extra/schema.d.ts +12 -0
- package/dist/extra/schema.js +18 -0
- package/dist/server/actor.d.ts +2 -1
- package/dist/service.d.ts +102 -90
- package/package.json +3 -3
|
@@ -13,7 +13,7 @@ import { FieldSet } from "@/components/ui/field";
|
|
|
13
13
|
import { Badge } from "@/components/ui/badge";
|
|
14
14
|
import { Button } from "@/components/ui/button";
|
|
15
15
|
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
16
|
-
import { Dialog,
|
|
16
|
+
import { Dialog, DialogFooter, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
17
17
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
18
18
|
import { Separator } from "@/components/ui/separator";
|
|
19
19
|
import { OrganizationEmail, OrganizationAddress, OrganizationMetadata, OrganizationPhone, OrganizationSocial, OrganizationTranslation, OrganizationWebsite, decodeOrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
@@ -27,9 +27,11 @@ import { ApiKeyRateLimit, apiKeyUsagePercent } from "./api-key-rate-limit.js";
|
|
|
27
27
|
import { ApiKeyReferrers, apiKeyReferrers } from "./api-key-referrers.js";
|
|
28
28
|
import { ContactAddressesField, ContactEmailsField, ContactPhonesField, ContactSocialsField, ContactWebsitesField, } from "./contact-fields.js";
|
|
29
29
|
import { useOpenedOnce } from "./hooks.js";
|
|
30
|
+
import { ScrollableDialogBody, ScrollableDialogContent, ScrollableDialogHeader, } from "./scrollable-dialog.js";
|
|
30
31
|
import { invitationDisplayStatus, isInvitationExpired, useInvitationExpirationClock, } from "./invitation-expiration.js";
|
|
31
32
|
import { ExtraUploadedAsset } from "../extra/schema.js";
|
|
32
33
|
import { assetPath, assetUrl, cn } from "./utils.js";
|
|
34
|
+
import { AssociatedProjectsNotice } from "./associated-projects-notice.js";
|
|
33
35
|
import { ExtraApiKeyPermissions } from "../extra/schema.js";
|
|
34
36
|
const messages = {
|
|
35
37
|
en: {
|
|
@@ -54,6 +56,8 @@ const messages = {
|
|
|
54
56
|
organization_create_slug_conflict: "That organization slug is already in use. Choose a different slug.",
|
|
55
57
|
organization_create_title: "Create organization",
|
|
56
58
|
organization_edit_description: "Update the active organization's localized profile.",
|
|
59
|
+
organization_projects_summary: "Used by {count} projects.",
|
|
60
|
+
organization_projects_view: "View",
|
|
57
61
|
organization_invitation_cancel: "Cancel invitation",
|
|
58
62
|
organization_invitation_cancel_error: "Could not cancel the invitation.",
|
|
59
63
|
organization_invitation_accept: "Accept invitation",
|
|
@@ -193,6 +197,8 @@ const messages = {
|
|
|
193
197
|
organization_create_slug_conflict: "Ce slug d'organisation est déjà utilisé. Choisissez un autre slug.",
|
|
194
198
|
organization_create_title: "Créer une organisation",
|
|
195
199
|
organization_edit_description: "Mettez à jour le profil localisé de l'organisation active.",
|
|
200
|
+
organization_projects_summary: "Utilisée dans {count} projets.",
|
|
201
|
+
organization_projects_view: "Voir",
|
|
196
202
|
organization_invitation_cancel: "Annuler l'invitation",
|
|
197
203
|
organization_invitation_cancel_error: "Impossible d'annuler l'invitation.",
|
|
198
204
|
organization_invitation_accept: "Accepter l'invitation",
|
|
@@ -812,7 +818,7 @@ export function OrganizationSwitcher({ baseUrl: providedBaseUrl, side = "bottom"
|
|
|
812
818
|
? { imageSrc: activeDisplay.image }
|
|
813
819
|
: {}) }), _jsx(ChevronsUpDown, { className: "text-muted-foreground size-4 shrink-0 group-data-[collapsible=icon]:hidden" })] }) }), _jsx(DropdownMenuContent, { className: "max-w-[calc(100vw-1rem)] min-w-64 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: activeDisplay.name, subtitle: activeSubtitle, icon: Building2, variant: "sidebar", className: "px-1 py-1.5 text-left text-sm", ...(activeDisplay.image
|
|
814
820
|
? { imageSrc: activeDisplay.image }
|
|
815
|
-
: {}) }) }), menuActions ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), menuActions] })) : null, hasOrganizationListItems ? _jsx(DropdownMenuSeparator, {}) : null, organizationsResult._tag === "Initial" ? (_jsx(DropdownMenuItem, { disabled: true, children: m.organization_loading() })) : null, organizationsError ? (_jsx(DropdownMenuItem, { disabled: true, children: organizationsError })) : null, canSwitchOrganizations && selectableOrganizations.length ? (_jsx("div", { className: cn(scrollOrganizationList &&
|
|
821
|
+
: {}) }) }), active ? (_jsx("div", { className: "px-1 py-2", children: _jsx(AssociatedProjectsNotice, { baseUrl: baseUrl, getSummary: (count) => m.organization_projects_summary({ count }), organizationId: active.id, viewLabel: m.organization_projects_view() }) })) : null, menuActions ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), menuActions] })) : null, hasOrganizationListItems ? _jsx(DropdownMenuSeparator, {}) : null, organizationsResult._tag === "Initial" ? (_jsx(DropdownMenuItem, { disabled: true, children: m.organization_loading() })) : null, organizationsError ? (_jsx(DropdownMenuItem, { disabled: true, children: organizationsError })) : null, canSwitchOrganizations && selectableOrganizations.length ? (_jsx("div", { className: cn(scrollOrganizationList &&
|
|
816
822
|
"max-h-64 overflow-y-auto overscroll-contain"), children: selectableOrganizations.map((organization) => {
|
|
817
823
|
const display = organizationDisplay(organization, m, baseUrl);
|
|
818
824
|
return (_jsx(DropdownMenuItem, { onClick: async () => {
|
|
@@ -841,7 +847,7 @@ export function OrganizationSwitcher({ baseUrl: providedBaseUrl, side = "bottom"
|
|
|
841
847
|
}, children: [_jsx(Copy, {}), m.organization_copy_id()] }));
|
|
842
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) => {
|
|
843
849
|
setDialog((current) => open ? "create" : current === "create" ? null : current);
|
|
844
|
-
}, children: _jsx(CreateOrganizationSection, { header: _jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() }), _jsx("div", { className: "
|
|
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) => {
|
|
845
851
|
setDialog(null);
|
|
846
852
|
let activated = false;
|
|
847
853
|
try {
|
|
@@ -858,20 +864,20 @@ export function OrganizationSwitcher({ baseUrl: providedBaseUrl, side = "bottom"
|
|
|
858
864
|
}
|
|
859
865
|
} }) }), _jsx(Dialog, { open: dialog === "manage" && canUpdateOrganization, onOpenChange: (open) => {
|
|
860
866
|
setDialog((current) => open ? "manage" : current === "manage" ? null : current);
|
|
861
|
-
}, children: activeOrganization && canUpdateOrganization ? (_jsx(EditOrganizationSection, { header: _jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() }), _jsx("div", { className: "
|
|
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) => {
|
|
862
868
|
setDialog((current) => open ? "members" : current === "members" ? null : current);
|
|
863
|
-
}, children: _jsx(
|
|
869
|
+
}, children: _jsx(ScrollableDialogContent, { size: "4xl", children: activeOrganization ? (_jsx(OrganizationMembersManager, { baseUrl: baseUrl, canManageMembers: canManageApiKeys, organization: activeOrganization, currentUserId: session.user.id, active: dialog === "members", onLeft: () => {
|
|
864
870
|
setDialog(null);
|
|
865
871
|
onChange?.(null);
|
|
866
872
|
} })) : null }) }), _jsx(Dialog, { open: dialog === "apiKeys" && canManageApiKeys, onOpenChange: (open) => {
|
|
867
873
|
setDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
868
|
-
}, children: _jsx(
|
|
874
|
+
}, children: _jsx(ScrollableDialogContent, { size: "4xl", children: activeOrganization ? (_jsx(OrganizationApiKeyManager, { baseUrl: baseUrl, organization: activeOrganization, active: dialog === "apiKeys" && canManageApiKeys, permissionLabels: auth?.accessLabels ?? undefined, permissions: apiKeyPermissions ??
|
|
869
875
|
auth?.access?.apiKeyPermissions.organization ??
|
|
870
876
|
{} })) : null }) }), _jsx(Dialog, { open: dialog === "invitations" && canViewOrganizationInvitations, onOpenChange: (open) => {
|
|
871
877
|
setDialog((current) => open ? "invitations" : current === "invitations" ? null : current);
|
|
872
|
-
}, children: _jsxs(
|
|
873
|
-
|
|
874
|
-
|
|
878
|
+
}, children: _jsxs(ScrollableDialogContent, { size: "4xl", children: [_jsx(ScrollableDialogHeader, { children: _jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_user_invitations_title() }), _jsx(DialogDescription, { children: m.organization_user_invitations_description() })] }) }), _jsx(ScrollableDialogBody, { children: _jsx(UserInvitationsManager, { baseUrl: baseUrl, invitations: userInvitations, loading: loadingUserInvitations, error: userInvitationsError, ...(activeOrganization
|
|
879
|
+
? { activeOrganizationId: activeOrganization.id }
|
|
880
|
+
: {}), onActionComplete: refreshAfterInvitationAction }) })] }) })] }));
|
|
875
881
|
}
|
|
876
882
|
function UserInvitationsManager({ baseUrl, invitations, loading, error, activeOrganizationId, onActionComplete, }) {
|
|
877
883
|
const m = useOrganizationMessages();
|
|
@@ -1023,7 +1029,7 @@ function EditOrganizationSection({ header, baseUrl, editingLocale, organization,
|
|
|
1023
1029
|
event.preventDefault();
|
|
1024
1030
|
event.stopPropagation();
|
|
1025
1031
|
submit();
|
|
1026
|
-
}, children: _jsxs(
|
|
1032
|
+
}, children: _jsxs(ScrollableDialogContent, { size: "2xl", children: [_jsx(ScrollableDialogHeader, { children: header }), _jsxs(ScrollableDialogBody, { className: "flex flex-col gap-4", padding: "form", children: [_jsxs(OrganizationFormSection, { title: m.organization_profile(), description: m.organization_translation_description(), children: [_jsxs(FieldSet, { disabled: editingLocale !== "en", className: editingLocale === "en" ? "contents" : "hidden", children: [_jsx(form.enName, { label: m.organization_translation_name() }), _jsx(form.enLogo, { label: m.organization_logo(), size: {
|
|
1027
1033
|
width: 175,
|
|
1028
1034
|
height: 50,
|
|
1029
1035
|
suggestedWidth: 350,
|
|
@@ -1099,7 +1105,7 @@ function CreateOrganizationSection({ header, baseUrl, editingLocale, onCreated,
|
|
|
1099
1105
|
event.preventDefault();
|
|
1100
1106
|
event.stopPropagation();
|
|
1101
1107
|
submit();
|
|
1102
|
-
}, children: _jsxs(
|
|
1108
|
+
}, children: _jsxs(ScrollableDialogContent, { size: "2xl", children: [_jsx(ScrollableDialogHeader, { children: header }), _jsxs(ScrollableDialogBody, { className: "flex flex-col gap-4", padding: "form", children: [_jsxs(OrganizationFormSection, { title: m.organization_profile(), description: m.organization_translation_description(), children: [_jsxs(FieldSet, { disabled: editingLocale !== "en", className: editingLocale === "en" ? "contents" : "hidden", children: [_jsx(form.enName, { label: m.organization_translation_name() }), _jsx(form.enLogo, { label: m.organization_logo(), size: {
|
|
1103
1109
|
width: 175,
|
|
1104
1110
|
height: 50,
|
|
1105
1111
|
suggestedWidth: 350,
|
|
@@ -1299,13 +1305,13 @@ function OrganizationMembersManager({ baseUrl, canManageMembers, organization, c
|
|
|
1299
1305
|
setCancellingInvitationId(null);
|
|
1300
1306
|
}
|
|
1301
1307
|
};
|
|
1302
|
-
return (_jsxs(_Fragment, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: inviting
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1308
|
+
return (_jsxs(_Fragment, { children: [_jsx(ScrollableDialogHeader, { children: _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: inviting
|
|
1309
|
+
? m.organization_invite_member_title()
|
|
1310
|
+
: m.organization_members_title() }), _jsx(DialogDescription, { children: inviting
|
|
1311
|
+
? m.organization_invite_member_description()
|
|
1312
|
+
: m.organization_members_dialog_description({
|
|
1313
|
+
name: organization.name,
|
|
1314
|
+
}) })] }), inviting ? (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", onClick: () => setInviting(false), type: "button", variant: "secondary", children: [_jsx(ArrowLeft, {}), m.organization_back()] })) : canInviteMembers ? (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", onClick: () => setInviting(true), type: "button", children: [_jsx(UserPlus, {}), m.organization_invite_member_title()] })) : null] }) }), _jsxs(ScrollableDialogBody, { className: "flex min-w-0 flex-col gap-5", children: [inviting ? (_jsx(inviteForm.Initialize, { defaultValues: { email: "", role: "member" }, children: _jsxs("form", { className: "grid gap-4 sm:grid-cols-[minmax(0,1fr)_12rem_auto] sm:items-end", onSubmit: (event) => {
|
|
1309
1315
|
event.preventDefault();
|
|
1310
1316
|
event.stopPropagation();
|
|
1311
1317
|
submitInvitation();
|
|
@@ -1513,28 +1519,28 @@ function OrganizationApiKeyManager({ baseUrl, organization, active, permissionLa
|
|
|
1513
1519
|
setError(organizationFailureMessage(cause, m.user_api_key_delete_error()));
|
|
1514
1520
|
}
|
|
1515
1521
|
};
|
|
1516
|
-
return (_jsxs(_Fragment, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: editingKey
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1522
|
+
return (_jsxs(_Fragment, { children: [_jsx(ScrollableDialogHeader, { children: _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: editingKey
|
|
1523
|
+
? m.user_api_key_edit_title()
|
|
1524
|
+
: createdKey
|
|
1525
|
+
? m.user_api_key_created_title()
|
|
1526
|
+
: creating
|
|
1527
|
+
? m.user_api_key_create_title()
|
|
1528
|
+
: m.user_api_keys_title() }), _jsx(DialogDescription, { children: editingKey
|
|
1529
|
+
? m.user_api_key_edit_description()
|
|
1530
|
+
: createdKey
|
|
1531
|
+
? m.user_api_key_created_description()
|
|
1532
|
+
: creating
|
|
1533
|
+
? m.user_api_key_create_description()
|
|
1534
|
+
: m.user_api_keys_organization_description({
|
|
1535
|
+
name: organization.name,
|
|
1536
|
+
}) })] }), creating || editingKey ? (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", onClick: () => {
|
|
1537
|
+
setCreating(false);
|
|
1538
|
+
setCreatedKey(null);
|
|
1539
|
+
setEditingKey(null);
|
|
1540
|
+
}, type: "button", variant: "secondary", children: [_jsx(ArrowLeft, {}), m.user_api_key_back()] })) : (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", onClick: () => {
|
|
1541
|
+
setCreatedKey(null);
|
|
1542
|
+
setCreating(true);
|
|
1543
|
+
}, type: "button", children: [_jsx(Plus, {}), m.user_api_key_create_title()] }))] }) }), _jsxs(ScrollableDialogBody, { className: "flex min-w-0 flex-col gap-5", children: [creating && !createdKey ? (_jsx("section", { className: "w-full", children: _jsx(createForm.Initialize, { defaultValues: { name: "", referrers: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
|
|
1538
1544
|
event.preventDefault();
|
|
1539
1545
|
event.stopPropagation();
|
|
1540
1546
|
submitApiKey();
|
|
@@ -1544,7 +1550,7 @@ function OrganizationApiKeyManager({ baseUrl, organization, active, permissionLa
|
|
|
1544
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", messages: {
|
|
1545
1551
|
copied: m.user_api_key_copied(),
|
|
1546
1552
|
copy: m.user_api_key_copy(),
|
|
1547
|
-
}, 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
|
|
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: {
|
|
1548
1554
|
export: { baseName: `${organization.slug}-api-keys` },
|
|
1549
1555
|
gallery: false,
|
|
1550
1556
|
rowActions: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { DialogContent } from "@/components/ui/dialog";
|
|
3
|
+
type ScrollableDialogSize = "2xl" | "3xl" | "4xl" | "6xl";
|
|
4
|
+
export declare const ScrollableDialogContent: ({ children, size, ...props }: Omit<ComponentProps<typeof DialogContent>, "className"> & {
|
|
5
|
+
readonly children: ReactNode;
|
|
6
|
+
readonly size: ScrollableDialogSize;
|
|
7
|
+
}) => import("react").JSX.Element;
|
|
8
|
+
export declare const ScrollableDialogHeader: ({ children, className, ...props }: ComponentProps<"div">) => import("react").JSX.Element;
|
|
9
|
+
export declare const ScrollableDialogBody: ({ children, className, padding, ...props }: Omit<ComponentProps<"div">, "className"> & {
|
|
10
|
+
readonly className?: string;
|
|
11
|
+
readonly padding?: "default" | "form";
|
|
12
|
+
}) => import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DialogContent } from "@/components/ui/dialog";
|
|
3
|
+
import { Separator } from "@/components/ui/separator";
|
|
4
|
+
const widthClass = {
|
|
5
|
+
"2xl": "sm:max-w-2xl",
|
|
6
|
+
"3xl": "sm:max-w-3xl",
|
|
7
|
+
"4xl": "sm:max-w-4xl",
|
|
8
|
+
"6xl": "sm:max-w-6xl",
|
|
9
|
+
};
|
|
10
|
+
export const ScrollableDialogContent = ({ children, size, ...props }) => (_jsx(DialogContent, { className: `grid max-h-[85vh] min-w-0 grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden ${widthClass[size]}`, ...props, children: children }));
|
|
11
|
+
export const ScrollableDialogHeader = ({ children, className = "", ...props }) => (_jsxs("div", { className: `flex flex-col gap-6 pb-6 ${className}`, ...props, children: [children, _jsx(Separator, {})] }));
|
|
12
|
+
export const ScrollableDialogBody = ({ children, className = "", padding = "default", ...props }) => (_jsx("div", { className: "-mx-6 min-h-0 overflow-y-auto", ...props, children: _jsx("div", { className: `min-w-0 px-6 pt-1 ${padding === "form" ? "pb-6" : "pb-2"} ${className}`, children: children }) }));
|
|
@@ -96,6 +96,8 @@ declare const messages: {
|
|
|
96
96
|
readonly user_delete: "Delete";
|
|
97
97
|
readonly user_field_password: "Password";
|
|
98
98
|
readonly user_form_description: "Update the profile details associated with your account.";
|
|
99
|
+
readonly user_form_projects_summary: "Used by {count} projects.";
|
|
100
|
+
readonly user_form_projects_view: "View";
|
|
99
101
|
readonly user_form_name_label: "Name";
|
|
100
102
|
readonly user_form_title: "Account";
|
|
101
103
|
readonly user_form_update_error: "Unable to update your account.";
|
|
@@ -231,6 +233,8 @@ declare const messages: {
|
|
|
231
233
|
readonly user_delete: "Supprimer";
|
|
232
234
|
readonly user_field_password: "Mot de passe";
|
|
233
235
|
readonly user_form_description: "Mettez à jour les informations de profil associées à votre compte.";
|
|
236
|
+
readonly user_form_projects_summary: "Utilisé dans {count} projets.";
|
|
237
|
+
readonly user_form_projects_view: "Voir";
|
|
234
238
|
readonly user_form_name_label: "Nom";
|
|
235
239
|
readonly user_form_title: "Compte";
|
|
236
240
|
readonly user_form_update_error: "Impossible de mettre à jour votre compte.";
|
|
@@ -14,7 +14,7 @@ import { effectFormMessages, ImageField, SubmitButton, SubmitError, TextAreaFiel
|
|
|
14
14
|
import { Badge } from "@/components/ui/badge";
|
|
15
15
|
import { Button } from "@/components/ui/button";
|
|
16
16
|
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
17
|
-
import { Dialog,
|
|
17
|
+
import { Dialog, DialogFooter, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
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 { authClientApi, authHttpClient } from "./auth-client-api.js";
|
|
@@ -30,6 +30,8 @@ import { ExtraUploadedAsset } from "../extra/schema.js";
|
|
|
30
30
|
import { assetPath, assetUrl } from "./utils.js";
|
|
31
31
|
import { AdminOrganizationsTable } from "./admin-organizations.js";
|
|
32
32
|
import { AdminUsersTable } from "./admin-users.js";
|
|
33
|
+
import { ScrollableDialogBody, ScrollableDialogContent, ScrollableDialogHeader, } from "./scrollable-dialog.js";
|
|
34
|
+
import { AssociatedProjectsNotice } from "./associated-projects-notice.js";
|
|
33
35
|
import { ContactEmailsField, ContactPhonesField, ContactSocialsField, ContactWebsitesField, } from "./contact-fields.js";
|
|
34
36
|
import { decodeUserMetadata, ContactLocale, SocialPlatform, USER_CONTACT_LIMIT, UserMetadata, } from "../schema.js";
|
|
35
37
|
const messages = {
|
|
@@ -126,6 +128,8 @@ const messages = {
|
|
|
126
128
|
user_delete: "Delete",
|
|
127
129
|
user_field_password: "Password",
|
|
128
130
|
user_form_description: "Update the profile details associated with your account.",
|
|
131
|
+
user_form_projects_summary: "Used by {count} projects.",
|
|
132
|
+
user_form_projects_view: "View",
|
|
129
133
|
user_form_name_label: "Name",
|
|
130
134
|
user_form_title: "Account",
|
|
131
135
|
user_form_update_error: "Unable to update your account.",
|
|
@@ -261,6 +265,8 @@ const messages = {
|
|
|
261
265
|
user_delete: "Supprimer",
|
|
262
266
|
user_field_password: "Mot de passe",
|
|
263
267
|
user_form_description: "Mettez à jour les informations de profil associées à votre compte.",
|
|
268
|
+
user_form_projects_summary: "Utilisé dans {count} projets.",
|
|
269
|
+
user_form_projects_view: "Voir",
|
|
264
270
|
user_form_name_label: "Nom",
|
|
265
271
|
user_form_title: "Compte",
|
|
266
272
|
user_form_update_error: "Impossible de mettre à jour votre compte.",
|
|
@@ -553,7 +559,7 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
|
|
|
553
559
|
: `${import.meta.env.VITE_SITE_URL}${signOutRedirect.startsWith("/") ? signOutRedirect : `/${signOutRedirect}`}`;
|
|
554
560
|
signOut({ baseUrl: resolvedBaseUrl, redirectUrl });
|
|
555
561
|
};
|
|
556
|
-
return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "outline", size: "icon", className: "overflow-hidden", children: [displayImage ? (_jsx("img", { src: displayImage, alt: displayName || displayEmail, className: "size-full 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: [isImpersonating ? (_jsx("div", { className: "px-1 py-0.5", children: _jsx(Badge, { variant: "secondary", className: "text-xs font-normal", children: m.user_button_impersonating() }) })) : null, _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 } : {}) }) }), menuActions ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), menuActions] })) : null, _jsx(DropdownMenuSeparator, {}), canManageUserSettings ? (_jsxs(_Fragment, { children: [_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, {})] })) : null, (isAdmin && canUseAdminSettings) || isImpersonating ? (_jsxs(_Fragment, { children: [isAdmin && canUseAdminSettings ? (_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({
|
|
562
|
+
return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "outline", size: "icon", className: "overflow-hidden", children: [displayImage ? (_jsx("img", { src: displayImage, alt: displayName || displayEmail, className: "size-full 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: [isImpersonating ? (_jsx("div", { className: "px-1 py-0.5", children: _jsx(Badge, { variant: "secondary", className: "text-xs font-normal", children: m.user_button_impersonating() }) })) : null, _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("div", { className: "px-1 py-2", children: _jsx(AssociatedProjectsNotice, { baseUrl: resolvedBaseUrl, getSummary: (count) => m.user_form_projects_summary({ count }), viewLabel: m.user_form_projects_view() }) }), menuActions ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), menuActions] })) : null, _jsx(DropdownMenuSeparator, {}), canManageUserSettings ? (_jsxs(_Fragment, { children: [_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, {})] })) : null, (isAdmin && canUseAdminSettings) || isImpersonating ? (_jsxs(_Fragment, { children: [isAdmin && canUseAdminSettings ? (_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({
|
|
557
563
|
baseUrl: resolvedBaseUrl,
|
|
558
564
|
currentSiteHref,
|
|
559
565
|
refreshSession,
|
|
@@ -599,58 +605,58 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
|
|
|
599
605
|
setManagingTwoFactor(false);
|
|
600
606
|
setRevokingAccount(null);
|
|
601
607
|
setSettingsDialog((current) => open ? "security" : current === "security" ? null : current);
|
|
602
|
-
}, children: _jsxs(
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
608
|
+
}, children: _jsxs(ScrollableDialogContent, { size: "3xl", children: [_jsx(ScrollableDialogHeader, { children: _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: changingPassword
|
|
609
|
+
? m.user_account_password_change_title()
|
|
610
|
+
: settingPassword
|
|
611
|
+
? m.user_account_password_set()
|
|
612
|
+
: revokingAccount
|
|
613
|
+
? m.user_account_revoke()
|
|
614
|
+
: managingTwoFactor
|
|
615
|
+
? m.user_two_factor_title()
|
|
616
|
+
: m.user_security_title() }), _jsx(DialogDescription, { children: changingPassword
|
|
617
|
+
? m.user_account_password_change_description()
|
|
618
|
+
: settingPassword
|
|
619
|
+
? m.user_account_password_description()
|
|
620
|
+
: revokingAccount
|
|
621
|
+
? m.user_account_revoke_description({
|
|
622
|
+
provider: providerName(revokingAccount.providerId, m),
|
|
623
|
+
})
|
|
624
|
+
: managingTwoFactor
|
|
625
|
+
? m.user_two_factor_description()
|
|
626
|
+
: m.user_security_description() })] }), changingPassword ||
|
|
627
|
+
settingPassword ||
|
|
628
|
+
revokingAccount ||
|
|
629
|
+
managingTwoFactor ? (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", type: "button", variant: "secondary", onClick: () => {
|
|
630
|
+
setChangingPassword(false);
|
|
631
|
+
setSettingPassword(false);
|
|
632
|
+
setTotpSetup(null);
|
|
633
|
+
setManagingTwoFactor(false);
|
|
634
|
+
setRevokingAccount(null);
|
|
635
|
+
}, children: [_jsx(ArrowLeft, {}), m.user_account_back()] })) : null] }) }), _jsx(ScrollableDialogBody, { children: changingPassword ? (_jsx(ChangePasswordForm, { baseUrl: resolvedBaseUrl })) : settingPassword ? (_jsx(SetPasswordForm, { baseUrl: resolvedBaseUrl, onSaved: async () => {
|
|
636
|
+
await accountCache.reload();
|
|
637
|
+
setSettingPassword(false);
|
|
638
|
+
} })) : revokingAccount ? (_jsx(RevokeAccountForm, { baseUrl: resolvedBaseUrl, account: revokingAccount, requirePassword: requiresPasswordForAccountRevoke(accountCache.accounts ?? []), onCancel: () => setRevokingAccount(null), onRevoked: async () => {
|
|
639
|
+
await accountCache.reload();
|
|
640
|
+
setRevokingAccount(null);
|
|
641
|
+
} })) : totpSetup ? (_jsx(VerifyTotpSetup, { baseUrl: resolvedBaseUrl, setup: totpSetup, onVerified: async () => {
|
|
642
|
+
await refreshSession();
|
|
643
|
+
setTotpSetup(null);
|
|
644
|
+
setManagingTwoFactor(false);
|
|
645
|
+
} })) : managingTwoFactor ? (_jsx(AccountSecuritySettings, { baseUrl: resolvedBaseUrl, accountCache: accountCache, onSetup: setTotpSetup })) : (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(ConnectedAccounts, { onChangePassword: () => setChangingPassword(true), onSetupPassword: () => setSettingPassword(true), onRevokeAccount: setRevokingAccount, baseUrl: resolvedBaseUrl, accountCache: accountCache, googleEnabled: projectConfig?.authOptions.google ?? true, currentSiteHref: currentSiteHref, navigate: navigate }), _jsx(Separator, {}), _jsxs("section", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h2", { className: "text-sm leading-none font-medium", children: m.user_two_factor_title() }), _jsx("p", { className: "text-muted-foreground text-xs", children: m.user_two_factor_description() })] }), _jsx(Badge, { variant: hasTwoFactorEnabled(session?.user)
|
|
646
|
+
? "default"
|
|
647
|
+
: "secondary", children: hasTwoFactorEnabled(session?.user)
|
|
648
|
+
? m.user_two_factor_enabled()
|
|
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) => {
|
|
644
650
|
setSettingsDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
645
|
-
}, children: _jsx(
|
|
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) => {
|
|
646
652
|
setSettingsDialog((current) => open ? "adminUsers" : current === "adminUsers" ? null : current);
|
|
647
|
-
}, children: _jsxs(
|
|
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) => {
|
|
648
654
|
setSettingsDialog((current) => open
|
|
649
655
|
? "adminOrganizations"
|
|
650
656
|
: current === "adminOrganizations"
|
|
651
657
|
? null
|
|
652
658
|
: current);
|
|
653
|
-
}, children: _jsxs(
|
|
659
|
+
}, children: _jsxs(ScrollableDialogContent, { size: "6xl", children: [_jsx(ScrollableDialogHeader, { 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(ScrollableDialogBody, { children: _jsx(AdminOrganizationsTable, {}) })] }) })] })) : null] }));
|
|
654
660
|
};
|
|
655
661
|
function ConnectedAccounts({ onSetupPassword, onRevokeAccount, onChangePassword, baseUrl, accountCache, googleEnabled, currentSiteHref, navigate, }) {
|
|
656
662
|
const m = useUserButtonMessages();
|
|
@@ -818,7 +824,7 @@ const UserForm = ({ defaultValues, error, onSubmit, }) => {
|
|
|
818
824
|
event.preventDefault();
|
|
819
825
|
event.stopPropagation();
|
|
820
826
|
submit();
|
|
821
|
-
}, children: _jsxs(
|
|
827
|
+
}, children: _jsxs(ScrollableDialogContent, { size: "3xl", children: [_jsx(ScrollableDialogHeader, { children: _jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_form_title() }), _jsx(DialogDescription, { children: m.user_form_description() })] }) }), _jsxs(ScrollableDialogBody, { className: "flex flex-col gap-4", padding: "form", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h2", { className: "text-sm leading-none font-medium", children: m.user_profile_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_profile_description() })] }), _jsx(form.image, { label: m.user_profile_photo_upload_label(), size: {
|
|
822
828
|
width: 96,
|
|
823
829
|
height: 96,
|
|
824
830
|
suggestedWidth: 512,
|
|
@@ -988,26 +994,26 @@ function ApiKeyManager({ baseUrl, active, permissionLabels, permissions = {}, })
|
|
|
988
994
|
? cause.message
|
|
989
995
|
: m.user_api_key_delete_error()))))));
|
|
990
996
|
const deleteKey = useAtomSet(deleteKeyAction);
|
|
991
|
-
return (_jsxs(_Fragment, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: editingKey
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
997
|
+
return (_jsxs(_Fragment, { children: [_jsx(ScrollableDialogHeader, { children: _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: editingKey
|
|
998
|
+
? m.user_api_key_edit_title()
|
|
999
|
+
: createdKey
|
|
1000
|
+
? m.user_api_key_created_title()
|
|
1001
|
+
: creating
|
|
1002
|
+
? m.user_api_key_create_title()
|
|
1003
|
+
: m.user_api_keys_title() }), _jsx(DialogDescription, { children: editingKey
|
|
1004
|
+
? m.user_api_key_edit_description()
|
|
1005
|
+
: createdKey
|
|
1006
|
+
? m.user_api_key_created_description()
|
|
1007
|
+
: creating
|
|
1008
|
+
? m.user_api_key_create_description()
|
|
1009
|
+
: m.user_api_keys_description() })] }), creating || editingKey ? (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", onClick: () => {
|
|
1010
|
+
setCreating(false);
|
|
1011
|
+
setCreatedKey(null);
|
|
1012
|
+
setEditingKey(null);
|
|
1013
|
+
}, type: "button", variant: "secondary", children: [_jsx(ArrowLeft, {}), m.user_api_key_back()] })) : (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", onClick: () => {
|
|
1014
|
+
setCreatedKey(null);
|
|
1015
|
+
setCreating(true);
|
|
1016
|
+
}, type: "button", children: [_jsx(Plus, {}), m.user_api_key_create_title()] }))] }) }), _jsxs(ScrollableDialogBody, { className: "flex min-w-0 flex-col gap-5", children: [creating && !createdKey ? (_jsx("section", { className: "w-full", children: _jsx(createForm.Initialize, { defaultValues: { name: "", referrers: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
|
|
1011
1017
|
event.preventDefault();
|
|
1012
1018
|
event.stopPropagation();
|
|
1013
1019
|
submitCreateForm();
|
|
@@ -1017,7 +1023,7 @@ function ApiKeyManager({ baseUrl, active, permissionLabels, permissions = {}, })
|
|
|
1017
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", messages: {
|
|
1018
1024
|
copied: m.user_api_key_copied(),
|
|
1019
1025
|
copy: m.user_api_key_copy(),
|
|
1020
|
-
}, 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
|
|
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: {
|
|
1021
1027
|
export: { baseName: m.user_api_keys_export_file_name() },
|
|
1022
1028
|
gallery: false,
|
|
1023
1029
|
rowActions: {
|
|
@@ -82,7 +82,12 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
82
82
|
readonly emailOtp: Schema.Boolean;
|
|
83
83
|
readonly google: Schema.Boolean;
|
|
84
84
|
}>;
|
|
85
|
-
}>>, Schema.toCodecJson<typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
85
|
+
}>>, Schema.toCodecJson<typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"listAssociatedProjects", "GET", "/auth/associated-projects", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
86
|
+
readonly organizationId: Schema.optional<Schema.String>;
|
|
87
|
+
}>>, never, never, Schema.toCodecJson<Schema.$Array<Schema.Struct<{
|
|
88
|
+
readonly id: Schema.String;
|
|
89
|
+
readonly name: Schema.String;
|
|
90
|
+
}>>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"setPassword", "POST", "/auth/set-password", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
86
91
|
readonly newPassword: Schema.NonEmptyString;
|
|
87
92
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
88
93
|
readonly ok: Schema.Boolean;
|
package/dist/extra/api.group.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { OpenApi } from "effect/unstable/httpapi";
|
|
3
3
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup, } from "effect/unstable/httpapi";
|
|
4
|
-
import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraOrganizationPublicProfile, ExtraOrganizationPublicProfileQuery, ExtraProjectPublicConfig, ExtraProjectPublicConfigQuery, ExtraSetPasswordPayload, ExtraUpdateApiKeyPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema.js";
|
|
4
|
+
import { ExtraBadRequest, ExtraAssociatedProjects, ExtraAssociatedProjectsQuery, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraOrganizationPublicProfile, ExtraOrganizationPublicProfileQuery, ExtraProjectPublicConfig, ExtraProjectPublicConfigQuery, ExtraSetPasswordPayload, ExtraUpdateApiKeyPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema.js";
|
|
5
5
|
export * from "./schema.js";
|
|
6
6
|
export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
7
7
|
.add(HttpApiEndpoint.get("getProjectPublicConfig", "/auth/project-config", {
|
|
@@ -12,6 +12,19 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
12
12
|
title: "Get project public config",
|
|
13
13
|
summary: "Get host-aware project white-label config",
|
|
14
14
|
description: "Returns resolved public branding and authentication options through the proxied auth API.",
|
|
15
|
+
})))
|
|
16
|
+
.add(HttpApiEndpoint.get("listAssociatedProjects", "/auth/associated-projects", {
|
|
17
|
+
query: ExtraAssociatedProjectsQuery.fields,
|
|
18
|
+
success: ExtraAssociatedProjects,
|
|
19
|
+
error: [
|
|
20
|
+
HttpApiError.Unauthorized,
|
|
21
|
+
HttpApiError.Forbidden,
|
|
22
|
+
HttpApiError.InternalServerError,
|
|
23
|
+
],
|
|
24
|
+
}).annotateMerge(OpenApi.annotations({
|
|
25
|
+
title: "List associated projects",
|
|
26
|
+
summary: "List projects affected by account or organization changes",
|
|
27
|
+
description: "Returns projects associated with the current user or with an organization the current user belongs to.",
|
|
15
28
|
})))
|
|
16
29
|
.add(HttpApiEndpoint.patch("updateApiKey", "/auth/api-key/:keyId", {
|
|
17
30
|
params: { keyId: Schema.NonEmptyString },
|
package/dist/extra/schema.d.ts
CHANGED
|
@@ -101,6 +101,17 @@ export declare const ExtraProjectPublicConfig: Schema.Struct<{
|
|
|
101
101
|
readonly google: Schema.Boolean;
|
|
102
102
|
}>;
|
|
103
103
|
}>;
|
|
104
|
+
export declare const ExtraAssociatedProjectsQuery: Schema.Struct<{
|
|
105
|
+
readonly organizationId: Schema.optional<Schema.String>;
|
|
106
|
+
}>;
|
|
107
|
+
export declare const ExtraAssociatedProject: Schema.Struct<{
|
|
108
|
+
readonly id: Schema.String;
|
|
109
|
+
readonly name: Schema.String;
|
|
110
|
+
}>;
|
|
111
|
+
export declare const ExtraAssociatedProjects: Schema.$Array<Schema.Struct<{
|
|
112
|
+
readonly id: Schema.String;
|
|
113
|
+
readonly name: Schema.String;
|
|
114
|
+
}>>;
|
|
104
115
|
export declare const ExtraOrganizationPublicProfileQuery: Schema.Struct<{
|
|
105
116
|
readonly organizationId: Schema.String;
|
|
106
117
|
readonly locale: Schema.optional<Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>>;
|
|
@@ -178,6 +189,7 @@ export type ExtraVerifyApiKeyPayload = typeof ExtraVerifyApiKeyPayload.Type;
|
|
|
178
189
|
export type ExtraVerifyApiKeyResponse = typeof ExtraVerifyApiKeyResponse.Type;
|
|
179
190
|
export type ExtraProjectPublicConfigQuery = typeof ExtraProjectPublicConfigQuery.Type;
|
|
180
191
|
export type ExtraProjectPublicConfig = typeof ExtraProjectPublicConfig.Type;
|
|
192
|
+
export type ExtraAssociatedProject = typeof ExtraAssociatedProject.Type;
|
|
181
193
|
export type ExtraOrganizationPublicProfileQuery = typeof ExtraOrganizationPublicProfileQuery.Type;
|
|
182
194
|
export type ExtraOrganizationPublicProfile = typeof ExtraOrganizationPublicProfile.Type;
|
|
183
195
|
export type ExtraOkResponse = typeof ExtraOkResponse.Type;
|