@krak-stack/auth 0.1.59 → 0.1.61
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/access.d.ts +53 -28
- package/dist/access.js +34 -19
- package/dist/api.d.ts +10 -6
- package/dist/components/api-key-edit-form.d.ts +6 -3
- package/dist/components/api-key-edit-form.js +44 -11
- package/dist/components/api-key-permissions.d.ts +10 -0
- package/dist/components/api-key-permissions.js +45 -0
- package/dist/components/api-key.d.ts +6 -1
- package/dist/components/api-key.js +21 -1
- package/dist/components/auth-client-api.d.ts +5 -3
- package/dist/components/auth-provider.d.ts +4 -2
- package/dist/components/auth-provider.js +3 -1
- package/dist/components/has-permission.d.ts +6 -0
- package/dist/components/has-permission.js +4 -0
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +3 -1
- package/dist/components/organization-switcher.d.ts +2 -2
- package/dist/components/organization-switcher.js +13 -11
- package/dist/components/project-access-matrix.d.ts +28 -0
- package/dist/components/project-access-matrix.js +92 -0
- package/dist/components/user-button.d.ts +2 -2
- package/dist/components/user-button.js +9 -8
- package/dist/extra/api.group.d.ts +5 -3
- package/dist/extra/api.group.js +10 -7
- package/dist/extra/schema.d.ts +6 -4
- package/dist/extra/schema.js +12 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/server/actor.d.ts +95 -0
- package/dist/server/actor.js +127 -0
- package/dist/server/index.d.ts +4 -2
- package/dist/server/index.js +2 -1
- package/dist/service.d.ts +21 -17
- package/dist/service.js +5 -2
- package/package.json +5 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export declare const useHasPermission: (permission: string) => boolean;
|
|
3
|
+
export declare const HasPermission: ({ children, permission, }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
permission: string;
|
|
6
|
+
}) => import("react").JSX.Element | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { usePermissions } from "./auth-provider";
|
|
3
|
+
export const useHasPermission = (permission) => usePermissions().can(permission);
|
|
4
|
+
export const HasPermission = ({ children, permission, }) => (useHasPermission(permission) ? _jsx(_Fragment, { children: children }) : null);
|
|
@@ -2,14 +2,17 @@ export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAut
|
|
|
2
2
|
export { createAuthUiClient } from "./auth-client";
|
|
3
3
|
export { OrganizationSwitcher } from "./organization-switcher";
|
|
4
4
|
export { MemberRequired } from "./member-required";
|
|
5
|
+
export { HasPermission, useHasPermission } from "./has-permission";
|
|
6
|
+
export { ProjectAccessMatrix } from "./project-access-matrix";
|
|
5
7
|
export { ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, } from "./auth-forms";
|
|
6
8
|
export { UserButton } from "./user-button";
|
|
7
9
|
export { AdminOrganizationsTable } from "./admin-organizations";
|
|
8
10
|
export { AdminOrganizationForm } from "./admin-organization-form";
|
|
9
11
|
export { AdminUsersTable, useAdminUsersTotal } from "./admin-users";
|
|
10
12
|
export { assetUrl } from "./utils";
|
|
11
|
-
export { ApiKeyPermissionGrant,
|
|
12
|
-
export type { ApiKeyOwner,
|
|
13
|
+
export { ApiKeyPermissionGrant, CurrentActor, Forbidden, all, actorUserId, any, defineProjectAccess, defineProjectAccessLabels, permission, policy, withPolicy, } from "../access";
|
|
14
|
+
export type { ApiKeyOwner, ApiKeyActor, Actor, Policy, ProjectAccessConfig, ProjectAccessCatalog, ProjectAccessLabelCatalog, ProjectAccessDefinition, ProjectAccessLabels, UserActor, } from "../access";
|
|
15
|
+
export type { ProjectAccessMatrixAccess, ProjectAccessMatrixMessages, } from "./project-access-matrix";
|
|
13
16
|
export type { KrakstackAuthContextValue, KrakstackAuthLocale, KrakstackAuthProviderProps, } from "./auth-provider";
|
|
14
17
|
export type { OrganizationSwitcherDialog, OrganizationSwitcherFeatures, OrganizationSwitcherProps, } from "./organization-switcher";
|
|
15
18
|
export type { UserButtonDialog } from "./user-button";
|
package/dist/components/index.js
CHANGED
|
@@ -2,10 +2,12 @@ export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAut
|
|
|
2
2
|
export { createAuthUiClient } from "./auth-client";
|
|
3
3
|
export { OrganizationSwitcher } from "./organization-switcher";
|
|
4
4
|
export { MemberRequired } from "./member-required";
|
|
5
|
+
export { HasPermission, useHasPermission } from "./has-permission";
|
|
6
|
+
export { ProjectAccessMatrix } from "./project-access-matrix";
|
|
5
7
|
export { ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, } from "./auth-forms";
|
|
6
8
|
export { UserButton } from "./user-button";
|
|
7
9
|
export { AdminOrganizationsTable } from "./admin-organizations";
|
|
8
10
|
export { AdminOrganizationForm } from "./admin-organization-form";
|
|
9
11
|
export { AdminUsersTable, useAdminUsersTotal } from "./admin-users";
|
|
10
12
|
export { assetUrl } from "./utils";
|
|
11
|
-
export { ApiKeyPermissionGrant,
|
|
13
|
+
export { ApiKeyPermissionGrant, CurrentActor, Forbidden, all, actorUserId, any, defineProjectAccess, defineProjectAccessLabels, permission, policy, withPolicy, } from "../access";
|
|
@@ -106,7 +106,7 @@ declare const messages: {
|
|
|
106
106
|
readonly user_api_key_created_title: "API key created";
|
|
107
107
|
readonly user_api_key_delete_error: "Could not delete the API key.";
|
|
108
108
|
readonly user_api_key_disabled: "Disabled";
|
|
109
|
-
readonly user_api_key_edit_description: "Update the key name, status,
|
|
109
|
+
readonly user_api_key_edit_description: "Update the key name, status, allowed referrers, and permissions.";
|
|
110
110
|
readonly user_api_key_edit_title: "Edit API key";
|
|
111
111
|
readonly user_api_key_enabled: "Enabled";
|
|
112
112
|
readonly user_api_key_hidden: "Secret hidden";
|
|
@@ -242,7 +242,7 @@ declare const messages: {
|
|
|
242
242
|
readonly user_api_key_created_title: "Clé API créée";
|
|
243
243
|
readonly user_api_key_delete_error: "Impossible de supprimer la clé API.";
|
|
244
244
|
readonly user_api_key_disabled: "Désactivée";
|
|
245
|
-
readonly user_api_key_edit_description: "Mettez à jour le nom, le statut
|
|
245
|
+
readonly user_api_key_edit_description: "Mettez à jour le nom, le statut, les référents autorisés et les autorisations de la clé.";
|
|
246
246
|
readonly user_api_key_edit_title: "Modifier la clé API";
|
|
247
247
|
readonly user_api_key_enabled: "Activée";
|
|
248
248
|
readonly user_api_key_hidden: "Secret masqué";
|
|
@@ -15,18 +15,18 @@ import { Field, FieldLabel, FieldSet } from "@/components/ui/field";
|
|
|
15
15
|
import { Input } from "@/components/ui/input";
|
|
16
16
|
import { Badge } from "@/components/ui/badge";
|
|
17
17
|
import { Button } from "@/components/ui/button";
|
|
18
|
-
import { Checkbox } from "@/components/ui/checkbox";
|
|
19
18
|
import { CopyButton } from "@/components/ui/copy-button";
|
|
20
19
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
21
20
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
22
21
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select";
|
|
23
22
|
import { Separator } from "@/components/ui/separator";
|
|
24
23
|
import { OrganizationEmail, OrganizationAddress, OrganizationMetadata, OrganizationPhone, OrganizationSocial, OrganizationTranslation, OrganizationWebsite, decodeOrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
25
|
-
import { isOrganizationRole, normalizeOrganizationRole, normalizeOrganizationRoles, organizationRoles, } from "../roles";
|
|
24
|
+
import { isOrganizationRole, normalizeOrganizationRole, normalizeOrganizationRoles, organizationRoles, parseRoleList, } from "../roles";
|
|
26
25
|
import { authClientApi } from "./auth-client-api";
|
|
27
26
|
import { useKrakstackAuth } from "./auth-provider";
|
|
28
27
|
import { createApiKey, parseApiKeyReferrers } from "./api-key";
|
|
29
28
|
import { ApiKeyEditForm } from "./api-key-edit-form";
|
|
29
|
+
import { ApiKeyPermissions } from "./api-key-permissions";
|
|
30
30
|
import { ApiKeyRateLimit, apiKeyUsagePercent } from "./api-key-rate-limit";
|
|
31
31
|
import { ApiKeyReferrers } from "./api-key-referrers";
|
|
32
32
|
import { useOpenedOnce } from "./hooks";
|
|
@@ -138,7 +138,7 @@ const messages = {
|
|
|
138
138
|
user_api_key_created_title: "API key created",
|
|
139
139
|
user_api_key_delete_error: "Could not delete the API key.",
|
|
140
140
|
user_api_key_disabled: "Disabled",
|
|
141
|
-
user_api_key_edit_description: "Update the key name, status,
|
|
141
|
+
user_api_key_edit_description: "Update the key name, status, allowed referrers, and permissions.",
|
|
142
142
|
user_api_key_edit_title: "Edit API key",
|
|
143
143
|
user_api_key_enabled: "Enabled",
|
|
144
144
|
user_api_key_hidden: "Secret hidden",
|
|
@@ -274,7 +274,7 @@ const messages = {
|
|
|
274
274
|
user_api_key_created_title: "Clé API créée",
|
|
275
275
|
user_api_key_delete_error: "Impossible de supprimer la clé API.",
|
|
276
276
|
user_api_key_disabled: "Désactivée",
|
|
277
|
-
user_api_key_edit_description: "Mettez à jour le nom, le statut
|
|
277
|
+
user_api_key_edit_description: "Mettez à jour le nom, le statut, les référents autorisés et les autorisations de la clé.",
|
|
278
278
|
user_api_key_edit_title: "Modifier la clé API",
|
|
279
279
|
user_api_key_enabled: "Activée",
|
|
280
280
|
user_api_key_hidden: "Secret masqué",
|
|
@@ -847,8 +847,8 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
847
847
|
onSuccess: () => null,
|
|
848
848
|
});
|
|
849
849
|
const loadingUserInvitations = invitationsResult._tag === "Initial";
|
|
850
|
-
const
|
|
851
|
-
const canManageApiKeys =
|
|
850
|
+
const activeMemberRoles = parseRoleList(activeOrganization.data?.members.find((member) => member.userId === session.data?.user.id)?.role);
|
|
851
|
+
const canManageApiKeys = activeMemberRoles.some((role) => role === "owner" || role === "admin");
|
|
852
852
|
const canUpdateOrganization = canManageApiKeys;
|
|
853
853
|
const canSwitchOrganizations = features?.organizationSwitching ?? true;
|
|
854
854
|
const canCreateOrganization = features?.organizationCreation ?? true;
|
|
@@ -954,8 +954,8 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
954
954
|
onChange?.(null);
|
|
955
955
|
} })) : null }) }), _jsx(Dialog, { open: dialog === "apiKeys" && canManageApiKeys, onOpenChange: (open) => {
|
|
956
956
|
setDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
957
|
-
}, children: _jsx(DialogContent, { className: "max-h-[85vh] min-w-0 overflow-x-hidden overflow-y-auto sm:max-w-3xl", children: activeOrganization.data ? (_jsx(OrganizationApiKeyManager, { authClient: authClient, organization: activeOrganization.data, active: dialog === "apiKeys" && canManageApiKeys, permissions: apiKeyPermissions ??
|
|
958
|
-
auth?.access?.
|
|
957
|
+
}, children: _jsx(DialogContent, { className: "max-h-[85vh] min-w-0 overflow-x-hidden overflow-y-auto sm:max-w-3xl", children: activeOrganization.data ? (_jsx(OrganizationApiKeyManager, { authClient: authClient, organization: activeOrganization.data, active: dialog === "apiKeys" && canManageApiKeys, permissionLabels: auth?.accessLabels ?? undefined, permissions: apiKeyPermissions ??
|
|
958
|
+
auth?.access?.apiKeyPermissions.organization ??
|
|
959
959
|
{} })) : null }) }), _jsx(Dialog, { open: dialog === "invitations" && canViewOrganizationInvitations, onOpenChange: (open) => {
|
|
960
960
|
setDialog((current) => open ? "invitations" : current === "invitations" ? null : current);
|
|
961
961
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_user_invitations_title() }), _jsx(DialogDescription, { children: m.organization_user_invitations_description() })] }), _jsx(Separator, {}), _jsx(UserInvitationsManager, { authClient: authClient, baseUrl: baseUrl, invitations: userInvitations, loading: loadingUserInvitations, error: userInvitationsError, ...(activeOrganization.data
|
|
@@ -1490,7 +1490,7 @@ const invitationRowActions = ({ m, cancellingInvitationId, onCancel, }) => [
|
|
|
1490
1490
|
onClick: onCancel,
|
|
1491
1491
|
},
|
|
1492
1492
|
];
|
|
1493
|
-
function OrganizationApiKeyManager({ authClient, organization, active, permissions, }) {
|
|
1493
|
+
function OrganizationApiKeyManager({ authClient, organization, active, permissionLabels, permissions, }) {
|
|
1494
1494
|
const m = useOrganizationMessages();
|
|
1495
1495
|
const hasOpened = useOpenedOnce(active);
|
|
1496
1496
|
const keysAtom = hasOpened
|
|
@@ -1587,7 +1587,7 @@ function OrganizationApiKeyManager({ authClient, organization, active, permissio
|
|
|
1587
1587
|
event.preventDefault();
|
|
1588
1588
|
event.stopPropagation();
|
|
1589
1589
|
submitApiKey();
|
|
1590
|
-
}, 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 }),
|
|
1590
|
+
}, 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, { description: m.user_api_key_permissions_description(), idPrefix: "organization-create", permissions: permissions, labels: permissionLabels, selected: selectedPermissions, title: m.user_api_key_permissions(), onChange: togglePermission }), _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: {
|
|
1591
1591
|
copied: m.user_api_key_copied(),
|
|
1592
1592
|
copy: m.user_api_key_copy(),
|
|
1593
1593
|
}, 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 overflow-x-hidden", children: _jsx(DataTable, { columns: apiKeyColumns({ m }), data: keys, features: {
|
|
@@ -1603,13 +1603,15 @@ function OrganizationApiKeyManager({ authClient, organization, active, permissio
|
|
|
1603
1603
|
}, searchState: "local", state: {
|
|
1604
1604
|
empty: loading ? m.user_loading() : m.table_empty(),
|
|
1605
1605
|
loading,
|
|
1606
|
-
} }) })) : null, editingKey ? (_jsx(ApiKeyEditForm, {
|
|
1606
|
+
} }) })) : null, editingKey ? (_jsx(ApiKeyEditForm, { configId: "organization", keyData: editingKey, permissions: permissions, permissionLabels: permissionLabels, messages: {
|
|
1607
1607
|
enabled: m.user_api_key_enabled(),
|
|
1608
1608
|
name: m.user_api_key_name(),
|
|
1609
1609
|
referrers: m.user_api_key_referrers(),
|
|
1610
1610
|
referrersDescription: m.user_api_key_referrers_description(),
|
|
1611
1611
|
referrersError: m.user_api_key_referrers_error(),
|
|
1612
1612
|
referrersPlaceholder: m.user_api_key_referrers_placeholder(),
|
|
1613
|
+
permissions: m.user_api_key_permissions(),
|
|
1614
|
+
permissionsDescription: m.user_api_key_permissions_description(),
|
|
1613
1615
|
updateError: m.user_api_key_update_error(),
|
|
1614
1616
|
}, onSaved: () => {
|
|
1615
1617
|
refreshKeys();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ProjectAccessLabels } from "../access";
|
|
2
|
+
export type ProjectAccessMatrixAccess<Action extends string = string> = {
|
|
3
|
+
readonly actions: ReadonlyArray<Action>;
|
|
4
|
+
readonly apiKeys: {
|
|
5
|
+
readonly user: ReadonlyArray<Action>;
|
|
6
|
+
readonly organization: ReadonlyArray<Action>;
|
|
7
|
+
readonly service: ReadonlyArray<Action>;
|
|
8
|
+
};
|
|
9
|
+
readonly project: string;
|
|
10
|
+
readonly roles: Readonly<Record<string, ReadonlyArray<Action> | undefined>>;
|
|
11
|
+
};
|
|
12
|
+
export type ProjectAccessMatrixMessages = {
|
|
13
|
+
action: string;
|
|
14
|
+
allowed: string;
|
|
15
|
+
apiKeyPermissions: string;
|
|
16
|
+
denied: string;
|
|
17
|
+
organizationKey: string;
|
|
18
|
+
resource: string;
|
|
19
|
+
rolePermissions: string;
|
|
20
|
+
serviceKey: string;
|
|
21
|
+
userKey: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const ProjectAccessMatrix: <Action extends string, Role extends string>({ access, labels, locale, messages: messageOverrides, }: {
|
|
24
|
+
access: ProjectAccessMatrixAccess<Action>;
|
|
25
|
+
labels?: ProjectAccessLabels<Action, Role>;
|
|
26
|
+
locale?: string;
|
|
27
|
+
messages?: Partial<ProjectAccessMatrixMessages>;
|
|
28
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check, Minus } from "lucide-react";
|
|
3
|
+
const messages = {
|
|
4
|
+
en: {
|
|
5
|
+
action: "Action",
|
|
6
|
+
allowed: "Allowed",
|
|
7
|
+
apiKeyPermissions: "API-key assignable permissions",
|
|
8
|
+
denied: "Not allowed",
|
|
9
|
+
organizationKey: "Organization key",
|
|
10
|
+
resource: "Resource",
|
|
11
|
+
rolePermissions: "Role grants",
|
|
12
|
+
serviceKey: "Service key",
|
|
13
|
+
userKey: "User key",
|
|
14
|
+
},
|
|
15
|
+
fr: {
|
|
16
|
+
action: "Action",
|
|
17
|
+
allowed: "Autorisé",
|
|
18
|
+
apiKeyPermissions: "Autorisations attribuables aux clés API",
|
|
19
|
+
denied: "Non autorisé",
|
|
20
|
+
organizationKey: "Clé d’organisation",
|
|
21
|
+
resource: "Ressource",
|
|
22
|
+
rolePermissions: "Droits des rôles",
|
|
23
|
+
serviceKey: "Clé de service",
|
|
24
|
+
userKey: "Clé utilisateur",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export const ProjectAccessMatrix = ({ access, labels, locale = "en", messages: messageOverrides, }) => {
|
|
28
|
+
const language = locale === "fr" ? "fr" : "en";
|
|
29
|
+
const text = { ...messages[language], ...messageOverrides };
|
|
30
|
+
const roleLabel = (id) => {
|
|
31
|
+
const label = Object.entries(labels?.roles ?? {}).find(([role]) => role === id)?.[1];
|
|
32
|
+
return typeof label === "string" ? label : capitalizeFirst(id);
|
|
33
|
+
};
|
|
34
|
+
const roleColumns = Object.entries(access.roles).map(([id, permissions]) => ({
|
|
35
|
+
id,
|
|
36
|
+
label: roleLabel(id),
|
|
37
|
+
permissions: permissions ?? [],
|
|
38
|
+
}));
|
|
39
|
+
const keyColumns = [
|
|
40
|
+
{
|
|
41
|
+
id: "user",
|
|
42
|
+
label: text.userKey,
|
|
43
|
+
permissions: access.apiKeys.user,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "organization",
|
|
47
|
+
label: text.organizationKey,
|
|
48
|
+
permissions: access.apiKeys.organization,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "service",
|
|
52
|
+
label: text.serviceKey,
|
|
53
|
+
permissions: access.apiKeys.service,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
return (_jsxs("div", { className: "space-y-8", children: [_jsx(PermissionTable, { access: access, columns: roleColumns, labels: labels, text: text, title: text.rolePermissions }), _jsx(PermissionTable, { access: access, columns: keyColumns, labels: labels, text: text, title: text.apiKeyPermissions })] }));
|
|
57
|
+
};
|
|
58
|
+
const PermissionTable = ({ access, columns, labels, text, title, }) => (_jsxs("section", { className: "space-y-3", children: [_jsx("h3", { className: "text-lg font-semibold", children: title }), _jsx("div", { className: "overflow-x-auto rounded-lg border", children: _jsxs("table", { className: "w-full min-w-max border-collapse text-sm", children: [_jsx("thead", { className: "bg-muted/50", children: _jsxs("tr", { children: [_jsx("th", { className: "px-4 py-3 text-left font-medium", scope: "col", children: text.resource }), _jsx("th", { className: "px-4 py-3 text-left font-medium", scope: "col", children: text.action }), columns.map((column) => (_jsx("th", { className: "px-4 py-3 text-center font-medium", scope: "col", children: column.label }, column.id)))] }) }), _jsx("tbody", { children: access.actions.map((permission) => {
|
|
59
|
+
const { action, resource } = splitPermission(permission);
|
|
60
|
+
return (_jsxs("tr", { className: "border-t", children: [_jsxs("th", { className: "px-4 py-3 text-left font-normal", scope: "row", children: [_jsx("span", { children: permissionLabels(labels, resource, action).resource }), _jsx("code", { className: "text-muted-foreground ml-2 text-xs", children: resource })] }), _jsxs("td", { className: "px-4 py-3", children: [_jsx("span", { children: permissionLabels(labels, resource, action).action }), _jsx("code", { className: "text-muted-foreground ml-2 text-xs", children: action })] }), columns.map((column) => (_jsx(PermissionCell, { allowed: column.permissions.includes(permission), messages: text }, column.id)))] }, permission));
|
|
61
|
+
}) })] }) })] }));
|
|
62
|
+
const PermissionCell = ({ allowed, messages, }) => (_jsxs("td", { className: "px-4 py-3 text-center", children: [_jsx("span", { className: "sr-only", children: allowed ? messages.allowed : messages.denied }), allowed ? (_jsx(Check, { "aria-hidden": "true", className: "mx-auto size-4 text-emerald-600 dark:text-emerald-400" })) : (_jsx(Minus, { "aria-hidden": "true", className: "text-muted-foreground/60 mx-auto size-4" }))] }));
|
|
63
|
+
const splitPermission = (permission) => {
|
|
64
|
+
const separator = permission.indexOf(":");
|
|
65
|
+
return separator === -1
|
|
66
|
+
? { resource: permission, action: permission }
|
|
67
|
+
: {
|
|
68
|
+
resource: permission.slice(0, separator),
|
|
69
|
+
action: permission.slice(separator + 1),
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const capitalizeFirst = (value) => value.charAt(0).toUpperCase() + value.slice(1);
|
|
73
|
+
const permissionLabels = (labels, resource, action) => {
|
|
74
|
+
const group = Reflect.get(labels?.permissions ?? {}, resource);
|
|
75
|
+
if (typeof group !== "object" || group === null) {
|
|
76
|
+
return {
|
|
77
|
+
resource: capitalizeFirst(resource),
|
|
78
|
+
action: capitalizeFirst(action),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const resourceLabel = Reflect.get(group, "label");
|
|
82
|
+
const actions = Reflect.get(group, "actions");
|
|
83
|
+
const actionLabel = typeof actions === "object" && actions !== null
|
|
84
|
+
? Reflect.get(actions, action)
|
|
85
|
+
: undefined;
|
|
86
|
+
return {
|
|
87
|
+
resource: typeof resourceLabel === "string"
|
|
88
|
+
? resourceLabel
|
|
89
|
+
: capitalizeFirst(resource),
|
|
90
|
+
action: typeof actionLabel === "string" ? actionLabel : capitalizeFirst(action),
|
|
91
|
+
};
|
|
92
|
+
};
|
|
@@ -42,7 +42,7 @@ declare const messages: {
|
|
|
42
42
|
readonly user_api_key_created_title: "API key created";
|
|
43
43
|
readonly user_api_key_delete_error: "Could not delete the API key.";
|
|
44
44
|
readonly user_api_key_disabled: "Disabled";
|
|
45
|
-
readonly user_api_key_edit_description: "Update the key name, status,
|
|
45
|
+
readonly user_api_key_edit_description: "Update the key name, status, allowed referrers, and permissions.";
|
|
46
46
|
readonly user_api_key_edit_title: "Edit API key";
|
|
47
47
|
readonly user_api_key_enabled: "Enabled";
|
|
48
48
|
readonly user_api_key_hidden: "Secret hidden";
|
|
@@ -149,7 +149,7 @@ declare const messages: {
|
|
|
149
149
|
readonly user_api_key_created_title: "Clé API créée";
|
|
150
150
|
readonly user_api_key_delete_error: "Impossible de supprimer la clé API.";
|
|
151
151
|
readonly user_api_key_disabled: "Désactivée";
|
|
152
|
-
readonly user_api_key_edit_description: "Mettez à jour le nom, le statut
|
|
152
|
+
readonly user_api_key_edit_description: "Mettez à jour le nom, le statut, les référents autorisés et les autorisations de la clé.";
|
|
153
153
|
readonly user_api_key_edit_title: "Modifier la clé API";
|
|
154
154
|
readonly user_api_key_enabled: "Activée";
|
|
155
155
|
readonly user_api_key_hidden: "Secret masqué";
|
|
@@ -13,16 +13,15 @@ import { AppBrand } from "@/components/ui/app-brand";
|
|
|
13
13
|
import { effectFormMessages, ImageField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@/components/ui/effect-form";
|
|
14
14
|
import { Badge } from "@/components/ui/badge";
|
|
15
15
|
import { Button } from "@/components/ui/button";
|
|
16
|
-
import { Checkbox } from "@/components/ui/checkbox";
|
|
17
16
|
import { CopyButton } from "@/components/ui/copy-button";
|
|
18
17
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
19
|
-
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSet, } from "@/components/ui/field";
|
|
20
18
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
21
19
|
import { Separator } from "@/components/ui/separator";
|
|
22
20
|
import { authClientApi } from "./auth-client-api";
|
|
23
21
|
import { useKrakstackAuth } from "./auth-provider";
|
|
24
22
|
import { createApiKey, parseApiKeyReferrers } from "./api-key";
|
|
25
23
|
import { ApiKeyEditForm } from "./api-key-edit-form";
|
|
24
|
+
import { ApiKeyPermissions } from "./api-key-permissions";
|
|
26
25
|
import { ApiKeyRateLimit, apiKeyUsagePercent } from "./api-key-rate-limit";
|
|
27
26
|
import { ApiKeyReferrers } from "./api-key-referrers";
|
|
28
27
|
import { useOpenedOnce } from "./hooks";
|
|
@@ -71,7 +70,7 @@ const messages = {
|
|
|
71
70
|
user_api_key_created_title: "API key created",
|
|
72
71
|
user_api_key_delete_error: "Could not delete the API key.",
|
|
73
72
|
user_api_key_disabled: "Disabled",
|
|
74
|
-
user_api_key_edit_description: "Update the key name, status,
|
|
73
|
+
user_api_key_edit_description: "Update the key name, status, allowed referrers, and permissions.",
|
|
75
74
|
user_api_key_edit_title: "Edit API key",
|
|
76
75
|
user_api_key_enabled: "Enabled",
|
|
77
76
|
user_api_key_hidden: "Secret hidden",
|
|
@@ -178,7 +177,7 @@ const messages = {
|
|
|
178
177
|
user_api_key_created_title: "Clé API créée",
|
|
179
178
|
user_api_key_delete_error: "Impossible de supprimer la clé API.",
|
|
180
179
|
user_api_key_disabled: "Désactivée",
|
|
181
|
-
user_api_key_edit_description: "Mettez à jour le nom, le statut
|
|
180
|
+
user_api_key_edit_description: "Mettez à jour le nom, le statut, les référents autorisés et les autorisations de la clé.",
|
|
182
181
|
user_api_key_edit_title: "Modifier la clé API",
|
|
183
182
|
user_api_key_enabled: "Activée",
|
|
184
183
|
user_api_key_hidden: "Secret masqué",
|
|
@@ -434,7 +433,7 @@ export const UserButton = ({ authClient: providedAuthClient, baseUrl, signOutRed
|
|
|
434
433
|
setSettingsDialog((current) => open ? "security" : current === "security" ? null : current);
|
|
435
434
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_security_title() }), _jsx(DialogDescription, { children: m.user_security_description() })] }), _jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(PasswordSettings, { authClient: authClient, baseUrl: baseUrl, accountCache: accountCache }), _jsx(Separator, {}), _jsx(AccountSecuritySettings, { authClient: authClient, accountCache: accountCache })] })] }) }), _jsx(Dialog, { open: canManageUserSettings && settingsDialog === "apiKeys", onOpenChange: (open) => {
|
|
436
435
|
setSettingsDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
437
|
-
}, children: _jsx(DialogContent, { className: "max-h-[85vh] min-w-0 overflow-x-hidden overflow-y-auto sm:max-w-3xl", children: _jsx(ApiKeyManager, { authClient: authClient, active: settingsDialog === "apiKeys", permissions: apiKeyPermissions ?? auth?.access?.
|
|
436
|
+
}, children: _jsx(DialogContent, { className: "max-h-[85vh] min-w-0 overflow-x-hidden overflow-y-auto sm:max-w-3xl", children: _jsx(ApiKeyManager, { authClient: authClient, active: settingsDialog === "apiKeys", permissionLabels: auth?.accessLabels ?? undefined, permissions: apiKeyPermissions ?? auth?.access?.apiKeyPermissions.user ?? {} }) }) }), isAdmin ? (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: settingsDialog === "adminUsers", onOpenChange: (open) => {
|
|
438
437
|
setSettingsDialog((current) => open ? "adminUsers" : current === "adminUsers" ? null : current);
|
|
439
438
|
}, children: _jsxs(DialogContent, { className: "flex h-[85vh] flex-col overflow-y-auto sm:max-w-6xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_button_admin_users() }), _jsx(DialogDescription, { children: m.user_button_admin_users_description() })] }), _jsx(Separator, {}), _jsx("div", { className: "min-h-0 flex-1", children: _jsx(AdminUsersTable, {}) })] }) }), _jsx(Dialog, { open: settingsDialog === "adminOrganizations", onOpenChange: (open) => {
|
|
440
439
|
setSettingsDialog((current) => open
|
|
@@ -753,7 +752,7 @@ function DisableTotpForm({ authClient, requirePassword, onDisabled, }) {
|
|
|
753
752
|
submit();
|
|
754
753
|
}, 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 })) : (_jsxs(Button, { type: "button", disabled: submitResult.waiting, onClick: () => submit(), children: [submitResult.waiting ? (_jsx(Loader2, { "data-icon": "inline-start", className: "animate-spin" })) : null, effectFormMessages().submit] }))] }) }));
|
|
755
754
|
}
|
|
756
|
-
function ApiKeyManager({ authClient, active, permissions = {}, }) {
|
|
755
|
+
function ApiKeyManager({ authClient, active, permissionLabels, permissions = {}, }) {
|
|
757
756
|
const m = useUserButtonMessages();
|
|
758
757
|
const hasOpened = useOpenedOnce(active);
|
|
759
758
|
const keysAtom = hasOpened ? userApiKeysAtom(authClient) : emptyApiKeysAtom;
|
|
@@ -842,7 +841,7 @@ function ApiKeyManager({ authClient, active, permissions = {}, }) {
|
|
|
842
841
|
event.preventDefault();
|
|
843
842
|
event.stopPropagation();
|
|
844
843
|
submitCreateForm();
|
|
845
|
-
}, 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 }),
|
|
844
|
+
}, 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, { description: m.user_api_key_permissions_description(), idPrefix: "user-create", permissions: permissions, labels: permissionLabels, selected: selectedPermissions, title: m.user_api_key_permissions(), onChange: togglePermission }), _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: {
|
|
846
845
|
copied: m.user_api_key_copied(),
|
|
847
846
|
copy: m.user_api_key_copy(),
|
|
848
847
|
}, 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 overflow-x-hidden", children: _jsx(DataTable, { columns: apiKeyColumns({ m }), data: keys, features: {
|
|
@@ -858,13 +857,15 @@ function ApiKeyManager({ authClient, active, permissions = {}, }) {
|
|
|
858
857
|
}, searchState: "local", state: {
|
|
859
858
|
empty: loading ? m.user_loading() : m.table_empty(),
|
|
860
859
|
loading,
|
|
861
|
-
} }) })) : null, editingKey ? (_jsx(ApiKeyEditForm, {
|
|
860
|
+
} }) })) : null, editingKey ? (_jsx(ApiKeyEditForm, { configId: "user", keyData: editingKey, permissions: permissions, permissionLabels: permissionLabels, messages: {
|
|
862
861
|
enabled: m.user_api_key_enabled(),
|
|
863
862
|
name: m.user_api_key_name(),
|
|
864
863
|
referrers: m.user_api_key_referrers(),
|
|
865
864
|
referrersDescription: m.user_api_key_referrers_description(),
|
|
866
865
|
referrersError: m.user_api_key_referrers_error(),
|
|
867
866
|
referrersPlaceholder: m.user_api_key_referrers_placeholder(),
|
|
867
|
+
permissions: m.user_api_key_permissions(),
|
|
868
|
+
permissionsDescription: m.user_api_key_permissions_description(),
|
|
868
869
|
updateError: m.user_api_key_update_error(),
|
|
869
870
|
}, onSaved: () => {
|
|
870
871
|
refreshKeys();
|
|
@@ -88,11 +88,14 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
88
88
|
readonly newPassword: Schema.NonEmptyString;
|
|
89
89
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
90
90
|
readonly ok: Schema.Boolean;
|
|
91
|
-
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
91
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"updateApiKey", "PATCH", "/auth/api-key/:keyId", HttpApiEndpoint.StringTree<Schema.Struct<{
|
|
92
92
|
readonly keyId: Schema.NonEmptyString;
|
|
93
93
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
94
94
|
readonly configId: Schema.Union<readonly [Schema.Literal<"user">, Schema.Literal<"organization">, Schema.Literal<"service">]>;
|
|
95
|
-
readonly
|
|
95
|
+
readonly name: Schema.NonEmptyString;
|
|
96
|
+
readonly enabled: Schema.Boolean;
|
|
97
|
+
readonly permissions: Schema.optional<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
|
|
98
|
+
readonly referrers: Schema.optional<Schema.$Array<Schema.String>>;
|
|
96
99
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
97
100
|
readonly ok: Schema.Boolean;
|
|
98
101
|
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"uploadUserImage", "POST", "/auth/image/upload", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/unstable/httpapi/HttpApiSchema").asMultipartStream<Schema.Struct<{
|
|
@@ -102,7 +105,6 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
102
105
|
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyApiKey", "POST", "/auth/verify-api-key", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
103
106
|
readonly key: Schema.NonEmptyString;
|
|
104
107
|
readonly configId: Schema.optional<Schema.Union<readonly [Schema.Literal<"user">, Schema.Literal<"organization">, Schema.Literal<"service">]>>;
|
|
105
|
-
readonly permissions: Schema.optional<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
|
|
106
108
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
107
109
|
readonly valid: Schema.Boolean;
|
|
108
110
|
readonly error: Schema.NullOr<Schema.Struct<{
|
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,
|
|
4
|
+
import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraOrganizationPublicProfile, ExtraOrganizationPublicProfileQuery, ExtraProjectPublicConfig, ExtraProjectPublicConfigQuery, ExtraSetPasswordPayload, ExtraUpdateApiKeyPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema";
|
|
5
5
|
export * from "./schema";
|
|
6
6
|
export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
7
7
|
.add(HttpApiEndpoint.get("getProjectPublicConfig", "/auth/project-config", {
|
|
@@ -13,11 +13,14 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
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
15
|
})))
|
|
16
|
-
.add(HttpApiEndpoint.patch("
|
|
16
|
+
.add(HttpApiEndpoint.patch("updateApiKey", "/auth/api-key/:keyId", {
|
|
17
17
|
params: Schema.Struct({ keyId: Schema.NonEmptyString }),
|
|
18
18
|
payload: Schema.Struct({
|
|
19
|
-
configId:
|
|
20
|
-
|
|
19
|
+
configId: ExtraUpdateApiKeyPayload.fields.configId,
|
|
20
|
+
name: ExtraUpdateApiKeyPayload.fields.name,
|
|
21
|
+
enabled: ExtraUpdateApiKeyPayload.fields.enabled,
|
|
22
|
+
permissions: ExtraUpdateApiKeyPayload.fields.permissions,
|
|
23
|
+
referrers: ExtraUpdateApiKeyPayload.fields.referrers,
|
|
21
24
|
}),
|
|
22
25
|
success: ExtraOkResponse,
|
|
23
26
|
error: [
|
|
@@ -27,9 +30,9 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
27
30
|
HttpApiError.InternalServerError,
|
|
28
31
|
],
|
|
29
32
|
}).annotateMerge(OpenApi.annotations({
|
|
30
|
-
title: "Update API key
|
|
31
|
-
summary: "
|
|
32
|
-
description: "Updates server-only
|
|
33
|
+
title: "Update API key",
|
|
34
|
+
summary: "Update an API key",
|
|
35
|
+
description: "Updates API key details and server-only permissions after Better Auth verifies user ownership or organization key-management access.",
|
|
33
36
|
})))
|
|
34
37
|
.add(HttpApiEndpoint.get("getOrganizationPublicProfile", "/auth/organization-profile", {
|
|
35
38
|
query: ExtraOrganizationPublicProfileQuery,
|
package/dist/extra/schema.d.ts
CHANGED
|
@@ -26,15 +26,17 @@ export declare const ExtraCreateApiKeyResponse: Schema.Struct<{
|
|
|
26
26
|
readonly id: Schema.String;
|
|
27
27
|
readonly key: Schema.String;
|
|
28
28
|
}>;
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const ExtraUpdateApiKeyPayload: Schema.Struct<{
|
|
30
30
|
readonly configId: Schema.Union<readonly [Schema.Literal<"user">, Schema.Literal<"organization">, Schema.Literal<"service">]>;
|
|
31
31
|
readonly keyId: Schema.NonEmptyString;
|
|
32
|
-
readonly
|
|
32
|
+
readonly name: Schema.NonEmptyString;
|
|
33
|
+
readonly enabled: Schema.Boolean;
|
|
34
|
+
readonly permissions: Schema.optional<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
|
|
35
|
+
readonly referrers: Schema.optional<Schema.$Array<Schema.String>>;
|
|
33
36
|
}>;
|
|
34
37
|
export declare const ExtraVerifyApiKeyPayload: Schema.Struct<{
|
|
35
38
|
readonly key: Schema.NonEmptyString;
|
|
36
39
|
readonly configId: Schema.optional<Schema.Union<readonly [Schema.Literal<"user">, Schema.Literal<"organization">, Schema.Literal<"service">]>>;
|
|
37
|
-
readonly permissions: Schema.optional<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
|
|
38
40
|
}>;
|
|
39
41
|
export declare const ExtraApiKeyVerificationError: Schema.Struct<{
|
|
40
42
|
readonly message: Schema.String;
|
|
@@ -176,7 +178,7 @@ export type ExtraSetPasswordPayload = typeof ExtraSetPasswordPayload.Type;
|
|
|
176
178
|
export type ExtraVerifyPasswordPayload = typeof ExtraVerifyPasswordPayload.Type;
|
|
177
179
|
export type ExtraCreateApiKeyPayload = typeof ExtraCreateApiKeyPayload.Type;
|
|
178
180
|
export type ExtraCreateApiKeyResponse = typeof ExtraCreateApiKeyResponse.Type;
|
|
179
|
-
export type
|
|
181
|
+
export type ExtraUpdateApiKeyPayload = typeof ExtraUpdateApiKeyPayload.Type;
|
|
180
182
|
export type ExtraVerifyApiKeyPayload = typeof ExtraVerifyApiKeyPayload.Type;
|
|
181
183
|
export type ExtraVerifyApiKeyResponse = typeof ExtraVerifyApiKeyResponse.Type;
|
|
182
184
|
export type ExtraProjectPublicConfigQuery = typeof ExtraProjectPublicConfigQuery.Type;
|
package/dist/extra/schema.js
CHANGED
|
@@ -70,35 +70,39 @@ export const ExtraCreateApiKeyResponse = Schema.Struct({
|
|
|
70
70
|
description: "Response returned after creating an API key. The secret key is only returned once.",
|
|
71
71
|
examples: [{ id: "api-key-id", key: "user_1234567890" }],
|
|
72
72
|
});
|
|
73
|
-
export const
|
|
73
|
+
export const ExtraUpdateApiKeyPayload = Schema.Struct({
|
|
74
74
|
configId: ExtraApiKeyConfigId,
|
|
75
75
|
keyId: Schema.NonEmptyString,
|
|
76
|
-
|
|
76
|
+
name: Schema.NonEmptyString,
|
|
77
|
+
enabled: Schema.Boolean,
|
|
78
|
+
permissions: Schema.optional(ExtraApiKeyPermissions),
|
|
79
|
+
referrers: Schema.optional(Schema.Array(Schema.String)),
|
|
77
80
|
}).annotate({
|
|
78
|
-
identifier: "
|
|
79
|
-
title: "Extra update API key
|
|
80
|
-
description: "Server-authorized
|
|
81
|
+
identifier: "ExtraUpdateApiKeyPayload",
|
|
82
|
+
title: "Extra update API key payload",
|
|
83
|
+
description: "Server-authorized updates for an existing API key, including its permissions.",
|
|
81
84
|
examples: [
|
|
82
85
|
{
|
|
83
86
|
configId: "organization",
|
|
84
87
|
keyId: "api-key-id",
|
|
88
|
+
name: "Production key",
|
|
89
|
+
enabled: true,
|
|
85
90
|
permissions: { "211-search": ["search:execute"] },
|
|
91
|
+
referrers: ["https://app.example.com"],
|
|
86
92
|
},
|
|
87
93
|
],
|
|
88
94
|
});
|
|
89
95
|
export const ExtraVerifyApiKeyPayload = Schema.Struct({
|
|
90
96
|
key: Schema.NonEmptyString,
|
|
91
97
|
configId: Schema.optional(ExtraApiKeyConfigId),
|
|
92
|
-
permissions: Schema.optional(ExtraApiKeyPermissions),
|
|
93
98
|
}).annotate({
|
|
94
99
|
identifier: "ExtraVerifyApiKeyPayload",
|
|
95
100
|
title: "Extra verify API key payload",
|
|
96
|
-
description: "Payload used
|
|
101
|
+
description: "Payload used to verify a KrakStack API key. Project permissions are enforced by consumer access policies.",
|
|
97
102
|
examples: [
|
|
98
103
|
{
|
|
99
104
|
key: "user_1234567890",
|
|
100
105
|
configId: "user",
|
|
101
|
-
permissions: { projects: ["read"] },
|
|
102
106
|
},
|
|
103
107
|
],
|
|
104
108
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { AuthClientApi, AuthServiceApi } from "./api";
|
|
|
5
5
|
export { AuthService, type AuthServiceLayerOptions } from "./service";
|
|
6
6
|
export { AuthClientConfig } from "./config";
|
|
7
7
|
export { proxyAuthRequest } from "./server/proxy";
|
|
8
|
-
export { OrganizationSwitcher, MemberRequired, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type MemberRequiredMessages, type MemberRequiredProps, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type OrganizationSwitcherFeatures, type OrganizationSwitcherProps, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
8
|
+
export { OrganizationSwitcher, MemberRequired, ProjectAccessMatrix, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type MemberRequiredMessages, type MemberRequiredProps, type ProjectAccessMatrixAccess, type ProjectAccessMatrixMessages, type ProjectAccessLabels, type ProjectAccessLabelCatalog, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type OrganizationSwitcherFeatures, type OrganizationSwitcherProps, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
9
9
|
export * as BetterAuth from "./better-auth/api.group";
|
|
10
10
|
export * as Extra from "./extra/api.group";
|
|
11
11
|
export * as Server from "./server";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { AuthClientApi, AuthServiceApi } from "./api";
|
|
|
5
5
|
export { AuthService } from "./service";
|
|
6
6
|
export { AuthClientConfig } from "./config";
|
|
7
7
|
export { proxyAuthRequest } from "./server/proxy";
|
|
8
|
-
export { OrganizationSwitcher, MemberRequired, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
8
|
+
export { OrganizationSwitcher, MemberRequired, ProjectAccessMatrix, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
9
9
|
export * as BetterAuth from "./better-auth/api.group";
|
|
10
10
|
export * as Extra from "./extra/api.group";
|
|
11
11
|
export * as Server from "./server";
|