@better-auth-ui/heroui 1.6.6 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/auth/api-key/api-key-skeleton.d.ts +1 -0
- package/dist/components/auth/api-key/api-key-skeleton.js +21 -0
- package/dist/components/auth/api-key/api-key.d.ts +5 -0
- package/dist/components/auth/api-key/api-key.js +55 -0
- package/dist/components/auth/api-key/api-keys-empty.d.ts +4 -0
- package/dist/components/auth/api-key/api-keys-empty.js +35 -0
- package/dist/components/auth/api-key/api-keys.d.ts +6 -0
- package/dist/components/auth/api-key/api-keys.js +41 -0
- package/dist/components/auth/api-key/create-api-key-dialog.d.ts +5 -0
- package/dist/components/auth/api-key/create-api-key-dialog.js +74 -0
- package/dist/components/auth/api-key/delete-api-key-dialog.d.ts +7 -0
- package/dist/components/auth/api-key/delete-api-key-dialog.js +51 -0
- package/dist/components/auth/api-key/new-api-key-dialog.d.ts +7 -0
- package/dist/components/auth/api-key/new-api-key-dialog.js +60 -0
- package/dist/components/auth/multi-session/switch-account-submenu-content.js +14 -15
- package/dist/components/auth/passkey/add-passkey-dialog.d.ts +5 -0
- package/dist/components/auth/passkey/add-passkey-dialog.js +65 -0
- package/dist/components/auth/passkey/delete-passkey-dialog.d.ts +11 -0
- package/dist/components/auth/passkey/delete-passkey-dialog.js +47 -0
- package/dist/components/auth/passkey/passkey-skeleton.d.ts +1 -0
- package/dist/components/auth/passkey/passkey-skeleton.js +17 -0
- package/dist/components/auth/passkey/passkey.d.ts +2 -5
- package/dist/components/auth/passkey/passkey.js +16 -13
- package/dist/components/auth/passkey/passkeys-empty.d.ts +4 -0
- package/dist/components/auth/passkey/passkeys-empty.js +35 -0
- package/dist/components/auth/passkey/passkeys.js +35 -99
- package/dist/components/auth/settings/security/linked-account.js +1 -1
- package/dist/lib/auth/api-key-plugin.d.ts +23 -0
- package/dist/lib/auth/api-key-plugin.js +10 -0
- package/dist/lib/auth/passkey-plugin.d.ts +4 -1
- package/dist/plugins.d.ts +2 -0
- package/dist/plugins.js +22 -20
- package/package.json +3 -3
- package/src/components/auth/api-key/api-key-skeleton.tsx +17 -0
- package/src/components/auth/api-key/api-key.tsx +64 -0
- package/src/components/auth/api-key/api-keys-empty.tsx +33 -0
- package/src/components/auth/api-key/api-keys.tsx +71 -0
- package/src/components/auth/api-key/create-api-key-dialog.tsx +134 -0
- package/src/components/auth/api-key/delete-api-key-dialog.tsx +92 -0
- package/src/components/auth/api-key/new-api-key-dialog.tsx +94 -0
- package/src/components/auth/multi-session/switch-account-submenu-content.tsx +1 -3
- package/src/components/auth/passkey/add-passkey-dialog.tsx +109 -0
- package/src/components/auth/passkey/delete-passkey-dialog.tsx +95 -0
- package/src/components/auth/passkey/passkey-skeleton.tsx +16 -0
- package/src/components/auth/passkey/passkey.tsx +23 -22
- package/src/components/auth/passkey/passkeys-empty.tsx +35 -0
- package/src/components/auth/passkey/passkeys.tsx +33 -154
- package/src/components/auth/settings/security/linked-account.tsx +2 -4
- package/src/lib/auth/api-key-plugin.ts +15 -0
- package/src/plugins.ts +2 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiKeySkeleton(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Skeleton as e } from "@heroui/react";
|
|
2
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/auth/api-key/api-key-skeleton.tsx
|
|
4
|
+
function r() {
|
|
5
|
+
return /* @__PURE__ */ t("div", {
|
|
6
|
+
className: "flex items-center justify-between",
|
|
7
|
+
children: /* @__PURE__ */ n("div", {
|
|
8
|
+
className: "flex items-center gap-3",
|
|
9
|
+
children: [/* @__PURE__ */ t(e, { className: "size-10 rounded-xl" }), /* @__PURE__ */ n("div", {
|
|
10
|
+
className: "flex flex-col gap-1",
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ t(e, { className: "h-4 w-28 rounded-lg" }),
|
|
13
|
+
/* @__PURE__ */ t(e, { className: "h-3 w-36 rounded-lg" }),
|
|
14
|
+
/* @__PURE__ */ t(e, { className: "h-3 w-32 rounded-lg" })
|
|
15
|
+
]
|
|
16
|
+
})]
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { r as ApiKeySkeleton };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { apiKeyPlugin as e } from "../../../lib/auth/api-key-plugin.js";
|
|
2
|
+
import { DeleteApiKeyDialog as t } from "./delete-api-key-dialog.js";
|
|
3
|
+
import { useAuth as n, useAuthPlugin as r } from "@better-auth-ui/react";
|
|
4
|
+
import { Key as i, Xmark as a } from "@gravity-ui/icons";
|
|
5
|
+
import { Button as o } from "@heroui/react";
|
|
6
|
+
import { useState as s } from "react";
|
|
7
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/auth/api-key/api-key.tsx
|
|
9
|
+
function u({ apiKey: u }) {
|
|
10
|
+
let { localization: d } = n(), { localization: f } = r(e), [p, m] = s(!1), h = `${u.start}${"*".repeat(16)}`;
|
|
11
|
+
return /* @__PURE__ */ l("div", {
|
|
12
|
+
className: "flex items-center gap-3",
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ c("div", {
|
|
15
|
+
className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary",
|
|
16
|
+
children: /* @__PURE__ */ c(i, { className: "size-4.5" })
|
|
17
|
+
}),
|
|
18
|
+
/* @__PURE__ */ l("div", {
|
|
19
|
+
className: "flex flex-col min-w-0",
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ c("span", {
|
|
22
|
+
className: "text-sm font-medium leading-tight truncate",
|
|
23
|
+
children: u.name || f.apiKey
|
|
24
|
+
}),
|
|
25
|
+
/* @__PURE__ */ c("span", {
|
|
26
|
+
className: "text-xs text-muted font-mono truncate",
|
|
27
|
+
children: h
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ c("span", {
|
|
30
|
+
className: "text-xs text-muted",
|
|
31
|
+
children: new Date(u.createdAt).toLocaleString(void 0, {
|
|
32
|
+
dateStyle: "medium",
|
|
33
|
+
timeStyle: "short"
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
}),
|
|
38
|
+
/* @__PURE__ */ l(o, {
|
|
39
|
+
className: "ml-auto shrink-0",
|
|
40
|
+
variant: "outline",
|
|
41
|
+
size: "sm",
|
|
42
|
+
onPress: () => m(!0),
|
|
43
|
+
"aria-label": f.deleteApiKey,
|
|
44
|
+
children: [/* @__PURE__ */ c(a, {}), d.settings.delete]
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ c(t, {
|
|
47
|
+
isOpen: p,
|
|
48
|
+
onOpenChange: m,
|
|
49
|
+
apiKey: u
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { u as ApiKey };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { apiKeyPlugin as e } from "../../../lib/auth/api-key-plugin.js";
|
|
2
|
+
import { useAuthPlugin as t } from "@better-auth-ui/react";
|
|
3
|
+
import { Key as n } from "@gravity-ui/icons";
|
|
4
|
+
import { Button as r } from "@heroui/react";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/auth/api-key/api-keys-empty.tsx
|
|
7
|
+
function o({ onCreatePress: o }) {
|
|
8
|
+
let { localization: s } = t(e);
|
|
9
|
+
return /* @__PURE__ */ a("div", {
|
|
10
|
+
className: "flex flex-col items-center justify-center gap-4",
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ i("div", {
|
|
13
|
+
className: "flex size-10 items-center justify-center rounded-xl bg-surface-secondary",
|
|
14
|
+
children: /* @__PURE__ */ i(n, { className: "size-4.5" })
|
|
15
|
+
}),
|
|
16
|
+
/* @__PURE__ */ a("div", {
|
|
17
|
+
className: "flex flex-col items-center justify-center gap-1 text-center",
|
|
18
|
+
children: [/* @__PURE__ */ i("p", {
|
|
19
|
+
className: "text-sm font-semibold",
|
|
20
|
+
children: s.noApiKeys
|
|
21
|
+
}), /* @__PURE__ */ i("p", {
|
|
22
|
+
className: "text-muted text-xs",
|
|
23
|
+
children: s.apiKeysDescription
|
|
24
|
+
})]
|
|
25
|
+
}),
|
|
26
|
+
/* @__PURE__ */ i(r, {
|
|
27
|
+
size: "sm",
|
|
28
|
+
onPress: o,
|
|
29
|
+
children: s.createApiKey
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { o as ApiKeysEmpty };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { apiKeyPlugin as e } from "../../../lib/auth/api-key-plugin.js";
|
|
2
|
+
import { ApiKey as t } from "./api-key.js";
|
|
3
|
+
import { ApiKeySkeleton as n } from "./api-key-skeleton.js";
|
|
4
|
+
import { ApiKeysEmpty as r } from "./api-keys-empty.js";
|
|
5
|
+
import { CreateApiKeyDialog as i } from "./create-api-key-dialog.js";
|
|
6
|
+
import { useAuth as a, useAuthPlugin as o, useListApiKeys as s } from "@better-auth-ui/react";
|
|
7
|
+
import { Button as c, Card as l, cn as u } from "@heroui/react";
|
|
8
|
+
import { useState as d } from "react";
|
|
9
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/auth/api-key/api-keys.tsx
|
|
11
|
+
function m({ className: m, variant: h }) {
|
|
12
|
+
let { authClient: g } = a(), { localization: _ } = o(e), { data: v, isPending: y } = s(g), [b, x] = d(!1);
|
|
13
|
+
return /* @__PURE__ */ p("div", {
|
|
14
|
+
className: u("flex flex-col gap-3", m),
|
|
15
|
+
children: [
|
|
16
|
+
/* @__PURE__ */ p("div", {
|
|
17
|
+
className: "flex items-end justify-between gap-3",
|
|
18
|
+
children: [/* @__PURE__ */ f("h2", {
|
|
19
|
+
className: "text-sm font-semibold truncate",
|
|
20
|
+
children: _.apiKeys
|
|
21
|
+
}), /* @__PURE__ */ f(c, {
|
|
22
|
+
className: "shrink-0",
|
|
23
|
+
size: "sm",
|
|
24
|
+
isDisabled: y,
|
|
25
|
+
onPress: () => x(!0),
|
|
26
|
+
children: _.createApiKey
|
|
27
|
+
})]
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ f(l, {
|
|
30
|
+
variant: h,
|
|
31
|
+
children: /* @__PURE__ */ f(l.Content, { children: y ? /* @__PURE__ */ f(n, {}) : v?.apiKeys.length ? v?.apiKeys.map((e, n) => /* @__PURE__ */ p("div", { children: [n > 0 && /* @__PURE__ */ f("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ f(t, { apiKey: e })] }, e.id)) : /* @__PURE__ */ f(r, { onCreatePress: () => x(!0) }) })
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ f(i, {
|
|
34
|
+
isOpen: b,
|
|
35
|
+
onOpenChange: x
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { m as ApiKeys };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { apiKeyPlugin as e } from "../../../lib/auth/api-key-plugin.js";
|
|
2
|
+
import { NewApiKeyDialog as t } from "./new-api-key-dialog.js";
|
|
3
|
+
import { useAuth as n, useAuthPlugin as r, useCreateApiKey as i } from "@better-auth-ui/react";
|
|
4
|
+
import { Key as a } from "@gravity-ui/icons";
|
|
5
|
+
import { AlertDialog as o, Button as s, FieldError as c, Form as l, Input as u, Label as d, Spinner as f, TextField as p } from "@heroui/react";
|
|
6
|
+
import { useState as m } from "react";
|
|
7
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/auth/api-key/create-api-key-dialog.tsx
|
|
9
|
+
function v({ isOpen: v, onOpenChange: y }) {
|
|
10
|
+
let { authClient: b, localization: x } = n(), { localization: S } = r(e), { mutate: C, isPending: w } = i(b), [T, E] = m(!1), [D, O] = m(null), [k, A] = m(null), j = (e) => {
|
|
11
|
+
e || (O(null), A(null)), y(e);
|
|
12
|
+
};
|
|
13
|
+
return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(o.Backdrop, {
|
|
14
|
+
isOpen: v,
|
|
15
|
+
onOpenChange: j,
|
|
16
|
+
children: /* @__PURE__ */ g(o.Container, { children: /* @__PURE__ */ g(o.Dialog, { children: /* @__PURE__ */ _(l, {
|
|
17
|
+
onSubmit: (e) => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
let t = new FormData(e.target).get("name")?.trim();
|
|
20
|
+
C(t ? { name: t } : void 0, { onSuccess: (e) => {
|
|
21
|
+
j(!1), O(t), A(e.key), E(!0);
|
|
22
|
+
} });
|
|
23
|
+
},
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ g(o.CloseTrigger, {}),
|
|
26
|
+
/* @__PURE__ */ _(o.Header, { children: [/* @__PURE__ */ g(o.Icon, {
|
|
27
|
+
status: "default",
|
|
28
|
+
children: /* @__PURE__ */ g(a, {})
|
|
29
|
+
}), /* @__PURE__ */ g(o.Heading, { children: S.createApiKey })] }),
|
|
30
|
+
/* @__PURE__ */ _(o.Body, {
|
|
31
|
+
className: "overflow-visible",
|
|
32
|
+
children: [/* @__PURE__ */ g("p", {
|
|
33
|
+
className: "text-muted text-sm",
|
|
34
|
+
children: S.apiKeysDescription
|
|
35
|
+
}), /* @__PURE__ */ _(p, {
|
|
36
|
+
className: "mt-4",
|
|
37
|
+
id: "name",
|
|
38
|
+
name: "name",
|
|
39
|
+
isDisabled: w,
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ g(d, { children: S.name }),
|
|
42
|
+
/* @__PURE__ */ g(u, {
|
|
43
|
+
autoFocus: !0,
|
|
44
|
+
placeholder: x.settings.optional,
|
|
45
|
+
variant: "secondary"
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ g(c, {})
|
|
48
|
+
]
|
|
49
|
+
})]
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ _(o.Footer, { children: [/* @__PURE__ */ g(s, {
|
|
52
|
+
slot: "close",
|
|
53
|
+
variant: "tertiary",
|
|
54
|
+
isDisabled: w,
|
|
55
|
+
children: x.settings.cancel
|
|
56
|
+
}), /* @__PURE__ */ _(s, {
|
|
57
|
+
type: "submit",
|
|
58
|
+
isPending: w,
|
|
59
|
+
children: [w && /* @__PURE__ */ g(f, {
|
|
60
|
+
color: "current",
|
|
61
|
+
size: "sm"
|
|
62
|
+
}), S.createApiKey]
|
|
63
|
+
})] })
|
|
64
|
+
]
|
|
65
|
+
}) }) })
|
|
66
|
+
}), /* @__PURE__ */ g(t, {
|
|
67
|
+
isOpen: T,
|
|
68
|
+
onOpenChange: E,
|
|
69
|
+
secretKey: k,
|
|
70
|
+
name: D
|
|
71
|
+
})] });
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { v as CreateApiKeyDialog };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ListedApiKey } from '@better-auth-ui/react';
|
|
2
|
+
export type DeleteApiKeyDialogProps = {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
apiKey: ListedApiKey;
|
|
6
|
+
};
|
|
7
|
+
export declare function DeleteApiKeyDialog({ isOpen, onOpenChange, apiKey }: DeleteApiKeyDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { apiKeyPlugin as e } from "../../../lib/auth/api-key-plugin.js";
|
|
2
|
+
import { useAuth as t, useAuthPlugin as n, useDeleteApiKey as r } from "@better-auth-ui/react";
|
|
3
|
+
import { Key as i } from "@gravity-ui/icons";
|
|
4
|
+
import { AlertDialog as a, Button as o, Input as s, Label as c, Spinner as l, TextField as u } from "@heroui/react";
|
|
5
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/auth/api-key/delete-api-key-dialog.tsx
|
|
7
|
+
function p({ isOpen: p, onOpenChange: m, apiKey: h }) {
|
|
8
|
+
let { authClient: g, localization: _ } = t(), { localization: v } = n(e), y = `${h.start}${"*".repeat(16)}`, { mutate: b, isPending: x } = r(g, { onSuccess: () => m(!1) });
|
|
9
|
+
return /* @__PURE__ */ d(a.Backdrop, {
|
|
10
|
+
isOpen: p,
|
|
11
|
+
onOpenChange: m,
|
|
12
|
+
children: /* @__PURE__ */ d(a.Container, { children: /* @__PURE__ */ f(a.Dialog, { children: [
|
|
13
|
+
/* @__PURE__ */ d(a.CloseTrigger, {}),
|
|
14
|
+
/* @__PURE__ */ f(a.Header, { children: [/* @__PURE__ */ d(a.Icon, {
|
|
15
|
+
status: "danger",
|
|
16
|
+
children: /* @__PURE__ */ d(i, {})
|
|
17
|
+
}), /* @__PURE__ */ d(a.Heading, { children: v.deleteApiKey })] }),
|
|
18
|
+
/* @__PURE__ */ f(a.Body, {
|
|
19
|
+
className: "flex flex-col gap-4 overflow-visible",
|
|
20
|
+
children: [/* @__PURE__ */ d("p", {
|
|
21
|
+
className: "text-muted text-sm",
|
|
22
|
+
children: v.deleteApiKeyWarning
|
|
23
|
+
}), /* @__PURE__ */ f(u, {
|
|
24
|
+
value: y,
|
|
25
|
+
className: "font-mono text-xs",
|
|
26
|
+
variant: "secondary",
|
|
27
|
+
children: [/* @__PURE__ */ d(c, { children: h.name || v.apiKey }), /* @__PURE__ */ d(s, {
|
|
28
|
+
readOnly: !0,
|
|
29
|
+
className: "font-mono text-xs"
|
|
30
|
+
})]
|
|
31
|
+
})]
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ f(a.Footer, { children: [/* @__PURE__ */ d(o, {
|
|
34
|
+
slot: "close",
|
|
35
|
+
variant: "tertiary",
|
|
36
|
+
isDisabled: x,
|
|
37
|
+
children: _.settings.cancel
|
|
38
|
+
}), /* @__PURE__ */ f(o, {
|
|
39
|
+
variant: "danger",
|
|
40
|
+
onPress: () => b({ keyId: h.id }),
|
|
41
|
+
isPending: x,
|
|
42
|
+
children: [x && /* @__PURE__ */ d(l, {
|
|
43
|
+
color: "current",
|
|
44
|
+
size: "sm"
|
|
45
|
+
}), v.deleteApiKey]
|
|
46
|
+
})] })
|
|
47
|
+
] }) })
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { p as DeleteApiKeyDialog };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type NewApiKeyDialogProps = {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
onOpenChange: (open: boolean) => void;
|
|
4
|
+
name: string | null;
|
|
5
|
+
secretKey: string | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function NewApiKeyDialog({ isOpen, onOpenChange, name, secretKey }: NewApiKeyDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { apiKeyPlugin as e } from "../../../lib/auth/api-key-plugin.js";
|
|
2
|
+
import { useAuth as t, useAuthPlugin as n } from "@better-auth-ui/react";
|
|
3
|
+
import { Check as r, Copy as i, Key as a } from "@gravity-ui/icons";
|
|
4
|
+
import { AlertDialog as o, Button as s, InputGroup as c, Label as l, TextField as u, toast as d } from "@heroui/react";
|
|
5
|
+
import { useState as f } from "react";
|
|
6
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/auth/api-key/new-api-key-dialog.tsx
|
|
8
|
+
function h({ isOpen: h, onOpenChange: g, name: _, secretKey: v }) {
|
|
9
|
+
let { localization: y } = t(), { localization: b } = n(e), [x, S] = f(!1);
|
|
10
|
+
return /* @__PURE__ */ p(o.Backdrop, {
|
|
11
|
+
isOpen: h,
|
|
12
|
+
onOpenChange: g,
|
|
13
|
+
children: /* @__PURE__ */ p(o.Container, { children: /* @__PURE__ */ m(o.Dialog, { children: [
|
|
14
|
+
/* @__PURE__ */ p(o.CloseTrigger, {}),
|
|
15
|
+
/* @__PURE__ */ m(o.Header, { children: [/* @__PURE__ */ p(o.Icon, {
|
|
16
|
+
status: "warning",
|
|
17
|
+
children: /* @__PURE__ */ p(a, {})
|
|
18
|
+
}), /* @__PURE__ */ p(o.Heading, { children: b.newApiKey })] }),
|
|
19
|
+
/* @__PURE__ */ m(o.Body, {
|
|
20
|
+
className: "flex flex-col gap-4 overflow-visible",
|
|
21
|
+
children: [/* @__PURE__ */ p("p", {
|
|
22
|
+
className: "text-muted text-sm",
|
|
23
|
+
children: b.newApiKeyWarning
|
|
24
|
+
}), /* @__PURE__ */ m(u, {
|
|
25
|
+
value: v ?? "",
|
|
26
|
+
className: "font-mono text-xs",
|
|
27
|
+
children: [/* @__PURE__ */ p(l, { children: _ || b.apiKey }), /* @__PURE__ */ m(c, {
|
|
28
|
+
variant: "secondary",
|
|
29
|
+
children: [/* @__PURE__ */ p(c.Input, {
|
|
30
|
+
readOnly: !0,
|
|
31
|
+
className: "font-mono text-xs"
|
|
32
|
+
}), /* @__PURE__ */ p(c.Suffix, {
|
|
33
|
+
className: "px-0",
|
|
34
|
+
children: /* @__PURE__ */ p(s, {
|
|
35
|
+
isIconOnly: !0,
|
|
36
|
+
"aria-label": y.settings.copyToClipboard,
|
|
37
|
+
size: "sm",
|
|
38
|
+
variant: "ghost",
|
|
39
|
+
onPress: async () => {
|
|
40
|
+
if (v) try {
|
|
41
|
+
await navigator.clipboard.writeText(v), S(!0), setTimeout(() => S(!1), 1500);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
d.danger(e instanceof Error ? e.message : String(e));
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
children: p(x ? r : i, {})
|
|
47
|
+
})
|
|
48
|
+
})]
|
|
49
|
+
})]
|
|
50
|
+
})]
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ p(o.Footer, { children: /* @__PURE__ */ p(s, {
|
|
53
|
+
slot: "close",
|
|
54
|
+
children: b.dismissNewKey
|
|
55
|
+
}) })
|
|
56
|
+
] }) })
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { h as NewApiKeyDialog };
|
|
@@ -3,27 +3,26 @@ import { SwitchAccountSubmenuItem as t } from "./switch-account-submenu-item.js"
|
|
|
3
3
|
import { multiSessionPlugin as n } from "../../../lib/auth/multi-session-plugin.js";
|
|
4
4
|
import { useAuth as r, useAuthPlugin as i, useListDeviceSessions as a, useSession as o } from "@better-auth-ui/react";
|
|
5
5
|
import { Check as s, CirclePlus as c } from "@gravity-ui/icons";
|
|
6
|
-
import { Dropdown as l, Label as u
|
|
7
|
-
import { jsx as
|
|
6
|
+
import { Dropdown as l, Label as u } from "@heroui/react";
|
|
7
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
8
|
//#region src/components/auth/multi-session/switch-account-submenu-content.tsx
|
|
9
|
-
function
|
|
10
|
-
let { authClient:
|
|
11
|
-
return /* @__PURE__ */
|
|
9
|
+
function p() {
|
|
10
|
+
let { authClient: p, basePaths: m, viewPaths: h } = r(), { localization: g } = i(n), { data: _ } = o(p), { data: v, isPending: y } = a(p);
|
|
11
|
+
return /* @__PURE__ */ d(l.Popover, {
|
|
12
12
|
className: "min-w-40 md:min-w-56 max-w-[48svw]",
|
|
13
|
-
children: /* @__PURE__ */
|
|
14
|
-
/* @__PURE__ */
|
|
13
|
+
children: /* @__PURE__ */ f(l.Menu, { children: [
|
|
14
|
+
/* @__PURE__ */ f(l.Item, {
|
|
15
15
|
className: "px-2",
|
|
16
|
-
children: [/* @__PURE__ */
|
|
16
|
+
children: [/* @__PURE__ */ d(e, { isPending: y }), !y && /* @__PURE__ */ d(s, { className: "ml-auto" })]
|
|
17
17
|
}),
|
|
18
|
-
|
|
19
|
-
/* @__PURE__ */ f(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
children: [/* @__PURE__ */ f(c, { className: "text-muted" }), /* @__PURE__ */ f(u, { children: _.addAccount })]
|
|
18
|
+
v?.filter((e) => e.session.id !== _?.session?.id).map((e) => /* @__PURE__ */ d(t, { deviceSession: e }, e.session.id)),
|
|
19
|
+
/* @__PURE__ */ f(l.Item, {
|
|
20
|
+
textValue: g.addAccount,
|
|
21
|
+
href: `${m.auth}/${h.auth.signIn}`,
|
|
22
|
+
children: [/* @__PURE__ */ d(c, { className: "text-muted" }), /* @__PURE__ */ d(u, { children: g.addAccount })]
|
|
24
23
|
})
|
|
25
24
|
] })
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
27
|
//#endregion
|
|
29
|
-
export {
|
|
28
|
+
export { p as SwitchAccountSubmenuContent };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { passkeyPlugin as e } from "../../../lib/auth/passkey-plugin.js";
|
|
2
|
+
import { useAddPasskey as t, useAuth as n, useAuthPlugin as r } from "@better-auth-ui/react";
|
|
3
|
+
import { Fingerprint as i } from "@gravity-ui/icons";
|
|
4
|
+
import { AlertDialog as a, Button as o, FieldError as s, Form as c, Input as l, Label as u, Spinner as d, TextField as f } from "@heroui/react";
|
|
5
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/auth/passkey/add-passkey-dialog.tsx
|
|
7
|
+
function h({ isOpen: h, onOpenChange: g }) {
|
|
8
|
+
let { authClient: _, localization: v } = n(), { localization: y } = r(e), { mutate: b, isPending: x } = t(_), S = (e) => {
|
|
9
|
+
g(e);
|
|
10
|
+
};
|
|
11
|
+
return /* @__PURE__ */ p(a.Backdrop, {
|
|
12
|
+
isOpen: h,
|
|
13
|
+
onOpenChange: S,
|
|
14
|
+
children: /* @__PURE__ */ p(a.Container, { children: /* @__PURE__ */ p(a.Dialog, { children: /* @__PURE__ */ m(c, {
|
|
15
|
+
onSubmit: (e) => {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
let t = new FormData(e.target).get("name")?.trim();
|
|
18
|
+
b(t ? { name: t } : void 0, { onSuccess: () => S(!1) });
|
|
19
|
+
},
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ p(a.CloseTrigger, {}),
|
|
22
|
+
/* @__PURE__ */ m(a.Header, { children: [/* @__PURE__ */ p(a.Icon, {
|
|
23
|
+
status: "default",
|
|
24
|
+
children: /* @__PURE__ */ p(i, {})
|
|
25
|
+
}), /* @__PURE__ */ p(a.Heading, { children: y.addPasskey })] }),
|
|
26
|
+
/* @__PURE__ */ m(a.Body, {
|
|
27
|
+
className: "overflow-visible",
|
|
28
|
+
children: [/* @__PURE__ */ p("p", {
|
|
29
|
+
className: "text-muted text-sm",
|
|
30
|
+
children: y.passkeysDescription
|
|
31
|
+
}), /* @__PURE__ */ m(f, {
|
|
32
|
+
className: "mt-4",
|
|
33
|
+
id: "name",
|
|
34
|
+
name: "name",
|
|
35
|
+
isDisabled: x,
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ p(u, { children: y.name }),
|
|
38
|
+
/* @__PURE__ */ p(l, {
|
|
39
|
+
autoFocus: !0,
|
|
40
|
+
placeholder: v.settings.optional,
|
|
41
|
+
variant: "secondary"
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ p(s, {})
|
|
44
|
+
]
|
|
45
|
+
})]
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ m(a.Footer, { children: [/* @__PURE__ */ p(o, {
|
|
48
|
+
slot: "close",
|
|
49
|
+
variant: "tertiary",
|
|
50
|
+
isDisabled: x,
|
|
51
|
+
children: v.settings.cancel
|
|
52
|
+
}), /* @__PURE__ */ m(o, {
|
|
53
|
+
type: "submit",
|
|
54
|
+
isPending: x,
|
|
55
|
+
children: [x && /* @__PURE__ */ p(d, {
|
|
56
|
+
color: "current",
|
|
57
|
+
size: "sm"
|
|
58
|
+
}), y.addPasskey]
|
|
59
|
+
})] })
|
|
60
|
+
]
|
|
61
|
+
}) }) })
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { h as AddPasskeyDialog };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ListedPasskey = {
|
|
2
|
+
id: string;
|
|
3
|
+
name?: string | null;
|
|
4
|
+
createdAt: Date;
|
|
5
|
+
};
|
|
6
|
+
export type DeletePasskeyDialogProps = {
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
onOpenChange: (open: boolean) => void;
|
|
9
|
+
passkey: ListedPasskey;
|
|
10
|
+
};
|
|
11
|
+
export declare function DeletePasskeyDialog({ isOpen, onOpenChange, passkey }: DeletePasskeyDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { passkeyPlugin as e } from "../../../lib/auth/passkey-plugin.js";
|
|
2
|
+
import { useAuth as t, useAuthPlugin as n, useDeletePasskey as r } from "@better-auth-ui/react";
|
|
3
|
+
import { Fingerprint as i } from "@gravity-ui/icons";
|
|
4
|
+
import { AlertDialog as a, Button as o, Input as s, Label as c, Spinner as l, TextField as u } from "@heroui/react";
|
|
5
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/auth/passkey/delete-passkey-dialog.tsx
|
|
7
|
+
function p({ isOpen: p, onOpenChange: m, passkey: h }) {
|
|
8
|
+
let { authClient: g, localization: _ } = t(), { localization: v } = n(e), y = h.name || v.passkey, { mutate: b, isPending: x } = r(g, { onSuccess: () => m(!1) });
|
|
9
|
+
return /* @__PURE__ */ d(a.Backdrop, {
|
|
10
|
+
isOpen: p,
|
|
11
|
+
onOpenChange: m,
|
|
12
|
+
children: /* @__PURE__ */ d(a.Container, { children: /* @__PURE__ */ f(a.Dialog, { children: [
|
|
13
|
+
/* @__PURE__ */ d(a.CloseTrigger, {}),
|
|
14
|
+
/* @__PURE__ */ f(a.Header, { children: [/* @__PURE__ */ d(a.Icon, {
|
|
15
|
+
status: "danger",
|
|
16
|
+
children: /* @__PURE__ */ d(i, {})
|
|
17
|
+
}), /* @__PURE__ */ d(a.Heading, { children: v.deletePasskeyTitle })] }),
|
|
18
|
+
/* @__PURE__ */ f(a.Body, {
|
|
19
|
+
className: "flex flex-col gap-4 overflow-visible",
|
|
20
|
+
children: [/* @__PURE__ */ d("p", {
|
|
21
|
+
className: "text-muted text-sm",
|
|
22
|
+
children: v.deletePasskeyWarning
|
|
23
|
+
}), /* @__PURE__ */ f(u, {
|
|
24
|
+
value: y,
|
|
25
|
+
variant: "secondary",
|
|
26
|
+
children: [/* @__PURE__ */ d(c, { children: h.name || v.passkey }), /* @__PURE__ */ d(s, { readOnly: !0 })]
|
|
27
|
+
})]
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ f(a.Footer, { children: [/* @__PURE__ */ d(o, {
|
|
30
|
+
slot: "close",
|
|
31
|
+
variant: "tertiary",
|
|
32
|
+
isDisabled: x,
|
|
33
|
+
children: _.settings.cancel
|
|
34
|
+
}), /* @__PURE__ */ f(o, {
|
|
35
|
+
variant: "danger",
|
|
36
|
+
onPress: () => b({ id: h.id }),
|
|
37
|
+
isPending: x,
|
|
38
|
+
children: [x && /* @__PURE__ */ d(l, {
|
|
39
|
+
color: "current",
|
|
40
|
+
size: "sm"
|
|
41
|
+
}), v.deletePasskeyTitle]
|
|
42
|
+
})] })
|
|
43
|
+
] }) })
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { p as DeletePasskeyDialog };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PasskeySkeleton(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Skeleton as e } from "@heroui/react";
|
|
2
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/auth/passkey/passkey-skeleton.tsx
|
|
4
|
+
function r() {
|
|
5
|
+
return /* @__PURE__ */ t("div", {
|
|
6
|
+
className: "flex items-center justify-between",
|
|
7
|
+
children: /* @__PURE__ */ n("div", {
|
|
8
|
+
className: "flex items-center gap-3",
|
|
9
|
+
children: [/* @__PURE__ */ t(e, { className: "size-10 rounded-xl" }), /* @__PURE__ */ n("div", {
|
|
10
|
+
className: "flex flex-col gap-1",
|
|
11
|
+
children: [/* @__PURE__ */ t(e, { className: "h-4 w-28 rounded-lg" }), /* @__PURE__ */ t(e, { className: "h-3 w-32 rounded-lg" })]
|
|
12
|
+
})]
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { r as PasskeySkeleton };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
+
import { ListedPasskey } from './delete-passkey-dialog';
|
|
1
2
|
export type PasskeyProps = {
|
|
2
|
-
passkey:
|
|
3
|
-
id: string;
|
|
4
|
-
name?: string | null;
|
|
5
|
-
createdAt: Date;
|
|
6
|
-
};
|
|
3
|
+
passkey: ListedPasskey;
|
|
7
4
|
};
|
|
8
5
|
export declare function Passkey({ passkey }: PasskeyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { passkeyPlugin as e } from "../../../lib/auth/passkey-plugin.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DeletePasskeyDialog as t } from "./delete-passkey-dialog.js";
|
|
3
|
+
import { useAuth as n, useAuthPlugin as r } from "@better-auth-ui/react";
|
|
3
4
|
import { Fingerprint as i, Xmark as a } from "@gravity-ui/icons";
|
|
4
|
-
import { Button as o
|
|
5
|
+
import { Button as o } from "@heroui/react";
|
|
6
|
+
import { useState as s } from "react";
|
|
5
7
|
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
8
|
//#region src/components/auth/passkey/passkey.tsx
|
|
7
9
|
function u({ passkey: u }) {
|
|
8
|
-
let {
|
|
10
|
+
let { localization: d } = n(), { localization: f } = r(e), [p, m] = s(!1), h = u.name || f.passkey;
|
|
9
11
|
return /* @__PURE__ */ l("div", {
|
|
10
12
|
className: "flex items-center gap-3",
|
|
11
13
|
children: [
|
|
@@ -14,10 +16,10 @@ function u({ passkey: u }) {
|
|
|
14
16
|
children: /* @__PURE__ */ c(i, { className: "size-4.5" })
|
|
15
17
|
}),
|
|
16
18
|
/* @__PURE__ */ l("div", {
|
|
17
|
-
className: "flex
|
|
19
|
+
className: "flex min-w-0 flex-col",
|
|
18
20
|
children: [/* @__PURE__ */ c("span", {
|
|
19
|
-
className: "text-sm font-medium leading-tight",
|
|
20
|
-
children:
|
|
21
|
+
className: "truncate text-sm font-medium leading-tight",
|
|
22
|
+
children: h
|
|
21
23
|
}), /* @__PURE__ */ c("span", {
|
|
22
24
|
className: "text-xs text-muted",
|
|
23
25
|
children: new Date(u.createdAt).toLocaleString(void 0, {
|
|
@@ -30,13 +32,14 @@ function u({ passkey: u }) {
|
|
|
30
32
|
className: "ml-auto shrink-0",
|
|
31
33
|
variant: "outline",
|
|
32
34
|
size: "sm",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
onPress: () => m(!0),
|
|
36
|
+
"aria-label": f.deletePasskey.replace("{{name}}", h),
|
|
37
|
+
children: [/* @__PURE__ */ c(a, {}), d.settings.delete]
|
|
38
|
+
}),
|
|
39
|
+
/* @__PURE__ */ c(t, {
|
|
40
|
+
isOpen: p,
|
|
41
|
+
onOpenChange: m,
|
|
42
|
+
passkey: u
|
|
40
43
|
})
|
|
41
44
|
]
|
|
42
45
|
});
|