better-auth-ui 3.2.5

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 (226) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/auth-hooks-IOEvlYYv.d.cts +6966 -0
  4. package/dist/auth-hooks-IOEvlYYv.d.ts +6966 -0
  5. package/dist/auth-mutators-DdqOmQ32.d.cts +29 -0
  6. package/dist/auth-mutators-DdqOmQ32.d.ts +29 -0
  7. package/dist/auth-ui-provider-BsH3xJDw.d.ts +697 -0
  8. package/dist/auth-ui-provider-DhZfncd3.d.cts +697 -0
  9. package/dist/chunk-BDFQSFBU.js +750 -0
  10. package/dist/chunk-CRAHKL2C.cjs +801 -0
  11. package/dist/chunk-MJPOA6PK.js +801 -0
  12. package/dist/chunk-SV64DXGW.cjs +750 -0
  13. package/dist/index.cjs +12618 -0
  14. package/dist/index.d.cts +771 -0
  15. package/dist/index.d.ts +771 -0
  16. package/dist/index.js +12618 -0
  17. package/dist/instantdb.cjs +189 -0
  18. package/dist/instantdb.d.cts +36 -0
  19. package/dist/instantdb.d.ts +36 -0
  20. package/dist/instantdb.js +189 -0
  21. package/dist/metafile-cjs.json +1 -0
  22. package/dist/metafile-esm.json +1 -0
  23. package/dist/server.cjs +194 -0
  24. package/dist/server.d.cts +35 -0
  25. package/dist/server.d.ts +35 -0
  26. package/dist/server.js +194 -0
  27. package/dist/style.css +1 -0
  28. package/dist/tanstack.cjs +153 -0
  29. package/dist/tanstack.d.cts +18 -0
  30. package/dist/tanstack.d.ts +18 -0
  31. package/dist/tanstack.js +153 -0
  32. package/dist/triplit.cjs +201 -0
  33. package/dist/triplit.d.cts +31 -0
  34. package/dist/triplit.d.ts +31 -0
  35. package/dist/triplit.js +201 -0
  36. package/dist/utils-C5R37WDe.d.cts +3 -0
  37. package/dist/utils-C5R37WDe.d.ts +3 -0
  38. package/dist/view-paths-CHSJf5dv.d.cts +645 -0
  39. package/dist/view-paths-CHSJf5dv.d.ts +645 -0
  40. package/package.json +156 -0
  41. package/src/components/account/account-view.tsx +220 -0
  42. package/src/components/auth/auth-callback.tsx +36 -0
  43. package/src/components/auth/auth-form.tsx +277 -0
  44. package/src/components/auth/auth-view.tsx +389 -0
  45. package/src/components/auth/email-otp-button.tsx +53 -0
  46. package/src/components/auth/forms/email-otp-form.tsx +288 -0
  47. package/src/components/auth/forms/forgot-password-form.tsx +168 -0
  48. package/src/components/auth/forms/magic-link-form.tsx +191 -0
  49. package/src/components/auth/forms/recover-account-form.tsx +138 -0
  50. package/src/components/auth/forms/reset-password-form.tsx +215 -0
  51. package/src/components/auth/forms/sign-in-form.tsx +289 -0
  52. package/src/components/auth/forms/sign-up-form.tsx +788 -0
  53. package/src/components/auth/forms/two-factor-form.tsx +372 -0
  54. package/src/components/auth/magic-link-button.tsx +54 -0
  55. package/src/components/auth/one-tap.tsx +48 -0
  56. package/src/components/auth/otp-input-group.tsx +65 -0
  57. package/src/components/auth/passkey-button.tsx +85 -0
  58. package/src/components/auth/provider-button.tsx +141 -0
  59. package/src/components/auth/sign-out.tsx +25 -0
  60. package/src/components/auth-loading.tsx +21 -0
  61. package/src/components/captcha/captcha.tsx +79 -0
  62. package/src/components/captcha/recaptcha-badge.tsx +61 -0
  63. package/src/components/captcha/recaptcha-v2.tsx +58 -0
  64. package/src/components/captcha/recaptcha-v3.tsx +73 -0
  65. package/src/components/email/email-template.tsx +216 -0
  66. package/src/components/form-error.tsx +27 -0
  67. package/src/components/organization/accept-invitation-card.tsx +362 -0
  68. package/src/components/organization/create-organization-dialog.tsx +395 -0
  69. package/src/components/organization/delete-organization-card.tsx +101 -0
  70. package/src/components/organization/delete-organization-dialog.tsx +209 -0
  71. package/src/components/organization/invitation-cell.tsx +156 -0
  72. package/src/components/organization/invite-member-dialog.tsx +258 -0
  73. package/src/components/organization/leave-organization-dialog.tsx +150 -0
  74. package/src/components/organization/member-cell.tsx +187 -0
  75. package/src/components/organization/organization-cell-view.tsx +122 -0
  76. package/src/components/organization/organization-cell.tsx +154 -0
  77. package/src/components/organization/organization-invitations-card.tsx +94 -0
  78. package/src/components/organization/organization-logo-card.tsx +308 -0
  79. package/src/components/organization/organization-logo.tsx +120 -0
  80. package/src/components/organization/organization-members-card.tsx +155 -0
  81. package/src/components/organization/organization-name-card.tsx +204 -0
  82. package/src/components/organization/organization-settings-cards.tsx +67 -0
  83. package/src/components/organization/organization-slug-card.tsx +223 -0
  84. package/src/components/organization/organization-switcher.tsx +512 -0
  85. package/src/components/organization/organization-view.tsx +228 -0
  86. package/src/components/organization/organizations-card.tsx +72 -0
  87. package/src/components/organization/personal-account-view.tsx +115 -0
  88. package/src/components/organization/remove-member-dialog.tsx +144 -0
  89. package/src/components/organization/update-member-role-dialog.tsx +213 -0
  90. package/src/components/organization/user-invitations-card.tsx +238 -0
  91. package/src/components/password-input.tsx +56 -0
  92. package/src/components/provider-icons.tsx +385 -0
  93. package/src/components/redirect-to-sign-in.tsx +16 -0
  94. package/src/components/redirect-to-sign-up.tsx +16 -0
  95. package/src/components/settings/account/account-cell.tsx +158 -0
  96. package/src/components/settings/account/accounts-card.tsx +75 -0
  97. package/src/components/settings/account/delete-account-card.tsx +65 -0
  98. package/src/components/settings/account/delete-account-dialog.tsx +231 -0
  99. package/src/components/settings/account/update-avatar-card.tsx +198 -0
  100. package/src/components/settings/account/update-field-card.tsx +282 -0
  101. package/src/components/settings/account/update-name-card.tsx +39 -0
  102. package/src/components/settings/account/update-username-card.tsx +42 -0
  103. package/src/components/settings/account-settings-cards.tsx +123 -0
  104. package/src/components/settings/api-key/api-key-cell.tsx +108 -0
  105. package/src/components/settings/api-key/api-key-delete-dialog.tsx +162 -0
  106. package/src/components/settings/api-key/api-key-display-dialog.tsx +110 -0
  107. package/src/components/settings/api-key/api-keys-card.tsx +98 -0
  108. package/src/components/settings/api-key/create-api-key-dialog.tsx +376 -0
  109. package/src/components/settings/passkey/passkey-cell.tsx +113 -0
  110. package/src/components/settings/passkey/passkeys-card.tsx +111 -0
  111. package/src/components/settings/providers/provider-cell.tsx +152 -0
  112. package/src/components/settings/providers/providers-card.tsx +108 -0
  113. package/src/components/settings/security/change-email-card.tsx +200 -0
  114. package/src/components/settings/security/change-password-card.tsx +326 -0
  115. package/src/components/settings/security/session-cell.tsx +120 -0
  116. package/src/components/settings/security/sessions-card.tsx +58 -0
  117. package/src/components/settings/security-settings-cards.tsx +111 -0
  118. package/src/components/settings/shared/session-freshness-dialog.tsx +97 -0
  119. package/src/components/settings/shared/settings-action-button.tsx +51 -0
  120. package/src/components/settings/shared/settings-card-footer.tsx +94 -0
  121. package/src/components/settings/shared/settings-card-header.tsx +67 -0
  122. package/src/components/settings/shared/settings-card.tsx +106 -0
  123. package/src/components/settings/skeletons/input-field-skeleton.tsx +18 -0
  124. package/src/components/settings/skeletons/settings-cell-skeleton.tsx +37 -0
  125. package/src/components/settings/two-factor/backup-codes-dialog.tsx +113 -0
  126. package/src/components/settings/two-factor/two-factor-card.tsx +63 -0
  127. package/src/components/settings/two-factor/two-factor-password-dialog.tsx +226 -0
  128. package/src/components/signed-in.tsx +20 -0
  129. package/src/components/signed-out.tsx +20 -0
  130. package/src/components/ui/alert.tsx +66 -0
  131. package/src/components/ui/avatar.tsx +53 -0
  132. package/src/components/ui/button.tsx +59 -0
  133. package/src/components/ui/card.tsx +92 -0
  134. package/src/components/ui/checkbox.tsx +32 -0
  135. package/src/components/ui/dialog.tsx +143 -0
  136. package/src/components/ui/drawer.tsx +135 -0
  137. package/src/components/ui/dropdown-menu.tsx +257 -0
  138. package/src/components/ui/form.tsx +167 -0
  139. package/src/components/ui/input-otp.tsx +77 -0
  140. package/src/components/ui/input.tsx +21 -0
  141. package/src/components/ui/label.tsx +24 -0
  142. package/src/components/ui/select.tsx +185 -0
  143. package/src/components/ui/separator.tsx +28 -0
  144. package/src/components/ui/skeleton.tsx +13 -0
  145. package/src/components/ui/tabs.tsx +66 -0
  146. package/src/components/ui/textarea.tsx +18 -0
  147. package/src/components/user-avatar.tsx +147 -0
  148. package/src/components/user-button.tsx +409 -0
  149. package/src/components/user-view.tsx +138 -0
  150. package/src/hooks/use-auth-data.ts +184 -0
  151. package/src/hooks/use-authenticate.ts +62 -0
  152. package/src/hooks/use-captcha.tsx +138 -0
  153. package/src/hooks/use-current-organization.ts +59 -0
  154. package/src/hooks/use-hydrated.ts +13 -0
  155. package/src/hooks/use-lang.ts +32 -0
  156. package/src/hooks/use-success-transition.ts +51 -0
  157. package/src/hooks/use-theme.ts +39 -0
  158. package/src/index.ts +65 -0
  159. package/src/instantdb.ts +1 -0
  160. package/src/lib/auth-data-cache.ts +90 -0
  161. package/src/lib/auth-ui-provider.tsx +658 -0
  162. package/src/lib/gravatar-utils.ts +58 -0
  163. package/src/lib/image-utils.ts +55 -0
  164. package/src/lib/instantdb/model-names.ts +24 -0
  165. package/src/lib/instantdb/use-instant-options.ts +98 -0
  166. package/src/lib/instantdb/use-list-accounts.ts +38 -0
  167. package/src/lib/instantdb/use-list-sessions.ts +53 -0
  168. package/src/lib/instantdb/use-session.ts +55 -0
  169. package/src/lib/organization-refetcher.tsx +56 -0
  170. package/src/lib/social-providers.ts +144 -0
  171. package/src/lib/tanstack/auth-ui-provider-tanstack.tsx +49 -0
  172. package/src/lib/tanstack/use-tanstack-options.ts +112 -0
  173. package/src/lib/triplit/model-names.ts +24 -0
  174. package/src/lib/triplit/use-conditional-query.ts +82 -0
  175. package/src/lib/triplit/use-list-accounts.ts +31 -0
  176. package/src/lib/triplit/use-list-sessions.ts +33 -0
  177. package/src/lib/triplit/use-session.ts +42 -0
  178. package/src/lib/triplit/use-triplit-hooks.ts +68 -0
  179. package/src/lib/triplit/use-triplit-token.ts +44 -0
  180. package/src/lib/utils.ts +105 -0
  181. package/src/lib/view-paths.ts +55 -0
  182. package/src/localization/admin-error-codes.ts +20 -0
  183. package/src/localization/anonymous-error-codes.ts +6 -0
  184. package/src/localization/api-key-error-codes.ts +32 -0
  185. package/src/localization/auth-localization.ts +740 -0
  186. package/src/localization/base-error-codes.ts +27 -0
  187. package/src/localization/captcha-error-codes.ts +17 -0
  188. package/src/localization/email-otp-error-codes.ts +7 -0
  189. package/src/localization/generic-oauth-error-codes.ts +3 -0
  190. package/src/localization/haveibeenpwned-error-codes.ts +4 -0
  191. package/src/localization/multi-session-error-codes.ts +3 -0
  192. package/src/localization/organization-error-codes.ts +57 -0
  193. package/src/localization/passkey-error-codes.ts +10 -0
  194. package/src/localization/phone-number-error-codes.ts +10 -0
  195. package/src/localization/stripe-localization.ts +12 -0
  196. package/src/localization/two-factor-error-codes.ts +12 -0
  197. package/src/localization/username-error-codes.ts +9 -0
  198. package/src/server.ts +4 -0
  199. package/src/style.css +1 -0
  200. package/src/tanstack.ts +1 -0
  201. package/src/triplit.ts +1 -0
  202. package/src/types/account-options.ts +35 -0
  203. package/src/types/additional-fields.ts +21 -0
  204. package/src/types/any-auth-client.ts +6 -0
  205. package/src/types/api-key.ts +9 -0
  206. package/src/types/auth-client.ts +37 -0
  207. package/src/types/auth-hooks.ts +61 -0
  208. package/src/types/auth-mutators.ts +17 -0
  209. package/src/types/avatar-options.ts +29 -0
  210. package/src/types/captcha-options.ts +32 -0
  211. package/src/types/captcha-provider.ts +6 -0
  212. package/src/types/credentials-options.ts +32 -0
  213. package/src/types/delete-user-options.ts +7 -0
  214. package/src/types/fetch-error.ts +6 -0
  215. package/src/types/generic-oauth-options.ts +16 -0
  216. package/src/types/gravatar-options.ts +21 -0
  217. package/src/types/image.ts +7 -0
  218. package/src/types/invitation.ts +10 -0
  219. package/src/types/link.ts +7 -0
  220. package/src/types/organization-options.ts +106 -0
  221. package/src/types/password-validation.ts +16 -0
  222. package/src/types/profile.ts +15 -0
  223. package/src/types/refetch.ts +1 -0
  224. package/src/types/render-toast.ts +9 -0
  225. package/src/types/sign-up-options.ts +7 -0
  226. package/src/types/social-options.ts +16 -0
