@krak-stack/auth 0.3.1 → 0.3.3
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/CHANGELOG.md +12 -0
- package/README.md +37 -0
- package/dist/admin/api.group.d.ts +4 -4
- package/dist/admin/schema.d.ts +6 -6
- package/dist/api.d.ts +1403 -1403
- package/dist/components/account-deletion.js +2 -1
- package/dist/components/admin-organization-form.js +3 -2
- package/dist/components/admin-organizations.js +3 -3
- package/dist/components/admin-users.js +3 -3
- package/dist/components/appearance.d.ts +89 -0
- package/dist/components/appearance.js +59 -0
- package/dist/components/auth-client-api.d.ts +4 -4
- package/dist/components/contact-fields.js +2 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/oauth-consent.d.ts +2 -2
- package/dist/components/oauth-consent.js +63 -1
- package/dist/components/organization-switcher.d.ts +7 -2
- package/dist/components/organization-switcher.js +11 -10
- package/dist/components/scrollable-dialog.d.ts +3 -2
- package/dist/components/scrollable-dialog.js +11 -4
- package/dist/components/user-button.d.ts +8 -2
- package/dist/components/user-button.js +8 -7
- package/package.json +3 -3
|
@@ -8,7 +8,8 @@ import { Button } from "@/components/ui/button";
|
|
|
8
8
|
import { Card, CardContent } from "@/components/ui/card";
|
|
9
9
|
import { Input } from "@/components/ui/input";
|
|
10
10
|
import { FieldLabel } from "@/components/ui/field";
|
|
11
|
-
import { Dialog
|
|
11
|
+
import { Dialog } from "@/components/ui/dialog";
|
|
12
|
+
import { DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, } from "./appearance.js";
|
|
12
13
|
import { authClientApi } from "./auth-client-api.js";
|
|
13
14
|
import { requestAccountDeletion } from "./account-deletion-request.js";
|
|
14
15
|
import { refreshOnAuthChange } from "./auth-atoms.js";
|
|
@@ -4,8 +4,9 @@ import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
|
|
|
4
4
|
import { Effect, Schema } from "effect";
|
|
5
5
|
import { AsyncResult, Atom } from "effect/reactivity";
|
|
6
6
|
import { useState } from "react";
|
|
7
|
-
import { ImageField,
|
|
8
|
-
import { Dialog
|
|
7
|
+
import { ImageField, SubmitButton, SubmitError, TextField, } from "@krak-stack/registry/effect-form";
|
|
8
|
+
import { Dialog } from "@/components/ui/dialog";
|
|
9
|
+
import { DialogContent, DialogDescription, DialogHeader, DialogTitle, SingleSearchableSelectField, } from "./appearance.js";
|
|
9
10
|
import { AdminCreateOrganizationPayload, } from "../admin/schema.js";
|
|
10
11
|
import { authClientApi, authHttpClient } from "./auth-client-api.js";
|
|
11
12
|
import { useKrakstackAuth } from "./auth-provider.js";
|
|
@@ -4,12 +4,12 @@ import { Cause, Effect, Schema } from "effect";
|
|
|
4
4
|
import { Atom, AsyncResult } from "effect/reactivity";
|
|
5
5
|
import { Building2, Pencil, Trash2, UserCog } from "lucide-react";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import {} from "@krak-stack/registry/data-table";
|
|
8
8
|
import { Query } from "@krak-stack/registry/query";
|
|
9
9
|
import { ErrorMessage } from "@krak-stack/registry/effect-form";
|
|
10
|
-
import { AppBrand } from "
|
|
10
|
+
import { AppBrand, DataTable, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "./appearance.js";
|
|
11
11
|
import { Badge } from "@/components/ui/badge";
|
|
12
|
-
import { AlertDialog, AlertDialogAction, AlertDialogCancel,
|
|
12
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, } from "@/components/ui/alert-dialog";
|
|
13
13
|
import { AdminListQuery } from "../admin/schema.js";
|
|
14
14
|
import { normalizeOrganizationRoles } from "../roles.js";
|
|
15
15
|
import { AdminOrganizationForm } from "./admin-organization-form.js";
|
|
@@ -4,12 +4,12 @@ import { Atom, AsyncResult } from "effect/reactivity";
|
|
|
4
4
|
import { Effect, Schema } from "effect";
|
|
5
5
|
import { Ban, Loader2, ShieldOff, UserCog, UserIcon } from "lucide-react";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import {} from "@krak-stack/registry/data-table";
|
|
8
8
|
import { Query } from "@krak-stack/registry/query";
|
|
9
9
|
import { ErrorMessage } from "@krak-stack/registry/effect-form";
|
|
10
|
-
import { AppBrand } from "
|
|
10
|
+
import { AppBrand, DataTable, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "./appearance.js";
|
|
11
11
|
import { Badge } from "@/components/ui/badge";
|
|
12
|
-
import { AlertDialog, AlertDialogAction, AlertDialogCancel,
|
|
12
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, } from "@/components/ui/alert-dialog";
|
|
13
13
|
import { AdminListQuery } from "../admin/schema.js";
|
|
14
14
|
import { reloadAfterImpersonation } from "./auth-atoms.js";
|
|
15
15
|
import { authClientApi, authHttpClient } from "./auth-client-api.js";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type ComponentProps } from "react";
|
|
2
|
+
import { AppBrand as RegistryAppBrand } from "@krak-stack/registry/app-brand";
|
|
3
|
+
import { type DataTableProps } from "@krak-stack/registry/data-table";
|
|
4
|
+
import { SelectField as RegistrySelectField, SingleSearchableSelectField as RegistrySingleSearchableSelectField } from "@krak-stack/registry/effect-form";
|
|
5
|
+
type Slots<Key extends string> = Partial<Record<Key, string>>;
|
|
6
|
+
/** Optional presentation hooks. No auth, data or interaction policy lives here. */
|
|
7
|
+
export type AuthUIClassNames = {
|
|
8
|
+
trigger?: Slots<"visual" | "image" | "icon" | "content" | "label" | "subtitle" | "indicator" | "badge">;
|
|
9
|
+
menu?: Slots<"content" | "header" | "group" | "item" | "label" | "separator" | "subContent" | "subTrigger">;
|
|
10
|
+
dialog?: Slots<"content" | "header" | "title" | "description" | "body" | "footer">;
|
|
11
|
+
popup?: Slots<"select" | "combobox">;
|
|
12
|
+
/** Scope forms through existing field/input/button data-slot attributes. */
|
|
13
|
+
form?: Slots<"content">;
|
|
14
|
+
table?: {
|
|
15
|
+
className?: string;
|
|
16
|
+
classNames?: {
|
|
17
|
+
table?: Slots<"content" | "header" | "body" | "row" | "head" | "cell">;
|
|
18
|
+
toolbar?: Slots<"content" | "search" | "trigger">;
|
|
19
|
+
menu?: Slots<"content" | "subContent" | "label" | "item" | "separator" | "subTrigger">;
|
|
20
|
+
popup?: Slots<"select" | "tooltip">;
|
|
21
|
+
pagination?: string;
|
|
22
|
+
gallery?: string;
|
|
23
|
+
feedback?: Slots<"loading" | "empty" | "error">;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const AuthUIStylesContext: import("react").Context<AuthUIClassNames | undefined>;
|
|
28
|
+
export declare const useAuthUIStyles: () => AuthUIClassNames | undefined;
|
|
29
|
+
export declare const DropdownMenuContent: (props: object & {
|
|
30
|
+
className?: string;
|
|
31
|
+
}) => import("react").JSX.Element;
|
|
32
|
+
export declare const DropdownMenuGroup: (props: object & {
|
|
33
|
+
className?: string;
|
|
34
|
+
}) => import("react").JSX.Element;
|
|
35
|
+
export declare const DropdownMenuLabel: (props: object & {
|
|
36
|
+
className?: string;
|
|
37
|
+
}) => import("react").JSX.Element;
|
|
38
|
+
export declare const DropdownMenuItem: (props: object & {
|
|
39
|
+
className?: string;
|
|
40
|
+
}) => import("react").JSX.Element;
|
|
41
|
+
export declare const DropdownMenuSeparator: (props: object & {
|
|
42
|
+
className?: string;
|
|
43
|
+
}) => import("react").JSX.Element;
|
|
44
|
+
export declare const DropdownMenuSubContent: (props: object & {
|
|
45
|
+
className?: string;
|
|
46
|
+
}) => import("react").JSX.Element;
|
|
47
|
+
export declare const DropdownMenuSubTrigger: (props: object & {
|
|
48
|
+
className?: string;
|
|
49
|
+
}) => import("react").JSX.Element;
|
|
50
|
+
export declare const DialogContent: (props: object & {
|
|
51
|
+
className?: string;
|
|
52
|
+
}) => import("react").JSX.Element;
|
|
53
|
+
export declare const DialogHeader: (props: object & {
|
|
54
|
+
className?: string;
|
|
55
|
+
}) => import("react").JSX.Element;
|
|
56
|
+
export declare const DialogTitle: (props: any & {
|
|
57
|
+
className?: string;
|
|
58
|
+
}) => import("react").JSX.Element;
|
|
59
|
+
export declare const DialogDescription: (props: object & {
|
|
60
|
+
className?: string;
|
|
61
|
+
}) => import("react").JSX.Element;
|
|
62
|
+
export declare const DialogFooter: (props: object & {
|
|
63
|
+
className?: string;
|
|
64
|
+
}) => import("react").JSX.Element;
|
|
65
|
+
export declare const AlertDialogContent: (props: object & {
|
|
66
|
+
className?: string;
|
|
67
|
+
}) => import("react").JSX.Element;
|
|
68
|
+
export declare const AlertDialogHeader: (props: object & {
|
|
69
|
+
className?: string;
|
|
70
|
+
}) => import("react").JSX.Element;
|
|
71
|
+
export declare const AlertDialogTitle: (props: object & {
|
|
72
|
+
className?: string;
|
|
73
|
+
}) => import("react").JSX.Element;
|
|
74
|
+
export declare const AlertDialogDescription: (props: object & {
|
|
75
|
+
className?: string;
|
|
76
|
+
}) => import("react").JSX.Element;
|
|
77
|
+
export declare const AlertDialogFooter: (props: object & {
|
|
78
|
+
className?: string;
|
|
79
|
+
}) => import("react").JSX.Element;
|
|
80
|
+
export declare const SelectContent: (props: object & {
|
|
81
|
+
className?: string;
|
|
82
|
+
}) => import("react").JSX.Element;
|
|
83
|
+
export declare const AppBrand: ({ appearance, ...props }: ComponentProps<typeof RegistryAppBrand> & {
|
|
84
|
+
appearance?: "default" | "menuHeader" | "trigger";
|
|
85
|
+
}) => import("react").JSX.Element;
|
|
86
|
+
export declare const DataTable: <Row extends object>(props: DataTableProps<Row>) => import("react").JSX.Element;
|
|
87
|
+
export declare const SelectField: <Value extends string>({ field, props, }: ComponentProps<typeof RegistrySelectField<Value>>) => import("react").JSX.Element;
|
|
88
|
+
export declare const SingleSearchableSelectField: <Value>({ field, props, }: ComponentProps<typeof RegistrySingleSearchableSelectField<Value>>) => import("react").JSX.Element;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, } from "react";
|
|
3
|
+
import * as Menu from "@/components/ui/dropdown-menu";
|
|
4
|
+
import * as Dialog from "@/components/ui/dialog";
|
|
5
|
+
import * as Alert from "@/components/ui/alert-dialog";
|
|
6
|
+
import * as Select from "@/components/ui/select";
|
|
7
|
+
import { AppBrand as RegistryAppBrand } from "@krak-stack/registry/app-brand";
|
|
8
|
+
import { DataTable as RegistryDataTable, } from "@krak-stack/registry/data-table";
|
|
9
|
+
import { SelectField as RegistrySelectField, SingleSearchableSelectField as RegistrySingleSearchableSelectField, } from "@krak-stack/registry/effect-form";
|
|
10
|
+
import { cn } from "./utils.js";
|
|
11
|
+
export const AuthUIStylesContext = createContext(undefined);
|
|
12
|
+
export const useAuthUIStyles = () => useContext(AuthUIStylesContext);
|
|
13
|
+
const styled = (Part, slot, style) => {
|
|
14
|
+
const StyledPart = (props) => {
|
|
15
|
+
const styles = useAuthUIStyles();
|
|
16
|
+
const className = cn(props.className, style(styles));
|
|
17
|
+
return _jsx(Part, { "data-auth-slot": slot, ...props, className: className });
|
|
18
|
+
};
|
|
19
|
+
return StyledPart;
|
|
20
|
+
};
|
|
21
|
+
export const DropdownMenuContent = styled(Menu.DropdownMenuContent, "menu", (s) => s?.menu?.content);
|
|
22
|
+
export const DropdownMenuGroup = styled(Menu.DropdownMenuGroup, "menu-group", (s) => s?.menu?.group);
|
|
23
|
+
export const DropdownMenuLabel = styled(Menu.DropdownMenuLabel, "menu-label", (s) => s?.menu?.label);
|
|
24
|
+
export const DropdownMenuItem = styled(Menu.DropdownMenuItem, "menu-item", (s) => s?.menu?.item);
|
|
25
|
+
export const DropdownMenuSeparator = styled(Menu.DropdownMenuSeparator, "menu-separator", (s) => s?.menu?.separator);
|
|
26
|
+
export const DropdownMenuSubContent = styled(Menu.DropdownMenuSubContent, "submenu", (s) => s?.menu?.subContent);
|
|
27
|
+
export const DropdownMenuSubTrigger = styled(Menu.DropdownMenuSubTrigger, "submenu-trigger", (s) => s?.menu?.subTrigger);
|
|
28
|
+
export const DialogContent = styled(Dialog.DialogContent, "dialog", (s) => s?.dialog?.content);
|
|
29
|
+
export const DialogHeader = styled(Dialog.DialogHeader, "dialog-header", (s) => s?.dialog?.header);
|
|
30
|
+
export const DialogTitle = styled(Dialog.DialogTitle, "dialog-title", (s) => s?.dialog?.title);
|
|
31
|
+
export const DialogDescription = styled(Dialog.DialogDescription, "dialog-description", (s) => s?.dialog?.description);
|
|
32
|
+
export const DialogFooter = styled(Dialog.DialogFooter, "dialog-footer", (s) => s?.dialog?.footer);
|
|
33
|
+
export const AlertDialogContent = styled(Alert.AlertDialogContent, "alert-dialog", (s) => s?.dialog?.content);
|
|
34
|
+
export const AlertDialogHeader = styled(Alert.AlertDialogHeader, "alert-dialog-header", (s) => s?.dialog?.header);
|
|
35
|
+
export const AlertDialogTitle = styled(Alert.AlertDialogTitle, "alert-dialog-title", (s) => s?.dialog?.title);
|
|
36
|
+
export const AlertDialogDescription = styled(Alert.AlertDialogDescription, "alert-dialog-description", (s) => s?.dialog?.description);
|
|
37
|
+
export const AlertDialogFooter = styled(Alert.AlertDialogFooter, "alert-dialog-footer", (s) => s?.dialog?.footer);
|
|
38
|
+
export const SelectContent = styled(Select.SelectContent, "select-popup", (s) => s?.popup?.select);
|
|
39
|
+
export const AppBrand = ({ appearance = "default", ...props }) => {
|
|
40
|
+
const styles = useAuthUIStyles();
|
|
41
|
+
const appearanceProps = appearance === "trigger" && styles?.trigger
|
|
42
|
+
? { classNames: styles.trigger }
|
|
43
|
+
: {};
|
|
44
|
+
return (_jsx(RegistryAppBrand, { ...props, ...appearanceProps, className: cn(props.className, appearance === "menuHeader" && styles?.menu?.header) }));
|
|
45
|
+
};
|
|
46
|
+
export const DataTable = (props) => {
|
|
47
|
+
const styles = useAuthUIStyles();
|
|
48
|
+
return _jsx(RegistryDataTable, { ...styles?.table, ...props });
|
|
49
|
+
};
|
|
50
|
+
export const SelectField = ({ field, props, }) => {
|
|
51
|
+
const styles = useAuthUIStyles();
|
|
52
|
+
const appearance = { contentClassName: styles?.popup?.select };
|
|
53
|
+
return (_jsx(RegistrySelectField, { field: field, props: { ...props, ...appearance } }));
|
|
54
|
+
};
|
|
55
|
+
export const SingleSearchableSelectField = ({ field, props, }) => {
|
|
56
|
+
const styles = useAuthUIStyles();
|
|
57
|
+
const appearance = { contentClassName: styles?.popup?.combobox };
|
|
58
|
+
return (_jsx(RegistrySingleSearchableSelectField, { field: field, props: { ...props, ...appearance } }));
|
|
59
|
+
};
|
|
@@ -232,8 +232,8 @@ export declare const authHttpClient: (baseUrl?: string, getLocale?: () => "en" |
|
|
|
232
232
|
readonly updatedAt: import("effect/Schema").Date;
|
|
233
233
|
}>>>, import("effect/Schema").toCodecJson<typeof import("effect/http-api/HttpApiError").Unauthorized | typeof import("effect/http-api/HttpApiError").Forbidden | typeof import("effect/http-api/HttpApiError").InternalServerError>, never, never>, never, never>;
|
|
234
234
|
readonly listOrganizations: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"listOrganizations", "GET", "/api/auth/admin/organizations", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
235
|
-
readonly page: import("effect/Schema").decodeTo<import("effect/Schema").Int, import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").
|
|
236
|
-
readonly pageSize: import("effect/Schema").decodeTo<import("effect/Schema").Int, import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").
|
|
235
|
+
readonly page: import("effect/Schema").decodeTo<import("effect/Schema").Int, import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Finite, import("effect/Schema").FiniteFromString]>>, never, never>;
|
|
236
|
+
readonly pageSize: import("effect/Schema").decodeTo<import("effect/Schema").Int, import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Finite, import("effect/Schema").FiniteFromString]>>, never, never>;
|
|
237
237
|
readonly globalFilter: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
238
238
|
readonly sort: import("effect/Schema").optional<import("effect/Schema").declare<readonly {
|
|
239
239
|
readonly id: string;
|
|
@@ -321,8 +321,8 @@ export declare const authHttpClient: (baseUrl?: string, getLocale?: () => "en" |
|
|
|
321
321
|
}>;
|
|
322
322
|
}>>, import("effect/Schema").toCodecJson<typeof import("effect/http-api/HttpApiError").Unauthorized | typeof import("effect/http-api/HttpApiError").Forbidden | typeof import("effect/http-api/HttpApiError").InternalServerError>, never, never>, never, never>;
|
|
323
323
|
readonly listUsers: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"listUsers", "GET", "/api/auth/admin/users", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
324
|
-
readonly page: import("effect/Schema").decodeTo<import("effect/Schema").Int, import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").
|
|
325
|
-
readonly pageSize: import("effect/Schema").decodeTo<import("effect/Schema").Int, import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").
|
|
324
|
+
readonly page: import("effect/Schema").decodeTo<import("effect/Schema").Int, import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Finite, import("effect/Schema").FiniteFromString]>>, never, never>;
|
|
325
|
+
readonly pageSize: import("effect/Schema").decodeTo<import("effect/Schema").Int, import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Finite, import("effect/Schema").FiniteFromString]>>, never, never>;
|
|
326
326
|
readonly globalFilter: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
327
327
|
readonly sort: import("effect/Schema").optional<import("effect/Schema").declare<readonly {
|
|
328
328
|
readonly id: string;
|
|
@@ -7,7 +7,8 @@ import { ErrorMessage } from "@krak-stack/registry/effect-form";
|
|
|
7
7
|
import { Button } from "@/components/ui/button";
|
|
8
8
|
import { Field, FieldLabel } from "@/components/ui/field";
|
|
9
9
|
import { Input } from "@/components/ui/input";
|
|
10
|
-
import { Select,
|
|
10
|
+
import { Select, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select";
|
|
11
|
+
import { SelectContent } from "./appearance.js";
|
|
11
12
|
const socialPlatform = (value) => {
|
|
12
13
|
switch (value) {
|
|
13
14
|
case "facebook":
|
|
@@ -21,4 +21,5 @@ export type { AdminOrganizationsMessages } from "./admin-organizations.js";
|
|
|
21
21
|
export type { KrakstackAuthContextValue, KrakstackAuthLocale, KrakstackAuthProviderProps, KrakstackAuthRequiredProps, KrakstackAuthStatus, } from "./auth-provider.js";
|
|
22
22
|
export type { OrganizationSwitcherDialog, OrganizationSwitcherFeatures, OrganizationSwitcherProps, } from "./organization-switcher.js";
|
|
23
23
|
export type { UserButtonDialog, UserButtonProps } from "./user-button.js";
|
|
24
|
+
export type { AuthUIClassNames } from "./appearance.js";
|
|
24
25
|
export type { MemberRequiredMessages, MemberRequiredProps, } from "./member-required.js";
|
|
@@ -16,7 +16,7 @@ export type OAuthConsentMessages = {
|
|
|
16
16
|
};
|
|
17
17
|
/** Shared login-provider-aware consent. The signed OAuth query is sent intact;
|
|
18
18
|
* the provider, not the component, validates scopes, grants and callbacks. */
|
|
19
|
-
export declare const OAuthConsent: ({ messages, baseUrl: providedBaseUrl, }: {
|
|
20
|
-
readonly messages
|
|
19
|
+
export declare const OAuthConsent: ({ messages: overrides, baseUrl: providedBaseUrl, }: {
|
|
20
|
+
readonly messages?: Partial<OAuthConsentMessages>;
|
|
21
21
|
readonly baseUrl?: string;
|
|
22
22
|
}) => import("react").JSX.Element;
|
|
@@ -15,6 +15,62 @@ const ConsentSearch = Schema.Struct({
|
|
|
15
15
|
sig: Schema.NonEmptyString,
|
|
16
16
|
scope: Schema.optional(Schema.String),
|
|
17
17
|
}).annotate({ identifier: "OAuthConsentSearch" });
|
|
18
|
+
const defaultMessages = {
|
|
19
|
+
en: {
|
|
20
|
+
title: "Authorize application",
|
|
21
|
+
description: ({ clientName }) => `${clientName} is requesting access to your account.`,
|
|
22
|
+
requestedScopes: "Requested scopes",
|
|
23
|
+
allow: "Authorize",
|
|
24
|
+
deny: "Deny",
|
|
25
|
+
error: "Unable to save your decision. Please try again.",
|
|
26
|
+
invalidRequest: "This authorization request is invalid or incomplete. Start again from your application.",
|
|
27
|
+
notice: "Only connect applications you trust. You can revoke access later.",
|
|
28
|
+
permissions: {
|
|
29
|
+
"mcp:read": {
|
|
30
|
+
title: "Read application data",
|
|
31
|
+
description: "View information your account can access in your organization.",
|
|
32
|
+
},
|
|
33
|
+
"mcp:write": {
|
|
34
|
+
title: "Make changes on your behalf",
|
|
35
|
+
description: "Only actions your account is allowed to perform.",
|
|
36
|
+
},
|
|
37
|
+
offline_access: {
|
|
38
|
+
title: "Stay connected",
|
|
39
|
+
description: "Continue access without asking you to sign in each time, until access is revoked.",
|
|
40
|
+
},
|
|
41
|
+
openid: { title: "Verify your identity" },
|
|
42
|
+
profile: { title: "View your name and profile picture" },
|
|
43
|
+
email: { title: "View your email address" },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
fr: {
|
|
47
|
+
title: "Autoriser l'application",
|
|
48
|
+
description: ({ clientName }) => `${clientName} demande l'accès à votre compte.`,
|
|
49
|
+
requestedScopes: "Portées demandées",
|
|
50
|
+
allow: "Autoriser",
|
|
51
|
+
deny: "Refuser",
|
|
52
|
+
error: "Impossible d'enregistrer votre décision. Veuillez réessayer.",
|
|
53
|
+
invalidRequest: "Cette demande d'autorisation est invalide ou incomplète. Recommencez depuis votre application.",
|
|
54
|
+
notice: "Connectez uniquement des applications de confiance. Vous pourrez révoquer l'accès plus tard.",
|
|
55
|
+
permissions: {
|
|
56
|
+
"mcp:read": {
|
|
57
|
+
title: "Lire les données de l'application",
|
|
58
|
+
description: "Consulter les informations accessibles à votre compte dans votre organisation.",
|
|
59
|
+
},
|
|
60
|
+
"mcp:write": {
|
|
61
|
+
title: "Effectuer des modifications en votre nom",
|
|
62
|
+
description: "Uniquement les actions autorisées pour votre compte.",
|
|
63
|
+
},
|
|
64
|
+
offline_access: {
|
|
65
|
+
title: "Rester connecté",
|
|
66
|
+
description: "Continuer l'accès sans vous demander de vous reconnecter à chaque fois, jusqu'à sa révocation.",
|
|
67
|
+
},
|
|
68
|
+
openid: { title: "Vérifier votre identité" },
|
|
69
|
+
profile: { title: "Consulter votre nom et votre photo de profil" },
|
|
70
|
+
email: { title: "Consulter votre adresse courriel" },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
18
74
|
const scopeIcon = (scope) => {
|
|
19
75
|
switch (scope) {
|
|
20
76
|
case "mcp:read":
|
|
@@ -45,8 +101,14 @@ const makeConsentAtom = (baseUrl, search) => {
|
|
|
45
101
|
};
|
|
46
102
|
/** Shared login-provider-aware consent. The signed OAuth query is sent intact;
|
|
47
103
|
* the provider, not the component, validates scopes, grants and callbacks. */
|
|
48
|
-
export const OAuthConsent = ({ messages, baseUrl: providedBaseUrl, }) => {
|
|
104
|
+
export const OAuthConsent = ({ messages: overrides, baseUrl: providedBaseUrl, }) => {
|
|
49
105
|
const auth = useKrakstackAuth();
|
|
106
|
+
const defaults = defaultMessages[auth?.locale ?? "en"];
|
|
107
|
+
const messages = {
|
|
108
|
+
...defaults,
|
|
109
|
+
...overrides,
|
|
110
|
+
permissions: { ...defaults.permissions, ...overrides?.permissions },
|
|
111
|
+
};
|
|
50
112
|
const baseUrl = providedBaseUrl ?? auth?.baseUrl;
|
|
51
113
|
const search = useRouterState({
|
|
52
114
|
select: (state) => state.location.searchStr,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Button } from "@/components/ui/button";
|
|
3
|
+
import { DropdownMenuContent, type AuthUIClassNames } from "./appearance.js";
|
|
3
4
|
declare const messages: {
|
|
4
5
|
readonly en: {
|
|
5
6
|
readonly organization_back: "Back";
|
|
@@ -292,6 +293,10 @@ export type OrganizationSwitcherFeatures = {
|
|
|
292
293
|
userInvitations?: boolean;
|
|
293
294
|
};
|
|
294
295
|
export type OrganizationSwitcherProps = {
|
|
296
|
+
classNames?: AuthUIClassNames;
|
|
297
|
+
variant?: ComponentProps<typeof Button>["variant"];
|
|
298
|
+
size?: ComponentProps<typeof Button>["size"];
|
|
299
|
+
triggerBadge?: ReactNode;
|
|
295
300
|
baseUrl?: string | undefined;
|
|
296
301
|
side?: ComponentProps<typeof DropdownMenuContent>["side"];
|
|
297
302
|
className?: string;
|
|
@@ -317,5 +322,5 @@ type OrganizationSummary = {
|
|
|
317
322
|
parentId?: string | null | undefined;
|
|
318
323
|
};
|
|
319
324
|
export type OrganizationSwitcherDialog = "create" | "manage" | "members" | "apiKeys" | "invitations";
|
|
320
|
-
export declare
|
|
325
|
+
export declare const OrganizationSwitcher: (props: OrganizationSwitcherProps) => import("react").JSX.Element;
|
|
321
326
|
export {};
|
|
@@ -6,17 +6,16 @@ import { Effect, Option, Predicate, Schema } from "effect";
|
|
|
6
6
|
import { AsyncResult, Atom } from "effect/reactivity";
|
|
7
7
|
import { ArrowLeft, Building2, Check, ChevronsUpDown, Copy, KeyRound, LogOut, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
8
8
|
import { createContext, useContext, useEffect, useRef, useState, } from "react";
|
|
9
|
-
import {
|
|
10
|
-
import { CheckboxField, ImageField,
|
|
9
|
+
import { DataTableListCell, } from "@krak-stack/registry/data-table";
|
|
10
|
+
import { CheckboxField, ImageField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@krak-stack/registry/effect-form";
|
|
11
11
|
import { EditingLocaleSwitcher } from "@krak-stack/registry/editing-locale-switcher";
|
|
12
|
-
import { AppBrand } from "@krak-stack/registry/app-brand";
|
|
13
12
|
import { FieldSet } from "@/components/ui/field";
|
|
14
13
|
import { Badge } from "@/components/ui/badge";
|
|
15
14
|
import { Button } from "@/components/ui/button";
|
|
16
|
-
import { AlertDialog
|
|
15
|
+
import { AlertDialog } from "@/components/ui/alert-dialog";
|
|
17
16
|
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
18
|
-
import { Dialog
|
|
19
|
-
import { DropdownMenu,
|
|
17
|
+
import { Dialog } from "@/components/ui/dialog";
|
|
18
|
+
import { DropdownMenu, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
20
19
|
import { Separator } from "@/components/ui/separator";
|
|
21
20
|
import { OrganizationEmail, OrganizationAddress, OrganizationMetadata, OrganizationPhone, OrganizationSocial, OrganizationTranslation, OrganizationWebsite, decodeOrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
22
21
|
import { isOrganizationRole, normalizeOrganizationRole, normalizeOrganizationRoles, organizationRoles, parseRoleList, } from "../roles.js";
|
|
@@ -36,6 +35,7 @@ import { ScrollableDialogBody, ScrollableDialogContent, ScrollableDialogHeader,
|
|
|
36
35
|
import { invitationDisplayStatus, isInvitationExpired, useInvitationExpirationClock, } from "./invitation-expiration.js";
|
|
37
36
|
import { ExtraUploadedAsset } from "../extra/schema.js";
|
|
38
37
|
import { assetPath, assetUrl, cn } from "./utils.js";
|
|
38
|
+
import { AuthUIStylesContext, AppBrand, DataTable, DialogFooter, DialogDescription, DialogHeader, DialogTitle, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, SelectField, } from "./appearance.js";
|
|
39
39
|
import { AssociatedProjectsNotice } from "./associated-projects-notice.js";
|
|
40
40
|
import { ExtraApiKeyPermissions } from "../extra/schema.js";
|
|
41
41
|
class OrganizationActionError extends Data.TaggedError("OrganizationActionError") {
|
|
@@ -723,7 +723,8 @@ const organizationMetadataFromForm = Effect.fn(function* (value, m, uploadImage,
|
|
|
723
723
|
addresses,
|
|
724
724
|
};
|
|
725
725
|
});
|
|
726
|
-
export
|
|
726
|
+
export const OrganizationSwitcher = (props) => (_jsx(AuthUIStylesContext.Provider, { value: props.classNames, children: _jsx(OrganizationSwitcherContent, { ...props }) }));
|
|
727
|
+
const OrganizationSwitcherContent = ({ classNames, variant = "ghost", size, triggerBadge, baseUrl: providedBaseUrl, side = "bottom", className, defaultDialog = null, features, hideTrigger = false, menuActions, renderUnauthenticated, allowedOrganizationIds, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, apiKeyPermissions, }) => {
|
|
727
728
|
const auth = useKrakstackAuth();
|
|
728
729
|
const baseUrl = providedBaseUrl ?? auth?.baseUrl;
|
|
729
730
|
const labels = organizationSwitcherMessages(messages);
|
|
@@ -821,13 +822,13 @@ export function OrganizationSwitcher({ baseUrl: providedBaseUrl, side = "bottom"
|
|
|
821
822
|
};
|
|
822
823
|
const activeDisplay = organizationDisplay(active ?? null, m, baseUrl);
|
|
823
824
|
const activeSubtitle = organizationSwitcherSubtitle(active ?? null, activeDisplay.subtitle, m);
|
|
824
|
-
return (_jsxs(OrganizationMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "
|
|
825
|
+
return (_jsxs(OrganizationMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: variant, size: size, "data-auth-slot": "organization-trigger", className: cn("w-full justify-between gap-2 group-data-[collapsible=icon]:size-8 group-data-[collapsible=icon]:justify-start group-data-[collapsible=icon]:!p-0", size === undefined && "h-11 !px-1 !py-0", triggerBadge != null && "relative", className), children: [triggerBadge != null ? (_jsx("span", { "data-auth-slot": "trigger-badge", className: cn("pointer-events-none absolute -top-1 -right-1 z-10", classNames?.trigger?.badge), children: triggerBadge })) : null, _jsx(AppBrand, { appearance: "trigger", to: null, label: activeName
|
|
825
826
|
? activeDisplay.name
|
|
826
827
|
: activeLoading
|
|
827
828
|
? m.organization_loading()
|
|
828
829
|
: m.organization_switcher_label(), subtitle: activeSubtitle, icon: Building2, variant: "sidebar", className: "min-w-0 flex-1 !p-0 text-left group-data-[collapsible=icon]:flex-none group-data-[collapsible=icon]:justify-start", ...(activeDisplay.image
|
|
829
830
|
? { imageSrc: activeDisplay.image }
|
|
830
|
-
: {}) }), _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
|
|
831
|
+
: {}) }), _jsx(ChevronsUpDown, { "data-auth-slot": "trigger-indicator", className: cn("text-muted-foreground size-4 shrink-0 group-data-[collapsible=icon]:hidden", classNames?.trigger?.indicator) })] }) }), _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, { appearance: "menuHeader", to: null, label: activeDisplay.name, subtitle: activeSubtitle, icon: Building2, variant: "sidebar", className: "px-1 py-1.5 text-left text-sm", ...(activeDisplay.image
|
|
831
832
|
? { imageSrc: activeDisplay.image }
|
|
832
833
|
: {}) }) }), active ? (_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 &&
|
|
833
834
|
"max-h-64 overflow-y-auto overscroll-contain"), children: selectableOrganizations.map((organization) => {
|
|
@@ -897,7 +898,7 @@ export function OrganizationSwitcher({ baseUrl: providedBaseUrl, side = "bottom"
|
|
|
897
898
|
}, 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
|
|
898
899
|
? { activeOrganizationId: activeOrganization.id }
|
|
899
900
|
: {}), onActionComplete: refreshAfterInvitationAction }) })] }) })] }));
|
|
900
|
-
}
|
|
901
|
+
};
|
|
901
902
|
const OrganizationDeletionDialog = ({ baseUrl, organization, onClose, onDeleted, }) => {
|
|
902
903
|
const auth = useKrakstackAuth();
|
|
903
904
|
const labels = adminOrganizationsMessages(auth?.locale ?? "en");
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
-
import { DialogContent } from "
|
|
2
|
+
import { DialogContent } from "./appearance.js";
|
|
3
3
|
type ScrollableDialogSize = "2xl" | "3xl" | "4xl" | "6xl";
|
|
4
|
-
export declare const ScrollableDialogContent: ({ children, size, ...props }: Omit<ComponentProps<typeof DialogContent>, "className"> & {
|
|
4
|
+
export declare const ScrollableDialogContent: ({ children, size, className, ...props }: Omit<ComponentProps<typeof DialogContent>, "className"> & {
|
|
5
|
+
readonly className?: string;
|
|
5
6
|
readonly children: ReactNode;
|
|
6
7
|
readonly size: ScrollableDialogSize;
|
|
7
8
|
}) => import("react").JSX.Element;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DialogContent } from "
|
|
2
|
+
import { DialogContent, useAuthUIStyles } from "./appearance.js";
|
|
3
3
|
import { Separator } from "@/components/ui/separator";
|
|
4
|
+
import { cn } from "./utils.js";
|
|
4
5
|
const widthClass = {
|
|
5
6
|
"2xl": "sm:max-w-2xl",
|
|
6
7
|
"3xl": "sm:max-w-3xl",
|
|
7
8
|
"4xl": "sm:max-w-4xl",
|
|
8
9
|
"6xl": "sm:max-w-6xl",
|
|
9
10
|
};
|
|
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 }) =>
|
|
12
|
-
|
|
11
|
+
export const ScrollableDialogContent = ({ children, size, className, ...props }) => (_jsx(DialogContent, { className: cn(`grid max-h-[85vh] min-w-0 grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden ${widthClass[size]}`, className), ...props, children: children }));
|
|
12
|
+
export const ScrollableDialogHeader = ({ children, className = "", ...props }) => {
|
|
13
|
+
const styles = useAuthUIStyles();
|
|
14
|
+
return (_jsxs("div", { "data-auth-slot": "dialog-header", className: cn("flex flex-col gap-6 pb-6", styles?.dialog?.header, className), ...props, children: [children, _jsx(Separator, {})] }));
|
|
15
|
+
};
|
|
16
|
+
export const ScrollableDialogBody = ({ children, className = "", padding = "default", ...props }) => {
|
|
17
|
+
const styles = useAuthUIStyles();
|
|
18
|
+
return (_jsx("div", { "data-auth-slot": "dialog-body", className: cn("-mx-6 min-h-0 overflow-y-auto", styles?.dialog?.body), ...props, children: _jsx("div", { "data-auth-slot": "form-scope", className: cn(`min-w-0 px-6 pt-1 ${padding === "form" ? "pb-6" : "pb-2"}`, styles?.form?.content, className), children: children }) }));
|
|
19
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { type ComponentProps, type ReactNode } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { Button } from "@/components/ui/button";
|
|
4
|
+
import { DropdownMenuContent, type AuthUIClassNames } from "./appearance.js";
|
|
4
5
|
import { type ContactEmail as ContactEmailValue, type ContactPhone as ContactPhoneValue, type ContactSocial as ContactSocialValue, type ContactWebsite as ContactWebsiteValue, UserMetadata } from "../schema.js";
|
|
5
6
|
declare const messages: {
|
|
6
7
|
readonly en: {
|
|
@@ -366,6 +367,11 @@ export declare const UserContactSocialsForm: Schema.$Array<Schema.Struct<{
|
|
|
366
367
|
}>>;
|
|
367
368
|
export declare const userMetadataFromForm: (value: UserFormType) => UserMetadata;
|
|
368
369
|
export type UserButtonProps = {
|
|
370
|
+
className?: string;
|
|
371
|
+
classNames?: AuthUIClassNames;
|
|
372
|
+
variant?: ComponentProps<typeof Button>["variant"];
|
|
373
|
+
size?: ComponentProps<typeof Button>["size"];
|
|
374
|
+
triggerBadge?: ReactNode;
|
|
369
375
|
baseUrl?: string | undefined;
|
|
370
376
|
signOutRedirect?: string;
|
|
371
377
|
side?: ComponentProps<typeof DropdownMenuContent>["side"];
|
|
@@ -379,5 +385,5 @@ export type UserButtonProps = {
|
|
|
379
385
|
onDialogChange?: (dialog: UserButtonDialog | null) => void;
|
|
380
386
|
};
|
|
381
387
|
export type UserButtonDialog = "deleteAccount" | "account" | "security" | "apiKeys" | "adminUsers" | "adminOrganizations";
|
|
382
|
-
export declare const UserButton: (
|
|
388
|
+
export declare const UserButton: (props: UserButtonProps) => import("react").JSX.Element;
|
|
383
389
|
export {};
|
|
@@ -8,15 +8,14 @@ import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
|
|
|
8
8
|
import { ArrowLeft, Building2, KeyRound, Loader2, LogOutIcon, Mail, Pencil, Plus, ShieldCheck, StopCircle, Trash2, UserCircleIcon, Users, UserIcon, } from "lucide-react";
|
|
9
9
|
import { QRCode } from "react-qr-code";
|
|
10
10
|
import { createContext, useContext, useRef, useEffect, useState, } from "react";
|
|
11
|
-
import {
|
|
12
|
-
import { AppBrand } from "@krak-stack/registry/app-brand";
|
|
11
|
+
import {} from "@krak-stack/registry/data-table";
|
|
13
12
|
import { EditingLocaleSwitcher } from "@krak-stack/registry/editing-locale-switcher";
|
|
14
13
|
import { effectFormMessages, ImageField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@krak-stack/registry/effect-form";
|
|
15
14
|
import { Badge } from "@/components/ui/badge";
|
|
16
15
|
import { Button } from "@/components/ui/button";
|
|
17
16
|
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
18
|
-
import { Dialog
|
|
19
|
-
import { DropdownMenu,
|
|
17
|
+
import { Dialog } from "@/components/ui/dialog";
|
|
18
|
+
import { DropdownMenu, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
20
19
|
import { Separator } from "@/components/ui/separator";
|
|
21
20
|
import { FieldLabel } from "@/components/ui/field";
|
|
22
21
|
import { Input } from "@/components/ui/input";
|
|
@@ -32,7 +31,8 @@ import { ApiKeyRateLimit, apiKeyUsagePercent } from "./api-key-rate-limit.js";
|
|
|
32
31
|
import { ApiKeyReferrers } from "./api-key-referrers.js";
|
|
33
32
|
import { useLatestAtom, useOpenedOnce } from "./hooks.js";
|
|
34
33
|
import { ExtraUploadedAsset } from "../extra/schema.js";
|
|
35
|
-
import { assetPath, assetUrl } from "./utils.js";
|
|
34
|
+
import { assetPath, assetUrl, cn } from "./utils.js";
|
|
35
|
+
import { AuthUIStylesContext, AppBrand, DataTable, DialogFooter, DialogDescription, DialogHeader, DialogTitle, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, } from "./appearance.js";
|
|
36
36
|
import { AdminOrganizationsTable } from "./admin-organizations.js";
|
|
37
37
|
import { AdminUsersTable } from "./admin-users.js";
|
|
38
38
|
import { ScrollableDialogBody, ScrollableDialogContent, ScrollableDialogHeader, } from "./scrollable-dialog.js";
|
|
@@ -528,7 +528,8 @@ const userApiKeysAtom = Atom.family((baseUrl) => Atom.keepAlive(Atom.map(authCli
|
|
|
528
528
|
reactivityKeys: ["user-api-keys", baseUrl],
|
|
529
529
|
}), AsyncResult.map(({ apiKeys }) => Array.from(apiKeys)))));
|
|
530
530
|
const emptyApiKeysAtom = Atom.make(Effect.succeed(Array()));
|
|
531
|
-
export const UserButton = (
|
|
531
|
+
export const UserButton = (props) => (_jsx(AuthUIStylesContext.Provider, { value: props.classNames, children: _jsx(UserButtonContent, { ...props }) }));
|
|
532
|
+
const UserButtonContent = ({ className, classNames, variant = "outline", size = "icon", triggerBadge, baseUrl, signOutRedirect = "/", side = "bottom", defaultDialog = null, hideTrigger = false, renderUnauthenticated, menuActions, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }) => {
|
|
532
533
|
const auth = useKrakstackAuth();
|
|
533
534
|
const resolvedBaseUrl = baseUrl ?? auth?.baseUrl;
|
|
534
535
|
const labels = userButtonMessages(messages);
|
|
@@ -638,7 +639,7 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
|
|
|
638
639
|
: `${import.meta.env.VITE_SITE_URL}${signOutRedirect.startsWith("/") ? signOutRedirect : `/${signOutRedirect}`}`;
|
|
639
640
|
signOut({ baseUrl: resolvedBaseUrl, redirectUrl });
|
|
640
641
|
};
|
|
641
|
-
return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "
|
|
642
|
+
return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: variant, size: size, "data-auth-slot": "user-trigger", className: cn(triggerBadge != null ? "relative" : "overflow-hidden", className), children: [triggerBadge != null ? (_jsx("span", { "data-auth-slot": "trigger-badge", className: cn("pointer-events-none absolute -top-1 -right-1 z-10", classNames?.trigger?.badge), children: triggerBadge })) : null, _jsx("span", { "data-auth-slot": "trigger-visual", className: cn("flex size-full items-center justify-center overflow-hidden rounded-[inherit]", classNames?.trigger?.visual), children: displayImage ? (_jsx("img", { src: displayImage, alt: displayName || displayEmail, "data-auth-slot": "trigger-image", className: cn("size-full object-cover", classNames?.trigger?.image) })) : (_jsx(UserIcon, { "data-auth-slot": "trigger-icon", className: cn("size-4.5", classNames?.trigger?.icon) })) }), _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, { appearance: "menuHeader", 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(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, deletionControlsEnabled &&
|
|
642
643
|
!isImpersonating &&
|
|
643
644
|
!isOrganizationImpersonating ? (_jsxs(DropdownMenuItem, { variant: "destructive", onClick: () => setSettingsDialog("deleteAccount"), children: [_jsx(Trash2, {}), m.user_delete_title()] })) : 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({
|
|
644
645
|
baseUrl: resolvedBaseUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/auth",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Effect HttpApi clients and schemas for KrakStack Auth.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
"react-qr-code": "^2.2.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@krak-stack/registry": "0.
|
|
84
|
+
"@krak-stack/registry": "0.10.2"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@krak-stack/registry": "^0.
|
|
87
|
+
"@krak-stack/registry": "^0.10.2",
|
|
88
88
|
"@tanstack/react-router": "^1.170.15",
|
|
89
89
|
"effect": "^4.1.0",
|
|
90
90
|
"input-otp": "^1.5.0",
|