@better-auth-ui/react 1.6.9 → 1.6.11
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/auth-context.d.ts +2 -2
- package/dist/components/auth/auth-provider.d.ts +4 -4
- package/dist/components/auth/email/email-changed.d.ts +2 -2
- package/dist/components/auth/email/email-verification.d.ts +2 -2
- package/dist/components/auth/email/index.d.ts +10 -10
- package/dist/components/auth/email/magic-link.d.ts +2 -2
- package/dist/components/auth/email/new-device.d.ts +2 -2
- package/dist/components/auth/email/organization-invitation.d.ts +2 -2
- package/dist/components/auth/email/otp-email.d.ts +2 -2
- package/dist/components/auth/email/password-changed.d.ts +2 -2
- package/dist/components/auth/email/reset-password.d.ts +2 -2
- package/dist/components/auth/fetch-options-provider.d.ts +1 -1
- package/dist/components/icons/apple.d.ts +1 -1
- package/dist/components/icons/atlassian.d.ts +1 -1
- package/dist/components/icons/cognito.d.ts +1 -1
- package/dist/components/icons/discord.d.ts +1 -1
- package/dist/components/icons/dropbox.d.ts +1 -1
- package/dist/components/icons/facebook.d.ts +1 -1
- package/dist/components/icons/figma.d.ts +1 -1
- package/dist/components/icons/github.d.ts +1 -1
- package/dist/components/icons/gitlab.d.ts +1 -1
- package/dist/components/icons/google.d.ts +1 -1
- package/dist/components/icons/huggingface.d.ts +1 -1
- package/dist/components/icons/index.d.ts +35 -35
- package/dist/components/icons/kakao.d.ts +1 -1
- package/dist/components/icons/kick.d.ts +1 -1
- package/dist/components/icons/line.d.ts +1 -1
- package/dist/components/icons/linear.d.ts +1 -1
- package/dist/components/icons/linkedin.d.ts +1 -1
- package/dist/components/icons/microsoft.d.ts +1 -1
- package/dist/components/icons/naver.d.ts +1 -1
- package/dist/components/icons/notion.d.ts +1 -1
- package/dist/components/icons/paybin.d.ts +1 -1
- package/dist/components/icons/paypal.d.ts +1 -1
- package/dist/components/icons/polar.d.ts +1 -1
- package/dist/components/icons/railway.d.ts +1 -1
- package/dist/components/icons/reddit.d.ts +1 -1
- package/dist/components/icons/roblox.d.ts +1 -1
- package/dist/components/icons/salesforce.d.ts +1 -1
- package/dist/components/icons/slack.d.ts +1 -1
- package/dist/components/icons/spotify.d.ts +1 -1
- package/dist/components/icons/tiktok.d.ts +1 -1
- package/dist/components/icons/twitch.d.ts +1 -1
- package/dist/components/icons/vercel.d.ts +1 -1
- package/dist/components/icons/vk.d.ts +1 -1
- package/dist/components/icons/wechat.d.ts +1 -1
- package/dist/components/icons/x.d.ts +1 -1
- package/dist/components/icons/zoom.d.ts +1 -1
- package/dist/email.d.ts +1 -1
- package/dist/email.js +1348 -1
- package/dist/hooks/auth/use-authenticate.d.ts +3 -3
- package/dist/hooks/auth/use-user.d.ts +34 -34
- package/dist/hooks/use-auth-mutation.d.ts +4 -4
- package/dist/hooks/use-auth-plugin.d.ts +1 -1
- package/dist/hooks/use-auth-query.d.ts +3 -3
- package/dist/index.d.ts +48 -48
- package/dist/index.js +2469 -47
- package/dist/lib/auth-client.d.ts +4 -4
- package/dist/lib/auth-plugin.d.ts +4 -4
- package/dist/lib/auth-server.d.ts +4 -4
- package/dist/lib/provider-icons.d.ts +2 -2
- package/dist/lib/settings-tab.d.ts +2 -2
- package/dist/lib/utils.d.ts +1 -1
- package/dist/mutations/api-key/create-api-key-mutation.d.ts +5 -5
- package/dist/mutations/api-key/delete-api-key-mutation.d.ts +5 -5
- package/dist/mutations/auth/request-password-reset-mutation.d.ts +4 -4
- package/dist/mutations/auth/reset-password-mutation.d.ts +4 -4
- package/dist/mutations/auth/send-verification-email-mutation.d.ts +4 -4
- package/dist/mutations/auth/sign-in-email-mutation.d.ts +7 -7
- package/dist/mutations/auth/sign-in-social-mutation.d.ts +6 -6
- package/dist/mutations/auth/sign-out-mutation.d.ts +5 -5
- package/dist/mutations/auth/sign-up-email-mutation.d.ts +9 -9
- package/dist/mutations/auth-mutation-options.d.ts +2 -2
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.d.ts +4 -4
- package/dist/mutations/multi-session/revoke-multi-session-mutation.d.ts +5 -5
- package/dist/mutations/multi-session/set-active-session-mutation.d.ts +5 -5
- package/dist/mutations/organization/accept-invitation-mutation.d.ts +7 -7
- package/dist/mutations/organization/cancel-invitation-mutation.d.ts +7 -7
- package/dist/mutations/organization/check-slug-mutation.d.ts +4 -4
- package/dist/mutations/organization/create-organization-mutation.d.ts +5 -5
- package/dist/mutations/organization/delete-organization-mutation.d.ts +5 -5
- package/dist/mutations/organization/index.d.ts +12 -12
- package/dist/mutations/organization/invite-member-mutation.d.ts +9 -9
- package/dist/mutations/organization/leave-organization-mutation.d.ts +5 -5
- package/dist/mutations/organization/reject-invitation-mutation.d.ts +7 -7
- package/dist/mutations/organization/remove-member-mutation.d.ts +5 -5
- package/dist/mutations/organization/set-active-organization-mutation.d.ts +7 -7
- package/dist/mutations/organization/update-member-role-mutation.d.ts +5 -5
- package/dist/mutations/organization/update-organization-mutation.d.ts +5 -5
- package/dist/mutations/passkey/add-passkey-mutation.d.ts +13 -13
- package/dist/mutations/passkey/delete-passkey-mutation.d.ts +5 -5
- package/dist/mutations/passkey/sign-in-passkey-mutation.d.ts +21 -21
- package/dist/mutations/settings/change-email-mutation.d.ts +5 -5
- package/dist/mutations/settings/change-password-mutation.d.ts +6 -6
- package/dist/mutations/settings/delete-user-mutation.d.ts +4 -4
- package/dist/mutations/settings/link-social-mutation.d.ts +4 -4
- package/dist/mutations/settings/revoke-session-mutation.d.ts +5 -5
- package/dist/mutations/settings/unlink-account-mutation.d.ts +5 -5
- package/dist/mutations/settings/update-user-mutation.d.ts +5 -5
- package/dist/mutations/username/is-username-available-mutation.d.ts +4 -4
- package/dist/mutations/username/sign-in-username-mutation.d.ts +7 -7
- package/dist/plugins/captcha-plugin.d.ts +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +27 -1
- package/dist/queries/api-key/list-api-keys-query.d.ts +6 -6
- package/dist/queries/auth/session-query.d.ts +6 -6
- package/dist/queries/auth-query-options.d.ts +2 -2
- package/dist/queries/multi-session/list-device-sessions-query.d.ts +6 -6
- package/dist/queries/organization/active-organization-query.d.ts +8 -8
- package/dist/queries/organization/full-organization-query.d.ts +6 -6
- package/dist/queries/organization/has-permission-query.d.ts +6 -6
- package/dist/queries/organization/index.d.ts +7 -7
- package/dist/queries/organization/list-invitations-query.d.ts +6 -6
- package/dist/queries/organization/list-members-query.d.ts +6 -6
- package/dist/queries/organization/list-organizations-query.d.ts +6 -6
- package/dist/queries/organization/list-user-invitations-query.d.ts +6 -6
- package/dist/queries/passkey/list-passkeys-query.d.ts +6 -6
- package/dist/queries/settings/account-info-query.d.ts +6 -6
- package/dist/queries/settings/list-accounts-query.d.ts +6 -6
- package/dist/queries/settings/list-sessions-query.d.ts +6 -6
- package/dist/server/queries/api-key/list-api-keys-query.d.ts +5 -5
- package/dist/server/queries/auth/session-query.d.ts +5 -5
- package/dist/server/queries/multi-session/list-device-sessions-query.d.ts +5 -5
- package/dist/server/queries/organization/active-organization-query.d.ts +7 -7
- package/dist/server/queries/organization/full-organization-query.d.ts +5 -5
- package/dist/server/queries/organization/has-permission-query.d.ts +5 -5
- package/dist/server/queries/organization/list-invitations-query.d.ts +5 -5
- package/dist/server/queries/organization/list-members-query.d.ts +5 -5
- package/dist/server/queries/organization/list-organizations-query.d.ts +5 -5
- package/dist/server/queries/organization/list-user-invitations-query.d.ts +5 -5
- package/dist/server/queries/passkey/list-passkeys-query.d.ts +5 -5
- package/dist/server/queries/settings/account-info-query.d.ts +5 -5
- package/dist/server/queries/settings/list-accounts-query.d.ts +5 -5
- package/dist/server/queries/settings/list-sessions-query.d.ts +5 -5
- package/dist/server.d.ts +15 -15
- package/dist/server.js +131 -14
- package/dist/use-auth-plugin-ClcP84Uz.js +80 -0
- package/package.json +2 -2
- package/dist/components/auth/auth-context.js +0 -4
- package/dist/components/auth/auth-provider.js +0 -68
- package/dist/components/auth/email/email-changed.js +0 -70
- package/dist/components/auth/email/email-localization.js +0 -26
- package/dist/components/auth/email/email-styles.js +0 -129
- package/dist/components/auth/email/email-verification.js +0 -75
- package/dist/components/auth/email/index.js +0 -10
- package/dist/components/auth/email/magic-link.js +0 -72
- package/dist/components/auth/email/new-device.js +0 -90
- package/dist/components/auth/email/organization-invitation.js +0 -110
- package/dist/components/auth/email/otp-email.js +0 -65
- package/dist/components/auth/email/password-changed.js +0 -76
- package/dist/components/auth/email/reset-password.js +0 -68
- package/dist/components/auth/fetch-options-provider.js +0 -31
- package/dist/components/icons/apple.js +0 -10
- package/dist/components/icons/atlassian.js +0 -14
- package/dist/components/icons/cognito.js +0 -10
- package/dist/components/icons/discord.js +0 -10
- package/dist/components/icons/dropbox.js +0 -10
- package/dist/components/icons/facebook.js +0 -12
- package/dist/components/icons/figma.js +0 -13
- package/dist/components/icons/github.js +0 -12
- package/dist/components/icons/gitlab.js +0 -10
- package/dist/components/icons/google.js +0 -10
- package/dist/components/icons/huggingface.js +0 -10
- package/dist/components/icons/index.js +0 -35
- package/dist/components/icons/kakao.js +0 -12
- package/dist/components/icons/kick.js +0 -12
- package/dist/components/icons/line.js +0 -10
- package/dist/components/icons/linear.js +0 -10
- package/dist/components/icons/linkedin.js +0 -10
- package/dist/components/icons/microsoft.js +0 -10
- package/dist/components/icons/naver.js +0 -10
- package/dist/components/icons/notion.js +0 -10
- package/dist/components/icons/paybin.js +0 -9
- package/dist/components/icons/paypal.js +0 -10
- package/dist/components/icons/polar.js +0 -10
- package/dist/components/icons/railway.js +0 -10
- package/dist/components/icons/reddit.js +0 -10
- package/dist/components/icons/roblox.js +0 -13
- package/dist/components/icons/salesforce.js +0 -10
- package/dist/components/icons/slack.js +0 -10
- package/dist/components/icons/spotify.js +0 -10
- package/dist/components/icons/tiktok.js +0 -11
- package/dist/components/icons/twitch.js +0 -13
- package/dist/components/icons/vercel.js +0 -10
- package/dist/components/icons/vk.js +0 -10
- package/dist/components/icons/wechat.js +0 -10
- package/dist/components/icons/x.js +0 -10
- package/dist/components/icons/zoom.js +0 -12
- package/dist/components/mutation-invalidator.js +0 -31
- package/dist/components/settings/account/theme-preview.js +0 -10
- package/dist/hooks/auth/use-authenticate.js +0 -29
- package/dist/hooks/auth/use-user.js +0 -15
- package/dist/hooks/use-auth-mutation.js +0 -19
- package/dist/hooks/use-auth-plugin.js +0 -28
- package/dist/hooks/use-auth-query.js +0 -21
- package/dist/lib/auth-client.js +0 -1
- package/dist/lib/auth-plugin.js +0 -1
- package/dist/lib/auth-server.js +0 -1
- package/dist/lib/provider-icons.js +0 -48
- package/dist/lib/settings-tab.js +0 -1
- package/dist/lib/utils.js +0 -5
- package/dist/mutations/api-key/create-api-key-mutation.js +0 -39
- package/dist/mutations/api-key/delete-api-key-mutation.js +0 -39
- package/dist/mutations/auth/request-password-reset-mutation.js +0 -33
- package/dist/mutations/auth/reset-password-mutation.js +0 -34
- package/dist/mutations/auth/send-verification-email-mutation.js +0 -33
- package/dist/mutations/auth/sign-in-email-mutation.js +0 -40
- package/dist/mutations/auth/sign-in-social-mutation.js +0 -38
- package/dist/mutations/auth/sign-out-mutation.js +0 -41
- package/dist/mutations/auth/sign-up-email-mutation.js +0 -36
- package/dist/mutations/auth-mutation-options.js +0 -23
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.js +0 -33
- package/dist/mutations/multi-session/revoke-multi-session-mutation.js +0 -39
- package/dist/mutations/multi-session/set-active-session-mutation.js +0 -40
- package/dist/mutations/organization/accept-invitation-mutation.js +0 -32
- package/dist/mutations/organization/cancel-invitation-mutation.js +0 -28
- package/dist/mutations/organization/check-slug-mutation.js +0 -30
- package/dist/mutations/organization/create-organization-mutation.js +0 -29
- package/dist/mutations/organization/delete-organization-mutation.js +0 -29
- package/dist/mutations/organization/index.js +0 -12
- package/dist/mutations/organization/invite-member-mutation.js +0 -35
- package/dist/mutations/organization/leave-organization-mutation.js +0 -32
- package/dist/mutations/organization/reject-invitation-mutation.js +0 -25
- package/dist/mutations/organization/remove-member-mutation.js +0 -29
- package/dist/mutations/organization/set-active-organization-mutation.js +0 -72
- package/dist/mutations/organization/update-member-role-mutation.js +0 -36
- package/dist/mutations/organization/update-organization-mutation.js +0 -36
- package/dist/mutations/passkey/add-passkey-mutation.js +0 -40
- package/dist/mutations/passkey/delete-passkey-mutation.js +0 -39
- package/dist/mutations/passkey/sign-in-passkey-mutation.js +0 -38
- package/dist/mutations/settings/change-email-mutation.js +0 -37
- package/dist/mutations/settings/change-password-mutation.js +0 -33
- package/dist/mutations/settings/delete-user-mutation.js +0 -33
- package/dist/mutations/settings/link-social-mutation.js +0 -33
- package/dist/mutations/settings/revoke-session-mutation.js +0 -39
- package/dist/mutations/settings/unlink-account-mutation.js +0 -39
- package/dist/mutations/settings/update-user-mutation.js +0 -36
- package/dist/mutations/username/is-username-available-mutation.js +0 -36
- package/dist/mutations/username/sign-in-username-mutation.js +0 -37
- package/dist/plugins/captcha-plugin.js +0 -34
- package/dist/queries/api-key/list-api-keys-query.js +0 -54
- package/dist/queries/auth/session-query.js +0 -72
- package/dist/queries/auth-query-options.js +0 -21
- package/dist/queries/multi-session/list-device-sessions-query.js +0 -85
- package/dist/queries/organization/active-organization-query.js +0 -37
- package/dist/queries/organization/full-organization-query.js +0 -31
- package/dist/queries/organization/has-permission-query.js +0 -38
- package/dist/queries/organization/index.js +0 -7
- package/dist/queries/organization/list-invitations-query.js +0 -37
- package/dist/queries/organization/list-members-query.js +0 -37
- package/dist/queries/organization/list-organizations-query.js +0 -31
- package/dist/queries/organization/list-user-invitations-query.js +0 -31
- package/dist/queries/passkey/list-passkeys-query.js +0 -83
- package/dist/queries/settings/account-info-query.js +0 -87
- package/dist/queries/settings/list-accounts-query.js +0 -85
- package/dist/queries/settings/list-sessions-query.js +0 -83
- package/dist/server/queries/api-key/list-api-keys-query.js +0 -49
- package/dist/server/queries/auth/session-query.js +0 -51
- package/dist/server/queries/multi-session/list-device-sessions-query.js +0 -54
- package/dist/server/queries/organization/active-organization-query.js +0 -25
- package/dist/server/queries/organization/full-organization-query.js +0 -21
- package/dist/server/queries/organization/has-permission-query.js +0 -23
- package/dist/server/queries/organization/list-invitations-query.js +0 -21
- package/dist/server/queries/organization/list-members-query.js +0 -21
- package/dist/server/queries/organization/list-organizations-query.js +0 -21
- package/dist/server/queries/organization/list-user-invitations-query.js +0 -21
- package/dist/server/queries/passkey/list-passkeys-query.js +0 -54
- package/dist/server/queries/settings/account-info-query.js +0 -54
- package/dist/server/queries/settings/list-accounts-query.js +0 -54
- package/dist/server/queries/settings/list-sessions-query.js +0 -54
package/dist/server.js
CHANGED
|
@@ -1,14 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { authQueryKeys as e } from "@better-auth-ui/core";
|
|
2
|
+
import { queryOptions as t } from "@tanstack/react-query";
|
|
3
|
+
import { apiKeyQueryKeys as n, multiSessionQueryKeys as r, organizationQueryKeys as i, passkeyQueryKeys as a } from "@better-auth-ui/core/plugins";
|
|
4
|
+
//#region src/server/queries/api-key/list-api-keys-query.ts
|
|
5
|
+
function o(e, r, i) {
|
|
6
|
+
return t({
|
|
7
|
+
queryKey: n.list(r, i?.query),
|
|
8
|
+
queryFn: () => e.api.listApiKeys(i)
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
var s = (e, t, n, r) => e.ensureQueryData(o(t, n, r)), c = (e, t, n, r) => e.prefetchQuery(o(t, n, r)), l = (e, t, n, r) => e.fetchQuery(o(t, n, r));
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/server/queries/auth/session-query.ts
|
|
14
|
+
function u(n, r) {
|
|
15
|
+
let i = e.session;
|
|
16
|
+
return t({
|
|
17
|
+
queryKey: i,
|
|
18
|
+
queryFn: () => n.api.getSession(r)
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
var d = (e, t, n) => e.ensureQueryData(u(t, n)), f = (e, t, n) => e.prefetchQuery(u(t, n)), p = (e, t, n) => e.fetchQuery(u(t, n));
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/server/queries/multi-session/list-device-sessions-query.ts
|
|
24
|
+
function m(e, n, i) {
|
|
25
|
+
return t({
|
|
26
|
+
queryKey: r.list(n, i?.query),
|
|
27
|
+
queryFn: () => e.api.listDeviceSessions(i)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
var h = (e, t, n, r) => e.ensureQueryData(m(t, n, r)), g = (e, t, n, r) => e.prefetchQuery(m(t, n, r)), _ = (e, t, n, r) => e.fetchQuery(m(t, n, r));
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/server/queries/organization/active-organization-query.ts
|
|
33
|
+
function v(e, n, r) {
|
|
34
|
+
return t({
|
|
35
|
+
queryKey: i.activeOrganization(n, r?.query),
|
|
36
|
+
queryFn: () => e.api.getFullOrganization(r)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
var ee = (e, t, n, r) => e.ensureQueryData(v(t, n, r)), y = (e, t, n, r) => e.prefetchQuery(v(t, n, r)), b = (e, t, n, r) => e.fetchQuery(v(t, n, r));
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/server/queries/organization/full-organization-query.ts
|
|
42
|
+
function x(e, n, r) {
|
|
43
|
+
return t({
|
|
44
|
+
queryKey: i.fullDetail(n, r?.query),
|
|
45
|
+
queryFn: () => e.api.getFullOrganization(r)
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
var S = (e, t, n, r) => e.ensureQueryData(x(t, n, r)), C = (e, t, n, r) => e.prefetchQuery(x(t, n, r)), w = (e, t, n, r) => e.fetchQuery(x(t, n, r));
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/server/queries/organization/has-permission-query.ts
|
|
51
|
+
function T(e, n, r) {
|
|
52
|
+
return t({
|
|
53
|
+
queryKey: i.permissions.has(n, r?.body),
|
|
54
|
+
queryFn: () => e.api.hasPermission(r)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
var E = (e, t, n, r) => e.ensureQueryData(T(t, n, r)), D = (e, t, n, r) => e.prefetchQuery(T(t, n, r)), O = (e, t, n, r) => e.fetchQuery(T(t, n, r));
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/server/queries/organization/list-invitations-query.ts
|
|
60
|
+
function k(e, n, r) {
|
|
61
|
+
return t({
|
|
62
|
+
queryKey: i.invitations.list(n, r?.query),
|
|
63
|
+
queryFn: () => e.api.listInvitations(r)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
var A = (e, t, n, r) => e.ensureQueryData(k(t, n, r)), j = (e, t, n, r) => e.prefetchQuery(k(t, n, r)), M = (e, t, n, r) => e.fetchQuery(k(t, n, r));
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/server/queries/organization/list-members-query.ts
|
|
69
|
+
function N(e, n, r) {
|
|
70
|
+
return t({
|
|
71
|
+
queryKey: i.members.list(n, r?.query),
|
|
72
|
+
queryFn: () => e.api.listMembers(r)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
var P = (e, t, n, r) => e.ensureQueryData(N(t, n, r)), F = (e, t, n, r) => e.prefetchQuery(N(t, n, r)), I = (e, t, n, r) => e.fetchQuery(N(t, n, r));
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/server/queries/organization/list-organizations-query.ts
|
|
78
|
+
function L(e, n, r) {
|
|
79
|
+
return t({
|
|
80
|
+
queryKey: i.list(n, r?.query),
|
|
81
|
+
queryFn: () => e.api.listOrganizations(r)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
var R = (e, t, n, r) => e.ensureQueryData(L(t, n, r)), te = (e, t, n, r) => e.prefetchQuery(L(t, n, r)), z = (e, t, n, r) => e.fetchQuery(L(t, n, r));
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/server/queries/organization/list-user-invitations-query.ts
|
|
87
|
+
function B(e, n, r) {
|
|
88
|
+
return t({
|
|
89
|
+
queryKey: i.userInvitations.list(n, r?.query),
|
|
90
|
+
queryFn: () => e.api.listUserInvitations(r)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
var V = (e, t, n, r) => e.ensureQueryData(B(t, n, r)), H = (e, t, n, r) => e.prefetchQuery(B(t, n, r)), U = (e, t, n, r) => e.fetchQuery(B(t, n, r));
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/server/queries/passkey/list-passkeys-query.ts
|
|
96
|
+
function W(e, n, r) {
|
|
97
|
+
return t({
|
|
98
|
+
queryKey: a.list(n, r?.query),
|
|
99
|
+
queryFn: () => e.api.listPasskeys(r)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
var G = (e, t, n, r) => e.ensureQueryData(W(t, n, r)), K = (e, t, n, r) => e.prefetchQuery(W(t, n, r)), q = (e, t, n, r) => e.fetchQuery(W(t, n, r));
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/server/queries/settings/account-info-query.ts
|
|
105
|
+
function J(n, r, i) {
|
|
106
|
+
return t({
|
|
107
|
+
queryKey: e.accountInfo(r, i?.query),
|
|
108
|
+
queryFn: () => n.api.accountInfo(i)
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
var Y = (e, t, n, r) => e.ensureQueryData(J(t, n, r)), X = (e, t, n, r) => e.prefetchQuery(J(t, n, r)), Z = (e, t, n, r) => e.fetchQuery(J(t, n, r));
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/server/queries/settings/list-accounts-query.ts
|
|
114
|
+
function Q(n, r, i) {
|
|
115
|
+
return t({
|
|
116
|
+
queryKey: e.listAccounts(r, i?.query),
|
|
117
|
+
queryFn: () => n.api.listUserAccounts(i)
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
var ne = (e, t, n, r) => e.ensureQueryData(Q(t, n, r)), re = (e, t, n, r) => e.prefetchQuery(Q(t, n, r)), ie = (e, t, n, r) => e.fetchQuery(Q(t, n, r));
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/server/queries/settings/list-sessions-query.ts
|
|
123
|
+
function $(n, r, i) {
|
|
124
|
+
return t({
|
|
125
|
+
queryKey: e.listSessions(r, i?.query),
|
|
126
|
+
queryFn: () => n.api.listSessions(i)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
var ae = (e, t, n, r) => e.ensureQueryData($(t, n, r)), oe = (e, t, n, r) => e.prefetchQuery($(t, n, r)), se = (e, t, n, r) => e.fetchQuery($(t, n, r));
|
|
130
|
+
//#endregion
|
|
131
|
+
export { J as accountInfoOptions, v as activeOrganizationOptions, Y as ensureAccountInfo, ee as ensureActiveOrganization, S as ensureFullOrganization, E as ensureHasPermission, ne as ensureListAccounts, s as ensureListApiKeys, h as ensureListDeviceSessions, A as ensureListOrganizationInvitations, P as ensureListOrganizationMembers, R as ensureListOrganizations, G as ensureListPasskeys, ae as ensureListSessions, V as ensureListUserInvitations, d as ensureSession, Z as fetchAccountInfo, b as fetchActiveOrganization, w as fetchFullOrganization, O as fetchHasPermission, ie as fetchListAccounts, l as fetchListApiKeys, _ as fetchListDeviceSessions, M as fetchListOrganizationInvitations, I as fetchListOrganizationMembers, z as fetchListOrganizations, q as fetchListPasskeys, se as fetchListSessions, U as fetchListUserInvitations, p as fetchSession, x as fullOrganizationOptions, T as hasPermissionOptions, Q as listAccountsOptions, o as listApiKeysOptions, m as listDeviceSessionsOptions, k as listOrganizationInvitationsOptions, N as listOrganizationMembersOptions, L as listOrganizationsOptions, W as listPasskeysOptions, $ as listSessionsOptions, B as listUserInvitationsOptions, X as prefetchAccountInfo, y as prefetchActiveOrganization, C as prefetchFullOrganization, D as prefetchHasPermission, re as prefetchListAccounts, c as prefetchListApiKeys, g as prefetchListDeviceSessions, j as prefetchListOrganizationInvitations, F as prefetchListOrganizationMembers, te as prefetchListOrganizations, K as prefetchListPasskeys, oe as prefetchListSessions, H as prefetchListUserInvitations, f as prefetchSession, u as sessionOptions };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { authMutationKeys as e, deepmerge as t, defaultAuthConfig as n } from "@better-auth-ui/core";
|
|
2
|
+
import { QueryClient as r, QueryClientContext as i, QueryClientProvider as a, matchMutation as o, matchQuery as s, useQueryClient as c } from "@tanstack/react-query";
|
|
3
|
+
import { createContext as l, useCallback as u, useContext as d, useEffect as f, useRef as p, useState as m } from "react";
|
|
4
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/mutation-invalidator.tsx
|
|
6
|
+
function _() {
|
|
7
|
+
let t = c();
|
|
8
|
+
return f(() => {
|
|
9
|
+
let n = t.getMutationCache(), r = n.config.onSuccess;
|
|
10
|
+
return n.config.onSuccess = async (n, i, a, c, l) => {
|
|
11
|
+
if (await r?.(n, i, a, c, l), !o({ mutationKey: e.all }, c)) return;
|
|
12
|
+
let { invalidates: u, awaits: d } = c.meta ?? {};
|
|
13
|
+
if (u?.length && t.invalidateQueries({ predicate: (e) => u.some((t) => s({ queryKey: t }, e)) }), d?.length) return t.invalidateQueries({ predicate: (e) => d.some((t) => s({ queryKey: t }, e)) }, { cancelRefetch: !1 });
|
|
14
|
+
}, () => {
|
|
15
|
+
n.config.onSuccess = r;
|
|
16
|
+
};
|
|
17
|
+
}, [t]), null;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/components/auth/auth-context.tsx
|
|
21
|
+
var v = l(void 0), y = l(void 0);
|
|
22
|
+
function b({ children: e }) {
|
|
23
|
+
let [t, n] = m(void 0), r = p(null), i = u((e) => {
|
|
24
|
+
n(e);
|
|
25
|
+
}, []), a = u((e) => {
|
|
26
|
+
r.current = e;
|
|
27
|
+
}, []), o = u(() => {
|
|
28
|
+
n(void 0), r.current?.();
|
|
29
|
+
}, []);
|
|
30
|
+
return /* @__PURE__ */ h(y.Provider, {
|
|
31
|
+
value: {
|
|
32
|
+
fetchOptions: t,
|
|
33
|
+
setFetchOptions: i,
|
|
34
|
+
resetFetchOptions: o,
|
|
35
|
+
registerReset: a
|
|
36
|
+
},
|
|
37
|
+
children: e
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function x() {
|
|
41
|
+
let e = d(y);
|
|
42
|
+
if (!e) throw Error("[Better Auth UI] useFetchOptions must be used within FetchOptionsProvider");
|
|
43
|
+
return e;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/components/auth/auth-provider.tsx
|
|
47
|
+
var S = new r({ defaultOptions: { queries: { staleTime: 5e3 } } });
|
|
48
|
+
function C({ children: e, queryClient: r, ...o }) {
|
|
49
|
+
let { authClient: s, ...c } = o, l = {
|
|
50
|
+
...t(n, c),
|
|
51
|
+
authClient: s
|
|
52
|
+
};
|
|
53
|
+
l.redirectTo = typeof window < "u" && new URLSearchParams(window.location.search).get("redirectTo")?.trim() || l.redirectTo;
|
|
54
|
+
let u = /* @__PURE__ */ new Map();
|
|
55
|
+
for (let e of l.plugins ?? []) for (let t of e.additionalFields ?? []) u.set(t.name, t);
|
|
56
|
+
for (let e of l.additionalFields ?? []) u.set(e.name, e);
|
|
57
|
+
l.additionalFields = Array.from(u.values());
|
|
58
|
+
let f = d(i);
|
|
59
|
+
return /* @__PURE__ */ h(a, {
|
|
60
|
+
client: r || f || S,
|
|
61
|
+
children: /* @__PURE__ */ h(v.Provider, {
|
|
62
|
+
value: l,
|
|
63
|
+
children: /* @__PURE__ */ g(b, { children: [/* @__PURE__ */ h(_, {}), e] })
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function w() {
|
|
68
|
+
let e = d(v);
|
|
69
|
+
if (!e) throw Error("[Better Auth UI] AuthProvider is required");
|
|
70
|
+
return e;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/hooks/use-auth-plugin.ts
|
|
74
|
+
function T(e) {
|
|
75
|
+
let { plugins: t } = w(), n = t?.find((t) => t.id === e.id);
|
|
76
|
+
if (!n) throw Error(`[Better Auth UI] useAuthPlugin: plugin "${e.id}" is not registered on AuthProvider.`);
|
|
77
|
+
return n;
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { x as a, b as i, C as n, w as r, T as t };
|
package/package.json
CHANGED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { deepmerge, defaultAuthConfig } from "@better-auth-ui/core";
|
|
4
|
-
import { QueryClient, QueryClientContext, QueryClientProvider } from "@tanstack/react-query";
|
|
5
|
-
import { useContext } from "react";
|
|
6
|
-
import { MutationInvalidator } from "../mutation-invalidator";
|
|
7
|
-
import { AuthContext } from "./auth-context";
|
|
8
|
-
import { FetchOptionsProvider } from "./fetch-options-provider";
|
|
9
|
-
const fallbackQueryClient = new QueryClient({
|
|
10
|
-
defaultOptions: {
|
|
11
|
-
queries: {
|
|
12
|
-
staleTime: 5000
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
/**
|
|
17
|
-
* Provides merged authentication configuration and a resolved React Query client to descendant components.
|
|
18
|
-
*
|
|
19
|
-
* The component merges the provided auth config with the library defaults, updates `redirectTo` from the
|
|
20
|
-
* current URL when the app is hydrated, wires a QueryClient (prop, context, or fallback) and installs an
|
|
21
|
-
* error handler that surfaces query errors via the configured toast. It then supplies the merged config
|
|
22
|
-
* via AuthContext and wraps children with QueryClientProvider.
|
|
23
|
-
*
|
|
24
|
-
* @returns The children wrapped with AuthContext.Provider and QueryClientProvider configured for auth.
|
|
25
|
-
*/
|
|
26
|
-
export function AuthProvider({ children, queryClient, ...config }) {
|
|
27
|
-
const { authClient, ...partialConfig } = config;
|
|
28
|
-
const mergedConfig = {
|
|
29
|
-
...deepmerge(defaultAuthConfig, partialConfig),
|
|
30
|
-
authClient
|
|
31
|
-
};
|
|
32
|
-
mergedConfig.redirectTo =
|
|
33
|
-
(typeof window !== "undefined" &&
|
|
34
|
-
new URLSearchParams(window.location.search).get("redirectTo")?.trim()) ||
|
|
35
|
-
mergedConfig.redirectTo;
|
|
36
|
-
// Merge plugin-contributed `additionalFields` with user-supplied ones.
|
|
37
|
-
// Plugin order is preserved; user-supplied entries with the same `name`
|
|
38
|
-
// override the plugin contribution.
|
|
39
|
-
const fieldsByName = new Map();
|
|
40
|
-
for (const plugin of mergedConfig.plugins ?? []) {
|
|
41
|
-
for (const field of plugin.additionalFields ?? []) {
|
|
42
|
-
fieldsByName.set(field.name, field);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
for (const field of mergedConfig.additionalFields ?? []) {
|
|
46
|
-
fieldsByName.set(field.name, field);
|
|
47
|
-
}
|
|
48
|
-
mergedConfig.additionalFields = Array.from(fieldsByName.values());
|
|
49
|
-
const contextQueryClient = useContext(QueryClientContext);
|
|
50
|
-
return (_jsx(QueryClientProvider, { client: queryClient || contextQueryClient || fallbackQueryClient, children: _jsx(AuthContext.Provider, { value: mergedConfig, children: _jsxs(FetchOptionsProvider, { children: [_jsx(MutationInvalidator, {}), children] }) }) }));
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Accesses the current authentication configuration from AuthContext.
|
|
54
|
-
*
|
|
55
|
-
* UI packages widen the plugin type globally via the `Register` interface
|
|
56
|
-
* (see module augmentation in `@better-auth-ui/heroui`), so callers don't
|
|
57
|
-
* need to pass a generic.
|
|
58
|
-
*
|
|
59
|
-
* @returns The merged authentication configuration provided by AuthProvider.
|
|
60
|
-
* @throws If no AuthProvider is present in the component tree.
|
|
61
|
-
*/
|
|
62
|
-
export function useAuth() {
|
|
63
|
-
const context = useContext(AuthContext);
|
|
64
|
-
if (!context) {
|
|
65
|
-
throw new Error("[Better Auth UI] AuthProvider is required");
|
|
66
|
-
}
|
|
67
|
-
return context;
|
|
68
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Body, Button, Container, Head, Heading, Hr, Html, Img, Link, Preview, pixelBasedPreset, Section, Tailwind, Text } from "@react-email/components";
|
|
3
|
-
import { cn } from "../../../lib/utils";
|
|
4
|
-
import { EmailStyles } from "./email-styles";
|
|
5
|
-
const emailChangedEmailLocalization = {
|
|
6
|
-
YOUR_EMAIL_ADDRESS_HAS_BEEN_CHANGED: "Your email address has been changed",
|
|
7
|
-
LOGO: "Logo",
|
|
8
|
-
EMAIL_ADDRESS_CHANGED: "Email address changed",
|
|
9
|
-
EMAIL_ADDRESS_FOR_YOUR_ACCOUNT_CHANGED: "The email address for your {appName} account has been changed.",
|
|
10
|
-
PREVIOUS_EMAIL: "Previous email:",
|
|
11
|
-
NEW_EMAIL: "New email:",
|
|
12
|
-
IF_YOU_MADE_THIS_CHANGE: "If you made this change, you can safely ignore this email.",
|
|
13
|
-
I_DIDNT_MAKE_THIS_CHANGE: "I didn't make this change",
|
|
14
|
-
EMAIL_SENT_BY: "Email sent by {appName}.",
|
|
15
|
-
IF_YOU_DIDNT_AUTHORIZE_THIS_CHANGE: "If you didn't authorize this change, please contact support immediately {supportEmail} to secure your account.",
|
|
16
|
-
POWERED_BY_BETTER_AUTH: "Powered by {betterAuth}"
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Email template component that notifies users when their email address has been changed.
|
|
20
|
-
*
|
|
21
|
-
* This email includes:
|
|
22
|
-
* - Display of both old and new email addresses
|
|
23
|
-
* - Revert action button if unauthorized change occurred
|
|
24
|
-
* - Security information and support contact details
|
|
25
|
-
* - Customizable branding and styling
|
|
26
|
-
* - Support for light/dark mode themes
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```tsx
|
|
30
|
-
* <EmailChangedEmail
|
|
31
|
-
* oldEmail="old@example.com"
|
|
32
|
-
* newEmail="new@example.com"
|
|
33
|
-
* revertURL="https://example.com/revert?token=abc123"
|
|
34
|
-
* appName="My App"
|
|
35
|
-
* supportEmail="support@example.com"
|
|
36
|
-
* logoURL="https://example.com/logo.png"
|
|
37
|
-
* darkMode={true}
|
|
38
|
-
* />
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export const EmailChangedEmail = ({ oldEmail, newEmail, revertURL, appName, supportEmail, logoURL, colors, classNames, darkMode = true, poweredBy, head, ...props }) => {
|
|
42
|
-
const localization = {
|
|
43
|
-
...EmailChangedEmail.localization,
|
|
44
|
-
...props.localization
|
|
45
|
-
};
|
|
46
|
-
const previewText = localization.YOUR_EMAIL_ADDRESS_HAS_BEEN_CHANGED;
|
|
47
|
-
return (_jsxs(Html, { children: [_jsxs(Head, { children: [_jsx("meta", { content: "light dark", name: "color-scheme" }), _jsx("meta", { content: "light dark", name: "supported-color-schemes" }), _jsx(EmailStyles, { colors: colors, darkMode: darkMode }), head] }), _jsx(Preview, { children: previewText }), _jsx(Tailwind, { config: { presets: [pixelBasedPreset] }, children: _jsx(Body, { className: cn("bg-background font-sans", classNames?.body), children: _jsx(Container, { className: cn("mx-auto my-auto max-w-xl px-2 py-10", classNames?.container), children: _jsxs(Section, { className: cn("bg-card text-card-foreground rounded-none border border-border p-8", classNames?.card), children: [logoURL &&
|
|
48
|
-
(typeof logoURL === "string" ? (_jsx(Img, { src: logoURL, width: 48, height: 48, alt: appName || localization.LOGO, className: cn("mx-auto mb-8", classNames?.logo) })) : (_jsxs(_Fragment, { children: [_jsx(Img, { src: logoURL.light, width: 48, height: 48, alt: appName || localization.LOGO, className: cn("mx-auto mb-8 logo-light", classNames?.logo) }), _jsx(Img, { src: logoURL.dark, width: 48, height: 48, alt: appName || localization.LOGO, className: cn("hidden mx-auto mb-8 logo-dark", classNames?.logo) })] }))), _jsx(Heading, { className: cn("m-0 mb-5 text-2xl font-semibold", classNames?.title), children: localization.EMAIL_ADDRESS_CHANGED }), _jsx(Text, { className: cn("text-sm font-normal", classNames?.content), children: localization.EMAIL_ADDRESS_FOR_YOUR_ACCOUNT_CHANGED.replace("{appName}", appName || "")
|
|
49
|
-
.replace(/\s{2,}/g, " ")
|
|
50
|
-
.replace(" .", ".") }), (oldEmail || newEmail) && (_jsxs(Section, { className: cn("my-6 border border-border bg-muted p-4", classNames?.codeBlock), children: [oldEmail && (_jsxs(_Fragment, { children: [_jsx(Text, { className: cn("m-0 mb-2 text-xs text-muted-foreground", classNames?.description), children: localization.PREVIOUS_EMAIL }), _jsx(Text, { className: cn("m-0 mb-4 text-sm font-semibold", classNames?.content), children: oldEmail })] })), newEmail && (_jsxs(_Fragment, { children: [_jsx(Text, { className: cn("m-0 mb-2 text-xs text-muted-foreground", classNames?.description), children: localization.NEW_EMAIL }), _jsx(Text, { className: cn("m-0 text-sm font-semibold text-primary", classNames?.content), children: newEmail })] }))] })), _jsx(Text, { className: cn("text-sm font-normal", classNames?.content), children: localization.IF_YOU_MADE_THIS_CHANGE }), revertURL && (_jsx(Section, { className: "my-6", children: _jsx(Button, { href: revertURL, className: cn("inline-block whitespace-nowrap rounded-none text-sm font-medium py-2.5 px-6 bg-primary text-primary-foreground no-underline", classNames?.button), children: localization.I_DIDNT_MAKE_THIS_CHANGE }) })), _jsx(Hr, { className: cn("my-6 w-full border border-solid border-border", classNames?.separator) }), appName && (_jsx(Text, { className: cn("mb-3 text-xs text-muted-foreground", classNames?.description), children: localization.EMAIL_SENT_BY.replace("{appName}", appName) })), _jsx(Text, { className: cn("mt-3 text-xs text-muted-foreground", classNames?.description), children: (() => {
|
|
51
|
-
const [beforeSupportEmail, afterSupportEmail] = localization.IF_YOU_DIDNT_AUTHORIZE_THIS_CHANGE.split("{supportEmail}");
|
|
52
|
-
return supportEmail ? (_jsxs(_Fragment, { children: [beforeSupportEmail, _jsx(Link, { href: `mailto:${supportEmail}`, className: cn("text-primary underline", classNames?.link), children: supportEmail }), afterSupportEmail] })) : (localization.IF_YOU_DIDNT_AUTHORIZE_THIS_CHANGE.replace("{supportEmail}", "")
|
|
53
|
-
.replace(/\s{2,}/g, " ")
|
|
54
|
-
.replace(" .", "."));
|
|
55
|
-
})() }), poweredBy && (_jsx(Text, { className: cn("mt-4 mb-0 text-center text-[11px] text-muted-foreground", classNames?.poweredBy), children: (() => {
|
|
56
|
-
const [beforeBetterAuth, afterBetterAuth] = localization.POWERED_BY_BETTER_AUTH.split("{betterAuth}");
|
|
57
|
-
return (_jsxs(_Fragment, { children: [beforeBetterAuth, _jsx(Link, { href: "https://better-auth.com", className: cn("text-primary underline", classNames?.link), children: "better-auth" }), afterBetterAuth] }));
|
|
58
|
-
})() }))] }) }) }) })] }));
|
|
59
|
-
};
|
|
60
|
-
EmailChangedEmail.localization = emailChangedEmailLocalization;
|
|
61
|
-
EmailChangedEmail.PreviewProps = {
|
|
62
|
-
oldEmail: "old@example.com",
|
|
63
|
-
newEmail: "new@example.com",
|
|
64
|
-
supportEmail: "support@example.com",
|
|
65
|
-
revertURL: "https://better-auth-ui.com/auth/revert-email?token=example-token",
|
|
66
|
-
appName: "Better Auth",
|
|
67
|
-
poweredBy: true,
|
|
68
|
-
darkMode: true
|
|
69
|
-
};
|
|
70
|
-
export default EmailChangedEmail;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import EmailChangedEmail from "./email-changed";
|
|
2
|
-
import EmailVerificationEmail from "./email-verification";
|
|
3
|
-
import MagicLinkEmail from "./magic-link";
|
|
4
|
-
import NewDeviceEmail from "./new-device";
|
|
5
|
-
import OrganizationInvitationEmail from "./organization-invitation";
|
|
6
|
-
import OtpEmail from "./otp-email";
|
|
7
|
-
import PasswordChangedEmail from "./password-changed";
|
|
8
|
-
import ResetPasswordEmail from "./reset-password";
|
|
9
|
-
/**
|
|
10
|
-
* Aggregated localization strings for all email components.
|
|
11
|
-
*
|
|
12
|
-
* Combines localization strings from all email templates (EmailChangedEmail,
|
|
13
|
-
* EmailVerificationEmail, MagicLinkEmail, NewDeviceEmail,
|
|
14
|
-
* OrganizationInvitationEmail, OtpEmail, PasswordChangedEmail,
|
|
15
|
-
* ResetPasswordEmail) into a single object for convenient bulk customization.
|
|
16
|
-
*/
|
|
17
|
-
export const emailLocalization = {
|
|
18
|
-
...EmailChangedEmail.localization,
|
|
19
|
-
...EmailVerificationEmail.localization,
|
|
20
|
-
...MagicLinkEmail.localization,
|
|
21
|
-
...NewDeviceEmail.localization,
|
|
22
|
-
...OrganizationInvitationEmail.localization,
|
|
23
|
-
...OtpEmail.localization,
|
|
24
|
-
...PasswordChangedEmail.localization,
|
|
25
|
-
...ResetPasswordEmail.localization
|
|
26
|
-
};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Default color scheme for email templates in light and dark modes.
|
|
4
|
-
*
|
|
5
|
-
* Provides a consistent color palette that can be customized via the EmailColors type.
|
|
6
|
-
*/
|
|
7
|
-
export const defaultColors = {
|
|
8
|
-
light: {
|
|
9
|
-
background: "#F5F5F5",
|
|
10
|
-
border: "#E5E5E5",
|
|
11
|
-
card: "#FFFFFF",
|
|
12
|
-
cardForeground: "#0A0A0A",
|
|
13
|
-
foreground: "#262626",
|
|
14
|
-
muted: "#F5F5F5",
|
|
15
|
-
mutedForeground: "#737373",
|
|
16
|
-
primary: "#171717",
|
|
17
|
-
primaryForeground: "#FAFAFA"
|
|
18
|
-
},
|
|
19
|
-
dark: {
|
|
20
|
-
background: "#0A0A0A",
|
|
21
|
-
border: "#2E2E2E",
|
|
22
|
-
card: "#171717",
|
|
23
|
-
cardForeground: "#FAFAFA",
|
|
24
|
-
foreground: "#D4D4D4",
|
|
25
|
-
muted: "#212121",
|
|
26
|
-
mutedForeground: "#A1A1A1",
|
|
27
|
-
primary: "#E5E5E5",
|
|
28
|
-
primaryForeground: "#171717"
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Component that injects CSS styles for email templates with support for light and dark modes.
|
|
33
|
-
*
|
|
34
|
-
* Generates inline styles that adapt to the user's color scheme preference and applies
|
|
35
|
-
* custom colors if provided. Handles logo visibility switching between light and dark modes.
|
|
36
|
-
*
|
|
37
|
-
* @param props - Style configuration options
|
|
38
|
-
* @returns A style element containing CSS for email template theming
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```tsx
|
|
42
|
-
* <EmailStyles
|
|
43
|
-
* colors={{
|
|
44
|
-
* light: { primary: "#000000" },
|
|
45
|
-
* dark: { primary: "#FFFFFF" }
|
|
46
|
-
* }}
|
|
47
|
-
* darkMode={true}
|
|
48
|
-
* />
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export const EmailStyles = ({ colors, darkMode = true }) => {
|
|
52
|
-
return (_jsx("style", { type: "text/css", children: `
|
|
53
|
-
.bg-background {
|
|
54
|
-
background-color: ${colors?.light?.background || defaultColors.light.background} !important;
|
|
55
|
-
}
|
|
56
|
-
.bg-card {
|
|
57
|
-
background-color: ${colors?.light?.card || defaultColors.light.card} !important;
|
|
58
|
-
}
|
|
59
|
-
.bg-primary {
|
|
60
|
-
background-color: ${colors?.light?.primary || defaultColors.light.primary} !important;
|
|
61
|
-
}
|
|
62
|
-
.bg-muted {
|
|
63
|
-
background-color: ${colors?.light?.muted || defaultColors.light.muted} !important;
|
|
64
|
-
}
|
|
65
|
-
.border-border {
|
|
66
|
-
border-color: ${colors?.light?.border || defaultColors.light.border} !important;
|
|
67
|
-
}
|
|
68
|
-
.text-card-foreground {
|
|
69
|
-
color: ${colors?.light?.cardForeground || defaultColors.light.cardForeground} !important;
|
|
70
|
-
}
|
|
71
|
-
.text-muted-foreground {
|
|
72
|
-
color: ${colors?.light?.mutedForeground || defaultColors.light.mutedForeground} !important;
|
|
73
|
-
}
|
|
74
|
-
.text-primary {
|
|
75
|
-
color: ${colors?.light?.primary || defaultColors.light.primary} !important;
|
|
76
|
-
}
|
|
77
|
-
.text-primary-foreground {
|
|
78
|
-
color: ${colors?.light?.primaryForeground || defaultColors.light.primaryForeground} !important;
|
|
79
|
-
}
|
|
80
|
-
.logo-dark {
|
|
81
|
-
display: none !important;
|
|
82
|
-
}
|
|
83
|
-
.logo-light {
|
|
84
|
-
display: block !important;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
${darkMode
|
|
88
|
-
? `@media (prefers-color-scheme: dark) {
|
|
89
|
-
.bg-background {
|
|
90
|
-
background-color: ${colors?.dark?.background || defaultColors.dark.background} !important;
|
|
91
|
-
}
|
|
92
|
-
.bg-card {
|
|
93
|
-
background-color: ${colors?.dark?.card || defaultColors.dark.card} !important;
|
|
94
|
-
}
|
|
95
|
-
.bg-primary {
|
|
96
|
-
background-color: ${colors?.dark?.primary || defaultColors.dark.primary} !important;
|
|
97
|
-
}
|
|
98
|
-
.bg-muted {
|
|
99
|
-
background-color: ${colors?.dark?.muted || defaultColors.dark.muted} !important;
|
|
100
|
-
}
|
|
101
|
-
.border-border {
|
|
102
|
-
border-color: ${colors?.dark?.border || defaultColors.dark.border} !important;
|
|
103
|
-
}
|
|
104
|
-
.text-card-foreground {
|
|
105
|
-
color: ${colors?.dark?.cardForeground || defaultColors.dark.cardForeground} !important;
|
|
106
|
-
}
|
|
107
|
-
.text-muted-foreground {
|
|
108
|
-
color: ${colors?.dark?.mutedForeground || defaultColors.dark.mutedForeground} !important;
|
|
109
|
-
}
|
|
110
|
-
.text-primary {
|
|
111
|
-
color: ${colors?.dark?.primary || defaultColors.dark.primary} !important;
|
|
112
|
-
}
|
|
113
|
-
.text-primary-foreground {
|
|
114
|
-
color: ${colors?.dark?.primaryForeground || defaultColors.dark.primaryForeground} !important;
|
|
115
|
-
}
|
|
116
|
-
.logo-dark {
|
|
117
|
-
display: block !important;
|
|
118
|
-
}
|
|
119
|
-
.logo-light {
|
|
120
|
-
display: none !important;
|
|
121
|
-
}
|
|
122
|
-
* {
|
|
123
|
-
box-shadow: none !important;
|
|
124
|
-
}
|
|
125
|
-
}`
|
|
126
|
-
: ""}
|
|
127
|
-
` }));
|
|
128
|
-
};
|
|
129
|
-
export default EmailStyles;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Body, Button, Container, Head, Heading, Hr, Html, Img, Link, Preview, pixelBasedPreset, Section, Tailwind, Text } from "@react-email/components";
|
|
3
|
-
import { cn } from "../../../lib/utils";
|
|
4
|
-
import { EmailStyles } from "./email-styles";
|
|
5
|
-
const emailVerificationEmailLocalization = {
|
|
6
|
-
VERIFY_YOUR_EMAIL_ADDRESS: "Verify your email address",
|
|
7
|
-
LOGO: "Logo",
|
|
8
|
-
CLICK_BUTTON_TO_VERIFY_EMAIL: "Click the button below to verify your email address {emailAddress} for your {appName} account.",
|
|
9
|
-
VERIFY_EMAIL_ADDRESS: "Verify email address",
|
|
10
|
-
OR_COPY_AND_PASTE_URL: "Or copy and paste this URL into your browser:",
|
|
11
|
-
THIS_LINK_EXPIRES_IN_MINUTES: "This link expires in {expirationMinutes} minutes.",
|
|
12
|
-
EMAIL_SENT_BY: "Email sent by {appName}.",
|
|
13
|
-
IF_YOU_DIDNT_REQUEST_THIS_EMAIL: "If you didn't request this email, you can safely ignore it. Someone else might have typed your email address by mistake.",
|
|
14
|
-
POWERED_BY_BETTER_AUTH: "Powered by {betterAuth}"
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Email template component that sends email verification links to users.
|
|
18
|
-
*
|
|
19
|
-
* This email includes:
|
|
20
|
-
* - Verification button and fallback URL
|
|
21
|
-
* - Expiration time information
|
|
22
|
-
* - Security notice for unauthorized requests
|
|
23
|
-
* - Customizable branding and styling
|
|
24
|
-
* - Support for light/dark mode themes
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```tsx
|
|
28
|
-
* <EmailVerificationEmail
|
|
29
|
-
* url="https://example.com/verify?token=abc123"
|
|
30
|
-
* email="user@example.com"
|
|
31
|
-
* appName="My App"
|
|
32
|
-
* expirationMinutes={60}
|
|
33
|
-
* logoURL="https://example.com/logo.png"
|
|
34
|
-
* darkMode={true}
|
|
35
|
-
* />
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export const EmailVerificationEmail = ({ url, email, appName, expirationMinutes = 60, logoURL, colors, classNames, darkMode = true, poweredBy, head, ...props }) => {
|
|
39
|
-
const localization = {
|
|
40
|
-
...EmailVerificationEmail.localization,
|
|
41
|
-
...props.localization
|
|
42
|
-
};
|
|
43
|
-
const previewText = localization.VERIFY_YOUR_EMAIL_ADDRESS;
|
|
44
|
-
return (_jsxs(Html, { children: [_jsxs(Head, { children: [_jsx("meta", { content: "light dark", name: "color-scheme" }), _jsx("meta", { content: "light dark", name: "supported-color-schemes" }), _jsx(EmailStyles, { colors: colors, darkMode: darkMode }), head] }), _jsx(Preview, { children: previewText }), _jsx(Tailwind, { config: { presets: [pixelBasedPreset] }, children: _jsx(Body, { className: cn("bg-background font-sans", classNames?.body), children: _jsx(Container, { className: cn("mx-auto my-auto max-w-xl px-2 py-10", classNames?.container), children: _jsxs(Section, { className: cn("bg-card text-card-foreground rounded-none border border-border p-8", classNames?.card), children: [logoURL &&
|
|
45
|
-
(typeof logoURL === "string" ? (_jsx(Img, { src: logoURL, width: 48, height: 48, alt: appName || localization.LOGO, className: cn("mx-auto mb-8", classNames?.logo) })) : (_jsxs(_Fragment, { children: [_jsx(Img, { src: logoURL.light, width: 48, height: 48, alt: appName || localization.LOGO, className: cn("mx-auto mb-8 logo-light", classNames?.logo) }), _jsx(Img, { src: logoURL.dark, width: 48, height: 48, alt: appName || localization.LOGO, className: cn("hidden mx-auto mb-8 logo-dark", classNames?.logo) })] }))), _jsx(Heading, { className: cn("m-0 mb-5 text-2xl font-semibold", classNames?.title), children: localization.VERIFY_EMAIL_ADDRESS }), _jsx(Text, { className: cn("text-sm font-normal", classNames?.content), children: (() => {
|
|
46
|
-
const textWithAppName = localization.CLICK_BUTTON_TO_VERIFY_EMAIL.replace("{appName}", appName || "")
|
|
47
|
-
.replace(/\s{2,}/g, " ")
|
|
48
|
-
.replace(" .", ".");
|
|
49
|
-
const [beforeEmailAddress, afterEmailAddress] = textWithAppName.split("{emailAddress}");
|
|
50
|
-
return email ? (_jsxs(_Fragment, { children: [beforeEmailAddress, _jsx(Link, { href: `mailto:${email}`, className: "text-primary font-medium", children: email }), afterEmailAddress] })) : (textWithAppName
|
|
51
|
-
.replace("{emailAddress}", "")
|
|
52
|
-
.replace(/\s{2,}/g, " ")
|
|
53
|
-
.replace(" .", "."));
|
|
54
|
-
})() }), _jsx(Section, { className: "my-6", children: _jsx(Button, { href: url, className: cn("inline-block whitespace-nowrap rounded-none text-sm font-medium py-2.5 px-6 bg-primary text-primary-foreground no-underline", classNames?.button), children: localization.VERIFY_EMAIL_ADDRESS }) }), _jsx(Text, { className: cn("mb-3 text-xs text-muted-foreground", classNames?.description), children: localization.OR_COPY_AND_PASTE_URL }), _jsx(Link, { className: cn("break-all text-xs text-primary", classNames?.link), href: url, children: url }), _jsx(Hr, { className: cn("my-6 w-full border border-solid border-border", classNames?.separator) }), expirationMinutes || appName ? (_jsxs(Text, { className: cn("mb-3 text-xs text-muted-foreground", classNames?.description), children: [expirationMinutes
|
|
55
|
-
? localization.THIS_LINK_EXPIRES_IN_MINUTES.replace("{expirationMinutes}", expirationMinutes.toString())
|
|
56
|
-
: null, appName && (_jsxs(_Fragment, { children: [expirationMinutes ? " " : "", localization.EMAIL_SENT_BY.replace("{appName}", appName)] }))] })) : null, _jsx(Text, { className: cn("mt-3 text-xs text-muted-foreground", classNames?.description), children: localization.IF_YOU_DIDNT_REQUEST_THIS_EMAIL }), poweredBy && (_jsx(Text, { className: cn("mt-4 mb-0 text-center text-[11px] text-muted-foreground", classNames?.poweredBy), children: (() => {
|
|
57
|
-
const [beforeBetterAuth, afterBetterAuth] = localization.POWERED_BY_BETTER_AUTH.split("{betterAuth}");
|
|
58
|
-
return (_jsxs(_Fragment, { children: [beforeBetterAuth, _jsx(Link, { href: "https://better-auth.com", className: cn("text-primary underline", classNames?.link), children: "better-auth" }), afterBetterAuth] }));
|
|
59
|
-
})() }))] }) }) }) })] }));
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Default localization strings for the email verification template.
|
|
63
|
-
* Can be overridden via the `localization` prop.
|
|
64
|
-
*/
|
|
65
|
-
EmailVerificationEmail.localization = emailVerificationEmailLocalization;
|
|
66
|
-
/**
|
|
67
|
-
* Example props for previewing the email template in development.
|
|
68
|
-
*/
|
|
69
|
-
EmailVerificationEmail.PreviewProps = {
|
|
70
|
-
url: "https://better-auth-ui.com/auth/verify-email?token=example-token",
|
|
71
|
-
appName: "Better Auth",
|
|
72
|
-
email: "m@example.com",
|
|
73
|
-
darkMode: true
|
|
74
|
-
};
|
|
75
|
-
export default EmailVerificationEmail;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./email-changed";
|
|
2
|
-
export * from "./email-localization";
|
|
3
|
-
export * from "./email-styles";
|
|
4
|
-
export * from "./email-verification";
|
|
5
|
-
export * from "./magic-link";
|
|
6
|
-
export * from "./new-device";
|
|
7
|
-
export * from "./organization-invitation";
|
|
8
|
-
export * from "./otp-email";
|
|
9
|
-
export * from "./password-changed";
|
|
10
|
-
export * from "./reset-password";
|