@@ -0,0 +1,27 @@
1
+ export const BASE_ERROR_CODES = {
2
+ USER_NOT_FOUND: "User not found",
3
+ FAILED_TO_CREATE_USER: "Failed to create user",
4
+ FAILED_TO_CREATE_SESSION: "Failed to create session",
5
+ FAILED_TO_UPDATE_USER: "Failed to update user",
6
+ FAILED_TO_GET_SESSION: "Failed to get session",
7
+ INVALID_PASSWORD: "Invalid password",
8
+ INVALID_EMAIL: "Invalid email",
9
+ INVALID_EMAIL_OR_PASSWORD: "Invalid email or password",
10
+ SOCIAL_ACCOUNT_ALREADY_LINKED: "Social account already linked",
11
+ PROVIDER_NOT_FOUND: "Provider not found",
12
+ INVALID_TOKEN: "Invalid token",
13
+ ID_TOKEN_NOT_SUPPORTED: "id_token not supported",
14
+ FAILED_TO_GET_USER_INFO: "Failed to get user info",
15
+ USER_EMAIL_NOT_FOUND: "User email not found",
16
+ EMAIL_NOT_VERIFIED: "Email not verified",
17
+ PASSWORD_TOO_SHORT: "Password too short",
18
+ PASSWORD_TOO_LONG: "Password too long",
19
+ USER_ALREADY_EXISTS: "User already exists",
20
+ EMAIL_CAN_NOT_BE_UPDATED: "Email can not be updated",
21
+ CREDENTIAL_ACCOUNT_NOT_FOUND: "Credential account not found",
22
+ SESSION_EXPIRED: "Session expired. Re-authenticate to perform this action.",
23
+ FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account",
24
+ ACCOUNT_NOT_FOUND: "Account not found",
25
+ USER_ALREADY_HAS_PASSWORD:
26
+ "User already has a password. Provide that to delete the account."
27
+ }
@@ -0,0 +1,17 @@
1
+ // These error codes are returned by the API
2
+ const EXTERNAL_ERROR_CODES = {
3
+ VERIFICATION_FAILED: "Captcha verification failed",
4
+ MISSING_RESPONSE: "Missing CAPTCHA response",
5
+ UNKNOWN_ERROR: "Something went wrong"
6
+ }
7
+
8
+ // These error codes are only visible in the server logs
9
+ const INTERNAL_ERROR_CODES = {
10
+ MISSING_SECRET_KEY: "Missing secret key",
11
+ SERVICE_UNAVAILABLE: "CAPTCHA service unavailable"
12
+ }
13
+
14
+ export const CAPTCHA_ERROR_CODES = {
15
+ ...EXTERNAL_ERROR_CODES,
16
+ ...INTERNAL_ERROR_CODES
17
+ }
@@ -0,0 +1,7 @@
1
+ export const EMAIL_OTP_ERROR_CODES = {
2
+ OTP_EXPIRED: "otp expired",
3
+ INVALID_OTP: "Invalid OTP",
4
+ INVALID_EMAIL: "Invalid email",
5
+ USER_NOT_FOUND: "User not found",
6
+ TOO_MANY_ATTEMPTS: "Too many attempts"
7
+ }
@@ -0,0 +1,3 @@
1
+ export const GENERIC_OAUTH_ERROR_CODES = {
2
+ INVALID_OAUTH_CONFIGURATION: "Invalid OAuth configuration"
3
+ }
@@ -0,0 +1,4 @@
1
+ export const HAVEIBEENPWNED_ERROR_CODES = {
2
+ PASSWORD_COMPROMISED:
3
+ "The password you entered has been compromised. Please choose a different password."
4
+ }
@@ -0,0 +1,3 @@
1
+ export const MULTI_SESSION_ERROR_CODES = {
2
+ INVALID_SESSION_TOKEN: "Invalid session token"
3
+ }
@@ -0,0 +1,57 @@
1
+ export const ORGANIZATION_ERROR_CODES = {
2
+ YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:
3
+ "You are not allowed to create a new organization",
4
+ YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:
5
+ "You have reached the maximum number of organizations",
6
+ ORGANIZATION_ALREADY_EXISTS: "Organization already exists",
7
+ ORGANIZATION_NOT_FOUND: "Organization not found",
8
+ USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:
9
+ "User is not a member of the organization",
10
+ YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:
11
+ "You are not allowed to update this organization",
12
+ YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:
13
+ "You are not allowed to delete this organization",
14
+ NO_ACTIVE_ORGANIZATION: "No active organization",
15
+ USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:
16
+ "User is already a member of this organization",
17
+ MEMBER_NOT_FOUND: "Member not found",
18
+ ROLE_NOT_FOUND: "Role not found",
19
+ YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:
20
+ "You are not allowed to create a new team",
21
+ TEAM_ALREADY_EXISTS: "Team already exists",
22
+ TEAM_NOT_FOUND: "Team not found",
23
+ YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:
24
+ "You cannot leave the organization as the only owner",
25
+ YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:
26
+ "You are not allowed to delete this member",
27
+ YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:
28
+ "You are not allowed to invite users to this organization",
29
+ USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:
30
+ "User is already invited to this organization",
31
+ INVITATION_NOT_FOUND: "Invitation not found",
32
+ YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:
33
+ "You are not the recipient of the invitation",
34
+ YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:
35
+ "You are not allowed to cancel this invitation",
36
+ INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:
37
+ "Inviter is no longer a member of the organization",
38
+ YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:
39
+ "you are not allowed to invite user with this role",
40
+ FAILED_TO_RETRIEVE_INVITATION: "Failed to retrieve invitation",
41
+ YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:
42
+ "You have reached the maximum number of teams",
43
+ UNABLE_TO_REMOVE_LAST_TEAM: "Unable to remove last team",
44
+ YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:
45
+ "You are not allowed to update this member",
46
+ ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:
47
+ "Organization membership limit reached",
48
+ YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:
49
+ "You are not allowed to create teams in this organization",
50
+ YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:
51
+ "You are not allowed to delete teams in this organization",
52
+ YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:
53
+ "You are not allowed to update this team",
54
+ YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:
55
+ "You are not allowed to delete this team",
56
+ INVITATION_LIMIT_REACHED: "Invitation limit reached"
57
+ }
@@ -0,0 +1,10 @@
1
+ export const PASSKEY_ERROR_CODES = {
2
+ CHALLENGE_NOT_FOUND: "Challenge not found",
3
+ YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY:
4
+ "You are not allowed to register this passkey",
5
+ FAILED_TO_VERIFY_REGISTRATION: "Failed to verify registration",
6
+ PASSKEY_NOT_FOUND: "Passkey not found",
7
+ AUTHENTICATION_FAILED: "Authentication failed",
8
+ UNABLE_TO_CREATE_SESSION: "Unable to create session",
9
+ FAILED_TO_UPDATE_PASSKEY: "Failed to update passkey"
10
+ }
@@ -0,0 +1,10 @@
1
+ export const PHONE_NUMBER_ERROR_CODES = {
2
+ INVALID_PHONE_NUMBER: "Invalid phone number",
3
+ PHONE_NUMBER_EXIST: "Phone number already exists",
4
+ INVALID_PHONE_NUMBER_OR_PASSWORD: "Invalid phone number or password",
5
+ UNEXPECTED_ERROR: "Unexpected error",
6
+ OTP_NOT_FOUND: "OTP not found",
7
+ OTP_EXPIRED: "OTP expired",
8
+ INVALID_OTP: "Invalid OTP",
9
+ PHONE_NUMBER_NOT_VERIFIED: "Phone number not verified"
10
+ }
@@ -0,0 +1,12 @@
1
+ export const STRIPE_ERROR_CODES = {
2
+ SUBSCRIPTION_NOT_FOUND: "Subscription not found",
3
+ SUBSCRIPTION_PLAN_NOT_FOUND: "Subscription plan not found",
4
+ ALREADY_SUBSCRIBED_PLAN: "You're already subscribed to this plan",
5
+ UNABLE_TO_CREATE_CUSTOMER: "Unable to create customer",
6
+ FAILED_TO_FETCH_PLANS: "Failed to fetch plans",
7
+ EMAIL_VERIFICATION_REQUIRED:
8
+ "Email verification is required before you can subscribe to a plan",
9
+ SUBSCRIPTION_NOT_ACTIVE: "Subscription is not active",
10
+ SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
11
+ "Subscription is not scheduled for cancellation"
12
+ }
@@ -0,0 +1,12 @@
1
+ export const TWO_FACTOR_ERROR_CODES = {
2
+ OTP_NOT_ENABLED: "OTP not enabled",
3
+ OTP_HAS_EXPIRED: "OTP has expired",
4
+ TOTP_NOT_ENABLED: "TOTP not enabled",
5
+ TWO_FACTOR_NOT_ENABLED: "Two factor isn't enabled",
6
+ BACKUP_CODES_NOT_ENABLED: "Backup codes aren't enabled",
7
+ INVALID_BACKUP_CODE: "Invalid backup code",
8
+ INVALID_CODE: "Invalid code",
9
+ TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:
10
+ "Too many attempts. Please request a new code.",
11
+ INVALID_TWO_FACTOR_COOKIE: "Invalid two factor cookie"
12
+ }
@@ -0,0 +1,9 @@
1
+ export const USERNAME_ERROR_CODES = {
2
+ INVALID_USERNAME_OR_PASSWORD: "invalid username or password",
3
+ EMAIL_NOT_VERIFIED: "email not verified",
4
+ UNEXPECTED_ERROR: "unexpected error",
5
+ USERNAME_IS_ALREADY_TAKEN: "username is already taken. please try another.",
6
+ USERNAME_TOO_SHORT: "username is too short",
7
+ USERNAME_TOO_LONG: "username is too long",
8
+ INVALID_USERNAME: "username is invalid"
9
+ }
package/src/server.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./components/email/email-template"
2
+ export { getViewByPath } from "./lib/utils"
3
+ export * from "./lib/view-paths"
4
+ export * from "./localization/auth-localization"
package/src/style.css ADDED
@@ -0,0 +1 @@
1
+ @source ".";
@@ -0,0 +1 @@
1
+ export * from "./lib/tanstack/auth-ui-provider-tanstack"
package/src/triplit.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./lib/triplit/use-triplit-hooks"
@@ -0,0 +1,35 @@
1
+ import type { AccountViewPaths } from "../lib/view-paths"
2
+
3
+ export type AccountOptions = {
4
+ /**
5
+ * Base path for account-scoped views
6
+ * @default "/account"
7
+ */
8
+ basePath?: string
9
+ /**
10
+ * Array of fields to show in Account Settings
11
+ * @default ["image", "name"]
12
+ */
13
+ fields: string[]
14
+ /**
15
+ * Customize account view paths
16
+ */
17
+ viewPaths?: Partial<AccountViewPaths>
18
+ }
19
+
20
+ export type AccountOptionsContext = {
21
+ /**
22
+ * Base path for account-scoped views
23
+ * @default "/account"
24
+ */
25
+ basePath: string
26
+ /**
27
+ * Array of fields to show in Account Settings
28
+ * @default ["image", "name"]
29
+ */
30
+ fields: string[]
31
+ /**
32
+ * Customize account view paths
33
+ */
34
+ viewPaths: AccountViewPaths
35
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from "react"
2
+
3
+ export type FieldType = "string" | "number" | "boolean"
4
+
5
+ export interface AdditionalField {
6
+ description?: ReactNode
7
+ instructions?: ReactNode
8
+ label: ReactNode
9
+ placeholder?: string
10
+ required?: boolean
11
+ type: FieldType
12
+ /**
13
+ * Render a multi-line textarea for string fields
14
+ */
15
+ multiline?: boolean
16
+ validate?: (value: string) => Promise<boolean>
17
+ }
18
+
19
+ export interface AdditionalFields {
20
+ [key: string]: AdditionalField
21
+ }
@@ -0,0 +1,6 @@
1
+ import type { createAuthClient } from "better-auth/react"
2
+
3
+ export type AnyAuthClient = Omit<
4
+ ReturnType<typeof createAuthClient>,
5
+ "signUp" | "getSession"
6
+ >
@@ -0,0 +1,9 @@
1
+ export type ApiKey = {
2
+ id: string
3
+ name?: string | null
4
+ start?: string | null
5
+ expiresAt?: Date | null
6
+ createdAt: Date
7
+ updatedAt: Date
8
+ metadata?: Record<string, unknown> | null
9
+ }
@@ -0,0 +1,37 @@
1
+ import {
2
+ anonymousClient,
3
+ apiKeyClient,
4
+ emailOTPClient,
5
+ genericOAuthClient,
6
+ magicLinkClient,
7
+ multiSessionClient,
8
+ oneTapClient,
9
+ organizationClient,
10
+ passkeyClient,
11
+ twoFactorClient,
12
+ usernameClient
13
+ } from "better-auth/client/plugins"
14
+ import { createAuthClient } from "better-auth/react"
15
+
16
+ export const authClient = createAuthClient({
17
+ plugins: [
18
+ apiKeyClient(),
19
+ multiSessionClient(),
20
+ passkeyClient(),
21
+ oneTapClient({
22
+ clientId: ""
23
+ }),
24
+ genericOAuthClient(),
25
+ anonymousClient(),
26
+ usernameClient(),
27
+ magicLinkClient(),
28
+ emailOTPClient(),
29
+ twoFactorClient(),
30
+ organizationClient()
31
+ ]
32
+ })
33
+
34
+ export type AuthClient = typeof authClient
35
+
36
+ export type Session = AuthClient["$Infer"]["Session"]["session"]
37
+ export type User = AuthClient["$Infer"]["Session"]["user"]
@@ -0,0 +1,61 @@
1
+ import type { BetterFetchError } from "@better-fetch/fetch"
2
+ import type { Account, User } from "better-auth"
3
+ import type { Member } from "better-auth/plugins/organization"
4
+ import type { AnyAuthClient } from "./any-auth-client"
5
+ import type { ApiKey } from "./api-key"
6
+ import type { AuthClient } from "./auth-client"
7
+ import type { Invitation } from "./invitation"
8
+ import type { Refetch } from "./refetch"
9
+
10
+ type AnyAuthSession = AnyAuthClient["$Infer"]["Session"]
11
+
12
+ type AuthHook<T> = {
13
+ isPending: boolean
14
+ data?: T | null
15
+ error?: BetterFetchError | null
16
+ refetch?: Refetch
17
+ }
18
+
19
+ export type AuthHooks = {
20
+ useSession: () => ReturnType<AnyAuthClient["useSession"]>
21
+ useListAccounts: () => AuthHook<Account[]>
22
+ useAccountInfo: (
23
+ params: Parameters<AuthClient["accountInfo"]>[0]
24
+ ) => AuthHook<{ user: User }>
25
+ useListDeviceSessions: () => AuthHook<AnyAuthClient["$Infer"]["Session"][]>
26
+ useListSessions: () => AuthHook<AnyAuthSession["session"][]>
27
+ useListPasskeys: () => Partial<ReturnType<AuthClient["useListPasskeys"]>>
28
+ useListApiKeys: () => AuthHook<ApiKey[]>
29
+ useActiveOrganization: () => Partial<
30
+ ReturnType<AuthClient["useActiveOrganization"]>
31
+ >
32
+ useListOrganizations: () => Partial<
33
+ ReturnType<AuthClient["useListOrganizations"]>
34
+ >
35
+ useHasPermission: (
36
+ params: Parameters<AuthClient["organization"]["hasPermission"]>[0]
37
+ ) => AuthHook<{
38
+ error: null
39
+ success: boolean
40
+ }>
41
+ useInvitation: (
42
+ params: Parameters<AuthClient["organization"]["getInvitation"]>[0]
43
+ ) => AuthHook<
44
+ Invitation & {
45
+ organizationName: string
46
+ organizationSlug: string
47
+ organizationLogo?: string
48
+ }
49
+ >
50
+ useListInvitations: (
51
+ params: Parameters<AuthClient["organization"]["listInvitations"]>[0]
52
+ ) => AuthHook<Invitation[]>
53
+ useListUserInvitations: () => AuthHook<Invitation[]>
54
+ useListMembers: (
55
+ params: Parameters<AuthClient["organization"]["listMembers"]>[0]
56
+ ) => AuthHook<{
57
+ members: (Member & { user?: Partial<User> | null })[]
58
+ total: number
59
+ }>
60
+ useIsRestoring?: () => boolean
61
+ }
@@ -0,0 +1,17 @@
1
+ type MutateFn<T = Record<string, unknown>> = (
2
+ params: T
3
+ ) => Promise<unknown> | Promise<void>
4
+
5
+ export interface AuthMutators {
6
+ deleteApiKey: MutateFn<{ keyId: string }>
7
+ deletePasskey: MutateFn<{ id: string }>
8
+ revokeDeviceSession: MutateFn<{ sessionToken: string }>
9
+ revokeSession: MutateFn<{ token: string }>
10
+ setActiveSession: MutateFn<{ sessionToken: string }>
11
+ updateOrganization: MutateFn<{
12
+ organizationId: string
13
+ data: Record<string, unknown>
14
+ }>
15
+ updateUser: MutateFn
16
+ unlinkAccount: MutateFn<{ providerId: string; accountId?: string }>
17
+ }
@@ -0,0 +1,29 @@
1
+ import type { Image } from "./image"
2
+
3
+ export type AvatarOptions = {
4
+ /**
5
+ * Upload an avatar image and return the URL string
6
+ * @remarks `(file: File) => Promise<string>`
7
+ */
8
+ upload?: (file: File) => Promise<string | undefined | null>
9
+ /**
10
+ * Delete a previously uploaded avatar image from your storage/CDN
11
+ * @remarks `(url: string) => Promise<void>`
12
+ */
13
+ delete?: (url: string) => Promise<void>
14
+ /**
15
+ * Avatar size for resizing
16
+ * @default 128 (or 256 if upload is provided)
17
+ */
18
+ size: number
19
+ /**
20
+ * File extension for avatar uploads
21
+ * @default "png"
22
+ */
23
+ extension: string
24
+ /**
25
+ * Custom Image component for rendering avatar images
26
+ * @default AvatarImage from Radix UI
27
+ */
28
+ Image?: Image
29
+ }
@@ -0,0 +1,32 @@
1
+ import type { CaptchaProvider } from "./captcha-provider"
2
+
3
+ export type CaptchaOptions = {
4
+ /**
5
+ * Captcha site key
6
+ */
7
+ siteKey: string
8
+ /**
9
+ * Captcha provider type
10
+ */
11
+ provider: CaptchaProvider
12
+ /**
13
+ * Hide the captcha badge
14
+ * @default false
15
+ */
16
+ hideBadge?: boolean
17
+ /**
18
+ * Use recaptcha.net domain instead of google.com
19
+ * @default false
20
+ */
21
+ recaptchaNet?: boolean
22
+ /**
23
+ * Enable enterprise mode for Google reCAPTCHA
24
+ * @default false
25
+ */
26
+ enterprise?: boolean
27
+ /**
28
+ * Overrides the default array of paths where captcha validation is enforced
29
+ * @default ["/sign-up/email", "/sign-in/email", "/forget-password"]
30
+ */
31
+ endpoints?: string[]
32
+ }
@@ -0,0 +1,6 @@
1
+ export type CaptchaProvider =
2
+ | "cloudflare-turnstile"
3
+ | "google-recaptcha-v2-checkbox"
4
+ | "google-recaptcha-v2-invisible"
5
+ | "google-recaptcha-v3"
6
+ | "hcaptcha"
@@ -0,0 +1,32 @@
1
+ import type { PasswordValidation } from "./password-validation"
2
+
3
+ export type CredentialsOptions = {
4
+ /**
5
+ * Enable or disable the Confirm Password input
6
+ * @default false
7
+ */
8
+ confirmPassword?: boolean
9
+
10
+ /**
11
+ * Enable or disable Forgot Password flow
12
+ * @default true
13
+ */
14
+ forgotPassword?: boolean
15
+
16
+ /**
17
+ * Customize the password validation
18
+ */
19
+ passwordValidation?: PasswordValidation
20
+
21
+ /**
22
+ * Enable or disable Remember Me checkbox
23
+ * @default false
24
+ */
25
+ rememberMe?: boolean
26
+
27
+ /**
28
+ * Enable or disable Username support
29
+ * @default false
30
+ */
31
+ username?: boolean
32
+ }
@@ -0,0 +1,7 @@
1
+ export type DeleteUserOptions = {
2
+ /**
3
+ * Enable or disable email verification for account deletion
4
+ * @default undefined
5
+ */
6
+ verification?: boolean
7
+ }
@@ -0,0 +1,6 @@
1
+ export type FetchError = {
2
+ code?: string | undefined
3
+ message?: string | undefined
4
+ status?: number
5
+ statusText?: string
6
+ }
@@ -0,0 +1,16 @@
1
+ import type { Provider } from "../lib/social-providers"
2
+ import type { AuthClient } from "./auth-client"
3
+
4
+ export type GenericOAuthOptions = {
5
+ /**
6
+ * Custom OAuth Providers
7
+ * @default []
8
+ */
9
+ providers: Provider[]
10
+ /**
11
+ * Custom generic OAuth sign in function
12
+ */
13
+ signIn?: (
14
+ params: Parameters<AuthClient["signIn"]["oauth2"]>[0]
15
+ ) => Promise<unknown>
16
+ }
@@ -0,0 +1,21 @@
1
+ export type GravatarOptions = {
2
+ /**
3
+ * Default image type or URL
4
+ * Options: '404', 'mp', 'identicon', 'monsterid', 'wavatar', 'retro', 'robohash', 'blank', or custom URL
5
+ */
6
+ d?: string
7
+ /**
8
+ * Image size in pixels (1-2048)
9
+ */
10
+ size?: number
11
+ /**
12
+ * Whether to append .jpg extension to the hash
13
+ * @default false
14
+ */
15
+ jpg?: boolean
16
+ /**
17
+ * Force default image even if user has Gravatar
18
+ * @default false
19
+ */
20
+ forceDefault?: boolean
21
+ }
@@ -0,0 +1,7 @@
1
+ import type { ComponentType } from "react"
2
+
3
+ export type Image = ComponentType<{
4
+ src: string
5
+ alt: string
6
+ className?: string
7
+ }>
@@ -0,0 +1,10 @@
1
+ export type Invitation = {
2
+ id: string
3
+ organizationId: string
4
+ email: string
5
+ role: string
6
+ status: string
7
+ inviterId: string
8
+ expiresAt: Date
9
+ teamId?: string | undefined
10
+ }
@@ -0,0 +1,7 @@
1
+ import type { ComponentType, ReactNode } from "react"
2
+
3
+ export type Link = ComponentType<{
4
+ href: string
5
+ className?: string
6
+ children: ReactNode
7
+ }>