@krak-stack/auth 0.1.22 → 0.1.23
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.
|
@@ -4,7 +4,7 @@ import {} from "@tanstack/react-table";
|
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
import { Building2, Check, ChevronsUpDown, KeyRound, Mail, PencilIcon, Plus, Trash2, UserPlus, Users, X, } from "lucide-react";
|
|
6
6
|
import { createContext, useContext, useEffect, useEffectEvent, useState, } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { DataTable } from "@/components/ui/data-table";
|
|
8
8
|
import { EditingLocaleSwitcher } from "@/components/ui/editing-locale-switcher";
|
|
9
9
|
import { AppBrand } from "@/components/ui/app-brand";
|
|
10
10
|
import { useAppForm } from "@/components/ui/form";
|
|
@@ -486,12 +486,14 @@ function UserInvitationsManager({ authClient, invitations, loading, error, activ
|
|
|
486
486
|
};
|
|
487
487
|
return (_jsxs("section", { className: "flex flex-col gap-4", children: [error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, actionError ? (_jsx("p", { className: "text-destructive text-sm", children: actionError })) : null, _jsx(DataTable, { columns: userInvitationColumns({
|
|
488
488
|
m,
|
|
489
|
+
}), data: invitations, emptyLabel: loading ? m.user_loading() : m.organization_user_invitations_empty(), exportFileName: "organization-invitations.csv", features: { gallery: false }, rowActions: userInvitationRowActions({
|
|
490
|
+
m,
|
|
489
491
|
actingInvitationId,
|
|
490
492
|
onAccept: acceptInvitation,
|
|
491
493
|
onReject: rejectInvitation,
|
|
492
|
-
})
|
|
494
|
+
}) })] }));
|
|
493
495
|
}
|
|
494
|
-
const userInvitationColumns = ({ m,
|
|
496
|
+
const userInvitationColumns = ({ m, }) => [
|
|
495
497
|
{
|
|
496
498
|
accessorKey: "organizationName",
|
|
497
499
|
header: m.organization_invitation_organization(),
|
|
@@ -512,21 +514,21 @@ const userInvitationColumns = ({ m, actingInvitationId, onAccept, onReject, }) =
|
|
|
512
514
|
header: m.organization_invitation_expires(),
|
|
513
515
|
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: formatOrganizationDate(row.original.expiresAt) })),
|
|
514
516
|
},
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
517
|
+
];
|
|
518
|
+
const userInvitationRowActions = ({ m, actingInvitationId, onAccept, onReject, }) => [
|
|
519
|
+
{
|
|
520
|
+
name: m.organization_invitation_accept(),
|
|
521
|
+
icon: _jsx(Check, {}),
|
|
522
|
+
visible: (invitation) => actingInvitationId !== invitation.id,
|
|
523
|
+
onClick: onAccept,
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
name: m.organization_invitation_reject(),
|
|
527
|
+
icon: _jsx(X, {}),
|
|
528
|
+
variant: "destructive",
|
|
529
|
+
visible: (invitation) => actingInvitationId !== invitation.id,
|
|
530
|
+
onClick: onReject,
|
|
531
|
+
},
|
|
530
532
|
];
|
|
531
533
|
function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated, }) {
|
|
532
534
|
const m = useOrganizationMessages();
|
|
@@ -801,17 +803,21 @@ function OrganizationMembersManager({ authClient, organization, currentUserId, }
|
|
|
801
803
|
value: role,
|
|
802
804
|
})) })) }), _jsx("div", { className: "self-end", children: _jsx(inviteForm.SubmitButton, {}) }), _jsx(inviteForm.FormError, {})] }) }), error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsxs("section", { className: "flex flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_members_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_members_description() })] }), _jsx(DataTable, { columns: memberColumns({
|
|
803
805
|
m,
|
|
804
|
-
currentUserId,
|
|
805
806
|
updatingMemberId,
|
|
806
|
-
onRemove: removeMember,
|
|
807
807
|
onRoleChange: updateRole,
|
|
808
|
-
}), data: members, emptyLabel: loading ? m.user_loading() : m.organization_members_empty(), exportFileName: `${organization.slug}-members.csv`, features: { gallery: false }
|
|
808
|
+
}), data: members, emptyLabel: loading ? m.user_loading() : m.organization_members_empty(), exportFileName: `${organization.slug}-members.csv`, features: { gallery: false }, rowActions: memberRowActions({
|
|
809
|
+
m,
|
|
810
|
+
currentUserId,
|
|
811
|
+
onRemove: removeMember,
|
|
812
|
+
}) })] }), _jsxs("section", { className: "flex flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_invitations_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invitations_description() })] }), _jsx(DataTable, { columns: invitationColumns({
|
|
813
|
+
m,
|
|
814
|
+
}), data: invitations, emptyLabel: loading ? m.user_loading() : m.organization_invitations_empty(), exportFileName: `${organization.slug}-invitations.csv`, features: { gallery: false }, rowActions: invitationRowActions({
|
|
809
815
|
m,
|
|
810
816
|
cancellingInvitationId,
|
|
811
817
|
onCancel: cancelInvitation,
|
|
812
|
-
})
|
|
818
|
+
}) })] })] }));
|
|
813
819
|
}
|
|
814
|
-
const memberColumns = ({ m,
|
|
820
|
+
const memberColumns = ({ m, updatingMemberId, onRoleChange, }) => [
|
|
815
821
|
{
|
|
816
822
|
id: "user",
|
|
817
823
|
header: m.organization_member_user(),
|
|
@@ -838,17 +844,17 @@ const memberColumns = ({ m, currentUserId, updatingMemberId, onRemove, onRoleCha
|
|
|
838
844
|
header: m.organization_member_joined(),
|
|
839
845
|
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: formatOrganizationDate(row.original.createdAt) })),
|
|
840
846
|
},
|
|
841
|
-
createDataTableActionsColumn([
|
|
842
|
-
{
|
|
843
|
-
name: m.organization_member_remove(),
|
|
844
|
-
icon: _jsx(Trash2, {}),
|
|
845
|
-
variant: "destructive",
|
|
846
|
-
visible: (member) => member.userId !== currentUserId,
|
|
847
|
-
onClick: onRemove,
|
|
848
|
-
},
|
|
849
|
-
]),
|
|
850
847
|
];
|
|
851
|
-
const
|
|
848
|
+
const memberRowActions = ({ m, currentUserId, onRemove, }) => [
|
|
849
|
+
{
|
|
850
|
+
name: m.organization_member_remove(),
|
|
851
|
+
icon: _jsx(Trash2, {}),
|
|
852
|
+
variant: "destructive",
|
|
853
|
+
visible: (member) => member.userId !== currentUserId,
|
|
854
|
+
onClick: onRemove,
|
|
855
|
+
},
|
|
856
|
+
];
|
|
857
|
+
const invitationColumns = ({ m, }) => [
|
|
852
858
|
{
|
|
853
859
|
accessorKey: "email",
|
|
854
860
|
header: m.organization_member_email(),
|
|
@@ -869,15 +875,15 @@ const invitationColumns = ({ m, cancellingInvitationId, onCancel, }) => [
|
|
|
869
875
|
header: m.organization_invitation_expires(),
|
|
870
876
|
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: formatOrganizationDate(row.original.expiresAt) })),
|
|
871
877
|
},
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
878
|
+
];
|
|
879
|
+
const invitationRowActions = ({ m, cancellingInvitationId, onCancel, }) => [
|
|
880
|
+
{
|
|
881
|
+
name: m.organization_invitation_cancel(),
|
|
882
|
+
icon: _jsx(Trash2, {}),
|
|
883
|
+
variant: "destructive",
|
|
884
|
+
visible: (invitation) => cancellingInvitationId !== invitation.id,
|
|
885
|
+
onClick: onCancel,
|
|
886
|
+
},
|
|
881
887
|
];
|
|
882
888
|
function OrganizationApiKeyManager({ authClient, organization, }) {
|
|
883
889
|
const m = useOrganizationMessages();
|
|
@@ -941,9 +947,9 @@ function OrganizationApiKeyManager({ authClient, organization, }) {
|
|
|
941
947
|
event.preventDefault();
|
|
942
948
|
event.stopPropagation();
|
|
943
949
|
createForm.handleSubmit();
|
|
944
|
-
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.user_api_key_name(), required: true })) }), _jsx(createForm.FormError, {}), _jsx(createForm.SubmitButton, {})] }) }), createdKey ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(KeyRound, {}), m.user_api_key_created_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_api_key_created_description() }), _jsx("code", { className: "bg-muted overflow-x-auto rounded-md p-3 text-sm", children: createdKey })] })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsx(Separator, {}), _jsx(DataTable, { columns: apiKeyColumns({ m
|
|
950
|
+
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.user_api_key_name(), required: true })) }), _jsx(createForm.FormError, {}), _jsx(createForm.SubmitButton, {})] }) }), createdKey ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(KeyRound, {}), m.user_api_key_created_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_api_key_created_description() }), _jsx("code", { className: "bg-muted overflow-x-auto rounded-md p-3 text-sm", children: createdKey })] })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsx(Separator, {}), _jsx(DataTable, { columns: apiKeyColumns({ m }), data: keys, emptyLabel: loading ? m.user_loading() : m.table_empty(), exportFileName: `${organization.slug}-api-keys.csv`, features: { gallery: false }, rowActions: apiKeyRowActions({ m, onDelete: deleteKey }) })] }));
|
|
945
951
|
}
|
|
946
|
-
const apiKeyColumns = ({ m,
|
|
952
|
+
const apiKeyColumns = ({ m, }) => [
|
|
947
953
|
{
|
|
948
954
|
accessorKey: "name",
|
|
949
955
|
header: m.user_api_key_name(),
|
|
@@ -958,12 +964,12 @@ const apiKeyColumns = ({ m, onDelete, }) => [
|
|
|
958
964
|
? m.user_api_key_enabled()
|
|
959
965
|
: m.user_api_key_disabled() })),
|
|
960
966
|
},
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
967
|
+
];
|
|
968
|
+
const apiKeyRowActions = ({ m, onDelete, }) => [
|
|
969
|
+
{
|
|
970
|
+
name: m.user_delete(),
|
|
971
|
+
icon: _jsx(Trash2, {}),
|
|
972
|
+
variant: "destructive",
|
|
973
|
+
onClick: onDelete,
|
|
974
|
+
},
|
|
969
975
|
];
|
|
@@ -4,7 +4,7 @@ import { useNavigate, useRouterState, } from "@tanstack/react-router";
|
|
|
4
4
|
import { Check, Copy, KeyRound, LogOutIcon, ShieldCheck, Trash2, UserCircleIcon, UserIcon, } from "lucide-react";
|
|
5
5
|
import { QRCode } from "react-qr-code";
|
|
6
6
|
import { createContext, useContext, useEffect, useEffectEvent, useState, } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { DataTable } from "@/components/ui/data-table";
|
|
8
8
|
import { AppBrand } from "@/components/ui/app-brand";
|
|
9
9
|
import { useAppForm } from "@/components/ui/form";
|
|
10
10
|
import { Badge } from "@/components/ui/badge";
|
|
@@ -700,9 +700,9 @@ function ApiKeyManager({ authClient, permissions = {}, }) {
|
|
|
700
700
|
event.preventDefault();
|
|
701
701
|
event.stopPropagation();
|
|
702
702
|
createForm.handleSubmit();
|
|
703
|
-
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.user_api_key_name(), required: true })) }), permissionOptions.length > 0 ? (_jsxs(FieldSet, { children: [_jsx(FieldLegend, { children: m.user_api_key_permissions() }), _jsx(FieldDescription, { children: m.user_api_key_permissions_description() }), _jsx(FieldGroup, { "data-slot": "checkbox-group", className: "gap-3", children: permissionOptions.map((permission) => (_jsxs(Field, { orientation: "horizontal", children: [_jsx(Checkbox, { id: permission.id, checked: selectedPermissions[permission.id] ?? false, onCheckedChange: (checked) => togglePermission(permission.id, checked) }), _jsx(FieldContent, { children: _jsx(FieldLabel, { htmlFor: permission.id, children: permission.id }) })] }, permission.id))) })] })) : null, _jsx(createForm.FormError, {}), _jsx(createForm.SubmitButton, {})] }) }), createdKey ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(KeyRound, {}), m.user_api_key_created_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_api_key_created_description() }), _jsxs("div", { className: "grid min-w-0 gap-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center", children: [_jsx("code", { className: "bg-muted block max-w-full overflow-x-auto rounded-md p-3 text-sm whitespace-nowrap", children: createdKey }), _jsxs(Button, { type: "button", variant: "outline", onClick: copyCreatedKey, className: "self-start sm:self-auto", children: [copiedKey ? _jsx(Check, {}) : _jsx(Copy, {}), copiedKey ? m.user_api_key_copied() : m.user_api_key_copy()] })] })] })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsx(Separator, {}), _jsx(DataTable, { columns: apiKeyColumns({ m
|
|
703
|
+
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.user_api_key_name(), required: true })) }), permissionOptions.length > 0 ? (_jsxs(FieldSet, { children: [_jsx(FieldLegend, { children: m.user_api_key_permissions() }), _jsx(FieldDescription, { children: m.user_api_key_permissions_description() }), _jsx(FieldGroup, { "data-slot": "checkbox-group", className: "gap-3", children: permissionOptions.map((permission) => (_jsxs(Field, { orientation: "horizontal", children: [_jsx(Checkbox, { id: permission.id, checked: selectedPermissions[permission.id] ?? false, onCheckedChange: (checked) => togglePermission(permission.id, checked) }), _jsx(FieldContent, { children: _jsx(FieldLabel, { htmlFor: permission.id, children: permission.id }) })] }, permission.id))) })] })) : null, _jsx(createForm.FormError, {}), _jsx(createForm.SubmitButton, {})] }) }), createdKey ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(KeyRound, {}), m.user_api_key_created_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_api_key_created_description() }), _jsxs("div", { className: "grid min-w-0 gap-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center", children: [_jsx("code", { className: "bg-muted block max-w-full overflow-x-auto rounded-md p-3 text-sm whitespace-nowrap", children: createdKey }), _jsxs(Button, { type: "button", variant: "outline", onClick: copyCreatedKey, className: "self-start sm:self-auto", children: [copiedKey ? _jsx(Check, {}) : _jsx(Copy, {}), copiedKey ? m.user_api_key_copied() : m.user_api_key_copy()] })] })] })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsx(Separator, {}), _jsx(DataTable, { columns: apiKeyColumns({ m }), data: keys, emptyLabel: loading ? m.user_loading() : m.table_empty(), exportFileName: m.user_api_keys_export_file_name(), features: { gallery: false }, rowActions: apiKeyRowActions({ m, onDelete: deleteKey }) })] }));
|
|
704
704
|
}
|
|
705
|
-
const apiKeyColumns = ({ m,
|
|
705
|
+
const apiKeyColumns = ({ m, }) => [
|
|
706
706
|
{
|
|
707
707
|
accessorKey: "name",
|
|
708
708
|
header: m.user_api_key_name(),
|
|
@@ -726,14 +726,14 @@ const apiKeyColumns = ({ m, onDelete, }) => [
|
|
|
726
726
|
return (_jsx("div", { className: "flex max-w-sm flex-wrap gap-1.5", children: permissions.map((permission) => (_jsx(Badge, { variant: "secondary", children: permission }, permission))) }));
|
|
727
727
|
},
|
|
728
728
|
},
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
729
|
+
];
|
|
730
|
+
const apiKeyRowActions = ({ m, onDelete, }) => [
|
|
731
|
+
{
|
|
732
|
+
name: m.user_delete(),
|
|
733
|
+
icon: _jsx(Trash2, {}),
|
|
734
|
+
variant: "destructive",
|
|
735
|
+
onClick: onDelete,
|
|
736
|
+
},
|
|
737
737
|
];
|
|
738
738
|
const getPermissionId = (resource, action) => `${resource}:${action}`;
|
|
739
739
|
const isPermissionRecord = (permissions) => typeof permissions === "object" &&
|