@better-auth-ui/heroui 1.6.7 → 1.6.9
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/additional-field.d.ts +2 -2
- package/dist/components/auth/additional-field.js +133 -266
- package/dist/components/auth/api-key/api-key-skeleton.js +4 -20
- package/dist/components/auth/api-key/api-key.d.ts +6 -2
- package/dist/components/auth/api-key/api-key.js +16 -54
- package/dist/components/auth/api-key/api-keys-empty.d.ts +3 -1
- package/dist/components/auth/api-key/api-keys-empty.js +8 -34
- package/dist/components/auth/api-key/api-keys.d.ts +10 -2
- package/dist/components/auth/api-key/api-keys.js +21 -40
- package/dist/components/auth/api-key/create-api-key-dialog.d.ts +3 -1
- package/dist/components/auth/api-key/create-api-key-dialog.js +43 -73
- package/dist/components/auth/api-key/delete-api-key-dialog.d.ts +4 -2
- package/dist/components/auth/api-key/delete-api-key-dialog.js +16 -50
- package/dist/components/auth/api-key/new-api-key-dialog.js +23 -59
- package/dist/components/auth/api-key/organization-api-keys.d.ts +14 -0
- package/dist/components/auth/api-key/organization-api-keys.js +22 -0
- package/dist/components/auth/auth-provider.d.ts +1 -1
- package/dist/components/auth/auth-provider.js +10 -16
- package/dist/components/auth/auth.d.ts +3 -3
- package/dist/components/auth/auth.js +86 -61
- package/dist/components/auth/delete-user/danger-zone.d.ts +3 -3
- package/dist/components/auth/delete-user/danger-zone.js +11 -17
- package/dist/components/auth/delete-user/delete-account.d.ts +9 -0
- package/dist/components/auth/delete-user/delete-account.js +50 -0
- package/dist/components/auth/email/email-changed-email.d.ts +2 -2
- package/dist/components/auth/email/email-changed-email.js +22 -29
- package/dist/components/auth/email/email-verification-email.d.ts +2 -2
- package/dist/components/auth/email/email-verification-email.js +22 -29
- package/dist/components/auth/email/magic-link-email.d.ts +2 -2
- package/dist/components/auth/email/magic-link-email.js +22 -29
- package/dist/components/auth/email/new-device-email.d.ts +2 -2
- package/dist/components/auth/email/new-device-email.js +22 -29
- package/dist/components/auth/email/organization-invitation-email.d.ts +3 -0
- package/dist/components/auth/email/organization-invitation-email.js +23 -0
- package/dist/components/auth/email/otp-email.d.ts +2 -2
- package/dist/components/auth/email/otp-email.js +21 -28
- package/dist/components/auth/email/password-changed-email.d.ts +2 -2
- package/dist/components/auth/email/password-changed-email.js +22 -29
- package/dist/components/auth/email/reset-password-email.d.ts +2 -2
- package/dist/components/auth/email/reset-password-email.js +22 -29
- package/dist/components/auth/error-toaster.js +32 -16
- package/dist/components/auth/field-separator.d.ts +1 -1
- package/dist/components/auth/field-separator.js +4 -17
- package/dist/components/auth/forgot-password.d.ts +1 -1
- package/dist/components/auth/forgot-password.js +36 -88
- package/dist/components/auth/magic-link/magic-link-button.d.ts +1 -1
- package/dist/components/auth/magic-link/magic-link-button.js +33 -19
- package/dist/components/auth/magic-link/magic-link.d.ts +2 -2
- package/dist/components/auth/magic-link/magic-link.js +39 -86
- package/dist/components/auth/multi-session/manage-account.d.ts +1 -1
- package/dist/components/auth/multi-session/manage-account.js +32 -48
- package/dist/components/auth/multi-session/manage-accounts.d.ts +1 -1
- package/dist/components/auth/multi-session/manage-accounts.js +32 -33
- package/dist/components/auth/multi-session/switch-account-submenu-content.d.ts +3 -1
- package/dist/components/auth/multi-session/switch-account-submenu-content.js +24 -27
- package/dist/components/auth/multi-session/switch-account-submenu-item.d.ts +3 -2
- package/dist/components/auth/multi-session/switch-account-submenu-item.js +16 -19
- package/dist/components/auth/multi-session/switch-account-submenu.d.ts +2 -1
- package/dist/components/auth/multi-session/switch-account-submenu.js +23 -23
- package/dist/components/auth/organization/change-organization-logo.d.ts +4 -0
- package/dist/components/auth/organization/change-organization-logo.js +69 -0
- package/dist/components/auth/organization/create-organization-dialog.d.ts +13 -0
- package/dist/components/auth/organization/create-organization-dialog.js +37 -0
- package/dist/components/auth/organization/delete-organization-dialog.d.ts +7 -0
- package/dist/components/auth/organization/delete-organization-dialog.js +25 -0
- package/dist/components/auth/organization/delete-organization-skeleton.d.ts +4 -0
- package/dist/components/auth/organization/delete-organization-skeleton.js +8 -0
- package/dist/components/auth/organization/delete-organization.d.ts +5 -0
- package/dist/components/auth/organization/delete-organization.js +27 -0
- package/dist/components/auth/organization/invite-member-dialog.d.ts +13 -0
- package/dist/components/auth/organization/invite-member-dialog.js +47 -0
- package/dist/components/auth/organization/leave-organization-dialog.d.ts +7 -0
- package/dist/components/auth/organization/leave-organization-dialog.js +21 -0
- package/dist/components/auth/organization/leave-organization.d.ts +4 -0
- package/dist/components/auth/organization/leave-organization.js +16 -0
- package/dist/components/auth/organization/organization-danger-zone.d.ts +16 -0
- package/dist/components/auth/organization/organization-danger-zone.js +23 -0
- package/dist/components/auth/organization/organization-invitation-row-skeleton.d.ts +5 -0
- package/dist/components/auth/organization/organization-invitation-row-skeleton.js +9 -0
- package/dist/components/auth/organization/organization-invitation-row.d.ts +5 -0
- package/dist/components/auth/organization/organization-invitation-row.js +31 -0
- package/dist/components/auth/organization/organization-invitations-empty.d.ts +8 -0
- package/dist/components/auth/organization/organization-invitations-empty.js +13 -0
- package/dist/components/auth/organization/organization-invitations.d.ts +9 -0
- package/dist/components/auth/organization/organization-invitations.js +66 -0
- package/dist/components/auth/organization/organization-logo.d.ts +15 -0
- package/dist/components/auth/organization/organization-logo.js +14 -0
- package/dist/components/auth/organization/organization-member-row-skeleton.d.ts +4 -0
- package/dist/components/auth/organization/organization-member-row-skeleton.js +9 -0
- package/dist/components/auth/organization/organization-member-row.d.ts +9 -0
- package/dist/components/auth/organization/organization-member-row.js +34 -0
- package/dist/components/auth/organization/organization-members.d.ts +9 -0
- package/dist/components/auth/organization/organization-members.js +67 -0
- package/dist/components/auth/organization/organization-people.d.ts +10 -0
- package/dist/components/auth/organization/organization-people.js +11 -0
- package/dist/components/auth/organization/organization-profile.d.ts +9 -0
- package/dist/components/auth/organization/organization-profile.js +34 -0
- package/dist/components/auth/organization/organization-row.d.ts +8 -0
- package/dist/components/auth/organization/organization-row.js +31 -0
- package/dist/components/auth/organization/organization-settings.d.ts +12 -0
- package/dist/components/auth/organization/organization-settings.js +13 -0
- package/dist/components/auth/organization/organization-switcher.d.ts +20 -0
- package/dist/components/auth/organization/organization-switcher.js +48 -0
- package/dist/components/auth/organization/organization-view-skeleton.d.ts +6 -0
- package/dist/components/auth/organization/organization-view-skeleton.js +9 -0
- package/dist/components/auth/organization/organization-view.d.ts +15 -0
- package/dist/components/auth/organization/organization-view.js +31 -0
- package/dist/components/auth/organization/organization.d.ts +17 -0
- package/dist/components/auth/organization/organization.js +60 -0
- package/dist/components/auth/organization/organizations-empty.d.ts +4 -0
- package/dist/components/auth/organization/organizations-empty.js +9 -0
- package/dist/components/auth/organization/organizations-settings.d.ts +17 -0
- package/dist/components/auth/organization/organizations-settings.js +17 -0
- package/dist/components/auth/organization/organizations.d.ts +10 -0
- package/dist/components/auth/organization/organizations.js +21 -0
- package/dist/components/auth/organization/remove-member-dialog.d.ts +9 -0
- package/dist/components/auth/organization/remove-member-dialog.js +20 -0
- package/dist/components/auth/organization/slug-field.d.ts +19 -0
- package/dist/components/auth/organization/slug-field.js +38 -0
- package/dist/components/auth/organization/user-invitation-row-skeleton.d.ts +4 -0
- package/dist/components/auth/organization/user-invitation-row-skeleton.js +8 -0
- package/dist/components/auth/organization/user-invitation-row.d.ts +10 -0
- package/dist/components/auth/organization/user-invitation-row.js +22 -0
- package/dist/components/auth/organization/user-invitations-empty.d.ts +4 -0
- package/dist/components/auth/organization/user-invitations-empty.js +12 -0
- package/dist/components/auth/organization/user-invitations.d.ts +10 -0
- package/dist/components/auth/organization/user-invitations.js +18 -0
- package/dist/components/auth/passkey/add-passkey-dialog.d.ts +5 -0
- package/dist/components/auth/passkey/add-passkey-dialog.js +22 -0
- package/dist/components/auth/passkey/delete-passkey-dialog.d.ts +11 -0
- package/dist/components/auth/passkey/delete-passkey-dialog.js +14 -0
- package/dist/components/auth/passkey/passkey-button.d.ts +1 -1
- package/dist/components/auth/passkey/passkey-button.js +24 -23
- package/dist/components/auth/passkey/passkey-skeleton.d.ts +1 -0
- package/dist/components/auth/passkey/passkey-skeleton.js +5 -0
- package/dist/components/auth/passkey/passkey.d.ts +2 -5
- package/dist/components/auth/passkey/passkey.js +16 -44
- package/dist/components/auth/passkey/passkeys-empty.d.ts +4 -0
- package/dist/components/auth/passkey/passkeys-empty.js +9 -0
- package/dist/components/auth/passkey/passkeys.d.ts +1 -1
- package/dist/components/auth/passkey/passkeys.js +15 -105
- package/dist/components/auth/provider-button.d.ts +2 -2
- package/dist/components/auth/provider-button.js +28 -24
- package/dist/components/auth/provider-buttons.js +28 -18
- package/dist/components/auth/reset-password.d.ts +1 -1
- package/dist/components/auth/reset-password.js +56 -146
- package/dist/components/auth/settings/account/account-settings.d.ts +2 -2
- package/dist/components/auth/settings/account/account-settings.js +21 -19
- package/dist/components/auth/settings/account/change-avatar.js +53 -88
- package/dist/components/auth/settings/account/change-email.d.ts +1 -1
- package/dist/components/auth/settings/account/change-email.js +27 -53
- package/dist/components/auth/settings/account/user-profile.d.ts +1 -1
- package/dist/components/auth/settings/account/user-profile.js +64 -85
- package/dist/components/auth/settings/security/active-session.d.ts +1 -1
- package/dist/components/auth/settings/security/active-session.js +50 -57
- package/dist/components/auth/settings/security/active-sessions.d.ts +1 -1
- package/dist/components/auth/settings/security/active-sessions.js +21 -32
- package/dist/components/auth/settings/security/change-password.d.ts +1 -1
- package/dist/components/auth/settings/security/change-password.js +76 -186
- package/dist/components/auth/settings/security/linked-account.d.ts +1 -1
- package/dist/components/auth/settings/security/linked-account.js +37 -55
- package/dist/components/auth/settings/security/linked-accounts.d.ts +1 -1
- package/dist/components/auth/settings/security/linked-accounts.js +34 -43
- package/dist/components/auth/settings/security/security-settings.d.ts +2 -2
- package/dist/components/auth/settings/security/security-settings.js +19 -21
- package/dist/components/auth/settings/settings.d.ts +4 -4
- package/dist/components/auth/settings/settings.js +52 -44
- package/dist/components/auth/sign-in.d.ts +2 -2
- package/dist/components/auth/sign-in.js +63 -132
- package/dist/components/auth/sign-out.js +32 -26
- package/dist/components/auth/sign-up.d.ts +2 -2
- package/dist/components/auth/sign-up.js +97 -211
- package/dist/components/auth/theme/appearance.d.ts +1 -1
- package/dist/components/auth/theme/appearance.js +23 -71
- package/dist/components/auth/theme/theme-toggle-item.js +56 -61
- package/dist/components/auth/user/user-avatar.d.ts +4 -4
- package/dist/components/auth/user/user-avatar.js +31 -28
- package/dist/components/auth/user/user-button.d.ts +6 -7
- package/dist/components/auth/user/user-button.js +38 -72
- package/dist/components/auth/user/user-view.d.ts +13 -7
- package/dist/components/auth/user/user-view.js +26 -36
- package/dist/components/auth/username/sign-in-username.d.ts +2 -2
- package/dist/components/auth/username/sign-in-username.js +87 -147
- package/dist/components/auth/username/username-field.d.ts +1 -1
- package/dist/components/auth/username/username-field.js +44 -52
- package/dist/email.d.ts +8 -7
- package/dist/email.js +8 -8
- package/dist/index.d.ts +21 -21
- package/dist/index.js +21 -22
- package/dist/lib/auth/api-key-plugin.d.ts +7 -4
- package/dist/lib/auth/api-key-plugin.js +12 -10
- package/dist/lib/auth/auth-plugin.d.ts +10 -6
- package/dist/lib/auth/auth-plugin.js +1 -0
- package/dist/lib/auth/delete-user-plugin.d.ts +6 -6
- package/dist/lib/auth/delete-user-plugin.js +6 -9
- package/dist/lib/auth/magic-link-plugin.d.ts +5 -5
- package/dist/lib/auth/magic-link-plugin.js +17 -12
- package/dist/lib/auth/multi-session-plugin.d.ts +5 -5
- package/dist/lib/auth/multi-session-plugin.js +8 -11
- package/dist/lib/auth/organization-plugin.d.ts +37 -0
- package/dist/lib/auth/organization-plugin.js +19 -0
- package/dist/lib/auth/passkey-plugin.d.ts +9 -6
- package/dist/lib/auth/passkey-plugin.js +8 -11
- package/dist/lib/auth/theme-plugin.d.ts +6 -6
- package/dist/lib/auth/theme-plugin.js +25 -22
- package/dist/lib/auth/username-plugin.d.ts +11 -11
- package/dist/lib/auth/username-plugin.js +18 -17
- package/dist/plugins.d.ts +46 -22
- package/dist/plugins.js +47 -22
- package/package.json +25 -19
- package/src/components/auth/api-key/api-key.tsx +25 -16
- package/src/components/auth/api-key/api-keys-empty.tsx +8 -4
- package/src/components/auth/api-key/api-keys.tsx +52 -14
- package/src/components/auth/api-key/create-api-key-dialog.tsx +17 -4
- package/src/components/auth/api-key/delete-api-key-dialog.tsx +10 -2
- package/src/components/auth/api-key/organization-api-keys.tsx +55 -0
- package/src/components/auth/delete-user/danger-zone.tsx +3 -3
- package/src/components/auth/delete-user/{delete-user.tsx → delete-account.tsx} +9 -9
- package/src/components/auth/email/organization-invitation-email.tsx +38 -0
- package/src/components/auth/error-toaster.tsx +28 -10
- package/src/components/auth/forgot-password.tsx +10 -2
- package/src/components/auth/multi-session/manage-accounts.tsx +1 -1
- package/src/components/auth/multi-session/switch-account-submenu-content.tsx +7 -2
- package/src/components/auth/multi-session/switch-account-submenu-item.tsx +4 -2
- package/src/components/auth/multi-session/switch-account-submenu.tsx +8 -4
- package/src/components/auth/organization/change-organization-logo.tsx +171 -0
- package/src/components/auth/organization/create-organization-dialog.tsx +133 -0
- package/src/components/auth/organization/delete-organization-dialog.tsx +97 -0
- package/src/components/auth/organization/delete-organization-skeleton.tsx +17 -0
- package/src/components/auth/organization/delete-organization.tsx +77 -0
- package/src/components/auth/organization/invite-member-dialog.tsx +177 -0
- package/src/components/auth/organization/leave-organization-dialog.tsx +95 -0
- package/src/components/auth/organization/leave-organization.tsx +59 -0
- package/src/components/auth/organization/organization-danger-zone.tsx +68 -0
- package/src/components/auth/organization/organization-invitation-row-skeleton.tsx +29 -0
- package/src/components/auth/organization/organization-invitation-row.tsx +97 -0
- package/src/components/auth/organization/organization-invitations-empty.tsx +39 -0
- package/src/components/auth/organization/organization-invitations.tsx +351 -0
- package/src/components/auth/organization/organization-logo.tsx +64 -0
- package/src/components/auth/organization/organization-member-row-skeleton.tsx +24 -0
- package/src/components/auth/organization/organization-member-row.tsx +157 -0
- package/src/components/auth/organization/organization-members.tsx +284 -0
- package/src/components/auth/organization/organization-people.tsx +26 -0
- package/src/components/auth/organization/organization-profile.tsx +141 -0
- package/src/components/auth/organization/organization-row.tsx +66 -0
- package/src/components/auth/organization/organization-settings.tsx +38 -0
- package/src/components/auth/organization/organization-switcher.tsx +233 -0
- package/src/components/auth/organization/organization-view-skeleton.tsx +36 -0
- package/src/components/auth/organization/organization-view.tsx +109 -0
- package/src/components/auth/organization/organization.tsx +162 -0
- package/src/components/auth/organization/organizations-empty.tsx +35 -0
- package/src/components/auth/organization/organizations-settings.tsx +36 -0
- package/src/components/auth/organization/organizations.tsx +80 -0
- package/src/components/auth/organization/remove-member-dialog.tsx +95 -0
- package/src/components/auth/organization/slug-field.tsx +111 -0
- package/src/components/auth/organization/user-invitation-row-skeleton.tsx +17 -0
- package/src/components/auth/organization/user-invitation-row.tsx +90 -0
- package/src/components/auth/organization/user-invitations-empty.tsx +30 -0
- package/src/components/auth/organization/user-invitations.tsx +59 -0
- 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/account/change-email.tsx +1 -1
- package/src/components/auth/settings/account/user-profile.tsx +5 -5
- package/src/components/auth/settings/security/active-sessions.tsx +6 -4
- package/src/components/auth/settings/security/linked-accounts.tsx +2 -2
- package/src/components/auth/settings/settings.tsx +77 -14
- package/src/components/auth/user/user-avatar.tsx +4 -1
- package/src/components/auth/user/user-button.tsx +14 -11
- package/src/components/auth/user/user-view.tsx +32 -12
- package/src/email.ts +1 -0
- package/src/lib/auth/api-key-plugin.ts +10 -4
- package/src/lib/auth/auth-plugin.ts +6 -1
- package/src/lib/auth/organization-plugin.tsx +32 -0
- package/src/plugins.ts +25 -1
- package/dist/components/auth/delete-user/delete-user.d.ts +0 -9
- package/dist/components/auth/delete-user/delete-user.js +0 -95
|
@@ -1,41 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useAuthPlugin, useListApiKeys } from "@better-auth-ui/react";
|
|
3
|
+
import { Button, Card, cn } from "@heroui/react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { apiKeyPlugin } from "../../../lib/auth/api-key-plugin";
|
|
6
|
+
import { ApiKey } from "./api-key";
|
|
7
|
+
import { ApiKeySkeleton } from "./api-key-skeleton";
|
|
8
|
+
import { ApiKeysEmpty } from "./api-keys-empty";
|
|
9
|
+
import { CreateApiKeyDialog } from "./create-api-key-dialog";
|
|
10
|
+
export function ApiKeys({ className, variant, organizationId, isPending: isPendingProp, hideCreate, hideDelete }) {
|
|
11
|
+
const { authClient } = useAuth();
|
|
12
|
+
const { localization: apiKeyLocalization } = useAuthPlugin(apiKeyPlugin);
|
|
13
|
+
const { data: listData, isPending: isListPending } = useListApiKeys(authClient, {
|
|
14
|
+
enabled: !isPendingProp,
|
|
15
|
+
...(organizationId
|
|
16
|
+
? { query: { organizationId, configId: "organization" } }
|
|
17
|
+
: {})
|
|
18
|
+
});
|
|
19
|
+
const isPending = isPendingProp || isListPending;
|
|
20
|
+
const [createOpen, setCreateOpen] = useState(false);
|
|
21
|
+
return (_jsxs("div", { className: cn("flex flex-col gap-3", className), children: [_jsxs("div", { className: "flex items-end justify-between gap-3", children: [_jsx("h2", { className: "text-sm font-semibold truncate", children: apiKeyLocalization.apiKeys }), !hideCreate && (_jsx(Button, { className: "shrink-0", size: "sm", isDisabled: isPending, onPress: () => setCreateOpen(true), children: apiKeyLocalization.createApiKey }))] }), _jsx(Card, { variant: variant, children: _jsx(Card.Content, { children: isPending ? (_jsx(ApiKeySkeleton, {})) : !listData?.apiKeys.length ? (_jsx(ApiKeysEmpty, { onCreatePress: () => setCreateOpen(true), hideCreate: hideCreate })) : (listData?.apiKeys.map((key, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 my-4" })), _jsx(ApiKey, { apiKey: key, hideDelete: hideDelete, organizationId: organizationId })] }, key.id)))) }) }), !hideCreate && (_jsx(CreateApiKeyDialog, { isOpen: createOpen, onOpenChange: setCreateOpen, organizationId: organizationId }))] }));
|
|
39
22
|
}
|
|
40
|
-
//#endregion
|
|
41
|
-
export { m as ApiKeys };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type CreateApiKeyDialogProps = {
|
|
2
2
|
isOpen: boolean;
|
|
3
3
|
onOpenChange: (open: boolean) => void;
|
|
4
|
+
/** Create an organization-owned key by passing the organization id. */
|
|
5
|
+
organizationId?: string;
|
|
4
6
|
};
|
|
5
|
-
export declare function CreateApiKeyDialog({ isOpen, onOpenChange }: CreateApiKeyDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function CreateApiKeyDialog({ isOpen, onOpenChange, organizationId }: CreateApiKeyDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,74 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
})] });
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useAuthPlugin, useCreateApiKey } from "@better-auth-ui/react";
|
|
3
|
+
import { Key } from "@gravity-ui/icons";
|
|
4
|
+
import { AlertDialog, Button, FieldError, Form, Input, Label, Spinner, TextField } from "@heroui/react";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { apiKeyPlugin } from "../../../lib/auth/api-key-plugin";
|
|
7
|
+
import { NewApiKeyDialog } from "./new-api-key-dialog";
|
|
8
|
+
export function CreateApiKeyDialog({ isOpen, onOpenChange, organizationId }) {
|
|
9
|
+
const { authClient, localization } = useAuth();
|
|
10
|
+
const { localization: apiKeyLocalization } = useAuthPlugin(apiKeyPlugin);
|
|
11
|
+
const { mutate: createApiKey, isPending: isCreating } = useCreateApiKey(authClient);
|
|
12
|
+
const [isNewKeyDialogOpen, setIsNewKeyDialogOpen] = useState(false);
|
|
13
|
+
const [keyName, setKeyName] = useState(null);
|
|
14
|
+
const [secretKey, setSecretKey] = useState(null);
|
|
15
|
+
const handleOpenChange = (open) => {
|
|
16
|
+
if (!open) {
|
|
17
|
+
setKeyName(null);
|
|
18
|
+
setSecretKey(null);
|
|
19
|
+
}
|
|
20
|
+
onOpenChange(open);
|
|
21
|
+
};
|
|
22
|
+
const handleSubmit = (e) => {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
const formData = new FormData(e.target);
|
|
25
|
+
const name = formData.get("name")?.trim();
|
|
26
|
+
const payload = name || organizationId
|
|
27
|
+
? {
|
|
28
|
+
...(name ? { name } : {}),
|
|
29
|
+
...(organizationId
|
|
30
|
+
? { organizationId, configId: "organization" }
|
|
31
|
+
: {})
|
|
32
|
+
}
|
|
33
|
+
: undefined;
|
|
34
|
+
createApiKey(payload, {
|
|
35
|
+
onSuccess: (result) => {
|
|
36
|
+
handleOpenChange(false);
|
|
37
|
+
setKeyName(name);
|
|
38
|
+
setSecretKey(result.key);
|
|
39
|
+
setIsNewKeyDialogOpen(true);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsx(AlertDialog.Backdrop, { isOpen: isOpen, onOpenChange: handleOpenChange, children: _jsx(AlertDialog.Container, { children: _jsx(AlertDialog.Dialog, { children: _jsxs(Form, { onSubmit: handleSubmit, children: [_jsx(AlertDialog.CloseTrigger, {}), _jsxs(AlertDialog.Header, { children: [_jsx(AlertDialog.Icon, { status: "default", children: _jsx(Key, {}) }), _jsx(AlertDialog.Heading, { children: apiKeyLocalization.createApiKey })] }), _jsxs(AlertDialog.Body, { className: "overflow-visible", children: [_jsx("p", { className: "text-muted text-sm", children: apiKeyLocalization.apiKeysDescription }), _jsxs(TextField, { className: "mt-4", id: "name", name: "name", isDisabled: isCreating, children: [_jsx(Label, { children: apiKeyLocalization.name }), _jsx(Input, { autoFocus: true, placeholder: localization.settings.optional, variant: "secondary" }), _jsx(FieldError, {})] })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { slot: "close", variant: "tertiary", isDisabled: isCreating, children: localization.settings.cancel }), _jsxs(Button, { type: "submit", isPending: isCreating, children: [isCreating && _jsx(Spinner, { color: "current", size: "sm" }), apiKeyLocalization.createApiKey] })] })] }) }) }) }), _jsx(NewApiKeyDialog, { isOpen: isNewKeyDialogOpen, onOpenChange: setIsNewKeyDialogOpen, secretKey: secretKey, name: keyName })] }));
|
|
72
44
|
}
|
|
73
|
-
//#endregion
|
|
74
|
-
export { v as CreateApiKeyDialog };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { ListedApiKey } from
|
|
1
|
+
import { type ListedApiKey } from "@better-auth-ui/react";
|
|
2
2
|
export type DeleteApiKeyDialogProps = {
|
|
3
3
|
isOpen: boolean;
|
|
4
4
|
onOpenChange: (open: boolean) => void;
|
|
5
5
|
apiKey: ListedApiKey;
|
|
6
|
+
/** Scope the delete payload to an organization (sets `configId`). */
|
|
7
|
+
organizationId?: string;
|
|
6
8
|
};
|
|
7
|
-
export declare function DeleteApiKeyDialog({ isOpen, onOpenChange, apiKey }: DeleteApiKeyDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function DeleteApiKeyDialog({ isOpen, onOpenChange, apiKey, organizationId }: DeleteApiKeyDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,51 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAuth
|
|
3
|
-
import { Key
|
|
4
|
-
import { AlertDialog
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useAuthPlugin, useDeleteApiKey } from "@better-auth-ui/react";
|
|
3
|
+
import { Key } from "@gravity-ui/icons";
|
|
4
|
+
import { AlertDialog, Button, Input, Label, Spinner, TextField } from "@heroui/react";
|
|
5
|
+
import { apiKeyPlugin } from "../../../lib/auth/api-key-plugin";
|
|
6
|
+
export function DeleteApiKeyDialog({ isOpen, onOpenChange, apiKey, organizationId }) {
|
|
7
|
+
const { authClient, localization } = useAuth();
|
|
8
|
+
const { localization: apiKeyLocalization } = useAuthPlugin(apiKeyPlugin);
|
|
9
|
+
const preview = `${apiKey.start}${"*".repeat(16)}`;
|
|
10
|
+
const { mutate: deleteApiKey, isPending: isDeleting } = useDeleteApiKey(authClient, {
|
|
11
|
+
onSuccess: () => onOpenChange(false)
|
|
12
|
+
});
|
|
13
|
+
return (_jsx(AlertDialog.Backdrop, { isOpen: isOpen, onOpenChange: onOpenChange, children: _jsx(AlertDialog.Container, { children: _jsxs(AlertDialog.Dialog, { children: [_jsx(AlertDialog.CloseTrigger, {}), _jsxs(AlertDialog.Header, { children: [_jsx(AlertDialog.Icon, { status: "danger", children: _jsx(Key, {}) }), _jsx(AlertDialog.Heading, { children: apiKeyLocalization.deleteApiKey })] }), _jsxs(AlertDialog.Body, { className: "flex flex-col gap-4 overflow-visible", children: [_jsx("p", { className: "text-muted text-sm", children: apiKeyLocalization.deleteApiKeyWarning }), _jsxs(TextField, { value: preview, className: "font-mono text-xs", variant: "secondary", children: [_jsx(Label, { children: apiKey.name || apiKeyLocalization.apiKey }), _jsx(Input, { readOnly: true, className: "font-mono text-xs" })] })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { slot: "close", variant: "tertiary", isDisabled: isDeleting, children: localization.settings.cancel }), _jsxs(Button, { variant: "danger", onPress: () => deleteApiKey({
|
|
14
|
+
keyId: apiKey.id,
|
|
15
|
+
...(organizationId ? { configId: "organization" } : {})
|
|
16
|
+
}), isPending: isDeleting, children: [isDeleting && _jsx(Spinner, { color: "current", size: "sm" }), apiKeyLocalization.deleteApiKey] })] })] }) }) }));
|
|
49
17
|
}
|
|
50
|
-
//#endregion
|
|
51
|
-
export { p as DeleteApiKeyDialog };
|
|
@@ -1,60 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAuth
|
|
3
|
-
import { Check
|
|
4
|
-
import { AlertDialog
|
|
5
|
-
import { useState
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useAuthPlugin } from "@better-auth-ui/react";
|
|
3
|
+
import { Check, Copy, Key } from "@gravity-ui/icons";
|
|
4
|
+
import { AlertDialog, Button, InputGroup, Label, TextField, toast } from "@heroui/react";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { apiKeyPlugin } from "../../../lib/auth/api-key-plugin";
|
|
7
|
+
export function NewApiKeyDialog({ isOpen, onOpenChange, name, secretKey }) {
|
|
8
|
+
const { localization } = useAuth();
|
|
9
|
+
const { localization: apiKeyLocalization } = useAuthPlugin(apiKeyPlugin);
|
|
10
|
+
const [copied, setCopied] = useState(false);
|
|
11
|
+
const copySecretKey = async () => {
|
|
12
|
+
if (!secretKey)
|
|
13
|
+
return;
|
|
14
|
+
try {
|
|
15
|
+
await navigator.clipboard.writeText(secretKey);
|
|
16
|
+
setCopied(true);
|
|
17
|
+
setTimeout(() => setCopied(false), 1500);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
toast.danger(error instanceof Error ? error.message : String(error));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return (_jsx(AlertDialog.Backdrop, { isOpen: isOpen, onOpenChange: onOpenChange, children: _jsx(AlertDialog.Container, { children: _jsxs(AlertDialog.Dialog, { children: [_jsx(AlertDialog.CloseTrigger, {}), _jsxs(AlertDialog.Header, { children: [_jsx(AlertDialog.Icon, { status: "warning", children: _jsx(Key, {}) }), _jsx(AlertDialog.Heading, { children: apiKeyLocalization.newApiKey })] }), _jsxs(AlertDialog.Body, { className: "flex flex-col gap-4 overflow-visible", children: [_jsx("p", { className: "text-muted text-sm", children: apiKeyLocalization.newApiKeyWarning }), _jsxs(TextField, { value: secretKey ?? "", className: "font-mono text-xs", children: [_jsx(Label, { children: name || apiKeyLocalization.apiKey }), _jsxs(InputGroup, { variant: "secondary", children: [_jsx(InputGroup.Input, { readOnly: true, className: "font-mono text-xs" }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": localization.settings.copyToClipboard, size: "sm", variant: "ghost", onPress: copySecretKey, children: copied ? _jsx(Check, {}) : _jsx(Copy, {}) }) })] })] })] }), _jsx(AlertDialog.Footer, { children: _jsx(Button, { slot: "close", children: apiKeyLocalization.dismissNewKey }) })] }) }) }));
|
|
58
24
|
}
|
|
59
|
-
//#endregion
|
|
60
|
-
export { h as NewApiKeyDialog };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CardProps } from "@heroui/react";
|
|
2
|
+
export type OrganizationApiKeysProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
variant?: CardProps["variant"];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* {@link ApiKeys} scoped to the active organization.
|
|
8
|
+
*
|
|
9
|
+
* Hidden for members whose role isn't `owner`. Better Auth's
|
|
10
|
+
* `/organization/has-permission` endpoint isn't usable for `apiKey:*` checks
|
|
11
|
+
* (it doesn't pass `allowCreatorAllPermissions` and the default org AC has no
|
|
12
|
+
* `apiKey` statements), so we gate on role directly.
|
|
13
|
+
*/
|
|
14
|
+
export declare function OrganizationApiKeys({ className, variant }: OrganizationApiKeysProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useActiveOrganization, useAuth, useListOrganizationMembers, useSession } from "@better-auth-ui/react";
|
|
3
|
+
import { ApiKeys } from "./api-keys";
|
|
4
|
+
/**
|
|
5
|
+
* {@link ApiKeys} scoped to the active organization.
|
|
6
|
+
*
|
|
7
|
+
* Hidden for members whose role isn't `owner`. Better Auth's
|
|
8
|
+
* `/organization/has-permission` endpoint isn't usable for `apiKey:*` checks
|
|
9
|
+
* (it doesn't pass `allowCreatorAllPermissions` and the default org AC has no
|
|
10
|
+
* `apiKey` statements), so we gate on role directly.
|
|
11
|
+
*/
|
|
12
|
+
export function OrganizationApiKeys({ className, variant }) {
|
|
13
|
+
const { authClient } = useAuth();
|
|
14
|
+
const { data: session } = useSession(authClient);
|
|
15
|
+
const { data: activeOrganization, isPending: activeOrganizationPending } = useActiveOrganization(authClient);
|
|
16
|
+
const { data: membersData } = useListOrganizationMembers(authClient);
|
|
17
|
+
const canManageApiKeys = membersData?.members.some((member) => member.role === "owner" && member.userId === session?.user.id);
|
|
18
|
+
if (!canManageApiKeys) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (_jsx(ApiKeys, { className: className, variant: variant, organizationId: activeOrganization?.id, isPending: activeOrganizationPending }));
|
|
22
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthClient, AuthProviderProps as AuthProviderPropsPrimitive } from
|
|
1
|
+
import { type AuthClient, type AuthProviderProps as AuthProviderPropsPrimitive } from "@better-auth-ui/react";
|
|
2
2
|
export type AuthProviderProps<TAuthClient = AuthClient> = AuthProviderPropsPrimitive<TAuthClient>;
|
|
3
3
|
/**
|
|
4
4
|
* Heroui-flavored `AuthProvider`. Wraps the primitive provider with a
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AuthProvider as
|
|
3
|
-
import { RouterProvider
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
navigate: (e) => o({ to: e }),
|
|
12
|
-
children: [a, /* @__PURE__ */ r(e, {})]
|
|
13
|
-
})
|
|
14
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AuthProvider as AuthProviderPrimitive } from "@better-auth-ui/react";
|
|
3
|
+
import { RouterProvider } from "@heroui/react";
|
|
4
|
+
import { ErrorToaster } from "./error-toaster";
|
|
5
|
+
/**
|
|
6
|
+
* Heroui-flavored `AuthProvider`. Wraps the primitive provider with a
|
|
7
|
+
* heroui `RouterProvider` and the heroui `ErrorToaster`.
|
|
8
|
+
*/
|
|
9
|
+
export function AuthProvider({ children, navigate, ...config }) {
|
|
10
|
+
return (_jsx(AuthProviderPrimitive, { navigate: navigate, ...config, children: _jsxs(RouterProvider, { navigate: (path) => navigate({ to: path }), children: [children, _jsx(ErrorToaster, {})] }) }));
|
|
15
11
|
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { a as AuthProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AuthView } from
|
|
2
|
-
import { CardProps } from
|
|
3
|
-
import { SocialLayout } from
|
|
1
|
+
import type { AuthView } from "@better-auth-ui/core";
|
|
2
|
+
import type { CardProps } from "@heroui/react";
|
|
3
|
+
import type { SocialLayout } from "./provider-buttons";
|
|
4
4
|
export type AuthProps = {
|
|
5
5
|
className?: string;
|
|
6
6
|
path?: string;
|
|
@@ -1,63 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth } from "@better-auth-ui/react";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { ForgotPassword } from "./forgot-password";
|
|
5
|
+
import { ResetPassword } from "./reset-password";
|
|
6
|
+
import { SignIn } from "./sign-in";
|
|
7
|
+
import { SignOut } from "./sign-out";
|
|
8
|
+
import { SignUp } from "./sign-up";
|
|
9
|
+
/**
|
|
10
|
+
* Built-in views that only make sense when email + password auth is enabled.
|
|
11
|
+
* When it's disabled, the `<Auth>` router redirects these to `signIn` so a
|
|
12
|
+
* plugin's `fallbackViews.auth.signIn` (e.g. magic link) takes over.
|
|
13
|
+
*/
|
|
14
|
+
const PASSWORD_ONLY_VIEWS = ["signUp", "forgotPassword", "resetPassword"];
|
|
15
|
+
const AUTH_VIEWS = {
|
|
16
|
+
signIn: SignIn,
|
|
17
|
+
signOut: SignOut,
|
|
18
|
+
signUp: SignUp,
|
|
19
|
+
forgotPassword: ForgotPassword,
|
|
20
|
+
resetPassword: ResetPassword
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Render the appropriate authentication view based on the provided `view` or `path`.
|
|
24
|
+
*
|
|
25
|
+
* @param path - Route path used to resolve an auth view when `view` is not provided
|
|
26
|
+
* @param socialLayout - Social layout to apply to sign-in/sign-up/magic-link views
|
|
27
|
+
* @param socialPosition - Position for social buttons ("top" or "bottom")
|
|
28
|
+
* @param variant - Variant to apply to the card
|
|
29
|
+
* @param view - Explicit auth view to render (e.g., "signIn", "signUp")
|
|
30
|
+
* @returns The React element for the resolved authentication view
|
|
31
|
+
*/
|
|
32
|
+
export function Auth({ path, socialLayout, socialPosition, view, ...props }) {
|
|
33
|
+
const { basePaths, emailAndPassword, plugins, viewPaths, navigate } = useAuth();
|
|
34
|
+
if (!view && !path) {
|
|
35
|
+
throw new Error("[Better Auth UI] Either `view` or `path` must be provided");
|
|
36
|
+
}
|
|
37
|
+
const authView = view ||
|
|
38
|
+
Object.keys(viewPaths.auth).find((key) => viewPaths.auth[key] === path);
|
|
39
|
+
// When email + password auth is disabled, password-only views (signUp,
|
|
40
|
+
// forgotPassword, resetPassword) have no meaning. Redirect them to signIn,
|
|
41
|
+
// where a plugin's `fallbackViews.auth.signIn` (e.g. magic link) takes
|
|
42
|
+
// over as the primary entry point.
|
|
43
|
+
const shouldRedirectToSignIn = !emailAndPassword?.enabled &&
|
|
44
|
+
authView &&
|
|
45
|
+
PASSWORD_ONLY_VIEWS.includes(authView);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (shouldRedirectToSignIn) {
|
|
48
|
+
navigate({
|
|
49
|
+
to: `${basePaths.auth}/${viewPaths.auth.signIn}`,
|
|
50
|
+
replace: true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, [shouldRedirectToSignIn, navigate, basePaths.auth, viewPaths.auth.signIn]);
|
|
54
|
+
if (shouldRedirectToSignIn) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
// 1. Plugin overrides (`views.auth[currentView]`) — first plugin wins,
|
|
58
|
+
// including over built-in views. Resolves the view key from `view`,
|
|
59
|
+
// then `authView` (built-in path match), then plugin-introduced paths
|
|
60
|
+
// (e.g. `magicLink` → `/auth/magic-link`).
|
|
61
|
+
for (const plugin of plugins) {
|
|
62
|
+
const pluginAuthPaths = plugin.viewPaths?.auth;
|
|
63
|
+
const pluginView = view ??
|
|
64
|
+
authView ??
|
|
65
|
+
(pluginAuthPaths &&
|
|
66
|
+
Object.keys(pluginAuthPaths).find((key) => pluginAuthPaths[key] === path));
|
|
67
|
+
if (!pluginView)
|
|
68
|
+
continue;
|
|
69
|
+
const PluginView = plugin.views?.auth?.[pluginView];
|
|
70
|
+
if (!PluginView)
|
|
71
|
+
continue;
|
|
72
|
+
return (_jsx(PluginView, { socialLayout: socialLayout, socialPosition: socialPosition, ...props }));
|
|
73
|
+
}
|
|
74
|
+
// 2. Plugin fallbacks — only when the built-in `signIn` isn't viable
|
|
75
|
+
// (password auth is off). Used by `magicLinkPlugin` to render the
|
|
76
|
+
// magic-link form as the primary passwordless sign-in surface.
|
|
77
|
+
if (authView === "signIn" && !emailAndPassword?.enabled) {
|
|
78
|
+
const Fallback = plugins.find((plugin) => plugin.fallbackViews?.auth?.signIn)?.fallbackViews?.auth?.signIn;
|
|
79
|
+
if (Fallback) {
|
|
80
|
+
return (_jsx(Fallback, { socialLayout: socialLayout, socialPosition: socialPosition, ...props }));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const AuthView = authView ? AUTH_VIEWS[authView] : undefined;
|
|
84
|
+
if (!AuthView) {
|
|
85
|
+
throw new Error(`[Better Auth UI] Unknown view "${authView}". Valid views are: ${Object.keys(AUTH_VIEWS).join(", ")}`);
|
|
86
|
+
}
|
|
87
|
+
return (_jsx(AuthView, { socialLayout: socialLayout, socialPosition: socialPosition, ...props }));
|
|
61
88
|
}
|
|
62
|
-
//#endregion
|
|
63
|
-
export { u as Auth };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CardProps } from
|
|
2
|
-
import { ComponentProps } from
|
|
1
|
+
import { type CardProps } from "@heroui/react";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
3
|
export type DangerZoneProps = {
|
|
4
4
|
className?: string;
|
|
5
5
|
variant?: CardProps["variant"];
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* Renders the danger zone heading and {@link
|
|
8
|
+
* Renders the danger zone heading and {@link DeleteAccount}.
|
|
9
9
|
* Registered as a `securityCard` by `deleteUserPlugin()`; gate by registering the plugin.
|
|
10
10
|
*/
|
|
11
11
|
export declare function DangerZone({ className, variant, ...props }: DangerZoneProps & ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|