@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.
Files changed (280) hide show
  1. package/dist/components/auth/additional-field.d.ts +2 -2
  2. package/dist/components/auth/additional-field.js +133 -266
  3. package/dist/components/auth/api-key/api-key-skeleton.js +4 -20
  4. package/dist/components/auth/api-key/api-key.d.ts +6 -2
  5. package/dist/components/auth/api-key/api-key.js +16 -54
  6. package/dist/components/auth/api-key/api-keys-empty.d.ts +3 -1
  7. package/dist/components/auth/api-key/api-keys-empty.js +8 -34
  8. package/dist/components/auth/api-key/api-keys.d.ts +10 -2
  9. package/dist/components/auth/api-key/api-keys.js +21 -40
  10. package/dist/components/auth/api-key/create-api-key-dialog.d.ts +3 -1
  11. package/dist/components/auth/api-key/create-api-key-dialog.js +43 -73
  12. package/dist/components/auth/api-key/delete-api-key-dialog.d.ts +4 -2
  13. package/dist/components/auth/api-key/delete-api-key-dialog.js +16 -50
  14. package/dist/components/auth/api-key/new-api-key-dialog.js +23 -59
  15. package/dist/components/auth/api-key/organization-api-keys.d.ts +14 -0
  16. package/dist/components/auth/api-key/organization-api-keys.js +22 -0
  17. package/dist/components/auth/auth-provider.d.ts +1 -1
  18. package/dist/components/auth/auth-provider.js +10 -16
  19. package/dist/components/auth/auth.d.ts +3 -3
  20. package/dist/components/auth/auth.js +86 -61
  21. package/dist/components/auth/delete-user/danger-zone.d.ts +3 -3
  22. package/dist/components/auth/delete-user/danger-zone.js +11 -17
  23. package/dist/components/auth/delete-user/delete-account.d.ts +9 -0
  24. package/dist/components/auth/delete-user/delete-account.js +50 -0
  25. package/dist/components/auth/email/email-changed-email.d.ts +2 -2
  26. package/dist/components/auth/email/email-changed-email.js +22 -29
  27. package/dist/components/auth/email/email-verification-email.d.ts +2 -2
  28. package/dist/components/auth/email/email-verification-email.js +22 -29
  29. package/dist/components/auth/email/magic-link-email.d.ts +2 -2
  30. package/dist/components/auth/email/magic-link-email.js +22 -29
  31. package/dist/components/auth/email/new-device-email.d.ts +2 -2
  32. package/dist/components/auth/email/new-device-email.js +22 -29
  33. package/dist/components/auth/email/organization-invitation-email.d.ts +3 -0
  34. package/dist/components/auth/email/organization-invitation-email.js +23 -0
  35. package/dist/components/auth/email/otp-email.d.ts +2 -2
  36. package/dist/components/auth/email/otp-email.js +21 -28
  37. package/dist/components/auth/email/password-changed-email.d.ts +2 -2
  38. package/dist/components/auth/email/password-changed-email.js +22 -29
  39. package/dist/components/auth/email/reset-password-email.d.ts +2 -2
  40. package/dist/components/auth/email/reset-password-email.js +22 -29
  41. package/dist/components/auth/error-toaster.js +32 -16
  42. package/dist/components/auth/field-separator.d.ts +1 -1
  43. package/dist/components/auth/field-separator.js +4 -17
  44. package/dist/components/auth/forgot-password.d.ts +1 -1
  45. package/dist/components/auth/forgot-password.js +36 -88
  46. package/dist/components/auth/magic-link/magic-link-button.d.ts +1 -1
  47. package/dist/components/auth/magic-link/magic-link-button.js +33 -19
  48. package/dist/components/auth/magic-link/magic-link.d.ts +2 -2
  49. package/dist/components/auth/magic-link/magic-link.js +39 -86
  50. package/dist/components/auth/multi-session/manage-account.d.ts +1 -1
  51. package/dist/components/auth/multi-session/manage-account.js +32 -48
  52. package/dist/components/auth/multi-session/manage-accounts.d.ts +1 -1
  53. package/dist/components/auth/multi-session/manage-accounts.js +32 -33
  54. package/dist/components/auth/multi-session/switch-account-submenu-content.d.ts +3 -1
  55. package/dist/components/auth/multi-session/switch-account-submenu-content.js +24 -27
  56. package/dist/components/auth/multi-session/switch-account-submenu-item.d.ts +3 -2
  57. package/dist/components/auth/multi-session/switch-account-submenu-item.js +16 -19
  58. package/dist/components/auth/multi-session/switch-account-submenu.d.ts +2 -1
  59. package/dist/components/auth/multi-session/switch-account-submenu.js +23 -23
  60. package/dist/components/auth/organization/change-organization-logo.d.ts +4 -0
  61. package/dist/components/auth/organization/change-organization-logo.js +69 -0
  62. package/dist/components/auth/organization/create-organization-dialog.d.ts +13 -0
  63. package/dist/components/auth/organization/create-organization-dialog.js +37 -0
  64. package/dist/components/auth/organization/delete-organization-dialog.d.ts +7 -0
  65. package/dist/components/auth/organization/delete-organization-dialog.js +25 -0
  66. package/dist/components/auth/organization/delete-organization-skeleton.d.ts +4 -0
  67. package/dist/components/auth/organization/delete-organization-skeleton.js +8 -0
  68. package/dist/components/auth/organization/delete-organization.d.ts +5 -0
  69. package/dist/components/auth/organization/delete-organization.js +27 -0
  70. package/dist/components/auth/organization/invite-member-dialog.d.ts +13 -0
  71. package/dist/components/auth/organization/invite-member-dialog.js +47 -0
  72. package/dist/components/auth/organization/leave-organization-dialog.d.ts +7 -0
  73. package/dist/components/auth/organization/leave-organization-dialog.js +21 -0
  74. package/dist/components/auth/organization/leave-organization.d.ts +4 -0
  75. package/dist/components/auth/organization/leave-organization.js +16 -0
  76. package/dist/components/auth/organization/organization-danger-zone.d.ts +16 -0
  77. package/dist/components/auth/organization/organization-danger-zone.js +23 -0
  78. package/dist/components/auth/organization/organization-invitation-row-skeleton.d.ts +5 -0
  79. package/dist/components/auth/organization/organization-invitation-row-skeleton.js +9 -0
  80. package/dist/components/auth/organization/organization-invitation-row.d.ts +5 -0
  81. package/dist/components/auth/organization/organization-invitation-row.js +31 -0
  82. package/dist/components/auth/organization/organization-invitations-empty.d.ts +8 -0
  83. package/dist/components/auth/organization/organization-invitations-empty.js +13 -0
  84. package/dist/components/auth/organization/organization-invitations.d.ts +9 -0
  85. package/dist/components/auth/organization/organization-invitations.js +66 -0
  86. package/dist/components/auth/organization/organization-logo.d.ts +15 -0
  87. package/dist/components/auth/organization/organization-logo.js +14 -0
  88. package/dist/components/auth/organization/organization-member-row-skeleton.d.ts +4 -0
  89. package/dist/components/auth/organization/organization-member-row-skeleton.js +9 -0
  90. package/dist/components/auth/organization/organization-member-row.d.ts +9 -0
  91. package/dist/components/auth/organization/organization-member-row.js +34 -0
  92. package/dist/components/auth/organization/organization-members.d.ts +9 -0
  93. package/dist/components/auth/organization/organization-members.js +67 -0
  94. package/dist/components/auth/organization/organization-people.d.ts +10 -0
  95. package/dist/components/auth/organization/organization-people.js +11 -0
  96. package/dist/components/auth/organization/organization-profile.d.ts +9 -0
  97. package/dist/components/auth/organization/organization-profile.js +34 -0
  98. package/dist/components/auth/organization/organization-row.d.ts +8 -0
  99. package/dist/components/auth/organization/organization-row.js +31 -0
  100. package/dist/components/auth/organization/organization-settings.d.ts +12 -0
  101. package/dist/components/auth/organization/organization-settings.js +13 -0
  102. package/dist/components/auth/organization/organization-switcher.d.ts +20 -0
  103. package/dist/components/auth/organization/organization-switcher.js +48 -0
  104. package/dist/components/auth/organization/organization-view-skeleton.d.ts +6 -0
  105. package/dist/components/auth/organization/organization-view-skeleton.js +9 -0
  106. package/dist/components/auth/organization/organization-view.d.ts +15 -0
  107. package/dist/components/auth/organization/organization-view.js +31 -0
  108. package/dist/components/auth/organization/organization.d.ts +17 -0
  109. package/dist/components/auth/organization/organization.js +60 -0
  110. package/dist/components/auth/organization/organizations-empty.d.ts +4 -0
  111. package/dist/components/auth/organization/organizations-empty.js +9 -0
  112. package/dist/components/auth/organization/organizations-settings.d.ts +17 -0
  113. package/dist/components/auth/organization/organizations-settings.js +17 -0
  114. package/dist/components/auth/organization/organizations.d.ts +10 -0
  115. package/dist/components/auth/organization/organizations.js +21 -0
  116. package/dist/components/auth/organization/remove-member-dialog.d.ts +9 -0
  117. package/dist/components/auth/organization/remove-member-dialog.js +20 -0
  118. package/dist/components/auth/organization/slug-field.d.ts +19 -0
  119. package/dist/components/auth/organization/slug-field.js +38 -0
  120. package/dist/components/auth/organization/user-invitation-row-skeleton.d.ts +4 -0
  121. package/dist/components/auth/organization/user-invitation-row-skeleton.js +8 -0
  122. package/dist/components/auth/organization/user-invitation-row.d.ts +10 -0
  123. package/dist/components/auth/organization/user-invitation-row.js +22 -0
  124. package/dist/components/auth/organization/user-invitations-empty.d.ts +4 -0
  125. package/dist/components/auth/organization/user-invitations-empty.js +12 -0
  126. package/dist/components/auth/organization/user-invitations.d.ts +10 -0
  127. package/dist/components/auth/organization/user-invitations.js +18 -0
  128. package/dist/components/auth/passkey/add-passkey-dialog.d.ts +5 -0
  129. package/dist/components/auth/passkey/add-passkey-dialog.js +22 -0
  130. package/dist/components/auth/passkey/delete-passkey-dialog.d.ts +11 -0
  131. package/dist/components/auth/passkey/delete-passkey-dialog.js +14 -0
  132. package/dist/components/auth/passkey/passkey-button.d.ts +1 -1
  133. package/dist/components/auth/passkey/passkey-button.js +24 -23
  134. package/dist/components/auth/passkey/passkey-skeleton.d.ts +1 -0
  135. package/dist/components/auth/passkey/passkey-skeleton.js +5 -0
  136. package/dist/components/auth/passkey/passkey.d.ts +2 -5
  137. package/dist/components/auth/passkey/passkey.js +16 -44
  138. package/dist/components/auth/passkey/passkeys-empty.d.ts +4 -0
  139. package/dist/components/auth/passkey/passkeys-empty.js +9 -0
  140. package/dist/components/auth/passkey/passkeys.d.ts +1 -1
  141. package/dist/components/auth/passkey/passkeys.js +15 -105
  142. package/dist/components/auth/provider-button.d.ts +2 -2
  143. package/dist/components/auth/provider-button.js +28 -24
  144. package/dist/components/auth/provider-buttons.js +28 -18
  145. package/dist/components/auth/reset-password.d.ts +1 -1
  146. package/dist/components/auth/reset-password.js +56 -146
  147. package/dist/components/auth/settings/account/account-settings.d.ts +2 -2
  148. package/dist/components/auth/settings/account/account-settings.js +21 -19
  149. package/dist/components/auth/settings/account/change-avatar.js +53 -88
  150. package/dist/components/auth/settings/account/change-email.d.ts +1 -1
  151. package/dist/components/auth/settings/account/change-email.js +27 -53
  152. package/dist/components/auth/settings/account/user-profile.d.ts +1 -1
  153. package/dist/components/auth/settings/account/user-profile.js +64 -85
  154. package/dist/components/auth/settings/security/active-session.d.ts +1 -1
  155. package/dist/components/auth/settings/security/active-session.js +50 -57
  156. package/dist/components/auth/settings/security/active-sessions.d.ts +1 -1
  157. package/dist/components/auth/settings/security/active-sessions.js +21 -32
  158. package/dist/components/auth/settings/security/change-password.d.ts +1 -1
  159. package/dist/components/auth/settings/security/change-password.js +76 -186
  160. package/dist/components/auth/settings/security/linked-account.d.ts +1 -1
  161. package/dist/components/auth/settings/security/linked-account.js +37 -55
  162. package/dist/components/auth/settings/security/linked-accounts.d.ts +1 -1
  163. package/dist/components/auth/settings/security/linked-accounts.js +34 -43
  164. package/dist/components/auth/settings/security/security-settings.d.ts +2 -2
  165. package/dist/components/auth/settings/security/security-settings.js +19 -21
  166. package/dist/components/auth/settings/settings.d.ts +4 -4
  167. package/dist/components/auth/settings/settings.js +52 -44
  168. package/dist/components/auth/sign-in.d.ts +2 -2
  169. package/dist/components/auth/sign-in.js +63 -132
  170. package/dist/components/auth/sign-out.js +32 -26
  171. package/dist/components/auth/sign-up.d.ts +2 -2
  172. package/dist/components/auth/sign-up.js +97 -211
  173. package/dist/components/auth/theme/appearance.d.ts +1 -1
  174. package/dist/components/auth/theme/appearance.js +23 -71
  175. package/dist/components/auth/theme/theme-toggle-item.js +56 -61
  176. package/dist/components/auth/user/user-avatar.d.ts +4 -4
  177. package/dist/components/auth/user/user-avatar.js +31 -28
  178. package/dist/components/auth/user/user-button.d.ts +6 -7
  179. package/dist/components/auth/user/user-button.js +38 -72
  180. package/dist/components/auth/user/user-view.d.ts +13 -7
  181. package/dist/components/auth/user/user-view.js +26 -36
  182. package/dist/components/auth/username/sign-in-username.d.ts +2 -2
  183. package/dist/components/auth/username/sign-in-username.js +87 -147
  184. package/dist/components/auth/username/username-field.d.ts +1 -1
  185. package/dist/components/auth/username/username-field.js +44 -52
  186. package/dist/email.d.ts +8 -7
  187. package/dist/email.js +8 -8
  188. package/dist/index.d.ts +21 -21
  189. package/dist/index.js +21 -22
  190. package/dist/lib/auth/api-key-plugin.d.ts +7 -4
  191. package/dist/lib/auth/api-key-plugin.js +12 -10
  192. package/dist/lib/auth/auth-plugin.d.ts +10 -6
  193. package/dist/lib/auth/auth-plugin.js +1 -0
  194. package/dist/lib/auth/delete-user-plugin.d.ts +6 -6
  195. package/dist/lib/auth/delete-user-plugin.js +6 -9
  196. package/dist/lib/auth/magic-link-plugin.d.ts +5 -5
  197. package/dist/lib/auth/magic-link-plugin.js +17 -12
  198. package/dist/lib/auth/multi-session-plugin.d.ts +5 -5
  199. package/dist/lib/auth/multi-session-plugin.js +8 -11
  200. package/dist/lib/auth/organization-plugin.d.ts +37 -0
  201. package/dist/lib/auth/organization-plugin.js +19 -0
  202. package/dist/lib/auth/passkey-plugin.d.ts +9 -6
  203. package/dist/lib/auth/passkey-plugin.js +8 -11
  204. package/dist/lib/auth/theme-plugin.d.ts +6 -6
  205. package/dist/lib/auth/theme-plugin.js +25 -22
  206. package/dist/lib/auth/username-plugin.d.ts +11 -11
  207. package/dist/lib/auth/username-plugin.js +18 -17
  208. package/dist/plugins.d.ts +46 -22
  209. package/dist/plugins.js +47 -22
  210. package/package.json +25 -19
  211. package/src/components/auth/api-key/api-key.tsx +25 -16
  212. package/src/components/auth/api-key/api-keys-empty.tsx +8 -4
  213. package/src/components/auth/api-key/api-keys.tsx +52 -14
  214. package/src/components/auth/api-key/create-api-key-dialog.tsx +17 -4
  215. package/src/components/auth/api-key/delete-api-key-dialog.tsx +10 -2
  216. package/src/components/auth/api-key/organization-api-keys.tsx +55 -0
  217. package/src/components/auth/delete-user/danger-zone.tsx +3 -3
  218. package/src/components/auth/delete-user/{delete-user.tsx → delete-account.tsx} +9 -9
  219. package/src/components/auth/email/organization-invitation-email.tsx +38 -0
  220. package/src/components/auth/error-toaster.tsx +28 -10
  221. package/src/components/auth/forgot-password.tsx +10 -2
  222. package/src/components/auth/multi-session/manage-accounts.tsx +1 -1
  223. package/src/components/auth/multi-session/switch-account-submenu-content.tsx +7 -2
  224. package/src/components/auth/multi-session/switch-account-submenu-item.tsx +4 -2
  225. package/src/components/auth/multi-session/switch-account-submenu.tsx +8 -4
  226. package/src/components/auth/organization/change-organization-logo.tsx +171 -0
  227. package/src/components/auth/organization/create-organization-dialog.tsx +133 -0
  228. package/src/components/auth/organization/delete-organization-dialog.tsx +97 -0
  229. package/src/components/auth/organization/delete-organization-skeleton.tsx +17 -0
  230. package/src/components/auth/organization/delete-organization.tsx +77 -0
  231. package/src/components/auth/organization/invite-member-dialog.tsx +177 -0
  232. package/src/components/auth/organization/leave-organization-dialog.tsx +95 -0
  233. package/src/components/auth/organization/leave-organization.tsx +59 -0
  234. package/src/components/auth/organization/organization-danger-zone.tsx +68 -0
  235. package/src/components/auth/organization/organization-invitation-row-skeleton.tsx +29 -0
  236. package/src/components/auth/organization/organization-invitation-row.tsx +97 -0
  237. package/src/components/auth/organization/organization-invitations-empty.tsx +39 -0
  238. package/src/components/auth/organization/organization-invitations.tsx +351 -0
  239. package/src/components/auth/organization/organization-logo.tsx +64 -0
  240. package/src/components/auth/organization/organization-member-row-skeleton.tsx +24 -0
  241. package/src/components/auth/organization/organization-member-row.tsx +157 -0
  242. package/src/components/auth/organization/organization-members.tsx +284 -0
  243. package/src/components/auth/organization/organization-people.tsx +26 -0
  244. package/src/components/auth/organization/organization-profile.tsx +141 -0
  245. package/src/components/auth/organization/organization-row.tsx +66 -0
  246. package/src/components/auth/organization/organization-settings.tsx +38 -0
  247. package/src/components/auth/organization/organization-switcher.tsx +233 -0
  248. package/src/components/auth/organization/organization-view-skeleton.tsx +36 -0
  249. package/src/components/auth/organization/organization-view.tsx +109 -0
  250. package/src/components/auth/organization/organization.tsx +162 -0
  251. package/src/components/auth/organization/organizations-empty.tsx +35 -0
  252. package/src/components/auth/organization/organizations-settings.tsx +36 -0
  253. package/src/components/auth/organization/organizations.tsx +80 -0
  254. package/src/components/auth/organization/remove-member-dialog.tsx +95 -0
  255. package/src/components/auth/organization/slug-field.tsx +111 -0
  256. package/src/components/auth/organization/user-invitation-row-skeleton.tsx +17 -0
  257. package/src/components/auth/organization/user-invitation-row.tsx +90 -0
  258. package/src/components/auth/organization/user-invitations-empty.tsx +30 -0
  259. package/src/components/auth/organization/user-invitations.tsx +59 -0
  260. package/src/components/auth/passkey/add-passkey-dialog.tsx +109 -0
  261. package/src/components/auth/passkey/delete-passkey-dialog.tsx +95 -0
  262. package/src/components/auth/passkey/passkey-skeleton.tsx +16 -0
  263. package/src/components/auth/passkey/passkey.tsx +23 -22
  264. package/src/components/auth/passkey/passkeys-empty.tsx +35 -0
  265. package/src/components/auth/passkey/passkeys.tsx +33 -154
  266. package/src/components/auth/settings/account/change-email.tsx +1 -1
  267. package/src/components/auth/settings/account/user-profile.tsx +5 -5
  268. package/src/components/auth/settings/security/active-sessions.tsx +6 -4
  269. package/src/components/auth/settings/security/linked-accounts.tsx +2 -2
  270. package/src/components/auth/settings/settings.tsx +77 -14
  271. package/src/components/auth/user/user-avatar.tsx +4 -1
  272. package/src/components/auth/user/user-button.tsx +14 -11
  273. package/src/components/auth/user/user-view.tsx +32 -12
  274. package/src/email.ts +1 -0
  275. package/src/lib/auth/api-key-plugin.ts +10 -4
  276. package/src/lib/auth/auth-plugin.ts +6 -1
  277. package/src/lib/auth/organization-plugin.tsx +32 -0
  278. package/src/plugins.ts +25 -1
  279. package/dist/components/auth/delete-user/delete-user.d.ts +0 -9
  280. package/dist/components/auth/delete-user/delete-user.js +0 -95
@@ -1,41 +1,22 @@
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
- });
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 { 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");
20
- C(t ? { name: t.trim() } : 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
- })] });
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 '@better-auth-ui/react';
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 { 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
- });
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 { 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
- });
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 '@better-auth-ui/react';
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 { ErrorToaster as e } from "./error-toaster.js";
2
- import { AuthProvider as t } from "@better-auth-ui/react";
3
- import { RouterProvider as n } from "@heroui/react";
4
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
- //#region src/components/auth/auth-provider.tsx
6
- function a({ children: a, navigate: o, ...s }) {
7
- return /* @__PURE__ */ r(t, {
8
- navigate: o,
9
- ...s,
10
- children: /* @__PURE__ */ i(n, {
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 '@better-auth-ui/core';
2
- import { CardProps } from '@heroui/react';
3
- import { SocialLayout } from './provider-buttons';
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 { ForgotPassword as e } from "./forgot-password.js";
2
- import { ResetPassword as t } from "./reset-password.js";
3
- import { SignIn as n } from "./sign-in.js";
4
- import { SignOut as r } from "./sign-out.js";
5
- import { SignUp as i } from "./sign-up.js";
6
- import { useAuth as a } from "@better-auth-ui/react";
7
- import { useEffect as o } from "react";
8
- import { jsx as s } from "react/jsx-runtime";
9
- //#region src/components/auth/auth.tsx
10
- var c = [
11
- "signUp",
12
- "forgotPassword",
13
- "resetPassword"
14
- ], l = {
15
- signIn: n,
16
- signOut: r,
17
- signUp: i,
18
- forgotPassword: e,
19
- resetPassword: t
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
- function u({ path: e, socialLayout: t, socialPosition: n, view: r, ...i }) {
22
- let { basePaths: u, emailAndPassword: d, plugins: f, viewPaths: p, navigate: m } = a();
23
- if (!r && !e) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
24
- let h = r || Object.keys(p.auth).find((t) => p.auth[t] === e), g = !d?.enabled && h && c.includes(h);
25
- if (o(() => {
26
- g && m({
27
- to: `${u.auth}/${p.auth.signIn}`,
28
- replace: !0
29
- });
30
- }, [
31
- g,
32
- m,
33
- u.auth,
34
- p.auth.signIn
35
- ]), g) return null;
36
- for (let a of f) {
37
- let o = a.viewPaths?.auth, c = r ?? h ?? (o && Object.keys(o).find((t) => o[t] === e));
38
- if (!c) continue;
39
- let l = a.views?.auth?.[c];
40
- if (l) return /* @__PURE__ */ s(l, {
41
- socialLayout: t,
42
- socialPosition: n,
43
- ...i
44
- });
45
- }
46
- if (h === "signIn" && !d?.enabled) {
47
- let e = f.find((e) => e.fallbackViews?.auth?.signIn)?.fallbackViews?.auth?.signIn;
48
- if (e) return /* @__PURE__ */ s(e, {
49
- socialLayout: t,
50
- socialPosition: n,
51
- ...i
52
- });
53
- }
54
- let _ = h ? l[h] : void 0;
55
- if (!_) throw Error(`[Better Auth UI] Unknown view "${h}". Valid views are: ${Object.keys(l).join(", ")}`);
56
- return /* @__PURE__ */ s(_, {
57
- socialLayout: t,
58
- socialPosition: n,
59
- ...i
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 '@heroui/react';
2
- import { ComponentProps } from 'react';
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 DeleteUser}.
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;